@formio/js 5.0.0-dev.5925.ef39512 → 5.0.0-dev.5932.9b8cb6d
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.form.js +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +2 -2
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/WebformBuilder.js +7 -0
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +1 -2
- package/lib/cjs/components/selectboxes/SelectBoxes.js +15 -1
- package/lib/mjs/WebformBuilder.js +7 -0
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +1 -2
- package/lib/mjs/components/selectboxes/SelectBoxes.js +15 -1
- package/package.json +1 -1
|
@@ -1085,6 +1085,12 @@ class WebformBuilder extends Component_1.default {
|
|
|
1085
1085
|
parentComponent.tabs[tabIndex].splice(index, 1, newComp);
|
|
1086
1086
|
newComp.checkValidity = () => true;
|
|
1087
1087
|
newComp.build(defaultValueComponent.element);
|
|
1088
|
+
if (this.preview && !this.preview.defaultChanged) {
|
|
1089
|
+
const defaultValue = lodash_1.default.get(this.preview._data, this.editForm._data.key);
|
|
1090
|
+
if (lodash_1.default.isObject(defaultValue) && !lodash_1.default.isArray(defaultValue)) {
|
|
1091
|
+
this.editForm._data.defaultValue = defaultValue;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1088
1094
|
}
|
|
1089
1095
|
}
|
|
1090
1096
|
else {
|
|
@@ -1095,6 +1101,7 @@ class WebformBuilder extends Component_1.default {
|
|
|
1095
1101
|
path.unshift(component.key);
|
|
1096
1102
|
dataPath = (0, utils_1.getStringFromComponentPath)(path);
|
|
1097
1103
|
}
|
|
1104
|
+
this.preview.defaultChanged = true;
|
|
1098
1105
|
lodash_1.default.set(this.preview._data, dataPath, changed.value);
|
|
1099
1106
|
lodash_1.default.set(this.webform._data, dataPath, changed.value);
|
|
1100
1107
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export default class SelectBoxesComponent extends RadioComponent {
|
|
2
2
|
static savedValueTypes(schema: any): string[];
|
|
3
3
|
constructor(...args: any[]);
|
|
4
|
-
get emptyValue():
|
|
5
|
-
get defaultValue(): {};
|
|
4
|
+
get emptyValue(): any;
|
|
6
5
|
/**
|
|
7
6
|
* Only empty if the values are all false.
|
|
8
7
|
* @param {any} value - The value to check if empty.
|
|
@@ -65,7 +65,12 @@ class SelectBoxesComponent extends Radio_1.default {
|
|
|
65
65
|
return info;
|
|
66
66
|
}
|
|
67
67
|
get emptyValue() {
|
|
68
|
-
return {
|
|
68
|
+
return this.component.values.reduce((prev, value) => {
|
|
69
|
+
if (value.value) {
|
|
70
|
+
prev[value.value] = false;
|
|
71
|
+
}
|
|
72
|
+
return prev;
|
|
73
|
+
}, {});
|
|
69
74
|
}
|
|
70
75
|
get defaultValue() {
|
|
71
76
|
let defaultValue = this.emptyValue;
|
|
@@ -134,6 +139,14 @@ class SelectBoxesComponent extends Radio_1.default {
|
|
|
134
139
|
checkedValues.forEach((value) => selectData.push(this.templateData[value]));
|
|
135
140
|
lodash_1.default.set(submission.metadata.selectData, this.path, selectData);
|
|
136
141
|
}
|
|
142
|
+
// Ensure that for dataSrc == 'values' that there are not any other superfluous values.
|
|
143
|
+
if (this.component.dataSrc === 'values') {
|
|
144
|
+
for (const key in value) {
|
|
145
|
+
if (!this.component.values.find((val) => val.value === key)) {
|
|
146
|
+
delete value[key];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
137
150
|
return value;
|
|
138
151
|
}
|
|
139
152
|
/**
|
|
@@ -262,6 +275,7 @@ class SelectBoxesComponent extends Radio_1.default {
|
|
|
262
275
|
else {
|
|
263
276
|
return super.setCustomValidity(messages, dirty, external);
|
|
264
277
|
}
|
|
278
|
+
;
|
|
265
279
|
}
|
|
266
280
|
validateValueAvailability(setting, value) {
|
|
267
281
|
if (!(0, utils_1.boolValue)(setting) || !value) {
|
|
@@ -1069,6 +1069,12 @@ export default class WebformBuilder extends Component {
|
|
|
1069
1069
|
parentComponent.tabs[tabIndex].splice(index, 1, newComp);
|
|
1070
1070
|
newComp.checkValidity = () => true;
|
|
1071
1071
|
newComp.build(defaultValueComponent.element);
|
|
1072
|
+
if (this.preview && !this.preview.defaultChanged) {
|
|
1073
|
+
const defaultValue = _.get(this.preview._data, this.editForm._data.key);
|
|
1074
|
+
if (_.isObject(defaultValue) && !_.isArray(defaultValue)) {
|
|
1075
|
+
this.editForm._data.defaultValue = defaultValue;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1072
1078
|
}
|
|
1073
1079
|
}
|
|
1074
1080
|
else {
|
|
@@ -1079,6 +1085,7 @@ export default class WebformBuilder extends Component {
|
|
|
1079
1085
|
path.unshift(component.key);
|
|
1080
1086
|
dataPath = getStringFromComponentPath(path);
|
|
1081
1087
|
}
|
|
1088
|
+
this.preview.defaultChanged = true;
|
|
1082
1089
|
_.set(this.preview._data, dataPath, changed.value);
|
|
1083
1090
|
_.set(this.webform._data, dataPath, changed.value);
|
|
1084
1091
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export default class SelectBoxesComponent extends RadioComponent {
|
|
2
2
|
static savedValueTypes(schema: any): string[];
|
|
3
3
|
constructor(...args: any[]);
|
|
4
|
-
get emptyValue():
|
|
5
|
-
get defaultValue(): {};
|
|
4
|
+
get emptyValue(): any;
|
|
6
5
|
/**
|
|
7
6
|
* Only empty if the values are all false.
|
|
8
7
|
* @param {any} value - The value to check if empty.
|
|
@@ -67,7 +67,12 @@ export default class SelectBoxesComponent extends RadioComponent {
|
|
|
67
67
|
return info;
|
|
68
68
|
}
|
|
69
69
|
get emptyValue() {
|
|
70
|
-
return {
|
|
70
|
+
return this.component.values.reduce((prev, value) => {
|
|
71
|
+
if (value.value) {
|
|
72
|
+
prev[value.value] = false;
|
|
73
|
+
}
|
|
74
|
+
return prev;
|
|
75
|
+
}, {});
|
|
71
76
|
}
|
|
72
77
|
get defaultValue() {
|
|
73
78
|
let defaultValue = this.emptyValue;
|
|
@@ -136,6 +141,14 @@ export default class SelectBoxesComponent extends RadioComponent {
|
|
|
136
141
|
checkedValues.forEach((value) => selectData.push(this.templateData[value]));
|
|
137
142
|
_.set(submission.metadata.selectData, this.path, selectData);
|
|
138
143
|
}
|
|
144
|
+
// Ensure that for dataSrc == 'values' that there are not any other superfluous values.
|
|
145
|
+
if (this.component.dataSrc === 'values') {
|
|
146
|
+
for (const key in value) {
|
|
147
|
+
if (!this.component.values.find((val) => val.value === key)) {
|
|
148
|
+
delete value[key];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
139
152
|
return value;
|
|
140
153
|
}
|
|
141
154
|
/**
|
|
@@ -263,6 +276,7 @@ export default class SelectBoxesComponent extends RadioComponent {
|
|
|
263
276
|
else {
|
|
264
277
|
return super.setCustomValidity(messages, dirty, external);
|
|
265
278
|
}
|
|
279
|
+
;
|
|
266
280
|
}
|
|
267
281
|
validateValueAvailability(setting, value) {
|
|
268
282
|
if (!boolValue(setting) || !value) {
|