@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
@@ -81,17 +81,26 @@ export default class NestedComponent extends Field {
|
|
81
81
|
const visibilityChanged = this._visible !== value;
|
82
82
|
this._visible = value;
|
83
83
|
const isVisible = this.visible;
|
84
|
+
const isConditionallyHidden = this.checkConditionallyHidden();
|
84
85
|
const forceShow = this.shouldForceShow();
|
85
86
|
const forceHide = this.shouldForceHide();
|
86
|
-
this.components.forEach(component => {
|
87
|
+
this.components.forEach((component) => {
|
87
88
|
// Set the parent visibility first since we may have nested components within nested components
|
88
89
|
// and they need to be able to determine their visibility based on the parent visibility.
|
89
90
|
component.parentVisible = isVisible;
|
90
|
-
|
91
|
-
|
91
|
+
component._parentConditionallyHidden = isConditionallyHidden;
|
92
|
+
let visible;
|
93
|
+
if (component.hasCondition()) {
|
94
|
+
component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
|
95
|
+
visible = !component.conditionallyHidden;
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
visible = !component.component.hidden;
|
99
|
+
}
|
100
|
+
if (forceShow || visible) {
|
92
101
|
component.visible = true;
|
93
102
|
}
|
94
|
-
else if (forceHide || !isVisible || !
|
103
|
+
else if (forceHide || !isVisible || !visible) {
|
95
104
|
component.visible = false;
|
96
105
|
}
|
97
106
|
// If hiding a nested component, clear all errors below.
|
@@ -100,7 +109,6 @@ export default class NestedComponent extends Field {
|
|
100
109
|
}
|
101
110
|
});
|
102
111
|
if (visibilityChanged) {
|
103
|
-
this.clearOnHide();
|
104
112
|
this.redraw();
|
105
113
|
}
|
106
114
|
}
|
@@ -365,6 +373,7 @@ export default class NestedComponent extends Field {
|
|
365
373
|
data = data || this.data;
|
366
374
|
options.parent = this;
|
367
375
|
options.parentVisible = this.visible;
|
376
|
+
options.parentConditionallyHidden = this.conditionallyHidden;
|
368
377
|
options.root = options?.root || this.root || this;
|
369
378
|
options.localRoot = this.localRoot;
|
370
379
|
options.skipInit = true;
|
@@ -623,7 +632,7 @@ export default class NestedComponent extends Field {
|
|
623
632
|
clearOnHide(show) {
|
624
633
|
super.clearOnHide(show);
|
625
634
|
if (this.component.clearOnHide) {
|
626
|
-
if (this.allowData && !this.hasValue() && !
|
635
|
+
if (this.allowData && !this.hasValue() && !this.conditionallyHidden) {
|
627
636
|
this.dataValue = this.defaultValue;
|
628
637
|
}
|
629
638
|
if (this.hasValue()) {
|
@@ -652,7 +661,7 @@ export default class NestedComponent extends Field {
|
|
652
661
|
}
|
653
662
|
calculateValue(data, flags, row) {
|
654
663
|
// Do not iterate into children and calculateValues if this nested component is conditionally hidden.
|
655
|
-
if (
|
664
|
+
if (this.conditionallyHidden) {
|
656
665
|
return false;
|
657
666
|
}
|
658
667
|
return this.getComponents().reduce((changed, comp) => comp.calculateValue(data, flags, row) || changed, super.calculateValue(data, flags, row));
|
@@ -60,7 +60,7 @@ export default class AddressComponent extends ContainerComponent {
|
|
60
60
|
renderElement(value: any): any;
|
61
61
|
renderRow(value: any, index: any): any;
|
62
62
|
renderGrid(): any;
|
63
|
-
render():
|
63
|
+
render(): string;
|
64
64
|
onSelectAddress(address: any, element: any, index: any): void;
|
65
65
|
addRow(): void;
|
66
66
|
attach(element: any): Promise<void>;
|
@@ -71,4 +71,3 @@ export default class AddressComponent extends ContainerComponent {
|
|
71
71
|
getValueAsString(value: any, options: any): any;
|
72
72
|
}
|
73
73
|
import ContainerComponent from '../container/Container';
|
74
|
-
import Field from '../_classes/field/Field';
|
@@ -214,7 +214,7 @@ export default class AddressComponent extends ContainerComponent {
|
|
214
214
|
super.dataValue = value;
|
215
215
|
}
|
216
216
|
get dataValue() {
|
217
|
-
const resultValue = _.get(this._data, this.
|
217
|
+
const resultValue = _.get(this._data, this.path);
|
218
218
|
if (!_.isArray(resultValue) && this.component.multiple) {
|
219
219
|
return [resultValue];
|
220
220
|
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
declare namespace _default {
|
2
|
+
let type: string;
|
3
|
+
let display: string;
|
4
|
+
let title: string;
|
5
|
+
let name: string;
|
6
|
+
let path: string;
|
7
|
+
let components: ({
|
8
|
+
label: string;
|
9
|
+
tableView: boolean;
|
10
|
+
multiple: boolean;
|
11
|
+
provider: string;
|
12
|
+
validateWhenHidden: boolean;
|
13
|
+
key: string;
|
14
|
+
providerOptions: {
|
15
|
+
params: {
|
16
|
+
autocompleteOptions: {};
|
17
|
+
};
|
18
|
+
};
|
19
|
+
type: string;
|
20
|
+
input: boolean;
|
21
|
+
components: {
|
22
|
+
label: string;
|
23
|
+
tableView: boolean;
|
24
|
+
key: string;
|
25
|
+
type: string;
|
26
|
+
input: boolean;
|
27
|
+
customConditional: string;
|
28
|
+
}[];
|
29
|
+
defaultValue: {}[];
|
30
|
+
disableOnInvalid?: undefined;
|
31
|
+
} | {
|
32
|
+
type: string;
|
33
|
+
label: string;
|
34
|
+
key: string;
|
35
|
+
disableOnInvalid: boolean;
|
36
|
+
input: boolean;
|
37
|
+
tableView: boolean;
|
38
|
+
multiple?: undefined;
|
39
|
+
provider?: undefined;
|
40
|
+
validateWhenHidden?: undefined;
|
41
|
+
providerOptions?: undefined;
|
42
|
+
components?: undefined;
|
43
|
+
defaultValue?: undefined;
|
44
|
+
})[];
|
45
|
+
}
|
46
|
+
export default _default;
|
@@ -0,0 +1,85 @@
|
|
1
|
+
export default {
|
2
|
+
type: 'form',
|
3
|
+
display: 'form',
|
4
|
+
title: 'FIO-9527',
|
5
|
+
name: 'fio9527',
|
6
|
+
path: 'fio9527',
|
7
|
+
components: [
|
8
|
+
{
|
9
|
+
label: 'Address',
|
10
|
+
tableView: false,
|
11
|
+
multiple: true,
|
12
|
+
provider: 'nominatim',
|
13
|
+
validateWhenHidden: false,
|
14
|
+
key: 'address',
|
15
|
+
providerOptions: {
|
16
|
+
params: {
|
17
|
+
autocompleteOptions: {}
|
18
|
+
}
|
19
|
+
},
|
20
|
+
type: 'address',
|
21
|
+
input: true,
|
22
|
+
components: [
|
23
|
+
{
|
24
|
+
label: 'Address 1',
|
25
|
+
tableView: false,
|
26
|
+
key: 'address1',
|
27
|
+
type: 'textfield',
|
28
|
+
input: true,
|
29
|
+
customConditional: "show = _.get(instance, 'parent.manualMode', false);"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
label: 'Address 2',
|
33
|
+
tableView: false,
|
34
|
+
key: 'address2',
|
35
|
+
type: 'textfield',
|
36
|
+
input: true,
|
37
|
+
customConditional: "show = _.get(instance, 'parent.manualMode', false);"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
label: 'City',
|
41
|
+
tableView: false,
|
42
|
+
key: 'city',
|
43
|
+
type: 'textfield',
|
44
|
+
input: true,
|
45
|
+
customConditional: "show = _.get(instance, 'parent.manualMode', false);"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
label: 'State',
|
49
|
+
tableView: false,
|
50
|
+
key: 'state',
|
51
|
+
type: 'textfield',
|
52
|
+
input: true,
|
53
|
+
customConditional: "show = _.get(instance, 'parent.manualMode', false);"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
label: 'Country',
|
57
|
+
tableView: false,
|
58
|
+
key: 'country',
|
59
|
+
type: 'textfield',
|
60
|
+
input: true,
|
61
|
+
customConditional: "show = _.get(instance, 'parent.manualMode', false);"
|
62
|
+
},
|
63
|
+
{
|
64
|
+
label: 'Zip Code',
|
65
|
+
tableView: false,
|
66
|
+
key: 'zip',
|
67
|
+
type: 'textfield',
|
68
|
+
input: true,
|
69
|
+
customConditional: "show = _.get(instance, 'parent.manualMode', false);"
|
70
|
+
}
|
71
|
+
],
|
72
|
+
defaultValue: [
|
73
|
+
{}
|
74
|
+
]
|
75
|
+
},
|
76
|
+
{
|
77
|
+
type: 'button',
|
78
|
+
label: 'Submit',
|
79
|
+
key: 'submit',
|
80
|
+
disableOnInvalid: true,
|
81
|
+
input: true,
|
82
|
+
tableView: false
|
83
|
+
}
|
84
|
+
]
|
85
|
+
};
|
@@ -21,7 +21,7 @@ export default class ButtonComponent extends Field {
|
|
21
21
|
get clicked(): any;
|
22
22
|
get defaultValue(): boolean;
|
23
23
|
get oauthConfig(): any;
|
24
|
-
render():
|
24
|
+
render(): string;
|
25
25
|
attachButton(): void;
|
26
26
|
hasError: boolean | undefined;
|
27
27
|
isDisabledOnInvalid: any;
|
@@ -14,7 +14,7 @@ export default class ColumnsComponent extends NestedComponent {
|
|
14
14
|
get columnKey(): string;
|
15
15
|
columns: any[] | undefined;
|
16
16
|
labelIsHidden(): boolean;
|
17
|
-
render():
|
17
|
+
render(): string;
|
18
18
|
justifyColumn(items: any, index: any): boolean;
|
19
19
|
justify(): any;
|
20
20
|
get gridSize(): number;
|
@@ -54,7 +54,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
54
54
|
hasTopSubmit(): any;
|
55
55
|
hasBottomSubmit(): any;
|
56
56
|
get canAddColumn(): boolean;
|
57
|
-
render():
|
57
|
+
render(): string;
|
58
58
|
getRows(): {}[];
|
59
59
|
getColumns(): any[];
|
60
60
|
hasHeader(): any;
|
@@ -69,7 +69,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
69
69
|
}
|
70
70
|
get dataValue() {
|
71
71
|
if (!this.key ||
|
72
|
-
(
|
72
|
+
(this.conditionallyHidden && this.component.clearOnHide)) {
|
73
73
|
return this.emptyValue;
|
74
74
|
}
|
75
75
|
if (!this.hasValue() && this.shouldAddDefaultValue) {
|
@@ -85,7 +85,7 @@ export default class DayComponent extends Field {
|
|
85
85
|
}[] | undefined;
|
86
86
|
setErrorClasses(elements: any, dirty: any, hasError: any): void;
|
87
87
|
dayFirst: any;
|
88
|
-
render():
|
88
|
+
render(): string;
|
89
89
|
renderField(name: any): any;
|
90
90
|
attach(element: any): Promise<void>;
|
91
91
|
set disabled(disabled: any);
|
@@ -2,6 +2,7 @@ import _ from 'lodash';
|
|
2
2
|
import moment from 'moment';
|
3
3
|
import Field from '../_classes/field/Field';
|
4
4
|
import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils/utils';
|
5
|
+
import { getDayFormat } from '@formio/core';
|
5
6
|
export default class DayComponent extends Field {
|
6
7
|
static schema(...extend) {
|
7
8
|
return Field.schema({
|
@@ -474,24 +475,7 @@ export default class DayComponent extends Field {
|
|
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 getDayFormat(this.component);
|
495
479
|
}
|
496
480
|
/**
|
497
481
|
* Return the date for this component.
|
@@ -1132,7 +1132,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
1132
1132
|
}
|
1133
1133
|
}
|
1134
1134
|
const changed = this.hasChanged(value, this.dataValue);
|
1135
|
-
if (this.parent
|
1135
|
+
if (this.parent) {
|
1136
1136
|
this.parent.checkComponentConditions();
|
1137
1137
|
}
|
1138
1138
|
this.dataValue = value;
|
@@ -1165,10 +1165,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
1165
1165
|
this.editRows = this.editRows.slice(0, dataLength);
|
1166
1166
|
this.openWhenEmpty();
|
1167
1167
|
this.updateOnChange(flags, changed);
|
1168
|
-
|
1169
|
-
if (!this.options.server) {
|
1170
|
-
this.checkData();
|
1171
|
-
}
|
1168
|
+
this.checkData();
|
1172
1169
|
this.changeState(changed, flags);
|
1173
1170
|
return changed;
|
1174
1171
|
}
|
@@ -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>;
|
@@ -138,6 +138,8 @@ export default class FormComponent extends Component {
|
|
138
138
|
options.events = this.createEmitter();
|
139
139
|
// Make sure to not show the submit button in wizards in the nested forms.
|
140
140
|
_.set(options, 'buttonSettings.showSubmit', false);
|
141
|
+
// Set the parent option to the subform so those references are stable when the subform is created
|
142
|
+
options.parent = this;
|
141
143
|
if (!this.options) {
|
142
144
|
return options;
|
143
145
|
}
|
@@ -389,12 +391,11 @@ export default class FormComponent extends Component {
|
|
389
391
|
return (new Form(form, this.getSubOptions())).ready.then((instance) => {
|
390
392
|
this.subForm = instance;
|
391
393
|
this.subForm.currentForm = this;
|
394
|
+
this.subForm.parentVisible = this.visible;
|
392
395
|
const componentsMap = this.componentsMap;
|
393
396
|
const formComponentsMap = this.subForm.componentsMap;
|
394
397
|
_.assign(componentsMap, formComponentsMap);
|
395
398
|
this.component.components = this.subForm.components.map((comp) => comp.component);
|
396
|
-
this.subForm.parent = this;
|
397
|
-
this.subForm.parentVisible = this.visible;
|
398
399
|
this.subForm.on('change', () => {
|
399
400
|
if (this.subForm) {
|
400
401
|
this.dataValue = this.subForm.getValue();
|
@@ -421,10 +422,11 @@ export default class FormComponent extends Component {
|
|
421
422
|
return this.subFormReady;
|
422
423
|
}
|
423
424
|
hideSubmitButton(component) {
|
424
|
-
const isSubmitButton =
|
425
|
-
((component.action === 'submit') || !component.action);
|
425
|
+
const isSubmitButton = component.type === 'button' && (component.action === 'submit' || !component.action);
|
426
426
|
if (isSubmitButton) {
|
427
427
|
component.hidden = true;
|
428
|
+
// clearOnHide no longer clears from the JSON `hidden` flag, so we make the button conditionally hidden to clear its data
|
429
|
+
component.customConditional = 'show = false';
|
428
430
|
}
|
429
431
|
}
|
430
432
|
/**
|
@@ -433,7 +435,7 @@ export default class FormComponent extends Component {
|
|
433
435
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
434
436
|
*/
|
435
437
|
loadSubForm(fromAttach) {
|
436
|
-
if (this.builderMode || this.
|
438
|
+
if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
|
437
439
|
return Promise.resolve();
|
438
440
|
}
|
439
441
|
if (this.hasLoadedForm && !this.isRevisionChanged &&
|
@@ -505,7 +507,7 @@ export default class FormComponent extends Component {
|
|
505
507
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
506
508
|
*/
|
507
509
|
get shouldSubmit() {
|
508
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.
|
510
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
|
509
511
|
}
|
510
512
|
/**
|
511
513
|
* Returns the data for the subform.
|
@@ -575,11 +577,21 @@ export default class FormComponent extends Component {
|
|
575
577
|
this.dataValue = submission;
|
576
578
|
return Promise.resolve(this.dataValue);
|
577
579
|
}
|
578
|
-
|
579
|
-
.
|
580
|
-
|
581
|
-
|
582
|
-
|
580
|
+
if (this.isSubFormLazyLoad() && !this.subFormLoading) {
|
581
|
+
return this.createSubForm(true)
|
582
|
+
.then(this.submitSubForm(false))
|
583
|
+
.then(() => {
|
584
|
+
return this.dataValue;
|
585
|
+
})
|
586
|
+
.then(() => super.beforeSubmit());
|
587
|
+
}
|
588
|
+
else {
|
589
|
+
return this.submitSubForm(false)
|
590
|
+
.then(() => {
|
591
|
+
return this.dataValue;
|
592
|
+
})
|
593
|
+
.then(() => super.beforeSubmit());
|
594
|
+
}
|
583
595
|
}
|
584
596
|
isSubFormLazyLoad() {
|
585
597
|
return this.root?._form?.display === 'wizard' && this.component.lazyLoad;
|
@@ -51,9 +51,21 @@ export default class HTMLComponent extends Component {
|
|
51
51
|
}
|
52
52
|
checkRefreshOn(changed) {
|
53
53
|
super.checkRefreshOn(changed);
|
54
|
-
|
55
|
-
|
56
|
-
this.
|
54
|
+
let visible;
|
55
|
+
if (this.hasCondition()) {
|
56
|
+
this._conditionallyHidden = this.checkConditionallyHidden();
|
57
|
+
visible = !this.conditionallyHidden;
|
58
|
+
}
|
59
|
+
else {
|
60
|
+
visible = !this.component.hidden;
|
61
|
+
}
|
62
|
+
const shouldSetContent = !this.builderMode
|
63
|
+
&& this.component.refreshOnChange
|
64
|
+
&& this.element
|
65
|
+
&& !_.isUndefined(changed)
|
66
|
+
&& ((_.isBoolean(changed) && changed) || !_.isEmpty(changed))
|
67
|
+
&& visible;
|
68
|
+
if (shouldSetContent) {
|
57
69
|
this.setContent(this.element, this.renderContent());
|
58
70
|
}
|
59
71
|
}
|
@@ -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/mjs/formio.embed.js
CHANGED
@@ -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
|
/**
|
@@ -2,6 +2,9 @@
|
|
2
2
|
import { Formio } from '../../Formio';
|
3
3
|
import _ from 'lodash';
|
4
4
|
import { AddressProvider } from './AddressProvider';
|
5
|
+
const GOOGLE_MAPS_BASE_URL = 'https://maps.googleapis.com';
|
6
|
+
const GOOGLE_MAPS_JS_URL = `${GOOGLE_MAPS_BASE_URL}/maps/api/js`;
|
7
|
+
const GOOGLE_MAPS_JS_WITH_PARAMS_URL = `${GOOGLE_MAPS_JS_URL}?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback`;
|
5
8
|
/**
|
6
9
|
* @typedef {object} AutocompleteOptions
|
7
10
|
* @property {string[]} fields - The fields to include in the autocomplete response.
|
@@ -48,10 +51,11 @@ export class GoogleAddressProvider extends AddressProvider {
|
|
48
51
|
constructor(options = {}) {
|
49
52
|
super(options);
|
50
53
|
this.setAutocompleteOptions();
|
51
|
-
let src =
|
54
|
+
let src = GOOGLE_MAPS_JS_WITH_PARAMS_URL;
|
52
55
|
if (options.params?.key) {
|
53
56
|
src += `&key=${options.params.key}`;
|
54
57
|
}
|
58
|
+
this.tryRemoveLibrary(options);
|
55
59
|
Formio.requireLibrary(this.getLibraryName(), 'google.maps.places', src);
|
56
60
|
}
|
57
61
|
/**
|
@@ -178,4 +182,21 @@ export class GoogleAddressProvider extends AddressProvider {
|
|
178
182
|
: this.alternativeDisplayValueProperty;
|
179
183
|
return _.get(address, displayedProperty, '');
|
180
184
|
}
|
185
|
+
/**
|
186
|
+
* Tries to remove the library if api key for loaded script is different.
|
187
|
+
* @param {ProviderOptions} options - The options for the provider.
|
188
|
+
*/
|
189
|
+
tryRemoveLibrary(options = {}) {
|
190
|
+
if (!Formio.libraries[this.getLibraryName()]) {
|
191
|
+
return;
|
192
|
+
}
|
193
|
+
const existingScript = document.querySelector(`script[src^="${GOOGLE_MAPS_JS_URL}"]`);
|
194
|
+
if (existingScript && options.params?.key && !existingScript.attributes.src.value.endsWith(options.params.key)) {
|
195
|
+
const googleMapsScripts = document.querySelectorAll(`script[src^="${GOOGLE_MAPS_BASE_URL}"]`) ?? [];
|
196
|
+
googleMapsScripts.forEach(script => script.parentNode.removeChild(script));
|
197
|
+
delete Formio.libraries[this.getLibraryName()];
|
198
|
+
delete global?.google?.maps;
|
199
|
+
delete global[`${this.getLibraryName()}Callback`];
|
200
|
+
}
|
201
|
+
}
|
181
202
|
}
|
@@ -24,8 +24,8 @@ export default {
|
|
24
24
|
maxWords: '{{field}} must have no more than {{length}} words.',
|
25
25
|
min: '{{field}} cannot be less than {{min}}.',
|
26
26
|
max: '{{field}} cannot be greater than {{max}}.',
|
27
|
-
maxDate: '{{field}} should not contain date after {{
|
28
|
-
minDate: '{{field}} should not contain date before {{
|
27
|
+
maxDate: '{{field}} should not contain date after {{maxDate}}',
|
28
|
+
minDate: '{{field}} should not contain date before {{minDate}}',
|
29
29
|
maxYear: '{{field}} should not contain year greater than {{maxYear}}',
|
30
30
|
minYear: '{{field}} should not contain year less than {{minYear}}',
|
31
31
|
minSelectedCount: 'You must select at least {{minCount}} items',
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@formio/js",
|
3
|
-
"version": "5.1.0-rc.
|
3
|
+
"version": "5.1.0-rc.10",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"exports": {
|
@@ -41,7 +41,7 @@
|
|
41
41
|
"build": "yarn doc && yarn lib && yarn dist",
|
42
42
|
"doc": "typedoc",
|
43
43
|
"dist": "gulp clean:dist && webpack --config webpack.config.js && webpack --config webpack.prod.js && gulp build",
|
44
|
-
"lib": "gulp clean:lib && tsc --project tsconfig.cjs.json && tsc --project tsconfig.mjs.json && yarn lib:package",
|
44
|
+
"lib": "gulp clean:lib && tsc --project tsconfig.cjs.json && tsc --project tsconfig.mjs.json && yarn lib:package && gulp version",
|
45
45
|
"lib:package": "node ./libpackage.js",
|
46
46
|
"version": "node -e 'console.log(require(`./package.json`).version)'",
|
47
47
|
"build-app": "yarn build-app:create-app && yarn build-app:jekyll && yarn build-app:remove-app",
|
@@ -81,7 +81,7 @@
|
|
81
81
|
"dependencies": {
|
82
82
|
"@formio/bootstrap": "3.1.0-rc.1",
|
83
83
|
"@formio/choices.js": "^10.2.1",
|
84
|
-
"@formio/core": "2.4.0-rc.
|
84
|
+
"@formio/core": "2.4.0-rc.7",
|
85
85
|
"@formio/text-mask-addons": "^3.8.0-formio.4",
|
86
86
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
87
87
|
"abortcontroller-polyfill": "^1.7.5",
|