@formio/js 5.1.0-rc.1 → 5.1.0-rc.11

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 (106) hide show
  1. package/dist/formio.builder.css +22 -24
  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 +22 -24
  7. package/dist/formio.form.js +36 -36
  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 +22 -24
  12. package/dist/formio.full.js +36 -36
  13. package/dist/formio.full.min.css +1 -1
  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 +21 -21
  17. package/dist/formio.min.js +1 -1
  18. package/dist/formio.min.js.LICENSE.txt +1 -1
  19. package/dist/formio.utils.js +18 -18
  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/Formio.js +1 -1
  24. package/lib/cjs/Webform.d.ts +1 -1
  25. package/lib/cjs/Wizard.js +1 -1
  26. package/lib/cjs/components/_classes/component/Component.d.ts +15 -0
  27. package/lib/cjs/components/_classes/component/Component.js +51 -17
  28. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
  29. package/lib/cjs/components/_classes/field/Field.d.ts +2 -2
  30. package/lib/cjs/components/_classes/field/Field.js +1 -1
  31. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  32. package/lib/cjs/components/_classes/nested/NestedComponent.js +16 -7
  33. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
  34. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +3 -0
  35. package/lib/cjs/components/address/Address.d.ts +1 -2
  36. package/lib/cjs/components/address/Address.js +1 -1
  37. package/lib/cjs/components/address/fixtures/comp5.d.ts +46 -0
  38. package/lib/cjs/components/address/fixtures/comp5.js +87 -0
  39. package/lib/cjs/components/address/fixtures/index.d.ts +2 -1
  40. package/lib/cjs/components/address/fixtures/index.js +3 -1
  41. package/lib/cjs/components/button/Button.d.ts +1 -1
  42. package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
  43. package/lib/cjs/components/columns/Columns.d.ts +1 -1
  44. package/lib/cjs/components/datagrid/DataGrid.d.ts +1 -1
  45. package/lib/cjs/components/datagrid/DataGrid.js +4 -1
  46. package/lib/cjs/components/datamap/DataMap.js +1 -1
  47. package/lib/cjs/components/day/Day.d.ts +1 -1
  48. package/lib/cjs/components/day/Day.js +2 -18
  49. package/lib/cjs/components/editgrid/EditGrid.js +2 -5
  50. package/lib/cjs/components/file/File.d.ts +1 -1
  51. package/lib/cjs/components/form/Form.d.ts +1 -0
  52. package/lib/cjs/components/form/Form.js +30 -14
  53. package/lib/cjs/components/html/HTML.js +15 -3
  54. package/lib/cjs/components/radio/Radio.d.ts +1 -1
  55. package/lib/cjs/components/select/Select.d.ts +1 -1
  56. package/lib/cjs/components/survey/Survey.d.ts +1 -1
  57. package/lib/cjs/components/table/Table.d.ts +1 -1
  58. package/lib/cjs/components/tabs/Tabs.d.ts +1 -1
  59. package/lib/cjs/formio.embed.d.ts +1 -1
  60. package/lib/cjs/formio.embed.js +3 -0
  61. package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +5 -0
  62. package/lib/cjs/providers/address/GoogleAddressProvider.js +23 -1
  63. package/lib/cjs/translations/en.js +2 -2
  64. package/lib/mjs/Embed.js +1 -1
  65. package/lib/mjs/Formio.js +1 -1
  66. package/lib/mjs/Webform.d.ts +1 -1
  67. package/lib/mjs/Wizard.js +1 -1
  68. package/lib/mjs/components/_classes/component/Component.d.ts +15 -0
  69. package/lib/mjs/components/_classes/component/Component.js +51 -17
  70. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
  71. package/lib/mjs/components/_classes/field/Field.d.ts +2 -2
  72. package/lib/mjs/components/_classes/field/Field.js +1 -1
  73. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  74. package/lib/mjs/components/_classes/nested/NestedComponent.js +16 -7
  75. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
  76. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +3 -0
  77. package/lib/mjs/components/address/Address.d.ts +1 -2
  78. package/lib/mjs/components/address/Address.js +1 -1
  79. package/lib/mjs/components/address/fixtures/comp5.d.ts +46 -0
  80. package/lib/mjs/components/address/fixtures/comp5.js +85 -0
  81. package/lib/mjs/components/address/fixtures/index.d.ts +2 -1
  82. package/lib/mjs/components/address/fixtures/index.js +2 -1
  83. package/lib/mjs/components/button/Button.d.ts +1 -1
  84. package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
  85. package/lib/mjs/components/columns/Columns.d.ts +1 -1
  86. package/lib/mjs/components/datagrid/DataGrid.d.ts +1 -1
  87. package/lib/mjs/components/datagrid/DataGrid.js +4 -1
  88. package/lib/mjs/components/datamap/DataMap.js +1 -1
  89. package/lib/mjs/components/day/Day.d.ts +1 -1
  90. package/lib/mjs/components/day/Day.js +2 -18
  91. package/lib/mjs/components/editgrid/EditGrid.js +2 -5
  92. package/lib/mjs/components/file/File.d.ts +1 -1
  93. package/lib/mjs/components/form/Form.d.ts +1 -0
  94. package/lib/mjs/components/form/Form.js +29 -14
  95. package/lib/mjs/components/html/HTML.js +15 -3
  96. package/lib/mjs/components/radio/Radio.d.ts +1 -1
  97. package/lib/mjs/components/select/Select.d.ts +1 -1
  98. package/lib/mjs/components/survey/Survey.d.ts +1 -1
  99. package/lib/mjs/components/table/Table.d.ts +1 -1
  100. package/lib/mjs/components/tabs/Tabs.d.ts +1 -1
  101. package/lib/mjs/formio.embed.d.ts +1 -1
  102. package/lib/mjs/formio.embed.js +1 -0
  103. package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +5 -0
  104. package/lib/mjs/providers/address/GoogleAddressProvider.js +22 -1
  105. package/lib/mjs/translations/en.js +2 -2
  106. package/package.json +4 -4
