@formio/js 5.1.0-rc.1 → 5.1.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formio.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 +33 -33
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +33 -33
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +21 -21
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +18 -18
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Embed.js +1 -1
- package/lib/cjs/Formio.js +1 -1
- package/lib/cjs/Webform.d.ts +1 -1
- package/lib/cjs/Wizard.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +15 -0
- package/lib/cjs/components/_classes/component/Component.js +51 -17
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
- package/lib/cjs/components/_classes/field/Field.d.ts +2 -2
- package/lib/cjs/components/_classes/field/Field.js +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +16 -7
- package/lib/cjs/components/address/Address.d.ts +1 -2
- package/lib/cjs/components/address/Address.js +1 -1
- package/lib/cjs/components/address/fixtures/comp5.d.ts +46 -0
- package/lib/cjs/components/address/fixtures/comp5.js +87 -0
- package/lib/cjs/components/address/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/address/fixtures/index.js +3 -1
- package/lib/cjs/components/button/Button.d.ts +1 -1
- package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/cjs/components/columns/Columns.d.ts +1 -1
- package/lib/cjs/components/datagrid/DataGrid.d.ts +1 -1
- package/lib/cjs/components/datamap/DataMap.js +1 -1
- package/lib/cjs/components/day/Day.d.ts +1 -1
- package/lib/cjs/components/day/Day.js +2 -18
- package/lib/cjs/components/editgrid/EditGrid.js +2 -5
- package/lib/cjs/components/file/File.d.ts +1 -1
- package/lib/cjs/components/form/Form.js +23 -11
- package/lib/cjs/components/html/HTML.js +15 -3
- package/lib/cjs/components/radio/Radio.d.ts +1 -1
- package/lib/cjs/components/select/Select.d.ts +1 -1
- package/lib/cjs/components/survey/Survey.d.ts +1 -1
- package/lib/cjs/components/table/Table.d.ts +1 -1
- package/lib/cjs/components/tabs/Tabs.d.ts +1 -1
- package/lib/cjs/formio.embed.d.ts +1 -1
- package/lib/cjs/formio.embed.js +3 -0
- package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +5 -0
- package/lib/cjs/providers/address/GoogleAddressProvider.js +23 -1
- package/lib/cjs/translations/en.js +2 -2
- package/lib/mjs/Embed.js +1 -1
- package/lib/mjs/Formio.js +1 -1
- package/lib/mjs/Webform.d.ts +1 -1
- package/lib/mjs/Wizard.js +1 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +15 -0
- package/lib/mjs/components/_classes/component/Component.js +51 -17
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
- package/lib/mjs/components/_classes/field/Field.d.ts +2 -2
- package/lib/mjs/components/_classes/field/Field.js +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +16 -7
- package/lib/mjs/components/address/Address.d.ts +1 -2
- package/lib/mjs/components/address/Address.js +1 -1
- package/lib/mjs/components/address/fixtures/comp5.d.ts +46 -0
- package/lib/mjs/components/address/fixtures/comp5.js +85 -0
- package/lib/mjs/components/address/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/address/fixtures/index.js +2 -1
- package/lib/mjs/components/button/Button.d.ts +1 -1
- package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/mjs/components/columns/Columns.d.ts +1 -1
- package/lib/mjs/components/datagrid/DataGrid.d.ts +1 -1
- package/lib/mjs/components/datamap/DataMap.js +1 -1
- package/lib/mjs/components/day/Day.d.ts +1 -1
- package/lib/mjs/components/day/Day.js +2 -18
- package/lib/mjs/components/editgrid/EditGrid.js +2 -5
- package/lib/mjs/components/file/File.d.ts +1 -1
- package/lib/mjs/components/form/Form.js +23 -11
- package/lib/mjs/components/html/HTML.js +15 -3
- package/lib/mjs/components/radio/Radio.d.ts +1 -1
- package/lib/mjs/components/select/Select.d.ts +1 -1
- package/lib/mjs/components/survey/Survey.d.ts +1 -1
- package/lib/mjs/components/table/Table.d.ts +1 -1
- package/lib/mjs/components/tabs/Tabs.d.ts +1 -1
- package/lib/mjs/formio.embed.d.ts +1 -1
- package/lib/mjs/formio.embed.js +1 -0
- package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +5 -0
- package/lib/mjs/providers/address/GoogleAddressProvider.js +22 -1
- package/lib/mjs/translations/en.js +2 -2
- package/package.json +3 -3
@@ -7,6 +7,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
8
8
|
const Field_1 = __importDefault(require("../_classes/field/Field"));
|
9
9
|
const utils_1 = require("../../utils/utils");
|
10
|
+
const core_1 = require("@formio/core");
|
10
11
|
class DayComponent extends Field_1.default {
|
11
12
|
static schema(...extend) {
|
12
13
|
return Field_1.default.schema({
|
@@ -474,24 +475,7 @@ class DayComponent extends Field_1.default {
|
|
474
475
|
* @returns {string} - the format for the value string.
|
475
476
|
*/
|
476
477
|
get format() {
|
477
|
-
|
478
|
-
if (this.component.dayFirst && this.showDay) {
|
479
|
-
format += 'D/';
|
480
|
-
}
|
481
|
-
if (this.showMonth) {
|
482
|
-
format += 'M/';
|
483
|
-
}
|
484
|
-
if (!this.component.dayFirst && this.showDay) {
|
485
|
-
format += 'D/';
|
486
|
-
}
|
487
|
-
if (this.showYear) {
|
488
|
-
format += 'YYYY';
|
489
|
-
return format;
|
490
|
-
}
|
491
|
-
else {
|
492
|
-
// Trim off the "/" from the end of the format string.
|
493
|
-
return format.length ? format.substring(0, format.length - 1) : format;
|
494
|
-
}
|
478
|
+
return (0, core_1.getDayFormat)(this.component);
|
495
479
|
}
|
496
480
|
/**
|
497
481
|
* Return the date for this component.
|
@@ -1141,7 +1141,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
1141
1141
|
}
|
1142
1142
|
}
|
1143
1143
|
const changed = this.hasChanged(value, this.dataValue);
|
1144
|
-
if (this.parent
|
1144
|
+
if (this.parent) {
|
1145
1145
|
this.parent.checkComponentConditions();
|
1146
1146
|
}
|
1147
1147
|
this.dataValue = value;
|
@@ -1174,10 +1174,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
1174
1174
|
this.editRows = this.editRows.slice(0, dataLength);
|
1175
1175
|
this.openWhenEmpty();
|
1176
1176
|
this.updateOnChange(flags, changed);
|
1177
|
-
|
1178
|
-
if (!this.options.server) {
|
1179
|
-
this.checkData();
|
1180
|
-
}
|
1177
|
+
this.checkData();
|
1181
1178
|
this.changeState(changed, flags);
|
1182
1179
|
return changed;
|
1183
1180
|
}
|
@@ -45,7 +45,7 @@ export default class FileComponent extends Field {
|
|
45
45
|
type: number;
|
46
46
|
actions: number;
|
47
47
|
};
|
48
|
-
render():
|
48
|
+
render(): string;
|
49
49
|
getVideoStream(constraints: any): any;
|
50
50
|
stopVideoStream(videoStream: any): void;
|
51
51
|
getFrame(videoPlayer: any): Promise<any>;
|
@@ -144,6 +144,8 @@ class FormComponent extends Component_1.default {
|
|
144
144
|
options.events = this.createEmitter();
|
145
145
|
// Make sure to not show the submit button in wizards in the nested forms.
|
146
146
|
lodash_1.default.set(options, 'buttonSettings.showSubmit', false);
|
147
|
+
// Set the parent option to the subform so those references are stable when the subform is created
|
148
|
+
options.parent = this;
|
147
149
|
if (!this.options) {
|
148
150
|
return options;
|
149
151
|
}
|
@@ -393,12 +395,11 @@ class FormComponent extends Component_1.default {
|
|
393
395
|
return (new Form_1.default(form, this.getSubOptions())).ready.then((instance) => {
|
394
396
|
this.subForm = instance;
|
395
397
|
this.subForm.currentForm = this;
|
398
|
+
this.subForm.parentVisible = this.visible;
|
396
399
|
const componentsMap = this.componentsMap;
|
397
400
|
const formComponentsMap = this.subForm.componentsMap;
|
398
401
|
lodash_1.default.assign(componentsMap, formComponentsMap);
|
399
402
|
this.component.components = this.subForm.components.map((comp) => comp.component);
|
400
|
-
this.subForm.parent = this;
|
401
|
-
this.subForm.parentVisible = this.visible;
|
402
403
|
this.subForm.on('change', () => {
|
403
404
|
if (this.subForm) {
|
404
405
|
this.dataValue = this.subForm.getValue();
|
@@ -425,10 +426,11 @@ class FormComponent extends Component_1.default {
|
|
425
426
|
return this.subFormReady;
|
426
427
|
}
|
427
428
|
hideSubmitButton(component) {
|
428
|
-
const isSubmitButton =
|
429
|
-
((component.action === 'submit') || !component.action);
|
429
|
+
const isSubmitButton = component.type === 'button' && (component.action === 'submit' || !component.action);
|
430
430
|
if (isSubmitButton) {
|
431
431
|
component.hidden = true;
|
432
|
+
// clearOnHide no longer clears from the JSON `hidden` flag, so we make the button conditionally hidden to clear its data
|
433
|
+
component.customConditional = 'show = false';
|
432
434
|
}
|
433
435
|
}
|
434
436
|
/**
|
@@ -438,7 +440,7 @@ class FormComponent extends Component_1.default {
|
|
438
440
|
*/
|
439
441
|
loadSubForm(fromAttach) {
|
440
442
|
var _a, _b, _c, _d, _e;
|
441
|
-
if (this.builderMode || this.
|
443
|
+
if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
|
442
444
|
return Promise.resolve();
|
443
445
|
}
|
444
446
|
if (this.hasLoadedForm && !this.isRevisionChanged &&
|
@@ -510,7 +512,7 @@ class FormComponent extends Component_1.default {
|
|
510
512
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
511
513
|
*/
|
512
514
|
get shouldSubmit() {
|
513
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.
|
515
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
|
514
516
|
}
|
515
517
|
/**
|
516
518
|
* Returns the data for the subform.
|
@@ -581,11 +583,21 @@ class FormComponent extends Component_1.default {
|
|
581
583
|
this.dataValue = submission;
|
582
584
|
return Promise.resolve(this.dataValue);
|
583
585
|
}
|
584
|
-
|
585
|
-
.
|
586
|
-
|
587
|
-
|
588
|
-
|
586
|
+
if (this.isSubFormLazyLoad() && !this.subFormLoading) {
|
587
|
+
return this.createSubForm(true)
|
588
|
+
.then(this.submitSubForm(false))
|
589
|
+
.then(() => {
|
590
|
+
return this.dataValue;
|
591
|
+
})
|
592
|
+
.then(() => super.beforeSubmit());
|
593
|
+
}
|
594
|
+
else {
|
595
|
+
return this.submitSubForm(false)
|
596
|
+
.then(() => {
|
597
|
+
return this.dataValue;
|
598
|
+
})
|
599
|
+
.then(() => super.beforeSubmit());
|
600
|
+
}
|
589
601
|
}
|
590
602
|
isSubFormLazyLoad() {
|
591
603
|
var _a, _b;
|
@@ -56,9 +56,21 @@ class HTMLComponent extends Component_1.default {
|
|
56
56
|
}
|
57
57
|
checkRefreshOn(changed) {
|
58
58
|
super.checkRefreshOn(changed);
|
59
|
-
|
60
|
-
|
61
|
-
this.
|
59
|
+
let visible;
|
60
|
+
if (this.hasCondition()) {
|
61
|
+
this._conditionallyHidden = this.checkConditionallyHidden();
|
62
|
+
visible = !this.conditionallyHidden;
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
visible = !this.component.hidden;
|
66
|
+
}
|
67
|
+
const shouldSetContent = !this.builderMode
|
68
|
+
&& this.component.refreshOnChange
|
69
|
+
&& this.element
|
70
|
+
&& !lodash_1.default.isUndefined(changed)
|
71
|
+
&& ((lodash_1.default.isBoolean(changed) && changed) || !lodash_1.default.isEmpty(changed))
|
72
|
+
&& visible;
|
73
|
+
if (shouldSetContent) {
|
62
74
|
this.setContent(this.element, this.renderContent());
|
63
75
|
}
|
64
76
|
}
|
@@ -28,7 +28,7 @@ export default class RadioComponent extends ListComponent {
|
|
28
28
|
optionsLoaded: boolean | undefined;
|
29
29
|
loadedOptions: any[] | undefined;
|
30
30
|
beforeSubmit(): Promise<any>;
|
31
|
-
render():
|
31
|
+
render(): string;
|
32
32
|
attach(element: any): Promise<void>;
|
33
33
|
detach(element: any): void;
|
34
34
|
validateValueProperty(): boolean;
|
@@ -112,7 +112,7 @@ export default class SelectComponent extends ListComponent {
|
|
112
112
|
activate(): void;
|
113
113
|
setLoadingItem(addToCurrentList?: boolean): void;
|
114
114
|
get active(): boolean | undefined;
|
115
|
-
render():
|
115
|
+
render(): string;
|
116
116
|
wrapElement(element: any): any;
|
117
117
|
choicesOptions(): any;
|
118
118
|
attach(element: any): Promise<void> | undefined;
|
@@ -14,7 +14,7 @@ export default class SurveyComponent extends Field {
|
|
14
14
|
operators: string[];
|
15
15
|
};
|
16
16
|
static savedValueTypes(schema: any): string[];
|
17
|
-
render():
|
17
|
+
render(): string;
|
18
18
|
attach(element: any): Promise<void>;
|
19
19
|
setValue(value: any, flags?: {}): boolean;
|
20
20
|
get emptyValue(): {};
|
@@ -19,6 +19,6 @@ export default class TableComponent extends NestedComponent {
|
|
19
19
|
get colWidth(): string;
|
20
20
|
noField: boolean;
|
21
21
|
table: any[] | undefined;
|
22
|
-
render():
|
22
|
+
render(): string;
|
23
23
|
}
|
24
24
|
import NestedComponent from '../_classes/nested/NestedComponent';
|
@@ -16,7 +16,7 @@ export default class TabsComponent extends NestedComponent {
|
|
16
16
|
currentTab: number;
|
17
17
|
noField: boolean;
|
18
18
|
tabs: any[] | undefined;
|
19
|
-
render():
|
19
|
+
render(): string;
|
20
20
|
detach(all: any): void;
|
21
21
|
/**
|
22
22
|
* Set the current tab.
|
@@ -1 +1 @@
|
|
1
|
-
export {};
|
1
|
+
export { Formio } from "./InlineEmbed";
|
package/lib/cjs/formio.embed.js
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Formio = void 0;
|
3
4
|
const InlineEmbed_1 = require("./InlineEmbed");
|
4
5
|
(0, InlineEmbed_1.embed)();
|
6
|
+
var InlineEmbed_2 = require("./InlineEmbed");
|
7
|
+
Object.defineProperty(exports, "Formio", { enumerable: true, get: function () { return InlineEmbed_2.Formio; } });
|
@@ -82,6 +82,11 @@ export class GoogleAddressProvider extends AddressProvider {
|
|
82
82
|
search(): Promise<void>;
|
83
83
|
makeRequest(): Promise<void>;
|
84
84
|
getDisplayValue(address: any): any;
|
85
|
+
/**
|
86
|
+
* Tries to remove the library if api key for loaded script is different.
|
87
|
+
* @param {ProviderOptions} options - The options for the provider.
|
88
|
+
*/
|
89
|
+
tryRemoveLibrary(options?: ProviderOptions): void;
|
85
90
|
}
|
86
91
|
export type AutocompleteOptions = {
|
87
92
|
/**
|
@@ -8,6 +8,9 @@ exports.GoogleAddressProvider = void 0;
|
|
8
8
|
const Formio_1 = require("../../Formio");
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
10
10
|
const AddressProvider_1 = require("./AddressProvider");
|
11
|
+
const GOOGLE_MAPS_BASE_URL = 'https://maps.googleapis.com';
|
12
|
+
const GOOGLE_MAPS_JS_URL = `${GOOGLE_MAPS_BASE_URL}/maps/api/js`;
|
13
|
+
const GOOGLE_MAPS_JS_WITH_PARAMS_URL = `${GOOGLE_MAPS_JS_URL}?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback`;
|
11
14
|
/**
|
12
15
|
* @typedef {object} AutocompleteOptions
|
13
16
|
* @property {string[]} fields - The fields to include in the autocomplete response.
|
@@ -55,10 +58,11 @@ class GoogleAddressProvider extends AddressProvider_1.AddressProvider {
|
|
55
58
|
var _a;
|
56
59
|
super(options);
|
57
60
|
this.setAutocompleteOptions();
|
58
|
-
let src =
|
61
|
+
let src = GOOGLE_MAPS_JS_WITH_PARAMS_URL;
|
59
62
|
if ((_a = options.params) === null || _a === void 0 ? void 0 : _a.key) {
|
60
63
|
src += `&key=${options.params.key}`;
|
61
64
|
}
|
65
|
+
this.tryRemoveLibrary(options);
|
62
66
|
Formio_1.Formio.requireLibrary(this.getLibraryName(), 'google.maps.places', src);
|
63
67
|
}
|
64
68
|
/**
|
@@ -185,5 +189,23 @@ class GoogleAddressProvider extends AddressProvider_1.AddressProvider {
|
|
185
189
|
: this.alternativeDisplayValueProperty;
|
186
190
|
return lodash_1.default.get(address, displayedProperty, '');
|
187
191
|
}
|
192
|
+
/**
|
193
|
+
* Tries to remove the library if api key for loaded script is different.
|
194
|
+
* @param {ProviderOptions} options - The options for the provider.
|
195
|
+
*/
|
196
|
+
tryRemoveLibrary(options = {}) {
|
197
|
+
var _a, _b, _c;
|
198
|
+
if (!Formio_1.Formio.libraries[this.getLibraryName()]) {
|
199
|
+
return;
|
200
|
+
}
|
201
|
+
const existingScript = document.querySelector(`script[src^="${GOOGLE_MAPS_JS_URL}"]`);
|
202
|
+
if (existingScript && ((_a = options.params) === null || _a === void 0 ? void 0 : _a.key) && !existingScript.attributes.src.value.endsWith(options.params.key)) {
|
203
|
+
const googleMapsScripts = (_b = document.querySelectorAll(`script[src^="${GOOGLE_MAPS_BASE_URL}"]`)) !== null && _b !== void 0 ? _b : [];
|
204
|
+
googleMapsScripts.forEach(script => script.parentNode.removeChild(script));
|
205
|
+
delete Formio_1.Formio.libraries[this.getLibraryName()];
|
206
|
+
(_c = global === null || global === void 0 ? void 0 : global.google) === null || _c === void 0 ? true : delete _c.maps;
|
207
|
+
delete global[`${this.getLibraryName()}Callback`];
|
208
|
+
}
|
209
|
+
}
|
188
210
|
}
|
189
211
|
exports.GoogleAddressProvider = GoogleAddressProvider;
|
@@ -26,8 +26,8 @@ exports.default = {
|
|
26
26
|
maxWords: '{{field}} must have no more than {{length}} words.',
|
27
27
|
min: '{{field}} cannot be less than {{min}}.',
|
28
28
|
max: '{{field}} cannot be greater than {{max}}.',
|
29
|
-
maxDate: '{{field}} should not contain date after {{
|
30
|
-
minDate: '{{field}} should not contain date before {{
|
29
|
+
maxDate: '{{field}} should not contain date after {{maxDate}}',
|
30
|
+
minDate: '{{field}} should not contain date before {{minDate}}',
|
31
31
|
maxYear: '{{field}} should not contain year greater than {{maxYear}}',
|
32
32
|
minYear: '{{field}} should not contain year less than {{minYear}}',
|
33
33
|
minSelectedCount: 'You must select at least {{minCount}} items',
|
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 = '
|
17
|
+
static version = '5.1.0-rc.10';
|
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 = '
|
7
|
+
FormioCore.version = '5.1.0-rc.10';
|
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) {
|
package/lib/mjs/Webform.d.ts
CHANGED
@@ -363,7 +363,7 @@ declare class Webform extends NestedDataComponent {
|
|
363
363
|
executeFormController(): false | undefined;
|
364
364
|
build(element: any): Promise<any>;
|
365
365
|
getClassName(): string;
|
366
|
-
render():
|
366
|
+
render(): string;
|
367
367
|
redraw(): Promise<void> | Promise<boolean>;
|
368
368
|
attach(element: any): Promise<boolean>;
|
369
369
|
hasRequiredFields(): boolean;
|
package/lib/mjs/Wizard.js
CHANGED
@@ -657,7 +657,7 @@ export default class Wizard extends Webform {
|
|
657
657
|
return this.page - 1;
|
658
658
|
}
|
659
659
|
beforeSubmit() {
|
660
|
-
const pages = this.getPages();
|
660
|
+
const pages = this.getPages({ all: true });
|
661
661
|
return Promise.all(pages.map((page) => {
|
662
662
|
page.options.beforeSubmit = true;
|
663
663
|
return page.beforeSubmit();
|
@@ -119,6 +119,13 @@ declare class Component extends Element {
|
|
119
119
|
*/
|
120
120
|
paths: import('@formio/core').ComponentPaths;
|
121
121
|
_path: string;
|
122
|
+
/**
|
123
|
+
* Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
|
124
|
+
* This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
|
125
|
+
* conditionallyHidden separately from "regular" visibility.
|
126
|
+
*/
|
127
|
+
_parentConditionallyHidden: any;
|
128
|
+
_conditionallyHidden: any;
|
122
129
|
/**
|
123
130
|
* Determines if this component is visible, or not.
|
124
131
|
*/
|
@@ -224,6 +231,14 @@ declare class Component extends Element {
|
|
224
231
|
* @returns {boolean} - Whether the component is visible or not.
|
225
232
|
*/
|
226
233
|
get visible(): boolean;
|
234
|
+
get conditionallyHidden(): any;
|
235
|
+
/**
|
236
|
+
* Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
|
237
|
+
* @param {object} data - The data object to evaluate the condition against.
|
238
|
+
* @param {object} row - The row object to evaluate the condition against.
|
239
|
+
* @returns {boolean} - Whether the component is conditionally hidden.
|
240
|
+
*/
|
241
|
+
checkConditionallyHidden(data?: object, row?: object): boolean;
|
227
242
|
set currentForm(instance: any);
|
228
243
|
get currentForm(): any;
|
229
244
|
_currentForm: any;
|
@@ -315,11 +315,18 @@ export default class Component extends Element {
|
|
315
315
|
this._path = '';
|
316
316
|
// Needs for Nextgen Rules Engine
|
317
317
|
this.resetCaches();
|
318
|
+
/**
|
319
|
+
* Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
|
320
|
+
* This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
|
321
|
+
* conditionallyHidden separately from "regular" visibility.
|
322
|
+
*/
|
323
|
+
this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
|
324
|
+
this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
|
318
325
|
/**
|
319
326
|
* Determines if this component is visible, or not.
|
320
327
|
*/
|
321
328
|
this._parentVisible = this.options.hasOwnProperty('parentVisible') ? this.options.parentVisible : true;
|
322
|
-
this._visible = this._parentVisible && this.
|
329
|
+
this._visible = this._parentVisible && (this.hasCondition() ? !this._conditionallyHidden : !this.component.hidden);
|
323
330
|
this._parentDisabled = false;
|
324
331
|
/**
|
325
332
|
* The reference attribute name for this component
|
@@ -388,7 +395,7 @@ export default class Component extends Element {
|
|
388
395
|
if (this.allowData && this.key) {
|
389
396
|
this.options.name += `[${this.key}]`;
|
390
397
|
// If component is visible or not set to clear on hide, set the default value.
|
391
|
-
if (this.
|
398
|
+
if (!(this.conditionallyHidden && this.component.clearOnHide)) {
|
392
399
|
if (!this.hasValue()) {
|
393
400
|
if (this.shouldAddDefaultValue) {
|
394
401
|
this.dataValue = this.defaultValue;
|
@@ -457,7 +464,8 @@ export default class Component extends Element {
|
|
457
464
|
}
|
458
465
|
init() {
|
459
466
|
this.disabled = this.shouldDisabled;
|
460
|
-
this.
|
467
|
+
this._conditionallyHidden = this.checkConditionallyHidden();
|
468
|
+
this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
461
469
|
if (this.component.addons?.length) {
|
462
470
|
this.component.addons.forEach((addon) => this.createAddon(addon));
|
463
471
|
}
|
@@ -600,7 +608,6 @@ export default class Component extends Element {
|
|
600
608
|
return;
|
601
609
|
}
|
602
610
|
this._visible = value;
|
603
|
-
this.clearOnHide();
|
604
611
|
this.redraw();
|
605
612
|
}
|
606
613
|
}
|
@@ -621,6 +628,21 @@ export default class Component extends Element {
|
|
621
628
|
}
|
622
629
|
return this._visible && this._parentVisible;
|
623
630
|
}
|
631
|
+
get conditionallyHidden() {
|
632
|
+
return this._conditionallyHidden || this._parentConditionallyHidden;
|
633
|
+
}
|
634
|
+
/**
|
635
|
+
* Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
|
636
|
+
* @param {object} data - The data object to evaluate the condition against.
|
637
|
+
* @param {object} row - The row object to evaluate the condition against.
|
638
|
+
* @returns {boolean} - Whether the component is conditionally hidden.
|
639
|
+
*/
|
640
|
+
checkConditionallyHidden(data = null, row = null) {
|
641
|
+
if (!this.hasCondition()) {
|
642
|
+
return false;
|
643
|
+
}
|
644
|
+
return !this.conditionallyVisible(data, row);
|
645
|
+
}
|
624
646
|
get currentForm() {
|
625
647
|
return this._currentForm;
|
626
648
|
}
|
@@ -1241,7 +1263,7 @@ export default class Component extends Element {
|
|
1241
1263
|
detach() {
|
1242
1264
|
// First iterate through each ref and delete the component so there are no dangling component references.
|
1243
1265
|
_.each(this.refs, (ref) => {
|
1244
|
-
if (
|
1266
|
+
if (ref instanceof NodeList) {
|
1245
1267
|
ref.forEach((elem) => {
|
1246
1268
|
delete elem.component;
|
1247
1269
|
});
|
@@ -1791,7 +1813,7 @@ export default class Component extends Element {
|
|
1791
1813
|
rebuild() {
|
1792
1814
|
this.destroy();
|
1793
1815
|
this.init();
|
1794
|
-
this.visible = this.
|
1816
|
+
this.visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
|
1795
1817
|
return this.redraw();
|
1796
1818
|
}
|
1797
1819
|
/**
|
@@ -1858,8 +1880,8 @@ export default class Component extends Element {
|
|
1858
1880
|
conditionallyVisible(data, row) {
|
1859
1881
|
data = data || this.rootValue;
|
1860
1882
|
row = row || this.data;
|
1861
|
-
if (this.builderMode || this.previewMode
|
1862
|
-
return
|
1883
|
+
if (this.builderMode || this.previewMode) {
|
1884
|
+
return true;
|
1863
1885
|
}
|
1864
1886
|
data = data || (this.root ? this.root.data : {});
|
1865
1887
|
return this.checkCondition(row, data);
|
@@ -1889,8 +1911,14 @@ export default class Component extends Element {
|
|
1889
1911
|
if (!this.builderMode & !this.previewMode && this.fieldLogic(data, row)) {
|
1890
1912
|
this.redraw();
|
1891
1913
|
}
|
1892
|
-
// Check advanced conditions
|
1893
|
-
const
|
1914
|
+
// Check advanced conditions (and cache the result)
|
1915
|
+
const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
|
1916
|
+
if (isConditionallyHidden !== this._conditionallyHidden) {
|
1917
|
+
this._conditionallyHidden = isConditionallyHidden;
|
1918
|
+
this.clearOnHide();
|
1919
|
+
}
|
1920
|
+
// Check visibility
|
1921
|
+
const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
1894
1922
|
if (this.visible !== visible) {
|
1895
1923
|
this.visible = visible;
|
1896
1924
|
}
|
@@ -2000,6 +2028,12 @@ export default class Component extends Element {
|
|
2000
2028
|
FormioUtils.setActionProperty(newComponent, action, result, row, data, this);
|
2001
2029
|
const property = action.property.value;
|
2002
2030
|
if (!_.isEqual(_.get(this.component, property), _.get(newComponent, property))) {
|
2031
|
+
// Advanced Logic can modify the component's hidden property; because we track conditionally hidden state
|
2032
|
+
// separately from the component's hidden property, and technically this Advanced Logic conditionally hides
|
2033
|
+
// a component, we need to set _conditionallyHidden to the new value
|
2034
|
+
if (property === 'hidden') {
|
2035
|
+
this._conditionallyHidden = newComponent.hidden;
|
2036
|
+
}
|
2003
2037
|
changed = true;
|
2004
2038
|
}
|
2005
2039
|
break;
|
@@ -2013,7 +2047,7 @@ export default class Component extends Element {
|
|
2013
2047
|
component: newComponent,
|
2014
2048
|
result,
|
2015
2049
|
});
|
2016
|
-
if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide &&
|
2050
|
+
if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
|
2017
2051
|
this.setValue(newValue);
|
2018
2052
|
if (this.viewOnly) {
|
2019
2053
|
this.dataValue = newValue;
|
@@ -2046,7 +2080,7 @@ export default class Component extends Element {
|
|
2046
2080
|
component: newComponent,
|
2047
2081
|
result,
|
2048
2082
|
}, 'value');
|
2049
|
-
if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide &&
|
2083
|
+
if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
|
2050
2084
|
this.setValue(newValue);
|
2051
2085
|
if (this.viewOnly) {
|
2052
2086
|
this.dataValue = newValue;
|
@@ -2157,7 +2191,7 @@ export default class Component extends Element {
|
|
2157
2191
|
this.component.clearOnHide !== false &&
|
2158
2192
|
!this.options.readOnly &&
|
2159
2193
|
!this.options.showHiddenFields) {
|
2160
|
-
if (
|
2194
|
+
if (this.conditionallyHidden) {
|
2161
2195
|
this.deleteValue();
|
2162
2196
|
}
|
2163
2197
|
else if (!this.hasValue() && this.shouldAddDefaultValue) {
|
@@ -2412,7 +2446,7 @@ export default class Component extends Element {
|
|
2412
2446
|
*/
|
2413
2447
|
get dataValue() {
|
2414
2448
|
if (!this.key ||
|
2415
|
-
(
|
2449
|
+
(this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
|
2416
2450
|
return this.emptyValue;
|
2417
2451
|
}
|
2418
2452
|
if (!this.hasValue() && this.shouldAddDefaultValue) {
|
@@ -2431,7 +2465,7 @@ export default class Component extends Element {
|
|
2431
2465
|
set dataValue(value) {
|
2432
2466
|
if (!this.allowData ||
|
2433
2467
|
!this.key ||
|
2434
|
-
(
|
2468
|
+
(this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
|
2435
2469
|
return;
|
2436
2470
|
}
|
2437
2471
|
if ((value !== null) && (value !== undefined)) {
|
@@ -2751,7 +2785,7 @@ export default class Component extends Element {
|
|
2751
2785
|
// If no calculated value or
|
2752
2786
|
// hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
|
2753
2787
|
const { clearOnHide } = this.component;
|
2754
|
-
const shouldBeCleared =
|
2788
|
+
const shouldBeCleared = this.conditionallyHidden && clearOnHide;
|
2755
2789
|
const allowOverride = _.get(this.component, 'allowCalculateOverride', false);
|
2756
2790
|
if (shouldBeCleared) {
|
2757
2791
|
// remove calculated value so that the value is recalculated once component becomes visible
|
@@ -3396,7 +3430,7 @@ export default class Component extends Element {
|
|
3396
3430
|
// If component definition changed, replace it.
|
3397
3431
|
if (!_.isEqual(this.component, newComponent)) {
|
3398
3432
|
this.component = newComponent;
|
3399
|
-
const visible = this.
|
3433
|
+
const visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
|
3400
3434
|
const disabled = this.shouldDisabled;
|
3401
3435
|
// Change states which won't be recalculated during redrawing
|
3402
3436
|
if (this.visible !== visible) {
|
@@ -128,10 +128,10 @@ export default [
|
|
128
128
|
{
|
129
129
|
weight: 700,
|
130
130
|
type: 'checkbox',
|
131
|
-
label: '
|
131
|
+
label: 'Omit Value From Submission Data When Conditionally Hidden',
|
132
132
|
key: 'clearOnHide',
|
133
133
|
defaultValue: true,
|
134
|
-
tooltip: 'When a field is hidden,
|
134
|
+
tooltip: 'When a field is conditionally hidden, omit the value from the submission data.',
|
135
135
|
input: true
|
136
136
|
},
|
137
137
|
EditFormUtils.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 1000, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),
|
@@ -1,9 +1,9 @@
|
|
1
1
|
export default class Field extends Component {
|
2
2
|
/**
|
3
3
|
* @param {object} element - The component to create.
|
4
|
-
* @returns {
|
4
|
+
* @returns {string} - The rendered HTML string of a component
|
5
5
|
*/
|
6
|
-
render(element: object):
|
6
|
+
render(element: object): string;
|
7
7
|
/**
|
8
8
|
/* Saves current caret position to restore it after the component is redrawn
|
9
9
|
* @param {HTMLElement} element - The element to save the caret position for.
|
@@ -6,7 +6,7 @@ import Component from '../component/Component';
|
|
6
6
|
export default class Field extends Component {
|
7
7
|
/**
|
8
8
|
* @param {object} element - The component to create.
|
9
|
-
* @returns {
|
9
|
+
* @returns {string} - The rendered HTML string of a component
|
10
10
|
*/
|
11
11
|
render(element) {
|
12
12
|
if (this.noField) {
|
@@ -146,7 +146,7 @@ export default class NestedComponent extends Field {
|
|
146
146
|
*/
|
147
147
|
addComponent(component: import('@formio/core').Component, data?: object, before?: HTMLElement, noAdd?: boolean | undefined): any;
|
148
148
|
beforeFocus(): void;
|
149
|
-
render(children: any):
|
149
|
+
render(children: any): string;
|
150
150
|
renderComponents(components: any): any;
|
151
151
|
attach(element: any): Promise<[void, void]>;
|
152
152
|
/**
|