@formio/js 5.0.0-dev.5860.a296208 → 5.0.0-dev.5863.a2bd4af
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 +4 -4
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +4 -4
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/components/_classes/component/Component.js +8 -6
- package/lib/cjs/components/day/Day.js +3 -0
- package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -2
- package/lib/cjs/components/editgrid/EditGrid.js +5 -6
- package/lib/cjs/components/select/Select.d.ts +1 -1
- package/lib/cjs/components/select/Select.js +12 -5
- package/lib/mjs/components/_classes/component/Component.js +8 -6
- package/lib/mjs/components/day/Day.js +3 -0
- package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -2
- package/lib/mjs/components/editgrid/EditGrid.js +5 -6
- package/lib/mjs/components/select/Select.d.ts +1 -1
- package/lib/mjs/components/select/Select.js +11 -4
- package/package.json +1 -1
|
@@ -1757,12 +1757,12 @@ class Component extends Element_1.default {
|
|
|
1757
1757
|
var _a, _b, _c;
|
|
1758
1758
|
if ((_a = this.root) === null || _a === void 0 ? void 0 : _a.currentSelection) {
|
|
1759
1759
|
if ((_b = this.refs.input) === null || _b === void 0 ? void 0 : _b.length) {
|
|
1760
|
-
const {
|
|
1760
|
+
const { index } = this.root.currentSelection;
|
|
1761
1761
|
let input = this.refs.input[index];
|
|
1762
1762
|
const isInputRangeSelectable = (i) => /text|search|password|tel|url/i.test((i === null || i === void 0 ? void 0 : i.type) || '');
|
|
1763
1763
|
if (input) {
|
|
1764
1764
|
if (isInputRangeSelectable(input)) {
|
|
1765
|
-
input.setSelectionRange(
|
|
1765
|
+
input.setSelectionRange(input.value.length, input.value.length);
|
|
1766
1766
|
}
|
|
1767
1767
|
}
|
|
1768
1768
|
else {
|
|
@@ -2962,12 +2962,14 @@ class Component extends Element_1.default {
|
|
|
2962
2962
|
if (flags.silentCheck) {
|
|
2963
2963
|
return [];
|
|
2964
2964
|
}
|
|
2965
|
-
let isDirty = this.dirty || flags.dirty;
|
|
2966
2965
|
if (this.options.alwaysDirty) {
|
|
2967
|
-
|
|
2966
|
+
flags.dirty = true;
|
|
2968
2967
|
}
|
|
2969
|
-
this.
|
|
2970
|
-
|
|
2968
|
+
if (flags.fromSubmission && this.hasValue(data)) {
|
|
2969
|
+
flags.dirty = this.pristine && this.component.protected ? false : true;
|
|
2970
|
+
}
|
|
2971
|
+
this.setDirty(flags.dirty);
|
|
2972
|
+
return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
|
|
2971
2973
|
}
|
|
2972
2974
|
/**
|
|
2973
2975
|
* Perform a component validation.
|
|
@@ -89,8 +89,8 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
89
89
|
hasOpenRows(): any;
|
|
90
90
|
getAttachedData(data?: null): any;
|
|
91
91
|
shouldValidateDraft(editRow: any): any;
|
|
92
|
-
shouldValidateRow(editRow: any, dirty: any
|
|
93
|
-
validateRow(editRow: any, dirty: any, forceSilentCheck: any
|
|
92
|
+
shouldValidateRow(editRow: any, dirty: any): any;
|
|
93
|
+
validateRow(editRow: any, dirty: any, forceSilentCheck: any): any;
|
|
94
94
|
showRowErrorAlerts(editRow: any, errors: any): void;
|
|
95
95
|
/**
|
|
96
96
|
* @returns {boolean} - Return that this component processes its own validation.
|
|
@@ -983,18 +983,17 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
983
983
|
!this.hasOpenRows()) ||
|
|
984
984
|
((_b = this.root) === null || _b === void 0 ? void 0 : _b.submitted);
|
|
985
985
|
}
|
|
986
|
-
shouldValidateRow(editRow, dirty
|
|
986
|
+
shouldValidateRow(editRow, dirty) {
|
|
987
987
|
return this.shouldValidateDraft(editRow) ||
|
|
988
988
|
editRow.state === EditRowState.Saving ||
|
|
989
989
|
editRow.state === EditRowState.Editing ||
|
|
990
990
|
editRow.alerts ||
|
|
991
|
-
fromSubmission ||
|
|
992
991
|
dirty;
|
|
993
992
|
}
|
|
994
|
-
validateRow(editRow, dirty, forceSilentCheck
|
|
993
|
+
validateRow(editRow, dirty, forceSilentCheck) {
|
|
995
994
|
var _a;
|
|
996
995
|
editRow.errors = [];
|
|
997
|
-
if (this.shouldValidateRow(editRow, dirty
|
|
996
|
+
if (this.shouldValidateRow(editRow, dirty)) {
|
|
998
997
|
const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
|
|
999
998
|
const rootValue = (0, utils_1.fastCloneDeep)(this.rootValue);
|
|
1000
999
|
const editGridValue = lodash_1.default.get(rootValue, this.path, []);
|
|
@@ -1066,7 +1065,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
1066
1065
|
}
|
|
1067
1066
|
checkComponentValidity(data, dirty, row, options = {}, errors = []) {
|
|
1068
1067
|
var _a, _b;
|
|
1069
|
-
const { silentCheck
|
|
1068
|
+
const { silentCheck } = options;
|
|
1070
1069
|
const superValid = super.checkComponentValidity(data, dirty, row, options, errors);
|
|
1071
1070
|
// If super tells us that component invalid and there is no need to update alerts, just return false
|
|
1072
1071
|
if (!superValid && (!this.alert && !this.hasOpenRows())) {
|
|
@@ -1076,7 +1075,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
|
1076
1075
|
const allRowErrors = [];
|
|
1077
1076
|
this.editRows.forEach((editRow, index) => {
|
|
1078
1077
|
// Trigger all errors on the row.
|
|
1079
|
-
const rowErrors = this.validateRow(editRow, dirty, silentCheck
|
|
1078
|
+
const rowErrors = this.validateRow(editRow, dirty, silentCheck);
|
|
1080
1079
|
errors.push(...rowErrors);
|
|
1081
1080
|
allRowErrors.push(...rowErrors);
|
|
1082
1081
|
if (this.rowRefs) {
|
|
@@ -131,7 +131,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
131
131
|
addCurrentChoices(values: any, items: any, keyValue: any): any;
|
|
132
132
|
getValueAsString(data: any, options: any): any;
|
|
133
133
|
normalizeSingleValue(value: any): any;
|
|
134
|
-
setMetadata(value: any): any;
|
|
134
|
+
setMetadata(value: any, flags?: {}): any;
|
|
135
135
|
updateValue(value: any, flags: any): boolean;
|
|
136
136
|
undoValueTyping(value: any): any;
|
|
137
137
|
setValue(value: any, flags?: {}): boolean;
|
|
@@ -1204,8 +1204,8 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1204
1204
|
}
|
|
1205
1205
|
return super.normalizeValue(this.normalizeSingleValue(value));
|
|
1206
1206
|
}
|
|
1207
|
-
setMetadata(value) {
|
|
1208
|
-
var _a;
|
|
1207
|
+
setMetadata(value, flags = {}) {
|
|
1208
|
+
var _a, _b;
|
|
1209
1209
|
if (lodash_1.default.isNil(value)) {
|
|
1210
1210
|
return;
|
|
1211
1211
|
}
|
|
@@ -1239,15 +1239,22 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1239
1239
|
}
|
|
1240
1240
|
lodash_1.default.set(submission.metadata.selectData, this.path, templateData);
|
|
1241
1241
|
}
|
|
1242
|
+
if (flags.resetValue && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission)) {
|
|
1243
|
+
const submission = this.root.submission;
|
|
1244
|
+
if (!submission.metadata) {
|
|
1245
|
+
submission.metadata = {};
|
|
1246
|
+
}
|
|
1247
|
+
submission.metadata.selectData = {};
|
|
1248
|
+
}
|
|
1242
1249
|
}
|
|
1243
1250
|
updateValue(value, flags) {
|
|
1244
1251
|
const changed = super.updateValue(value, flags);
|
|
1245
|
-
if (changed || !this.selectMetadata) {
|
|
1252
|
+
if (changed || !this.selectMetadata || flags.resetValue) {
|
|
1246
1253
|
if (this.component.multiple && Array.isArray(this.dataValue)) {
|
|
1247
|
-
this.dataValue.forEach(singleValue => this.setMetadata(singleValue));
|
|
1254
|
+
this.dataValue.forEach(singleValue => this.setMetadata(singleValue, flags));
|
|
1248
1255
|
}
|
|
1249
1256
|
else {
|
|
1250
|
-
this.setMetadata(this.dataValue);
|
|
1257
|
+
this.setMetadata(this.dataValue, flags);
|
|
1251
1258
|
}
|
|
1252
1259
|
}
|
|
1253
1260
|
return changed;
|
|
@@ -1720,12 +1720,12 @@ export default class Component extends Element {
|
|
|
1720
1720
|
restoreCaretPosition() {
|
|
1721
1721
|
if (this.root?.currentSelection) {
|
|
1722
1722
|
if (this.refs.input?.length) {
|
|
1723
|
-
const {
|
|
1723
|
+
const { index } = this.root.currentSelection;
|
|
1724
1724
|
let input = this.refs.input[index];
|
|
1725
1725
|
const isInputRangeSelectable = (i) => /text|search|password|tel|url/i.test(i?.type || '');
|
|
1726
1726
|
if (input) {
|
|
1727
1727
|
if (isInputRangeSelectable(input)) {
|
|
1728
|
-
input.setSelectionRange(
|
|
1728
|
+
input.setSelectionRange(input.value.length, input.value.length);
|
|
1729
1729
|
}
|
|
1730
1730
|
}
|
|
1731
1731
|
else {
|
|
@@ -2926,12 +2926,14 @@ export default class Component extends Element {
|
|
|
2926
2926
|
if (flags.silentCheck) {
|
|
2927
2927
|
return [];
|
|
2928
2928
|
}
|
|
2929
|
-
let isDirty = this.dirty || flags.dirty;
|
|
2930
2929
|
if (this.options.alwaysDirty) {
|
|
2931
|
-
|
|
2930
|
+
flags.dirty = true;
|
|
2932
2931
|
}
|
|
2933
|
-
this.
|
|
2934
|
-
|
|
2932
|
+
if (flags.fromSubmission && this.hasValue(data)) {
|
|
2933
|
+
flags.dirty = this.pristine && this.component.protected ? false : true;
|
|
2934
|
+
}
|
|
2935
|
+
this.setDirty(flags.dirty);
|
|
2936
|
+
return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
|
|
2935
2937
|
}
|
|
2936
2938
|
/**
|
|
2937
2939
|
* Perform a component validation.
|
|
@@ -89,8 +89,8 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
89
89
|
hasOpenRows(): any;
|
|
90
90
|
getAttachedData(data?: null): any;
|
|
91
91
|
shouldValidateDraft(editRow: any): any;
|
|
92
|
-
shouldValidateRow(editRow: any, dirty: any
|
|
93
|
-
validateRow(editRow: any, dirty: any, forceSilentCheck: any
|
|
92
|
+
shouldValidateRow(editRow: any, dirty: any): any;
|
|
93
|
+
validateRow(editRow: any, dirty: any, forceSilentCheck: any): any;
|
|
94
94
|
showRowErrorAlerts(editRow: any, errors: any): void;
|
|
95
95
|
/**
|
|
96
96
|
* @returns {boolean} - Return that this component processes its own validation.
|
|
@@ -973,17 +973,16 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
973
973
|
!this.hasOpenRows()) ||
|
|
974
974
|
this.root?.submitted;
|
|
975
975
|
}
|
|
976
|
-
shouldValidateRow(editRow, dirty
|
|
976
|
+
shouldValidateRow(editRow, dirty) {
|
|
977
977
|
return this.shouldValidateDraft(editRow) ||
|
|
978
978
|
editRow.state === EditRowState.Saving ||
|
|
979
979
|
editRow.state === EditRowState.Editing ||
|
|
980
980
|
editRow.alerts ||
|
|
981
|
-
fromSubmission ||
|
|
982
981
|
dirty;
|
|
983
982
|
}
|
|
984
|
-
validateRow(editRow, dirty, forceSilentCheck
|
|
983
|
+
validateRow(editRow, dirty, forceSilentCheck) {
|
|
985
984
|
editRow.errors = [];
|
|
986
|
-
if (this.shouldValidateRow(editRow, dirty
|
|
985
|
+
if (this.shouldValidateRow(editRow, dirty)) {
|
|
987
986
|
const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
|
|
988
987
|
const rootValue = fastCloneDeep(this.rootValue);
|
|
989
988
|
const editGridValue = _.get(rootValue, this.path, []);
|
|
@@ -1054,7 +1053,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
1054
1053
|
return true;
|
|
1055
1054
|
}
|
|
1056
1055
|
checkComponentValidity(data, dirty, row, options = {}, errors = []) {
|
|
1057
|
-
const { silentCheck
|
|
1056
|
+
const { silentCheck } = options;
|
|
1058
1057
|
const superValid = super.checkComponentValidity(data, dirty, row, options, errors);
|
|
1059
1058
|
// If super tells us that component invalid and there is no need to update alerts, just return false
|
|
1060
1059
|
if (!superValid && (!this.alert && !this.hasOpenRows())) {
|
|
@@ -1064,7 +1063,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
1064
1063
|
const allRowErrors = [];
|
|
1065
1064
|
this.editRows.forEach((editRow, index) => {
|
|
1066
1065
|
// Trigger all errors on the row.
|
|
1067
|
-
const rowErrors = this.validateRow(editRow, dirty, silentCheck
|
|
1066
|
+
const rowErrors = this.validateRow(editRow, dirty, silentCheck);
|
|
1068
1067
|
errors.push(...rowErrors);
|
|
1069
1068
|
allRowErrors.push(...rowErrors);
|
|
1070
1069
|
if (this.rowRefs) {
|
|
@@ -131,7 +131,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
131
131
|
addCurrentChoices(values: any, items: any, keyValue: any): any;
|
|
132
132
|
getValueAsString(data: any, options: any): any;
|
|
133
133
|
normalizeSingleValue(value: any): any;
|
|
134
|
-
setMetadata(value: any): any;
|
|
134
|
+
setMetadata(value: any, flags?: {}): any;
|
|
135
135
|
updateValue(value: any, flags: any): boolean;
|
|
136
136
|
undoValueTyping(value: any): any;
|
|
137
137
|
setValue(value: any, flags?: {}): boolean;
|
|
@@ -1233,7 +1233,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1233
1233
|
}
|
|
1234
1234
|
return super.normalizeValue(this.normalizeSingleValue(value));
|
|
1235
1235
|
}
|
|
1236
|
-
setMetadata(value) {
|
|
1236
|
+
setMetadata(value, flags = {}) {
|
|
1237
1237
|
if (_.isNil(value)) {
|
|
1238
1238
|
return;
|
|
1239
1239
|
}
|
|
@@ -1267,15 +1267,22 @@ export default class SelectComponent extends ListComponent {
|
|
|
1267
1267
|
}
|
|
1268
1268
|
_.set(submission.metadata.selectData, this.path, templateData);
|
|
1269
1269
|
}
|
|
1270
|
+
if (flags.resetValue && this.root?.submission) {
|
|
1271
|
+
const submission = this.root.submission;
|
|
1272
|
+
if (!submission.metadata) {
|
|
1273
|
+
submission.metadata = {};
|
|
1274
|
+
}
|
|
1275
|
+
submission.metadata.selectData = {};
|
|
1276
|
+
}
|
|
1270
1277
|
}
|
|
1271
1278
|
updateValue(value, flags) {
|
|
1272
1279
|
const changed = super.updateValue(value, flags);
|
|
1273
|
-
if (changed || !this.selectMetadata) {
|
|
1280
|
+
if (changed || !this.selectMetadata || flags.resetValue) {
|
|
1274
1281
|
if (this.component.multiple && Array.isArray(this.dataValue)) {
|
|
1275
|
-
this.dataValue.forEach(singleValue => this.setMetadata(singleValue));
|
|
1282
|
+
this.dataValue.forEach(singleValue => this.setMetadata(singleValue, flags));
|
|
1276
1283
|
}
|
|
1277
1284
|
else {
|
|
1278
|
-
this.setMetadata(this.dataValue);
|
|
1285
|
+
this.setMetadata(this.dataValue, flags);
|
|
1279
1286
|
}
|
|
1280
1287
|
}
|
|
1281
1288
|
return changed;
|