@formio/js 5.1.0-dev.5974.1be1688 → 5.1.0-dev.5976.f61da27

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 (108) hide show
  1. package/dist/formio.builder.css +19 -17
  2. package/dist/formio.builder.min.css +1 -1
  3. package/dist/formio.embed.js +1 -1
  4. package/dist/formio.embed.min.js +1 -1
  5. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  6. package/dist/formio.form.css +19 -17
  7. package/dist/formio.form.js +37 -37
  8. package/dist/formio.form.min.css +1 -1
  9. package/dist/formio.form.min.js +1 -1
  10. package/dist/formio.form.min.js.LICENSE.txt +3 -3
  11. package/dist/formio.full.css +19 -17
  12. package/dist/formio.full.js +43 -43
  13. package/dist/formio.full.min.css +2 -2
  14. package/dist/formio.full.min.js +1 -1
  15. package/dist/formio.full.min.js.LICENSE.txt +3 -3
  16. package/dist/formio.js +9 -9
  17. package/dist/formio.min.js +1 -1
  18. package/dist/formio.min.js.LICENSE.txt +1 -1
  19. package/dist/formio.utils.js +5 -5
  20. package/dist/formio.utils.min.js +1 -1
  21. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  22. package/lib/cjs/Embed.js +1 -1
  23. package/lib/cjs/Form.d.ts +2 -4
  24. package/lib/cjs/Form.js +3 -1
  25. package/lib/cjs/Formio.js +1 -1
  26. package/lib/cjs/PDFBuilder.js +2 -2
  27. package/lib/cjs/Webform.d.ts +5 -2
  28. package/lib/cjs/Webform.js +31 -16
  29. package/lib/cjs/WebformBuilder.d.ts +1 -0
  30. package/lib/cjs/WebformBuilder.js +14 -3
  31. package/lib/cjs/Wizard.js +2 -1
  32. package/lib/cjs/WizardBuilder.js +14 -1
  33. package/lib/cjs/components/Components.d.ts +3 -0
  34. package/lib/cjs/components/_classes/component/Component.js +12 -2
  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.d.ts +37 -0
  37. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +13 -2
  38. package/lib/cjs/components/_classes/component/editForm/utils.d.ts +1 -0
  39. package/lib/cjs/components/_classes/component/editForm/utils.js +3 -0
  40. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
  41. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +3 -0
  42. package/lib/cjs/components/address/Address.js +1 -1
  43. package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
  44. package/lib/cjs/components/datetime/DateTime.js +5 -5
  45. package/lib/cjs/components/day/Day.js +7 -5
  46. package/lib/cjs/components/file/File.js +2 -1
  47. package/lib/cjs/components/form/Form.d.ts +4 -2
  48. package/lib/cjs/components/form/Form.js +25 -10
  49. package/lib/cjs/components/form/editForm/Form.edit.data.js +1 -1
  50. package/lib/cjs/components/form/editForm/Form.edit.form.js +2 -2
  51. package/lib/cjs/components/select/Select.d.ts +0 -1
  52. package/lib/cjs/components/select/Select.js +3 -23
  53. package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -2
  54. package/lib/cjs/components/tags/Tags.d.ts +1 -1
  55. package/lib/cjs/components/tags/Tags.js +2 -2
  56. package/lib/cjs/providers/storage/googleDrive.js +3 -2
  57. package/lib/cjs/providers/storage/s3.js +3 -3
  58. package/lib/cjs/providers/storage/xhr.d.ts +1 -0
  59. package/lib/cjs/providers/storage/xhr.js +6 -1
  60. package/lib/cjs/utils/ChoicesWrapper.d.ts +4 -25
  61. package/lib/cjs/utils/ChoicesWrapper.js +47 -124
  62. package/lib/cjs/utils/utils.d.ts +2 -1
  63. package/lib/cjs/utils/utils.js +3 -2
  64. package/lib/cjs/widgets/CalendarWidget.js +0 -14
  65. package/lib/mjs/Embed.js +1 -1
  66. package/lib/mjs/Form.d.ts +2 -4
  67. package/lib/mjs/Form.js +4 -2
  68. package/lib/mjs/Formio.js +1 -1
  69. package/lib/mjs/PDFBuilder.js +2 -2
  70. package/lib/mjs/Webform.d.ts +5 -2
  71. package/lib/mjs/Webform.js +31 -16
  72. package/lib/mjs/WebformBuilder.d.ts +1 -0
  73. package/lib/mjs/WebformBuilder.js +13 -2
  74. package/lib/mjs/Wizard.js +2 -1
  75. package/lib/mjs/WizardBuilder.js +14 -1
  76. package/lib/mjs/components/Components.d.ts +3 -0
  77. package/lib/mjs/components/_classes/component/Component.js +12 -2
  78. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  79. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +37 -0
  80. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +13 -2
  81. package/lib/mjs/components/_classes/component/editForm/utils.d.ts +1 -0
  82. package/lib/mjs/components/_classes/component/editForm/utils.js +3 -0
  83. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
  84. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +3 -0
  85. package/lib/mjs/components/address/Address.js +1 -1
  86. package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
  87. package/lib/mjs/components/datetime/DateTime.js +5 -5
  88. package/lib/mjs/components/day/Day.js +7 -5
  89. package/lib/mjs/components/file/File.js +2 -1
  90. package/lib/mjs/components/form/Form.d.ts +4 -2
  91. package/lib/mjs/components/form/Form.js +25 -10
  92. package/lib/mjs/components/form/editForm/Form.edit.data.js +1 -1
  93. package/lib/mjs/components/form/editForm/Form.edit.form.js +2 -2
  94. package/lib/mjs/components/select/Select.d.ts +0 -1
  95. package/lib/mjs/components/select/Select.js +3 -22
  96. package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -2
  97. package/lib/mjs/components/tags/Tags.d.ts +1 -1
  98. package/lib/mjs/components/tags/Tags.js +2 -2
  99. package/lib/mjs/providers/storage/googleDrive.js +3 -2
  100. package/lib/mjs/providers/storage/s3.js +3 -3
  101. package/lib/mjs/providers/storage/xhr.d.ts +1 -0
  102. package/lib/mjs/providers/storage/xhr.js +6 -1
  103. package/lib/mjs/utils/ChoicesWrapper.d.ts +4 -25
  104. package/lib/mjs/utils/ChoicesWrapper.js +26 -119
  105. package/lib/mjs/utils/utils.d.ts +2 -1
  106. package/lib/mjs/utils/utils.js +3 -2
  107. package/lib/mjs/widgets/CalendarWidget.js +0 -14
  108. package/package.json +3 -3
