@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
@@ -20,7 +20,7 @@
20
20
 
21
21
  /*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */
22
22
 
23
- /*! formiojs v5.1.0-dev.1 | https://unpkg.com/formiojs@5.1.0-dev.1/LICENSE.txt */
23
+ /*! formiojs v5.1.0-dev.2 | https://unpkg.com/formiojs@5.1.0-dev.2/LICENSE.txt */
24
24
 
25
25
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
26
26
 
package/lib/cjs/Embed.js CHANGED
@@ -418,7 +418,7 @@ Formio.formioReady = new Promise((ready, reject) => {
418
418
  _a._formioReady = ready;
419
419
  _a._formioReadyReject = reject;
420
420
  });
421
- Formio.version = '5.1.0-dev.1';
421
+ Formio.version = '5.1.0-dev.2';
422
422
  // Create a report.
423
423
  Formio.Report = {
424
424
  create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
package/lib/cjs/Form.d.ts CHANGED
@@ -48,7 +48,7 @@ export default class Form extends Element {
48
48
  * @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
49
49
  * @property {boolean} [readOnly] - Set this form to readOnly.
50
50
  * @property {boolean} [noAlerts] - Disable the alerts dialog.
51
- * @property {{[key: string]: string}} [i18n] - The translation file for this rendering.
51
+ * @property {Record<string, Record<string, string>>} [i18n] - The translation file for this rendering.
52
52
  * @property {string} [template] - Custom logic for creation of elements.
53
53
  * @property {boolean} [noDefaults] - Exclude default values from the settings.
54
54
  * @property {any} [fileService] - The file service for this form.
@@ -117,9 +117,7 @@ export default class Form extends Element {
117
117
  /**
118
118
  * - The translation file for this rendering.
119
119
  */
120
- i18n?: {
121
- [key: string]: string;
122
- } | undefined;
120
+ i18n?: Record<string, Record<string, string>> | undefined;
123
121
  /**
124
122
  * - Custom logic for creation of elements.
125
123
  */
package/lib/cjs/Form.js CHANGED
@@ -281,7 +281,9 @@ class Form extends Element_1.default {
281
281
  this.form.display = display;
282
282
  this.instance.destroy();
283
283
  this.instance = this.create(display);
284
- return this.setForm(this.form);
284
+ return this.setForm(this.form).then(() => {
285
+ this.instance.emit('setDisplay', this.form.display);
286
+ });
285
287
  }
286
288
  empty() {
287
289
  if (this.element) {
package/lib/cjs/Formio.js CHANGED
@@ -11,7 +11,7 @@ const CDN_1 = __importDefault(require("./CDN"));
11
11
  const providers_1 = __importDefault(require("./providers"));
12
12
  sdk_1.Formio.cdn = new CDN_1.default();
13
13
  sdk_1.Formio.Providers = providers_1.default;
14
- sdk_1.Formio.version = '5.1.0-dev.1';
14
+ sdk_1.Formio.version = '5.1.0-dev.2';
15
15
  CDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
16
16
  const isNil = (val) => val === null || val === undefined;
17
17
  sdk_1.Formio.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
@@ -300,7 +300,7 @@ class PDFBuilder extends WebformBuilder_1.default {
300
300
  height: schema.height,
301
301
  width: schema.width
302
302
  };
303
- if (!this.options.noNewEdit && !component.component.noNewEdit) {
303
+ if (!this.options.noNewEdit && !component.component.noNewEdit && this.hasEditTabs(component.type)) {
304
304
  this.editComponent(component.component, this.getParentContainer(component), isNew);
305
305
  }
306
306
  this.emit('updateComponent', component.component);
@@ -324,7 +324,7 @@ class PDFBuilder extends WebformBuilder_1.default {
324
324
  });
325
325
  this.webform.on('iframe-componentClick', schema => {
326
326
  const component = this.webform.getComponentById(schema.id);
327
- if (component) {
327
+ if (component && this.hasEditTabs(component.type)) {
328
328
  this.editComponent(component.component, this.getParentContainer(component));
329
329
  }
330
330
  }, 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;
@@ -315,12 +315,24 @@ class Webform extends NestedDataComponent_1.default {
315
315
  this.localRoot = this;
316
316
  }
317
317
  /* eslint-enable max-statements */
318
+ beforeInit() {
319
+ this.executeFormController = lodash_1.default.once(this._executeFormController);
320
+ }
318
321
  get language() {
319
322
  return this.options.language;
320
323
  }
321
324
  get emptyValue() {
322
325
  return null;
323
326
  }
327
+ get shouldCallFormController() {
328
+ // If no controller value or
329
+ // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
330
+ return (this.form &&
331
+ this.form.controller &&
332
+ !((!this.visible || this.component.hidden) &&
333
+ this.component.clearOnHide &&
334
+ !this.rootPristine));
335
+ }
324
336
  componentContext() {
325
337
  return this._data;
326
338
  }
@@ -899,19 +911,12 @@ class Webform extends NestedDataComponent_1.default {
899
911
  this.on('resetForm', () => this.resetValue(), true);
900
912
  this.on('deleteSubmission', () => this.deleteSubmission(), true);
901
913
  this.on('refreshData', () => this.updateValue(), true);
902
- this.executeFormController();
914
+ if (this.shouldCallFormController) {
915
+ this.executeFormController();
916
+ }
903
917
  return this.formReady;
904
918
  }
905
- executeFormController() {
906
- // If no controller value or
907
- // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
908
- if (!this.form ||
909
- !this.form.controller ||
910
- ((!this.visible || this.component.hidden) &&
911
- this.component.clearOnHide &&
912
- !this.rootPristine)) {
913
- return false;
914
- }
919
+ _executeFormController() {
915
920
  this.formReady.then(() => {
916
921
  this.evaluate(this.form.controller, {
917
922
  components: this.components,
@@ -1529,18 +1534,28 @@ class Webform extends NestedDataComponent_1.default {
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
+ (0, formUtils_1.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';
@@ -123,7 +123,7 @@ class WebformBuilder extends Component_1.default {
123
123
  }
124
124
  this.options.hooks = this.options.hooks || {};
125
125
  this.options.hooks.renderComponent = (html, { component, self }) => {
126
- var _a, _b;
126
+ var _a, _b, _c;
127
127
  if (self.type === 'form' && !self.key) {
128
128
  const template = this.hook('renderComponentFormTemplate', html.replace('formio-component-form', ''));
129
129
  // The main webform shouldn't have this class as it adds extra styles.
@@ -136,7 +136,9 @@ class WebformBuilder extends Component_1.default {
136
136
  html,
137
137
  disableBuilderActions: (_a = self === null || self === void 0 ? void 0 : self.component) === null || _a === void 0 ? void 0 : _a.disableBuilderActions,
138
138
  childComponent: component,
139
- design: (_b = self === null || self === void 0 ? void 0 : self.options) === null || _b === void 0 ? void 0 : _b.design
139
+ design: (_b = self === null || self === void 0 ? void 0 : self.options) === null || _b === void 0 ? void 0 : _b.design,
140
+ editJson: (_c = self === null || self === void 0 ? void 0 : self.options) === null || _c === void 0 ? void 0 : _c.editJson,
141
+ editComponent: this.hasEditTabs(component.type)
140
142
  });
141
143
  };
142
144
  this.options.hooks.renderComponents = (html, { components, self }) => {
@@ -855,7 +857,11 @@ class WebformBuilder extends Component_1.default {
855
857
  parent.addChildComponent(info, element, target, source, sibling);
856
858
  }
857
859
  const componentInDataGrid = parent.type === 'datagrid';
858
- if (isNew && !this.options.noNewEdit && !info.noNewEdit && !(this.options.design && info.type === 'reviewpage')) {
860
+ if (isNew
861
+ && !this.options.noNewEdit
862
+ && !info.noNewEdit
863
+ && this.hasEditTabs(info.type)
864
+ && !(this.options.design && info.type === 'reviewpage')) {
859
865
  this.editComponent(info, target, isNew, null, null, { inDataGrid: componentInDataGrid });
860
866
  }
861
867
  // Only rebuild the parts needing to be rebuilt.
@@ -1616,5 +1622,10 @@ class WebformBuilder extends Component_1.default {
1616
1622
  info.placeholder ||
1617
1623
  info.type);
1618
1624
  }
1625
+ hasEditTabs(type) {
1626
+ const editTabs = (0, formUtils_1.getComponent)(Components_1.default.components[type].editForm().components, 'tabs', true).components;
1627
+ const hiddenEditTabs = lodash_1.default.filter(lodash_1.default.get(this.options, `editForm.${type}`, []), 'ignore');
1628
+ return lodash_1.default.intersectionBy(editTabs, hiddenEditTabs, 'key').length !== editTabs.length;
1629
+ }
1619
1630
  }
1620
1631
  exports.default = WebformBuilder;
package/lib/cjs/Wizard.js CHANGED
@@ -602,6 +602,7 @@ class Wizard extends Webform_1.default {
602
602
  }
603
603
  this.redraw().then(() => {
604
604
  this.checkData(this.submission.data);
605
+ this.triggerCaptcha(this.currentPanel.components);
605
606
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
606
607
  if (this.alert) {
607
608
  this.showErrors(errors, true, true);
@@ -667,7 +668,7 @@ class Wizard extends Webform_1.default {
667
668
  return this.page - 1;
668
669
  }
669
670
  beforeSubmit() {
670
- const pages = this.getPages();
671
+ const pages = this.getPages({ all: true });
671
672
  return Promise.all(pages.map((page) => {
672
673
  page.options.beforeSubmit = true;
673
674
  return page.beforeSubmit();
@@ -261,10 +261,23 @@ class WizardBuilder extends WebformBuilder_1.default {
261
261
  if (component instanceof WizardBuilder) {
262
262
  return;
263
263
  }
264
+ if (!window.sessionStorage) {
265
+ return console.warn(this.t('sessionStorageSupportError'));
266
+ }
267
+ // If pasting after the Wizard's page, check if a full Wizard page was copied and pass it to addPage method
264
268
  if (this._form.components.find(comp => lodash_1.default.isEqual(component.component, comp))) {
265
- this.addPage(component);
269
+ const data = window.sessionStorage.getItem('formio.clipboard');
270
+ if (data) {
271
+ const schema = JSON.parse(data);
272
+ // If the copied component is not a Wizard's page, do nothing since we can't paste outside the panel in Wizard
273
+ if (schema.type !== 'panel') {
274
+ return;
275
+ }
276
+ this.addPage(schema);
277
+ }
266
278
  }
267
279
  else {
280
+ // If we are not trying to paster after the current Wizard's page, just pass it to the WebformBuilder
268
281
  return super.pasteComponent(component);
269
282
  }
270
283
  }
@@ -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;
@@ -198,6 +198,7 @@ class Component extends Element_1.default {
198
198
  properties: {},
199
199
  allowMultipleMasks: false,
200
200
  addons: [],
201
+ serverOverride: {},
201
202
  }, ...sources);
202
203
  }
203
204
  /**
@@ -453,6 +454,9 @@ class Component extends Element_1.default {
453
454
  // Allow anyone to hook into the component creation.
454
455
  this.hook('component');
455
456
  if (!this.options.skipInit) {
457
+ if (typeof this.beforeInit === 'function') {
458
+ this.beforeInit();
459
+ }
456
460
  this.init();
457
461
  }
458
462
  }
@@ -1296,7 +1300,7 @@ class Component extends Element_1.default {
1296
1300
  detach() {
1297
1301
  // First iterate through each ref and delete the component so there are no dangling component references.
1298
1302
  lodash_1.default.each(this.refs, (ref) => {
1299
- if (typeof ref === NodeList) {
1303
+ if (ref instanceof NodeList) {
1300
1304
  ref.forEach((elem) => {
1301
1305
  delete elem.component;
1302
1306
  });
@@ -1948,15 +1952,21 @@ class Component extends Element_1.default {
1948
1952
  }
1949
1953
  // Check advanced conditions (and cache the result)
1950
1954
  const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1955
+ let shouldClear = false;
1951
1956
  if (isConditionallyHidden !== this._conditionallyHidden) {
1952
1957
  this._conditionallyHidden = isConditionallyHidden;
1953
- this.clearOnHide();
1958
+ shouldClear = true;
1954
1959
  }
1955
1960
  // Check visibility
1956
1961
  const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1957
1962
  if (this.visible !== visible) {
1958
1963
  this.visible = visible;
1959
1964
  }
1965
+ // Wait for visibility to update for nested components, so the component state is up-to-date when
1966
+ // calling clearOnHide
1967
+ if (shouldClear) {
1968
+ this.clearOnHide();
1969
+ }
1960
1970
  return visible;
1961
1971
  }
1962
1972
  /**
@@ -50,6 +50,6 @@ exports.default = [
50
50
  },
51
51
  utils_1.default.javaScriptValue('Advanced Conditions', 'customConditional', 'conditional.json', 110, '<p>You must assign the <strong>show</strong> variable a boolean result.</p>' +
52
52
  '<p><strong>Note: Advanced Conditional logic will override the results of the Simple Conditional logic.</strong></p>' +
53
- '<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>')
53
+ '<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>', utils_1.default.tokenVariableDescription())
54
54
  ];
55
55
  /* 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;
@@ -140,7 +140,7 @@ exports.default = [
140
140
  input: true
141
141
  },
142
142
  utils_1.default.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>'),
143
- utils_1.default.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>'),
143
+ utils_1.default.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>', utils_1.default.tokenVariableDescription()),
144
144
  {
145
145
  type: 'checkbox',
146
146
  input: true,
@@ -157,5 +157,16 @@ exports.default = [
157
157
  label: 'Allow Manual Override of Calculated Value',
158
158
  tooltip: 'When checked, this will allow the user to manually override the calculated value.'
159
159
  },
160
+ {
161
+ type: 'textarea',
162
+ as: 'json',
163
+ editor: 'ace',
164
+ weight: 1400,
165
+ input: true,
166
+ key: 'serverOverride',
167
+ label: 'Server Override',
168
+ tooltip: 'A JSON object containing the component settings that should be overriden when the form submission is processed on the server side.',
169
+ defaultValue: {},
170
+ description: '<b>Example</b>: { "clearOnHide": true }',
171
+ }
160
172
  ];
161
- /* 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;
@@ -37,6 +37,9 @@ const EditFormUtils = {
37
37
  }
38
38
  return lodash_1.default.isEqual(objValue, srcValue);
39
39
  },
40
+ tokenVariableDescription() {
41
+ return '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>';
42
+ },
40
43
  logicVariablesTable(additional) {
41
44
  additional = additional || '';
42
45
  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;
@@ -26,6 +26,9 @@ class NestedDataComponent extends NestedComponent_1.default {
26
26
  get emptyValue() {
27
27
  return {};
28
28
  }
29
+ get shouldAddDefaultValue() {
30
+ return !this.options.noDefaults || !this.options.server;
31
+ }
29
32
  componentContext() {
30
33
  return this.dataValue;
31
34
  }
@@ -218,7 +218,7 @@ class AddressComponent extends Container_1.default {
218
218
  super.dataValue = value;
219
219
  }
220
220
  get dataValue() {
221
- const resultValue = lodash_1.default.get(this._data, this.component.path);
221
+ const resultValue = lodash_1.default.get(this._data, this.path);
222
222
  if (!lodash_1.default.isArray(resultValue) && this.component.multiple) {
223
223
  return [resultValue];
224
224
  }
@@ -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';
@@ -104,8 +104,8 @@ class DateTimeComponent extends Input_1.default {
104
104
  /* eslint-disable camelcase */
105
105
  this.component.widget = Object.assign({ type: 'calendar', timezone, displayInTimezone: lodash_1.default.get(this.component, 'displayInTimezone', 'viewer'), locale: this.options.language, useLocaleSettings: lodash_1.default.get(this.component, 'useLocaleSettings', false), allowInput: lodash_1.default.get(this.component, 'allowInput', true), mode: 'single', enableTime: lodash_1.default.get(this.component, 'enableTime', true), noCalendar: !lodash_1.default.get(this.component, 'enableDate', true), format: this.component.format, hourIncrement: lodash_1.default.get(this.component, 'timePicker.hourStep', 1), minuteIncrement: lodash_1.default.get(this.component, 'timePicker.minuteStep', 5), time_24hr: time24hr, readOnly: this.options.readOnly, minDate: lodash_1.default.get(this.component, 'datePicker.minDate'), disabledDates: lodash_1.default.get(this.component, 'datePicker.disable'), disableWeekends: lodash_1.default.get(this.component, 'datePicker.disableWeekends'), disableWeekdays: lodash_1.default.get(this.component, 'datePicker.disableWeekdays'), disableFunction: lodash_1.default.get(this.component, 'datePicker.disableFunction'), maxDate: lodash_1.default.get(this.component, 'datePicker.maxDate') }, customOptions);
106
106
  // update originalComponent to include widget and other updated settings
107
- // it is done here since these settings depend on properties present after the component is initialized
108
- // originalComponent is used to restore the component (and widget) after evaluating field logic
107
+ // it is done here since these settings depend on properties present after the component is initialized
108
+ // originalComponent is used to restore the component (and widget) after evaluating field logic
109
109
  this.originalComponent = (0, utils_2.fastCloneDeep)(this.component);
110
110
  /* eslint-enable camelcase */
111
111
  }
@@ -153,15 +153,15 @@ class DateTimeComponent extends Input_1.default {
153
153
  }
154
154
  return super.checkValidity(data, dirty, rowData);
155
155
  }
156
- getValueAsString(value) {
156
+ getValueAsString(value, options) {
157
157
  let format = utils_1.default.convertFormatToMoment(this.component.format);
158
158
  format += format.match(/z$/) ? '' : ' z';
159
159
  const timezone = this.timezone;
160
160
  if (value && !this.attached && timezone) {
161
161
  if (Array.isArray(value) && this.component.multiple) {
162
- return value.map(item => lodash_1.default.trim(utils_1.default.momentDate(item, format, timezone).format(format))).join(', ');
162
+ return value.map(item => lodash_1.default.trim(utils_1.default.momentDate(item, format, timezone, options).format(format))).join(', ');
163
163
  }
164
- return lodash_1.default.trim(utils_1.default.momentDate(value, format, timezone).format(format));
164
+ return lodash_1.default.trim(utils_1.default.momentDate(value, format, timezone, options).format(format));
165
165
  }
166
166
  if (Array.isArray(value) && this.component.multiple) {
167
167
  return value.map(item => lodash_1.default.trim((0, moment_1.default)(item).format(format))).join(', ');
@@ -53,11 +53,13 @@ class DayComponent extends Field_1.default {
53
53
  return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.string];
54
54
  }
55
55
  constructor(component, options, data) {
56
- if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
57
- component.maxDate = (0, moment_1.default)(component.maxDate, 'YYYY-MM-DD').toISOString();
58
- }
59
- if (component.minDate && component.minDate.indexOf('moment(') === -1) {
60
- component.minDate = (0, moment_1.default)(component.minDate, 'YYYY-MM-DD').toISOString();
56
+ if (!options.inFormBuilder && !options.building) {
57
+ if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
58
+ component.maxDate = (0, moment_1.default)(component.maxDate, 'YYYY-MM-DD').toISOString();
59
+ }
60
+ if (component.minDate && component.minDate.indexOf('moment(') === -1) {
61
+ component.minDate = (0, moment_1.default)(component.minDate, 'YYYY-MM-DD').toISOString();
62
+ }
61
63
  }
62
64
  super(component, options, data);
63
65
  }
@@ -109,7 +109,8 @@ class FileComponent extends Field_1.default {
109
109
  if (this.component.privateDownload) {
110
110
  fileInfo.private = true;
111
111
  }
112
- return this.fileService.downloadFile(fileInfo).then((result) => result.url);
112
+ // pass the component to the downloadFile method
113
+ return this.fileService.downloadFile(fileInfo, this.component).then((result) => result.url);
113
114
  }
114
115
  get emptyValue() {
115
116
  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;