@formio/js 5.0.0-dev.5842.5155aaa → 5.0.0-dev.5844.c491f7d

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.
@@ -3469,14 +3469,16 @@ class Component extends Element_1.default {
3469
3469
  window.scrollTo(verticalOnly ? window.scrollX : left + window.scrollX, top + window.scrollY);
3470
3470
  }
3471
3471
  focus(index) {
3472
- var _a, _b, _c;
3472
+ var _a, _b, _c, _d;
3473
3473
  if ('beforeFocus' in this.parent) {
3474
3474
  this.parent.beforeFocus(this);
3475
3475
  }
3476
- index = index || ((_a = this.refs.input) === null || _a === void 0 ? void 0 : _a.length) - 1;
3477
- if ((_b = this.refs.input) === null || _b === void 0 ? void 0 : _b.length) {
3476
+ 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)) {
3477
+ index = this.refs.input.length - 1;
3478
+ }
3479
+ if ((_c = this.refs.input) === null || _c === void 0 ? void 0 : _c.length) {
3478
3480
  const focusingInput = this.refs.input[index];
3479
- if (((_c = this.component.widget) === null || _c === void 0 ? void 0 : _c.type) === 'calendar') {
3481
+ if (((_d = this.component.widget) === null || _d === void 0 ? void 0 : _d.type) === 'calendar') {
3480
3482
  const sibling = focusingInput.nextSibling;
3481
3483
  if (sibling) {
3482
3484
  sibling.focus();
@@ -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[DAY] && !lodash_1.default.isNaN(defaults[DAY]) ? defaults[DAY] : 0;
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[MONTH] && !lodash_1.default.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0;
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[YEAR] && !lodash_1.default.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0;
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
- this.dataValue = this.emptyValue;
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
@@ -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 = index || this.refs.input?.length - 1;
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') {
@@ -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[DAY] && !_.isNaN(defaults[DAY]) ? defaults[DAY] : 0;
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[MONTH] && !_.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0;
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[YEAR] && !_.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0;
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
- this.dataValue = this.emptyValue;
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5842.5155aaa",
3
+ "version": "5.0.0-dev.5844.c491f7d",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {