@formio/js 5.4.0-api98.1 → 5.4.1

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 (132) hide show
  1. package/dist/formio.builder.css +26 -5
  2. package/dist/formio.builder.min.css +1 -1
  3. package/dist/formio.embed.js +1 -1
  4. package/dist/formio.embed.min.js +1 -1
  5. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  6. package/dist/formio.form.css +26 -5
  7. package/dist/formio.form.js +3462 -3448
  8. package/dist/formio.form.min.css +1 -1
  9. package/dist/formio.form.min.js +1 -1
  10. package/dist/formio.form.min.js.LICENSE.txt +2 -2
  11. package/dist/formio.full.css +26 -5
  12. package/dist/formio.full.js +4277 -4263
  13. package/dist/formio.full.min.css +1 -1
  14. package/dist/formio.full.min.js +1 -1
  15. package/dist/formio.full.min.js.LICENSE.txt +2 -2
  16. package/dist/formio.js +1738 -1724
  17. package/dist/formio.min.js +1 -1
  18. package/dist/formio.min.js.LICENSE.txt +2 -2
  19. package/dist/formio.utils.js +1631 -1617
  20. package/dist/formio.utils.min.js +1 -1
  21. package/dist/formio.utils.min.js.LICENSE.txt +2 -2
  22. package/lib/cjs/Element.d.ts +11 -0
  23. package/lib/cjs/Element.js +24 -0
  24. package/lib/cjs/Embed.js +23 -2
  25. package/lib/cjs/Form.d.ts +1 -1
  26. package/lib/cjs/Formio.js +1 -1
  27. package/lib/cjs/PDFBuilder.js +6 -1
  28. package/lib/cjs/Webform.d.ts +1 -1
  29. package/lib/cjs/Webform.js +9 -6
  30. package/lib/cjs/WebformBuilder.js +14 -1
  31. package/lib/cjs/Wizard.js +15 -11
  32. package/lib/cjs/components/Components.d.ts +3 -0
  33. package/lib/cjs/components/Components.js +3 -1
  34. package/lib/cjs/components/_classes/component/Component.d.ts +13 -0
  35. package/lib/cjs/components/_classes/component/Component.js +137 -44
  36. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  37. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +1 -1
  38. package/lib/cjs/components/_classes/component/editForm/utils.d.ts +1 -0
  39. package/lib/cjs/components/_classes/component/editForm/utils.js +3 -0
  40. package/lib/cjs/components/_classes/nested/NestedComponent.js +5 -7
  41. package/lib/cjs/components/address/Address.js +2 -0
  42. package/lib/cjs/components/button/Button.d.ts +1 -0
  43. package/lib/cjs/components/button/Button.js +22 -1
  44. package/lib/cjs/components/datagrid/DataGrid.js +35 -10
  45. package/lib/cjs/components/datamap/DataMap.d.ts +1 -4
  46. package/lib/cjs/components/datamap/DataMap.js +42 -10
  47. package/lib/cjs/components/datetime/DateTime.js +11 -1
  48. package/lib/cjs/components/datetime/editForm/DateTime.edit.date.d.ts +18 -1
  49. package/lib/cjs/components/datetime/editForm/DateTime.edit.date.js +3 -0
  50. package/lib/cjs/components/datetime/editForm/DateTime.edit.time.d.ts +13 -2
  51. package/lib/cjs/components/datetime/editForm/DateTime.edit.time.js +3 -0
  52. package/lib/cjs/components/day/Day.d.ts +0 -15
  53. package/lib/cjs/components/day/Day.js +8 -17
  54. package/lib/cjs/components/editgrid/EditGrid.js +13 -3
  55. package/lib/cjs/components/file/File.js +7 -6
  56. package/lib/cjs/components/form/Form.d.ts +1 -0
  57. package/lib/cjs/components/form/Form.js +20 -8
  58. package/lib/cjs/components/number/Number.d.ts +1 -0
  59. package/lib/cjs/components/number/Number.js +18 -0
  60. package/lib/cjs/components/select/Select.js +6 -3
  61. package/lib/cjs/components/signature/Signature.js +5 -5
  62. package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
  63. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +0 -1
  64. package/lib/cjs/components/textfield/editForm/TextField.edit.display.d.ts +0 -10
  65. package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +9 -23
  66. package/lib/cjs/formio.form.js +2 -5
  67. package/lib/cjs/package.json +1 -1
  68. package/lib/cjs/providers/address/GoogleAddressProvider.js +1 -1
  69. package/lib/cjs/providers/storage/azure.js +9 -3
  70. package/lib/cjs/translations/en.d.ts +1 -0
  71. package/lib/cjs/translations/en.js +3 -1
  72. package/lib/cjs/utils/formUtils.d.ts +2 -2
  73. package/lib/cjs/utils/index.d.ts +3 -3
  74. package/lib/cjs/utils/utils.d.ts +1 -1
  75. package/lib/cjs/utils/utils.js +28 -11
  76. package/lib/cjs/widgets/CalendarWidget.js +1 -1
  77. package/lib/mjs/Element.d.ts +11 -0
  78. package/lib/mjs/Element.js +23 -0
  79. package/lib/mjs/Embed.js +21 -2
  80. package/lib/mjs/Form.d.ts +1 -1
  81. package/lib/mjs/Formio.js +1 -1
  82. package/lib/mjs/PDFBuilder.js +6 -1
  83. package/lib/mjs/Webform.d.ts +1 -1
  84. package/lib/mjs/Webform.js +6 -3
  85. package/lib/mjs/WebformBuilder.js +13 -1
  86. package/lib/mjs/Wizard.js +9 -10
  87. package/lib/mjs/components/Components.d.ts +3 -0
  88. package/lib/mjs/components/Components.js +3 -1
  89. package/lib/mjs/components/_classes/component/Component.d.ts +13 -0
  90. package/lib/mjs/components/_classes/component/Component.js +135 -43
  91. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  92. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +1 -1
  93. package/lib/mjs/components/_classes/component/editForm/utils.d.ts +1 -0
  94. package/lib/mjs/components/_classes/component/editForm/utils.js +3 -0
  95. package/lib/mjs/components/_classes/nested/NestedComponent.js +5 -6
  96. package/lib/mjs/components/address/Address.js +2 -0
  97. package/lib/mjs/components/button/Button.d.ts +1 -0
  98. package/lib/mjs/components/button/Button.js +21 -1
  99. package/lib/mjs/components/datagrid/DataGrid.js +39 -11
  100. package/lib/mjs/components/datamap/DataMap.d.ts +1 -4
  101. package/lib/mjs/components/datamap/DataMap.js +41 -10
  102. package/lib/mjs/components/datetime/DateTime.js +11 -1
  103. package/lib/mjs/components/datetime/editForm/DateTime.edit.date.d.ts +18 -1
  104. package/lib/mjs/components/datetime/editForm/DateTime.edit.date.js +3 -0
  105. package/lib/mjs/components/datetime/editForm/DateTime.edit.time.d.ts +13 -2
  106. package/lib/mjs/components/datetime/editForm/DateTime.edit.time.js +3 -0
  107. package/lib/mjs/components/day/Day.d.ts +0 -15
  108. package/lib/mjs/components/day/Day.js +8 -17
  109. package/lib/mjs/components/editgrid/EditGrid.js +12 -2
  110. package/lib/mjs/components/file/File.js +7 -6
  111. package/lib/mjs/components/form/Form.d.ts +1 -0
  112. package/lib/mjs/components/form/Form.js +18 -6
  113. package/lib/mjs/components/number/Number.d.ts +1 -0
  114. package/lib/mjs/components/number/Number.js +17 -0
  115. package/lib/mjs/components/select/Select.js +6 -3
  116. package/lib/mjs/components/signature/Signature.js +1 -1
  117. package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
  118. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +0 -1
  119. package/lib/mjs/components/textfield/editForm/TextField.edit.display.d.ts +0 -10
  120. package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +9 -23
  121. package/lib/mjs/formio.form.js +4 -7
  122. package/lib/mjs/package.json +1 -1
  123. package/lib/mjs/providers/address/GoogleAddressProvider.js +1 -1
  124. package/lib/mjs/providers/storage/azure.js +9 -3
  125. package/lib/mjs/translations/en.d.ts +1 -0
  126. package/lib/mjs/translations/en.js +3 -1
  127. package/lib/mjs/utils/formUtils.d.ts +2 -2
  128. package/lib/mjs/utils/index.d.ts +3 -3
  129. package/lib/mjs/utils/utils.d.ts +1 -1
  130. package/lib/mjs/utils/utils.js +27 -11
  131. package/lib/mjs/widgets/CalendarWidget.js +2 -2
  132. package/package.json +8 -7
