@formio/js 5.0.0-dev.5844.c491f7d → 5.0.0-dev.5846.7f5a910
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +6 -0
- package/dist/formio.form.js +5 -5
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +5 -5
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/Webform.js +5 -3
- package/lib/cjs/components/_classes/component/Component.js +7 -6
- package/lib/cjs/components/_classes/nested/NestedComponent.js +7 -6
- package/lib/cjs/components/editgrid/EditGrid.js +1 -0
- package/lib/cjs/components/select/Select.js +12 -4
- package/lib/mjs/Webform.js +5 -3
- package/lib/mjs/components/_classes/component/Component.js +6 -6
- package/lib/mjs/components/_classes/nested/NestedComponent.js +7 -6
- package/lib/mjs/components/editgrid/EditGrid.js +1 -0
- package/lib/mjs/components/select/Select.js +12 -4
- package/package.json +1 -1
package/lib/cjs/Webform.js
CHANGED
|
@@ -710,6 +710,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
710
710
|
*/
|
|
711
711
|
onSetSubmission(submission, flags = {}) {
|
|
712
712
|
this.submissionSet = true;
|
|
713
|
+
flags.submission = structuredClone(submission);
|
|
713
714
|
this.triggerChange(flags);
|
|
714
715
|
this.emit('beforeSetSubmission', submission);
|
|
715
716
|
this.setValue(submission, flags);
|
|
@@ -1247,9 +1248,10 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1247
1248
|
this.pristine = false;
|
|
1248
1249
|
}
|
|
1249
1250
|
this.checkData(value.data, flags);
|
|
1250
|
-
|
|
1251
|
-
flags.
|
|
1252
|
-
|
|
1251
|
+
let shouldValidate = flags.noValidate ? false :
|
|
1252
|
+
lodash_1.default.isUndefined(flags.noValidate) ||
|
|
1253
|
+
flags.fromIframe ||
|
|
1254
|
+
(flags.fromSubmission && this.rootPristine && this.pristine);
|
|
1253
1255
|
const errors = shouldValidate
|
|
1254
1256
|
? this.validate(value.data, Object.assign(Object.assign({}, flags), { noValidate: false, process: 'change' }))
|
|
1255
1257
|
: [];
|
|
@@ -2456,7 +2456,6 @@ class Component extends Element_1.default {
|
|
|
2456
2456
|
return;
|
|
2457
2457
|
}
|
|
2458
2458
|
lodash_1.default.set(this._data, this.key, value);
|
|
2459
|
-
return;
|
|
2460
2459
|
}
|
|
2461
2460
|
/**
|
|
2462
2461
|
* Splice a value from the dataValue.
|
|
@@ -2959,17 +2958,19 @@ class Component extends Element_1.default {
|
|
|
2959
2958
|
* @returns {boolean} - TRUE if the component is valid.
|
|
2960
2959
|
*/
|
|
2961
2960
|
showValidationErrors(errors, data, row, flags) {
|
|
2961
|
+
var _a;
|
|
2962
2962
|
if (flags.silentCheck) {
|
|
2963
2963
|
return [];
|
|
2964
2964
|
}
|
|
2965
|
+
let dirty = this.dirty || flags.dirty;
|
|
2965
2966
|
if (this.options.alwaysDirty) {
|
|
2966
|
-
|
|
2967
|
+
dirty = true;
|
|
2967
2968
|
}
|
|
2968
|
-
if (flags.fromSubmission &&
|
|
2969
|
-
|
|
2969
|
+
if (flags.fromSubmission && !lodash_1.default.isUndefined(lodash_1.default.get((_a = flags === null || flags === void 0 ? void 0 : flags.submission) === null || _a === void 0 ? void 0 : _a.data, this.key)) && !(this.pristine && this.protected)) {
|
|
2970
|
+
dirty = this.pristine && this.component.protected ? false : true;
|
|
2970
2971
|
}
|
|
2971
|
-
this.setDirty(
|
|
2972
|
-
return this.setComponentValidity(errors,
|
|
2972
|
+
this.setDirty(dirty);
|
|
2973
|
+
return this.setComponentValidity(errors, dirty, flags.silentCheck, flags.fromSubmission);
|
|
2973
2974
|
}
|
|
2974
2975
|
/**
|
|
2975
2976
|
* Perform a component validation.
|
|
@@ -827,22 +827,23 @@ class NestedComponent extends Field_1.default {
|
|
|
827
827
|
}
|
|
828
828
|
setNestedValue(component, value, flags = {}) {
|
|
829
829
|
component._data = this.componentContext(component);
|
|
830
|
+
let componentFlags = Object.assign({}, flags);
|
|
830
831
|
if (component.type === 'button') {
|
|
831
832
|
return false;
|
|
832
833
|
}
|
|
833
834
|
if (component.type === 'components') {
|
|
834
835
|
if (component.tree && component.hasValue(value)) {
|
|
835
|
-
return component.setValue(lodash_1.default.get(value, component.key),
|
|
836
|
+
return component.setValue(lodash_1.default.get(value, component.key), componentFlags);
|
|
836
837
|
}
|
|
837
|
-
return component.setValue(value,
|
|
838
|
+
return component.setValue(value, componentFlags);
|
|
838
839
|
}
|
|
839
840
|
else if (value && component.hasValue(value)) {
|
|
840
|
-
return component.setValue(lodash_1.default.get(value, component.key),
|
|
841
|
+
return component.setValue(lodash_1.default.get(value, component.key), componentFlags);
|
|
841
842
|
}
|
|
842
843
|
else if ((!this.rootPristine || component.visible) && component.shouldAddDefaultValue) {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
return component.setValue(component.defaultValue,
|
|
844
|
+
componentFlags.noValidate = !componentFlags.dirty;
|
|
845
|
+
componentFlags.resetValue = true;
|
|
846
|
+
return component.setValue(component.defaultValue, componentFlags);
|
|
846
847
|
}
|
|
847
848
|
}
|
|
848
849
|
setValue(value, flags = {}) {
|
|
@@ -983,6 +983,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
983
983
|
editRow.state === EditRowState.New ||
|
|
984
984
|
editRow.state === EditRowState.Editing ||
|
|
985
985
|
editRow.alerts ||
|
|
986
|
+
this.dirty ||
|
|
986
987
|
dirty;
|
|
987
988
|
}
|
|
988
989
|
validateRow(editRow, dirty, forceSilentCheck) {
|
|
@@ -246,7 +246,11 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
246
246
|
const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
|
|
247
247
|
return this.sanitize(value, this.shouldSanitizeValue);
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
// Inside DataTable component won't have dataValue set
|
|
250
|
+
const shouldUseSelectData = (this.component.multiple && lodash_1.default.isArray(this.dataValue)
|
|
251
|
+
? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)
|
|
252
|
+
: (this.dataValue === this.normalizeSingleValue(value))) || this.inDataTable;
|
|
253
|
+
if (shouldUseSelectData) {
|
|
250
254
|
const selectData = this.selectData;
|
|
251
255
|
if (selectData) {
|
|
252
256
|
const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
|
|
@@ -1213,7 +1217,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1213
1217
|
// Check to see if we need to save off the template data into our metadata.
|
|
1214
1218
|
const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
|
|
1215
1219
|
const shouldSaveData = !valueIsObject || this.component.reference;
|
|
1216
|
-
if (templateValue && shouldSaveData && this.templateData && this.templateData[templateValue] && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submission)) {
|
|
1220
|
+
if (!lodash_1.default.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submission)) {
|
|
1217
1221
|
const submission = this.root.submission;
|
|
1218
1222
|
if (!submission.metadata) {
|
|
1219
1223
|
submission.metadata = {};
|
|
@@ -1468,8 +1472,12 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1468
1472
|
asString(value, options = {}) {
|
|
1469
1473
|
var _a;
|
|
1470
1474
|
value = value !== null && value !== void 0 ? value : this.getValue();
|
|
1471
|
-
if (options.modalPreview) {
|
|
1472
|
-
|
|
1475
|
+
if (options.modalPreview || this.inDataTable) {
|
|
1476
|
+
if (this.inDataTable) {
|
|
1477
|
+
value = this.undoValueTyping(value);
|
|
1478
|
+
}
|
|
1479
|
+
const templateValue = (this.isEntireObjectDisplay() && !lodash_1.default.isObject(value.data)) ? { data: value } : value;
|
|
1480
|
+
const template = this.itemTemplate(templateValue, value, options);
|
|
1473
1481
|
return template;
|
|
1474
1482
|
}
|
|
1475
1483
|
//need to convert values to strings to be able to compare values with available options that are strings
|
package/lib/mjs/Webform.js
CHANGED
|
@@ -708,6 +708,7 @@ export default class Webform extends NestedDataComponent {
|
|
|
708
708
|
*/
|
|
709
709
|
onSetSubmission(submission, flags = {}) {
|
|
710
710
|
this.submissionSet = true;
|
|
711
|
+
flags.submission = structuredClone(submission);
|
|
711
712
|
this.triggerChange(flags);
|
|
712
713
|
this.emit('beforeSetSubmission', submission);
|
|
713
714
|
this.setValue(submission, flags);
|
|
@@ -1249,9 +1250,10 @@ export default class Webform extends NestedDataComponent {
|
|
|
1249
1250
|
this.pristine = false;
|
|
1250
1251
|
}
|
|
1251
1252
|
this.checkData(value.data, flags);
|
|
1252
|
-
|
|
1253
|
-
flags.
|
|
1254
|
-
|
|
1253
|
+
let shouldValidate = flags.noValidate ? false :
|
|
1254
|
+
_.isUndefined(flags.noValidate) ||
|
|
1255
|
+
flags.fromIframe ||
|
|
1256
|
+
(flags.fromSubmission && this.rootPristine && this.pristine);
|
|
1255
1257
|
const errors = shouldValidate
|
|
1256
1258
|
? this.validate(value.data, {
|
|
1257
1259
|
...flags,
|
|
@@ -2422,7 +2422,6 @@ export default class Component extends Element {
|
|
|
2422
2422
|
return;
|
|
2423
2423
|
}
|
|
2424
2424
|
_.set(this._data, this.key, value);
|
|
2425
|
-
return;
|
|
2426
2425
|
}
|
|
2427
2426
|
/**
|
|
2428
2427
|
* Splice a value from the dataValue.
|
|
@@ -2926,14 +2925,15 @@ export default class Component extends Element {
|
|
|
2926
2925
|
if (flags.silentCheck) {
|
|
2927
2926
|
return [];
|
|
2928
2927
|
}
|
|
2928
|
+
let dirty = this.dirty || flags.dirty;
|
|
2929
2929
|
if (this.options.alwaysDirty) {
|
|
2930
|
-
|
|
2930
|
+
dirty = true;
|
|
2931
2931
|
}
|
|
2932
|
-
if (flags.fromSubmission &&
|
|
2933
|
-
|
|
2932
|
+
if (flags.fromSubmission && !_.isUndefined(_.get(flags?.submission?.data, this.key)) && !(this.pristine && this.protected)) {
|
|
2933
|
+
dirty = this.pristine && this.component.protected ? false : true;
|
|
2934
2934
|
}
|
|
2935
|
-
this.setDirty(
|
|
2936
|
-
return this.setComponentValidity(errors,
|
|
2935
|
+
this.setDirty(dirty);
|
|
2936
|
+
return this.setComponentValidity(errors, dirty, flags.silentCheck, flags.fromSubmission);
|
|
2937
2937
|
}
|
|
2938
2938
|
/**
|
|
2939
2939
|
* Perform a component validation.
|
|
@@ -822,22 +822,23 @@ export default class NestedComponent extends Field {
|
|
|
822
822
|
}
|
|
823
823
|
setNestedValue(component, value, flags = {}) {
|
|
824
824
|
component._data = this.componentContext(component);
|
|
825
|
+
let componentFlags = { ...flags };
|
|
825
826
|
if (component.type === 'button') {
|
|
826
827
|
return false;
|
|
827
828
|
}
|
|
828
829
|
if (component.type === 'components') {
|
|
829
830
|
if (component.tree && component.hasValue(value)) {
|
|
830
|
-
return component.setValue(_.get(value, component.key),
|
|
831
|
+
return component.setValue(_.get(value, component.key), componentFlags);
|
|
831
832
|
}
|
|
832
|
-
return component.setValue(value,
|
|
833
|
+
return component.setValue(value, componentFlags);
|
|
833
834
|
}
|
|
834
835
|
else if (value && component.hasValue(value)) {
|
|
835
|
-
return component.setValue(_.get(value, component.key),
|
|
836
|
+
return component.setValue(_.get(value, component.key), componentFlags);
|
|
836
837
|
}
|
|
837
838
|
else if ((!this.rootPristine || component.visible) && component.shouldAddDefaultValue) {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
return component.setValue(component.defaultValue,
|
|
839
|
+
componentFlags.noValidate = !componentFlags.dirty;
|
|
840
|
+
componentFlags.resetValue = true;
|
|
841
|
+
return component.setValue(component.defaultValue, componentFlags);
|
|
841
842
|
}
|
|
842
843
|
}
|
|
843
844
|
setValue(value, flags = {}) {
|
|
@@ -973,6 +973,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
973
973
|
editRow.state === EditRowState.New ||
|
|
974
974
|
editRow.state === EditRowState.Editing ||
|
|
975
975
|
editRow.alerts ||
|
|
976
|
+
this.dirty ||
|
|
976
977
|
dirty;
|
|
977
978
|
}
|
|
978
979
|
validateRow(editRow, dirty, forceSilentCheck) {
|
|
@@ -246,7 +246,11 @@ export default class SelectComponent extends ListComponent {
|
|
|
246
246
|
const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
|
|
247
247
|
return this.sanitize(value, this.shouldSanitizeValue);
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
// Inside DataTable component won't have dataValue set
|
|
250
|
+
const shouldUseSelectData = (this.component.multiple && _.isArray(this.dataValue)
|
|
251
|
+
? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)
|
|
252
|
+
: (this.dataValue === this.normalizeSingleValue(value))) || this.inDataTable;
|
|
253
|
+
if (shouldUseSelectData) {
|
|
250
254
|
const selectData = this.selectData;
|
|
251
255
|
if (selectData) {
|
|
252
256
|
const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
|
|
@@ -1241,7 +1245,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1241
1245
|
// Check to see if we need to save off the template data into our metadata.
|
|
1242
1246
|
const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
|
|
1243
1247
|
const shouldSaveData = !valueIsObject || this.component.reference;
|
|
1244
|
-
if (templateValue && shouldSaveData && this.templateData && this.templateData[templateValue] && this.root?.submission) {
|
|
1248
|
+
if (!_.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && this.root?.submission) {
|
|
1245
1249
|
const submission = this.root.submission;
|
|
1246
1250
|
if (!submission.metadata) {
|
|
1247
1251
|
submission.metadata = {};
|
|
@@ -1495,8 +1499,12 @@ export default class SelectComponent extends ListComponent {
|
|
|
1495
1499
|
}
|
|
1496
1500
|
asString(value, options = {}) {
|
|
1497
1501
|
value = value ?? this.getValue();
|
|
1498
|
-
if (options.modalPreview) {
|
|
1499
|
-
|
|
1502
|
+
if (options.modalPreview || this.inDataTable) {
|
|
1503
|
+
if (this.inDataTable) {
|
|
1504
|
+
value = this.undoValueTyping(value);
|
|
1505
|
+
}
|
|
1506
|
+
const templateValue = (this.isEntireObjectDisplay() && !_.isObject(value.data)) ? { data: value } : value;
|
|
1507
|
+
const template = this.itemTemplate(templateValue, value, options);
|
|
1500
1508
|
return template;
|
|
1501
1509
|
}
|
|
1502
1510
|
//need to convert values to strings to be able to compare values with available options that are strings
|