@formio/js 5.1.0-dev.6040.debc859 → 5.1.0-dev.6042.603237d
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 +99 -310
- package/README.md +7 -0
- package/dist/formio.builder.css +1 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.form.css +1 -0
- package/dist/formio.form.js +661 -672
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -1
- package/dist/formio.full.css +1 -0
- package/dist/formio.full.js +688 -699
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -1
- package/dist/formio.js +90 -68
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +103 -81
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +3 -1
- package/lib/cjs/Element.d.ts +2 -1
- package/lib/cjs/Element.js +18 -39
- 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.d.ts +2 -2
- package/lib/cjs/Webform.js +14 -15
- package/lib/cjs/WebformBuilder.d.ts +1 -0
- package/lib/cjs/WebformBuilder.js +44 -14
- package/lib/cjs/Wizard.d.ts +2 -2
- package/lib/cjs/Wizard.js +41 -27
- package/lib/cjs/WizardBuilder.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +49 -15
- package/lib/cjs/components/_classes/component/Component.js +188 -125
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/utils.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 +3 -3
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +0 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.form.js +13 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.js +17 -25
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -12
- package/lib/cjs/components/address/Address.d.ts +9 -0
- package/lib/cjs/components/address/Address.js +32 -9
- package/lib/cjs/components/address/editForm/Address.edit.display.d.ts +4 -0
- package/lib/cjs/components/address/editForm/Address.edit.display.js +1 -0
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -8
- package/lib/cjs/components/alert/Alert.js +1 -1
- package/lib/cjs/components/button/Button.d.ts +1 -1
- package/lib/cjs/components/button/Button.js +7 -11
- package/lib/cjs/components/checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/container/Container.js +1 -1
- package/lib/cjs/components/content/editForm/Content.edit.display.js +8 -0
- package/lib/cjs/components/currency/Currency.js +1 -1
- package/lib/cjs/components/currency/editForm/Currency.edit.display.js +12 -0
- package/lib/cjs/components/datagrid/DataGrid.js +5 -4
- package/lib/cjs/components/datamap/DataMap.js +2 -6
- package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/cjs/components/datetime/DateTime.js +15 -13
- package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
- package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
- package/lib/cjs/components/day/Day.js +2 -2
- package/lib/cjs/components/day/editForm/Day.edit.display.js +8 -0
- package/lib/cjs/components/editgrid/EditGrid.js +4 -14
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/cjs/components/email/editForm/Email.edit.display.js +12 -0
- package/lib/cjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
- package/lib/cjs/components/file/File.js +6 -2
- package/lib/cjs/components/file/editForm/File.edit.file.d.ts +13 -0
- package/lib/cjs/components/file/editForm/File.edit.file.js +1 -0
- package/lib/cjs/components/form/Form.d.ts +0 -1
- package/lib/cjs/components/form/Form.js +32 -24
- package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
- package/lib/cjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
- package/lib/cjs/components/html/HTML.js +1 -2
- package/lib/cjs/components/html/editForm/HTML.edit.display.js +8 -0
- package/lib/cjs/components/number/Number.js +1 -1
- package/lib/cjs/components/number/editForm/Number.edit.display.js +12 -0
- package/lib/cjs/components/panel/Panel.js +1 -1
- package/lib/cjs/components/password/editForm/Password.edit.display.js +13 -1
- package/lib/cjs/components/phonenumber/PhoneNumber.form.js +9 -1
- package/lib/cjs/components/radio/Radio.d.ts +8 -0
- package/lib/cjs/components/radio/Radio.js +17 -7
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/cjs/components/select/Select.d.ts +1 -0
- package/lib/cjs/components/select/Select.js +21 -5
- package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +68 -110
- package/lib/cjs/components/select/editForm/Select.edit.data.js +3 -38
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/cjs/components/selectboxes/SelectBoxes.js +7 -1
- package/lib/cjs/components/signature/Signature.js +1 -1
- package/lib/cjs/components/survey/Survey.js +2 -2
- package/lib/cjs/components/tabs/Tabs.js +1 -0
- package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
- package/lib/cjs/components/tags/Tags.js +1 -1
- package/lib/cjs/components/textarea/TextArea.js +10 -2
- package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
- package/lib/cjs/components/textfield/TextField.js +9 -32
- package/lib/cjs/components/time/Time.js +1 -1
- package/lib/cjs/components/unknown/Unknown.form.d.ts +2 -1
- package/lib/cjs/components/unknown/Unknown.form.js +13 -9
- package/lib/cjs/components/url/editForm/Url.edit.display.js +12 -0
- package/lib/cjs/components/well/editForm/Well.edit.display.js +8 -0
- package/lib/cjs/formio.form.js +5 -5
- package/lib/cjs/providers/storage/uploadAdapter.js +8 -6
- package/lib/cjs/translations/en.d.ts +1 -234
- package/lib/cjs/translations/en.js +4 -2
- package/lib/cjs/utils/Evaluator.d.ts +20 -6
- package/lib/cjs/utils/Evaluator.js +38 -15
- package/lib/cjs/utils/builder.js +5 -5
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/index.d.ts +169 -2
- package/lib/cjs/utils/index.js +22 -2
- package/lib/cjs/utils/utils.d.ts +31 -45
- package/lib/cjs/utils/utils.js +80 -156
- package/lib/cjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/cjs/widgets/CalendarWidget.js +19 -40
- package/lib/mjs/Element.d.ts +2 -1
- package/lib/mjs/Element.js +11 -9
- 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.d.ts +2 -2
- package/lib/mjs/Webform.js +12 -13
- package/lib/mjs/WebformBuilder.d.ts +1 -0
- package/lib/mjs/WebformBuilder.js +37 -8
- package/lib/mjs/Wizard.d.ts +2 -2
- package/lib/mjs/Wizard.js +39 -25
- package/lib/mjs/WizardBuilder.js +1 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +49 -15
- package/lib/mjs/components/_classes/component/Component.js +161 -75
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/utils.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 +3 -3
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +0 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.form.js +13 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.js +17 -25
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -12
- package/lib/mjs/components/address/Address.d.ts +9 -0
- package/lib/mjs/components/address/Address.js +32 -9
- package/lib/mjs/components/address/editForm/Address.edit.display.d.ts +4 -0
- package/lib/mjs/components/address/editForm/Address.edit.display.js +1 -0
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -8
- package/lib/mjs/components/alert/Alert.js +1 -1
- package/lib/mjs/components/button/Button.d.ts +1 -1
- 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/content/editForm/Content.edit.display.js +8 -0
- package/lib/mjs/components/currency/Currency.js +1 -1
- package/lib/mjs/components/currency/editForm/Currency.edit.display.js +12 -0
- package/lib/mjs/components/datagrid/DataGrid.js +5 -4
- package/lib/mjs/components/datamap/DataMap.js +2 -6
- package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/mjs/components/datetime/DateTime.js +15 -13
- package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
- package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
- package/lib/mjs/components/day/Day.js +2 -2
- package/lib/mjs/components/day/editForm/Day.edit.display.js +8 -0
- package/lib/mjs/components/editgrid/EditGrid.js +4 -13
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/mjs/components/email/editForm/Email.edit.display.js +12 -0
- package/lib/mjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
- package/lib/mjs/components/file/File.js +6 -2
- package/lib/mjs/components/file/editForm/File.edit.file.d.ts +13 -0
- package/lib/mjs/components/file/editForm/File.edit.file.js +1 -0
- package/lib/mjs/components/form/Form.d.ts +0 -1
- package/lib/mjs/components/form/Form.js +31 -24
- package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
- package/lib/mjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
- package/lib/mjs/components/html/HTML.js +1 -2
- package/lib/mjs/components/html/editForm/HTML.edit.display.js +8 -0
- package/lib/mjs/components/number/Number.js +1 -1
- package/lib/mjs/components/number/editForm/Number.edit.display.js +12 -0
- package/lib/mjs/components/panel/Panel.js +1 -1
- package/lib/mjs/components/password/editForm/Password.edit.display.js +13 -1
- package/lib/mjs/components/phonenumber/PhoneNumber.form.js +9 -1
- package/lib/mjs/components/radio/Radio.d.ts +8 -0
- package/lib/mjs/components/radio/Radio.js +17 -7
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/mjs/components/select/Select.d.ts +1 -0
- package/lib/mjs/components/select/Select.js +21 -5
- package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +68 -110
- package/lib/mjs/components/select/editForm/Select.edit.data.js +3 -38
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/mjs/components/selectboxes/SelectBoxes.js +7 -1
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/components/survey/Survey.js +2 -2
- package/lib/mjs/components/tabs/Tabs.js +1 -0
- package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
- package/lib/mjs/components/tags/Tags.js +1 -1
- package/lib/mjs/components/textarea/TextArea.js +10 -2
- package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
- package/lib/mjs/components/textfield/TextField.js +3 -3
- package/lib/mjs/components/time/Time.js +1 -1
- package/lib/mjs/components/unknown/Unknown.form.d.ts +2 -1
- package/lib/mjs/components/unknown/Unknown.form.js +13 -9
- package/lib/mjs/components/url/editForm/Url.edit.display.js +12 -0
- package/lib/mjs/components/well/editForm/Well.edit.display.js +8 -0
- package/lib/mjs/formio.form.js +3 -3
- package/lib/mjs/providers/storage/uploadAdapter.js +8 -6
- package/lib/mjs/translations/en.d.ts +1 -234
- package/lib/mjs/translations/en.js +6 -47
- package/lib/mjs/utils/Evaluator.d.ts +20 -6
- package/lib/mjs/utils/Evaluator.js +31 -13
- package/lib/mjs/utils/builder.js +1 -1
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/index.d.ts +169 -2
- package/lib/mjs/utils/index.js +18 -1
- package/lib/mjs/utils/utils.d.ts +31 -45
- package/lib/mjs/utils/utils.js +72 -129
- package/lib/mjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/mjs/widgets/CalendarWidget.js +19 -40
- package/package.json +8 -6
- package/lib/cjs/i18n.d.ts +0 -13
- package/lib/cjs/i18n.js +0 -19
- package/lib/cjs/utils/i18n.d.ts +0 -19
- package/lib/cjs/utils/i18n.js +0 -120
- package/lib/mjs/i18n.d.ts +0 -13
- package/lib/mjs/i18n.js +0 -14
- package/lib/mjs/utils/i18n.d.ts +0 -19
- package/lib/mjs/utils/i18n.js +0 -112
@@ -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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -42,8 +19,8 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
42
19
|
const ismobilejs_1 = __importDefault(require("ismobilejs"));
|
43
20
|
const process_1 = require("@formio/core/process");
|
44
21
|
const Formio_1 = require("../../../Formio");
|
45
|
-
const
|
46
|
-
const
|
22
|
+
const utils_1 = __importDefault(require("../../../utils"));
|
23
|
+
const utils_2 = require("../../../utils");
|
47
24
|
const Element_1 = __importDefault(require("../../../Element"));
|
48
25
|
const ComponentModal_1 = __importDefault(require("../componentModal/ComponentModal"));
|
49
26
|
const widgets_1 = __importDefault(require("../../../widgets"));
|
@@ -51,7 +28,7 @@ const addons_1 = __importDefault(require("../../../addons"));
|
|
51
28
|
const uploadAdapter_1 = require("../../../providers/storage/uploadAdapter");
|
52
29
|
const en_1 = __importDefault(require("../../../translations/en"));
|
53
30
|
const Templates_1 = __importDefault(require("../../../templates/Templates"));
|
54
|
-
const isIEBrowser =
|
31
|
+
const isIEBrowser = utils_1.default.getBrowserInfo().ie;
|
55
32
|
/**
|
56
33
|
* This is the Component class
|
57
34
|
which all elements within the FormioForm derive from.
|
@@ -225,7 +202,7 @@ class Component extends Element_1.default {
|
|
225
202
|
*/
|
226
203
|
static savedValueTypes(schema) {
|
227
204
|
schema = schema || {};
|
228
|
-
return
|
205
|
+
return utils_1.default.getComponentSavedTypes(schema) || [utils_1.default.componentValueTypes.any];
|
229
206
|
}
|
230
207
|
/**
|
231
208
|
* Provides a table view for this component. Override if you wish to do something different than using getView
|
@@ -292,7 +269,7 @@ class Component extends Element_1.default {
|
|
292
269
|
this.component.id = this.id;
|
293
270
|
this.afterComponentAssign();
|
294
271
|
// Save off the original component to be used in logic.
|
295
|
-
this.originalComponent = (0,
|
272
|
+
this.originalComponent = (0, utils_2.fastCloneDeep)(this.component);
|
296
273
|
/**
|
297
274
|
* If the component has been attached
|
298
275
|
*/
|
@@ -325,7 +302,7 @@ class Component extends Element_1.default {
|
|
325
302
|
* Determines if this component is disabled, or not.
|
326
303
|
* @type {boolean}
|
327
304
|
*/
|
328
|
-
this._disabled = (0,
|
305
|
+
this._disabled = (0, utils_2.boolValue)(this.component.disabled) ? this.component.disabled : false;
|
329
306
|
/**
|
330
307
|
* Points to the root component, usually the FormComponent.
|
331
308
|
* @type {Component}
|
@@ -346,23 +323,16 @@ class Component extends Element_1.default {
|
|
346
323
|
* The component paths for this component.
|
347
324
|
* @type {import('@formio/core').ComponentPaths} - The component paths.
|
348
325
|
*/
|
349
|
-
this.paths =
|
326
|
+
this.paths = utils_1.default.getComponentPaths(this.component, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component, Object.assign(Object.assign({}, (_b = this.parent) === null || _b === void 0 ? void 0 : _b.paths), { dataIndex: this.options.rowIndex === undefined ? (_d = (_c = this.parent) === null || _c === void 0 ? void 0 : _c.paths) === null || _d === void 0 ? void 0 : _d.dataIndex : this.options.rowIndex }));
|
350
327
|
this.options.name = this.options.name || 'data';
|
351
328
|
this._path = '';
|
352
329
|
// Needs for Nextgen Rules Engine
|
353
330
|
this.resetCaches();
|
354
|
-
/**
|
355
|
-
* Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
|
356
|
-
* This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
|
357
|
-
* conditionallyHidden separately from "regular" visibility.
|
358
|
-
*/
|
359
|
-
this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
|
360
|
-
this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
|
361
331
|
/**
|
362
332
|
* Determines if this component is visible, or not.
|
363
333
|
*/
|
364
334
|
this._parentVisible = this.options.hasOwnProperty('parentVisible') ? this.options.parentVisible : true;
|
365
|
-
this._visible = this._parentVisible && (this.hasCondition() ? !this.
|
335
|
+
this._visible = this._parentVisible && (this.hasCondition() ? !this.conditionallyHidden() : !this.component.hidden);
|
366
336
|
this._parentDisabled = false;
|
367
337
|
/**
|
368
338
|
* The reference attribute name for this component
|
@@ -431,7 +401,7 @@ class Component extends Element_1.default {
|
|
431
401
|
if (this.allowData && this.key) {
|
432
402
|
this.options.name += `[${this.key}]`;
|
433
403
|
// If component is visible or not set to clear on hide, set the default value.
|
434
|
-
if (!
|
404
|
+
if (!this.shouldConditionallyClear()) {
|
435
405
|
if (!this.hasValue()) {
|
436
406
|
if (this.shouldAddDefaultValue) {
|
437
407
|
this.dataValue = this.defaultValue;
|
@@ -465,6 +435,45 @@ class Component extends Element_1.default {
|
|
465
435
|
var _a;
|
466
436
|
return ((_a = this.root) === null || _a === void 0 ? void 0 : _a.childComponentsMap) || {};
|
467
437
|
}
|
438
|
+
/**
|
439
|
+
* Returns if the parent should conditionally clear.
|
440
|
+
* @returns {boolean} - If the parent should conditionally clear.
|
441
|
+
*/
|
442
|
+
parentShouldConditionallyClear() {
|
443
|
+
let currentParent = this.parent;
|
444
|
+
while (currentParent) {
|
445
|
+
if ((currentParent.allowData && currentParent._conditionallyClear) ||
|
446
|
+
(!currentParent.allowData && currentParent._conditionallyHidden)) {
|
447
|
+
return true;
|
448
|
+
}
|
449
|
+
currentParent = currentParent.parent;
|
450
|
+
}
|
451
|
+
return false;
|
452
|
+
}
|
453
|
+
parentConditionallyHidden() {
|
454
|
+
let currentParent = this.parent;
|
455
|
+
while (currentParent) {
|
456
|
+
if (currentParent._conditionallyHidden) {
|
457
|
+
return true;
|
458
|
+
}
|
459
|
+
currentParent = currentParent.parent;
|
460
|
+
}
|
461
|
+
return false;
|
462
|
+
}
|
463
|
+
/**
|
464
|
+
* Returns true if any of the parents default their component "hidden" property to true.
|
465
|
+
* @returns {boolean} - If any parent defaults the hidden property to true.
|
466
|
+
*/
|
467
|
+
anyParentDefaultsHidden() {
|
468
|
+
let currentParent = this.parent;
|
469
|
+
while (currentParent) {
|
470
|
+
if (currentParent.component.hidden) {
|
471
|
+
return true;
|
472
|
+
}
|
473
|
+
currentParent = currentParent.parent;
|
474
|
+
}
|
475
|
+
return false;
|
476
|
+
}
|
468
477
|
get data() {
|
469
478
|
return this._data;
|
470
479
|
}
|
@@ -491,7 +500,7 @@ class Component extends Element_1.default {
|
|
491
500
|
label.labelPosition = this.component.labelPosition;
|
492
501
|
label.tooltipClass = `${this.iconClass('question-sign')} text-muted`;
|
493
502
|
const isPDFReadOnlyMode = this.isPDFReadOnlyMode;
|
494
|
-
if (this.hasInput && this.component.validate && (0,
|
503
|
+
if (this.hasInput && this.component.validate && (0, utils_2.boolValue)(this.component.validate.required) && !isPDFReadOnlyMode) {
|
495
504
|
label.className += ' field-required';
|
496
505
|
}
|
497
506
|
if (label.hidden) {
|
@@ -505,8 +514,7 @@ class Component extends Element_1.default {
|
|
505
514
|
init() {
|
506
515
|
var _a;
|
507
516
|
this.disabled = this.shouldDisabled;
|
508
|
-
this.
|
509
|
-
this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
517
|
+
this._visible = (this.hasCondition() ? !this.conditionallyHidden() : !this.component.hidden);
|
510
518
|
if ((_a = this.component.addons) === null || _a === void 0 ? void 0 : _a.length) {
|
511
519
|
this.component.addons.forEach((addon) => this.createAddon(addon));
|
512
520
|
}
|
@@ -525,7 +533,7 @@ class Component extends Element_1.default {
|
|
525
533
|
*/
|
526
534
|
set rowIndex(value) {
|
527
535
|
var _a, _b;
|
528
|
-
this.paths =
|
536
|
+
this.paths = utils_1.default.getComponentPaths(this.component, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component, Object.assign(Object.assign({}, (((_b = this.parent) === null || _b === void 0 ? void 0 : _b.paths) || {})), { dataIndex: value }));
|
529
537
|
this._rowIndex = value;
|
530
538
|
}
|
531
539
|
afterComponentAssign() {
|
@@ -671,20 +679,64 @@ class Component extends Element_1.default {
|
|
671
679
|
}
|
672
680
|
return this._visible && this._parentVisible;
|
673
681
|
}
|
674
|
-
get
|
675
|
-
|
682
|
+
get logicallyHidden() {
|
683
|
+
if (this._logicallyHidden && !this.component.hidden) {
|
684
|
+
this._logicallyHidden = false;
|
685
|
+
}
|
686
|
+
return this._logicallyHidden;
|
676
687
|
}
|
677
688
|
/**
|
678
|
-
*
|
679
|
-
* @
|
680
|
-
* @param {object} row - The row object to evaluate the condition against.
|
681
|
-
* @returns {boolean} - Whether the component is conditionally hidden.
|
689
|
+
* Determines if the component should clear its value when the root form is pristine.
|
690
|
+
* @returns {boolean} - If the component should clear its value when the root form is pristine.
|
682
691
|
*/
|
683
|
-
|
684
|
-
|
685
|
-
|
692
|
+
shouldConditionallyClearOnPristine() {
|
693
|
+
// If the form is pristine, we should NOT clear the value of a conditionally hidden child component
|
694
|
+
// of a layout component that defaults to hidden using the "hidden" component property.
|
695
|
+
return !this.anyParentDefaultsHidden();
|
696
|
+
}
|
697
|
+
/**
|
698
|
+
* Returns if the component should clear its value when conditionally hidden.
|
699
|
+
* @returns {boolean} - If the component should clear its value when conditionally hidden.
|
700
|
+
*/
|
701
|
+
shouldConditionallyClear() {
|
702
|
+
// Skip if this component has clearOnHide set to false.
|
703
|
+
if (this.component.clearOnHide === false) {
|
704
|
+
this._conditionallyClear = false;
|
705
|
+
return this._conditionallyClear;
|
706
|
+
}
|
707
|
+
// If the component is logically hidden, then it is conditionally hidden and should clear.
|
708
|
+
if (this.logicallyHidden) {
|
709
|
+
this._conditionallyClear = true;
|
710
|
+
return this._conditionallyClear;
|
711
|
+
}
|
712
|
+
// If we have a condition and it is not conditionally visible, the it should conditionally clear.
|
713
|
+
if (this.hasCondition() &&
|
714
|
+
!this.conditionallyVisible() &&
|
715
|
+
(!this.rootPristine || this.shouldConditionallyClearOnPristine())) {
|
716
|
+
this._conditionallyClear = true;
|
717
|
+
return this._conditionallyClear;
|
718
|
+
}
|
719
|
+
this._conditionallyClear = this.hasSetValue ? false : this.parentShouldConditionallyClear();
|
720
|
+
return this._conditionallyClear;
|
721
|
+
}
|
722
|
+
/**
|
723
|
+
* Returns if the component is conditionally hidden.
|
724
|
+
* @returns {boolean} - If the component is conditionally hidden.
|
725
|
+
*/
|
726
|
+
conditionallyHidden() {
|
727
|
+
// If it is logically hidden, then it is conditionally hidden.
|
728
|
+
if (this.logicallyHidden) {
|
729
|
+
this._conditionallyHidden = true;
|
730
|
+
return this._conditionallyHidden;
|
686
731
|
}
|
687
|
-
|
732
|
+
// If it has a condition, and is not conditionally visible, then it is conditionally hidden.
|
733
|
+
if (this.hasCondition() && !this.conditionallyVisible()) {
|
734
|
+
this._conditionallyHidden = true;
|
735
|
+
return this._conditionallyHidden;
|
736
|
+
}
|
737
|
+
// It is conditionally hidden if its parent is conditionally hidden.
|
738
|
+
this._conditionallyHidden = this.parentConditionallyHidden();
|
739
|
+
return this._conditionallyHidden;
|
688
740
|
}
|
689
741
|
get currentForm() {
|
690
742
|
return this._currentForm;
|
@@ -801,7 +853,7 @@ class Component extends Element_1.default {
|
|
801
853
|
* @returns {object} - The JSON schema for this component.
|
802
854
|
*/
|
803
855
|
get schema() {
|
804
|
-
return (0,
|
856
|
+
return (0, utils_2.fastCloneDeep)(this.getModifiedSchema(lodash_1.default.omit(this.component, 'id'), this.defaultSchema));
|
805
857
|
}
|
806
858
|
/**
|
807
859
|
* Returns true if component is inside DataGrid
|
@@ -953,7 +1005,7 @@ class Component extends Element_1.default {
|
|
953
1005
|
if (!this.shouldSanitizeValue && !forceSanitize) {
|
954
1006
|
return dirty;
|
955
1007
|
}
|
956
|
-
return
|
1008
|
+
return utils_1.default.sanitize(dirty, {
|
957
1009
|
sanitizeConfig: lodash_1.default.merge(((_a = this.options) === null || _a === void 0 ? void 0 : _a.sanitizeConfig) || {}, options || {}),
|
958
1010
|
});
|
959
1011
|
}
|
@@ -1072,7 +1124,7 @@ class Component extends Element_1.default {
|
|
1072
1124
|
return submissionTimezone;
|
1073
1125
|
}
|
1074
1126
|
// Return current timezone if none are provided.
|
1075
|
-
return (0,
|
1127
|
+
return (0, utils_2.currentTimezone)();
|
1076
1128
|
}
|
1077
1129
|
/**
|
1078
1130
|
*
|
@@ -1377,7 +1429,7 @@ class Component extends Element_1.default {
|
|
1377
1429
|
else {
|
1378
1430
|
this.refreshOnChanged = true;
|
1379
1431
|
}
|
1380
|
-
this.refreshOnValue = (0,
|
1432
|
+
this.refreshOnValue = (0, utils_2.fastCloneDeep)(value);
|
1381
1433
|
if (this.refreshOnChanged) {
|
1382
1434
|
if (this.component.clearOnRefresh) {
|
1383
1435
|
this.setValue(null);
|
@@ -1619,7 +1671,7 @@ class Component extends Element_1.default {
|
|
1619
1671
|
if (this.component.customClass) {
|
1620
1672
|
className += this.component.customClass;
|
1621
1673
|
}
|
1622
|
-
if (this.hasInput && this.component.validate && (0,
|
1674
|
+
if (this.hasInput && this.component.validate && (0, utils_2.boolValue)(this.component.validate.required)) {
|
1623
1675
|
className += ' required';
|
1624
1676
|
}
|
1625
1677
|
if (this.labelIsHidden()) {
|
@@ -1852,7 +1904,7 @@ class Component extends Element_1.default {
|
|
1852
1904
|
rebuild() {
|
1853
1905
|
this.destroy();
|
1854
1906
|
this.init();
|
1855
|
-
this.visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
|
1907
|
+
this.visible = this.hasCondition() ? !this.conditionallyHidden() : !this.component.hidden;
|
1856
1908
|
return this.redraw();
|
1857
1909
|
}
|
1858
1910
|
/**
|
@@ -1907,7 +1959,7 @@ class Component extends Element_1.default {
|
|
1907
1959
|
if (this._hasCondition !== null) {
|
1908
1960
|
return this._hasCondition;
|
1909
1961
|
}
|
1910
|
-
this._hasCondition =
|
1962
|
+
this._hasCondition = utils_1.default.hasCondition(this.component);
|
1911
1963
|
return this._hasCondition;
|
1912
1964
|
}
|
1913
1965
|
/**
|
@@ -1934,7 +1986,7 @@ class Component extends Element_1.default {
|
|
1934
1986
|
* @returns {boolean} - True if the condition applies to this component.
|
1935
1987
|
*/
|
1936
1988
|
checkCondition(row, data) {
|
1937
|
-
return
|
1989
|
+
return utils_1.default.checkCondition(this.component, row || this.data, data || this.rootValue, this.root ? this.root._form : {}, this);
|
1938
1990
|
}
|
1939
1991
|
/**
|
1940
1992
|
* Check for conditionals and hide/show the element based on those conditions.
|
@@ -1950,23 +2002,12 @@ class Component extends Element_1.default {
|
|
1950
2002
|
if (!this.builderMode & !this.previewMode && this.fieldLogic(data, row)) {
|
1951
2003
|
this.redraw();
|
1952
2004
|
}
|
1953
|
-
// Check advanced conditions (and cache the result)
|
1954
|
-
const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
|
1955
|
-
let shouldClear = false;
|
1956
|
-
if (isConditionallyHidden !== this._conditionallyHidden) {
|
1957
|
-
this._conditionallyHidden = isConditionallyHidden;
|
1958
|
-
shouldClear = true;
|
1959
|
-
}
|
1960
2005
|
// Check visibility
|
1961
|
-
const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
2006
|
+
const visible = (this.hasCondition() ? !this.conditionallyHidden() : !this.component.hidden);
|
1962
2007
|
if (this.visible !== visible) {
|
1963
2008
|
this.visible = visible;
|
1964
2009
|
}
|
1965
|
-
|
1966
|
-
// calling clearOnHide
|
1967
|
-
if (shouldClear) {
|
1968
|
-
this.clearOnHide();
|
1969
|
-
}
|
2010
|
+
this.clearComponentOnHide();
|
1970
2011
|
return visible;
|
1971
2012
|
}
|
1972
2013
|
/**
|
@@ -2001,9 +2042,9 @@ class Component extends Element_1.default {
|
|
2001
2042
|
if (logics.length === 0) {
|
2002
2043
|
return;
|
2003
2044
|
}
|
2004
|
-
const newComponent = (0,
|
2045
|
+
const newComponent = (0, utils_2.fastCloneDeep)(this.originalComponent);
|
2005
2046
|
let changed = logics.reduce((changed, logic) => {
|
2006
|
-
const result =
|
2047
|
+
const result = utils_1.default.checkTrigger(newComponent, logic.trigger, row, data, this.root ? this.root._form : {}, this);
|
2007
2048
|
return (result ? this.applyActions(newComponent, logic.actions, result, row, data) : false) || changed;
|
2008
2049
|
}, false);
|
2009
2050
|
// If component definition changed, replace and mark as changed.
|
@@ -2070,14 +2111,14 @@ class Component extends Element_1.default {
|
|
2070
2111
|
return actions.reduce((changed, action) => {
|
2071
2112
|
switch (action.type) {
|
2072
2113
|
case 'property': {
|
2073
|
-
|
2114
|
+
utils_1.default.setActionProperty(newComponent, action, result, row, data, this);
|
2074
2115
|
const property = action.property.value;
|
2075
2116
|
if (!lodash_1.default.isEqual(lodash_1.default.get(this.component, property), lodash_1.default.get(newComponent, property))) {
|
2076
2117
|
// Advanced Logic can modify the component's hidden property; because we track conditionally hidden state
|
2077
2118
|
// separately from the component's hidden property, and technically this Advanced Logic conditionally hides
|
2078
|
-
// a component, we need to set
|
2119
|
+
// a component, we need to set a temporary variable to the new value
|
2079
2120
|
if (property === 'hidden') {
|
2080
|
-
this.
|
2121
|
+
this._logicallyHidden = newComponent.hidden;
|
2081
2122
|
}
|
2082
2123
|
changed = true;
|
2083
2124
|
}
|
@@ -2092,7 +2133,7 @@ class Component extends Element_1.default {
|
|
2092
2133
|
component: newComponent,
|
2093
2134
|
result,
|
2094
2135
|
});
|
2095
|
-
if (!lodash_1.default.isEqual(oldValue, newValue) && !
|
2136
|
+
if (!lodash_1.default.isEqual(oldValue, newValue) && !this.shouldConditionallyClear()) {
|
2096
2137
|
this.setValue(newValue);
|
2097
2138
|
if (this.viewOnly) {
|
2098
2139
|
this.dataValue = newValue;
|
@@ -2125,7 +2166,7 @@ class Component extends Element_1.default {
|
|
2125
2166
|
component: newComponent,
|
2126
2167
|
result,
|
2127
2168
|
}, 'value');
|
2128
|
-
if (!lodash_1.default.isEqual(oldValue, newValue) && !
|
2169
|
+
if (!lodash_1.default.isEqual(oldValue, newValue) && !this.shouldConditionallyClear()) {
|
2129
2170
|
this.setValue(newValue);
|
2130
2171
|
if (this.viewOnly) {
|
2131
2172
|
this.dataValue = newValue;
|
@@ -2226,17 +2267,12 @@ class Component extends Element_1.default {
|
|
2226
2267
|
element.setAttribute('aria-invalid', invalid ? 'true' : 'false');
|
2227
2268
|
}
|
2228
2269
|
/**
|
2229
|
-
*
|
2270
|
+
* Clear any conditionally hidden components for this component only.
|
2230
2271
|
*/
|
2231
|
-
|
2272
|
+
clearComponentOnHide() {
|
2232
2273
|
// clearOnHide defaults to true for old forms (without the value set) so only trigger if the value is false.
|
2233
|
-
if (
|
2234
|
-
|
2235
|
-
(!this.rootPristine || this.options.server || (0, utils_1.isInsideScopingComponent)(this)) &&
|
2236
|
-
this.component.clearOnHide !== false &&
|
2237
|
-
!this.options.readOnly &&
|
2238
|
-
!this.options.showHiddenFields) {
|
2239
|
-
if (this.conditionallyHidden) {
|
2274
|
+
if (this.component.clearOnHide !== false && !this.options.readOnly && !this.options.showHiddenFields) {
|
2275
|
+
if (this.shouldConditionallyClear()) {
|
2240
2276
|
this.deleteValue();
|
2241
2277
|
}
|
2242
2278
|
else if (!this.hasValue() && this.shouldAddDefaultValue) {
|
@@ -2247,6 +2283,12 @@ class Component extends Element_1.default {
|
|
2247
2283
|
}
|
2248
2284
|
}
|
2249
2285
|
}
|
2286
|
+
/**
|
2287
|
+
* Clears the components data if it is conditionally hidden AND clearOnHide is set to true for this component.
|
2288
|
+
*/
|
2289
|
+
clearOnHide() {
|
2290
|
+
this.clearComponentOnHide();
|
2291
|
+
}
|
2250
2292
|
/**
|
2251
2293
|
* Triggers a debounced onChange event for the root component (usually Webform).
|
2252
2294
|
* @param {...any} args - The arguments to pass to the onChange event.
|
@@ -2494,27 +2536,17 @@ class Component extends Element_1.default {
|
|
2494
2536
|
* @returns {*} - The value for this component.
|
2495
2537
|
*/
|
2496
2538
|
get dataValue() {
|
2497
|
-
if (!this.key
|
2498
|
-
|
2499
|
-
return this.emptyValue;
|
2539
|
+
if (!this.key) {
|
2540
|
+
return this.component.multiple ? [] : this.emptyValue;
|
2500
2541
|
}
|
2501
|
-
|
2502
|
-
const empty = this.component.multiple ? [] : this.emptyValue;
|
2503
|
-
if (!this.rootPristine) {
|
2504
|
-
this.dataValue = empty;
|
2505
|
-
}
|
2506
|
-
return empty;
|
2507
|
-
}
|
2508
|
-
return lodash_1.default.get(this._data, this.key);
|
2542
|
+
return lodash_1.default.get(this._data, this.key, this.component.multiple ? [] : this.emptyValue);
|
2509
2543
|
}
|
2510
2544
|
/**
|
2511
2545
|
* Sets the static value of this component.
|
2512
2546
|
* @param {*} value - The value to set for this component.
|
2513
2547
|
*/
|
2514
2548
|
set dataValue(value) {
|
2515
|
-
if (!this.allowData ||
|
2516
|
-
!this.key ||
|
2517
|
-
(this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
|
2549
|
+
if (!this.allowData || !this.key) {
|
2518
2550
|
return;
|
2519
2551
|
}
|
2520
2552
|
if ((value !== null) && (value !== undefined)) {
|
@@ -2557,13 +2589,30 @@ class Component extends Element_1.default {
|
|
2557
2589
|
}
|
2558
2590
|
getCustomDefaultValue(defaultValue) {
|
2559
2591
|
if (this.component.customDefaultValue && !this.options.preview) {
|
2560
|
-
defaultValue = this.evaluate(this.component.customDefaultValue, { value:
|
2592
|
+
defaultValue = this.evaluate(this.component.customDefaultValue, { value: this.dataValue }, 'value');
|
2561
2593
|
}
|
2562
2594
|
return defaultValue;
|
2563
2595
|
}
|
2596
|
+
/**
|
2597
|
+
* Returns if a component has a default value set.
|
2598
|
+
* @returns {boolean} - TRUE if a default value is set.
|
2599
|
+
*/
|
2600
|
+
get hasDefaultValue() {
|
2601
|
+
return this.component.customDefaultValue || (this.component.hasOwnProperty('defaultValue') &&
|
2602
|
+
(this.component.defaultValue !== null) &&
|
2603
|
+
(this.component.defaultValue !== undefined));
|
2604
|
+
}
|
2605
|
+
/**
|
2606
|
+
* Determine if we should add a default value for this component.
|
2607
|
+
* @returns {boolean} - TRUE if a default value should be set
|
2608
|
+
*/
|
2564
2609
|
get shouldAddDefaultValue() {
|
2565
|
-
return
|
2610
|
+
return this.pristine && this.allowData && (this.hasDefaultValue || !this.options.noDefaults);
|
2566
2611
|
}
|
2612
|
+
/**
|
2613
|
+
* Get the default value of this component.
|
2614
|
+
* @returns {*} - The default value for this component.
|
2615
|
+
*/
|
2567
2616
|
get defaultValue() {
|
2568
2617
|
let defaultValue = this.emptyValue;
|
2569
2618
|
if (this.component.defaultValue) {
|
@@ -2575,7 +2624,7 @@ class Component extends Element_1.default {
|
|
2575
2624
|
if (this.component.type !== 'textfield') {
|
2576
2625
|
const placeholderChar = this.placeholderChar;
|
2577
2626
|
value = (0, vanilla_text_mask_1.conformToMask)(value, this.defaultMask, { placeholderChar }).conformedValue;
|
2578
|
-
if (!
|
2627
|
+
if (!utils_1.default.matchInputMask(value, this.defaultMask)) {
|
2579
2628
|
value = '';
|
2580
2629
|
}
|
2581
2630
|
}
|
@@ -2641,13 +2690,16 @@ class Component extends Element_1.default {
|
|
2641
2690
|
}
|
2642
2691
|
const isArray = Array.isArray(value);
|
2643
2692
|
const valueInput = this.refs.fileLink || this.refs.input;
|
2693
|
+
const isFilelink = !!this.refs.fileLink;
|
2644
2694
|
if (isArray &&
|
2645
2695
|
Array.isArray(this.defaultValue) &&
|
2646
2696
|
this.refs.hasOwnProperty('input') &&
|
2647
2697
|
valueInput &&
|
2648
2698
|
(valueInput.length !== value.length) &&
|
2649
2699
|
this.visible) {
|
2650
|
-
|
2700
|
+
if (isFilelink || valueInput.length) {
|
2701
|
+
this.redraw();
|
2702
|
+
}
|
2651
2703
|
}
|
2652
2704
|
if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
|
2653
2705
|
this.redraw();
|
@@ -2834,10 +2886,8 @@ class Component extends Element_1.default {
|
|
2834
2886
|
}
|
2835
2887
|
// If no calculated value or
|
2836
2888
|
// hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
|
2837
|
-
const { clearOnHide } = this.component;
|
2838
|
-
const shouldBeCleared = this.conditionallyHidden && clearOnHide;
|
2839
2889
|
const allowOverride = lodash_1.default.get(this.component, 'allowCalculateOverride', false);
|
2840
|
-
if (
|
2890
|
+
if (this.shouldConditionallyClear()) {
|
2841
2891
|
// remove calculated value so that the value is recalculated once component becomes visible
|
2842
2892
|
if (this.hasOwnProperty('calculatedValue') && allowOverride) {
|
2843
2893
|
lodash_1.default.unset(this, 'calculatedValue');
|
@@ -2895,7 +2945,7 @@ class Component extends Element_1.default {
|
|
2895
2945
|
}
|
2896
2946
|
if (fromSubmission) {
|
2897
2947
|
// If we set value from submission and it differs from calculated one, set the calculated value to prevent overriding dataValue in the next pass
|
2898
|
-
this.calculatedValue = (0,
|
2948
|
+
this.calculatedValue = (0, utils_2.fastCloneDeep)(calculatedValue);
|
2899
2949
|
return false;
|
2900
2950
|
}
|
2901
2951
|
// If this is the firstPass, and the dataValue is different than to the calculatedValue.
|
@@ -2904,7 +2954,7 @@ class Component extends Element_1.default {
|
|
2904
2954
|
return true;
|
2905
2955
|
}
|
2906
2956
|
}
|
2907
|
-
this.calculatedValue = (0,
|
2957
|
+
this.calculatedValue = (0, utils_2.fastCloneDeep)(calculatedValue);
|
2908
2958
|
if (changed) {
|
2909
2959
|
if (!flags.noPristineChangeOnModified && this.root.initialized) {
|
2910
2960
|
this.pristine = false;
|
@@ -2958,12 +3008,14 @@ class Component extends Element_1.default {
|
|
2958
3008
|
* @param {boolean} dirty - If the component is dirty.
|
2959
3009
|
* @param {boolean} ignoreCondition - If conditions for the component should be ignored when checking validity.
|
2960
3010
|
* @param {*} row - Contextual row data for this component.
|
3011
|
+
* @param {*} options - Additional options for validation.
|
2961
3012
|
* @returns {string} - The message to show when the component is invalid.
|
2962
3013
|
*/
|
2963
|
-
invalidMessage(data, dirty, ignoreCondition, row) {
|
3014
|
+
invalidMessage(data, dirty, ignoreCondition, row, options = {}) {
|
2964
3015
|
var _a;
|
3016
|
+
const { local } = options;
|
2965
3017
|
if (!row) {
|
2966
|
-
row = (0,
|
3018
|
+
row = (0, utils_2.getContextualRowData)(this.component, data, this.paths);
|
2967
3019
|
}
|
2968
3020
|
if (!ignoreCondition && !this.checkCondition(row, data)) {
|
2969
3021
|
return '';
|
@@ -2981,6 +3033,7 @@ class Component extends Element_1.default {
|
|
2981
3033
|
component: this.component,
|
2982
3034
|
data,
|
2983
3035
|
row,
|
3036
|
+
local,
|
2984
3037
|
path: this.path || this.component.key,
|
2985
3038
|
parent: (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component,
|
2986
3039
|
paths: this.paths,
|
@@ -2991,7 +3044,7 @@ class Component extends Element_1.default {
|
|
2991
3044
|
]
|
2992
3045
|
});
|
2993
3046
|
const errors = validationScope.errors;
|
2994
|
-
const interpolatedErrors =
|
3047
|
+
const interpolatedErrors = utils_1.default.interpolateErrors(this.component, errors, this.t.bind(this));
|
2995
3048
|
return lodash_1.default.map(interpolatedErrors, 'message').join('\n\n');
|
2996
3049
|
}
|
2997
3050
|
/**
|
@@ -3022,7 +3075,7 @@ class Component extends Element_1.default {
|
|
3022
3075
|
*/
|
3023
3076
|
interpolateErrors(errors) {
|
3024
3077
|
var _a;
|
3025
|
-
const interpolatedErrors =
|
3078
|
+
const interpolatedErrors = utils_1.default.interpolateErrors(this.component, errors, this.t.bind(this));
|
3026
3079
|
return ((_a = this.serverErrors) === null || _a === void 0 ? void 0 : _a.length) ? [...interpolatedErrors, ...this.serverErrors] : interpolatedErrors;
|
3027
3080
|
}
|
3028
3081
|
/**
|
@@ -3157,19 +3210,29 @@ class Component extends Element_1.default {
|
|
3157
3210
|
data = data || this.rootValue;
|
3158
3211
|
flags = flags || {};
|
3159
3212
|
row = row || this.data;
|
3213
|
+
if (flags.noCheck) {
|
3214
|
+
return true;
|
3215
|
+
}
|
3216
|
+
// Some components (for legacy reasons) have calls to "checkData" in inappropriate places such
|
3217
|
+
// as setValue. Historically, this was bypassed by a series of cached states around the data model
|
3218
|
+
// which caused its own problems. We need to ensure that premium and custom components do not fall into
|
3219
|
+
// an infinite loop by only checking this component once.
|
3220
|
+
if (this.checkingData) {
|
3221
|
+
return;
|
3222
|
+
}
|
3223
|
+
this.checkingData = true;
|
3160
3224
|
// Needs for Nextgen Rules Engine
|
3161
3225
|
this.resetCaches();
|
3162
3226
|
// Do not trigger refresh if change was triggered on blur event since components with Refresh on Blur have their own listeners
|
3163
3227
|
if (!flags.fromBlur) {
|
3164
3228
|
this.checkRefreshOn(flags.changes, flags);
|
3165
3229
|
}
|
3166
|
-
if (flags.noCheck) {
|
3167
|
-
return true;
|
3168
|
-
}
|
3169
3230
|
this.checkComponentConditions(data, flags, row);
|
3170
3231
|
if (this.id !== flags.triggeredComponentId) {
|
3171
3232
|
this.calculateComponentValue(data, flags, row);
|
3172
3233
|
}
|
3234
|
+
// We are done checking data.
|
3235
|
+
this.checkingData = false;
|
3173
3236
|
}
|
3174
3237
|
checkModal(errors = [], dirty = false) {
|
3175
3238
|
const messages = errors.filter(error => !error.fromServer);
|
@@ -3232,7 +3295,7 @@ class Component extends Element_1.default {
|
|
3232
3295
|
}
|
3233
3296
|
});
|
3234
3297
|
this.addEventListener(element, 'blur', () => {
|
3235
|
-
this.root.pendingBlur =
|
3298
|
+
this.root.pendingBlur = utils_1.default.delay(() => {
|
3236
3299
|
this.emit('blur', this);
|
3237
3300
|
if (this.component.validateOn === 'blur') {
|
3238
3301
|
this.root.triggerChange({ fromBlur: true }, {
|
@@ -3480,12 +3543,12 @@ class Component extends Element_1.default {
|
|
3480
3543
|
if (logic.trigger.type === 'event') {
|
3481
3544
|
const event = this.interpolate(logic.trigger.event);
|
3482
3545
|
this.on(event, (...args) => {
|
3483
|
-
const newComponent = (0,
|
3546
|
+
const newComponent = (0, utils_2.fastCloneDeep)(this.originalComponent);
|
3484
3547
|
if (this.applyActions(newComponent, logic.actions, args)) {
|
3485
3548
|
// If component definition changed, replace it.
|
3486
3549
|
if (!lodash_1.default.isEqual(this.component, newComponent)) {
|
3487
3550
|
this.component = newComponent;
|
3488
|
-
const visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
|
3551
|
+
const visible = this.hasCondition() ? !this.conditionallyHidden() : !this.component.hidden;
|
3489
3552
|
const disabled = this.shouldDisabled;
|
3490
3553
|
// Change states which won't be recalculated during redrawing
|
3491
3554
|
if (this.visible !== visible) {
|
@@ -3615,7 +3678,7 @@ Component.requireLibrary = function (name, property, src, polling) {
|
|
3615
3678
|
}.bind(Component.externalLibraries[name]);
|
3616
3679
|
}
|
3617
3680
|
// See if the plugin already exists.
|
3618
|
-
const plugin = (0,
|
3681
|
+
const plugin = (0, utils_2.getScriptPlugin)(property);
|
3619
3682
|
if (plugin) {
|
3620
3683
|
Component.externalLibraries[name].resolve(plugin);
|
3621
3684
|
}
|
@@ -3658,7 +3721,7 @@ Component.requireLibrary = function (name, property, src, polling) {
|
|
3658
3721
|
// if no callback is provided, then check periodically for the script.
|
3659
3722
|
if (polling) {
|
3660
3723
|
setTimeout(function checkLibrary() {
|
3661
|
-
const plugin = (0,
|
3724
|
+
const plugin = (0, utils_2.getScriptPlugin)(property);
|
3662
3725
|
if (plugin) {
|
3663
3726
|
Component.externalLibraries[name].resolve(plugin);
|
3664
3727
|
}
|