@formio/js 5.1.0-dev.6040.debc859 → 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 (236) hide show
  1. package/Changelog.md +99 -310
  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 +661 -672
  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 +688 -699
  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 +90 -68
  16. package/dist/formio.min.js +1 -1
  17. package/dist/formio.utils.js +103 -81
  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.d.ts +2 -1
  21. package/lib/cjs/Element.js +18 -39
  22. package/lib/cjs/EventEmitter.js +2 -25
  23. package/lib/cjs/Form.js +2 -25
  24. package/lib/cjs/PDF.js +1 -1
  25. package/lib/cjs/PDFBuilder.js +4 -5
  26. package/lib/cjs/Webform.d.ts +2 -2
  27. package/lib/cjs/Webform.js +14 -15
  28. package/lib/cjs/WebformBuilder.d.ts +1 -0
  29. package/lib/cjs/WebformBuilder.js +44 -14
  30. package/lib/cjs/Wizard.d.ts +2 -2
  31. package/lib/cjs/Wizard.js +41 -27
  32. package/lib/cjs/WizardBuilder.js +1 -1
  33. package/lib/cjs/components/_classes/component/Component.d.ts +49 -15
  34. package/lib/cjs/components/_classes/component/Component.js +188 -125
  35. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  36. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
  37. package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  38. package/lib/cjs/components/_classes/component/editForm/utils.js +1 -1
  39. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
  40. package/lib/cjs/components/_classes/input/Input.js +1 -1
  41. package/lib/cjs/components/_classes/list/ListComponent.js +3 -3
  42. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +0 -1
  43. package/lib/cjs/components/_classes/nested/NestedComponent.form.js +13 -0
  44. package/lib/cjs/components/_classes/nested/NestedComponent.js +17 -25
  45. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  46. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
  47. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -12
  48. package/lib/cjs/components/address/Address.d.ts +9 -0
  49. package/lib/cjs/components/address/Address.js +32 -9
  50. package/lib/cjs/components/address/editForm/Address.edit.display.d.ts +4 -0
  51. package/lib/cjs/components/address/editForm/Address.edit.display.js +1 -0
  52. package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -8
  53. package/lib/cjs/components/alert/Alert.js +1 -1
  54. package/lib/cjs/components/button/Button.d.ts +1 -1
  55. package/lib/cjs/components/button/Button.js +7 -11
  56. package/lib/cjs/components/checkbox/Checkbox.js +1 -1
  57. package/lib/cjs/components/container/Container.js +1 -1
  58. package/lib/cjs/components/content/editForm/Content.edit.display.js +8 -0
  59. package/lib/cjs/components/currency/Currency.js +1 -1
  60. package/lib/cjs/components/currency/editForm/Currency.edit.display.js +12 -0
  61. package/lib/cjs/components/datagrid/DataGrid.js +5 -4
  62. package/lib/cjs/components/datamap/DataMap.js +2 -6
  63. package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
  64. package/lib/cjs/components/datetime/DateTime.js +15 -13
  65. package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
  66. package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
  67. package/lib/cjs/components/day/Day.js +2 -2
  68. package/lib/cjs/components/day/editForm/Day.edit.display.js +8 -0
  69. package/lib/cjs/components/editgrid/EditGrid.js +4 -14
  70. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  71. package/lib/cjs/components/email/editForm/Email.edit.display.js +12 -0
  72. package/lib/cjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
  73. package/lib/cjs/components/file/File.js +6 -2
  74. package/lib/cjs/components/file/editForm/File.edit.file.d.ts +13 -0
  75. package/lib/cjs/components/file/editForm/File.edit.file.js +1 -0
  76. package/lib/cjs/components/form/Form.d.ts +0 -1
  77. package/lib/cjs/components/form/Form.js +32 -24
  78. package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
  79. package/lib/cjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
  80. package/lib/cjs/components/html/HTML.js +1 -2
  81. package/lib/cjs/components/html/editForm/HTML.edit.display.js +8 -0
  82. package/lib/cjs/components/number/Number.js +1 -1
  83. package/lib/cjs/components/number/editForm/Number.edit.display.js +12 -0
  84. package/lib/cjs/components/panel/Panel.js +1 -1
  85. package/lib/cjs/components/password/editForm/Password.edit.display.js +13 -1
  86. package/lib/cjs/components/phonenumber/PhoneNumber.form.js +9 -1
  87. package/lib/cjs/components/radio/Radio.d.ts +8 -0
  88. package/lib/cjs/components/radio/Radio.js +17 -7
  89. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  90. package/lib/cjs/components/select/Select.d.ts +1 -0
  91. package/lib/cjs/components/select/Select.js +21 -5
  92. package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +68 -110
  93. package/lib/cjs/components/select/editForm/Select.edit.data.js +3 -38
  94. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
  95. package/lib/cjs/components/selectboxes/SelectBoxes.js +7 -1
  96. package/lib/cjs/components/signature/Signature.js +1 -1
  97. package/lib/cjs/components/survey/Survey.js +2 -2
  98. package/lib/cjs/components/tabs/Tabs.js +1 -0
  99. package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
  100. package/lib/cjs/components/tags/Tags.js +1 -1
  101. package/lib/cjs/components/textarea/TextArea.js +10 -2
  102. package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
  103. package/lib/cjs/components/textfield/TextField.js +9 -32
  104. package/lib/cjs/components/time/Time.js +1 -1
  105. package/lib/cjs/components/unknown/Unknown.form.d.ts +2 -1
  106. package/lib/cjs/components/unknown/Unknown.form.js +13 -9
  107. package/lib/cjs/components/url/editForm/Url.edit.display.js +12 -0
  108. package/lib/cjs/components/well/editForm/Well.edit.display.js +8 -0
  109. package/lib/cjs/formio.form.js +5 -5
  110. package/lib/cjs/providers/storage/uploadAdapter.js +8 -6
  111. package/lib/cjs/translations/en.d.ts +1 -234
  112. package/lib/cjs/translations/en.js +4 -2
  113. package/lib/cjs/utils/Evaluator.d.ts +20 -6
  114. package/lib/cjs/utils/Evaluator.js +38 -15
  115. package/lib/cjs/utils/builder.js +5 -5
  116. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
  117. package/lib/cjs/utils/formUtils.d.ts +2 -2
  118. package/lib/cjs/utils/index.d.ts +169 -2
  119. package/lib/cjs/utils/index.js +22 -2
  120. package/lib/cjs/utils/utils.d.ts +31 -45
  121. package/lib/cjs/utils/utils.js +80 -156
  122. package/lib/cjs/widgets/CalendarWidget.d.ts +1 -8
  123. package/lib/cjs/widgets/CalendarWidget.js +19 -40
  124. package/lib/mjs/Element.d.ts +2 -1
  125. package/lib/mjs/Element.js +11 -9
  126. package/lib/mjs/EventEmitter.js +2 -2
  127. package/lib/mjs/Form.js +1 -1
  128. package/lib/mjs/PDF.js +1 -1
  129. package/lib/mjs/PDFBuilder.js +1 -2
  130. package/lib/mjs/Webform.d.ts +2 -2
  131. package/lib/mjs/Webform.js +12 -13
  132. package/lib/mjs/WebformBuilder.d.ts +1 -0
  133. package/lib/mjs/WebformBuilder.js +37 -8
  134. package/lib/mjs/Wizard.d.ts +2 -2
  135. package/lib/mjs/Wizard.js +39 -25
  136. package/lib/mjs/WizardBuilder.js +1 -1
  137. package/lib/mjs/components/_classes/component/Component.d.ts +49 -15
  138. package/lib/mjs/components/_classes/component/Component.js +161 -75
  139. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  140. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
  141. package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
  142. package/lib/mjs/components/_classes/component/editForm/utils.js +1 -1
  143. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
  144. package/lib/mjs/components/_classes/input/Input.js +1 -1
  145. package/lib/mjs/components/_classes/list/ListComponent.js +3 -3
  146. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +0 -1
  147. package/lib/mjs/components/_classes/nested/NestedComponent.form.js +13 -0
  148. package/lib/mjs/components/_classes/nested/NestedComponent.js +17 -25
  149. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  150. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
  151. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -12
  152. package/lib/mjs/components/address/Address.d.ts +9 -0
  153. package/lib/mjs/components/address/Address.js +32 -9
  154. package/lib/mjs/components/address/editForm/Address.edit.display.d.ts +4 -0
  155. package/lib/mjs/components/address/editForm/Address.edit.display.js +1 -0
  156. package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -8
  157. package/lib/mjs/components/alert/Alert.js +1 -1
  158. package/lib/mjs/components/button/Button.d.ts +1 -1
  159. package/lib/mjs/components/button/Button.js +7 -10
  160. package/lib/mjs/components/checkbox/Checkbox.js +1 -1
  161. package/lib/mjs/components/container/Container.js +1 -1
  162. package/lib/mjs/components/content/editForm/Content.edit.display.js +8 -0
  163. package/lib/mjs/components/currency/Currency.js +1 -1
  164. package/lib/mjs/components/currency/editForm/Currency.edit.display.js +12 -0
  165. package/lib/mjs/components/datagrid/DataGrid.js +5 -4
  166. package/lib/mjs/components/datamap/DataMap.js +2 -6
  167. package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
  168. package/lib/mjs/components/datetime/DateTime.js +15 -13
  169. package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
  170. package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
  171. package/lib/mjs/components/day/Day.js +2 -2
  172. package/lib/mjs/components/day/editForm/Day.edit.display.js +8 -0
  173. package/lib/mjs/components/editgrid/EditGrid.js +4 -13
  174. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  175. package/lib/mjs/components/email/editForm/Email.edit.display.js +12 -0
  176. package/lib/mjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
  177. package/lib/mjs/components/file/File.js +6 -2
  178. package/lib/mjs/components/file/editForm/File.edit.file.d.ts +13 -0
  179. package/lib/mjs/components/file/editForm/File.edit.file.js +1 -0
  180. package/lib/mjs/components/form/Form.d.ts +0 -1
  181. package/lib/mjs/components/form/Form.js +31 -24
  182. package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
  183. package/lib/mjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
  184. package/lib/mjs/components/html/HTML.js +1 -2
  185. package/lib/mjs/components/html/editForm/HTML.edit.display.js +8 -0
  186. package/lib/mjs/components/number/Number.js +1 -1
  187. package/lib/mjs/components/number/editForm/Number.edit.display.js +12 -0
  188. package/lib/mjs/components/panel/Panel.js +1 -1
  189. package/lib/mjs/components/password/editForm/Password.edit.display.js +13 -1
  190. package/lib/mjs/components/phonenumber/PhoneNumber.form.js +9 -1
  191. package/lib/mjs/components/radio/Radio.d.ts +8 -0
  192. package/lib/mjs/components/radio/Radio.js +17 -7
  193. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
  194. package/lib/mjs/components/select/Select.d.ts +1 -0
  195. package/lib/mjs/components/select/Select.js +21 -5
  196. package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +68 -110
  197. package/lib/mjs/components/select/editForm/Select.edit.data.js +3 -38
  198. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
  199. package/lib/mjs/components/selectboxes/SelectBoxes.js +7 -1
  200. package/lib/mjs/components/signature/Signature.js +1 -1
  201. package/lib/mjs/components/survey/Survey.js +2 -2
  202. package/lib/mjs/components/tabs/Tabs.js +1 -0
  203. package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
  204. package/lib/mjs/components/tags/Tags.js +1 -1
  205. package/lib/mjs/components/textarea/TextArea.js +10 -2
  206. package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
  207. package/lib/mjs/components/textfield/TextField.js +3 -3
  208. package/lib/mjs/components/time/Time.js +1 -1
  209. package/lib/mjs/components/unknown/Unknown.form.d.ts +2 -1
  210. package/lib/mjs/components/unknown/Unknown.form.js +13 -9
  211. package/lib/mjs/components/url/editForm/Url.edit.display.js +12 -0
  212. package/lib/mjs/components/well/editForm/Well.edit.display.js +8 -0
  213. package/lib/mjs/formio.form.js +3 -3
  214. package/lib/mjs/providers/storage/uploadAdapter.js +8 -6
  215. package/lib/mjs/translations/en.d.ts +1 -234
  216. package/lib/mjs/translations/en.js +6 -47
  217. package/lib/mjs/utils/Evaluator.d.ts +20 -6
  218. package/lib/mjs/utils/Evaluator.js +31 -13
  219. package/lib/mjs/utils/builder.js +1 -1
  220. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
  221. package/lib/mjs/utils/formUtils.d.ts +2 -2
  222. package/lib/mjs/utils/index.d.ts +169 -2
  223. package/lib/mjs/utils/index.js +18 -1
  224. package/lib/mjs/utils/utils.d.ts +31 -45
  225. package/lib/mjs/utils/utils.js +72 -129
  226. package/lib/mjs/widgets/CalendarWidget.d.ts +1 -8
  227. package/lib/mjs/widgets/CalendarWidget.js +19 -40
  228. package/package.json +8 -6
  229. package/lib/cjs/i18n.d.ts +0 -13
  230. package/lib/cjs/i18n.js +0 -19
  231. package/lib/cjs/utils/i18n.d.ts +0 -19
  232. package/lib/cjs/utils/i18n.js +0 -120
  233. package/lib/mjs/i18n.d.ts +0 -13
  234. package/lib/mjs/i18n.js +0 -14
  235. package/lib/mjs/utils/i18n.d.ts +0 -19
  236. package/lib/mjs/utils/i18n.js +0 -112
