@formio/js 5.1.0-dev.6101.0682abe → 5.1.0-dev.6102.9a0147c

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 (139) hide show
  1. package/README.md +5 -0
  2. package/dist/formio.form.js +125 -125
  3. package/dist/formio.form.min.js +1 -1
  4. package/dist/formio.form.min.js.LICENSE.txt +2 -0
  5. package/dist/formio.full.js +131 -131
  6. package/dist/formio.full.min.js +1 -1
  7. package/dist/formio.full.min.js.LICENSE.txt +2 -0
  8. package/dist/formio.js +73 -62
  9. package/dist/formio.min.js +1 -1
  10. package/dist/formio.utils.js +85 -74
  11. package/dist/formio.utils.min.js +1 -1
  12. package/dist/formio.utils.min.js.LICENSE.txt +2 -0
  13. package/lib/cjs/Element.js +13 -36
  14. package/lib/cjs/EventEmitter.js +2 -25
  15. package/lib/cjs/Form.js +2 -25
  16. package/lib/cjs/PDF.js +1 -1
  17. package/lib/cjs/PDFBuilder.js +4 -5
  18. package/lib/cjs/Webform.js +3 -4
  19. package/lib/cjs/WebformBuilder.d.ts +1 -0
  20. package/lib/cjs/WebformBuilder.js +22 -9
  21. package/lib/cjs/Wizard.d.ts +1 -2
  22. package/lib/cjs/Wizard.js +18 -24
  23. package/lib/cjs/WizardBuilder.js +1 -1
  24. package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
  25. package/lib/cjs/components/_classes/component/Component.js +29 -53
  26. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  27. package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  28. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
  29. package/lib/cjs/components/_classes/input/Input.js +1 -1
  30. package/lib/cjs/components/_classes/list/ListComponent.js +1 -1
  31. package/lib/cjs/components/_classes/nested/NestedComponent.js +7 -7
  32. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  33. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  34. package/lib/cjs/components/address/Address.js +1 -1
  35. package/lib/cjs/components/alert/Alert.js +1 -1
  36. package/lib/cjs/components/button/Button.d.ts +2 -2
  37. package/lib/cjs/components/button/Button.js +10 -14
  38. package/lib/cjs/components/checkbox/Checkbox.js +1 -1
  39. package/lib/cjs/components/container/Container.js +1 -1
  40. package/lib/cjs/components/currency/Currency.js +1 -1
  41. package/lib/cjs/components/datagrid/DataGrid.js +5 -1
  42. package/lib/cjs/components/datamap/DataMap.d.ts +1 -1
  43. package/lib/cjs/components/datamap/DataMap.js +4 -4
  44. package/lib/cjs/components/datetime/DateTime.js +1 -1
  45. package/lib/cjs/components/day/Day.js +1 -1
  46. package/lib/cjs/components/editgrid/EditGrid.js +1 -1
  47. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  48. package/lib/cjs/components/file/File.js +5 -6
  49. package/lib/cjs/components/form/Form.js +1 -1
  50. package/lib/cjs/components/number/Number.js +1 -1
  51. package/lib/cjs/components/panel/Panel.js +1 -1
  52. package/lib/cjs/components/radio/Radio.js +1 -1
  53. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  54. package/lib/cjs/components/select/Select.js +1 -1
  55. package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -1
  56. package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
  57. package/lib/cjs/components/signature/Signature.js +1 -1
  58. package/lib/cjs/components/survey/Survey.js +1 -1
  59. package/lib/cjs/components/tags/Tags.js +1 -1
  60. package/lib/cjs/components/textarea/TextArea.js +3 -3
  61. package/lib/cjs/components/textfield/TextField.js +7 -30
  62. package/lib/cjs/components/time/Time.js +1 -1
  63. package/lib/cjs/formio.form.js +3 -3
  64. package/lib/cjs/i18n.js +1 -1
  65. package/lib/cjs/providers/storage/uploadAdapter.js +3 -3
  66. package/lib/cjs/utils/Evaluator.d.ts +13 -6
  67. package/lib/cjs/utils/Evaluator.js +27 -15
  68. package/lib/cjs/utils/builder.js +5 -5
  69. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
  70. package/lib/cjs/utils/i18n.js +3 -3
  71. package/lib/cjs/utils/index.d.ts +160 -2
  72. package/lib/cjs/utils/index.js +12 -2
  73. package/lib/cjs/utils/utils.d.ts +0 -5
  74. package/lib/cjs/utils/utils.js +4 -42
  75. package/lib/cjs/widgets/CalendarWidget.js +1 -1
  76. package/lib/mjs/Element.js +6 -6
  77. package/lib/mjs/EventEmitter.js +2 -2
  78. package/lib/mjs/Form.js +1 -1
  79. package/lib/mjs/PDF.js +1 -1
  80. package/lib/mjs/PDFBuilder.js +1 -2
  81. package/lib/mjs/Webform.js +1 -2
  82. package/lib/mjs/WebformBuilder.d.ts +1 -0
  83. package/lib/mjs/WebformBuilder.js +14 -2
  84. package/lib/mjs/Wizard.d.ts +1 -2
  85. package/lib/mjs/Wizard.js +17 -23
  86. package/lib/mjs/WizardBuilder.js +1 -1
  87. package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
  88. package/lib/mjs/components/_classes/component/Component.js +2 -3
  89. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  90. package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  91. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
  92. package/lib/mjs/components/_classes/input/Input.js +1 -1
  93. package/lib/mjs/components/_classes/list/ListComponent.js +1 -1
  94. package/lib/mjs/components/_classes/nested/NestedComponent.js +7 -7
  95. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  96. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
  97. package/lib/mjs/components/address/Address.js +1 -1
  98. package/lib/mjs/components/alert/Alert.js +1 -1
  99. package/lib/mjs/components/button/Button.d.ts +2 -2
  100. package/lib/mjs/components/button/Button.js +7 -10
  101. package/lib/mjs/components/checkbox/Checkbox.js +1 -1
  102. package/lib/mjs/components/container/Container.js +1 -1
  103. package/lib/mjs/components/currency/Currency.js +1 -1
  104. package/lib/mjs/components/datagrid/DataGrid.js +5 -1
  105. package/lib/mjs/components/datamap/DataMap.d.ts +1 -1
  106. package/lib/mjs/components/datamap/DataMap.js +1 -1
  107. package/lib/mjs/components/datetime/DateTime.js +1 -1
  108. package/lib/mjs/components/day/Day.js +1 -1
  109. package/lib/mjs/components/editgrid/EditGrid.js +1 -1
  110. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  111. package/lib/mjs/components/file/File.js +5 -6
  112. package/lib/mjs/components/form/Form.js +1 -1
  113. package/lib/mjs/components/number/Number.js +1 -1
  114. package/lib/mjs/components/panel/Panel.js +1 -1
  115. package/lib/mjs/components/radio/Radio.js +1 -1
  116. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  117. package/lib/mjs/components/select/Select.js +1 -1
  118. package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -1
  119. package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
  120. package/lib/mjs/components/signature/Signature.js +1 -1
  121. package/lib/mjs/components/survey/Survey.js +1 -1
  122. package/lib/mjs/components/tags/Tags.js +1 -1
  123. package/lib/mjs/components/textarea/TextArea.js +3 -3
  124. package/lib/mjs/components/textfield/TextField.js +1 -1
  125. package/lib/mjs/components/time/Time.js +1 -1
  126. package/lib/mjs/formio.form.js +2 -2
  127. package/lib/mjs/i18n.js +1 -1
  128. package/lib/mjs/providers/storage/uploadAdapter.js +3 -3
  129. package/lib/mjs/utils/Evaluator.d.ts +13 -6
  130. package/lib/mjs/utils/Evaluator.js +21 -13
  131. package/lib/mjs/utils/builder.js +1 -1
  132. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
  133. package/lib/mjs/utils/i18n.js +1 -1
  134. package/lib/mjs/utils/index.d.ts +160 -2
  135. package/lib/mjs/utils/index.js +11 -1
  136. package/lib/mjs/utils/utils.d.ts +0 -5
  137. package/lib/mjs/utils/utils.js +1 -23
  138. package/lib/mjs/widgets/CalendarWidget.js +1 -1
  139. package/package.json +4 -4
