@formio/js 5.1.0-rc.1 → 5.1.0-rc.11
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.builder.css +22 -24
- package/dist/formio.builder.min.css +1 -1
- 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.css +22 -24
- package/dist/formio.form.js +36 -36
- 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 -3
- package/dist/formio.full.css +22 -24
- package/dist/formio.full.js +36 -36
- 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 -3
- 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/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +3 -0
- 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/datagrid/DataGrid.js +4 -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.d.ts +1 -0
- package/lib/cjs/components/form/Form.js +30 -14
- 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/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +3 -0
- 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/datagrid/DataGrid.js +4 -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.d.ts +1 -0
- package/lib/mjs/components/form/Form.js +29 -14
- 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 +4 -4
@@ -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
|
/**
|
@@ -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));
|
@@ -3,6 +3,7 @@ export default class NestedDataComponent extends NestedComponent {
|
|
3
3
|
hasChanged(newValue: any, oldValue: any): boolean;
|
4
4
|
get allowData(): boolean;
|
5
5
|
get emptyValue(): {};
|
6
|
+
get shouldAddDefaultValue(): boolean;
|
6
7
|
componentContext(): any;
|
7
8
|
getValueAsString(value: any, options: any): string;
|
8
9
|
getDataValueAsTable(value: any, options: any): string;
|
@@ -22,6 +22,9 @@ export default class NestedDataComponent extends NestedComponent {
|
|
22
22
|
get emptyValue() {
|
23
23
|
return {};
|
24
24
|
}
|
25
|
+
get shouldAddDefaultValue() {
|
26
|
+
return !this.options.noDefaults || !this.options.server;
|
27
|
+
}
|
25
28
|
componentContext() {
|
26
29
|
return this.dataValue;
|
27
30
|
}
|
@@ -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;
|
@@ -393,7 +393,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
393
393
|
row
|
394
394
|
});
|
395
395
|
this.checkConditions();
|
396
|
-
this.triggerChange();
|
396
|
+
this.triggerChange({ modified: true });
|
397
397
|
this.redraw().then(() => {
|
398
398
|
this.focusOnNewRowElement(this.rows[index]);
|
399
399
|
});
|
@@ -472,6 +472,9 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
472
472
|
options.name += `[${rowIndex}]`;
|
473
473
|
options.row = `${rowIndex}-${colIndex}`;
|
474
474
|
options.rowIndex = rowIndex;
|
475
|
+
options.onChange = (flags, changed, modified) => {
|
476
|
+
this.triggerChange({ modified });
|
477
|
+
};
|
475
478
|
let columnComponent;
|
476
479
|
if (this.builderMode) {
|
477
480
|
col.id = col.id + rowIndex;
|
@@ -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>;
|
@@ -32,6 +32,7 @@ export default class FormComponent extends Component {
|
|
32
32
|
attach(element: any): Promise<void>;
|
33
33
|
get hasLoadedForm(): any;
|
34
34
|
get isRevisionChanged(): any;
|
35
|
+
get subFormData(): any;
|
35
36
|
subFormReady: Promise<any> | null | undefined;
|
36
37
|
/**
|
37
38
|
* Pass everyComponent to subform.
|
@@ -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
|
}
|
@@ -327,6 +329,9 @@ export default class FormComponent extends Component {
|
|
327
329
|
&& _.isNumber(this.formObj._vid)
|
328
330
|
&& this.formObj._vid !== this.subFormRevision;
|
329
331
|
}
|
332
|
+
get subFormData() {
|
333
|
+
return this.dataValue?.data || {};
|
334
|
+
}
|
330
335
|
destroy(all = false) {
|
331
336
|
if (this.subForm) {
|
332
337
|
this.subForm.destroy(all);
|
@@ -389,12 +394,11 @@ export default class FormComponent extends Component {
|
|
389
394
|
return (new Form(form, this.getSubOptions())).ready.then((instance) => {
|
390
395
|
this.subForm = instance;
|
391
396
|
this.subForm.currentForm = this;
|
397
|
+
this.subForm.parentVisible = this.visible;
|
392
398
|
const componentsMap = this.componentsMap;
|
393
399
|
const formComponentsMap = this.subForm.componentsMap;
|
394
400
|
_.assign(componentsMap, formComponentsMap);
|
395
401
|
this.component.components = this.subForm.components.map((comp) => comp.component);
|
396
|
-
this.subForm.parent = this;
|
397
|
-
this.subForm.parentVisible = this.visible;
|
398
402
|
this.subForm.on('change', () => {
|
399
403
|
if (this.subForm) {
|
400
404
|
this.dataValue = this.subForm.getValue();
|
@@ -421,10 +425,11 @@ export default class FormComponent extends Component {
|
|
421
425
|
return this.subFormReady;
|
422
426
|
}
|
423
427
|
hideSubmitButton(component) {
|
424
|
-
const isSubmitButton =
|
425
|
-
((component.action === 'submit') || !component.action);
|
428
|
+
const isSubmitButton = component.type === 'button' && (component.action === 'submit' || !component.action);
|
426
429
|
if (isSubmitButton) {
|
427
430
|
component.hidden = true;
|
431
|
+
// clearOnHide no longer clears from the JSON `hidden` flag, so we make the button conditionally hidden to clear its data
|
432
|
+
component.customConditional = 'show = false';
|
428
433
|
}
|
429
434
|
}
|
430
435
|
/**
|
@@ -433,7 +438,7 @@ export default class FormComponent extends Component {
|
|
433
438
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
434
439
|
*/
|
435
440
|
loadSubForm(fromAttach) {
|
436
|
-
if (this.builderMode || this.
|
441
|
+
if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
|
437
442
|
return Promise.resolve();
|
438
443
|
}
|
439
444
|
if (this.hasLoadedForm && !this.isRevisionChanged &&
|
@@ -475,14 +480,14 @@ export default class FormComponent extends Component {
|
|
475
480
|
return visible;
|
476
481
|
}
|
477
482
|
if (this.subForm) {
|
478
|
-
return this.subForm.checkConditions(
|
483
|
+
return this.subForm.checkConditions(this.subFormData, flags);
|
479
484
|
}
|
480
485
|
// There are few cases when subForm is not loaded when a change is triggered,
|
481
486
|
// so we need to perform checkConditions after it is ready, or some conditional fields might be hidden in View mode
|
482
487
|
else if (this.subFormReady) {
|
483
488
|
this.subFormReady.then(() => {
|
484
489
|
if (this.subForm) {
|
485
|
-
return this.subForm.checkConditions(
|
490
|
+
return this.subForm.checkConditions(this.subFormData, flags);
|
486
491
|
}
|
487
492
|
});
|
488
493
|
}
|
@@ -490,7 +495,7 @@ export default class FormComponent extends Component {
|
|
490
495
|
}
|
491
496
|
calculateValue(data, flags, row) {
|
492
497
|
if (this.subForm) {
|
493
|
-
return this.subForm.calculateValue(
|
498
|
+
return this.subForm.calculateValue(this.subFormData, flags);
|
494
499
|
}
|
495
500
|
return super.calculateValue(data, flags, row);
|
496
501
|
}
|
@@ -505,7 +510,7 @@ export default class FormComponent extends Component {
|
|
505
510
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
506
511
|
*/
|
507
512
|
get shouldSubmit() {
|
508
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.
|
513
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
|
509
514
|
}
|
510
515
|
/**
|
511
516
|
* Returns the data for the subform.
|
@@ -575,11 +580,21 @@ export default class FormComponent extends Component {
|
|
575
580
|
this.dataValue = submission;
|
576
581
|
return Promise.resolve(this.dataValue);
|
577
582
|
}
|
578
|
-
|
579
|
-
.
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
+
if (this.isSubFormLazyLoad() && !this.subFormLoading) {
|
584
|
+
return this.createSubForm(true)
|
585
|
+
.then(this.submitSubForm(false))
|
586
|
+
.then(() => {
|
587
|
+
return this.dataValue;
|
588
|
+
})
|
589
|
+
.then(() => super.beforeSubmit());
|
590
|
+
}
|
591
|
+
else {
|
592
|
+
return this.submitSubForm(false)
|
593
|
+
.then(() => {
|
594
|
+
return this.dataValue;
|
595
|
+
})
|
596
|
+
.then(() => super.beforeSubmit());
|
597
|
+
}
|
583
598
|
}
|
584
599
|
isSubFormLazyLoad() {
|
585
600
|
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
|
/**
|