@@ -85,7 +85,7 @@ export default class DayComponent extends Field {
85
85
  }[] | undefined;
86
86
  setErrorClasses(elements: any, dirty: any, hasError: any): void;
87
87
  dayFirst: any;
88
- render(): Field;
88
+ render(): string;
89
89
  renderField(name: any): any;
90
90
  attach(element: any): Promise<void>;
91
91
  set disabled(disabled: any);
@@ -7,6 +7,7 @@ const lodash_1 = __importDefault(require("lodash"));
7
7
  const moment_1 = __importDefault(require("moment"));
8
8
  const Field_1 = __importDefault(require("../_classes/field/Field"));
9
9
  const utils_1 = require("../../utils/utils");
10
+ const core_1 = require("@formio/core");
10
11
  class DayComponent extends Field_1.default {
11
12
  static schema(...extend) {
12
13
  return Field_1.default.schema({
@@ -474,24 +475,7 @@ class DayComponent extends Field_1.default {
474
475
  * @returns {string} - the format for the value string.
475
476
  */
476
477
  get format() {
477
- let format = '';
478
- if (this.component.dayFirst && this.showDay) {
479
- format += 'D/';
480
- }
481
- if (this.showMonth) {
482
- format += 'M/';
483
- }
484
- if (!this.component.dayFirst && this.showDay) {
485
- format += 'D/';
486
- }
487
- if (this.showYear) {
488
- format += 'YYYY';
489
- return format;
490
- }
491
- else {
492
- // Trim off the "/" from the end of the format string.
493
- return format.length ? format.substring(0, format.length - 1) : format;
494
- }
478
+ return (0, core_1.getDayFormat)(this.component);
495
479
  }
496
480
  /**
497
481
  * Return the date for this component.
@@ -1141,7 +1141,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1141
1141
  }
1142
1142
  }
1143
1143
  const changed = this.hasChanged(value, this.dataValue);
1144
- if (this.parent && !this.options.server) {
1144
+ if (this.parent) {
1145
1145
  this.parent.checkComponentConditions();
1146
1146
  }
1147
1147
  this.dataValue = value;
@@ -1174,10 +1174,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1174
1174
  this.editRows = this.editRows.slice(0, dataLength);
1175
1175
  this.openWhenEmpty();
1176
1176
  this.updateOnChange(flags, changed);
1177
- // do not call checkData with server option, it is called when change is triggered in updateOnChange
1178
- if (!this.options.server) {
1179
- this.checkData();
1180
- }
1177
+ this.checkData();
1181
1178
  this.changeState(changed, flags);
1182
1179
  return changed;
1183
1180
  }
@@ -45,7 +45,7 @@ export default class FileComponent extends Field {
45
45
  type: number;
46
46
  actions: number;
47
47
  };
48
- render(): Field;
48
+ render(): string;
49
49
  getVideoStream(constraints: any): any;
50
50
  stopVideoStream(videoStream: any): void;
51
51
  getFrame(videoPlayer: any): Promise<any>;
@@ -32,6 +32,7 @@ export default class FormComponent extends Component {
32
32
  attach(element: any): Promise<void>;
33
33
  get hasLoadedForm(): any;
34
34
  get isRevisionChanged(): any;
35
+ get subFormData(): any;
35
36
  subFormReady: Promise<any> | null | undefined;
36
37
  /**
37
38
  * Pass everyComponent to subform.
@@ -144,6 +144,8 @@ class FormComponent extends Component_1.default {
144
144
  options.events = this.createEmitter();
145
145
  // Make sure to not show the submit button in wizards in the nested forms.
146
146
  lodash_1.default.set(options, 'buttonSettings.showSubmit', false);
147
+ // Set the parent option to the subform so those references are stable when the subform is created
148
+ options.parent = this;
147
149
  if (!this.options) {
148
150
  return options;
149
151
  }
@@ -330,6 +332,10 @@ class FormComponent extends Component_1.default {
330
332
  && lodash_1.default.isNumber(this.formObj._vid)
331
333
  && this.formObj._vid !== this.subFormRevision;
332
334
  }
335
+ get subFormData() {
336
+ var _a;
337
+ return ((_a = this.dataValue) === null || _a === void 0 ? void 0 : _a.data) || {};
338
+ }
333
339
  destroy(all = false) {
334
340
  if (this.subForm) {
335
341
  this.subForm.destroy(all);
@@ -393,12 +399,11 @@ class FormComponent extends Component_1.default {
393
399
  return (new Form_1.default(form, this.getSubOptions())).ready.then((instance) => {
394
400
  this.subForm = instance;
395
401
  this.subForm.currentForm = this;
402
+ this.subForm.parentVisible = this.visible;
396
403
  const componentsMap = this.componentsMap;
397
404
  const formComponentsMap = this.subForm.componentsMap;
398
405
  lodash_1.default.assign(componentsMap, formComponentsMap);
399
406
  this.component.components = this.subForm.components.map((comp) => comp.component);
400
- this.subForm.parent = this;
401
- this.subForm.parentVisible = this.visible;
402
407
  this.subForm.on('change', () => {
403
408
  if (this.subForm) {
404
409
  this.dataValue = this.subForm.getValue();
@@ -425,10 +430,11 @@ class FormComponent extends Component_1.default {
425
430
  return this.subFormReady;
426
431
  }
427
432
  hideSubmitButton(component) {
428
- const isSubmitButton = (component.type === 'button') &&
429
- ((component.action === 'submit') || !component.action);
433
+ const isSubmitButton = component.type === 'button' && (component.action === 'submit' || !component.action);
430
434
  if (isSubmitButton) {
431
435
  component.hidden = true;
436
+ // clearOnHide no longer clears from the JSON `hidden` flag, so we make the button conditionally hidden to clear its data
437
+ component.customConditional = 'show = false';
432
438
  }
433
439
  }
434
440
  /**
@@ -438,7 +444,7 @@ class FormComponent extends Component_1.default {
438
444
  */
439
445
  loadSubForm(fromAttach) {
440
446
  var _a, _b, _c, _d, _e;
441
- if (this.builderMode || this.isHidden() || (this.isSubFormLazyLoad() && !fromAttach)) {
447
+ if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
442
448
  return Promise.resolve();
443
449
  }
444
450
  if (this.hasLoadedForm && !this.isRevisionChanged &&
@@ -480,14 +486,14 @@ class FormComponent extends Component_1.default {
480
486
  return visible;
481
487
  }
482
488
  if (this.subForm) {
483
- return this.subForm.checkConditions(data, flags, row);
489
+ return this.subForm.checkConditions(this.subFormData, flags);
484
490
  }
485
491
  // There are few cases when subForm is not loaded when a change is triggered,
486
492
  // so we need to perform checkConditions after it is ready, or some conditional fields might be hidden in View mode
487
493
  else if (this.subFormReady) {
488
494
  this.subFormReady.then(() => {
489
495
  if (this.subForm) {
490
- return this.subForm.checkConditions(data, flags, row);
496
+ return this.subForm.checkConditions(this.subFormData, flags);
491
497
  }
492
498
  });
493
499
  }
@@ -495,7 +501,7 @@ class FormComponent extends Component_1.default {
495
501
  }
496
502
  calculateValue(data, flags, row) {
497
503
  if (this.subForm) {
498
- return this.subForm.calculateValue(data, flags, row);
504
+ return this.subForm.calculateValue(this.subFormData, flags);
499
505
  }
500
506
  return super.calculateValue(data, flags, row);
501
507
  }
@@ -510,7 +516,7 @@ class FormComponent extends Component_1.default {
510
516
  * @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
511
517
  */
512
518
  get shouldSubmit() {
513
- return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.isHidden();
519
+ return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
514
520
  }
515
521
  /**
516
522
  * Returns the data for the subform.
@@ -581,11 +587,21 @@ class FormComponent extends Component_1.default {
581
587
  this.dataValue = submission;
582
588
  return Promise.resolve(this.dataValue);
583
589
  }
584
- return this.submitSubForm(false)
585
- .then(() => {
586
- return this.dataValue;
587
- })
588
- .then(() => super.beforeSubmit());
590
+ if (this.isSubFormLazyLoad() && !this.subFormLoading) {
591
+ return this.createSubForm(true)
592
+ .then(this.submitSubForm(false))
593
+ .then(() => {
594
+ return this.dataValue;
595
+ })
596
+ .then(() => super.beforeSubmit());
597
+ }
598
+ else {
599
+ return this.submitSubForm(false)
600
+ .then(() => {
601
+ return this.dataValue;
602
+ })
603
+ .then(() => super.beforeSubmit());
604
+ }
589
605
  }
590
606
  isSubFormLazyLoad() {
591
607
  var _a, _b;
@@ -56,9 +56,21 @@ class HTMLComponent extends Component_1.default {
56
56
  }
57
57
  checkRefreshOn(changed) {
58
58
  super.checkRefreshOn(changed);
59
- if (!this.builderMode && this.component.refreshOnChange && this.element &&
60
- !lodash_1.default.isUndefined(changed) && ((lodash_1.default.isBoolean(changed) && changed) || !lodash_1.default.isEmpty(changed)) &&
61
- this.conditionallyVisible(this.data, this.row)) {
59
+ let visible;
60
+ if (this.hasCondition()) {
61
+ this._conditionallyHidden = this.checkConditionallyHidden();
62
+ visible = !this.conditionallyHidden;
63
+ }
64
+ else {
65
+ visible = !this.component.hidden;
66
+ }
67
+ const shouldSetContent = !this.builderMode
68
+ && this.component.refreshOnChange
69
+ && this.element
70
+ && !lodash_1.default.isUndefined(changed)
71
+ && ((lodash_1.default.isBoolean(changed) && changed) || !lodash_1.default.isEmpty(changed))
72
+ && visible;
73
+ if (shouldSetContent) {
62
74
  this.setContent(this.element, this.renderContent());
63
75
  }
64
76
  }
@@ -28,7 +28,7 @@ export default class RadioComponent extends ListComponent {
28
28
  optionsLoaded: boolean | undefined;
29
29
  loadedOptions: any[] | undefined;
30
30
  beforeSubmit(): Promise<any>;
31
- render(): import("../_classes/field/Field").default;
31
+ render(): string;
32
32
  attach(element: any): Promise<void>;
33
33
  detach(element: any): void;
34
34
  validateValueProperty(): boolean;
@@ -112,7 +112,7 @@ export default class SelectComponent extends ListComponent {
112
112
  activate(): void;
113
113
  setLoadingItem(addToCurrentList?: boolean): void;
114
114
  get active(): boolean | undefined;
115
- render(): import("../_classes/field/Field").default;
115
+ render(): string;
116
116
  wrapElement(element: any): any;
117
117
  choicesOptions(): any;
118
118
  attach(element: any): Promise<void> | undefined;
@@ -14,7 +14,7 @@ export default class SurveyComponent extends Field {
14
14
  operators: string[];
15
15
  };
16
16
  static savedValueTypes(schema: any): string[];
17
- render(): Field;
17
+ render(): string;
18
18
  attach(element: any): Promise<void>;
19
19
  setValue(value: any, flags?: {}): boolean;
20
20
  get emptyValue(): {};
@@ -19,6 +19,6 @@ export default class TableComponent extends NestedComponent {
19
19
  get colWidth(): string;
20
20
  noField: boolean;
21
21
  table: any[] | undefined;
22
- render(): import("../_classes/field/Field").default;
22
+ render(): string;
23
23
  }
24
24
  import NestedComponent from '../_classes/nested/NestedComponent';
@@ -16,7 +16,7 @@ export default class TabsComponent extends NestedComponent {
16
16
  currentTab: number;
17
17
  noField: boolean;
18
18
  tabs: any[] | undefined;
19
- render(): import("../_classes/field/Field").default;
19
+ render(): string;
20
20
  detach(all: any): void;
21
21
  /**
22
22
  * Set the current tab.
@@ -1 +1 @@
1
- export {};
1
+ export { Formio } from "./InlineEmbed";
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Formio = void 0;
3
4
  const InlineEmbed_1 = require("./InlineEmbed");
4
5
  (0, InlineEmbed_1.embed)();
6
+ var InlineEmbed_2 = require("./InlineEmbed");
7
+ Object.defineProperty(exports, "Formio", { enumerable: true, get: function () { return InlineEmbed_2.Formio; } });
@@ -82,6 +82,11 @@ export class GoogleAddressProvider extends AddressProvider {
82
82
  search(): Promise<void>;
83
83
  makeRequest(): Promise<void>;
84
84
  getDisplayValue(address: any): any;
85
+ /**
86
+ * Tries to remove the library if api key for loaded script is different.
87
+ * @param {ProviderOptions} options - The options for the provider.
88
+ */
89
+ tryRemoveLibrary(options?: ProviderOptions): void;
85
90
  }
86
91
  export type AutocompleteOptions = {
87
92
  /**
@@ -8,6 +8,9 @@ exports.GoogleAddressProvider = void 0;
8
8
  const Formio_1 = require("../../Formio");
9
9
  const lodash_1 = __importDefault(require("lodash"));
10
10
  const AddressProvider_1 = require("./AddressProvider");
11
+ const GOOGLE_MAPS_BASE_URL = 'https://maps.googleapis.com';
12
+ const GOOGLE_MAPS_JS_URL = `${GOOGLE_MAPS_BASE_URL}/maps/api/js`;
13
+ const GOOGLE_MAPS_JS_WITH_PARAMS_URL = `${GOOGLE_MAPS_JS_URL}?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback`;
11
14
  /**
12
15
  * @typedef {object} AutocompleteOptions
13
16
  * @property {string[]} fields - The fields to include in the autocomplete response.
@@ -55,10 +58,11 @@ class GoogleAddressProvider extends AddressProvider_1.AddressProvider {
55
58
  var _a;
56
59
  super(options);
57
60
  this.setAutocompleteOptions();
58
- let src = 'https://maps.googleapis.com/maps/api/js?v=quarterly&libraries=places&loading=async&callback=googleMapsCallback';
61
+ let src = GOOGLE_MAPS_JS_WITH_PARAMS_URL;
59
62
  if ((_a = options.params) === null || _a === void 0 ? void 0 : _a.key) {
60
63
  src += `&key=${options.params.key}`;
61
64
  }
65
+ this.tryRemoveLibrary(options);
62
66
  Formio_1.Formio.requireLibrary(this.getLibraryName(), 'google.maps.places', src);
63
67
  }
64
68
  /**
@@ -185,5 +189,23 @@ class GoogleAddressProvider extends AddressProvider_1.AddressProvider {
185
189
  : this.alternativeDisplayValueProperty;
186
190
  return lodash_1.default.get(address, displayedProperty, '');
187
191
  }
192
+ /**
193
+ * Tries to remove the library if api key for loaded script is different.
194
+ * @param {ProviderOptions} options - The options for the provider.
195
+ */
196
+ tryRemoveLibrary(options = {}) {
197
+ var _a, _b, _c;
198
+ if (!Formio_1.Formio.libraries[this.getLibraryName()]) {
199
+ return;
200
+ }
201
+ const existingScript = document.querySelector(`script[src^="${GOOGLE_MAPS_JS_URL}"]`);
202
+ if (existingScript && ((_a = options.params) === null || _a === void 0 ? void 0 : _a.key) && !existingScript.attributes.src.value.endsWith(options.params.key)) {
203
+ const googleMapsScripts = (_b = document.querySelectorAll(`script[src^="${GOOGLE_MAPS_BASE_URL}"]`)) !== null && _b !== void 0 ? _b : [];
204
+ googleMapsScripts.forEach(script => script.parentNode.removeChild(script));
205
+ delete Formio_1.Formio.libraries[this.getLibraryName()];
206
+ (_c = global === null || global === void 0 ? void 0 : global.google) === null || _c === void 0 ? true : delete _c.maps;
207
+ delete global[`${this.getLibraryName()}Callback`];
208
+ }
209
+ }
188
210
  }
189
211
  exports.GoogleAddressProvider = GoogleAddressProvider;
@@ -26,8 +26,8 @@ exports.default = {
26
26
  maxWords: '{{field}} must have no more than {{length}} words.',
27
27
  min: '{{field}} cannot be less than {{min}}.',
28
28
  max: '{{field}} cannot be greater than {{max}}.',
29
- maxDate: '{{field}} should not contain date after {{- maxDate}}',
30
- minDate: '{{field}} should not contain date before {{- minDate}}',
29
+ maxDate: '{{field}} should not contain date after {{maxDate}}',
30
+ minDate: '{{field}} should not contain date before {{minDate}}',
31
31
  maxYear: '{{field}} should not contain year greater than {{maxYear}}',
32
32
  minYear: '{{field}} should not contain year less than {{minYear}}',
33
33
  minSelectedCount: 'You must select at least {{minCount}} items',
package/lib/mjs/Embed.js CHANGED
@@ -14,7 +14,7 @@ export class Formio {
14
14
  Formio._formioReady = ready;
15
15
  Formio._formioReadyReject = reject;
16
16
  });
17
- static version = 'FORMIO_VERSION';
17
+ static version = '5.1.0-rc.11';
18
18
  static setLicense(license, norecurse = false) {
19
19
  Formio.license = license;
20
20
  if (!norecurse && Formio.FormioClass) {
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 = 'FORMIO_VERSION';
7
+ FormioCore.version = '5.1.0-rc.11';
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) {
@@ -363,7 +363,7 @@ declare class Webform extends NestedDataComponent {
363
363
  executeFormController(): false | undefined;
364
364
  build(element: any): Promise<any>;
365
365
  getClassName(): string;
366
- render(): import("./components/_classes/field/Field").default;
366
+ render(): string;
367
367
  redraw(): Promise<void> | Promise<boolean>;
368
368
  attach(element: any): Promise<boolean>;
369
369
  hasRequiredFields(): boolean;
package/lib/mjs/Wizard.js CHANGED
@@ -657,7 +657,7 @@ export default class Wizard extends Webform {
657
657
  return this.page - 1;
658
658
  }
659
659
  beforeSubmit() {
660
- const pages = this.getPages();
660
+ const pages = this.getPages({ all: true });
661
661
  return Promise.all(pages.map((page) => {
662
662
  page.options.beforeSubmit = true;
663
663
  return page.beforeSubmit();
@@ -119,6 +119,13 @@ declare class Component extends Element {
119
119
  */
120
120
  paths: import('@formio/core').ComponentPaths;
121
121
  _path: string;
122
+ /**
123
+ * Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
124
+ * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
125
+ * conditionallyHidden separately from "regular" visibility.
126
+ */
127
+ _parentConditionallyHidden: any;
128
+ _conditionallyHidden: any;
122
129
  /**
123
130
  * Determines if this component is visible, or not.
124
131
  */
@@ -224,6 +231,14 @@ declare class Component extends Element {
224
231
  * @returns {boolean} - Whether the component is visible or not.
225
232
  */
226
233
  get visible(): boolean;
234
+ get conditionallyHidden(): any;
235
+ /**
236
+ * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
237
+ * @param {object} data - The data object to evaluate the condition against.
238
+ * @param {object} row - The row object to evaluate the condition against.
239
+ * @returns {boolean} - Whether the component is conditionally hidden.
240
+ */
241
+ checkConditionallyHidden(data?: object, row?: object): boolean;
227
242
  set currentForm(instance: any);
228
243
  get currentForm(): any;
229
244
  _currentForm: any;
@@ -315,11 +315,18 @@ export default class Component extends Element {
315
315
  this._path = '';
316
316
  // Needs for Nextgen Rules Engine
317
317
  this.resetCaches();
318
+ /**
319
+ * Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
320
+ * This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
321
+ * conditionallyHidden separately from "regular" visibility.
322
+ */
323
+ this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
324
+ this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
318
325
  /**
319
326
  * Determines if this component is visible, or not.
320
327
  */
321
328
  this._parentVisible = this.options.hasOwnProperty('parentVisible') ? this.options.parentVisible : true;
322
- this._visible = this._parentVisible && this.conditionallyVisible(null, data);
329
+ this._visible = this._parentVisible && (this.hasCondition() ? !this._conditionallyHidden : !this.component.hidden);
323
330
  this._parentDisabled = false;
324
331
  /**
325
332
  * The reference attribute name for this component
@@ -388,7 +395,7 @@ export default class Component extends Element {
388
395
  if (this.allowData && this.key) {
389
396
  this.options.name += `[${this.key}]`;
390
397
  // If component is visible or not set to clear on hide, set the default value.
391
- if (this.visible || !this.component.clearOnHide) {
398
+ if (!(this.conditionallyHidden && this.component.clearOnHide)) {
392
399
  if (!this.hasValue()) {
393
400
  if (this.shouldAddDefaultValue) {
394
401
  this.dataValue = this.defaultValue;
@@ -457,7 +464,8 @@ export default class Component extends Element {
457
464
  }
458
465
  init() {
459
466
  this.disabled = this.shouldDisabled;
460
- this._visible = this.conditionallyVisible(null, null);
467
+ this._conditionallyHidden = this.checkConditionallyHidden();
468
+ this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
461
469
  if (this.component.addons?.length) {
462
470
  this.component.addons.forEach((addon) => this.createAddon(addon));
463
471
  }
@@ -600,7 +608,6 @@ export default class Component extends Element {
600
608
  return;
601
609
  }
602
610
  this._visible = value;
603
- this.clearOnHide();
604
611
  this.redraw();
605
612
  }
606
613
  }
@@ -621,6 +628,21 @@ export default class Component extends Element {
621
628
  }
622
629
  return this._visible && this._parentVisible;
623
630
  }
631
+ get conditionallyHidden() {
632
+ return this._conditionallyHidden || this._parentConditionallyHidden;
633
+ }
634
+ /**
635
+ * Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
636
+ * @param {object} data - The data object to evaluate the condition against.
637
+ * @param {object} row - The row object to evaluate the condition against.
638
+ * @returns {boolean} - Whether the component is conditionally hidden.
639
+ */
640
+ checkConditionallyHidden(data = null, row = null) {
641
+ if (!this.hasCondition()) {
642
+ return false;
643
+ }
644
+ return !this.conditionallyVisible(data, row);
645
+ }
624
646
  get currentForm() {
625
647
  return this._currentForm;
626
648
  }
@@ -1241,7 +1263,7 @@ export default class Component extends Element {
1241
1263
  detach() {
1242
1264
  // First iterate through each ref and delete the component so there are no dangling component references.
1243
1265
  _.each(this.refs, (ref) => {
1244
- if (typeof ref === NodeList) {
1266
+ if (ref instanceof NodeList) {
1245
1267
  ref.forEach((elem) => {
1246
1268
  delete elem.component;
1247
1269
  });
@@ -1791,7 +1813,7 @@ export default class Component extends Element {
1791
1813
  rebuild() {
1792
1814
  this.destroy();
1793
1815
  this.init();
1794
- this.visible = this.conditionallyVisible(null, null);
1816
+ this.visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
1795
1817
  return this.redraw();
1796
1818
  }
1797
1819
  /**
@@ -1858,8 +1880,8 @@ export default class Component extends Element {
1858
1880
  conditionallyVisible(data, row) {
1859
1881
  data = data || this.rootValue;
1860
1882
  row = row || this.data;
1861
- if (this.builderMode || this.previewMode || !this.hasCondition()) {
1862
- return !this.component.hidden;
1883
+ if (this.builderMode || this.previewMode) {
1884
+ return true;
1863
1885
  }
1864
1886
  data = data || (this.root ? this.root.data : {});
1865
1887
  return this.checkCondition(row, data);
@@ -1889,8 +1911,14 @@ export default class Component extends Element {
1889
1911
  if (!this.builderMode & !this.previewMode && this.fieldLogic(data, row)) {
1890
1912
  this.redraw();
1891
1913
  }
1892
- // Check advanced conditions
1893
- const visible = this.conditionallyVisible(data, row);
1914
+ // Check advanced conditions (and cache the result)
1915
+ const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
1916
+ if (isConditionallyHidden !== this._conditionallyHidden) {
1917
+ this._conditionallyHidden = isConditionallyHidden;
1918
+ this.clearOnHide();
1919
+ }
1920
+ // Check visibility
1921
+ const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
1894
1922
  if (this.visible !== visible) {
1895
1923
  this.visible = visible;
1896
1924
  }
@@ -2000,6 +2028,12 @@ export default class Component extends Element {
2000
2028
  FormioUtils.setActionProperty(newComponent, action, result, row, data, this);
2001
2029
  const property = action.property.value;
2002
2030
  if (!_.isEqual(_.get(this.component, property), _.get(newComponent, property))) {
2031
+ // Advanced Logic can modify the component's hidden property; because we track conditionally hidden state
2032
+ // separately from the component's hidden property, and technically this Advanced Logic conditionally hides
2033
+ // a component, we need to set _conditionallyHidden to the new value
2034
+ if (property === 'hidden') {
2035
+ this._conditionallyHidden = newComponent.hidden;
2036
+ }
2003
2037
  changed = true;
2004
2038
  }
2005
2039
  break;
@@ -2013,7 +2047,7 @@ export default class Component extends Element {
2013
2047
  component: newComponent,
2014
2048
  result,
2015
2049
  });
2016
- if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && !this.visible)) {
2050
+ if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
2017
2051
  this.setValue(newValue);
2018
2052
  if (this.viewOnly) {
2019
2053
  this.dataValue = newValue;
@@ -2046,7 +2080,7 @@ export default class Component extends Element {
2046
2080
  component: newComponent,
2047
2081
  result,
2048
2082
  }, 'value');
2049
- if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && !this.visible)) {
2083
+ if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
2050
2084
  this.setValue(newValue);
2051
2085
  if (this.viewOnly) {
2052
2086
  this.dataValue = newValue;
@@ -2157,7 +2191,7 @@ export default class Component extends Element {
2157
2191
  this.component.clearOnHide !== false &&
2158
2192
  !this.options.readOnly &&
2159
2193
  !this.options.showHiddenFields) {
2160
- if (!this.visible) {
2194
+ if (this.conditionallyHidden) {
2161
2195
  this.deleteValue();
2162
2196
  }
2163
2197
  else if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2412,7 +2446,7 @@ export default class Component extends Element {
2412
2446
  */
2413
2447
  get dataValue() {
2414
2448
  if (!this.key ||
2415
- (!this.visible && this.component.clearOnHide && !this.rootPristine)) {
2449
+ (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2416
2450
  return this.emptyValue;
2417
2451
  }
2418
2452
  if (!this.hasValue() && this.shouldAddDefaultValue) {
@@ -2431,7 +2465,7 @@ export default class Component extends Element {
2431
2465
  set dataValue(value) {
2432
2466
  if (!this.allowData ||
2433
2467
  !this.key ||
2434
- (!this.visible && this.component.clearOnHide && !this.rootPristine)) {
2468
+ (this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
2435
2469
  return;
2436
2470
  }
2437
2471
  if ((value !== null) && (value !== undefined)) {
@@ -2751,7 +2785,7 @@ export default class Component extends Element {
2751
2785
  // If no calculated value or
2752
2786
  // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
2753
2787
  const { clearOnHide } = this.component;
2754
- const shouldBeCleared = !this.visible && clearOnHide;
2788
+ const shouldBeCleared = this.conditionallyHidden && clearOnHide;
2755
2789
  const allowOverride = _.get(this.component, 'allowCalculateOverride', false);
2756
2790
  if (shouldBeCleared) {
2757
2791
  // remove calculated value so that the value is recalculated once component becomes visible
@@ -3396,7 +3430,7 @@ export default class Component extends Element {
3396
3430
  // If component definition changed, replace it.
3397
3431
  if (!_.isEqual(this.component, newComponent)) {
3398
3432
  this.component = newComponent;
3399
- const visible = this.conditionallyVisible(null, null);
3433
+ const visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
3400
3434
  const disabled = this.shouldDisabled;
3401
3435
  // Change states which won't be recalculated during redrawing
3402
3436
  if (this.visible !== visible) {
@@ -128,10 +128,10 @@ export default [
128
128
  {
129
129
  weight: 700,
130
130
  type: 'checkbox',
131
- label: 'Clear Value When Hidden',
131
+ label: 'Omit Value From Submission Data When Conditionally Hidden',
132
132
  key: 'clearOnHide',
133
133
  defaultValue: true,
134
- tooltip: 'When a field is hidden, clear the value.',
134
+ tooltip: 'When a field is conditionally hidden, omit the value from the submission data.',
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>'),
@@ -1,9 +1,9 @@
1
1
  export default class Field extends Component {
2
2
  /**
3
3
  * @param {object} element - The component to create.
4
- * @returns {Field} - The created field.
4
+ * @returns {string} - The rendered HTML string of a component
5
5
  */
6
- render(element: object): Field;
6
+ render(element: object): string;
7
7
  /**
8
8
  /* Saves current caret position to restore it after the component is redrawn
9
9
  * @param {HTMLElement} element - The element to save the caret position for.