@@ -3,7 +3,7 @@ import _ from 'lodash';
3
3
  import Field from '../field/Field';
4
4
  import Components from '../../Components';
5
5
  '';
6
- import { getComponentPaths, getRandomComponentId, componentMatches, getBestMatch, getStringFromComponentPath } from '../../../utils/utils';
6
+ import FormioUtils from '../../../utils';
7
7
  import { process as processAsync, processSync } from '@formio/core/process';
8
8
  /**
9
9
  * NestedComponent class.
@@ -204,7 +204,7 @@ export default class NestedComponent extends Field {
204
204
  */
205
205
  set rowIndex(value) {
206
206
  this._rowIndex = value;
207
- this.paths = getComponentPaths(this.component, this.parent?.component, {
207
+ this.paths = FormioUtils.getComponentPaths(this.component, this.parent?.component, {
208
208
  ...(this.parent?.paths || {}),
209
209
  ...{ dataIndex: value }
210
210
  });
@@ -308,7 +308,7 @@ export default class NestedComponent extends Field {
308
308
  * @returns {any} - The component that is located.
309
309
  */
310
310
  getComponent(path) {
311
- path = getStringFromComponentPath(path);
311
+ path = FormioUtils.getStringFromComponentPath(path);
312
312
  const matches = {
313
313
  path: undefined,
314
314
  fullPath: undefined,
@@ -320,7 +320,7 @@ export default class NestedComponent extends Field {
320
320
  };
321
321
  this.everyComponent((component) => {
322
322
  // All searches are relative to this component so replace this path from the child paths.
323
- componentMatches(component.component, {
323
+ FormioUtils.componentMatches(component.component, {
324
324
  path: component.paths?.path?.replace(new RegExp(`^${this.paths?.path}\\.?`), ''),
325
325
  fullPath: component.paths?.fullPath?.replace(new RegExp(`^${this.paths?.fullPath}\\.?`), ''),
326
326
  localPath: component.paths?.localPath?.replace(new RegExp(`^${this.paths?.localPath}\\.?`), ''),
@@ -332,7 +332,7 @@ export default class NestedComponent extends Field {
332
332
  return match;
333
333
  });
334
334
  });
335
- return getBestMatch(matches)?.instance;
335
+ return FormioUtils.getBestMatch(matches)?.instance;
336
336
  }
337
337
  /**
338
338
  * Return a component provided the Id of the component.
@@ -374,7 +374,7 @@ export default class NestedComponent extends Field {
374
374
  options.localRoot = this.localRoot;
375
375
  options.skipInit = true;
376
376
  if (!(options.display === 'pdf' && this.builderMode)) {
377
- component.id = getRandomComponentId();
377
+ component.id = FormioUtils.getRandomComponentId();
378
378
  }
379
379
  const comp = Components.create(component, options, data, true);
380
380
  comp.init();
@@ -659,7 +659,7 @@ export default class NestedComponent extends Field {
659
659
  }
660
660
  validationProcessor({ scope, data, row, instance, paths }, flags) {
661
661
  const { dirty } = flags;
662
- if (this.root.hasExtraPages && this.page !== this.root.page) {
662
+ if (this.root.hasSubWizards && this.page !== this.root.page) {
663
663
  instance = this.componentsMap?.hasOwnProperty(paths.dataPath)
664
664
  ? this.componentsMap[paths.dataPath]
665
665
  : this.getComponent(paths.dataPath);
@@ -2,7 +2,7 @@
2
2
  import _ from 'lodash';
3
3
  import { Utils } from '@formio/core/utils';
4
4
  const { getComponentPaths } = Utils;
5
- import { componentValueTypes, isLayoutComponent } from '../../../utils/utils';
5
+ import { componentValueTypes, isLayoutComponent } from '../../../utils';
6
6
  import Component from '../component/Component';
7
7
  import NestedDataComponent from '../nesteddata/NestedDataComponent';
8
8
  export default class NestedArrayComponent extends NestedDataComponent {
@@ -2,7 +2,7 @@
2
2
  import Component from '../component/Component';
3
3
  import NestedComponent from '../nested/NestedComponent';
4
4
  import _ from 'lodash';
5
- import { componentValueTypes, getComponentSavedTypes } from '../../../utils/utils';
5
+ import { componentValueTypes, getComponentSavedTypes } from '../../../utils';
6
6
  export default class NestedDataComponent extends NestedComponent {
7
7
  hasChanged(newValue, oldValue) {
8
8
  // If we do not have a value and are getting set to anything other than undefined or null, then we changed.
@@ -5,7 +5,7 @@ import { GoogleAddressProvider } from '../../providers/address/GoogleAddressProv
5
5
  import Field from '../_classes/field/Field';
6
6
  import NestedComponent from '../_classes/nested/NestedComponent';
7
7
  import ContainerComponent from '../container/Container';
8
- import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
8
+ import { componentValueTypes, getComponentSavedTypes } from '../../utils';
9
9
  export const AddressComponentMode = {
10
10
  Autocomplete: 'autocomplete',
11
11
  Manual: 'manual',
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { getStringFromComponentPath } from '../../utils/utils';
2
+ import { getStringFromComponentPath } from '../../utils';
3
3
  export default class Alert {
4
4
  constructor(container, component) {
5
5
  this.container = container;
@@ -7,9 +7,9 @@ export default class ButtonComponent extends Field {
7
7
  weight: number;
8
8
  schema: any;
9
9
  };
10
- static savedValueTypes(schema: any): string[];
10
+ static savedValueTypes(schema: any): any;
11
11
  constructor(component: any, options: any, data: any);
12
- filesUploading: any[];
12
+ filesUploading: number;
13
13
  get inputInfo(): any;
14
14
  get labelInfo(): {
15
15
  hidden: boolean;
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import Field from '../_classes/field/Field';
3
3
  import Input from '../_classes/input/Input';
4
- import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils/utils';
4
+ import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils/formUtils';
5
5
  export default class ButtonComponent extends Field {
6
6
  static schema(...extend) {
7
7
  return Input.schema({
@@ -34,7 +34,7 @@ export default class ButtonComponent extends Field {
34
34
  }
35
35
  constructor(component, options, data) {
36
36
  super(component, options, data);
37
- this.filesUploading = [];
37
+ this.filesUploading = 0;
38
38
  }
39
39
  get defaultSchema() {
40
40
  return ButtonComponent.schema();
@@ -142,16 +142,13 @@ export default class ButtonComponent extends Field {
142
142
  this.addClass(this.refs.buttonMessageContainer, 'has-error');
143
143
  this.setContent(this.refs.buttonMessage, resultMessage);
144
144
  }, true);
145
- this.on('fileUploadingStart', (filePromise) => {
146
- this.filesUploading.push(filePromise);
145
+ this.on('fileUploadingStart', () => {
146
+ this.filesUploading++;
147
147
  this.disabled = true;
148
148
  this.setDisabled(this.refs.button, this.disabled);
149
149
  }, true);
150
- this.on('fileUploadingEnd', (filePromise) => {
151
- const index = this.filesUploading.indexOf(filePromise);
152
- if (index !== -1) {
153
- this.filesUploading.splice(index, 1);
154
- }
150
+ this.on('fileUploadingEnd', () => {
151
+ this.filesUploading--;
155
152
  this.disabled = this.shouldDisabled ? true : false;
156
153
  this.setDisabled(this.refs.button, this.disabled);
157
154
  }, true);
@@ -247,7 +244,7 @@ export default class ButtonComponent extends Field {
247
244
  }
248
245
  }
249
246
  get shouldDisabled() {
250
- return super.shouldDisabled || !!this.filesUploading?.length || this.isDisabledOnInvalid;
247
+ return super.shouldDisabled || this.filesUploading > 0 || this.isDisabledOnInvalid;
251
248
  }
252
249
  attach(element) {
253
250
  this.loadRefs(element, {
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
2
+ import { componentValueTypes, getComponentSavedTypes } from '../../utils';
3
3
  import Field from '../_classes/field/Field';
4
4
  export default class CheckBoxComponent extends Field {
5
5
  static schema(...extend) {
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { componentValueTypes, getComponentSavedTypes, getFocusableElements } from '../../utils/utils';
2
+ import { componentValueTypes, getComponentSavedTypes, getFocusableElements } from '../../utils';
3
3
  import Component from '../_classes/component/Component';
4
4
  import Field from '../_classes/field/Field';
5
5
  import NestedDataComponent from '../_classes/nesteddata/NestedDataComponent';
@@ -1,7 +1,7 @@
1
1
  import { createNumberMask } from '@formio/text-mask-addons';
2
2
  import { maskInput } from '@formio/vanilla-text-mask';
3
3
  import _ from 'lodash';
4
- import { getCurrencyAffixes } from '../../utils/utils';
4
+ import { getCurrencyAffixes } from '../../utils';
5
5
  import NumberComponent from '../number/Number';
6
6
  export default class CurrencyComponent extends NumberComponent {
7
7
  static schema(...extend) {
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
3
- import { fastCloneDeep, getFocusableElements } from '../../utils/utils';
3
+ import { fastCloneDeep, getFocusableElements, getComponent } from '../../utils';
4
4
  export default class DataGridComponent extends NestedArrayComponent {
5
5
  static schema(...extend) {
6
6
  return NestedArrayComponent.schema({
@@ -488,6 +488,10 @@ export default class DataGridComponent extends NestedArrayComponent {
488
488
  options.row = `${rowIndex}-${colIndex}`;
489
489
  options.rowIndex = rowIndex;
490
490
  options.onChange = (flags, changed, modified) => {
491
+ if (changed.component.type === 'form') {
492
+ const formComp = getComponent(this.component.components, changed.component.key);
493
+ _.set(formComp, 'components', changed.component.components);
494
+ }
491
495
  this.triggerChange({ modified });
492
496
  };
493
497
  let columnComponent;
@@ -1,5 +1,5 @@
1
1
  export default class DataMapComponent extends DataGridComponent {
2
- static savedValueTypes(schema: any): string[];
2
+ static savedValueTypes(schema: any): any;
3
3
  constructor(component: any, options: any, data: any);
4
4
  get schema(): any;
5
5
  get emptyValue(): {};
@@ -2,7 +2,7 @@ import Component from '../_classes/component/Component';
2
2
  import DataGridComponent from '../datagrid/DataGrid';
3
3
  import _ from 'lodash';
4
4
  import EventEmitter from 'eventemitter3';
5
- import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/utils';
5
+ import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/formUtils';
6
6
  export default class DataMapComponent extends DataGridComponent {
7
7
  static schema(...extend) {
8
8
  return Component.schema({
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import moment from 'moment';
3
3
  import FormioUtils from '../../utils';
4
- import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils/utils';
4
+ import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils';
5
5
  import Input from '../_classes/input/Input';
6
6
  export default class DateTimeComponent extends Input {
7
7
  static schema(...extend) {
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import moment from 'moment';
3
3
  import Field from '../_classes/field/Field';
4
- import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils/utils';
4
+ import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils';
5
5
  import { getDayFormat } from '@formio/core';
6
6
  export default class DayComponent extends Field {
7
7
  static schema(...extend) {
@@ -4,7 +4,7 @@ import { editgrid as templates } from '@formio/bootstrap/components';
4
4
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
5
5
  import Component from '../_classes/component/Component';
6
6
  import Alert from '../alert/Alert';
7
- import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent } from '../../utils/utils';
7
+ import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent } from '../../utils';
8
8
  const EditRowState = {
9
9
  New: 'new',
10
10
  Editing: 'editing',
@@ -33,7 +33,7 @@ export default [
33
33
  weight: 1002,
34
34
  input: false,
35
35
  customConditional() {
36
- return !Evaluator.noeval;
36
+ return !Evaluator.noeval || !Evaluator.protectedEval;
37
37
  },
38
38
  },
39
39
  {
@@ -1,5 +1,5 @@
1
1
  import Field from '../_classes/field/Field';
2
- import { componentValueTypes, getComponentSavedTypes, uniqueName } from '../../utils/utils';
2
+ import { componentValueTypes, getComponentSavedTypes, uniqueName } from '../../utils';
3
3
  import download from 'downloadjs';
4
4
  import _ from 'lodash';
5
5
  import fileProcessor from '../../providers/processor/fileProcessor';
@@ -903,17 +903,16 @@ export default class FileComponent extends Field {
903
903
  } : false;
904
904
  }
905
905
  async uploadFile(fileToSync) {
906
- const filePromise = this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
906
+ return await this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
907
907
  // Progress callback
908
908
  this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
909
- this.emit('fileUploadingStart', filePromise);
909
+ this.emit('fileUploadingStart');
910
910
  },
911
911
  // Abort upload callback
912
912
  (abort) => this.abortUploads.push({
913
913
  id: fileToSync.id,
914
914
  abort,
915
915
  }), this.getMultipartOptions(fileToSync));
916
- return await filePromise;
917
916
  }
918
917
  async upload() {
919
918
  if (!this.filesToSync.filesToUpload.length) {
@@ -933,7 +932,7 @@ export default class FileComponent extends Field {
933
932
  fileToSync.message = this.t('succefullyUploaded');
934
933
  fileInfo.originalName = fileToSync.originalName;
935
934
  fileInfo.hash = fileToSync.hash;
936
- this.emit('fileUploadingEnd', Promise.resolve(fileInfo));
935
+ this.emit('fileUploadingEnd');
937
936
  }
938
937
  catch (response) {
939
938
  fileToSync.status = 'error';
@@ -943,7 +942,7 @@ export default class FileComponent extends Field {
943
942
  : response.type === 'abort'
944
943
  ? this.t('Request was aborted')
945
944
  : response.toString();
946
- this.emit('fileUploadingEnd', Promise.reject(response));
945
+ this.emit('fileUploadingEnd');
947
946
  this.emit('fileUploadError', {
948
947
  fileToSync,
949
948
  response,
@@ -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 {
@@ -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({
@@ -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({
@@ -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',
@@ -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) {
@@ -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);
@@ -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) {
@@ -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) {
@@ -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 './utils/i18n';
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);
package/lib/mjs/i18n.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import enTranslation from './translations/en';
2
- import { fastCloneDeep } from './utils/utils';
2
+ import { fastCloneDeep } from './utils';
3
3
  export default {
4
4
  lng: 'en',
5
5
  nsSeparator: '::',
@@ -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
  }
@@ -1,7 +1,14 @@
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
+ * Set the evaluator to use for evaluating expressions.
3
+ * @param {CoreEvaluator} override - The new evaluator instance to use.
4
+ * @returns {void}
5
+ */
6
+ export function registerEvaluator(override: CoreEvaluator): void;
7
+ export class DefaultEvaluator extends CoreEvaluator {
8
+ cache: {};
9
+ protectedEval: boolean;
10
+ template(template: any, hash: any): any;
11
+ interpolate(rawTemplate: any, data: any, _options: any): any;
7
12
  }
13
+ export let Evaluator: DefaultEvaluator;
14
+ 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,12 @@ export class Evaluator extends CoreEvaluator {
51
50
  return template;
52
51
  }
53
52
  }
53
+ export let Evaluator = new DefaultEvaluator();
54
+ /**
55
+ * Set the evaluator to use for evaluating expressions.
56
+ * @param {CoreEvaluator} override - The new evaluator instance to use.
57
+ * @returns {void}
58
+ */
59
+ export function registerEvaluator(override) {
60
+ Evaluator = override;
61
+ }
@@ -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';
@@ -1,4 +1,4 @@
1
- import { Evaluator } from '@formio/core/utils';
1
+ import { Evaluator } from './Evaluator';
2
2
  import i18n from '../i18n';
3
3
  import { isEmpty } from 'lodash';
4
4
  import { fastCloneDeep } from '@formio/core';