@formio/js 5.1.0-dev.6058.189ce78 → 5.1.0-dev.6059.845a6e3

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 (166) hide show
  1. package/Changelog.md +13 -131
  2. package/README.md +1 -28
  3. package/dist/formio.builder.css +17 -19
  4. package/dist/formio.builder.min.css +1 -1
  5. package/dist/formio.embed.js +1 -1
  6. package/dist/formio.embed.min.js +1 -1
  7. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  8. package/dist/formio.form.css +17 -19
  9. package/dist/formio.form.js +176 -102
  10. package/dist/formio.form.min.css +1 -1
  11. package/dist/formio.form.min.js +1 -1
  12. package/dist/formio.form.min.js.LICENSE.txt +3 -3
  13. package/dist/formio.full.css +17 -19
  14. package/dist/formio.full.js +86 -108
  15. package/dist/formio.full.min.css +2 -2
  16. package/dist/formio.full.min.js +1 -1
  17. package/dist/formio.full.min.js.LICENSE.txt +3 -3
  18. package/dist/formio.js +10 -10
  19. package/dist/formio.min.js +1 -1
  20. package/dist/formio.min.js.LICENSE.txt +1 -1
  21. package/dist/formio.utils.js +3 -3
  22. package/dist/formio.utils.min.js +1 -1
  23. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  24. package/lib/cjs/CDN.d.ts +1 -1
  25. package/lib/cjs/CDN.js +2 -2
  26. package/lib/cjs/Embed.js +1 -1
  27. package/lib/cjs/Form.d.ts +6 -4
  28. package/lib/cjs/Form.js +8 -16
  29. package/lib/cjs/Formio.js +1 -1
  30. package/lib/cjs/PDFBuilder.js +4 -4
  31. package/lib/cjs/Webform.d.ts +13 -16
  32. package/lib/cjs/Webform.js +148 -162
  33. package/lib/cjs/WebformBuilder.js +28 -17
  34. package/lib/cjs/Wizard.js +1 -1
  35. package/lib/cjs/WizardBuilder.js +2 -15
  36. package/lib/cjs/components/Components.d.ts +0 -3
  37. package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
  38. package/lib/cjs/components/_classes/component/Component.js +11 -38
  39. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  40. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
  41. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -32
  42. package/lib/cjs/components/_classes/component/editForm/utils.d.ts +0 -1
  43. package/lib/cjs/components/_classes/component/editForm/utils.js +0 -3
  44. package/lib/cjs/components/_classes/input/Input.js +1 -23
  45. package/lib/cjs/components/_classes/list/ListComponent.js +4 -4
  46. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
  47. package/lib/cjs/components/_classes/multivalue/Multivalue.js +3 -10
  48. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +0 -2
  49. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +31 -52
  50. package/lib/cjs/components/address/Address.js +1 -1
  51. package/lib/cjs/components/button/Button.js +6 -6
  52. package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
  53. package/lib/cjs/components/checkbox/Checkbox.js +2 -2
  54. package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -2
  55. package/lib/cjs/components/datagrid/DataGrid.js +26 -41
  56. package/lib/cjs/components/day/Day.js +7 -9
  57. package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -1
  58. package/lib/cjs/components/editgrid/EditGrid.js +8 -26
  59. package/lib/cjs/components/file/File.d.ts +1 -1
  60. package/lib/cjs/components/file/File.js +17 -23
  61. package/lib/cjs/components/form/Form.d.ts +1 -1
  62. package/lib/cjs/components/form/Form.js +5 -9
  63. package/lib/cjs/components/form/editForm/Form.edit.form.js +3 -3
  64. package/lib/cjs/components/hidden/Hidden.d.ts +1 -0
  65. package/lib/cjs/components/hidden/Hidden.js +1 -1
  66. package/lib/cjs/components/number/Number.js +5 -12
  67. package/lib/cjs/components/radio/Radio.js +0 -10
  68. package/lib/cjs/components/recaptcha/ReCaptcha.js +2 -2
  69. package/lib/cjs/components/select/Select.d.ts +1 -0
  70. package/lib/cjs/components/select/Select.js +33 -12
  71. package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +1 -1
  72. package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -3
  73. package/lib/cjs/components/selectboxes/SelectBoxes.js +2 -2
  74. package/lib/cjs/components/signature/Signature.d.ts +1 -1
  75. package/lib/cjs/components/signature/Signature.js +3 -5
  76. package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +6 -0
  77. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +1 -0
  78. package/lib/cjs/components/survey/Survey.js +2 -2
  79. package/lib/cjs/components/tags/Tags.d.ts +1 -1
  80. package/lib/cjs/components/tags/Tags.js +2 -2
  81. package/lib/cjs/components/textarea/TextArea.js +6 -6
  82. package/lib/cjs/formio.form.js +0 -5
  83. package/lib/cjs/providers/storage/googleDrive.js +2 -3
  84. package/lib/cjs/providers/storage/s3.js +3 -3
  85. package/lib/cjs/providers/storage/xhr.d.ts +0 -1
  86. package/lib/cjs/providers/storage/xhr.js +1 -6
  87. package/lib/cjs/translations/en.d.ts +81 -234
  88. package/lib/cjs/translations/en.js +81 -8
  89. package/lib/cjs/utils/ChoicesWrapper.d.ts +25 -4
  90. package/lib/cjs/utils/ChoicesWrapper.js +124 -47
  91. package/lib/cjs/utils/formUtils.d.ts +2 -2
  92. package/lib/cjs/utils/i18n.d.ts +2 -5
  93. package/lib/cjs/utils/i18n.js +5 -32
  94. package/lib/cjs/widgets/CalendarWidget.js +27 -27
  95. package/lib/mjs/CDN.d.ts +1 -1
  96. package/lib/mjs/CDN.js +2 -2
  97. package/lib/mjs/Embed.js +1 -1
  98. package/lib/mjs/Form.d.ts +6 -4
  99. package/lib/mjs/Form.js +9 -17
  100. package/lib/mjs/Formio.js +1 -1
  101. package/lib/mjs/PDFBuilder.js +4 -4
  102. package/lib/mjs/Webform.d.ts +13 -16
  103. package/lib/mjs/Webform.js +158 -171
  104. package/lib/mjs/WebformBuilder.js +28 -17
  105. package/lib/mjs/Wizard.js +1 -1
  106. package/lib/mjs/WizardBuilder.js +2 -15
  107. package/lib/mjs/components/Components.d.ts +0 -3
  108. package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
  109. package/lib/mjs/components/_classes/component/Component.js +11 -27
  110. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  111. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
  112. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -32
  113. package/lib/mjs/components/_classes/component/editForm/utils.d.ts +0 -1
  114. package/lib/mjs/components/_classes/component/editForm/utils.js +0 -3
  115. package/lib/mjs/components/_classes/input/Input.js +1 -22
  116. package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
  117. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
  118. package/lib/mjs/components/_classes/multivalue/Multivalue.js +3 -10
  119. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +0 -2
  120. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +31 -53
  121. package/lib/mjs/components/address/Address.js +1 -1
  122. package/lib/mjs/components/button/Button.js +6 -6
  123. package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
  124. package/lib/mjs/components/checkbox/Checkbox.js +2 -2
  125. package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -2
  126. package/lib/mjs/components/datagrid/DataGrid.js +26 -41
  127. package/lib/mjs/components/day/Day.js +7 -9
  128. package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -1
  129. package/lib/mjs/components/editgrid/EditGrid.js +7 -25
  130. package/lib/mjs/components/file/File.d.ts +1 -1
  131. package/lib/mjs/components/file/File.js +17 -23
  132. package/lib/mjs/components/form/Form.d.ts +1 -1
  133. package/lib/mjs/components/form/Form.js +5 -8
  134. package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -3
  135. package/lib/mjs/components/hidden/Hidden.d.ts +1 -0
  136. package/lib/mjs/components/hidden/Hidden.js +1 -1
  137. package/lib/mjs/components/number/Number.js +5 -12
  138. package/lib/mjs/components/radio/Radio.js +0 -10
  139. package/lib/mjs/components/recaptcha/ReCaptcha.js +2 -2
  140. package/lib/mjs/components/select/Select.d.ts +1 -0
  141. package/lib/mjs/components/select/Select.js +34 -14
  142. package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +1 -1
  143. package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -3
  144. package/lib/mjs/components/selectboxes/SelectBoxes.js +2 -2
  145. package/lib/mjs/components/signature/Signature.d.ts +1 -1
  146. package/lib/mjs/components/signature/Signature.js +3 -5
  147. package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +6 -0
  148. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +1 -0
  149. package/lib/mjs/components/survey/Survey.js +2 -2
  150. package/lib/mjs/components/tags/Tags.d.ts +1 -1
  151. package/lib/mjs/components/tags/Tags.js +2 -2
  152. package/lib/mjs/components/textarea/TextArea.js +6 -6
  153. package/lib/mjs/formio.form.js +0 -5
  154. package/lib/mjs/providers/storage/googleDrive.js +2 -3
  155. package/lib/mjs/providers/storage/s3.js +3 -3
  156. package/lib/mjs/providers/storage/xhr.d.ts +0 -1
  157. package/lib/mjs/providers/storage/xhr.js +1 -6
  158. package/lib/mjs/translations/en.d.ts +81 -234
  159. package/lib/mjs/translations/en.js +1 -87
  160. package/lib/mjs/utils/ChoicesWrapper.d.ts +25 -4
  161. package/lib/mjs/utils/ChoicesWrapper.js +119 -26
  162. package/lib/mjs/utils/formUtils.d.ts +2 -2
  163. package/lib/mjs/utils/i18n.d.ts +2 -5
  164. package/lib/mjs/utils/i18n.js +5 -32
  165. package/lib/mjs/widgets/CalendarWidget.js +27 -27
  166. package/package.json +11 -27