package/lib/mjs/Form.js CHANGED
@@ -51,7 +51,7 @@ export default class Form extends Element {
51
51
  * @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
52
52
  * @property {boolean} [readOnly] - Set this form to readOnly.
53
53
  * @property {boolean} [noAlerts] - Disable the alerts dialog.
54
- * @property {{[key: string]: string}} [i18n] - The translation file for this rendering.
54
+ * @property {Record<string, Record<string, string>>} [i18n] - The translation file for this rendering.
55
55
  * @property {string} [template] - Custom logic for creation of elements.
56
56
  * @property {boolean} [noDefaults] - Exclude default values from the settings.
57
57
  * @property {any} [fileService] - The file service for this form.
@@ -350,7 +350,9 @@ export default class Form extends Element {
350
350
  this.form.display = display;
351
351
  this.instance.destroy();
352
352
  this.instance = this.create(display);
353
- return this.setForm(this.form);
353
+ return this.setForm(this.form).then(() => {
354
+ this.instance.emit('setDisplay', this.form.display);
355
+ });
354
356
  }
355
357
  empty() {
356
358
  if (this.element) {
package/lib/mjs/Formio.js CHANGED
@@ -4,7 +4,7 @@ import CDN from './CDN';
4
4
  import Providers from './providers';
5
5
  FormioCore.cdn = new CDN();
6
6
  FormioCore.Providers = Providers;
7
- FormioCore.version = '5.1.0-dev.1';
7
+ FormioCore.version = '5.1.0-dev.2';
8
8
  CDN.defaultCDN = FormioCore.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
9
9
  const isNil = (val) => val === null || val === undefined;
10
10
  FormioCore.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
@@ -294,7 +294,7 @@ export default class PDFBuilder extends WebformBuilder {
294
294
  height: schema.height,
295
295
  width: schema.width
296
296
  };
297
- if (!this.options.noNewEdit && !component.component.noNewEdit) {
297
+ if (!this.options.noNewEdit && !component.component.noNewEdit && this.hasEditTabs(component.type)) {
298
298
  this.editComponent(component.component, this.getParentContainer(component), isNew);
299
299
  }
300
300
  this.emit('updateComponent', component.component);
@@ -318,7 +318,7 @@ export default class PDFBuilder extends WebformBuilder {
318
318
  });
319
319
  this.webform.on('iframe-componentClick', schema => {
320
320
  const component = this.webform.getComponentById(schema.id);
321
- if (component) {
321
+ if (component && this.hasEditTabs(component.type)) {
322
322
  this.editComponent(component.component, this.getParentContainer(component));
323
323
  }
324
324
  }, true);
@@ -190,7 +190,10 @@ declare class Webform extends NestedDataComponent {
190
190
  get language(): string;
191
191
  root: this;
192
192
  localRoot: this;
193
+ beforeInit(): void;
194
+ executeFormController: any;
193
195
  get emptyValue(): null;
196
+ get shouldCallFormController(): any;
194
197
  get shadowRoot(): any;
195
198
  /**
196
199
  * Add a language for translations
@@ -360,7 +363,7 @@ declare class Webform extends NestedDataComponent {
360
363
  * @returns {Promise} - The promise that is triggered when the form is built.
361
364
  */
362
365
  init(): Promise<any>;
363
- executeFormController(): false | undefined;
366
+ _executeFormController(): void;
364
367
  build(element: any): Promise<any>;
365
368
  getClassName(): string;
366
369
  render(): string;
@@ -452,7 +455,7 @@ declare class Webform extends NestedDataComponent {
452
455
  */
453
456
  submit(before?: boolean, options?: any): Promise<any>;
454
457
  submitUrl(URL: any, headers: any): void;
455
- triggerCaptcha(): void;
458
+ triggerCaptcha(components?: null): void;
456
459
  _nosubmit: any;
457
460
  get conditions(): any;
458
461
  get variables(): any;
@@ -287,12 +287,24 @@ export default class Webform extends NestedDataComponent {
287
287
  this.localRoot = this;
288
288
  }
289
289
  /* eslint-enable max-statements */
290
+ beforeInit() {
291
+ this.executeFormController = _.once(this._executeFormController);
292
+ }
290
293
  get language() {
291
294
  return this.options.language;
292
295
  }
293
296
  get emptyValue() {
294
297
  return null;
295
298
  }
299
+ get shouldCallFormController() {
300
+ // If no controller value or
301
+ // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
302
+ return (this.form &&
303
+ this.form.controller &&
304
+ !((!this.visible || this.component.hidden) &&
305
+ this.component.clearOnHide &&
306
+ !this.rootPristine));
307
+ }
296
308
  componentContext() {
297
309
  return this._data;
298
310
  }
@@ -902,19 +914,12 @@ export default class Webform extends NestedDataComponent {
902
914
  this.on('resetForm', () => this.resetValue(), true);
903
915
  this.on('deleteSubmission', () => this.deleteSubmission(), true);
904
916
  this.on('refreshData', () => this.updateValue(), true);
905
- this.executeFormController();
917
+ if (this.shouldCallFormController) {
918
+ this.executeFormController();
919
+ }
906
920
  return this.formReady;
907
921
  }
908
- executeFormController() {
909
- // If no controller value or
910
- // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
911
- if (!this.form ||
912
- !this.form.controller ||
913
- ((!this.visible || this.component.hidden) &&
914
- this.component.clearOnHide &&
915
- !this.rootPristine)) {
916
- return false;
917
- }
922
+ _executeFormController() {
918
923
  this.formReady.then(() => {
919
924
  this.evaluate(this.form.controller, {
920
925
  components: this.components,
@@ -1529,18 +1534,28 @@ export default class Webform extends NestedDataComponent {
1529
1534
  return console.warn(message);
1530
1535
  }
1531
1536
  }
1532
- triggerCaptcha() {
1533
- if (!this || !this.components) {
1537
+ triggerCaptcha(components = null) {
1538
+ if (!this || !this.components || this.options.preview) {
1534
1539
  return;
1535
1540
  }
1536
1541
  const captchaComponent = [];
1537
- this.eachComponent((component) => {
1542
+ eachComponent(components || this.components, (component) => {
1538
1543
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1539
1544
  captchaComponent.push(component);
1540
1545
  }
1541
- });
1546
+ }, true);
1542
1547
  if (captchaComponent.length > 0) {
1543
- captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1548
+ if (captchaComponent[0].component.provider === 'google' && components) {
1549
+ return;
1550
+ }
1551
+ if (this.parent) {
1552
+ this.parent.subFormReady.then(() => {
1553
+ captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1554
+ });
1555
+ }
1556
+ else {
1557
+ captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1558
+ }
1544
1559
  }
1545
1560
  }
1546
1561
  set nosubmit(value) {
@@ -123,6 +123,7 @@ export default class WebformBuilder extends Component {
123
123
  addBuilderGroup(name: any, group: any): void;
124
124
  updateBuilderGroup(name: any, group: any): void;
125
125
  generateKey(info: any): any;
126
+ hasEditTabs(type: any): boolean;
126
127
  }
127
128
  import Component from './components/_classes/component/Component';
128
129
  import Webform from './Webform';
@@ -115,7 +115,9 @@ export default class WebformBuilder extends Component {
115
115
  html,
116
116
  disableBuilderActions: self?.component?.disableBuilderActions,
117
117
  childComponent: component,
118
- design: self?.options?.design
118
+ design: self?.options?.design,
119
+ editJson: self?.options?.editJson,
120
+ editComponent: this.hasEditTabs(component.type)
119
121
  });
120
122
  };
121
123
  this.options.hooks.renderComponents = (html, { components, self }) => {
@@ -840,7 +842,11 @@ export default class WebformBuilder extends Component {
840
842
  parent.addChildComponent(info, element, target, source, sibling);
841
843
  }
842
844
  const componentInDataGrid = parent.type === 'datagrid';
843
- if (isNew && !this.options.noNewEdit && !info.noNewEdit && !(this.options.design && info.type === 'reviewpage')) {
845
+ if (isNew
846
+ && !this.options.noNewEdit
847
+ && !info.noNewEdit
848
+ && this.hasEditTabs(info.type)
849
+ && !(this.options.design && info.type === 'reviewpage')) {
844
850
  this.editComponent(info, target, isNew, null, null, { inDataGrid: componentInDataGrid });
845
851
  }
846
852
  // Only rebuild the parts needing to be rebuilt.
@@ -1619,4 +1625,9 @@ export default class WebformBuilder extends Component {
1619
1625
  info.placeholder ||
1620
1626
  info.type);
1621
1627
  }
1628
+ hasEditTabs(type) {
1629
+ const editTabs = getComponent(Components.components[type].editForm().components, 'tabs', true).components;
1630
+ const hiddenEditTabs = _.filter(_.get(this.options, `editForm.${type}`, []), 'ignore');
1631
+ return _.intersectionBy(editTabs, hiddenEditTabs, 'key').length !== editTabs.length;
1632
+ }
1622
1633
  }
package/lib/mjs/Wizard.js CHANGED
@@ -594,6 +594,7 @@ export default class Wizard extends Webform {
594
594
  }
595
595
  this.redraw().then(() => {
596
596
  this.checkData(this.submission.data);
597
+ this.triggerCaptcha(this.currentPanel.components);
597
598
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
598
599
  if (this.alert) {
599
600
  this.showErrors(errors, true, true);
@@ -657,7 +658,7 @@ export default class Wizard extends Webform {
657
658
  return this.page - 1;
658
659
  }
659
660
  beforeSubmit() {
660
- const pages = this.getPages();
661
+ const pages = this.getPages({ all: true });
661
662
  return Promise.all(pages.map((page) => {
662
663
  page.options.beforeSubmit = true;
663
664
  return page.beforeSubmit();
@@ -255,10 +255,23 @@ export default class WizardBuilder extends WebformBuilder {
255
255
  if (component instanceof WizardBuilder) {
256
256
  return;
257
257
  }
258
+ if (!window.sessionStorage) {
259
+ return console.warn(this.t('sessionStorageSupportError'));
260
+ }
261
+ // If pasting after the Wizard's page, check if a full Wizard page was copied and pass it to addPage method
258
262
  if (this._form.components.find(comp => _.isEqual(component.component, comp))) {
259
- this.addPage(component);
263
+ const data = window.sessionStorage.getItem('formio.clipboard');
264
+ if (data) {
265
+ const schema = JSON.parse(data);
266
+ // If the copied component is not a Wizard's page, do nothing since we can't paste outside the panel in Wizard
267
+ if (schema.type !== 'panel') {
268
+ return;
269
+ }
270
+ this.addPage(schema);
271
+ }
260
272
  }
261
273
  else {
274
+ // If we are not trying to paster after the current Wizard's page, just pass it to the WebformBuilder
262
275
  return super.pasteComponent(component);
263
276
  }
264
277
  }
@@ -2,6 +2,7 @@ export default class Components {
2
2
  static _editFormUtils: {
3
3
  sortAndFilterComponents(components: any): any;
4
4
  unifyComponents(objValue: any, srcValue: any): any;
5
+ tokenVariableDescription(): string;
5
6
  logicVariablesTable(additional: any): {
6
7
  type: string;
7
8
  tag: string;
@@ -86,6 +87,7 @@ export default class Components {
86
87
  static set EditFormUtils(value: {
87
88
  sortAndFilterComponents(components: any): any;
88
89
  unifyComponents(objValue: any, srcValue: any): any;
90
+ tokenVariableDescription(): string;
89
91
  logicVariablesTable(additional: any): {
90
92
  type: string;
91
93
  tag: string;
@@ -169,6 +171,7 @@ export default class Components {
169
171
  static get EditFormUtils(): {
170
172
  sortAndFilterComponents(components: any): any;
171
173
  unifyComponents(objValue: any, srcValue: any): any;
174
+ tokenVariableDescription(): string;
172
175
  logicVariablesTable(additional: any): {
173
176
  type: string;
174
177
  tag: string;
@@ -161,6 +161,7 @@ export default class Component extends Element {
161
161
  properties: {},
162
162
  allowMultipleMasks: false,
163
163
  addons: [],
164
+ serverOverride: {},
164
165
  }, ...sources);
165
166
  }
166
167
  /**
@@ -418,6 +419,9 @@ export default class Component extends Element {
418
419
  // Allow anyone to hook into the component creation.
419
420
  this.hook('component');
420
421
  if (!this.options.skipInit) {
422
+ if (typeof this.beforeInit === 'function') {
423
+ this.beforeInit();
424
+ }
421
425
  this.init();
422
426
  }
423
427
  }
@@ -1264,7 +1268,7 @@ export default class Component extends Element {
1264
1268
  detach() {
1265
1269
  // First iterate through each ref and delete the component so there are no dangling component references.
1266
1270
  _.each(this.refs, (ref) => {
1267
- if (typeof ref === NodeList) {
1271
+ if (ref instanceof NodeList) {
1268
1272
  ref.forEach((elem) => {
1269
1273
  delete elem.component;
1270
1274
  });
@@ -1914,15 +1918,21 @@ export default class Component extends Element {
1914
1918
  }
1915
1919
  // Check advanced conditions (and cache the result)
1916
1920
  const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1921
+ let shouldClear = false;
1917
1922
  if (isConditionallyHidden !== this._conditionallyHidden) {
1918
1923
  this._conditionallyHidden = isConditionallyHidden;
1919
- this.clearOnHide();
1924
+ shouldClear = true;
1920
1925
  }
1921
1926
  // Check visibility
1922
1927
  const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1923
1928
  if (this.visible !== visible) {
1924
1929
  this.visible = visible;
1925
1930
  }
1931
+ // Wait for visibility to update for nested components, so the component state is up-to-date when
1932
+ // calling clearOnHide
1933
+ if (shouldClear) {
1934
+ this.clearOnHide();
1935
+ }
1926
1936
  return visible;
1927
1937
  }
1928
1938
  /**
@@ -45,6 +45,6 @@ export default [
45
45
  },
46
46
  EditFormUtils.javaScriptValue('Advanced Conditions', 'customConditional', 'conditional.json', 110, '<p>You must assign the <strong>show</strong> variable a boolean result.</p>' +
47
47
  '<p><strong>Note: Advanced Conditional logic will override the results of the Simple Conditional logic.</strong></p>' +
48
- '<h5>Example</h5><pre>show = !!data.showMe;</pre>', '<p><a href="https://help.form.io/userguide/form-building/logic-and-conditions" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>')
48
+ '<h5>Example</h5><pre>show = !!data.showMe;</pre>', '<p><a href="https://help.form.io/userguide/form-building/logic-and-conditions" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', EditFormUtils.tokenVariableDescription())
49
49
  ];
50
50
  /* eslint-enable quotes, max-len */
@@ -87,6 +87,9 @@ declare const _default: ({
87
87
  valueProperty?: undefined;
88
88
  data?: undefined;
89
89
  conditional?: undefined;
90
+ as?: undefined;
91
+ editor?: undefined;
92
+ description?: undefined;
90
93
  } | {
91
94
  type: string;
92
95
  label: string;
@@ -103,6 +106,9 @@ declare const _default: ({
103
106
  valueProperty?: undefined;
104
107
  data?: undefined;
105
108
  conditional?: undefined;
109
+ as?: undefined;
110
+ editor?: undefined;
111
+ description?: undefined;
106
112
  } | {
107
113
  weight: number;
108
114
  type: string;
@@ -125,6 +131,9 @@ declare const _default: ({
125
131
  valueProperty?: undefined;
126
132
  data?: undefined;
127
133
  conditional?: undefined;
134
+ as?: undefined;
135
+ editor?: undefined;
136
+ description?: undefined;
128
137
  } | {
129
138
  weight: number;
130
139
  type: string;
@@ -173,6 +182,9 @@ declare const _default: ({
173
182
  valueProperty?: undefined;
174
183
  data?: undefined;
175
184
  conditional?: undefined;
185
+ as?: undefined;
186
+ editor?: undefined;
187
+ description?: undefined;
176
188
  } | {
177
189
  type: string;
178
190
  input: boolean;
@@ -200,6 +212,9 @@ declare const _default: ({
200
212
  defaultValue?: undefined;
201
213
  values?: undefined;
202
214
  logic?: undefined;
215
+ as?: undefined;
216
+ editor?: undefined;
217
+ description?: undefined;
203
218
  } | {
204
219
  weight: number;
205
220
  type: string;
@@ -216,5 +231,27 @@ declare const _default: ({
216
231
  valueProperty?: undefined;
217
232
  data?: undefined;
218
233
  conditional?: undefined;
234
+ as?: undefined;
235
+ editor?: undefined;
236
+ description?: undefined;
237
+ } | {
238
+ type: string;
239
+ as: string;
240
+ editor: string;
241
+ weight: number;
242
+ input: boolean;
243
+ key: string;
244
+ label: string;
245
+ tooltip: string;
246
+ defaultValue: {};
247
+ description: string;
248
+ placeholder?: undefined;
249
+ inline?: undefined;
250
+ values?: undefined;
251
+ logic?: undefined;
252
+ dataSrc?: undefined;
253
+ valueProperty?: undefined;
254
+ data?: undefined;
255
+ conditional?: undefined;
219
256
  })[];
220
257
  export default _default;
@@ -135,7 +135,7 @@ export default [
135
135
  input: true
136
136
  },
137
137
  EditFormUtils.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 1000, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),
138
- EditFormUtils.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="https://help.form.io/userguide/form-building/logic-and-conditions#calculated-values" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>'),
138
+ EditFormUtils.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="https://help.form.io/userguide/form-building/logic-and-conditions#calculated-values" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', EditFormUtils.tokenVariableDescription()),
139
139
  {
140
140
  type: 'checkbox',
141
141
  input: true,
@@ -152,5 +152,16 @@ export default [
152
152
  label: 'Allow Manual Override of Calculated Value',
153
153
  tooltip: 'When checked, this will allow the user to manually override the calculated value.'
154
154
  },
155
+ {
156
+ type: 'textarea',
157
+ as: 'json',
158
+ editor: 'ace',
159
+ weight: 1400,
160
+ input: true,
161
+ key: 'serverOverride',
162
+ label: 'Server Override',
163
+ tooltip: 'A JSON object containing the component settings that should be overriden when the form submission is processed on the server side.',
164
+ defaultValue: {},
165
+ description: '<b>Example</b>: { "clearOnHide": true }',
166
+ }
155
167
  ];
156
- /* eslint-enable max-len */
@@ -2,6 +2,7 @@ export default EditFormUtils;
2
2
  declare namespace EditFormUtils {
3
3
  function sortAndFilterComponents(components: any): any;
4
4
  function unifyComponents(objValue: any, srcValue: any): any;
5
+ function tokenVariableDescription(): string;
5
6
  function logicVariablesTable(additional: any): {
6
7
  type: string;
7
8
  tag: string;
@@ -32,6 +32,9 @@ const EditFormUtils = {
32
32
  }
33
33
  return _.isEqual(objValue, srcValue);
34
34
  },
35
+ tokenVariableDescription() {
36
+ return '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>';
37
+ },
35
38
  logicVariablesTable(additional) {
36
39
  additional = additional || '';
37
40
  return {
@@ -3,6 +3,7 @@ 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;
6
7
  componentContext(): any;
7
8
  getValueAsString(value: any, options: any): string;
8
9
  getDataValueAsTable(value: any, options: any): string;
@@ -22,6 +22,9 @@ export default class NestedDataComponent extends NestedComponent {
22
22
  get emptyValue() {
23
23
  return {};
24
24
  }
25
+ get shouldAddDefaultValue() {
26
+ return !this.options.noDefaults || !this.options.server;
27
+ }
25
28
  componentContext() {
26
29
  return this.dataValue;
27
30
  }
@@ -214,7 +214,7 @@ export default class AddressComponent extends ContainerComponent {
214
214
  super.dataValue = value;
215
215
  }
216
216
  get dataValue() {
217
- const resultValue = _.get(this._data, this.component.path);
217
+ const resultValue = _.get(this._data, this.path);
218
218
  if (!_.isArray(resultValue) && this.component.multiple) {
219
219
  return [resultValue];
220
220
  }
@@ -20,6 +20,6 @@ export default class DateTimeComponent extends Input {
20
20
  get momentFormat(): string;
21
21
  createWrapper(): boolean;
22
22
  checkValidity(data: any, dirty: any, rowData: any): boolean;
23
- getValueAsString(value: any): any;
23
+ getValueAsString(value: any, options: any): any;
24
24
  }
25
25
  import Input from '../_classes/input/Input';
@@ -128,8 +128,8 @@ export default class DateTimeComponent extends Input {
128
128
  ...customOptions,
129
129
  };
130
130
  // update originalComponent to include widget and other updated settings
131
- // it is done here since these settings depend on properties present after the component is initialized
132
- // originalComponent is used to restore the component (and widget) after evaluating field logic
131
+ // it is done here since these settings depend on properties present after the component is initialized
132
+ // originalComponent is used to restore the component (and widget) after evaluating field logic
133
133
  this.originalComponent = fastCloneDeep(this.component);
134
134
  /* eslint-enable camelcase */
135
135
  }
@@ -177,15 +177,15 @@ export default class DateTimeComponent extends Input {
177
177
  }
178
178
  return super.checkValidity(data, dirty, rowData);
179
179
  }
180
- getValueAsString(value) {
180
+ getValueAsString(value, options) {
181
181
  let format = FormioUtils.convertFormatToMoment(this.component.format);
182
182
  format += format.match(/z$/) ? '' : ' z';
183
183
  const timezone = this.timezone;
184
184
  if (value && !this.attached && timezone) {
185
185
  if (Array.isArray(value) && this.component.multiple) {
186
- return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone).format(format))).join(', ');
186
+ return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone, options).format(format))).join(', ');
187
187
  }
188
- return _.trim(FormioUtils.momentDate(value, format, timezone).format(format));
188
+ return _.trim(FormioUtils.momentDate(value, format, timezone, options).format(format));
189
189
  }
190
190
  if (Array.isArray(value) && this.component.multiple) {
191
191
  return value.map(item => _.trim(moment(item).format(format))).join(', ');
@@ -53,11 +53,13 @@ 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 (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
57
- component.maxDate = moment(component.maxDate, 'YYYY-MM-DD').toISOString();
58
- }
59
- if (component.minDate && component.minDate.indexOf('moment(') === -1) {
60
- component.minDate = moment(component.minDate, 'YYYY-MM-DD').toISOString();
56
+ if (!options.inFormBuilder && !options.building) {
57
+ if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
58
+ component.maxDate = moment(component.maxDate, 'YYYY-MM-DD').toISOString();
59
+ }
60
+ if (component.minDate && component.minDate.indexOf('moment(') === -1) {
61
+ component.minDate = moment(component.minDate, 'YYYY-MM-DD').toISOString();
62
+ }
61
63
  }
62
64
  super(component, options, data);
63
65
  }
@@ -98,7 +98,8 @@ export default class FileComponent extends Field {
98
98
  if (this.component.privateDownload) {
99
99
  fileInfo.private = true;
100
100
  }
101
- return this.fileService.downloadFile(fileInfo).then((result) => result.url);
101
+ // pass the component to the downloadFile method
102
+ return this.fileService.downloadFile(fileInfo, this.component).then((result) => result.url);
102
103
  }
103
104
  get emptyValue() {
104
105
  return [];
@@ -45,16 +45,18 @@ export default class FormComponent extends Component {
45
45
  /**
46
46
  * Create a subform instance.
47
47
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
48
+ * @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
48
49
  * @returns {*} - The subform instance.
49
50
  */
50
- createSubForm(fromAttach?: boolean | undefined): any;
51
+ createSubForm(fromAttach?: boolean | undefined, beforeSubmit?: boolean | undefined): any;
51
52
  hideSubmitButton(component: any): void;
52
53
  /**
53
54
  * Load the subform.
54
55
  * @param {boolean} fromAttach - This function is being called from an `attach` method.
56
+ * @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
55
57
  * @returns {Promise} - The promise that resolves when the subform is loaded.
56
58
  */
57
- loadSubForm(fromAttach: boolean): Promise<any>;
59
+ loadSubForm(fromAttach: boolean, beforeSubmit: boolean): Promise<any>;
58
60
  subFormLoading: boolean | undefined;
59
61
  checkComponentConditions(data: any, flags: any, row: any): any;
60
62
  calculateValue(data: any, flags: any, row: any): any;
@@ -375,10 +375,11 @@ export default class FormComponent extends Component {
375
375
  /**
376
376
  * Create a subform instance.
377
377
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
378
+ * @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
378
379
  * @returns {*} - The subform instance.
379
380
  */
380
- createSubForm(fromAttach) {
381
- this.subFormReady = this.loadSubForm(fromAttach).then((form) => {
381
+ createSubForm(fromAttach, beforeSubmit) {
382
+ this.subFormReady = this.loadSubForm(fromAttach, beforeSubmit).then((form) => {
382
383
  if (!form) {
383
384
  return;
384
385
  }
@@ -435,10 +436,12 @@ export default class FormComponent extends Component {
435
436
  /**
436
437
  * Load the subform.
437
438
  * @param {boolean} fromAttach - This function is being called from an `attach` method.
439
+ * @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
438
440
  * @returns {Promise} - The promise that resolves when the subform is loaded.
439
441
  */
440
- loadSubForm(fromAttach) {
441
- if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
442
+ loadSubForm(fromAttach, beforeSubmit) {
443
+ const loadHiddenForm = beforeSubmit && !this.component.clearOnHide;
444
+ if (this.builderMode || (this.conditionallyHidden && !loadHiddenForm) || (this.isSubFormLazyLoad() && !fromAttach)) {
442
445
  return Promise.resolve();
443
446
  }
444
447
  if (this.hasLoadedForm && !this.isRevisionChanged &&
@@ -510,7 +513,7 @@ export default class FormComponent extends Component {
510
513
  * @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
511
514
  */
512
515
  get shouldSubmit() {
513
- return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
516
+ return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && (!this.conditionallyHidden || !this.component.clearOnHide);
514
517
  }
515
518
  /**
516
519
  * Returns the data for the subform.
@@ -580,11 +583,23 @@ export default class FormComponent extends Component {
580
583
  this.dataValue = submission;
581
584
  return Promise.resolve(this.dataValue);
582
585
  }
583
- return this.submitSubForm(false)
584
- .then(() => {
585
- return this.dataValue;
586
- })
587
- .then(() => super.beforeSubmit());
586
+ // we need to load a hidden form (when clearOnHide is disabled) in order to get and submit (if needed) its data
587
+ const loadHiddenForm = !this.subForm && !this.component.clearOnHide;
588
+ if ((this.isSubFormLazyLoad() || loadHiddenForm) && !this.subFormLoading) {
589
+ return this.createSubForm(true, true)
590
+ .then(this.submitSubForm(false))
591
+ .then(() => {
592
+ return this.dataValue;
593
+ })
594
+ .then(() => super.beforeSubmit());
595
+ }
596
+ else {
597
+ return this.submitSubForm(false)
598
+ .then(() => {
599
+ return this.dataValue;
600
+ })
601
+ .then(() => super.beforeSubmit());
602
+ }
588
603
  }
589
604
  isSubFormLazyLoad() {
590
605
  return this.root?._form?.display === 'wizard' && this.component.lazyLoad;