@formio/js 5.2.1-dev.6202.2449b29 → 5.2.1-dev.6228.7172789
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/Changelog.md +25 -0
- 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 +10 -10
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +11 -11
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +2 -2
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Element.js +2 -2
- package/lib/cjs/Embed.js +1 -1
- package/lib/cjs/Formio.js +1 -1
- package/lib/cjs/WebformBuilder.d.ts +1 -0
- package/lib/cjs/WebformBuilder.js +15 -0
- package/lib/cjs/Wizard.js +2 -6
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +4 -2
- package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -2
- package/lib/cjs/components/form/Form.d.ts +2 -1
- package/lib/cjs/components/form/Form.js +32 -20
- package/lib/cjs/components/select/Select.js +1 -1
- package/lib/cjs/components/tags/Tags.js +7 -0
- package/lib/cjs/formio.form.d.ts +2 -1
- package/lib/cjs/formio.form.js +2 -1
- package/lib/cjs/utils/index.d.ts +3 -2
- package/lib/cjs/utils/index.js +2 -1
- package/lib/mjs/Element.js +2 -2
- package/lib/mjs/Embed.js +1 -1
- package/lib/mjs/Formio.js +1 -1
- package/lib/mjs/WebformBuilder.d.ts +1 -0
- package/lib/mjs/WebformBuilder.js +14 -0
- package/lib/mjs/Wizard.js +2 -6
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +4 -2
- package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -2
- package/lib/mjs/components/form/Form.d.ts +2 -1
- package/lib/mjs/components/form/Form.js +32 -20
- package/lib/mjs/components/select/Select.js +1 -1
- package/lib/mjs/components/tags/Tags.js +7 -0
- package/lib/mjs/formio.form.d.ts +2 -1
- package/lib/mjs/formio.form.js +2 -2
- package/lib/mjs/utils/index.d.ts +3 -2
- package/lib/mjs/utils/index.js +2 -2
- package/package.json +1 -1
@@ -20,7 +20,7 @@
|
|
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
|
-
/*! formiojs v5.2.1-rc.
|
23
|
+
/*! formiojs v5.2.1-rc.14 | https://unpkg.com/formiojs@5.2.1-rc.14/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.js
CHANGED
@@ -531,9 +531,9 @@ class Element {
|
|
531
531
|
if (this.component.filter === string && !this.options.building) {
|
532
532
|
const evalContext = this.evalContext(data);
|
533
533
|
evalContext.data = lodash_1.default.mapValues(evalContext.data, (val) => lodash_1.default.isString(val) ? encodeURIComponent(val) : val);
|
534
|
-
return utils_1.default.
|
534
|
+
return utils_1.default.interpolate(string, evalContext, options);
|
535
535
|
}
|
536
|
-
return utils_1.default.
|
536
|
+
return utils_1.default.interpolate(string, this.evalContext(data), options);
|
537
537
|
}
|
538
538
|
/**
|
539
539
|
* Performs an evaluation using the evaluation context of this component.
|
package/lib/cjs/Embed.js
CHANGED
@@ -418,7 +418,7 @@ Formio.formioReady = new Promise((ready, reject) => {
|
|
418
418
|
_a._formioReady = ready;
|
419
419
|
_a._formioReadyReject = reject;
|
420
420
|
});
|
421
|
-
Formio.version = '5.2.1-rc.
|
421
|
+
Formio.version = '5.2.1-rc.14';
|
422
422
|
// Create a report.
|
423
423
|
Formio.Report = {
|
424
424
|
create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
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.2.1-rc.
|
14
|
+
sdk_1.Formio.version = '5.2.1-rc.14';
|
15
15
|
CDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
|
16
16
|
const isNil = (val) => val === null || val === undefined;
|
17
17
|
sdk_1.Formio.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
|
@@ -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
|
findComponentsWithRepeatablePaths(): any[];
|
81
82
|
highlightInvalidComponents(): void;
|
82
83
|
/**
|
@@ -1089,6 +1089,17 @@ class WebformBuilder extends Component_1.default {
|
|
1089
1089
|
'fields.month.required',
|
1090
1090
|
'fields.year.required',
|
1091
1091
|
]));
|
1092
|
+
if (defaultValueComponent.component.components) {
|
1093
|
+
if (!this.originalDefaultValue) {
|
1094
|
+
this.originalDefaultValue = (0, utils_1.fastCloneDeep)(defaultValueComponent.component);
|
1095
|
+
}
|
1096
|
+
(0, utils_1.eachComponent)(defaultValueComponent.component.components, (comp => {
|
1097
|
+
var _a;
|
1098
|
+
if ((_a = comp.validate) === null || _a === void 0 ? void 0 : _a.required) {
|
1099
|
+
comp.validate.required = false;
|
1100
|
+
}
|
1101
|
+
}));
|
1102
|
+
}
|
1092
1103
|
const parentComponent = defaultValueComponent.parent;
|
1093
1104
|
let tabIndex = -1;
|
1094
1105
|
let index = -1;
|
@@ -1198,6 +1209,10 @@ class WebformBuilder extends Component_1.default {
|
|
1198
1209
|
if (index !== -1) {
|
1199
1210
|
let submissionData = this.editForm.submission.data;
|
1200
1211
|
submissionData = submissionData.componentJson || submissionData;
|
1212
|
+
if (submissionData.components && this.originalDefaultValue) {
|
1213
|
+
submissionData.components = this.originalDefaultValue.components;
|
1214
|
+
this.originalDefaultValue = null;
|
1215
|
+
}
|
1201
1216
|
const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
|
1202
1217
|
this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
|
1203
1218
|
this.hook('beforeSaveComponentSettings', submissionData);
|
package/lib/cjs/Wizard.js
CHANGED
@@ -599,7 +599,7 @@ class Wizard extends Webform_1.default {
|
|
599
599
|
if (!this._seenPages.includes(parentNum)) {
|
600
600
|
this._seenPages = this._seenPages.concat(parentNum);
|
601
601
|
}
|
602
|
-
this.redraw().then(() => {
|
602
|
+
return this.redraw().then(() => {
|
603
603
|
this.checkData(this.submission.data);
|
604
604
|
this.triggerCaptcha(this.currentPage.components);
|
605
605
|
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
@@ -607,7 +607,6 @@ class Wizard extends Webform_1.default {
|
|
607
607
|
this.showErrors(errors, true, true);
|
608
608
|
}
|
609
609
|
});
|
610
|
-
return Promise.resolve();
|
611
610
|
}
|
612
611
|
else if (!this.pages.length) {
|
613
612
|
this.redraw();
|
@@ -936,10 +935,7 @@ class Wizard extends Webform_1.default {
|
|
936
935
|
if (pageIndex >= 0) {
|
937
936
|
const page = this.pages[pageIndex];
|
938
937
|
if (page && page !== this.currentPage) {
|
939
|
-
return this.setPage(pageIndex).then(() =>
|
940
|
-
this.showErrors(this.validate(this.localData, { dirty: true }));
|
941
|
-
super.focusOnComponent(key);
|
942
|
-
});
|
938
|
+
return this.setPage(pageIndex).then(() => super.focusOnComponent(key));
|
943
939
|
}
|
944
940
|
}
|
945
941
|
}
|
@@ -155,7 +155,7 @@ export default class NestedComponent extends Field {
|
|
155
155
|
* @param {import('@formio/core').Component[]} components - The components to attach logic to.
|
156
156
|
*/
|
157
157
|
attachComponentsLogic(components: import('@formio/core').Component[]): void;
|
158
|
-
attachComponents(element: any, components: any, container: any): Promise<any>;
|
158
|
+
attachComponents(element: any, components: any, container: any): Promise<void> | Promise<any[]>;
|
159
159
|
/**
|
160
160
|
* Remove a component from the components array and from the children object
|
161
161
|
* @param {import('@formio/core').Component} component - The component to remove from the components.
|
@@ -538,8 +538,7 @@ class NestedComponent extends Field_1.default {
|
|
538
538
|
container = container || this.component.components;
|
539
539
|
element = this.hook('attachComponents', element, components, container, this);
|
540
540
|
if (!element) {
|
541
|
-
|
542
|
-
return (new Promise(() => { }));
|
541
|
+
return Promise.resolve();
|
543
542
|
}
|
544
543
|
let index = 0;
|
545
544
|
const promises = [];
|
@@ -840,6 +839,9 @@ class NestedComponent extends Field_1.default {
|
|
840
839
|
}
|
841
840
|
}
|
842
841
|
setValue(value, flags = {}) {
|
842
|
+
if (!value) {
|
843
|
+
return false;
|
844
|
+
}
|
843
845
|
// If the value is equal to the empty value, then this means we need to reset the values.
|
844
846
|
if (lodash_1.default.isEqual(value, this.emptyValue)) {
|
845
847
|
// TO-DO: For a future major release, we need to investigate removing the need for the
|
@@ -73,10 +73,10 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
73
73
|
rowIndex: any;
|
74
74
|
} | undefined;
|
75
75
|
emptyRow: any;
|
76
|
-
addRowModal(rowIndex: any): Promise<any>;
|
76
|
+
addRowModal(rowIndex: any): Promise<void> | Promise<any[]>;
|
77
77
|
alert: Alert | null | undefined;
|
78
78
|
showDialog(rowIndex: any): Promise<any>;
|
79
|
-
editRow(rowIndex: any): Promise<any>;
|
79
|
+
editRow(rowIndex: any): Promise<void> | Promise<any[]>;
|
80
80
|
clearErrors(rowIndex: any): void;
|
81
81
|
cancelRow(rowIndex: any): void;
|
82
82
|
saveRow(rowIndex: any, modified: any): boolean | undefined;
|
@@ -29,7 +29,7 @@ export default class FormComponent extends Component {
|
|
29
29
|
* Prints out the value of form components as a datagrid value.
|
30
30
|
*/
|
31
31
|
getValueAsString(value: any, options: any): any;
|
32
|
-
attach(element: any): Promise<
|
32
|
+
attach(element: any): Promise<any>;
|
33
33
|
get hasLoadedForm(): any;
|
34
34
|
get isRevisionChanged(): any;
|
35
35
|
get subFormData(): any;
|
@@ -42,6 +42,7 @@ export default class FormComponent extends Component {
|
|
42
42
|
everyComponent(...args: any[]): any;
|
43
43
|
setSubFormDisabled(subForm: any): void;
|
44
44
|
updateSubWizards(subForm: any): void;
|
45
|
+
setComponentsMap(): void;
|
45
46
|
/**
|
46
47
|
* Create a subform instance.
|
47
48
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
@@ -289,29 +289,35 @@ class FormComponent extends Component_1.default {
|
|
289
289
|
return;
|
290
290
|
}
|
291
291
|
this.setContent(element, this.render());
|
292
|
+
const postAttach = () => {
|
293
|
+
if (!this.builderMode && this.component.modalEdit) {
|
294
|
+
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
295
|
+
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
296
|
+
this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
297
|
+
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
298
|
+
this.setOpenModalElement();
|
299
|
+
}
|
300
|
+
this.calculateValue();
|
301
|
+
};
|
292
302
|
if (this.subForm) {
|
293
303
|
if (this.isNestedWizard) {
|
294
304
|
element = this.root.element;
|
295
305
|
}
|
296
|
-
this.subForm.attach(element)
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
306
|
+
return this.subForm.attach(element).then(() => {
|
307
|
+
this.valueChanged = this.hasSetValue;
|
308
|
+
if (!this.shouldConditionallyClear()) {
|
309
|
+
if (!this.valueChanged && this.dataValue.state !== 'submitted') {
|
310
|
+
this.setDefaultValue();
|
311
|
+
}
|
312
|
+
else {
|
313
|
+
this.restoreValue();
|
314
|
+
}
|
304
315
|
}
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
309
|
-
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
310
|
-
this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
311
|
-
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
312
|
-
this.setOpenModalElement();
|
316
|
+
postAttach();
|
317
|
+
this.setComponentsMap();
|
318
|
+
});
|
313
319
|
}
|
314
|
-
|
320
|
+
postAttach();
|
315
321
|
});
|
316
322
|
});
|
317
323
|
}
|
@@ -389,6 +395,14 @@ class FormComponent extends Component_1.default {
|
|
389
395
|
this.emit('subWizardsUpdated', subForm);
|
390
396
|
}
|
391
397
|
}
|
398
|
+
setComponentsMap() {
|
399
|
+
if (!this.subForm) {
|
400
|
+
return;
|
401
|
+
}
|
402
|
+
const componentsMap = this.componentsMap;
|
403
|
+
const formComponentsMap = this.subForm.componentsMap;
|
404
|
+
lodash_1.default.assign(componentsMap, formComponentsMap);
|
405
|
+
}
|
392
406
|
/**
|
393
407
|
* Create a subform instance.
|
394
408
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
@@ -414,9 +428,7 @@ class FormComponent extends Component_1.default {
|
|
414
428
|
this.subForm = instance;
|
415
429
|
this.subForm.currentForm = this;
|
416
430
|
this.subForm.parentVisible = this.visible;
|
417
|
-
|
418
|
-
const formComponentsMap = this.subForm.componentsMap;
|
419
|
-
lodash_1.default.assign(componentsMap, formComponentsMap);
|
431
|
+
this.setComponentsMap();
|
420
432
|
this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
|
421
433
|
this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
|
422
434
|
this.subForm.on('change', () => {
|
@@ -1123,7 +1123,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
1123
1123
|
}
|
1124
1124
|
// Choices will return undefined if nothing is selected. We really want '' to be empty.
|
1125
1125
|
if (value === undefined || value === null) {
|
1126
|
-
value =
|
1126
|
+
value = this.emptyValue;
|
1127
1127
|
}
|
1128
1128
|
return value;
|
1129
1129
|
}
|
@@ -160,6 +160,13 @@ class TagsComponent extends Input_1.default {
|
|
160
160
|
this.refs.input[0].parentNode.lastChild.focus();
|
161
161
|
}
|
162
162
|
}
|
163
|
+
getValue() {
|
164
|
+
if (this.choices) {
|
165
|
+
const value = this.choices.getValue(true);
|
166
|
+
return value.join(`${this.delimiter}`);
|
167
|
+
}
|
168
|
+
return super.getValue();
|
169
|
+
}
|
163
170
|
getValueAsString(value) {
|
164
171
|
if (!value) {
|
165
172
|
return '';
|
package/lib/cjs/formio.form.d.ts
CHANGED
@@ -23,4 +23,5 @@ import { Formio } from './Formio';
|
|
23
23
|
import Licenses from './licenses';
|
24
24
|
import EventEmitter from './EventEmitter';
|
25
25
|
import Webform from './Webform';
|
26
|
-
|
26
|
+
import { DefaultEvaluator } from './utils';
|
27
|
+
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
|
package/lib/cjs/formio.form.js
CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.Webform = exports.EventEmitter = exports.Licenses = exports.Formio = exports.Form = exports.Utils = exports.Templates = exports.Widgets = exports.Providers = exports.Displays = exports.Components = exports.FormioCore = exports.useModule = exports.registerModule = void 0;
|
6
|
+
exports.DefaultEvaluator = exports.Webform = exports.EventEmitter = exports.Licenses = exports.Formio = exports.Form = exports.Utils = exports.Templates = exports.Widgets = exports.Providers = exports.Displays = exports.Components = exports.FormioCore = exports.useModule = exports.registerModule = void 0;
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
8
8
|
const Formio_1 = require("./Formio");
|
9
9
|
Object.defineProperty(exports, "Formio", { enumerable: true, get: function () { return Formio_1.Formio; } });
|
@@ -29,6 +29,7 @@ exports.EventEmitter = EventEmitter_1.default;
|
|
29
29
|
const Webform_1 = __importDefault(require("./Webform"));
|
30
30
|
exports.Webform = Webform_1.default;
|
31
31
|
const utils_2 = require("./utils");
|
32
|
+
Object.defineProperty(exports, "DefaultEvaluator", { enumerable: true, get: function () { return utils_2.DefaultEvaluator; } });
|
32
33
|
Formio_1.Formio.loadModules = (path = `${Formio_1.Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
|
33
34
|
Formio_1.Formio.requireLibrary(name, name, path, true)
|
34
35
|
.then((modules) => {
|
package/lib/cjs/utils/index.d.ts
CHANGED
@@ -2,7 +2,7 @@ export * from "./utils";
|
|
2
2
|
export * from "./formUtils";
|
3
3
|
export default FormioUtils;
|
4
4
|
declare const FormioUtils: {
|
5
|
-
Evaluator:
|
5
|
+
Evaluator: DefaultEvaluator;
|
6
6
|
interpolate: typeof interpolate;
|
7
7
|
ConditionOperators: {
|
8
8
|
[x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
|
@@ -163,6 +163,7 @@ declare const FormioUtils: {
|
|
163
163
|
};
|
164
164
|
import { Evaluator } from './Evaluator';
|
165
165
|
import { registerEvaluator } from './Evaluator';
|
166
|
+
import { DefaultEvaluator } from './Evaluator';
|
166
167
|
import { interpolate } from './Evaluator';
|
167
168
|
import moment from 'moment';
|
168
|
-
export { FormioUtils as Utils, Evaluator, registerEvaluator };
|
169
|
+
export { FormioUtils as Utils, Evaluator, registerEvaluator, DefaultEvaluator };
|
package/lib/cjs/utils/index.js
CHANGED
@@ -29,12 +29,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
30
30
|
};
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
32
|
-
exports.registerEvaluator = exports.Evaluator = exports.Utils = void 0;
|
32
|
+
exports.DefaultEvaluator = exports.registerEvaluator = exports.Evaluator = exports.Utils = void 0;
|
33
33
|
const utils = __importStar(require("./utils"));
|
34
34
|
const formUtils = __importStar(require("./formUtils"));
|
35
35
|
const Evaluator_1 = require("./Evaluator");
|
36
36
|
Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
|
37
37
|
Object.defineProperty(exports, "registerEvaluator", { enumerable: true, get: function () { return Evaluator_1.registerEvaluator; } });
|
38
|
+
Object.defineProperty(exports, "DefaultEvaluator", { enumerable: true, get: function () { return Evaluator_1.DefaultEvaluator; } });
|
38
39
|
const conditionOperators_1 = __importDefault(require("./conditionOperators"));
|
39
40
|
const lodash_1 = __importDefault(require("lodash"));
|
40
41
|
const moment_1 = __importDefault(require("moment"));
|
package/lib/mjs/Element.js
CHANGED
@@ -523,9 +523,9 @@ export default class Element {
|
|
523
523
|
if (this.component.filter === string && !this.options.building) {
|
524
524
|
const evalContext = this.evalContext(data);
|
525
525
|
evalContext.data = _.mapValues(evalContext.data, (val) => _.isString(val) ? encodeURIComponent(val) : val);
|
526
|
-
return FormioUtils.
|
526
|
+
return FormioUtils.interpolate(string, evalContext, options);
|
527
527
|
}
|
528
|
-
return FormioUtils.
|
528
|
+
return FormioUtils.interpolate(string, this.evalContext(data), options);
|
529
529
|
}
|
530
530
|
/**
|
531
531
|
* Performs an evaluation using the evaluation context of this component.
|
package/lib/mjs/Embed.js
CHANGED
@@ -14,7 +14,7 @@ export class Formio {
|
|
14
14
|
Formio._formioReady = ready;
|
15
15
|
Formio._formioReadyReject = reject;
|
16
16
|
});
|
17
|
-
static version = '5.2.1-rc.
|
17
|
+
static version = '5.2.1-rc.14';
|
18
18
|
static setLicense(license, norecurse = false) {
|
19
19
|
Formio.license = license;
|
20
20
|
if (!norecurse && Formio.FormioClass) {
|
package/lib/mjs/Formio.js
CHANGED
@@ -4,7 +4,7 @@ import CDN from './CDN';
|
|
4
4
|
import Providers from './providers';
|
5
5
|
FormioCore.cdn = new CDN();
|
6
6
|
FormioCore.Providers = Providers;
|
7
|
-
FormioCore.version = '5.2.1-rc.
|
7
|
+
FormioCore.version = '5.2.1-rc.14';
|
8
8
|
CDN.defaultCDN = FormioCore.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
|
9
9
|
const isNil = (val) => val === null || val === undefined;
|
10
10
|
FormioCore.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
|
@@ -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
|
findComponentsWithRepeatablePaths(): any[];
|
81
82
|
highlightInvalidComponents(): void;
|
82
83
|
/**
|
@@ -1073,6 +1073,16 @@ export default class WebformBuilder extends Component {
|
|
1073
1073
|
'fields.month.required',
|
1074
1074
|
'fields.year.required',
|
1075
1075
|
]));
|
1076
|
+
if (defaultValueComponent.component.components) {
|
1077
|
+
if (!this.originalDefaultValue) {
|
1078
|
+
this.originalDefaultValue = fastCloneDeep(defaultValueComponent.component);
|
1079
|
+
}
|
1080
|
+
eachComponent(defaultValueComponent.component.components, (comp => {
|
1081
|
+
if (comp.validate?.required) {
|
1082
|
+
comp.validate.required = false;
|
1083
|
+
}
|
1084
|
+
}));
|
1085
|
+
}
|
1076
1086
|
const parentComponent = defaultValueComponent.parent;
|
1077
1087
|
let tabIndex = -1;
|
1078
1088
|
let index = -1;
|
@@ -1181,6 +1191,10 @@ export default class WebformBuilder extends Component {
|
|
1181
1191
|
if (index !== -1) {
|
1182
1192
|
let submissionData = this.editForm.submission.data;
|
1183
1193
|
submissionData = submissionData.componentJson || submissionData;
|
1194
|
+
if (submissionData.components && this.originalDefaultValue) {
|
1195
|
+
submissionData.components = this.originalDefaultValue.components;
|
1196
|
+
this.originalDefaultValue = null;
|
1197
|
+
}
|
1184
1198
|
const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
|
1185
1199
|
this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
|
1186
1200
|
this.hook('beforeSaveComponentSettings', submissionData);
|
package/lib/mjs/Wizard.js
CHANGED
@@ -591,7 +591,7 @@ export default class Wizard extends Webform {
|
|
591
591
|
if (!this._seenPages.includes(parentNum)) {
|
592
592
|
this._seenPages = this._seenPages.concat(parentNum);
|
593
593
|
}
|
594
|
-
this.redraw().then(() => {
|
594
|
+
return this.redraw().then(() => {
|
595
595
|
this.checkData(this.submission.data);
|
596
596
|
this.triggerCaptcha(this.currentPage.components);
|
597
597
|
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
@@ -599,7 +599,6 @@ export default class Wizard extends Webform {
|
|
599
599
|
this.showErrors(errors, true, true);
|
600
600
|
}
|
601
601
|
});
|
602
|
-
return Promise.resolve();
|
603
602
|
}
|
604
603
|
else if (!this.pages.length) {
|
605
604
|
this.redraw();
|
@@ -924,10 +923,7 @@ export default class Wizard extends Webform {
|
|
924
923
|
if (pageIndex >= 0) {
|
925
924
|
const page = this.pages[pageIndex];
|
926
925
|
if (page && page !== this.currentPage) {
|
927
|
-
return this.setPage(pageIndex).then(() =>
|
928
|
-
this.showErrors(this.validate(this.localData, { dirty: true }));
|
929
|
-
super.focusOnComponent(key);
|
930
|
-
});
|
926
|
+
return this.setPage(pageIndex).then(() => super.focusOnComponent(key));
|
931
927
|
}
|
932
928
|
}
|
933
929
|
}
|
@@ -155,7 +155,7 @@ export default class NestedComponent extends Field {
|
|
155
155
|
* @param {import('@formio/core').Component[]} components - The components to attach logic to.
|
156
156
|
*/
|
157
157
|
attachComponentsLogic(components: import('@formio/core').Component[]): void;
|
158
|
-
attachComponents(element: any, components: any, container: any): Promise<any>;
|
158
|
+
attachComponents(element: any, components: any, container: any): Promise<void> | Promise<any[]>;
|
159
159
|
/**
|
160
160
|
* Remove a component from the components array and from the children object
|
161
161
|
* @param {import('@formio/core').Component} component - The component to remove from the components.
|
@@ -534,8 +534,7 @@ export default class NestedComponent extends Field {
|
|
534
534
|
container = container || this.component.components;
|
535
535
|
element = this.hook('attachComponents', element, components, container, this);
|
536
536
|
if (!element) {
|
537
|
-
|
538
|
-
return (new Promise(() => { }));
|
537
|
+
return Promise.resolve();
|
539
538
|
}
|
540
539
|
let index = 0;
|
541
540
|
const promises = [];
|
@@ -834,6 +833,9 @@ export default class NestedComponent extends Field {
|
|
834
833
|
}
|
835
834
|
}
|
836
835
|
setValue(value, flags = {}) {
|
836
|
+
if (!value) {
|
837
|
+
return false;
|
838
|
+
}
|
837
839
|
// If the value is equal to the empty value, then this means we need to reset the values.
|
838
840
|
if (_.isEqual(value, this.emptyValue)) {
|
839
841
|
// TO-DO: For a future major release, we need to investigate removing the need for the
|
@@ -73,10 +73,10 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
73
73
|
rowIndex: any;
|
74
74
|
} | undefined;
|
75
75
|
emptyRow: any;
|
76
|
-
addRowModal(rowIndex: any): Promise<any>;
|
76
|
+
addRowModal(rowIndex: any): Promise<void> | Promise<any[]>;
|
77
77
|
alert: Alert | null | undefined;
|
78
78
|
showDialog(rowIndex: any): Promise<any>;
|
79
|
-
editRow(rowIndex: any): Promise<any>;
|
79
|
+
editRow(rowIndex: any): Promise<void> | Promise<any[]>;
|
80
80
|
clearErrors(rowIndex: any): void;
|
81
81
|
cancelRow(rowIndex: any): void;
|
82
82
|
saveRow(rowIndex: any, modified: any): boolean | undefined;
|
@@ -29,7 +29,7 @@ export default class FormComponent extends Component {
|
|
29
29
|
* Prints out the value of form components as a datagrid value.
|
30
30
|
*/
|
31
31
|
getValueAsString(value: any, options: any): any;
|
32
|
-
attach(element: any): Promise<
|
32
|
+
attach(element: any): Promise<any>;
|
33
33
|
get hasLoadedForm(): any;
|
34
34
|
get isRevisionChanged(): any;
|
35
35
|
get subFormData(): any;
|
@@ -42,6 +42,7 @@ export default class FormComponent extends Component {
|
|
42
42
|
everyComponent(...args: any[]): any;
|
43
43
|
setSubFormDisabled(subForm: any): void;
|
44
44
|
updateSubWizards(subForm: any): void;
|
45
|
+
setComponentsMap(): void;
|
45
46
|
/**
|
46
47
|
* Create a subform instance.
|
47
48
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
@@ -286,29 +286,35 @@ export default class FormComponent extends Component {
|
|
286
286
|
return;
|
287
287
|
}
|
288
288
|
this.setContent(element, this.render());
|
289
|
+
const postAttach = () => {
|
290
|
+
if (!this.builderMode && this.component.modalEdit) {
|
291
|
+
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
292
|
+
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
293
|
+
this.componentModal = new ComponentModal(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
294
|
+
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
295
|
+
this.setOpenModalElement();
|
296
|
+
}
|
297
|
+
this.calculateValue();
|
298
|
+
};
|
289
299
|
if (this.subForm) {
|
290
300
|
if (this.isNestedWizard) {
|
291
301
|
element = this.root.element;
|
292
302
|
}
|
293
|
-
this.subForm.attach(element)
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
303
|
+
return this.subForm.attach(element).then(() => {
|
304
|
+
this.valueChanged = this.hasSetValue;
|
305
|
+
if (!this.shouldConditionallyClear()) {
|
306
|
+
if (!this.valueChanged && this.dataValue.state !== 'submitted') {
|
307
|
+
this.setDefaultValue();
|
308
|
+
}
|
309
|
+
else {
|
310
|
+
this.restoreValue();
|
311
|
+
}
|
301
312
|
}
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
306
|
-
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
307
|
-
this.componentModal = new ComponentModal(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
308
|
-
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
309
|
-
this.setOpenModalElement();
|
313
|
+
postAttach();
|
314
|
+
this.setComponentsMap();
|
315
|
+
});
|
310
316
|
}
|
311
|
-
|
317
|
+
postAttach();
|
312
318
|
});
|
313
319
|
});
|
314
320
|
}
|
@@ -384,6 +390,14 @@ export default class FormComponent extends Component {
|
|
384
390
|
this.emit('subWizardsUpdated', subForm);
|
385
391
|
}
|
386
392
|
}
|
393
|
+
setComponentsMap() {
|
394
|
+
if (!this.subForm) {
|
395
|
+
return;
|
396
|
+
}
|
397
|
+
const componentsMap = this.componentsMap;
|
398
|
+
const formComponentsMap = this.subForm.componentsMap;
|
399
|
+
_.assign(componentsMap, formComponentsMap);
|
400
|
+
}
|
387
401
|
/**
|
388
402
|
* Create a subform instance.
|
389
403
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
@@ -408,9 +422,7 @@ export default class FormComponent extends Component {
|
|
408
422
|
this.subForm = instance;
|
409
423
|
this.subForm.currentForm = this;
|
410
424
|
this.subForm.parentVisible = this.visible;
|
411
|
-
|
412
|
-
const formComponentsMap = this.subForm.componentsMap;
|
413
|
-
_.assign(componentsMap, formComponentsMap);
|
425
|
+
this.setComponentsMap();
|
414
426
|
this.component.components = this.subForm._form?.components;
|
415
427
|
this.component.display = this.subForm._form?.display;
|
416
428
|
this.subForm.on('change', () => {
|
@@ -1153,7 +1153,7 @@ export default class SelectComponent extends ListComponent {
|
|
1153
1153
|
}
|
1154
1154
|
// Choices will return undefined if nothing is selected. We really want '' to be empty.
|
1155
1155
|
if (value === undefined || value === null) {
|
1156
|
-
value =
|
1156
|
+
value = this.emptyValue;
|
1157
1157
|
}
|
1158
1158
|
return value;
|
1159
1159
|
}
|
@@ -158,6 +158,13 @@ export default class TagsComponent extends Input {
|
|
158
158
|
this.refs.input[0].parentNode.lastChild.focus();
|
159
159
|
}
|
160
160
|
}
|
161
|
+
getValue() {
|
162
|
+
if (this.choices) {
|
163
|
+
const value = this.choices.getValue(true);
|
164
|
+
return value.join(`${this.delimiter}`);
|
165
|
+
}
|
166
|
+
return super.getValue();
|
167
|
+
}
|
161
168
|
getValueAsString(value) {
|
162
169
|
if (!value) {
|
163
170
|
return '';
|
package/lib/mjs/formio.form.d.ts
CHANGED
@@ -23,4 +23,5 @@ import { Formio } from './Formio';
|
|
23
23
|
import Licenses from './licenses';
|
24
24
|
import EventEmitter from './EventEmitter';
|
25
25
|
import Webform from './Webform';
|
26
|
-
|
26
|
+
import { DefaultEvaluator } from './utils';
|
27
|
+
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
|
package/lib/mjs/formio.form.js
CHANGED
@@ -11,7 +11,7 @@ import Utils from './utils';
|
|
11
11
|
import Licenses from './licenses';
|
12
12
|
import EventEmitter from './EventEmitter';
|
13
13
|
import Webform from './Webform';
|
14
|
-
import { Evaluator, registerEvaluator } from './utils';
|
14
|
+
import { Evaluator, registerEvaluator, DefaultEvaluator } from './utils';
|
15
15
|
Formio.loadModules = (path = `${Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
|
16
16
|
Formio.requireLibrary(name, name, path, true)
|
17
17
|
.then((modules) => {
|
@@ -126,4 +126,4 @@ export function useModule(defaultFn = null) {
|
|
126
126
|
Formio.use = useModule();
|
127
127
|
export { Formio as FormioCore } from './Formio';
|
128
128
|
// Export the components.
|
129
|
-
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform };
|
129
|
+
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
|