@formio/js 5.0.0-dev.5842.5155aaa → 5.0.0-dev.5846.796fec1
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 +1 -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 +13 -10
- package/lib/cjs/components/_classes/nested/NestedComponent.js +7 -6
- package/lib/cjs/components/day/Day.js +23 -11
- package/lib/cjs/components/editgrid/EditGrid.js +1 -0
- package/lib/mjs/Webform.js +5 -3
- package/lib/mjs/components/_classes/component/Component.js +9 -7
- package/lib/mjs/components/_classes/nested/NestedComponent.js +7 -6
- package/lib/mjs/components/day/Day.js +23 -11
- package/lib/mjs/components/editgrid/EditGrid.js +1 -0
- 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 = 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.
|
|
@@ -3469,14 +3470,16 @@ class Component extends Element_1.default {
|
|
|
3469
3470
|
window.scrollTo(verticalOnly ? window.scrollX : left + window.scrollX, top + window.scrollY);
|
|
3470
3471
|
}
|
|
3471
3472
|
focus(index) {
|
|
3472
|
-
var _a, _b, _c;
|
|
3473
|
+
var _a, _b, _c, _d;
|
|
3473
3474
|
if ('beforeFocus' in this.parent) {
|
|
3474
3475
|
this.parent.beforeFocus(this);
|
|
3475
3476
|
}
|
|
3476
|
-
index
|
|
3477
|
-
|
|
3477
|
+
if (!index && !lodash_1.default.isNumber(index) && ((_b = (_a = this.refs) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
3478
|
+
index = this.refs.input.length - 1;
|
|
3479
|
+
}
|
|
3480
|
+
if ((_c = this.refs.input) === null || _c === void 0 ? void 0 : _c.length) {
|
|
3478
3481
|
const focusingInput = this.refs.input[index];
|
|
3479
|
-
if (((
|
|
3482
|
+
if (((_d = this.component.widget) === null || _d === void 0 ? void 0 : _d.type) === 'calendar') {
|
|
3480
3483
|
const sibling = focusingInput.nextSibling;
|
|
3481
3484
|
if (sibling) {
|
|
3482
3485
|
sibling.focus();
|
|
@@ -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 = {}) {
|
|
@@ -286,7 +286,7 @@ class DayComponent extends Field_1.default {
|
|
|
286
286
|
if (!this.component.fields.day.hide && maxDay) {
|
|
287
287
|
this.refs.day.max = maxDay;
|
|
288
288
|
}
|
|
289
|
-
if (maxDay && day > maxDay) {
|
|
289
|
+
if (maxDay && day > maxDay && this.refs.day) {
|
|
290
290
|
this.refs.day.value = this.refs.day.max;
|
|
291
291
|
}
|
|
292
292
|
updateValueAndSaveFocus(this.refs.month, 'month')();
|
|
@@ -496,28 +496,40 @@ class DayComponent extends Field_1.default {
|
|
|
496
496
|
if (defaultValue) {
|
|
497
497
|
defaults = defaultValue.split('/').map(x => parseInt(x, 10));
|
|
498
498
|
}
|
|
499
|
+
const isModalEditClosed = this.component.modalEdit && !this.componentModal.isOpened;
|
|
499
500
|
if (this.showDay && this.refs.day) {
|
|
500
|
-
day = this.refs.day.value === '' ? '' : parseInt(this.refs.day.value, 10);
|
|
501
|
+
day = (this.refs.day.value === '' && !isModalEditClosed) ? '' : parseInt(this.refs.day.value, 10);
|
|
501
502
|
}
|
|
502
|
-
if (day === undefined || lodash_1.default.isNaN(day)) {
|
|
503
|
-
day = defaults
|
|
503
|
+
if (day === undefined || lodash_1.default.isNaN(day) || value) {
|
|
504
|
+
day = (defaults.length !== 3)
|
|
505
|
+
? this.getDayWithHiddenFields(defaults).day
|
|
506
|
+
: (defaults[DAY] && !lodash_1.default.isNaN(defaults[DAY]) ? defaults[DAY] : 0);
|
|
504
507
|
}
|
|
505
508
|
if (this.showMonth && this.refs.month) {
|
|
506
509
|
// Months are 0 indexed.
|
|
507
|
-
month = this.refs.month.value === '' ? '' : parseInt(this.refs.month.value, 10);
|
|
510
|
+
month = (this.refs.month.value === '' && !isModalEditClosed) ? '' : parseInt(this.refs.month.value, 10);
|
|
508
511
|
}
|
|
509
|
-
if (month === undefined || lodash_1.default.isNaN(month)) {
|
|
510
|
-
month = defaults
|
|
512
|
+
if (month === undefined || lodash_1.default.isNaN(month) || value) {
|
|
513
|
+
month = (defaults.length !== 3)
|
|
514
|
+
? this.getDayWithHiddenFields(defaults).month
|
|
515
|
+
: (defaults[MONTH] && !lodash_1.default.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0);
|
|
511
516
|
}
|
|
512
517
|
if (this.showYear && this.refs.year) {
|
|
513
|
-
year = this.refs.year.value === '' ? '' : parseInt(this.refs.year.value);
|
|
518
|
+
year = (this.refs.year.value === '' && !isModalEditClosed) ? '' : parseInt(this.refs.year.value);
|
|
514
519
|
}
|
|
515
|
-
if (year === undefined || lodash_1.default.isNaN(year)) {
|
|
516
|
-
year = defaults
|
|
520
|
+
if (year === undefined || lodash_1.default.isNaN(year) || value) {
|
|
521
|
+
year = (defaults.length !== 3)
|
|
522
|
+
? this.getDayWithHiddenFields(defaults).year
|
|
523
|
+
: (defaults[YEAR] && !lodash_1.default.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0);
|
|
517
524
|
}
|
|
518
525
|
let result;
|
|
519
526
|
if (!day && !month && !year) {
|
|
520
|
-
|
|
527
|
+
if (!isModalEditClosed) {
|
|
528
|
+
this.dataValue = this.emptyValue;
|
|
529
|
+
if (this.options.building) {
|
|
530
|
+
this.triggerChange();
|
|
531
|
+
}
|
|
532
|
+
}
|
|
521
533
|
return null;
|
|
522
534
|
}
|
|
523
535
|
// add trailing zeros if the data is showed
|
|
@@ -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) {
|
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 = 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.
|
|
@@ -3434,7 +3434,9 @@ export default class Component extends Element {
|
|
|
3434
3434
|
if ('beforeFocus' in this.parent) {
|
|
3435
3435
|
this.parent.beforeFocus(this);
|
|
3436
3436
|
}
|
|
3437
|
-
index
|
|
3437
|
+
if (!index && !_.isNumber(index) && this.refs?.input?.length) {
|
|
3438
|
+
index = this.refs.input.length - 1;
|
|
3439
|
+
}
|
|
3438
3440
|
if (this.refs.input?.length) {
|
|
3439
3441
|
const focusingInput = this.refs.input[index];
|
|
3440
3442
|
if (this.component.widget?.type === 'calendar') {
|
|
@@ -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 = {}) {
|
|
@@ -284,7 +284,7 @@ export default class DayComponent extends Field {
|
|
|
284
284
|
if (!this.component.fields.day.hide && maxDay) {
|
|
285
285
|
this.refs.day.max = maxDay;
|
|
286
286
|
}
|
|
287
|
-
if (maxDay && day > maxDay) {
|
|
287
|
+
if (maxDay && day > maxDay && this.refs.day) {
|
|
288
288
|
this.refs.day.value = this.refs.day.max;
|
|
289
289
|
}
|
|
290
290
|
updateValueAndSaveFocus(this.refs.month, 'month')();
|
|
@@ -494,28 +494,40 @@ export default class DayComponent extends Field {
|
|
|
494
494
|
if (defaultValue) {
|
|
495
495
|
defaults = defaultValue.split('/').map(x => parseInt(x, 10));
|
|
496
496
|
}
|
|
497
|
+
const isModalEditClosed = this.component.modalEdit && !this.componentModal.isOpened;
|
|
497
498
|
if (this.showDay && this.refs.day) {
|
|
498
|
-
day = this.refs.day.value === '' ? '' : parseInt(this.refs.day.value, 10);
|
|
499
|
+
day = (this.refs.day.value === '' && !isModalEditClosed) ? '' : parseInt(this.refs.day.value, 10);
|
|
499
500
|
}
|
|
500
|
-
if (day === undefined || _.isNaN(day)) {
|
|
501
|
-
day = defaults
|
|
501
|
+
if (day === undefined || _.isNaN(day) || value) {
|
|
502
|
+
day = (defaults.length !== 3)
|
|
503
|
+
? this.getDayWithHiddenFields(defaults).day
|
|
504
|
+
: (defaults[DAY] && !_.isNaN(defaults[DAY]) ? defaults[DAY] : 0);
|
|
502
505
|
}
|
|
503
506
|
if (this.showMonth && this.refs.month) {
|
|
504
507
|
// Months are 0 indexed.
|
|
505
|
-
month = this.refs.month.value === '' ? '' : parseInt(this.refs.month.value, 10);
|
|
508
|
+
month = (this.refs.month.value === '' && !isModalEditClosed) ? '' : parseInt(this.refs.month.value, 10);
|
|
506
509
|
}
|
|
507
|
-
if (month === undefined || _.isNaN(month)) {
|
|
508
|
-
month = defaults
|
|
510
|
+
if (month === undefined || _.isNaN(month) || value) {
|
|
511
|
+
month = (defaults.length !== 3)
|
|
512
|
+
? this.getDayWithHiddenFields(defaults).month
|
|
513
|
+
: (defaults[MONTH] && !_.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0);
|
|
509
514
|
}
|
|
510
515
|
if (this.showYear && this.refs.year) {
|
|
511
|
-
year = this.refs.year.value === '' ? '' : parseInt(this.refs.year.value);
|
|
516
|
+
year = (this.refs.year.value === '' && !isModalEditClosed) ? '' : parseInt(this.refs.year.value);
|
|
512
517
|
}
|
|
513
|
-
if (year === undefined || _.isNaN(year)) {
|
|
514
|
-
year = defaults
|
|
518
|
+
if (year === undefined || _.isNaN(year) || value) {
|
|
519
|
+
year = (defaults.length !== 3)
|
|
520
|
+
? this.getDayWithHiddenFields(defaults).year
|
|
521
|
+
: (defaults[YEAR] && !_.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0);
|
|
515
522
|
}
|
|
516
523
|
let result;
|
|
517
524
|
if (!day && !month && !year) {
|
|
518
|
-
|
|
525
|
+
if (!isModalEditClosed) {
|
|
526
|
+
this.dataValue = this.emptyValue;
|
|
527
|
+
if (this.options.building) {
|
|
528
|
+
this.triggerChange();
|
|
529
|
+
}
|
|
530
|
+
}
|
|
519
531
|
return null;
|
|
520
532
|
}
|
|
521
533
|
// add trailing zeros if the data is showed
|
|
@@ -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) {
|