@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
@@ -5,8 +5,8 @@ import _ from 'lodash';
5
5
  import isMobile from 'ismobilejs';
6
6
  import { processOne, processOneSync, validateProcessInfo } from '@formio/core/process';
7
7
  import { Formio } from '../../../Formio';
8
- import * as FormioUtils from '../../../utils/utils';
9
- import { fastCloneDeep, boolValue, currentTimezone, getScriptPlugin, getContextualRowData } from '../../../utils/utils';
8
+ import FormioUtils from '../../../utils';
9
+ import { fastCloneDeep, boolValue, currentTimezone, getScriptPlugin, getContextualRowData } from '../../../utils';
10
10
  import Element from '../../../Element';
11
11
  import ComponentModal from '../componentModal/ComponentModal';
12
12
  import Widgets from '../../../widgets';
@@ -422,10 +422,15 @@ export default class Component extends Element {
422
422
  get componentsMap() {
423
423
  return this.root?.childComponentsMap || {};
424
424
  }
425
+ /**
426
+ * Returns if the parent should conditionally clear.
427
+ * @returns {boolean} - If the parent should conditionally clear.
428
+ */
425
429
  parentShouldConditionallyClear() {
426
430
  let currentParent = this.parent;
427
431
  while (currentParent) {
428
- if (currentParent.shouldConditionallyClear(true)) {
432
+ if ((currentParent.allowData && currentParent._conditionallyClear) ||
433
+ (!currentParent.allowData && currentParent._conditionallyHidden)) {
429
434
  return true;
430
435
  }
431
436
  currentParent = currentParent.parent;
@@ -435,7 +440,21 @@ export default class Component extends Element {
435
440
  parentConditionallyHidden() {
436
441
  let currentParent = this.parent;
437
442
  while (currentParent) {
438
- if (currentParent.conditionallyHidden(true)) {
443
+ if (currentParent._conditionallyHidden) {
444
+ return true;
445
+ }
446
+ currentParent = currentParent.parent;
447
+ }
448
+ return false;
449
+ }
450
+ /**
451
+ * Returns true if any of the parents default their component "hidden" property to true.
452
+ * @returns {boolean} - If any parent defaults the hidden property to true.
453
+ */
454
+ anyParentDefaultsHidden() {
455
+ let currentParent = this.parent;
456
+ while (currentParent) {
457
+ if (currentParent.component.hidden) {
439
458
  return true;
440
459
  }
441
460
  currentParent = currentParent.parent;
@@ -653,48 +672,58 @@ export default class Component extends Element {
653
672
  }
654
673
  return this._logicallyHidden;
655
674
  }
656
- shouldConditionallyClear(skipParent = false) {
675
+ /**
676
+ * Determines if the component should clear its value when the root form is pristine.
677
+ * @returns {boolean} - If the component should clear its value when the root form is pristine.
678
+ */
679
+ shouldConditionallyClearOnPristine() {
680
+ // If the form is pristine, we should NOT clear the value of a conditionally hidden child component
681
+ // of a layout component that defaults to hidden using the "hidden" component property.
682
+ return !this.anyParentDefaultsHidden();
683
+ }
684
+ /**
685
+ * Returns if the component should clear its value when conditionally hidden.
686
+ * @returns {boolean} - If the component should clear its value when conditionally hidden.
687
+ */
688
+ shouldConditionallyClear() {
657
689
  // Skip if this component has clearOnHide set to false.
658
690
  if (this.component.clearOnHide === false) {
659
- return false;
691
+ this._conditionallyClear = false;
692
+ return this._conditionallyClear;
660
693
  }
661
694
  // If the component is logically hidden, then it is conditionally hidden and should clear.
662
695
  if (this.logicallyHidden) {
663
- return true;
696
+ this._conditionallyClear = true;
697
+ return this._conditionallyClear;
664
698
  }
665
699
  // If we have a condition and it is not conditionally visible, the it should conditionally clear.
666
- if (this.hasCondition() && !this.conditionallyVisible()) {
667
- return true;
700
+ if (this.hasCondition() &&
701
+ !this.conditionallyVisible() &&
702
+ (!this.rootPristine || this.shouldConditionallyClearOnPristine())) {
703
+ this._conditionallyClear = true;
704
+ return this._conditionallyClear;
668
705
  }
669
- if (skipParent) {
670
- // Stop recurrsion for the parent checks.
671
- return false;
672
- }
673
- // If this component has a set value, then it should ONLY clear if a parent is hidden
674
- // and has the clearOnHide set to true.
675
- if (this.hasSetValue) {
676
- return this.parentShouldConditionallyClear();
677
- }
678
- // Clear the value if the parent is conditionally hidden.
679
- return this.parentConditionallyHidden();
706
+ this._conditionallyClear = this.hasSetValue ? false : this.parentShouldConditionallyClear();
707
+ return this._conditionallyClear;
680
708
  }
681
- conditionallyHidden(skipParent = false) {
709
+ /**
710
+ * Returns if the component is conditionally hidden.
711
+ * @returns {boolean} - If the component is conditionally hidden.
712
+ */
713
+ conditionallyHidden() {
714
+ // If it is logically hidden, then it is conditionally hidden.
682
715
  if (this.logicallyHidden) {
683
- return true;
684
- }
685
- if (!this.hasCondition() && !skipParent) {
686
- return this.parentConditionallyHidden();
687
- }
688
- // Return if we are not conditionally visible (conditionallyHidden)
689
- if (!this.conditionallyVisible()) {
690
- return true;
716
+ this._conditionallyHidden = true;
717
+ return this._conditionallyHidden;
691
718
  }
692
- if (skipParent) {
693
- // Stop recurrsion for the parent checks.
694
- return false;
719
+ // If it has a condition, and is not conditionally visible, then it is conditionally hidden.
720
+ if (this.hasCondition() && !this.conditionallyVisible()) {
721
+ this._conditionallyHidden = true;
722
+ return this._conditionallyHidden;
695
723
  }
696
- // Check the parent.
697
- return this.parentConditionallyHidden();
724
+ // It is conditionally hidden if its parent is conditionally hidden.
725
+ this._conditionallyHidden = this.parentConditionallyHidden();
726
+ return this._conditionallyHidden;
698
727
  }
699
728
  get currentForm() {
700
729
  return this._currentForm;
@@ -2653,13 +2682,16 @@ export default class Component extends Element {
2653
2682
  }
2654
2683
  const isArray = Array.isArray(value);
2655
2684
  const valueInput = this.refs.fileLink || this.refs.input;
2685
+ const isFilelink = !!this.refs.fileLink;
2656
2686
  if (isArray &&
2657
2687
  Array.isArray(this.defaultValue) &&
2658
2688
  this.refs.hasOwnProperty('input') &&
2659
2689
  valueInput &&
2660
2690
  (valueInput.length !== value.length) &&
2661
2691
  this.visible) {
2662
- this.redraw();
2692
+ if (isFilelink || valueInput.length) {
2693
+ this.redraw();
2694
+ }
2663
2695
  }
2664
2696
  if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
2665
2697
  this.redraw();
@@ -3166,6 +3198,9 @@ export default class Component extends Element {
3166
3198
  data = data || this.rootValue;
3167
3199
  flags = flags || {};
3168
3200
  row = row || this.data;
3201
+ if (flags.noCheck) {
3202
+ return true;
3203
+ }
3169
3204
  // Some components (for legacy reasons) have calls to "checkData" in inappropriate places such
3170
3205
  // as setValue. Historically, this was bypassed by a series of cached states around the data model
3171
3206
  // which caused its own problems. We need to ensure that premium and custom components do not fall into
@@ -3180,9 +3215,6 @@ export default class Component extends Element {
3180
3215
  if (!flags.fromBlur) {
3181
3216
  this.checkRefreshOn(flags.changes, flags);
3182
3217
  }
3183
- if (flags.noCheck) {
3184
- return true;
3185
- }
3186
3218
  this.checkComponentConditions(data, flags, row);
3187
3219
  if (this.id !== flags.triggeredComponentId) {
3188
3220
  this.calculateComponentValue(data, flags, row);
@@ -1,5 +1,5 @@
1
1
  import EditFormUtils from './utils';
2
- import { getContextComponents } from '../../../../utils/utils';
2
+ import { getContextComponents } from '../../../../utils';
3
3
  /* eslint-disable quotes, max-len */
4
4
  export default [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  import EditFormUtils from './utils';
2
- import { getContextComponents } from '../../../../utils/utils';
2
+ import { getContextComponents } from '../../../../utils';
3
3
  /* eslint-disable quotes, max-len */
4
4
  export default [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { fastCloneDeep } from '../../../utils/utils';
2
+ import { fastCloneDeep } from '../../../utils';
3
3
  export default class ComponentModal {
4
4
  static render(component, data, topLevel) {
5
5
  const children = component.renderTemplate('component', data, topLevel);
@@ -1,5 +1,5 @@
1
1
  import Multivalue from '../multivalue/Multivalue';
2
- import { convertStringToHTMLElement } from '../../../utils/utils';
2
+ import { convertStringToHTMLElement } from '../../../utils';
3
3
  import Widgets from '../../../widgets';
4
4
  import _ from 'lodash';
5
5
  export default class Input extends Multivalue {
@@ -1,7 +1,7 @@
1
1
  import Field from '../field/Field';
2
2
  import { Formio } from '../../../Formio';
3
3
  import _ from 'lodash';
4
- import { getItemTemplateKeys } from '../../../utils/utils';
4
+ import { getItemTemplateKeys } from '../../../utils';
5
5
  export default class ListComponent extends Field {
6
6
  static schema(...extend) {
7
7
  return Field.schema({
@@ -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;
@@ -9,7 +9,7 @@ export default class ButtonComponent extends Field {
9
9
  };
10
10
  static savedValueTypes(schema: any): string[];
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';
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;
@@ -17,7 +17,7 @@ export default class DateTimeComponent extends Input {
17
17
  };
18
18
  static savedValueTypes(schema: any): string[];
19
19
  get emptyValue(): string;
20
- get momentFormat(): string;
20
+ get dayjsFormat(): string;
21
21
  createWrapper(): boolean;
22
22
  checkValidity(data: any, dirty: any, rowData: any): boolean;
23
23
  getValueAsString(value: any, options: any): any;
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
- import moment from 'moment';
2
+ import dayjs from 'dayjs';
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) {
@@ -147,8 +147,8 @@ export default class DateTimeComponent extends Input {
147
147
  get emptyValue() {
148
148
  return '';
149
149
  }
150
- get momentFormat() {
151
- return FormioUtils.convertFormatToMoment(this.component.format);
150
+ get dayjsFormat() {
151
+ return FormioUtils.convertFormatToDayjs(this.component.format);
152
152
  }
153
153
  isEmpty(value = this.dataValue) {
154
154
  if (value && (value.toString() === 'Invalid Date')) {
@@ -157,12 +157,14 @@ export default class DateTimeComponent extends Input {
157
157
  return super.isEmpty(value);
158
158
  }
159
159
  formatValue(input) {
160
- const result = moment.utc(input).toISOString();
161
- return result === 'Invalid date' ? input : result;
160
+ if (dayjs(input).isValid()) {
161
+ return dayjs.utc(input).toISOString();
162
+ }
163
+ return input;
162
164
  }
163
165
  isEqual(valueA, valueB = this.dataValue) {
164
166
  return (this.isEmpty(valueA) && this.isEmpty(valueB))
165
- || moment.utc(valueA).format(this.momentFormat) === moment.utc(valueB).format(this.momentFormat);
167
+ || dayjs.utc(valueA).format(this.dayjsFormat) === dayjs.utc(valueB).format(this.dayjsFormat);
166
168
  }
167
169
  createWrapper() {
168
170
  return false;
@@ -178,18 +180,18 @@ export default class DateTimeComponent extends Input {
178
180
  return super.checkValidity(data, dirty, rowData);
179
181
  }
180
182
  getValueAsString(value, options) {
181
- let format = FormioUtils.convertFormatToMoment(this.component.format);
182
- format += format.match(/z$/) ? '' : ' z';
183
+ let format = FormioUtils.convertFormatToDayjs(this.component.format);
183
184
  const timezone = this.timezone;
184
185
  if (value && !this.attached && timezone) {
186
+ format += format.match(/z$/) ? '' : ' z';
185
187
  if (Array.isArray(value) && this.component.multiple) {
186
- return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone, options).format(format))).join(', ');
188
+ return value.map(item => _.trim(FormioUtils.dayjsDate(item, format, timezone, options).format(format))).join(', ');
187
189
  }
188
- return _.trim(FormioUtils.momentDate(value, format, timezone, options).format(format));
190
+ return _.trim(FormioUtils.dayjsDate(value, format, timezone, options).format(format));
189
191
  }
190
192
  if (Array.isArray(value) && this.component.multiple) {
191
- return value.map(item => _.trim(moment(item).format(format))).join(', ');
193
+ return value.map(item => _.trim(dayjs(item).format(format))).join(', ');
192
194
  }
193
- return (value ? _.trim(moment(value).format(format)) : value) || '';
195
+ return (value ? _.trim(dayjs(value).format(format)) : value) || '';
194
196
  }
195
197
  }
@@ -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) {
@@ -53,7 +53,7 @@ export default class DayComponent extends Field {
53
53
  // Empty value used before 9.3.x
54
54
  static oldEmptyValue = '00/00/0000';
55
55
  constructor(component, options, data) {
56
- if (!options.inFormBuilder && !options.building) {
56
+ if (options && !options.inFormBuilder && !options.building) {
57
57
  if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
58
58
  component.maxDate = moment(component.maxDate, 'YYYY-MM-DD').toISOString();
59
59
  }
@@ -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,
@@ -98,7 +98,6 @@ export default class FormComponent extends Component {
98
98
  * @returns {void}
99
99
  */
100
100
  onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
101
- areAllComponentsEmpty(data: any): boolean;
102
101
  updateSubFormVisibility(): void;
103
102
  /**
104
103
  * Determines if this form is a Nested Wizard