@formio/js 5.1.0-dev.6042.18ef5d3 → 5.1.0-dev.6042.603237d

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 (156) hide show
  1. package/Changelog.md +57 -402
  2. package/README.md +7 -0
  3. package/dist/formio.builder.css +1 -0
  4. package/dist/formio.builder.min.css +1 -1
  5. package/dist/formio.form.css +1 -0
  6. package/dist/formio.form.js +104 -126
  7. package/dist/formio.form.min.css +1 -1
  8. package/dist/formio.form.min.js +1 -1
  9. package/dist/formio.form.min.js.LICENSE.txt +3 -1
  10. package/dist/formio.full.css +1 -0
  11. package/dist/formio.full.js +111 -133
  12. package/dist/formio.full.min.css +1 -1
  13. package/dist/formio.full.min.js +1 -1
  14. package/dist/formio.full.min.js.LICENSE.txt +3 -1
  15. package/dist/formio.js +53 -64
  16. package/dist/formio.min.js +1 -1
  17. package/dist/formio.utils.js +66 -77
  18. package/dist/formio.utils.min.js +1 -1
  19. package/dist/formio.utils.min.js.LICENSE.txt +3 -1
  20. package/lib/cjs/Element.js +13 -36
  21. package/lib/cjs/EventEmitter.js +2 -25
  22. package/lib/cjs/Form.js +2 -25
  23. package/lib/cjs/PDF.js +1 -1
  24. package/lib/cjs/PDFBuilder.js +4 -5
  25. package/lib/cjs/Webform.js +8 -7
  26. package/lib/cjs/WebformBuilder.d.ts +1 -0
  27. package/lib/cjs/WebformBuilder.js +40 -14
  28. package/lib/cjs/Wizard.d.ts +1 -2
  29. package/lib/cjs/Wizard.js +18 -24
  30. package/lib/cjs/WizardBuilder.js +1 -1
  31. package/lib/cjs/components/_classes/component/Component.d.ts +26 -2
  32. package/lib/cjs/components/_classes/component/Component.js +97 -88
  33. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  34. package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  35. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
  36. package/lib/cjs/components/_classes/input/Input.js +1 -1
  37. package/lib/cjs/components/_classes/list/ListComponent.js +1 -1
  38. package/lib/cjs/components/_classes/nested/NestedComponent.js +7 -7
  39. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  40. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  41. package/lib/cjs/components/address/Address.js +1 -1
  42. package/lib/cjs/components/alert/Alert.js +1 -1
  43. package/lib/cjs/components/button/Button.d.ts +1 -1
  44. package/lib/cjs/components/button/Button.js +7 -11
  45. package/lib/cjs/components/checkbox/Checkbox.js +1 -1
  46. package/lib/cjs/components/container/Container.js +1 -1
  47. package/lib/cjs/components/currency/Currency.js +1 -1
  48. package/lib/cjs/components/datagrid/DataGrid.js +5 -1
  49. package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
  50. package/lib/cjs/components/datetime/DateTime.js +15 -13
  51. package/lib/cjs/components/day/Day.js +2 -2
  52. package/lib/cjs/components/editgrid/EditGrid.js +1 -1
  53. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  54. package/lib/cjs/components/file/File.js +5 -6
  55. package/lib/cjs/components/form/Form.d.ts +0 -1
  56. package/lib/cjs/components/form/Form.js +26 -22
  57. package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
  58. package/lib/cjs/components/number/Number.js +1 -1
  59. package/lib/cjs/components/panel/Panel.js +1 -1
  60. package/lib/cjs/components/radio/Radio.d.ts +8 -0
  61. package/lib/cjs/components/radio/Radio.js +16 -6
  62. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  63. package/lib/cjs/components/select/Select.d.ts +1 -0
  64. package/lib/cjs/components/select/Select.js +20 -4
  65. package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -1
  66. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
  67. package/lib/cjs/components/selectboxes/SelectBoxes.js +4 -1
  68. package/lib/cjs/components/signature/Signature.js +1 -1
  69. package/lib/cjs/components/survey/Survey.js +1 -1
  70. package/lib/cjs/components/tags/Tags.js +1 -1
  71. package/lib/cjs/components/textarea/TextArea.js +3 -3
  72. package/lib/cjs/components/textfield/TextField.js +9 -32
  73. package/lib/cjs/components/time/Time.js +1 -1
  74. package/lib/cjs/formio.form.js +3 -3
  75. package/lib/cjs/providers/storage/uploadAdapter.js +3 -3
  76. package/lib/cjs/translations/en.js +1 -1
  77. package/lib/cjs/utils/Evaluator.d.ts +20 -6
  78. package/lib/cjs/utils/Evaluator.js +38 -15
  79. package/lib/cjs/utils/builder.js +5 -5
  80. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
  81. package/lib/cjs/utils/formUtils.d.ts +2 -2
  82. package/lib/cjs/utils/index.d.ts +169 -2
  83. package/lib/cjs/utils/index.js +22 -2
  84. package/lib/cjs/utils/utils.d.ts +31 -37
  85. package/lib/cjs/utils/utils.js +79 -135
  86. package/lib/cjs/widgets/CalendarWidget.d.ts +1 -8
  87. package/lib/cjs/widgets/CalendarWidget.js +19 -40
  88. package/lib/mjs/Element.js +6 -6
  89. package/lib/mjs/EventEmitter.js +2 -2
  90. package/lib/mjs/Form.js +1 -1
  91. package/lib/mjs/PDF.js +1 -1
  92. package/lib/mjs/PDFBuilder.js +1 -2
  93. package/lib/mjs/Webform.js +6 -5
  94. package/lib/mjs/WebformBuilder.d.ts +1 -0
  95. package/lib/mjs/WebformBuilder.js +32 -7
  96. package/lib/mjs/Wizard.d.ts +1 -2
  97. package/lib/mjs/Wizard.js +17 -23
  98. package/lib/mjs/WizardBuilder.js +1 -1
  99. package/lib/mjs/components/_classes/component/Component.d.ts +26 -2
  100. package/lib/mjs/components/_classes/component/Component.js +70 -38
  101. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  102. package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  103. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
  104. package/lib/mjs/components/_classes/input/Input.js +1 -1
  105. package/lib/mjs/components/_classes/list/ListComponent.js +1 -1
  106. package/lib/mjs/components/_classes/nested/NestedComponent.js +7 -7
  107. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  108. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  109. package/lib/mjs/components/address/Address.js +1 -1
  110. package/lib/mjs/components/alert/Alert.js +1 -1
  111. package/lib/mjs/components/button/Button.d.ts +1 -1
  112. package/lib/mjs/components/button/Button.js +7 -10
  113. package/lib/mjs/components/checkbox/Checkbox.js +1 -1
  114. package/lib/mjs/components/container/Container.js +1 -1
  115. package/lib/mjs/components/currency/Currency.js +1 -1
  116. package/lib/mjs/components/datagrid/DataGrid.js +5 -1
  117. package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
  118. package/lib/mjs/components/datetime/DateTime.js +15 -13
  119. package/lib/mjs/components/day/Day.js +2 -2
  120. package/lib/mjs/components/editgrid/EditGrid.js +1 -1
  121. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  122. package/lib/mjs/components/file/File.js +5 -6
  123. package/lib/mjs/components/form/Form.d.ts +0 -1
  124. package/lib/mjs/components/form/Form.js +25 -22
  125. package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
  126. package/lib/mjs/components/number/Number.js +1 -1
  127. package/lib/mjs/components/panel/Panel.js +1 -1
  128. package/lib/mjs/components/radio/Radio.d.ts +8 -0
  129. package/lib/mjs/components/radio/Radio.js +16 -6
  130. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  131. package/lib/mjs/components/select/Select.d.ts +1 -0
  132. package/lib/mjs/components/select/Select.js +20 -4
  133. package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -1
  134. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
  135. package/lib/mjs/components/selectboxes/SelectBoxes.js +4 -1
  136. package/lib/mjs/components/signature/Signature.js +1 -1
  137. package/lib/mjs/components/survey/Survey.js +1 -1
  138. package/lib/mjs/components/tags/Tags.js +1 -1
  139. package/lib/mjs/components/textarea/TextArea.js +3 -3
  140. package/lib/mjs/components/textfield/TextField.js +3 -3
  141. package/lib/mjs/components/time/Time.js +1 -1
  142. package/lib/mjs/formio.form.js +2 -2
  143. package/lib/mjs/providers/storage/uploadAdapter.js +3 -3
  144. package/lib/mjs/translations/en.js +3 -0
  145. package/lib/mjs/utils/Evaluator.d.ts +20 -6
  146. package/lib/mjs/utils/Evaluator.js +31 -13
  147. package/lib/mjs/utils/builder.js +1 -1
  148. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
  149. package/lib/mjs/utils/formUtils.d.ts +2 -2
  150. package/lib/mjs/utils/index.d.ts +169 -2
  151. package/lib/mjs/utils/index.js +18 -1
  152. package/lib/mjs/utils/utils.d.ts +31 -37
  153. package/lib/mjs/utils/utils.js +71 -109
  154. package/lib/mjs/widgets/CalendarWidget.d.ts +1 -8
  155. package/lib/mjs/widgets/CalendarWidget.js +19 -40
  156. package/package.json +8 -6