@@ -97,7 +97,7 @@ export default class FormComponent extends Component {
97
97
  return this.createSubForm();
98
98
  }
99
99
  get dataReady() {
100
- return this.subForm?.dataReady || this.subFormReady || Promise.resolve();
100
+ return this.subFormReady || Promise.resolve();
101
101
  }
102
102
  get defaultValue() {
103
103
  // Not not provide a default value unless the subform is ready so that it will initialize correctly.
@@ -211,7 +211,7 @@ export default class FormComponent extends Component {
211
211
  /* eslint-enable max-statements */
212
212
  render() {
213
213
  if (this.builderMode) {
214
- return super.render(this.t(this.component.label || 'nestedForm'));
214
+ return super.render(this.component.label || 'Nested form');
215
215
  }
216
216
  const subform = this.subForm ? this.subForm.render() : this.renderTemplate('loading');
217
217
  return super.render(subform);
@@ -224,13 +224,13 @@ export default class FormComponent extends Component {
224
224
  */
225
225
  getValueAsString(value, options) {
226
226
  if (!value) {
227
- return this.t('noDataProvided');
227
+ return 'No data provided';
228
228
  }
229
229
  if (!value.data && value._id) {
230
230
  return value._id;
231
231
  }
232
232
  if (!value.data || !Object.keys(value.data).length) {
233
- return this.t('noDataProvided');
233
+ return 'No data provided';
234
234
  }
235
235
  if (options?.email) {
236
236
  let result = (`
@@ -648,7 +648,7 @@ export default class FormComponent extends Component {
648
648
  : {};
649
649
  this.subForm.setUrl(submissionUrl, { ...this.options, ...options });
650
650
  this.subForm.loadSubmission().catch((err) => {
651
- console.error(this.t('subformSubmissionLoadingError', { submissionId: submission._id }), err);
651
+ console.error(`Unable to load subform submission ${submission._id}:`, err);
652
652
  });
653
653
  }
654
654
  else {
@@ -663,9 +663,6 @@ export default class FormComponent extends Component {
663
663
  */
664
664
  onSetSubFormValue(submission, flags) {
665
665
  this.subForm.setValue(submission, flags);
666
- if (flags?.fromSubmission) {
667
- this.subForm.submissionReadyResolve(submission);
668
- }
669
666
  }
670
667
  isEmpty(value = this.dataValue) {
671
668
  return value === null || _.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value?.data) && !value?._id);
@@ -44,7 +44,7 @@ export default [
44
44
  },
45
45
  searchField: 'title__regex',
46
46
  template: '<span>{{ item._vid }}</span>',
47
- valueProperty: 'revisionId',
47
+ valueProperty: '_id',
48
48
  authenticate: true,
49
49
  label: 'Form Revision',
50
50
  key: 'revision',
@@ -66,7 +66,7 @@ export default [
66
66
  input: true,
67
67
  weight: 20,
68
68
  key: 'reference',
69
- label: 'Submit as reference',
70
- tooltip: 'When "Submit as reference" is enabled, the form submission will be recorded against the Parent Form as well as the Child Form. When a submission recorded with "Submit as reference" is edited, the update is applied to each submission made against the Parent Form and Child Form.'
69
+ label: 'Save as reference',
70
+ tooltip: 'Using this option will save this field as a reference and link its value to the value of the origin record.'
71
71
  }
72
72
  ];
@@ -10,6 +10,7 @@ export default class HiddenComponent extends Input {
10
10
  };
11
11
  get inputInfo(): any;
12
12
  labelIsHidden(): boolean;
13
+ get emptyValue(): string;
13
14
  setValue(value: any, flags?: {}): boolean;
14
15
  }
15
16
  import Input from '../_classes/input/Input';
@@ -43,7 +43,7 @@ export default class HiddenComponent extends Input {
43
43
  return true;
44
44
  }
45
45
  get emptyValue() {
46
- return null;
46
+ return '';
47
47
  }
48
48
  setValue(value, flags = {}) {
49
49
  return this.updateValue(value, flags);
@@ -54,7 +54,7 @@ export default class NumberComponent extends Input {
54
54
  }
55
55
  else {
56
56
  if (this.component.thousandsSeparator || this.options.properties?.thousandsSeparator || this.options.thousandsSeparator) {
57
- console.warn(this.t('noDelimiterSet'));
57
+ console.warn('In order for thousands separator to work properly, you must set the delimiter to true in the component json');
58
58
  }
59
59
  this.delimiter = '';
60
60
  }
@@ -168,21 +168,14 @@ export default class NumberComponent extends Input {
168
168
  if (typeof input === 'string') {
169
169
  input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
170
170
  }
171
- let value;
172
- if (!_.isNaN(input)) {
171
+ let value = parseFloat(input);
172
+ if (!_.isNaN(value)) {
173
173
  // Format scientific notation
174
- if (/[0-9]+[eE]/.test(String(input))) {
175
- // Convert to exponential notation will depend on the decimal limit set in the component
176
- // Example: 1.23e-5 will be converted to 1.23e-5 if decimal limit is set to 2
177
- // Example: 1.23e5 will be converted to 1.23e+5 if decimal limit is set to 2
178
- // if decimal limit is 3, 1.23e5 will be converted to 1.230e+5
179
- // if decimal limit is not set, 1.23e5 will be converted to 1.23000000000000000000e+5
180
- value = parseFloat(input);
174
+ if (/e/i.test(String(value))) {
181
175
  value = value.toExponential(this.decimalLimit);
182
176
  }
183
177
  else {
184
- value = parseFloat(input);
185
- value = !_.isNaN(value) ? String(value).replace('.', this.decimalSeparator) : null;
178
+ value = String(value).replace('.', this.decimalSeparator);
186
179
  }
187
180
  }
188
181
  else {
@@ -293,16 +293,6 @@ export default class RadioComponent extends ListComponent {
293
293
  if (method.toUpperCase() === 'GET') {
294
294
  body = null;
295
295
  }
296
- const limit = this.component.limit || 100;
297
- const skip = this.isScrollLoading ? this.selectOptions.length : 0;
298
- // Allow for url interpolation.
299
- url = this.sanitize(this.interpolate(url, {
300
- formioBase: Formio.getBaseUrl(),
301
- search,
302
- limit,
303
- skip,
304
- page: Math.abs(Math.floor(skip / limit))
305
- }), this.shouldSanitizeValue);
306
296
  // Set ignoreCache if it is
307
297
  options.ignoreCache = this.component.ignoreCache;
308
298
  // Make the request.
@@ -47,7 +47,7 @@ export default class ReCaptchaComponent extends Component {
47
47
  this.recaptchaApiReady = Formio.requireLibrary('googleRecaptcha', 'grecaptcha', recaptchaApiScriptUrl, true);
48
48
  }
49
49
  else {
50
- console.warn(this.t('noSiteKey'));
50
+ console.warn('There is no Site Key specified in settings in form JSON');
51
51
  }
52
52
  }
53
53
  }
@@ -60,7 +60,7 @@ export default class ReCaptchaComponent extends Component {
60
60
  async verify(actionName) {
61
61
  const siteKey = _get(this.root.form, 'settings.recaptcha.siteKey');
62
62
  if (!siteKey) {
63
- console.warn(this.t('noSiteKey'));
63
+ console.warn('There is no Site Key specified in settings in form JSON');
64
64
  return;
65
65
  }
66
66
  if (!this.recaptchaApiReady) {
@@ -126,6 +126,7 @@ export default class SelectComponent extends ListComponent {
126
126
  get isLoadingAvailable(): any;
127
127
  onScroll(): void;
128
128
  attachRefreshOnBlur(): void;
129
+ addPlaceholderItem(placeholderValue: any): void;
129
130
  update(): void;
130
131
  addCurrentChoices(values: any, items: any, keyValue: any): any;
131
132
  getValueAsString(data: any, options: any): any;
@@ -1,6 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import { Formio } from '../../Formio';
3
3
  import ListComponent from '../_classes/list/ListComponent';
4
+ import Input from '../_classes/input/Input';
4
5
  import Form from '../../Form';
5
6
  import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes, isSelectResourceWithObjectValue, removeHTML } from '../../utils/utils';
6
7
  import Choices from '../../utils/ChoicesWrapper';
@@ -531,13 +532,13 @@ export default class SelectComponent extends ListComponent {
531
532
  skip,
532
533
  };
533
534
  // Allow for url interpolation.
534
- url = this.sanitize(this.interpolate(url, {
535
+ url = this.interpolate(url, {
535
536
  formioBase: Formio.getBaseUrl(),
536
537
  search,
537
538
  limit,
538
539
  skip,
539
540
  page: Math.abs(Math.floor(skip / limit))
540
- }), this.shouldSanitizeValue);
541
+ });
541
542
  // Add search capability.
542
543
  if (this.component.searchField && search) {
543
544
  const searchValue = Array.isArray(search)
@@ -594,7 +595,7 @@ export default class SelectComponent extends ListComponent {
594
595
  component: this.component,
595
596
  message: err.toString(),
596
597
  });
597
- console.warn(this.t('loadResourcesError', { componentKey: this.key }));
598
+ console.warn(`Unable to load resources for ${this.key}`);
598
599
  }
599
600
  /**
600
601
  * Get the request headers for this select dropdown.
@@ -728,7 +729,7 @@ export default class SelectComponent extends ListComponent {
728
729
  }
729
730
  }
730
731
  else if (this.component.dataSrc === 'url' || this.component.dataSrc === 'resource') {
731
- this.addOption('', `${this.t('loading')}...`);
732
+ this.addOption('', this.t('loading...'));
732
733
  }
733
734
  }
734
735
  get active() {
@@ -772,16 +773,16 @@ export default class SelectComponent extends ListComponent {
772
773
  removeItemButton: this.component.disabled ? false : _.get(this.component, 'removeItemButton', true),
773
774
  itemSelectText: '',
774
775
  classNames: {
775
- containerOuter: ['choices', 'form-group', 'formio-choices'],
776
- containerInner: this.transform('class', 'form-control ui fluid selection dropdown').split(' '),
776
+ containerOuter: 'choices form-group formio-choices',
777
+ containerInner: this.transform('class', 'form-control ui fluid selection dropdown')
777
778
  },
778
779
  addItemText: false,
779
780
  allowHTML: true,
780
781
  placeholder: !!this.component.placeholder,
781
782
  placeholderValue: placeholderValue,
782
- noResultsText: this.t('noResultsFound'),
783
- noChoicesText: this.t('noChoices'),
784
- searchPlaceholderValue: this.t('typeToSearch'),
783
+ noResultsText: this.t('No results found'),
784
+ noChoicesText: this.t('No choices to choose from'),
785
+ searchPlaceholderValue: this.t('Type to search'),
785
786
  shouldSort: false,
786
787
  position: (this.component.dropdown || 'auto'),
787
788
  searchEnabled: useSearch,
@@ -801,7 +802,6 @@ export default class SelectComponent extends ListComponent {
801
802
  }),
802
803
  valueComparer: _.isEqual,
803
804
  resetScrollPosition: false,
804
- duplicateItemsAllowed: false,
805
805
  ...customOptions,
806
806
  };
807
807
  }
@@ -868,7 +868,7 @@ export default class SelectComponent extends ListComponent {
868
868
  this.choices.containerOuter.element.setAttribute('tabIndex', '-1');
869
869
  this.addEventListener(this.choices.containerOuter.element, 'focus', () => this.focusableElement.focus());
870
870
  }
871
- this.addFocusBlurEvents(this.choices.input.element);
871
+ Input.prototype.addFocusBlurEvents.call(this, this.focusableElement);
872
872
  if (this.itemsFromUrl && !this.component.noRefreshOnScroll) {
873
873
  this.scrollList = this.choices.choiceList.element;
874
874
  this.addEventListener(this.scrollList, 'scroll', () => this.onScroll());
@@ -934,6 +934,12 @@ export default class SelectComponent extends ListComponent {
934
934
  this.positionDropdown();
935
935
  });
936
936
  }
937
+ if (this.choices && choicesOptions.placeholderValue && this.choices._isSelectOneElement) {
938
+ this.addPlaceholderItem(choicesOptions.placeholderValue);
939
+ this.addEventListener(input, 'removeItem', () => {
940
+ this.addPlaceholderItem(choicesOptions.placeholderValue);
941
+ });
942
+ }
937
943
  // Add value options.
938
944
  this.addValueOptions();
939
945
  this.setChoicesValue(this.dataValue);
@@ -1019,6 +1025,20 @@ export default class SelectComponent extends ListComponent {
1019
1025
  });
1020
1026
  }
1021
1027
  }
1028
+ addPlaceholderItem(placeholderValue) {
1029
+ const items = this.choices._store.activeItems;
1030
+ if (!items.length) {
1031
+ this.choices._addItem({
1032
+ value: '',
1033
+ label: placeholderValue,
1034
+ choiceId: 0,
1035
+ groupId: -1,
1036
+ customProperties: null,
1037
+ placeholder: true,
1038
+ keyCode: null
1039
+ });
1040
+ }
1041
+ }
1022
1042
  /* eslint-enable max-statements */
1023
1043
  update() {
1024
1044
  if (this.component.dataSrc === 'custom') {
@@ -1199,7 +1219,7 @@ export default class SelectComponent extends ListComponent {
1199
1219
  return normalize[dataType]().value;
1200
1220
  }
1201
1221
  catch (err) {
1202
- console.warn(this.t('failedToNormalize'), err);
1222
+ console.warn('Failed to normalize value', err);
1203
1223
  return value;
1204
1224
  }
1205
1225
  }
@@ -1395,7 +1415,7 @@ export default class SelectComponent extends ListComponent {
1395
1415
  return (JSON.stringify(normalizedOptionValue) === JSON.stringify(value));
1396
1416
  }
1397
1417
  catch (err) {
1398
- console.warn.error(this.t('failedToCompareItems'), err);
1418
+ console.warn.error('Error while comparing items', err);
1399
1419
  return false;
1400
1420
  }
1401
1421
  };
@@ -1487,7 +1507,7 @@ export default class SelectComponent extends ListComponent {
1487
1507
  }
1488
1508
  asString(value, options = {}) {
1489
1509
  value = value ?? this.getValue();
1490
- if (options.modalPreview || this.inDataTable || options.email) {
1510
+ if (options.modalPreview || this.inDataTable) {
1491
1511
  if (this.inDataTable) {
1492
1512
  value = this.undoValueTyping(value);
1493
1513
  }
@@ -1099,7 +1099,6 @@ declare const _default: ({
1099
1099
  alwaysEnabled?: undefined;
1100
1100
  } | {
1101
1101
  key: string;
1102
- type: string;
1103
1102
  conditional: {
1104
1103
  json: {
1105
1104
  and: ({
@@ -1150,6 +1149,7 @@ declare const _default: ({
1150
1149
  };
1151
1150
  };
1152
1151
  data?: undefined;
1152
+ type?: undefined;
1153
1153
  weight?: undefined;
1154
1154
  input?: undefined;
1155
1155
  label?: undefined;
@@ -635,8 +635,8 @@ export default [
635
635
  input: true,
636
636
  weight: 25,
637
637
  key: 'reference',
638
- label: 'Submit as reference',
639
- tooltip: 'Using this option will submit this field as a reference id and link its value to the value of the origin record.',
638
+ label: 'Save as reference',
639
+ tooltip: 'Using this option will save this field as a reference and link its value to the value of the origin record.',
640
640
  conditional: {
641
641
  json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },
642
642
  },
@@ -681,7 +681,6 @@ export default [
681
681
  },
682
682
  {
683
683
  key: 'selectData',
684
- type: 'hidden',
685
684
  conditional: {
686
685
  json: {
687
686
  and: [
@@ -253,14 +253,14 @@ export default class SelectBoxesComponent extends RadioComponent {
253
253
  this.setInputsDisabled(false);
254
254
  }
255
255
  if (!isValid && maxCount && count > maxCount) {
256
- const message = this.t(this.component.maxSelectedCountMessage || 'maxSelectItems', { maxCount });
256
+ const message = this.t(this.component.maxSelectedCountMessage || 'You may only select up to {{maxCount}} items', { maxCount });
257
257
  this.errors.push({ message });
258
258
  this.setCustomValidity(message, dirty);
259
259
  return false;
260
260
  }
261
261
  else if (!isValid && minCount && count < minCount) {
262
262
  this.setInputsDisabled(false);
263
- const message = this.t(this.component.minSelectedCountMessage || 'minSelectItems', { minCount });
263
+ const message = this.t(this.component.minSelectedCountMessage || 'You must select at least {{minCount}} items', { minCount });
264
264
  this.errors.push({ message });
265
265
  this.setCustomValidity(message, dirty);
266
266
  return false;
@@ -24,7 +24,7 @@ export default class SignatureComponent extends Input {
24
24
  checkSize(force: any, scale: any): void;
25
25
  signaturePad: SignaturePad | null | undefined;
26
26
  observer: any;
27
- getValueAsString(value: any): string;
27
+ getValueAsString(value: any): "" | "Yes" | "No";
28
28
  focus(): void;
29
29
  setDataToSigaturePad(): void;
30
30
  }
@@ -156,9 +156,7 @@ export default class SignatureComponent extends Input {
156
156
  if (this.dataValue) {
157
157
  this.setDataToSigaturePad();
158
158
  }
159
- if (!this.disabled) {
160
- this.showCanvas(true);
161
- }
159
+ this.showCanvas(true);
162
160
  }
163
161
  }
164
162
  renderElement(value, index) {
@@ -174,7 +172,7 @@ export default class SignatureComponent extends Input {
174
172
  return this.renderModalPreview({
175
173
  previewText: this.dataValue ?
176
174
  `<img src=${this.dataValue} ${this._referenceAttributeName}='openModal' style="width: 100%;height: 100%;" />` :
177
- this.t('clickToSign')
175
+ this.t('Click to Sign')
178
176
  });
179
177
  }
180
178
  attach(element) {
@@ -242,7 +240,7 @@ export default class SignatureComponent extends Input {
242
240
  if (_.isUndefined(value) && this.inDataTable) {
243
241
  return '';
244
242
  }
245
- return this.t(value ? 'yes' : 'no');
243
+ return value ? 'Yes' : 'No';
246
244
  }
247
245
  focus() {
248
246
  this.refs.padBody.focus();
@@ -7,6 +7,7 @@ declare const _default: ({
7
7
  placeholder: string;
8
8
  weight: number;
9
9
  conditional?: undefined;
10
+ customConditional?: undefined;
10
11
  ignore?: undefined;
11
12
  } | {
12
13
  type: string;
@@ -23,6 +24,7 @@ declare const _default: ({
23
24
  };
24
25
  };
25
26
  weight: number;
27
+ customConditional?: undefined;
26
28
  ignore?: undefined;
27
29
  } | {
28
30
  weight: number;
@@ -30,6 +32,9 @@ declare const _default: ({
30
32
  label: string;
31
33
  tooltip: string;
32
34
  key: string;
35
+ customConditional: ({ options }: {
36
+ options: any;
37
+ }) => boolean;
33
38
  input: boolean;
34
39
  placeholder?: undefined;
35
40
  conditional?: undefined;
@@ -44,5 +49,6 @@ declare const _default: ({
44
49
  placeholder?: undefined;
45
50
  weight?: undefined;
46
51
  conditional?: undefined;
52
+ customConditional?: undefined;
47
53
  })[];
48
54
  export default _default;
@@ -37,6 +37,7 @@ export default [
37
37
  label: 'Keep Overlay Aspect Ratio',
38
38
  tooltip: 'If checked, the field will have the same aspect ratio as its preview.',
39
39
  key: 'keepOverlayRatio',
40
+ customConditional: ({ options }) => (options?.editForm?.display === 'pdf'),
40
41
  input: true
41
42
  },
42
43
  {
@@ -126,8 +126,8 @@ export default class SurveyComponent extends Field {
126
126
  <table border="1" style="width:100%">
127
127
  <thead>
128
128
  <tr>
129
- <th>${this.t('surveyQuestion')}</th>
130
- <th>${this.t('surveyQuestionValue')}</th>
129
+ <th>Question</th>
130
+ <th>Value</th>
131
131
  </tr>
132
132
  </thead>
133
133
  <tbody>
@@ -24,4 +24,4 @@ export default class TagsComponent extends Input {
24
24
  getValueAsString(value: any): any;
25
25
  }
26
26
  import Input from '../_classes/input/Input';
27
- import Choices from 'choices.js';
27
+ import Choices from '@formio/choices.js';
@@ -1,6 +1,6 @@
1
1
  import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
2
2
  import Input from '../_classes/input/Input';
3
- import Choices from 'choices.js';
3
+ import Choices from '@formio/choices.js';
4
4
  export default class TagsComponent extends Input {
5
5
  static schema(...extend) {
6
6
  return Input.schema({
@@ -127,7 +127,7 @@ export default class TagsComponent extends Input {
127
127
  const changed = super.setValue(value, flags);
128
128
  if (this.choices) {
129
129
  let dataValue = this.dataValue;
130
- this.choices.clearStore();
130
+ this.choices.removeActiveItems();
131
131
  if (dataValue) {
132
132
  if (typeof dataValue === 'string') {
133
133
  dataValue = dataValue.split(this.delimiter).filter(result => result);
@@ -131,7 +131,7 @@ export default class TextAreaComponent extends TextFieldComponent {
131
131
  case 'quill':
132
132
  // Normalize the configurations for quill.
133
133
  if (settings.hasOwnProperty('toolbarGroups') || settings.hasOwnProperty('toolbar')) {
134
- console.warn(this.t('needConfigurationForQuill'));
134
+ console.warn('The WYSIWYG settings are configured for CKEditor. For this renderer, you will need to use configurations for the Quill Editor. See https://quilljs.com/docs/configuration for more information.');
135
135
  settings = this.wysiwygDefault.quill;
136
136
  }
137
137
  // Add the quill editor.
@@ -203,7 +203,7 @@ export default class TextAreaComponent extends TextFieldComponent {
203
203
  imageHandler(moduleInstance, range, files) {
204
204
  const quillInstance = moduleInstance.quill;
205
205
  if (!files || !files.length) {
206
- console.warn(this.t('noFilesSelected'));
206
+ console.warn('No files selected');
207
207
  return;
208
208
  }
209
209
  quillInstance.enable(false);
@@ -228,7 +228,7 @@ export default class TextAreaComponent extends TextFieldComponent {
228
228
  alt: JSON.stringify(requestData),
229
229
  }), Quill.sources.USER);
230
230
  }).catch(error => {
231
- console.warn(this.t('quillImageUploadFailed'));
231
+ console.warn('Quill image upload failed');
232
232
  console.warn(error);
233
233
  quillInstance.enable(true);
234
234
  });
@@ -523,7 +523,7 @@ export default class TextAreaComponent extends TextFieldComponent {
523
523
  }
524
524
  this.element.scrollIntoView();
525
525
  }).catch((err) => {
526
- console.warn(this.t('editorFocusError'), err);
526
+ console.warn('An editor did not initialize properly when trying to focus:', err);
527
527
  });
528
528
  break;
529
529
  }
@@ -532,7 +532,7 @@ export default class TextAreaComponent extends TextFieldComponent {
532
532
  this.editors[0].focus();
533
533
  this.element.scrollIntoView();
534
534
  }).catch((err) => {
535
- console.warn(this.t('editorFocusError'), err);
535
+ console.warn('An editor did not initialize properly when trying to focus:', err);
536
536
  });
537
537
  break;
538
538
  }
@@ -540,7 +540,7 @@ export default class TextAreaComponent extends TextFieldComponent {
540
540
  this.editorsReady[0]?.then(() => {
541
541
  this.editors[0].focus();
542
542
  }).catch((err) => {
543
- console.warn(this.t('editorFocusError'), err);
543
+ console.warn('An editor did not initialize properly when trying to focus:', err);
544
544
  });
545
545
  break;
546
546
  }
@@ -12,7 +12,6 @@ import { Evaluator } from './utils/Evaluator';
12
12
  import Licenses from './licenses';
13
13
  import EventEmitter from './EventEmitter';
14
14
  import Webform from './Webform';
15
- import { I18n } from './utils/i18n';
16
15
  Formio.loadModules = (path = `${Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
17
16
  Formio.requireLibrary(name, name, path, true)
18
17
  .then((modules) => {
@@ -57,7 +56,6 @@ export function registerModule(mod, defaultFn = null, options = {}) {
57
56
  case 'templates':
58
57
  for (const framework of Object.keys(mod.templates)) {
59
58
  Formio.Templates.extendTemplate(framework, mod.templates[framework]);
60
- Formio.Templates.defaultTemplates = _.defaults(mod.templates[framework], Formio.Templates.defaultTemplates);
61
59
  }
62
60
  if (mod.templates[current]) {
63
61
  Formio.Templates.current = mod.templates[current];
@@ -85,9 +83,6 @@ export function registerModule(mod, defaultFn = null, options = {}) {
85
83
  case 'evaluator':
86
84
  Formio.Evaluator.registerEvaluator(mod.evaluator);
87
85
  break;
88
- case 'translations':
89
- I18n.setDefaultTranslations(mod.translations);
90
- break;
91
86
  case 'library':
92
87
  options.license
93
88
  ? Formio.Licenses.addLicense(mod.library, options.license)
@@ -50,11 +50,10 @@ function googledrive(formio) {
50
50
  xhr.send(fd);
51
51
  }));
52
52
  },
53
- downloadFile(file, component) {
53
+ downloadFile(file) {
54
54
  const token = formio.getToken();
55
- // Constructed the url with the fileId, fileName, displayImage, imageSize if applicable
56
55
  file.url =
57
- `${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}${component.image ? '&displayImage=true' : ''}${component.imageSize ? `&imageSize=${component.imageSize}` : ''}`;
56
+ `${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}`;
58
57
  return Promise.resolve(file);
59
58
  },
60
59
  deleteFile: function deleteFile(fileInfo) {
@@ -75,7 +75,7 @@ function s3(formio) {
75
75
  const { changeMessage } = multipart;
76
76
  changeMessage('Completing AWS S3 multipart upload...');
77
77
  const token = formio.getToken();
78
- const response = await XHR.fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
78
+ const response = await fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
79
79
  method: 'POST',
80
80
  headers: {
81
81
  'Content-Type': 'application/json',
@@ -96,7 +96,7 @@ function s3(formio) {
96
96
  abortMultipartUpload(serverResponse) {
97
97
  const { uploadId, key } = serverResponse;
98
98
  const token = formio.getToken();
99
- XHR.fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
99
+ fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
100
100
  method: 'POST',
101
101
  headers: {
102
102
  'Content-Type': 'application/json',
@@ -113,7 +113,7 @@ function s3(formio) {
113
113
  const start = i * partSize;
114
114
  const end = (i + 1) * partSize;
115
115
  const blob = i < urls.length ? file.slice(start, end) : file.slice(start);
116
- const promise = XHR.fetch(urls[i], {
116
+ const promise = fetch(urls[i], {
117
117
  method: 'PUT',
118
118
  headers,
119
119
  body: blob,
@@ -3,7 +3,6 @@ export default XHR;
3
3
  declare namespace XHR {
4
4
  function trim(text: any): any;
5
5
  function path(items: any): any;
6
- function fetch(url: any, options: any): Promise<Response>;
7
6
  function upload(formio: any, type: any, xhrCallback: any, file: any, fileName: any, dir: any, progressCallback: any, groupPermissions: any, groupId: any, abortCallback: any, multipartOptions: any): Promise<any>;
8
7
  function makeXhrRequest(formio: any, xhrCallback: any, serverResponse: any, progressCallback: any, abortCallback: any): Promise<any>;
9
8
  }
@@ -1,5 +1,4 @@
1
1
  import _trim from 'lodash/trim';
2
- import { Formio } from '../../Formio';
3
2
  export const setXhrHeaders = (formio, xhr) => {
4
3
  const { headers } = formio.options;
5
4
  if (headers) {
@@ -21,16 +20,12 @@ const XHR = {
21
20
  path(items) {
22
21
  return items.filter(item => !!item).map(XHR.trim).join('/');
23
22
  },
24
- fetch(url, options) {
25
- options = Formio.pluginAlter('requestOptions', options, url);
26
- return fetch(url, options);
27
- },
28
23
  async upload(formio, type, xhrCallback, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback, multipartOptions) {
29
24
  // make request to Form.io server
30
25
  const token = formio.getToken();
31
26
  let response;
32
27
  try {
33
- response = await XHR.fetch(`${formio.formUrl}/storage/${type}`, {
28
+ response = await fetch(`${formio.formUrl}/storage/${type}`, {
34
29
  method: 'POST',
35
30
  headers: {
36
31
  'Accept': 'application/json',