@formio/js 5.0.0-dev.5799.552d965 → 5.0.0-dev.5801.1d6d8a9

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.
Files changed (44) hide show
  1. package/Changelog.md +4 -0
  2. package/dist/formio.form.js +9 -9
  3. package/dist/formio.form.min.js +1 -1
  4. package/dist/formio.full.js +16 -16
  5. package/dist/formio.full.min.js +1 -1
  6. package/dist/formio.js +1 -1
  7. package/dist/formio.min.js +1 -1
  8. package/dist/formio.utils.js +3 -3
  9. package/dist/formio.utils.min.js +1 -1
  10. package/lib/cjs/Webform.js +4 -0
  11. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +2 -2
  12. package/lib/cjs/components/_classes/multivalue/Multivalue.js +9 -5
  13. package/lib/cjs/components/day/Day.d.ts +5 -0
  14. package/lib/cjs/components/day/Day.js +52 -12
  15. package/lib/cjs/components/day/editForm/Day.edit.day.d.ts +17 -0
  16. package/lib/cjs/components/day/editForm/Day.edit.day.js +19 -0
  17. package/lib/cjs/components/day/editForm/Day.edit.month.d.ts +5 -0
  18. package/lib/cjs/components/day/editForm/Day.edit.month.js +19 -0
  19. package/lib/cjs/components/day/editForm/Day.edit.year.d.ts +5 -0
  20. package/lib/cjs/components/day/editForm/Day.edit.year.js +13 -0
  21. package/lib/cjs/components/radio/Radio.js +1 -1
  22. package/lib/cjs/components/select/Select.js +3 -0
  23. package/lib/cjs/components/select/editForm/Select.edit.validation.js +2 -1
  24. package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
  25. package/lib/cjs/utils/formUtils.d.ts +1 -2
  26. package/lib/cjs/utils/formUtils.js +2 -3
  27. package/lib/mjs/Webform.js +4 -0
  28. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +2 -2
  29. package/lib/mjs/components/_classes/multivalue/Multivalue.js +9 -5
  30. package/lib/mjs/components/day/Day.d.ts +5 -0
  31. package/lib/mjs/components/day/Day.js +52 -12
  32. package/lib/mjs/components/day/editForm/Day.edit.day.d.ts +17 -0
  33. package/lib/mjs/components/day/editForm/Day.edit.day.js +16 -0
  34. package/lib/mjs/components/day/editForm/Day.edit.month.d.ts +5 -0
  35. package/lib/mjs/components/day/editForm/Day.edit.month.js +16 -0
  36. package/lib/mjs/components/day/editForm/Day.edit.year.d.ts +5 -0
  37. package/lib/mjs/components/day/editForm/Day.edit.year.js +10 -0
  38. package/lib/mjs/components/radio/Radio.js +1 -1
  39. package/lib/mjs/components/select/Select.js +3 -0
  40. package/lib/mjs/components/select/editForm/Select.edit.validation.js +2 -1
  41. package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
  42. package/lib/mjs/utils/formUtils.d.ts +1 -2
  43. package/lib/mjs/utils/formUtils.js +2 -2
  44. package/package.json +2 -2