@@ -163,6 +163,13 @@ export default class DateTimeComponent extends Input {
163
163
  get momentFormat() {
164
164
  return FormioUtils.convertFormatToMoment(this.component.format);
165
165
  }
166
+ get timezone() {
167
+ const widget = this.component.widget;
168
+ if (widget && widget.type === 'calendar') {
169
+ return this.getTimezone(widget);
170
+ }
171
+ return super.timezone;
172
+ }
166
173
  isEmpty(value = this.dataValue) {
167
174
  if (value && value.toString() === 'Invalid Date') {
168
175
  return true;
@@ -194,7 +201,10 @@ export default class DateTimeComponent extends Input {
194
201
  let format = FormioUtils.convertFormatToMoment(this.component.format);
195
202
  format += format.match(/z$/) ? '' : ' z';
196
203
  const timezone = this.timezone;
197
- if (value && !this.attached && timezone) {
204
+ const useTimezoneAwareFormat = value &&
205
+ timezone &&
206
+ (this.options.pdf || options?.email);
207
+ if (useTimezoneAwareFormat) {
198
208
  if (Array.isArray(value) && this.component.multiple) {
199
209
  return value
200
210
  .map((item) => _.trim(FormioUtils.momentDate(item, format, timezone, options).format(format)))
@@ -5,8 +5,10 @@ declare const _default: ({
5
5
  label: string;
6
6
  weight: number;
7
7
  tooltip: string;
8
+ validate: {
9
+ custom: string;
10
+ };
8
11
  placeholder?: undefined;
9
- validate?: undefined;
10
12
  title?: undefined;
11
13
  collapsible?: undefined;
12
14
  collapsed?: undefined;
@@ -57,7 +59,22 @@ declare const _default: ({
57
59
  label?: undefined;
58
60
  weight?: undefined;
59
61
  tooltip?: undefined;
62
+ validate?: undefined;
60
63
  placeholder?: undefined;
64
+ } | {
65
+ type: string;
66
+ input: boolean;
67
+ key: string;
68
+ label: string;
69
+ tooltip: string;
70
+ weight: number;
61
71
  validate?: undefined;
72
+ placeholder?: undefined;
73
+ title?: undefined;
74
+ collapsible?: undefined;
75
+ collapsed?: undefined;
76
+ style?: undefined;
77
+ customConditional?: undefined;
78
+ components?: undefined;
62
79
  })[];
63
80
  export default _default;
@@ -8,6 +8,9 @@ export default [
8
8
  label: 'Enable Date Input',
9
9
  weight: 0,
10
10
  tooltip: 'Enables date input for this field.',
11
+ validate: {
12
+ custom: "valid = !data.enableTime && !input ? 'Cannot disable both Date and Time inputs at the same time' : true",
13
+ },
11
14
  },
12
15
  {
13
16
  type: 'tags',
@@ -1,9 +1,20 @@
1
- declare const _default: {
1
+ declare const _default: ({
2
2
  type: string;
3
3
  input: boolean;
4
4
  key: string;
5
5
  label: string;
6
6
  tooltip: string;
7
7
  weight: number;
8
- }[];
8
+ validate: {
9
+ custom: string;
10
+ };
11
+ } | {
12
+ type: string;
13
+ input: boolean;
14
+ key: string;
15
+ label: string;
16
+ tooltip: string;
17
+ weight: number;
18
+ validate?: undefined;
19
+ })[];
9
20
  export default _default;
@@ -6,6 +6,9 @@ export default [
6
6
  label: 'Enable Time Input',
7
7
  tooltip: 'Enables time input for this field.',
8
8
  weight: 0,
9
+ validate: {
10
+ custom: "valid = !data.enableDate && !input ? 'Cannot disable both Date and Time inputs at the same time' : true",
11
+ },
9
12
  },
10
13
  {
11
14
  type: 'number',
@@ -57,10 +57,6 @@ export default class DayComponent extends Field {
57
57
  value: string;
58
58
  label: any;
59
59
  }[];
60
- _days: {
61
- value: string;
62
- label: any;
63
- }[] | undefined;
64
60
  get months(): ({
65
61
  value: string;
66
62
  label: any;
@@ -68,21 +64,10 @@ export default class DayComponent extends Field {
68
64
  value: number;
69
65
  label: string;
70
66
  })[];
71
- _months: ({
72
- value: string;
73
- label: any;
74
- } | {
75
- value: number;
76
- label: string;
77
- })[] | undefined;
78
67
  get years(): {
79
68
  value: string;
80
69
  label: any;
81
70
  }[];
82
- _years: {
83
- value: string;
84
- label: any;
85
- }[] | undefined;
86
71
  setErrorClasses(elements: any, dirty: any, hasError: any): void;
87
72
  dayFirst: any;
88
73
  render(): string;
@@ -166,25 +166,19 @@ export default class DayComponent extends Field {
166
166
  };
167
167
  }
168
168
  get days() {
169
- if (this._days) {
170
- return this._days;
171
- }
172
- this._days = [
169
+ const days = [
173
170
  { value: '', label: _.get(this.component, 'fields.day.placeholder', '') },
174
171
  ];
175
172
  for (let x = 1; x <= 31; x++) {
176
- this._days.push({
173
+ days.push({
177
174
  value: x,
178
175
  label: x.toString(),
179
176
  });
180
177
  }
181
- return this._days;
178
+ return days;
182
179
  }
183
180
  get months() {
184
- if (this._months) {
185
- return this._months;
186
- }
187
- this._months = [
181
+ const months = [
188
182
  {
189
183
  value: '',
190
184
  label: _.get(this.component, 'fields.month.placeholder') ||
@@ -203,24 +197,21 @@ export default class DayComponent extends Field {
203
197
  { value: 11, label: 'November' },
204
198
  { value: 12, label: 'December' },
205
199
  ];
206
- return this._months;
200
+ return months;
207
201
  }
208
202
  get years() {
209
- if (this._years) {
210
- return this._years;
211
- }
212
- this._years = [
203
+ const years = [
213
204
  { value: '', label: _.get(this.component, 'fields.year.placeholder', '') },
214
205
  ];
215
206
  const minYears = _.get(this.component, 'fields.year.minYear', 1900) || 1900;
216
207
  const maxYears = _.get(this.component, 'fields.year.maxYear', 2030) || 2030;
217
208
  for (let x = minYears; x <= maxYears; x++) {
218
- this._years.push({
209
+ years.push({
219
210
  value: x,
220
211
  label: x.toString(),
221
212
  });
222
213
  }
223
- return this._years;
214
+ return years;
224
215
  }
225
216
  setErrorClasses(elements, dirty, hasError) {
226
217
  super.setErrorClasses(elements, dirty, hasError);
@@ -538,7 +538,7 @@ export default class EditGridComponent extends NestedArrayComponent {
538
538
  isVisibleInRow: (component) => this.isComponentVisibleInRow(component, flattenedComponents),
539
539
  getView: (component, data) => {
540
540
  const instance = flattenedComponents[component.key];
541
- const view = instance ? instance.getView(data || instance.dataValue) : '';
541
+ const view = instance ? instance.getView(instance.dataValue) : '';
542
542
  // If there is an html tag in view, don't allow it to be injected in template
543
543
  const htmlTagRegExp = new RegExp('<(.*?)>');
544
544
  return typeof view === 'string' &&
@@ -859,7 +859,7 @@ export default class EditGridComponent extends NestedArrayComponent {
859
859
  if (this.component.rowDrafts) {
860
860
  editRow.components.forEach((comp) => comp.setPristine(this.pristine));
861
861
  }
862
- this.checkValidity(null, true);
862
+ this.checkValidity(null, !this.component.rowDrafts || this.root?.submitted);
863
863
  this.redraw();
864
864
  if (editRow.alerts) {
865
865
  editRow.alerts = false;
@@ -948,9 +948,19 @@ export default class EditGridComponent extends NestedArrayComponent {
948
948
  }
949
949
  const column = _.clone(col);
950
950
  const options = _.clone(this.options);
951
+ const rootSubmissionTz = _.get(this.root, 'options.submissionTimezone');
952
+ if (rootSubmissionTz && !options.submissionTimezone) {
953
+ options.submissionTimezone = rootSubmissionTz;
954
+ }
951
955
  options.name += `[${rowIndex}]`;
952
956
  options.row = `${rowIndex}-${colIndex}`;
953
957
  options.rowIndex = rowIndex;
958
+ if (this.submissionTimezone) {
959
+ options.submissionTimezone = this.submissionTimezone;
960
+ if (column.type === 'datetime') {
961
+ column.widget = { ...column.widget, submissionTimezone: this.submissionTimezone };
962
+ }
963
+ }
954
964
  options.onChange = (flags = {}, changed, modified) => {
955
965
  if (changed.instance.root?.id && this.root?.id !== changed.instance.root.id) {
956
966
  changed.instance.root?.triggerChange?.(flags, changed, modified);
@@ -963,16 +963,17 @@ export default class FileComponent extends Field {
963
963
  : false;
964
964
  }
965
965
  async uploadFile(fileToSync) {
966
- return await this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
966
+ const filePromise = this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
967
967
  // Progress callback
968
968
  this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
969
- this.emit('fileUploadingStart');
969
+ this.emit('fileUploadingStart', filePromise);
970
970
  },
971
971
  // Abort upload callback
972
972
  (abort) => this.abortUploads.push({
973
973
  id: fileToSync.id,
974
974
  abort,
975
975
  }), this.getMultipartOptions(fileToSync));
976
+ return await filePromise;
976
977
  }
977
978
  async upload() {
978
979
  if (!this.filesToSync.filesToUpload.length) {
@@ -1008,7 +1009,7 @@ export default class FileComponent extends Field {
1008
1009
  fileToSync.message = this.t('Succefully uploaded');
1009
1010
  fileInfo.originalName = fileToSync.originalName;
1010
1011
  fileInfo.hash = fileToSync.hash;
1011
- this.emit('fileUploadingEnd');
1012
+ this.emit('fileUploadingEnd', Promise.resolve(fileInfo));
1012
1013
  }
1013
1014
  catch (response) {
1014
1015
  fileToSync.status = 'error';
@@ -1019,8 +1020,8 @@ export default class FileComponent extends Field {
1019
1020
  : response.type === 'abort'
1020
1021
  ? this.t('Request was aborted')
1021
1022
  : response.toString();
1022
- this.emit('fileUploadingEnd');
1023
- this.emit('fileUploadError', {
1023
+ this.emit('fileUploadingEnd', Promise.reject(response));
1024
+ this.emit(_.get(response, 'type') === 'abort' ? 'fileUploadCanceled' : 'fileUploadError', {
1024
1025
  fileToSync,
1025
1026
  response,
1026
1027
  });
@@ -1029,7 +1030,7 @@ export default class FileComponent extends Field {
1029
1030
  delete fileToSync.progress;
1030
1031
  this.redraw();
1031
1032
  const fileExists = this.resolvedFiles.find(x => x.fileInfo.originalName === fileToSync.originalName);
1032
- if (!fileExists) {
1033
+ if (!fileExists && fileToSync.status !== 'error') {
1033
1034
  this.resolvedFiles.push({ fileToSync, fileInfo });
1034
1035
  }
1035
1036
  }
@@ -42,6 +42,7 @@ export default class FormComponent extends Component {
42
42
  everyComponent(...args: any[]): any;
43
43
  setSubFormDisabled(subForm: any): void;
44
44
  updateSubWizards(subForm: any): void;
45
+ updateTopLevelComponentsMap(): void;
45
46
  setComponentsMap(): void;
46
47
  /**
47
48
  * Create a subform instance.
@@ -393,13 +393,22 @@ export default class FormComponent extends Component {
393
393
  this.emit('subWizardsUpdated', subForm);
394
394
  }
395
395
  }
396
+ updateTopLevelComponentsMap() {
397
+ let prevRootId = null;
398
+ let currentRoot = this.root;
399
+ const subFormComponentMap = this.subForm.componentsMap;
400
+ // update components map for all top forms
401
+ while (currentRoot && prevRootId !== currentRoot.id) {
402
+ _.assign(currentRoot.componentsMap, subFormComponentMap);
403
+ prevRootId = currentRoot.id;
404
+ currentRoot = currentRoot.root;
405
+ }
406
+ }
396
407
  setComponentsMap() {
397
408
  if (!this.subForm) {
398
409
  return;
399
410
  }
400
- const componentsMap = this.componentsMap;
401
- const formComponentsMap = this.subForm.componentsMap;
402
- _.assign(componentsMap, formComponentsMap);
411
+ this.updateTopLevelComponentsMap();
403
412
  }
404
413
  /**
405
414
  * Create a subform instance.
@@ -428,7 +437,7 @@ export default class FormComponent extends Component {
428
437
  this.subForm.currentForm = this;
429
438
  this.subForm.parentVisible = this.visible;
430
439
  this.setComponentsMap();
431
- this.component.components = this.subForm._form?.components;
440
+ this.component.components = this.subForm.components.map((comp) => comp.component);
432
441
  this.component.display = this.subForm._form?.display;
433
442
  this.subForm.on('change', () => {
434
443
  if (this.subForm && !this.shouldConditionallyClear()) {
@@ -552,10 +561,11 @@ export default class FormComponent extends Component {
552
561
  * @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
553
562
  */
554
563
  get shouldSubmit() {
564
+ const hiddenByJsonOnly = !this.hasCondition() && this.component.hidden;
555
565
  return (this.subFormReady &&
556
566
  (!this.component.hasOwnProperty('reference') || this.component.reference) &&
557
567
  !this.shouldConditionallyClear() &&
558
- !(this.component.hidden && this.component.clearOnHide));
568
+ !(hiddenByJsonOnly && this.component.clearOnHide));
559
569
  }
560
570
  /**
561
571
  * Returns the data for the subform.
@@ -760,7 +770,9 @@ export default class FormComponent extends Component {
760
770
  }
761
771
  this.updateSubFormVisibility();
762
772
  this.clearOnHide();
763
- isNestedWizard ? this.rebuild() : this.redraw();
773
+ if (!isNestedWizard) {
774
+ this.redraw();
775
+ }
764
776
  }
765
777
  if (!value && isNestedWizard) {
766
778
  this.root?.redraw();
@@ -34,6 +34,7 @@ export default class NumberComponent extends Input {
34
34
  * @returns {number} a parsed number
35
35
  */
36
36
  parseNumber(value: string): number;
37
+ normalizeValue(value: any, flags?: {}, emptyValue?: null): any;
37
38
  setInputMask(input: any): void;
38
39
  getValueAt(index: any): number | null;
39
40
  setValueAt(index: any, value: any, flags?: {}): void;
@@ -141,6 +141,23 @@ export default class NumberComponent extends Input {
141
141
  return parseFloat(value);
142
142
  }
143
143
  }
144
+ normalizeValue(value, flags = {}, emptyValue = this.emptyValue) {
145
+ if (typeof value === 'string') {
146
+ const result = this.parseNumber(value);
147
+ value = _.isNaN(result) ? this.emptyValue : result;
148
+ }
149
+ if (this.component?.multiple && Array.isArray(value)) {
150
+ const normilizedValues = value.map((val) => {
151
+ if (typeof val === 'string') {
152
+ const result = this.parseNumber(val);
153
+ return _.isNaN(result) ? this.emptyValue : result;
154
+ }
155
+ return val;
156
+ });
157
+ value = normilizedValues;
158
+ }
159
+ return super.normalizeValue(value, flags, emptyValue);
160
+ }
144
161
  setInputMask(input) {
145
162
  let numberPattern = '[0-9';
146
163
  numberPattern += this.decimalSeparator || '';
@@ -1326,8 +1326,7 @@ export default class SelectComponent extends ListComponent {
1326
1326
  return super.normalizeValue(this.normalizeSingleValue(value));
1327
1327
  }
1328
1328
  setMetadata(value, flags = {}) {
1329
- if (_.isNil(value) ||
1330
- (this.inDataTable && this.component.dataSrc === 'values')) {
1329
+ if (_.isNil(value)) {
1331
1330
  return;
1332
1331
  }
1333
1332
  const valueIsObject = _.isObject(value);
@@ -1366,6 +1365,10 @@ export default class SelectComponent extends ListComponent {
1366
1365
  }
1367
1366
  _.set(submission.metadata.selectData, this.path, templateData);
1368
1367
  }
1368
+ else if (!this.templateData[templateValue] &&
1369
+ this.isEmpty(value)) {
1370
+ _.unset(this.root.submission, `metadata.selectData.${this.path}`);
1371
+ }
1369
1372
  if (flags.resetValue && this.root?.submission && !this.options.readOnly) {
1370
1373
  const submission = this.root.submission;
1371
1374
  if (!submission.metadata) {
@@ -1627,7 +1630,7 @@ export default class SelectComponent extends ListComponent {
1627
1630
  if (this.inDataTable) {
1628
1631
  value = this.undoValueTyping(value);
1629
1632
  }
1630
- const templateValue = this.isEntireObjectDisplay() && !_.isObject(value.data) ? { data: value } : value;
1633
+ const templateValue = !_.isEmpty(value) && this.isEntireObjectDisplay() && !_.isObject(value.data) ? { data: value } : value;
1631
1634
  const template = this.itemTemplate(templateValue, value, options);
1632
1635
  return template;
1633
1636
  }
@@ -57,7 +57,7 @@ export default class SignatureComponent extends Input {
57
57
  this.component.height = '200px';
58
58
  }
59
59
  if (this.component.keepOverlayRatio &&
60
- this.options?.display === 'pdf' &&
60
+ this.options.pdf &&
61
61
  this.component.overlay?.width &&
62
62
  this.component.overlay?.height) {
63
63
  this.ratio = this.component.overlay?.width / this.component.overlay?.height;
@@ -7,7 +7,6 @@ declare const _default: ({
7
7
  placeholder: string;
8
8
  weight: number;
9
9
  conditional?: undefined;
10
- customConditional?: undefined;
11
10
  ignore?: undefined;
12
11
  } | {
13
12
  type: string;
@@ -24,7 +23,6 @@ declare const _default: ({
24
23
  };
25
24
  };
26
25
  weight: number;
27
- customConditional?: undefined;
28
26
  ignore?: undefined;
29
27
  } | {
30
28
  weight: number;
@@ -32,9 +30,6 @@ declare const _default: ({
32
30
  label: string;
33
31
  tooltip: string;
34
32
  key: string;
35
- customConditional: ({ options }: {
36
- options: any;
37
- }) => boolean;
38
33
  input: boolean;
39
34
  placeholder?: undefined;
40
35
  conditional?: undefined;
@@ -49,6 +44,5 @@ declare const _default: ({
49
44
  placeholder?: undefined;
50
45
  weight?: undefined;
51
46
  conditional?: undefined;
52
- customConditional?: undefined;
53
47
  })[];
54
48
  export default _default;
@@ -46,7 +46,6 @@ export default [
46
46
  label: 'Keep Overlay Aspect Ratio',
47
47
  tooltip: 'If checked, the field will have the same aspect ratio as its preview.',
48
48
  key: 'keepOverlayRatio',
49
- customConditional: ({ options }) => options?.editForm?.display === 'pdf',
50
49
  input: true,
51
50
  },
52
51
  {
@@ -25,7 +25,6 @@ declare const _default: ({
25
25
  };
26
26
  };
27
27
  clearOnHide?: undefined;
28
- customDefaultValue?: undefined;
29
28
  rows?: undefined;
30
29
  editor?: undefined;
31
30
  as?: undefined;
@@ -40,7 +39,6 @@ declare const _default: ({
40
39
  label: string;
41
40
  clearOnHide: boolean;
42
41
  onChange: (context: any) => void;
43
- customDefaultValue: (value: any, component: any, row: any, data: any, instance: any) => any;
44
42
  input: boolean;
45
43
  rows: number;
46
44
  editor: string;
@@ -79,7 +77,6 @@ declare const _default: ({
79
77
  data?: undefined;
80
78
  conditional?: undefined;
81
79
  clearOnHide?: undefined;
82
- customDefaultValue?: undefined;
83
80
  rows?: undefined;
84
81
  editor?: undefined;
85
82
  as?: undefined;
@@ -107,7 +104,6 @@ declare const _default: ({
107
104
  onChange?: undefined;
108
105
  conditional?: undefined;
109
106
  clearOnHide?: undefined;
110
- customDefaultValue?: undefined;
111
107
  rows?: undefined;
112
108
  editor?: undefined;
113
109
  as?: undefined;
@@ -133,7 +129,6 @@ declare const _default: ({
133
129
  data?: undefined;
134
130
  conditional?: undefined;
135
131
  clearOnHide?: undefined;
136
- customDefaultValue?: undefined;
137
132
  rows?: undefined;
138
133
  editor?: undefined;
139
134
  as?: undefined;
@@ -154,7 +149,6 @@ declare const _default: ({
154
149
  data?: undefined;
155
150
  conditional?: undefined;
156
151
  clearOnHide?: undefined;
157
- customDefaultValue?: undefined;
158
152
  rows?: undefined;
159
153
  editor?: undefined;
160
154
  as?: undefined;
@@ -177,7 +171,6 @@ declare const _default: ({
177
171
  data?: undefined;
178
172
  conditional?: undefined;
179
173
  clearOnHide?: undefined;
180
- customDefaultValue?: undefined;
181
174
  rows?: undefined;
182
175
  editor?: undefined;
183
176
  as?: undefined;
@@ -208,7 +201,6 @@ declare const _default: ({
208
201
  data?: undefined;
209
202
  conditional?: undefined;
210
203
  clearOnHide?: undefined;
211
- customDefaultValue?: undefined;
212
204
  rows?: undefined;
213
205
  editor?: undefined;
214
206
  as?: undefined;
@@ -228,7 +220,6 @@ declare const _default: ({
228
220
  data?: undefined;
229
221
  conditional?: undefined;
230
222
  clearOnHide?: undefined;
231
- customDefaultValue?: undefined;
232
223
  rows?: undefined;
233
224
  editor?: undefined;
234
225
  as?: undefined;
@@ -251,7 +242,6 @@ declare const _default: ({
251
242
  data?: undefined;
252
243
  conditional?: undefined;
253
244
  clearOnHide?: undefined;
254
- customDefaultValue?: undefined;
255
245
  rows?: undefined;
256
246
  editor?: undefined;
257
247
  as?: undefined;
@@ -14,30 +14,30 @@ export default [
14
14
  tooltip: 'The widget is the display UI used to input the value of the field.',
15
15
  defaultValue: 'input',
16
16
  calculateValue: (context) => {
17
- let currentType = context.data['widget.type'];
17
+ let currentType = context.instance._widgetType;
18
18
  if (currentType) {
19
19
  return currentType;
20
20
  }
21
21
  const widget = context.data.widget;
22
22
  if (isObject(widget) && widget.type) {
23
- context.data['widget.type'] = widget.type;
23
+ context.instance._widgetType = widget.type;
24
24
  return widget.type;
25
25
  }
26
26
  if (typeof widget === 'string') {
27
27
  const originalType = getOriginalWidget(context.instance)?.type;
28
28
  if (originalType) {
29
- context.data['widget.type'] = originalType;
29
+ context.instance._widgetType = originalType;
30
30
  return originalType;
31
31
  }
32
32
  }
33
33
  return 'input';
34
34
  },
35
35
  onChange: (context) => {
36
- const newType = context.data['widget.type'];
36
+ const newType = context.instance.dataValue;
37
37
  const currentWidget = context.data.widget;
38
38
  let oldType;
39
39
  if (isObject(currentWidget)) {
40
- oldType = currentWidget.type;
40
+ oldType = context.instance._widgetType;
41
41
  }
42
42
  else if (typeof currentWidget === 'string') {
43
43
  oldType = getOriginalWidget(context.instance)?.type;
@@ -48,10 +48,12 @@ export default [
48
48
  if (newType !== oldType) {
49
49
  if (newType === 'input') {
50
50
  context.data.widget = { type: 'input' };
51
+ context.instance._widgetType = newType;
51
52
  }
52
- else {
53
+ else if (newType) {
53
54
  const defaultSettings = getDefaultWidgetSettings(newType);
54
55
  context.data.widget = defaultSettings || { type: newType };
56
+ context.instance._widgetType = newType;
55
57
  }
56
58
  }
57
59
  else if (!currentWidget) {
@@ -87,28 +89,12 @@ export default [
87
89
  return;
88
90
  }
89
91
  if (isObject(currentWidget)) {
90
- const currentType = context.data['widget.type'];
92
+ const currentType = context.instance.root.getComponent('widget.type')._widgetType || currentWidget.type;
91
93
  if (currentType && currentWidget.type !== currentType) {
92
94
  context.data.widget = { ...currentWidget, type: currentType };
93
95
  }
94
96
  }
95
97
  },
96
- customDefaultValue: (value, component, row, data, instance) => {
97
- if (!data.widget) {
98
- const originalWidget = getOriginalWidget(instance);
99
- const widgetType = data['widget.type'] || originalWidget?.type;
100
- if (widgetType && widgetType !== 'input') {
101
- if (originalWidget?.type === widgetType && !_.isEmpty(_.omit(originalWidget, 'type'))) {
102
- return _.omit(originalWidget, 'language');
103
- }
104
- const defaultSettings = getDefaultWidgetSettings(widgetType);
105
- if (defaultSettings) {
106
- return defaultSettings;
107
- }
108
- }
109
- }
110
- return value;
111
- },
112
98
  input: true,
113
99
  rows: 5,
114
100
  editor: 'ace',
@@ -7,7 +7,7 @@ import Templates from './templates/Templates';
7
7
  import Providers from './providers';
8
8
  import Widgets from './widgets';
9
9
  import Form, { FormOptions } from './Form';
10
- import Utils, { Evaluator, registerEvaluator, DefaultEvaluator } from './utils';
10
+ import Utils, { DefaultEvaluator, Evaluator, registerEvaluator } from './utils';
11
11
  import Licenses from './licenses';
12
12
  import EventEmitter from './EventEmitter';
13
13
  import Webform from './Webform';
@@ -90,12 +90,9 @@ export function registerModule(mod, defaultFn = null, options = {}) {
90
90
  break;
91
91
  default:
92
92
  if (defaultFn) {
93
- if (!defaultFn(key, mod)) {
94
- console.warn('Unknown module option', key);
95
- }
93
+ defaultFn(key, mod);
96
94
  break;
97
95
  }
98
- console.log('Unknown module option', key);
99
96
  }
100
97
  }
101
98
  }
@@ -108,7 +105,7 @@ export function useModule(defaultFn = null) {
108
105
  plugins = _.isArray(plugins)
109
106
  ? plugins
110
107
  : [
111
- plugins,
108
+ plugins
112
109
  ];
113
110
  plugins.forEach((plugin) => {
114
111
  if (Array.isArray(plugin)) {
@@ -129,4 +126,4 @@ export function useModule(defaultFn = null) {
129
126
  Formio.use = useModule();
130
127
  export { Formio as FormioCore } from './Formio';
131
128
  // Export the components.
132
- export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator, FormOptions, };
129
+ export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator, FormOptions };