@@ -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.
@@ -81,18 +81,15 @@ export default class NestedComponent extends Field {
81
81
  const visibilityChanged = this._visible !== value;
82
82
  this._visible = value;
83
83
  const isVisible = this.visible;
84
- const isConditionallyHidden = this.checkConditionallyHidden();
85
84
  const forceShow = this.shouldForceShow();
86
85
  const forceHide = this.shouldForceHide();
87
86
  this.components.forEach((component) => {
88
87
  // Set the parent visibility first since we may have nested components within nested components
89
88
  // and they need to be able to determine their visibility based on the parent visibility.
90
89
  component.parentVisible = isVisible;
91
- component._parentConditionallyHidden = isConditionallyHidden;
92
90
  let visible;
93
91
  if (component.hasCondition()) {
94
- component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
95
- visible = !component.conditionallyHidden;
92
+ visible = !component.conditionallyHidden();
96
93
  }
97
94
  else {
98
95
  visible = !component.component.hidden;
@@ -207,7 +204,7 @@ export default class NestedComponent extends Field {
207
204
  */
208
205
  set rowIndex(value) {
209
206
  this._rowIndex = value;
210
- this.paths = getComponentPaths(this.component, this.parent?.component, {
207
+ this.paths = FormioUtils.getComponentPaths(this.component, this.parent?.component, {
211
208
  ...(this.parent?.paths || {}),
212
209
  ...{ dataIndex: value }
213
210
  });
@@ -311,7 +308,7 @@ export default class NestedComponent extends Field {
311
308
  * @returns {any} - The component that is located.
312
309
  */
313
310
  getComponent(path) {
314
- path = getStringFromComponentPath(path);
311
+ path = FormioUtils.getStringFromComponentPath(path);
315
312
  const matches = {
316
313
  path: undefined,
317
314
  fullPath: undefined,
@@ -323,7 +320,7 @@ export default class NestedComponent extends Field {
323
320
  };
324
321
  this.everyComponent((component) => {
325
322
  // All searches are relative to this component so replace this path from the child paths.
326
- componentMatches(component.component, {
323
+ FormioUtils.componentMatches(component.component, {
327
324
  path: component.paths?.path?.replace(new RegExp(`^${this.paths?.path}\\.?`), ''),
328
325
  fullPath: component.paths?.fullPath?.replace(new RegExp(`^${this.paths?.fullPath}\\.?`), ''),
329
326
  localPath: component.paths?.localPath?.replace(new RegExp(`^${this.paths?.localPath}\\.?`), ''),
@@ -335,7 +332,7 @@ export default class NestedComponent extends Field {
335
332
  return match;
336
333
  });
337
334
  });
338
- return getBestMatch(matches)?.instance;
335
+ return FormioUtils.getBestMatch(matches)?.instance;
339
336
  }
340
337
  /**
341
338
  * Return a component provided the Id of the component.
@@ -373,12 +370,11 @@ export default class NestedComponent extends Field {
373
370
  data = data || this.data;
374
371
  options.parent = this;
375
372
  options.parentVisible = this.visible;
376
- options.parentConditionallyHidden = this.conditionallyHidden;
377
373
  options.root = options?.root || this.root || this;
378
374
  options.localRoot = this.localRoot;
379
375
  options.skipInit = true;
380
376
  if (!(options.display === 'pdf' && this.builderMode)) {
381
- component.id = getRandomComponentId();
377
+ component.id = FormioUtils.getRandomComponentId();
382
378
  }
383
379
  const comp = Components.create(component, options, data, true);
384
380
  comp.init();
@@ -631,19 +627,8 @@ export default class NestedComponent extends Field {
631
627
  }
632
628
  clearOnHide(show) {
633
629
  super.clearOnHide(show);
634
- if (this.component.clearOnHide) {
635
- if (this.allowData && !this.hasValue() && !this.conditionallyHidden) {
636
- this.dataValue = this.defaultValue;
637
- }
638
- if (this.hasValue()) {
639
- this.restoreComponentsContext();
640
- }
641
- }
642
630
  this.getComponents().forEach(component => component.clearOnHide(show));
643
631
  }
644
- restoreComponentsContext() {
645
- this.getComponents().forEach((component) => component.data = this.dataValue);
646
- }
647
632
  /**
648
633
  * Allow components to hook into the next page trigger to perform their own logic.
649
634
  * @param {Function} next - The callback to continue to the next page.
@@ -661,7 +646,7 @@ export default class NestedComponent extends Field {
661
646
  }
662
647
  calculateValue(data, flags, row) {
663
648
  // Do not iterate into children and calculateValues if this nested component is conditionally hidden.
664
- if (this.conditionallyHidden) {
649
+ if (this.conditionallyHidden()) {
665
650
  return false;
666
651
  }
667
652
  return this.getComponents().reduce((changed, comp) => comp.calculateValue(data, flags, row) || changed, super.calculateValue(data, flags, row));
@@ -674,7 +659,7 @@ export default class NestedComponent extends Field {
674
659
  }
675
660
  validationProcessor({ scope, data, row, instance, paths }, flags) {
676
661
  const { dirty } = flags;
677
- if (this.root.hasExtraPages && this.page !== this.root.page) {
662
+ if (this.root.hasSubWizards && this.page !== this.root.page) {
678
663
  instance = this.componentsMap?.hasOwnProperty(paths.dataPath)
679
664
  ? this.componentsMap[paths.dataPath]
680
665
  : this.getComponent(paths.dataPath);
@@ -831,7 +816,7 @@ export default class NestedComponent extends Field {
831
816
  else if (value && component.hasValue(value)) {
832
817
  return component.setValue(_.get(value, component.key), flags);
833
818
  }
834
- else if ((!this.rootPristine || component.visible) && component.shouldAddDefaultValue) {
819
+ else if ((!this.rootPristine || component.visible) && (flags.resetValue || component.shouldAddDefaultValue)) {
835
820
  flags.noValidate = !flags.dirty;
836
821
  flags.resetValue = true;
837
822
  return component.setValue(component.defaultValue, flags);
@@ -841,6 +826,13 @@ export default class NestedComponent extends Field {
841
826
  if (!value) {
842
827
  return false;
843
828
  }
829
+ // If the value is equal to the empty value, then this means we need to reset the values.
830
+ if (_.isEqual(value, this.emptyValue)) {
831
+ // TO-DO: For a future major release, we need to investigate removing the need for the
832
+ // "resetValue" flag. This seems like a hack that is no longer necessary and the renderer
833
+ // may behave more deterministically without it.
834
+ flags.resetValue = true;
835
+ }
844
836
  return this.getComponents().reduce((changed, component) => {
845
837
  return this.setNestedValue(component, value, flags, changed) || changed;
846
838
  }, false);
@@ -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 {
@@ -3,11 +3,9 @@ export default class NestedDataComponent extends NestedComponent {
3
3
  hasChanged(newValue: any, oldValue: any): boolean;
4
4
  get allowData(): boolean;
5
5
  get emptyValue(): {};
6
- get shouldAddDefaultValue(): boolean;
7
6
  componentContext(): any;
8
7
  getValueAsString(value: any, options: any): string;
9
8
  getDataValueAsTable(value: any, options: any): string;
10
- everyComponent(fn: any, options?: {}): void;
11
9
  /**
12
10
  * Get the value of this component.
13
11
  * @returns {any} - Return the value of this component.
@@ -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.
@@ -90,17 +90,6 @@ export default class NestedDataComponent extends NestedComponent {
90
90
  `);
91
91
  return result;
92
92
  }
93
- everyComponent(fn, options = {}) {
94
- if (options?.email) {
95
- if (options.fromRoot) {
96
- delete options.fromRoot;
97
- }
98
- else {
99
- return;
100
- }
101
- }
102
- return super.everyComponent(fn, options);
103
- }
104
93
  /**
105
94
  * Get the value of this component.
106
95
  * @returns {any} - Return the value of this component.
@@ -36,12 +36,21 @@ export default class AddressComponent extends ContainerComponent {
36
36
  get autocompleteMode(): boolean;
37
37
  get manualMode(): boolean;
38
38
  get manualModeEnabled(): boolean;
39
+ restoreComponentsContext(): void;
39
40
  get isMultiple(): boolean;
40
41
  set address(value: any);
41
42
  get address(): any;
42
43
  isValueInLegacyFormat(value: any): any;
43
44
  normalizeValue(value: any): any;
44
45
  get modeSwitcher(): any;
46
+ get providerOptions(): {
47
+ params: any;
48
+ url: any;
49
+ queryProperty: any;
50
+ responseProperty: any;
51
+ displayValueProperty: any;
52
+ autocompleteOptions: any;
53
+ };
45
54
  get removeValueIcon(): any;
46
55
  get searchInput(): any;
47
56
  get addRowButton(): any;
@@ -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',
@@ -20,7 +20,6 @@ export default class AddressComponent extends ContainerComponent {
20
20
  key: 'address',
21
21
  switchToManualModeLabel: 'Can\'t find address? Switch to manual mode.',
22
22
  provider: '',
23
- providerOptions: {},
24
23
  manualModeViewString: '',
25
24
  hideLabel: false,
26
25
  disableClearIcon: false,
@@ -113,20 +112,33 @@ export default class AddressComponent extends ContainerComponent {
113
112
  NestedComponent.prototype.addComponents.call(this, this.manualMode ? this.address : {});
114
113
  }
115
114
  Field.prototype.init.call(this);
115
+ // Added for backwards compatibility
116
+ if (this.component.providerOptions) {
117
+ const { params, url, queryProperty, responseProperty, displayValueProperty } = this.component.providerOptions;
118
+ const key = params?.key;
119
+ const autocompleteOptions = params?.autocompleteOptions;
120
+ delete this.component.providerOptions;
121
+ this.component.url = url;
122
+ this.component.queryProperty = queryProperty;
123
+ this.component.responseProperty = responseProperty;
124
+ this.component.displayValueProperty = displayValueProperty;
125
+ this.component.apiKey = key;
126
+ this.component.autocompleteOptions = autocompleteOptions;
127
+ }
128
+ let provider = this.component.provider;
129
+ const providerOptions = this.providerOptions;
130
+ const map = this.component.map;
116
131
  if (!this.builderMode) {
117
- if (this.component.provider) {
118
- const { provider, providerOptions, } = this.component;
132
+ if (provider) {
119
133
  if (_.get(providerOptions, 'params.subscriptionKey')) {
120
134
  _.set(providerOptions, "params['subscription-key']", _.get(providerOptions, 'params.subscriptionKey'));
121
135
  _.unset(providerOptions, 'params.subscriptionKey');
122
136
  }
123
137
  this.provider = this.initializeProvider(provider, providerOptions);
124
138
  }
125
- else if (this.component.map) {
139
+ else if (map) {
126
140
  // Fallback to legacy version where Google Maps was the only provider.
127
- this.component.provider = GoogleAddressProvider.name;
128
- this.component.providerOptions = this.component.providerOptions || {};
129
- const { map, provider, providerOptions, } = this.component;
141
+ provider = this.component.provider = GoogleAddressProvider.name;
130
142
  const { key, region, } = map;
131
143
  if (key) {
132
144
  _.set(providerOptions, 'params.key', key);
@@ -258,6 +270,16 @@ export default class AddressComponent extends ContainerComponent {
258
270
  ? (this.refs[AddressComponent.modeSwitcherRef] || null)
259
271
  : null;
260
272
  }
273
+ get providerOptions() {
274
+ return {
275
+ params: { subscriptionKey: this.component.subscriptionKey, key: this.component.apiKey, ...this.component.params },
276
+ url: this.component.url,
277
+ queryProperty: this.component.queryProperty,
278
+ responseProperty: this.component.responseProperty,
279
+ displayValueProperty: this.component.displayValueProperty,
280
+ autocompleteOptions: this.component.autocompleteOptions
281
+ };
282
+ }
261
283
  get removeValueIcon() {
262
284
  return this.refs
263
285
  ? (this.refs[AddressComponent.removeValueIconRef] || null)
@@ -371,7 +393,8 @@ export default class AddressComponent extends ContainerComponent {
371
393
  const result = ((this.builderMode || this.manualMode) ? super.attach : Field.prototype.attach).call(this, element);
372
394
  if (!this.builderMode) {
373
395
  if (!this.provider && this.component.provider) {
374
- const { provider, providerOptions, } = this.component;
396
+ const provider = this.component.provider;
397
+ const providerOptions = this.providerOptions;
375
398
  this.provider = this.initializeProvider(provider, providerOptions);
376
399
  }
377
400
  }
@@ -8,6 +8,7 @@ declare const _default: ({
8
8
  customConditional: ({ data }: {
9
9
  data: any;
10
10
  }) => boolean;
11
+ defaultValue?: undefined;
11
12
  placeholder?: undefined;
12
13
  validate?: undefined;
13
14
  } | {
@@ -15,6 +16,7 @@ declare const _default: ({
15
16
  type: string;
16
17
  input: boolean;
17
18
  key: string;
19
+ defaultValue: string;
18
20
  label: string;
19
21
  placeholder: string;
20
22
  tooltip: string;
@@ -32,6 +34,7 @@ declare const _default: ({
32
34
  label: string;
33
35
  tooltip: string;
34
36
  customConditional?: undefined;
37
+ defaultValue?: undefined;
35
38
  placeholder?: undefined;
36
39
  validate?: undefined;
37
40
  } | {
@@ -45,6 +48,7 @@ declare const _default: ({
45
48
  customConditional: ({ data }: {
46
49
  data: any;
47
50
  }) => any;
51
+ defaultValue?: undefined;
48
52
  validate?: undefined;
49
53
  })[];
50
54
  export default _default;
@@ -13,6 +13,7 @@ export default [
13
13
  type: 'textfield',
14
14
  input: true,
15
15
  key: 'switchToManualModeLabel',
16
+ defaultValue: 'Can\'t find address? Switch to manual mode.',
16
17
  label: 'Switch To Manual Mode Label',
17
18
  placeholder: 'Switch To Manual Mode Label',
18
19
  tooltip: 'The label for the checkbox used to switch to manual mode.',
@@ -26,7 +26,7 @@ export default [
26
26
  {
27
27
  type: 'textfield',
28
28
  input: true,
29
- key: "providerOptions.params.subscriptionKey",
29
+ key: "subscriptionKey",
30
30
  label: 'Subscription Key',
31
31
  placeholder: 'Enter Subscription Key',
32
32
  weight: 10,
@@ -41,7 +41,7 @@ export default [
41
41
  {
42
42
  type: 'textfield',
43
43
  input: true,
44
- key: 'providerOptions.url',
44
+ key: 'url',
45
45
  label: 'Url',
46
46
  placeholder: 'Enter Url',
47
47
  weight: 10,
@@ -56,7 +56,7 @@ export default [
56
56
  {
57
57
  type: 'textfield',
58
58
  input: true,
59
- key: 'providerOptions.queryProperty',
59
+ key: 'queryProperty',
60
60
  label: 'Query Property',
61
61
  defaultValue: 'query',
62
62
  placeholder: 'Enter Query Property',
@@ -69,7 +69,7 @@ export default [
69
69
  {
70
70
  type: 'textfield',
71
71
  input: true,
72
- key: 'providerOptions.responseProperty',
72
+ key: 'responseProperty',
73
73
  label: 'Response Property',
74
74
  placeholder: 'Enter Response Property',
75
75
  weight: 30,
@@ -81,7 +81,7 @@ export default [
81
81
  {
82
82
  type: 'textfield',
83
83
  input: true,
84
- key: 'providerOptions.displayValueProperty',
84
+ key: 'displayValueProperty',
85
85
  label: 'Display Value Property',
86
86
  placeholder: 'Display Value Property',
87
87
  weight: 40,
@@ -93,7 +93,7 @@ export default [
93
93
  {
94
94
  type: 'textarea',
95
95
  input: true,
96
- key: 'providerOptions.params',
96
+ key: 'params',
97
97
  label: 'Params',
98
98
  placeholder: '{ ... }',
99
99
  weight: 50,
@@ -108,7 +108,7 @@ export default [
108
108
  {
109
109
  type: 'textfield',
110
110
  input: true,
111
- key: 'providerOptions.params.key',
111
+ key: 'apiKey',
112
112
  label: 'API Key',
113
113
  placeholder: 'Enter API Key',
114
114
  weight: 10,
@@ -123,7 +123,7 @@ export default [
123
123
  {
124
124
  type: 'textarea',
125
125
  input: true,
126
- key: 'providerOptions.params.autocompleteOptions',
126
+ key: 'autocompleteOptions',
127
127
  label: 'Provider options',
128
128
  placeholder: 'Enter provider options as JSON object',
129
129
  defaultValue: {},
@@ -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';
@@ -3,6 +3,14 @@ export default [
3
3
  key: 'labelPosition',
4
4
  ignore: true
5
5
  },
6
+ {
7
+ key: 'labelWidth',
8
+ ignore: true
9
+ },
10
+ {
11
+ key: 'labelMargin',
12
+ ignore: true
13
+ },
6
14
  {
7
15
  key: 'placeholder',
8
16
  ignore: true
@@ -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) {
@@ -7,6 +7,18 @@ export default [
7
7
  key: 'allowMultipleMasks',
8
8
  ignore: true
9
9
  },
10
+ {
11
+ key: 'inputMasks',
12
+ ignore: true
13
+ },
14
+ {
15
+ key: 'widget.type',
16
+ ignore: true
17
+ },
18
+ {
19
+ key: 'widget',
20
+ ignore: true
21
+ },
10
22
  {
11
23
  key: 'showWordCount',
12
24
  ignore: true
@@ -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;
@@ -609,9 +613,6 @@ export default class DataGridComponent extends NestedArrayComponent {
609
613
  this.updateOnChange(flags, changed);
610
614
  return changed;
611
615
  }
612
- restoreComponentsContext() {
613
- this.rows.forEach((row, index) => _.forIn(row, (component) => component.data = this.dataValue[index]));
614
- }
615
616
  toggleGroup(element, index) {
616
617
  element.classList.toggle('collapsed');
617
618
  _.each(this.refs.chunks[index], row => {
@@ -68,14 +68,10 @@ export default class DataMapComponent extends DataGridComponent {
68
68
  return {};
69
69
  }
70
70
  get dataValue() {
71
- if (!this.key ||
72
- (this.conditionallyHidden && this.component.clearOnHide)) {
71
+ if (!this.key) {
73
72
  return this.emptyValue;
74
73
  }
75
- if (!this.hasValue() && this.shouldAddDefaultValue) {
76
- this.dataValue = this.emptyValue;
77
- }
78
- return _.get(this.data, this.key);
74
+ return _.get(this.data, this.key, this.emptyValue);
79
75
  }
80
76
  set dataValue(value) {
81
77
  super.dataValue = value;
@@ -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
  }