@@ -3,7 +3,7 @@ import _ from 'lodash';
3
3
  import Component from '../_classes/component/Component';
4
4
  import ComponentModal from '../_classes/componentModal/ComponentModal';
5
5
  import EventEmitter from 'eventemitter3';
6
- import { isMongoId, eachComponent, componentValueTypes } from '../../utils/utils';
6
+ import { isMongoId, eachComponent, componentValueTypes } from '../../utils';
7
7
  import { Formio } from '../../Formio';
8
8
  import Form from '../../Form';
9
9
  export default class FormComponent extends Component {
@@ -96,6 +96,9 @@ export default class FormComponent extends Component {
96
96
  }
97
97
  return this.createSubForm();
98
98
  }
99
+ shouldConditionallyClearOnPristine() {
100
+ return !this.hasSetValue && super.shouldConditionallyClearOnPristine();
101
+ }
99
102
  get dataReady() {
100
103
  return this.subForm?.dataReady || this.subFormReady || Promise.resolve();
101
104
  }
@@ -271,6 +274,9 @@ export default class FormComponent extends Component {
271
274
  if (this.isSubFormLazyLoad() && !this.hasLoadedForm && !this.subFormLoading) {
272
275
  this.createSubForm(true);
273
276
  }
277
+ if (!this.subFormReady) {
278
+ return Promise.resolve();
279
+ }
274
280
  return this.subFormReady.then(() => {
275
281
  this.empty(element);
276
282
  if (this.options.builder) {
@@ -286,11 +292,13 @@ export default class FormComponent extends Component {
286
292
  }
287
293
  this.subForm.attach(element);
288
294
  this.valueChanged = this.hasSetValue;
289
- if (!this.valueChanged && this.dataValue.state !== 'submitted') {
290
- this.setDefaultValue();
291
- }
292
- else {
293
- this.restoreValue();
295
+ if (!this.shouldConditionallyClear()) {
296
+ if (!this.valueChanged && this.dataValue.state !== 'submitted') {
297
+ this.setDefaultValue();
298
+ }
299
+ else {
300
+ this.restoreValue();
301
+ }
294
302
  }
295
303
  }
296
304
  if (!this.builderMode && this.component.modalEdit) {
@@ -403,9 +411,10 @@ export default class FormComponent extends Component {
403
411
  const componentsMap = this.componentsMap;
404
412
  const formComponentsMap = this.subForm.componentsMap;
405
413
  _.assign(componentsMap, formComponentsMap);
406
- this.component.components = this.subForm.components.map((comp) => comp.component);
414
+ this.component.components = this.subForm._form?.components;
415
+ this.component.display = this.subForm._form?.display;
407
416
  this.subForm.on('change', () => {
408
- if (this.subForm) {
417
+ if (this.subForm && !this.shouldConditionallyClear()) {
409
418
  this.dataValue = this.subForm.getValue();
410
419
  this.triggerChange({
411
420
  noEmit: true
@@ -668,20 +677,7 @@ export default class FormComponent extends Component {
668
677
  }
669
678
  }
670
679
  isEmpty(value = this.dataValue) {
671
- return value === null || _.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value?.data) && !value?._id);
672
- }
673
- areAllComponentsEmpty(data) {
674
- let res = true;
675
- if (this.subForm) {
676
- this.subForm.everyComponent((comp) => {
677
- const componentValue = _.get(data, comp.key);
678
- res &= comp.isEmpty(componentValue);
679
- });
680
- }
681
- else {
682
- res = false;
683
- }
684
- return res;
680
+ return value === null || _.isEqual(value, this.emptyValue);
685
681
  }
686
682
  getValue() {
687
683
  if (this.subForm) {
@@ -696,6 +692,13 @@ export default class FormComponent extends Component {
696
692
  }
697
693
  return errors;
698
694
  }
695
+ conditionallyHidden() {
696
+ const conditionallyHidden = super.conditionallyHidden();
697
+ if (this.subForm) {
698
+ this.subForm._conditionallyHidden = conditionallyHidden;
699
+ }
700
+ return conditionallyHidden;
701
+ }
699
702
  updateSubFormVisibility() {
700
703
  if (this.subForm) {
701
704
  this.subForm.parentVisible = this.visible;
@@ -30,9 +30,10 @@ export default [
30
30
  tooltip: 'if it is checked, the subform is loaded after navigation to the page with this component within the wizard.',
31
31
  input: true,
32
32
  customConditional({ instance, data }) {
33
- const formInfo = instance.root?.getComponent('form')?.defaultDownloadedResources.find(res => res._id === data.form);
33
+ const formComp = instance.root?.getComponent('form');
34
+ const formInfo = formComp?.defaultDownloadedResources.find(res => res._id === data.form);
34
35
  const displayMode = 'wizard';
35
- return instance.options?.editForm?.display === displayMode && formInfo && formInfo.display !== displayMode;
36
+ return instance.options?.editForm?.display === displayMode && ((data.form && !formInfo) || (formInfo && formInfo.display !== displayMode));
36
37
  },
37
38
  },
38
39
  {
@@ -2,7 +2,7 @@ import { createNumberMask } from '@formio/text-mask-addons';
2
2
  import { conformToMask, maskInput } from '@formio/vanilla-text-mask';
3
3
  import _ from 'lodash';
4
4
  import Input from '../_classes/input/Input';
5
- import { getNumberSeparators, getNumberDecimalLimit, componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
5
+ import { getNumberSeparators, getNumberDecimalLimit, componentValueTypes, getComponentSavedTypes } from '../../utils/';
6
6
  export default class NumberComponent extends Input {
7
7
  static schema(...extend) {
8
8
  return Input.schema({
@@ -1,5 +1,5 @@
1
1
  import NestedComponent from '../_classes/nested/NestedComponent';
2
- import { isChildOf } from '../../utils/utils';
2
+ import { isChildOf } from '../../utils';
3
3
  export default class PanelComponent extends NestedComponent {
4
4
  static schema(...extend) {
5
5
  return NestedComponent.schema({
@@ -28,6 +28,7 @@ export default class RadioComponent extends ListComponent {
28
28
  optionsLoaded: boolean | undefined;
29
29
  loadedOptions: any[] | undefined;
30
30
  beforeSubmit(): Promise<any>;
31
+ convertValues(values: any): any;
31
32
  render(): string;
32
33
  attach(element: any): Promise<void>;
33
34
  detach(element: any): void;
@@ -41,5 +42,12 @@ export default class RadioComponent extends ListComponent {
41
42
  setSelectedClasses(): void;
42
43
  updateValue(value: any, flags: any): boolean;
43
44
  currentValue: any;
45
+ /**
46
+ * Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
47
+ * @param {*} value - The value to normalize
48
+ * @returns {*} - Returns the normalized value
49
+ */
50
+ convertByDataType(value: any): any;
51
+ normalizeValue(value: any): any;
44
52
  }
45
53
  import ListComponent from '../_classes/list/ListComponent';
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import ListComponent from '../_classes/list/ListComponent';
3
3
  import { Formio } from '../../Formio';
4
- import { boolValue, componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
4
+ import { boolValue, componentValueTypes, getComponentSavedTypes } from '../../utils';
5
5
  export default class RadioComponent extends ListComponent {
6
6
  static schema(...extend) {
7
7
  return ListComponent.schema({
@@ -153,6 +153,12 @@ export default class RadioComponent extends ListComponent {
153
153
  this.dataReady.then(() => res(true));
154
154
  });
155
155
  }
156
+ convertValues(values) {
157
+ if (this.options.renderMode === 'html' && this.type === 'radio') {
158
+ return values.map(x => ({ ...x, value: this.convertByDataType(x.value) }));
159
+ }
160
+ return values;
161
+ }
156
162
  render() {
157
163
  if (!this.optionsLoaded) {
158
164
  return super.render(this.renderTemplate('loader'));
@@ -160,7 +166,7 @@ export default class RadioComponent extends ListComponent {
160
166
  return super.render(this.renderTemplate('radio', {
161
167
  input: this.inputInfo,
162
168
  inline: this.component.inline,
163
- values: this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions,
169
+ values: this.component.dataSrc === 'values' ? this.convertValues(this.component.values) : this.loadedOptions,
164
170
  value: this.dataValue,
165
171
  row: this.row,
166
172
  }));
@@ -406,7 +412,7 @@ export default class RadioComponent extends ListComponent {
406
412
  * @param {*} value - The value to normalize
407
413
  * @returns {*} - Returns the normalized value
408
414
  */
409
- normalizeValue(value) {
415
+ convertByDataType(value) {
410
416
  const dataType = this.component.dataType || 'auto';
411
417
  if (value === this.emptyValue) {
412
418
  return value;
@@ -438,13 +444,17 @@ export default class RadioComponent extends ListComponent {
438
444
  value = !(!value || value.toString() === 'false');
439
445
  break;
440
446
  }
441
- if (this.isSelectURL && this.templateData && this.templateData[value]) {
447
+ return value;
448
+ }
449
+ normalizeValue(value) {
450
+ const valueConverted = this.convertByDataType(value);
451
+ if (this.isSelectURL && this.templateData && this.templateData[valueConverted]) {
442
452
  const submission = this.root.submission;
443
453
  if (!submission.metadata.selectData) {
444
454
  submission.metadata.selectData = {};
445
455
  }
446
- _.set(submission.metadata.selectData, this.path, this.templateData[value]);
456
+ _.set(submission.metadata.selectData, this.path, this.templateData[valueConverted]);
447
457
  }
448
- return super.normalizeValue(value);
458
+ return super.normalizeValue(valueConverted);
449
459
  }
450
460
  }
@@ -1,4 +1,4 @@
1
- import { getContextButtons } from '../../../utils/utils';
1
+ import { getContextButtons } from '../../../utils';
2
2
  export default [
3
3
  {
4
4
  key: 'recaptchaInfo',
@@ -89,6 +89,7 @@ export default class SelectComponent extends ListComponent {
89
89
  disableInfiniteScroll(): void;
90
90
  set serverCount(value: any);
91
91
  get serverCount(): any;
92
+ shouldResetChoicesItems(items: any): boolean;
92
93
  setItems(items: any, fromSearch: any): void;
93
94
  selectItems: any;
94
95
  set downloadedResources(value: any);
@@ -2,7 +2,7 @@ import _ from 'lodash';
2
2
  import { Formio } from '../../Formio';
3
3
  import ListComponent from '../_classes/list/ListComponent';
4
4
  import Form from '../../Form';
5
- import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes, isSelectResourceWithObjectValue, removeHTML } from '../../utils/utils';
5
+ import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes, isSelectResourceWithObjectValue, removeHTML } from '../../utils';
6
6
  import Choices from '../../utils/ChoicesWrapper';
7
7
  export default class SelectComponent extends ListComponent {
8
8
  static schema(...extend) {
@@ -359,6 +359,18 @@ export default class SelectComponent extends ListComponent {
359
359
  this.downloadedResources.serverCount = this.downloadedResources.length;
360
360
  this.serverCount = this.downloadedResources.length;
361
361
  }
362
+ shouldResetChoicesItems(items) {
363
+ if (this.choices._store.choices.length !== items.length) {
364
+ return true;
365
+ }
366
+ for (let item of items) {
367
+ const choicesItem = this.choices._store.choices.find((i) => i.label === item.label);
368
+ if (!choicesItem) {
369
+ return true;
370
+ }
371
+ }
372
+ return false;
373
+ }
362
374
  /* eslint-disable max-statements */
363
375
  setItems(items, fromSearch) {
364
376
  this.selectItems = items;
@@ -444,7 +456,7 @@ export default class SelectComponent extends ListComponent {
444
456
  this.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, _.get(item, this.component.idPath, String(index)));
445
457
  });
446
458
  if (this.choices) {
447
- this.choices.setChoices(this.selectOptions, 'value', 'label', true);
459
+ this.choices.setChoices(this.selectOptions, 'value', 'label', true, true, !fromSearch && this.shouldResetChoicesItems(this.selectOptions));
448
460
  }
449
461
  else if (this.loading) {
450
462
  // Re-attach select input.
@@ -935,8 +947,9 @@ export default class SelectComponent extends ListComponent {
935
947
  });
936
948
  }
937
949
  // Add value options.
950
+ const value = this.undoValueTyping(this.dataValue);
938
951
  this.addValueOptions();
939
- this.setChoicesValue(this.dataValue);
952
+ this.setChoicesValue(value);
940
953
  if (this.isSelectResource && this.refs.addResource) {
941
954
  this.addEventListener(this.refs.addResource, 'click', (event) => {
942
955
  event.preventDefault();
@@ -1248,7 +1261,7 @@ export default class SelectComponent extends ListComponent {
1248
1261
  }
1249
1262
  _.set(submission.metadata.selectData, this.path, templateData);
1250
1263
  }
1251
- if (flags.resetValue && this.root?.submission && !this.options.readOnly) {
1264
+ if (flags.resetValue && !flags.fromSubmission && this.root?.submission && !this.options.readOnly) {
1252
1265
  const submission = this.root.submission;
1253
1266
  if (!submission.metadata) {
1254
1267
  submission.metadata = {};
@@ -1312,6 +1325,9 @@ export default class SelectComponent extends ListComponent {
1312
1325
  this.lazyLoadInit = true;
1313
1326
  const searchProperty = this.component.searchField || this.component.valueProperty;
1314
1327
  this.triggerUpdate(_.get(value.data || value, searchProperty, value), true);
1328
+ this.itemsLoaded.then(() => {
1329
+ this.setChoicesValue(value, hasPreviousValue, flags);
1330
+ });
1315
1331
  return changed;
1316
1332
  }
1317
1333
  // Add the value options.
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { eachComponent } from '../../../utils/utils';
2
+ import { eachComponent } from '../../../utils';
3
3
  const calculateSingleSelectData = (context, defaultValue) => {
4
4
  const { instance, data } = context;
5
5
  const rawDefaultValue = instance.downloadedResources.find(resource => _.get(resource, data.valueProperty) === defaultValue);
@@ -8,6 +8,12 @@ export default class SelectBoxesComponent extends RadioComponent {
8
8
  * @returns {boolean} - If the value is empty.
9
9
  */
10
10
  isEmpty(value?: any): boolean;
11
+ /**
12
+ * Normalize values coming into updateValue.
13
+ * @param {any} value - The value to normalize.
14
+ * @returns {*} - The normalized value
15
+ */
16
+ normalizeValue(value: any): any;
11
17
  setInputsDisabled(value: any, onlyUnchecked: any): void;
12
18
  checkComponentValidity(data: any, dirty: any, rowData: any, options: any, errors?: any[]): boolean;
13
19
  }
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { componentValueTypes, getComponentSavedTypes, boolValue, getComponent } from '../../utils/utils';
2
+ import { componentValueTypes, getComponentSavedTypes, boolValue, getComponent } from '../../utils';
3
3
  import RadioComponent from '../radio/Radio';
4
4
  export default class SelectBoxesComponent extends RadioComponent {
5
5
  static schema(...extend) {
@@ -152,6 +152,9 @@ export default class SelectBoxesComponent extends RadioComponent {
152
152
  }
153
153
  }
154
154
  }
155
+ else if (_.isEmpty(this.loadedOptions) && !checkedValues.length) {
156
+ value = {};
157
+ }
155
158
  return value;
156
159
  }
157
160
  /**
@@ -1,7 +1,7 @@
1
1
  import SignaturePad from 'signature_pad';
2
2
  import Input from '../_classes/input/Input';
3
3
  import _ from 'lodash';
4
- import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
4
+ import { componentValueTypes, getComponentSavedTypes } from '../../utils';
5
5
  export default class SignatureComponent extends Input {
6
6
  static schema(...extend) {
7
7
  return Input.schema({
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import Field from '../_classes/field/Field';
3
- import { boolValue, componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
3
+ import { boolValue, componentValueTypes, getComponentSavedTypes } from '../../utils';
4
4
  export default class SurveyComponent extends Field {
5
5
  static schema(...extend) {
6
6
  return Field.schema({
@@ -1,4 +1,4 @@
1
- import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
1
+ import { componentValueTypes, getComponentSavedTypes } from '../../utils';
2
2
  import Input from '../_classes/input/Input';
3
3
  import Choices from 'choices.js';
4
4
  export default class TagsComponent extends Input {
@@ -1,7 +1,7 @@
1
1
  /* global Quill */
2
2
  import TextFieldComponent from '../textfield/TextField';
3
3
  import _ from 'lodash';
4
- import { uniqueName, getBrowserInfo } from '../../utils/utils';
4
+ import { uniqueName, getBrowserInfo } from '../../utils';
5
5
  export default class TextAreaComponent extends TextFieldComponent {
6
6
  static schema(...extend) {
7
7
  return TextFieldComponent.schema({
@@ -58,8 +58,8 @@ export default class TextAreaComponent extends TextFieldComponent {
58
58
  if ((this.options.readOnly || this.disabled) && !this.isHtmlRenderMode()) {
59
59
  const elementStyle = this.info.attr.style || '';
60
60
  const children = `
61
- <div ${this._referenceAttributeName}="input"
62
- class="formio-editor-read-only-content"
61
+ <div ${this._referenceAttributeName}="input"
62
+ class="formio-editor-read-only-content"
63
63
  ${elementStyle ? `style='${elementStyle}'` : ''}
64
64
  role="textbox"
65
65
  aria-multiline="true"
@@ -1,7 +1,7 @@
1
1
  import Input from '../_classes/input/Input';
2
2
  import { conformToMask } from '@formio/vanilla-text-mask';
3
3
  import Inputmask from 'inputmask';
4
- import * as FormioUtils from '../../utils/utils';
4
+ import FormioUtils from '../../utils';
5
5
  import _ from 'lodash';
6
6
  export default class TextFieldComponent extends Input {
7
7
  static schema(...extend) {
@@ -86,8 +86,8 @@ export default class TextFieldComponent extends Input {
86
86
  locale: this.component.widget.locale || this.options.language,
87
87
  saveAs: 'text'
88
88
  };
89
- // update originalComponent to include widget settings after component initialization
90
- // originalComponent is used to restore the component (and widget) after evaluating field logic
89
+ // update originalComponent to include widget settings after component initialization
90
+ // originalComponent is used to restore the component (and widget) after evaluating field logic
91
91
  this.originalComponent = FormioUtils.fastCloneDeep(this.component);
92
92
  }
93
93
  }
@@ -1,6 +1,6 @@
1
1
  import moment from 'moment';
2
2
  import TextFieldComponent from '../textfield/TextField';
3
- import { getBrowserInfo } from '../../utils/utils';
3
+ import { getBrowserInfo } from '../../utils';
4
4
  const defaultDataFormat = 'HH:mm:ss';
5
5
  export default class TimeComponent extends TextFieldComponent {
6
6
  static schema(...extend) {
@@ -8,11 +8,11 @@ import Providers from './providers';
8
8
  import Widgets from './widgets';
9
9
  import Form from './Form';
10
10
  import Utils from './utils';
11
- import { Evaluator } from './utils/Evaluator';
12
11
  import Licenses from './licenses';
13
12
  import EventEmitter from './EventEmitter';
14
13
  import Webform from './Webform';
15
14
  import { I18n } from '@formio/core';
15
+ import { Evaluator, registerEvaluator } from './utils';
16
16
  Formio.loadModules = (path = `${Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
17
17
  Formio.requireLibrary(name, name, path, true)
18
18
  .then((modules) => {
@@ -83,7 +83,7 @@ export function registerModule(mod, defaultFn = null, options = {}) {
83
83
  Formio.Displays.addDisplays(mod.displays);
84
84
  break;
85
85
  case 'evaluator':
86
- Formio.Evaluator.registerEvaluator(mod.evaluator);
86
+ registerEvaluator(mod.evaluator);
87
87
  break;
88
88
  case 'translations':
89
89
  I18n.setDefaultTranslations(mod.translations);
@@ -1,4 +1,4 @@
1
- import { uniqueName } from '../../utils/utils';
1
+ import { uniqueName } from '../../utils';
2
2
  /**
3
3
  * UploadAdapter for CKEditor https://ckeditor.com/docs/ckeditor5/latest/framework/guides/deep-dive/upload-adapter.html
4
4
  */
@@ -24,7 +24,7 @@ class FormioUploadAdapter {
24
24
  null,
25
25
  null
26
26
  ];
27
- const uploadPromise = this.fileService.uploadFile(...uploadParams, () => this.component.emit('fileUploadingStart', uploadPromise)).then((result) => {
27
+ this.fileService.uploadFile(...uploadParams, () => this.component.emit('fileUploadingStart')).then((result) => {
28
28
  return this.fileService.downloadFile(result);
29
29
  }).then((result) => {
30
30
  return resolve({
@@ -34,7 +34,7 @@ class FormioUploadAdapter {
34
34
  console.warn('An Error occured while uploading file', err);
35
35
  reject(err);
36
36
  }).finally(() => {
37
- this.component.emit('fileUploadingEnd', uploadPromise);
37
+ this.component.emit('fileUploadingEnd');
38
38
  });
39
39
  }));
40
40
  }
@@ -3,6 +3,8 @@ import { coreEnTranslation } from '@formio/core';
3
3
  import _ from 'lodash';
4
4
  export default {
5
5
  ...(bootstrap?.translations?.en || {}),
6
+ // these keys contain a '-' to strip whitespace in core
7
+ // which is not handled correctly in the renderer, so we redefine them
6
8
  ..._.omit(coreEnTranslation, ['maxDate', 'minDate']),
7
9
  unsavedRowsError: 'Please save all rows before proceeding.',
8
10
  invalidRowsError: 'Please correct invalid rows before proceeding.',
@@ -37,6 +39,7 @@ export default {
37
39
  reCaptchaTokenValidationError: 'ReCAPTCHA: Token validation error',
38
40
  reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission',
39
41
  apiKey: 'API Key is not unique: {{key}}',
42
+ apiKeyNotValid: 'API Key is not valid: {{key}}',
40
43
  typeRemaining: '{{ remaining }} {{ type }} remaining.',
41
44
  typeCount: '{{ count }} {{ type }}',
42
45
  requiredDayEmpty: '{{ field }} is required',
@@ -1,7 +1,21 @@
1
- export class Evaluator {
2
- static cache: {};
3
- static protectedEval: boolean;
4
- static noeval: boolean;
5
- static template(template: any, hash: any): any;
6
- static interpolate(rawTemplate: any, data: any, _options: any): any;
1
+ /**
2
+ * For backwards compatibility we a standalone interpolate function. This merely calls the
3
+ * global mutable Evaluator instance's interpolate function.
4
+ * @param {...any} args - interpolate arguments, typically "rawTemplate", "data", and "options"
5
+ * @returns {any} the interpolation result.
6
+ */
7
+ export function interpolate(...args: any[]): any;
8
+ /**
9
+ * Set the evaluator to use for evaluating expressions.
10
+ * @param {CoreEvaluator} override - The new evaluator instance to use.
11
+ * @returns {void}
12
+ */
13
+ export function registerEvaluator(override: CoreEvaluator): void;
14
+ export class DefaultEvaluator extends CoreEvaluator {
15
+ cache: {};
16
+ protectedEval: boolean;
17
+ template(template: any, hash: any): any;
18
+ interpolate(rawTemplate: any, data: any, _options: any): any;
7
19
  }
20
+ export let Evaluator: DefaultEvaluator;
21
+ import { DefaultEvaluator as CoreEvaluator } from '@formio/core';
@@ -1,25 +1,24 @@
1
1
  import _ from 'lodash';
2
2
  import stringHash from 'string-hash';
3
- import { JSONLogicEvaluator as CoreEvaluator } from '@formio/core/utils';
4
- export class Evaluator extends CoreEvaluator {
5
- static cache = {};
6
- static protectedEval = false;
7
- static noeval = false;
8
- static template(template, hash) {
3
+ import { DefaultEvaluator as CoreEvaluator } from '@formio/core';
4
+ export class DefaultEvaluator extends CoreEvaluator {
5
+ cache = {};
6
+ protectedEval = false;
7
+ template(template, hash) {
9
8
  hash = hash || stringHash(template);
10
- if (Evaluator.cache[hash]) {
11
- return Evaluator.cache[hash];
9
+ if (this.cache[hash]) {
10
+ return this.cache[hash];
12
11
  }
13
12
  try {
14
13
  // Ensure we handle copied templates from the ejs files.
15
14
  template = template.replace(/ctx\./g, '');
16
- return (Evaluator.cache[hash] = _.template(template, Evaluator.templateSettings));
15
+ return (this.cache[hash] = _.template(template, this.templateSettings));
17
16
  }
18
17
  catch (err) {
19
18
  console.warn('Error while processing template', err, template);
20
19
  }
21
20
  }
22
- static interpolate(rawTemplate, data, _options) {
21
+ interpolate(rawTemplate, data, _options) {
23
22
  // Ensure reverse compatability.
24
23
  const options = _.isObject(_options) ? _options : { noeval: _options };
25
24
  if (typeof rawTemplate === 'function') {
@@ -33,11 +32,11 @@ export class Evaluator extends CoreEvaluator {
33
32
  }
34
33
  rawTemplate = String(rawTemplate);
35
34
  let template;
36
- if (Evaluator.noeval || options.noeval) {
37
- return CoreEvaluator.interpolateString(rawTemplate, data, _options);
35
+ if (this.noeval || options.noeval) {
36
+ return this.interpolateString(rawTemplate, data, _options);
38
37
  }
39
38
  else {
40
- template = Evaluator.template(rawTemplate);
39
+ template = this.template(rawTemplate);
41
40
  }
42
41
  if (typeof template === 'function') {
43
42
  try {
@@ -51,3 +50,22 @@ export class Evaluator extends CoreEvaluator {
51
50
  return template;
52
51
  }
53
52
  }
53
+ export let Evaluator = new DefaultEvaluator();
54
+ // preserve the standalone interpolate function for backwards compatibility
55
+ /**
56
+ * For backwards compatibility we a standalone interpolate function. This merely calls the
57
+ * global mutable Evaluator instance's interpolate function.
58
+ * @param {...any} args - interpolate arguments, typically "rawTemplate", "data", and "options"
59
+ * @returns {any} the interpolation result.
60
+ */
61
+ export function interpolate(...args) {
62
+ return Evaluator.interpolate(...args);
63
+ }
64
+ /**
65
+ * Set the evaluator to use for evaluating expressions.
66
+ * @param {CoreEvaluator} override - The new evaluator instance to use.
67
+ * @returns {void}
68
+ */
69
+ export function registerEvaluator(override) {
70
+ Evaluator = override;
71
+ }
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { eachComponent, uniqueKey } from './utils';
2
+ import { eachComponent, uniqueKey } from './index';
3
3
  export default {
4
4
  /**
5
5
  * Appends a number to a component.key to keep it unique
@@ -1,6 +1,6 @@
1
1
  import ConditionOperator from './ConditionOperator';
2
2
  import _ from 'lodash';
3
- import { compareSelectResourceWithObjectTypeValues, isSelectResourceWithObjectValue } from '../utils';
3
+ import { compareSelectResourceWithObjectTypeValues, isSelectResourceWithObjectValue } from '../';
4
4
  export default class IsEqualTo extends ConditionOperator {
5
5
  static get operatorKey() {
6
6
  return 'isEqual';
@@ -26,8 +26,8 @@ export const getBestMatch: typeof Utils.getBestMatch;
26
26
  export const getComponentFromPath: typeof Utils.getComponentFromPath;
27
27
  export const getComponentValue: typeof Utils.getComponentValue;
28
28
  export const findComponents: typeof Utils.findComponents;
29
- export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => Promise<void>;
30
- export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => void;
29
+ export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => Promise<void>;
30
+ export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => void;
31
31
  export const getComponentKey: typeof Utils.getComponentKey;
32
32
  export const getContextualRowPath: typeof Utils.getContextualRowPath;
33
33
  export const getContextualRowData: typeof Utils.getContextualRowData;