@@ -1098,6 +1098,9 @@ class Webform extends NestedDataComponent_1.default {
1098
1098
  if (!Array.isArray(errors)) {
1099
1099
  errors = [errors];
1100
1100
  }
1101
+ if (Array.isArray(this.errors)) {
1102
+ errors = lodash_1.default.union(errors, this.errors);
1103
+ }
1101
1104
  errors = errors.concat(this.customErrors).filter((err) => !!err);
1102
1105
  if (!errors.length) {
1103
1106
  this.setAlert(false);
@@ -1211,6 +1214,7 @@ class Webform extends NestedDataComponent_1.default {
1211
1214
  * @returns {Array} errors - All errors.
1212
1215
  */
1213
1216
  onSubmissionError(error) {
1217
+ // console.log(error, ' - error in onSubmissionError')
1214
1218
  error = this.normalizeError(error);
1215
1219
  this.submitting = false;
1216
1220
  this.setPristine(false);
@@ -2,11 +2,11 @@ export default class Multivalue extends Field {
2
2
  /**
3
3
  * Normalize values coming into updateValue.
4
4
  * @param {*} value - The value to normalize before setting.
5
- * @param {Object} flags - Flags to use when normalizing the value.
5
+ * @param {object} flags - Flags to use when normalizing the value.
6
6
  * @param {*} emptyValue - The empty value for the field.
7
7
  * @returns {*} - The normalized value.
8
8
  */
9
- normalizeValue(value: any, flags?: Object, emptyValue?: any): any;
9
+ normalizeValue(value: any, flags?: object, emptyValue?: any): any;
10
10
  get addAnother(): string;
11
11
  /**
12
12
  * @returns {Field} - The created field.
@@ -5,23 +5,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Field_1 = __importDefault(require("../field/Field"));
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
+ const core_1 = require("@formio/core");
8
9
  class Multivalue extends Field_1.default {
9
10
  /**
10
11
  * Normalize values coming into updateValue.
11
12
  * @param {*} value - The value to normalize before setting.
12
- * @param {Object} flags - Flags to use when normalizing the value.
13
+ * @param {object} flags - Flags to use when normalizing the value.
13
14
  * @param {*} emptyValue - The empty value for the field.
14
15
  * @returns {*} - The normalized value.
15
16
  */
16
17
  normalizeValue(value, flags = {}, emptyValue = this.emptyValue) {
18
+ const underlyingValueShouldBeArray = core_1.Utils.getModelType(this.component) === 'array' || this.component.storeas === 'array' || Array.isArray(emptyValue);
17
19
  if (this.component.multiple) {
18
20
  if (Array.isArray(value)) {
21
+ if (underlyingValueShouldBeArray) {
22
+ if (value.length === 0 || !Array.isArray(value[0])) {
23
+ return [value];
24
+ }
25
+ }
19
26
  if (value.length === 0) {
20
27
  return [emptyValue];
21
28
  }
22
- if (this.component.storeas === 'array') {
23
- return super.normalizeValue([value], flags);
24
- }
25
29
  return super.normalizeValue(value, flags);
26
30
  }
27
31
  else {
@@ -29,7 +33,7 @@ class Multivalue extends Field_1.default {
29
33
  }
30
34
  }
31
35
  else {
32
- if (Array.isArray(value) && !Array.isArray(emptyValue)) {
36
+ if (Array.isArray(value) && !underlyingValueShouldBeArray) {
33
37
  if (this.component.storeas === 'string') {
34
38
  return super.normalizeValue(value.join(this.delimiter || ''), flags);
35
39
  }
@@ -97,6 +97,11 @@ export default class DayComponent extends Field {
97
97
  * @returns {null|void} - Returns null if the value is invalid, otherwise void.
98
98
  */
99
99
  setValueAt(index: number, value: any): null | void;
100
+ getDayWithHiddenFields(parts: any): {
101
+ month: any;
102
+ day: any;
103
+ year: any;
104
+ };
100
105
  getFieldValue(name: any): number;
101
106
  get parts(): {
102
107
  day: number;
@@ -344,6 +344,18 @@ class DayComponent extends Field_1.default {
344
344
  const valueParts = value.split('/');
345
345
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
346
346
  const defaultValue = this.component.defaultValue ? this.component.defaultValue.split('/') : '';
347
+ let defaultDay = '';
348
+ let defaultMonth = '';
349
+ let defaultYear = '';
350
+ if (defaultValue) {
351
+ const hasHiddenFields = defaultValue.length !== 3;
352
+ defaultDay = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).day : defaultValue[DAY];
353
+ defaultMonth = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).month : defaultValue[MONTH];
354
+ defaultYear = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).year : defaultValue[YEAR];
355
+ }
356
+ if (this.options.building && defaultValue.length === 3) {
357
+ return this.component.defaultValue;
358
+ }
347
359
  const getNextPart = (shouldTake, defaultValue) => {
348
360
  // Only push the part if it's not an empty string
349
361
  const part = shouldTake ? valueParts.shift() : defaultValue;
@@ -352,13 +364,13 @@ class DayComponent extends Field_1.default {
352
364
  }
353
365
  };
354
366
  if (this.dayFirst) {
355
- getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
367
+ getNextPart(this.showDay, defaultDay);
356
368
  }
357
- getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '');
369
+ getNextPart(this.showMonth, defaultMonth);
358
370
  if (!this.dayFirst) {
359
- getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
371
+ getNextPart(this.showDay, defaultDay);
360
372
  }
361
- getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '');
373
+ getNextPart(this.showYear, defaultYear);
362
374
  return dateParts.join('/');
363
375
  }
364
376
  /**
@@ -373,16 +385,23 @@ class DayComponent extends Field_1.default {
373
385
  if (value === 'Invalid date') {
374
386
  return null;
375
387
  }
388
+ let day, month, year;
376
389
  const parts = value.split('/');
377
- let day;
378
- if (this.component.dayFirst) {
379
- day = parts.shift();
390
+ if (parts.length !== 3) {
391
+ day = this.getDayWithHiddenFields(parts).day;
392
+ month = this.getDayWithHiddenFields(parts).month;
393
+ year = this.getDayWithHiddenFields(parts).year;
380
394
  }
381
- const month = parts.shift();
382
- if (!this.component.dayFirst) {
383
- day = parts.shift();
395
+ else {
396
+ if (this.component.dayFirst) {
397
+ day = parts.shift();
398
+ }
399
+ month = parts.shift();
400
+ if (!this.component.dayFirst) {
401
+ day = parts.shift();
402
+ }
403
+ year = parts.shift();
384
404
  }
385
- const year = parts.shift();
386
405
  if (this.refs.day && this.showDay) {
387
406
  this.refs.day.value = day === '00' ? '' : parseInt(day, 10);
388
407
  }
@@ -393,6 +412,27 @@ class DayComponent extends Field_1.default {
393
412
  this.refs.year.value = year === '0000' ? '' : parseInt(year, 10);
394
413
  }
395
414
  }
415
+ getDayWithHiddenFields(parts) {
416
+ let [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
417
+ if (!this.showDay) {
418
+ MONTH = MONTH === 0 ? 0 : MONTH - 1;
419
+ YEAR = YEAR - 1;
420
+ DAY = null;
421
+ }
422
+ if (!this.showMonth) {
423
+ DAY = DAY === 0 ? 0 : DAY - 1;
424
+ YEAR = YEAR - 1;
425
+ MONTH = null;
426
+ }
427
+ if (!this.showYear) {
428
+ YEAR = null;
429
+ }
430
+ return {
431
+ month: lodash_1.default.isNull(MONTH) ? '' : parts[MONTH],
432
+ day: lodash_1.default.isNull(DAY) ? '' : parts[DAY],
433
+ year: lodash_1.default.isNull(YEAR) ? '' : parts[YEAR],
434
+ };
435
+ }
396
436
  getFieldValue(name) {
397
437
  const parts = this.dataValue ? this.dataValue.split('/') : [];
398
438
  let val = 0;
@@ -561,7 +601,7 @@ class DayComponent extends Field_1.default {
561
601
  }
562
602
  isPartialDay(value) {
563
603
  if (!value) {
564
- return false;
604
+ return true;
565
605
  }
566
606
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
567
607
  const values = value.split('/');
@@ -14,6 +14,7 @@ declare const _default: ({
14
14
  input?: undefined;
15
15
  placeholder?: undefined;
16
16
  tooltip?: undefined;
17
+ onChange?: undefined;
17
18
  } | {
18
19
  weight: number;
19
20
  type: string;
@@ -25,16 +26,32 @@ declare const _default: ({
25
26
  wieght?: undefined;
26
27
  datasrc?: undefined;
27
28
  data?: undefined;
29
+ onChange?: undefined;
28
30
  } | {
29
31
  weight: number;
30
32
  type: string;
31
33
  label: string;
32
34
  tooltip: string;
33
35
  key: string;
36
+ onChange: ({ data }: {
37
+ data: any;
38
+ }) => void;
34
39
  input: boolean;
35
40
  wieght?: undefined;
36
41
  datasrc?: undefined;
37
42
  data?: undefined;
38
43
  placeholder?: undefined;
44
+ } | {
45
+ weight: number;
46
+ type: string;
47
+ label: string;
48
+ tooltip: string;
49
+ key: string;
50
+ input: boolean;
51
+ wieght?: undefined;
52
+ datasrc?: undefined;
53
+ data?: undefined;
54
+ placeholder?: undefined;
55
+ onChange?: undefined;
39
56
  })[];
40
57
  export default _default;
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_1 = __importDefault(require("lodash"));
3
7
  exports.default = [
4
8
  {
5
9
  wieght: 200,
@@ -35,6 +39,21 @@ exports.default = [
35
39
  label: 'Hidden',
36
40
  tooltip: 'Hide the Day part of the component.',
37
41
  key: 'fields.day.hide',
42
+ onChange: ({ data }) => {
43
+ if (data.defaultValue) {
44
+ const defaultValueParts = data.defaultValue.split('/');
45
+ if (!data.fields.day.hide && defaultValueParts.length !== 3) {
46
+ const newDefaultValue = ['00'];
47
+ if (!data.fields.month.hide) {
48
+ data.dayFirst ? newDefaultValue.push(defaultValueParts[0]) : newDefaultValue.unshift(defaultValueParts[0]);
49
+ }
50
+ if (!data.fields.year.hide) {
51
+ newDefaultValue.push(defaultValueParts[1]);
52
+ }
53
+ lodash_1.default.set(data, 'defaultValue', newDefaultValue.join('/'));
54
+ }
55
+ }
56
+ },
38
57
  input: true
39
58
  },
40
59
  {
@@ -14,6 +14,7 @@ declare const _default: ({
14
14
  input?: undefined;
15
15
  placeholder?: undefined;
16
16
  tooltip?: undefined;
17
+ onChange?: undefined;
17
18
  } | {
18
19
  weight: number;
19
20
  type: string;
@@ -25,12 +26,16 @@ declare const _default: ({
25
26
  wieght?: undefined;
26
27
  datasrc?: undefined;
27
28
  data?: undefined;
29
+ onChange?: undefined;
28
30
  } | {
29
31
  weight: number;
30
32
  type: string;
31
33
  label: string;
32
34
  tooltip: string;
33
35
  key: string;
36
+ onChange: ({ data }: {
37
+ data: any;
38
+ }) => void;
34
39
  input: boolean;
35
40
  wieght?: undefined;
36
41
  datasrc?: undefined;
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_1 = __importDefault(require("lodash"));
3
7
  exports.default = [
4
8
  {
5
9
  wieght: 200,
@@ -35,6 +39,21 @@ exports.default = [
35
39
  label: 'Hidden',
36
40
  tooltip: 'Hide the Month part of the component.',
37
41
  key: 'fields.month.hide',
42
+ onChange: ({ data }) => {
43
+ if (data.defaultValue) {
44
+ const defaultValueParts = data.defaultValue.split('/');
45
+ if (!data.fields.month.hide && defaultValueParts.length !== 3) {
46
+ const newDefaultValue = ['00'];
47
+ if (!data.fields.day.hide) {
48
+ data.dayFirst ? newDefaultValue.unshift(defaultValueParts[0]) : newDefaultValue.push(defaultValueParts[0]);
49
+ }
50
+ if (!data.fields.year.hide) {
51
+ newDefaultValue.push(defaultValueParts[1]);
52
+ }
53
+ lodash_1.default.set(data, 'defaultValue', newDefaultValue.join('/'));
54
+ }
55
+ }
56
+ },
38
57
  input: true
39
58
  },
40
59
  ];
@@ -14,6 +14,7 @@ declare const _default: ({
14
14
  input?: undefined;
15
15
  placeholder?: undefined;
16
16
  tooltip?: undefined;
17
+ onChange?: undefined;
17
18
  } | {
18
19
  weight: number;
19
20
  type: string;
@@ -25,12 +26,16 @@ declare const _default: ({
25
26
  wieght?: undefined;
26
27
  datasrc?: undefined;
27
28
  data?: undefined;
29
+ onChange?: undefined;
28
30
  } | {
29
31
  weight: number;
30
32
  type: string;
31
33
  label: string;
32
34
  tooltip: string;
33
35
  key: string;
36
+ onChange: ({ data }: {
37
+ data: any;
38
+ }) => void;
34
39
  input: boolean;
35
40
  wieght?: undefined;
36
41
  datasrc?: undefined;
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_1 = __importDefault(require("lodash"));
3
7
  exports.default = [
4
8
  {
5
9
  wieght: 200,
@@ -53,6 +57,15 @@ exports.default = [
53
57
  label: 'Hidden',
54
58
  tooltip: 'Hide the Year part of the component.',
55
59
  key: 'fields.year.hide',
60
+ onChange: ({ data }) => {
61
+ if (data.defaultValue) {
62
+ const defaultValueParts = data.defaultValue.split('/');
63
+ if (!data.fields.month.hide && defaultValueParts.length !== 3) {
64
+ defaultValueParts.push('0000');
65
+ lodash_1.default.set(data, 'defaultValue', defaultValueParts.join('/'));
66
+ }
67
+ }
68
+ },
56
69
  input: true
57
70
  },
58
71
  ];
@@ -212,7 +212,7 @@ class RadioComponent extends ListComponent_1.default {
212
212
  if (!(0, utils_1.boolValue)(setting) || !value) {
213
213
  return true;
214
214
  }
215
- const values = this.component.values;
215
+ const values = this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions;
216
216
  if (values) {
217
217
  return values.findIndex(({ value: optionValue }) => this.normalizeValue(optionValue) === value) !== -1;
218
218
  }
@@ -1429,6 +1429,9 @@ class SelectComponent extends ListComponent_1.default {
1429
1429
  case 'custom':
1430
1430
  rawItems = this.getCustomItems();
1431
1431
  break;
1432
+ case 'url':
1433
+ rawItems = this.selectItems;
1434
+ break;
1432
1435
  }
1433
1436
  if (typeof rawItems === 'string') {
1434
1437
  try {
@@ -26,7 +26,8 @@ exports.default = [
26
26
  [
27
27
  'values',
28
28
  'json',
29
- 'custom'
29
+ 'custom',
30
+ 'url'
30
31
  ],
31
32
  ],
32
33
  },
@@ -254,7 +254,7 @@ class SelectBoxesComponent extends Radio_1.default {
254
254
  if (!(0, utils_1.boolValue)(setting) || !value) {
255
255
  return true;
256
256
  }
257
- const values = this.component.values;
257
+ const values = this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions;
258
258
  const availableValueKeys = (values || []).map(({ value: optionValue }) => optionValue);
259
259
  const valueKeys = Object.keys(value);
260
260
  return valueKeys.every((key) => availableValueKeys.includes(key));
@@ -8,11 +8,10 @@ export function findComponents(components: import('@formio/core').Component[], q
8
8
  export const flattenComponents: typeof Utils.flattenComponents;
9
9
  export const guid: typeof Utils.guid;
10
10
  export const uniqueName: typeof Utils.uniqueName;
11
- export const MODEL_TYPES: Record<string, string[]>;
11
+ export const MODEL_TYPES: any;
12
12
  export const getModelType: typeof Utils.getModelType;
13
13
  export const getComponentAbsolutePath: typeof Utils.getComponentAbsolutePath;
14
14
  export const getComponentPath: typeof Utils.getComponentPath;
15
- export const isComponentModelType: typeof Utils.isComponentModelType;
16
15
  export const isComponentNestedDataType: typeof Utils.isComponentNestedDataType;
17
16
  export const componentPath: typeof Utils.componentPath;
18
17
  export const componentChildPath: any;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentActualValue = exports.getComponentData = exports.eachComponentAsync = exports.eachComponent = exports.componentInfo = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.eachComponentData = exports.eachComponentDataAsync = exports.componentChildPath = exports.componentPath = exports.isComponentNestedDataType = exports.isComponentModelType = exports.getComponentPath = exports.getComponentAbsolutePath = exports.getModelType = exports.MODEL_TYPES = exports.uniqueName = exports.guid = exports.flattenComponents = exports.findComponents = void 0;
3
+ exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentActualValue = exports.getComponentData = exports.eachComponentAsync = exports.eachComponent = exports.componentInfo = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.eachComponentData = exports.eachComponentDataAsync = exports.componentChildPath = exports.componentPath = exports.isComponentNestedDataType = exports.getComponentPath = exports.getComponentAbsolutePath = exports.getModelType = exports.MODEL_TYPES = exports.uniqueName = exports.guid = exports.flattenComponents = exports.findComponents = void 0;
4
4
  const core_1 = require("@formio/core");
5
- const { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentModelType, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty } = core_1.Utils;
5
+ const { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty } = core_1.Utils;
6
6
  exports.flattenComponents = flattenComponents;
7
7
  exports.guid = guid;
8
8
  exports.uniqueName = uniqueName;
@@ -10,7 +10,6 @@ exports.MODEL_TYPES = MODEL_TYPES;
10
10
  exports.getModelType = getModelType;
11
11
  exports.getComponentAbsolutePath = getComponentAbsolutePath;
12
12
  exports.getComponentPath = getComponentPath;
13
- exports.isComponentModelType = isComponentModelType;
14
13
  exports.isComponentNestedDataType = isComponentNestedDataType;
15
14
  exports.componentPath = componentPath;
16
15
  exports.componentChildPath = componentChildPath;
@@ -1102,6 +1102,9 @@ export default class Webform extends NestedDataComponent {
1102
1102
  if (!Array.isArray(errors)) {
1103
1103
  errors = [errors];
1104
1104
  }
1105
+ if (Array.isArray(this.errors)) {
1106
+ errors = _.union(errors, this.errors);
1107
+ }
1105
1108
  errors = errors.concat(this.customErrors).filter((err) => !!err);
1106
1109
  if (!errors.length) {
1107
1110
  this.setAlert(false);
@@ -1213,6 +1216,7 @@ export default class Webform extends NestedDataComponent {
1213
1216
  * @returns {Array} errors - All errors.
1214
1217
  */
1215
1218
  onSubmissionError(error) {
1219
+ // console.log(error, ' - error in onSubmissionError')
1216
1220
  error = this.normalizeError(error);
1217
1221
  this.submitting = false;
1218
1222
  this.setPristine(false);
@@ -2,11 +2,11 @@ export default class Multivalue extends Field {
2
2
  /**
3
3
  * Normalize values coming into updateValue.
4
4
  * @param {*} value - The value to normalize before setting.
5
- * @param {Object} flags - Flags to use when normalizing the value.
5
+ * @param {object} flags - Flags to use when normalizing the value.
6
6
  * @param {*} emptyValue - The empty value for the field.
7
7
  * @returns {*} - The normalized value.
8
8
  */
9
- normalizeValue(value: any, flags?: Object, emptyValue?: any): any;
9
+ normalizeValue(value: any, flags?: object, emptyValue?: any): any;
10
10
  get addAnother(): string;
11
11
  /**
12
12
  * @returns {Field} - The created field.
@@ -1,22 +1,26 @@
1
1
  import Field from '../field/Field';
2
2
  import _ from 'lodash';
3
+ import { Utils } from '@formio/core';
3
4
  export default class Multivalue extends Field {
4
5
  /**
5
6
  * Normalize values coming into updateValue.
6
7
  * @param {*} value - The value to normalize before setting.
7
- * @param {Object} flags - Flags to use when normalizing the value.
8
+ * @param {object} flags - Flags to use when normalizing the value.
8
9
  * @param {*} emptyValue - The empty value for the field.
9
10
  * @returns {*} - The normalized value.
10
11
  */
11
12
  normalizeValue(value, flags = {}, emptyValue = this.emptyValue) {
13
+ const underlyingValueShouldBeArray = Utils.getModelType(this.component) === 'array' || this.component.storeas === 'array' || Array.isArray(emptyValue);
12
14
  if (this.component.multiple) {
13
15
  if (Array.isArray(value)) {
16
+ if (underlyingValueShouldBeArray) {
17
+ if (value.length === 0 || !Array.isArray(value[0])) {
18
+ return [value];
19
+ }
20
+ }
14
21
  if (value.length === 0) {
15
22
  return [emptyValue];
16
23
  }
17
- if (this.component.storeas === 'array') {
18
- return super.normalizeValue([value], flags);
19
- }
20
24
  return super.normalizeValue(value, flags);
21
25
  }
22
26
  else {
@@ -24,7 +28,7 @@ export default class Multivalue extends Field {
24
28
  }
25
29
  }
26
30
  else {
27
- if (Array.isArray(value) && !Array.isArray(emptyValue)) {
31
+ if (Array.isArray(value) && !underlyingValueShouldBeArray) {
28
32
  if (this.component.storeas === 'string') {
29
33
  return super.normalizeValue(value.join(this.delimiter || ''), flags);
30
34
  }
@@ -97,6 +97,11 @@ export default class DayComponent extends Field {
97
97
  * @returns {null|void} - Returns null if the value is invalid, otherwise void.
98
98
  */
99
99
  setValueAt(index: number, value: any): null | void;
100
+ getDayWithHiddenFields(parts: any): {
101
+ month: any;
102
+ day: any;
103
+ year: any;
104
+ };
100
105
  getFieldValue(name: any): number;
101
106
  get parts(): {
102
107
  day: number;
@@ -342,6 +342,18 @@ export default class DayComponent extends Field {
342
342
  const valueParts = value.split('/');
343
343
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
344
344
  const defaultValue = this.component.defaultValue ? this.component.defaultValue.split('/') : '';
345
+ let defaultDay = '';
346
+ let defaultMonth = '';
347
+ let defaultYear = '';
348
+ if (defaultValue) {
349
+ const hasHiddenFields = defaultValue.length !== 3;
350
+ defaultDay = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).day : defaultValue[DAY];
351
+ defaultMonth = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).month : defaultValue[MONTH];
352
+ defaultYear = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).year : defaultValue[YEAR];
353
+ }
354
+ if (this.options.building && defaultValue.length === 3) {
355
+ return this.component.defaultValue;
356
+ }
345
357
  const getNextPart = (shouldTake, defaultValue) => {
346
358
  // Only push the part if it's not an empty string
347
359
  const part = shouldTake ? valueParts.shift() : defaultValue;
@@ -350,13 +362,13 @@ export default class DayComponent extends Field {
350
362
  }
351
363
  };
352
364
  if (this.dayFirst) {
353
- getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
365
+ getNextPart(this.showDay, defaultDay);
354
366
  }
355
- getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '');
367
+ getNextPart(this.showMonth, defaultMonth);
356
368
  if (!this.dayFirst) {
357
- getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
369
+ getNextPart(this.showDay, defaultDay);
358
370
  }
359
- getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '');
371
+ getNextPart(this.showYear, defaultYear);
360
372
  return dateParts.join('/');
361
373
  }
362
374
  /**
@@ -371,16 +383,23 @@ export default class DayComponent extends Field {
371
383
  if (value === 'Invalid date') {
372
384
  return null;
373
385
  }
386
+ let day, month, year;
374
387
  const parts = value.split('/');
375
- let day;
376
- if (this.component.dayFirst) {
377
- day = parts.shift();
388
+ if (parts.length !== 3) {
389
+ day = this.getDayWithHiddenFields(parts).day;
390
+ month = this.getDayWithHiddenFields(parts).month;
391
+ year = this.getDayWithHiddenFields(parts).year;
378
392
  }
379
- const month = parts.shift();
380
- if (!this.component.dayFirst) {
381
- day = parts.shift();
393
+ else {
394
+ if (this.component.dayFirst) {
395
+ day = parts.shift();
396
+ }
397
+ month = parts.shift();
398
+ if (!this.component.dayFirst) {
399
+ day = parts.shift();
400
+ }
401
+ year = parts.shift();
382
402
  }
383
- const year = parts.shift();
384
403
  if (this.refs.day && this.showDay) {
385
404
  this.refs.day.value = day === '00' ? '' : parseInt(day, 10);
386
405
  }
@@ -391,6 +410,27 @@ export default class DayComponent extends Field {
391
410
  this.refs.year.value = year === '0000' ? '' : parseInt(year, 10);
392
411
  }
393
412
  }
413
+ getDayWithHiddenFields(parts) {
414
+ let [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
415
+ if (!this.showDay) {
416
+ MONTH = MONTH === 0 ? 0 : MONTH - 1;
417
+ YEAR = YEAR - 1;
418
+ DAY = null;
419
+ }
420
+ if (!this.showMonth) {
421
+ DAY = DAY === 0 ? 0 : DAY - 1;
422
+ YEAR = YEAR - 1;
423
+ MONTH = null;
424
+ }
425
+ if (!this.showYear) {
426
+ YEAR = null;
427
+ }
428
+ return {
429
+ month: _.isNull(MONTH) ? '' : parts[MONTH],
430
+ day: _.isNull(DAY) ? '' : parts[DAY],
431
+ year: _.isNull(YEAR) ? '' : parts[YEAR],
432
+ };
433
+ }
394
434
  getFieldValue(name) {
395
435
  const parts = this.dataValue ? this.dataValue.split('/') : [];
396
436
  let val = 0;
@@ -557,7 +597,7 @@ export default class DayComponent extends Field {
557
597
  }
558
598
  isPartialDay(value) {
559
599
  if (!value) {
560
- return false;
600
+ return true;
561
601
  }
562
602
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
563
603
  const values = value.split('/');