@formio/js 5.2.0 → 5.2.1-rc.1

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 (76) hide show
  1. package/dist/formio.builder.css +15 -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 +15 -17
  7. package/dist/formio.form.js +31 -31
  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 +15 -17
  12. package/dist/formio.full.js +32 -32
  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 +6 -6
  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/Formio.js +1 -1
  24. package/lib/cjs/Webform.js +2 -1
  25. package/lib/cjs/WebformBuilder.js +18 -11
  26. package/lib/cjs/Wizard.d.ts +1 -2
  27. package/lib/cjs/Wizard.js +17 -23
  28. package/lib/cjs/components/Components.js +1 -1
  29. package/lib/cjs/components/_classes/component/Component.d.ts +23 -2
  30. package/lib/cjs/components/_classes/component/Component.js +61 -35
  31. package/lib/cjs/components/_classes/nested/NestedComponent.js +2 -2
  32. package/lib/cjs/components/file/File.d.ts +1 -1
  33. package/lib/cjs/components/file/File.js +6 -1
  34. package/lib/cjs/components/form/Form.d.ts +0 -2
  35. package/lib/cjs/components/form/Form.js +12 -20
  36. package/lib/cjs/components/select/Select.d.ts +0 -1
  37. package/lib/cjs/components/select/Select.js +3 -23
  38. package/lib/cjs/components/tags/Tags.d.ts +1 -1
  39. package/lib/cjs/components/tags/Tags.js +2 -2
  40. package/lib/cjs/formio.form.js +1 -0
  41. package/lib/cjs/utils/ChoicesWrapper.d.ts +4 -25
  42. package/lib/cjs/utils/ChoicesWrapper.js +47 -124
  43. package/lib/cjs/utils/formUtils.d.ts +2 -2
  44. package/lib/cjs/utils/index.d.ts +4 -4
  45. package/lib/cjs/utils/utils.d.ts +4 -4
  46. package/lib/cjs/utils/utils.js +2 -2
  47. package/lib/cjs/widgets/CalendarWidget.d.ts +1 -1
  48. package/lib/cjs/widgets/CalendarWidget.js +1 -1
  49. package/lib/mjs/Embed.js +1 -1
  50. package/lib/mjs/Formio.js +1 -1
  51. package/lib/mjs/Webform.js +1 -1
  52. package/lib/mjs/WebformBuilder.js +19 -12
  53. package/lib/mjs/Wizard.d.ts +1 -2
  54. package/lib/mjs/Wizard.js +16 -22
  55. package/lib/mjs/components/Components.js +1 -1
  56. package/lib/mjs/components/_classes/component/Component.d.ts +23 -2
  57. package/lib/mjs/components/_classes/component/Component.js +61 -35
  58. package/lib/mjs/components/_classes/nested/NestedComponent.js +2 -2
  59. package/lib/mjs/components/file/File.d.ts +1 -1
  60. package/lib/mjs/components/file/File.js +6 -1
  61. package/lib/mjs/components/form/Form.d.ts +0 -2
  62. package/lib/mjs/components/form/Form.js +12 -20
  63. package/lib/mjs/components/select/Select.d.ts +0 -1
  64. package/lib/mjs/components/select/Select.js +3 -22
  65. package/lib/mjs/components/tags/Tags.d.ts +1 -1
  66. package/lib/mjs/components/tags/Tags.js +2 -2
  67. package/lib/mjs/formio.form.js +1 -0
  68. package/lib/mjs/utils/ChoicesWrapper.d.ts +4 -25
  69. package/lib/mjs/utils/ChoicesWrapper.js +26 -119
  70. package/lib/mjs/utils/formUtils.d.ts +2 -2
  71. package/lib/mjs/utils/index.d.ts +4 -4
  72. package/lib/mjs/utils/utils.d.ts +4 -4
  73. package/lib/mjs/utils/utils.js +2 -2
  74. package/lib/mjs/widgets/CalendarWidget.d.ts +1 -1
  75. package/lib/mjs/widgets/CalendarWidget.js +1 -1
  76. package/package.json +5 -5
@@ -20,7 +20,7 @@
20
20
 
21
21
  /*! @license DOMPurify 3.2.4 | (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.4/LICENSE */
22
22
 
23
- /*! formiojs v5.2.0 | https://unpkg.com/formiojs@5.2.0/LICENSE.txt */
23
+ /*! formiojs v5.2.1-rc.1 | https://unpkg.com/formiojs@5.2.1-rc.1/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.2.0';
421
+ Formio.version = '5.2.1-rc.1';
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/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.2.0';
14
+ sdk_1.Formio.version = '5.2.1-rc.1';
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) {
@@ -740,7 +740,8 @@ class Webform extends NestedDataComponent_1.default {
740
740
  this.emit(restoreDraft ? "restoreDraftError" : "saveDraftError", errDetails || errorMessage);
741
741
  }
742
742
  saveDraft() {
743
- if (!this.draftEnabled) {
743
+ var _a;
744
+ if (!this.draftEnabled || ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.component.reference) === false) {
744
745
  return;
745
746
  }
746
747
  if (!this.formio) {
@@ -1132,15 +1132,18 @@ class WebformBuilder extends Component_1.default {
1132
1132
  (0, utils_1.eachComponent)(this.form.components, (comp, path, components, parent, paths) => {
1133
1133
  var _a, _b;
1134
1134
  const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
1135
- if (keys.has(paths.dataPath)) {
1136
- const onlyRadioCheckboxes = ((_a = repeatablePaths[paths.dataPath]) === null || _a === void 0 ? void 0 : _a.onlyRadioCheckboxes) === false ? false : isRadioCheckbox;
1137
- repeatablePaths[paths.dataPath] = {
1138
- comps: [...(((_b = repeatablePaths[paths.dataPath]) === null || _b === void 0 ? void 0 : _b.comps) || []), keys.get(paths.dataPath), comp],
1139
- onlyRadioCheckboxes,
1140
- };
1141
- }
1142
- else {
1143
- keys.set(paths.dataPath, comp);
1135
+ const isLayout = (0, utils_1.componentInfo)(comp).layout;
1136
+ if (!isLayout) {
1137
+ if (keys.has(paths.dataPath)) {
1138
+ const onlyRadioCheckboxes = ((_a = repeatablePaths[paths.dataPath]) === null || _a === void 0 ? void 0 : _a.onlyRadioCheckboxes) === false ? false : isRadioCheckbox;
1139
+ repeatablePaths[paths.dataPath] = {
1140
+ comps: [...(((_b = repeatablePaths[paths.dataPath]) === null || _b === void 0 ? void 0 : _b.comps) || []), keys.get(paths.dataPath), comp],
1141
+ onlyRadioCheckboxes,
1142
+ };
1143
+ }
1144
+ else {
1145
+ keys.set(paths.dataPath, comp);
1146
+ }
1144
1147
  }
1145
1148
  }, true);
1146
1149
  const componentsWithRepeatablePaths = [];
@@ -1160,6 +1163,9 @@ class WebformBuilder extends Component_1.default {
1160
1163
  comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
1161
1164
  hasInvalidComponents = true;
1162
1165
  }
1166
+ else {
1167
+ comp.setCustomValidity();
1168
+ }
1163
1169
  });
1164
1170
  this.emit('builderFormValidityChange', hasInvalidComponents);
1165
1171
  }
@@ -1279,7 +1285,8 @@ class WebformBuilder extends Component_1.default {
1279
1285
  helplinks: this.helplinks,
1280
1286
  }));
1281
1287
  this.editForm.attach(this.componentEdit.querySelector(`[${this._referenceAttributeName}="editForm"]`));
1282
- this.updateComponent((_a = this.editForm.submission.data) !== null && _a !== void 0 ? _a : component);
1288
+ const editFormData = (_a = this.editForm.submission) === null || _a === void 0 ? void 0 : _a.data;
1289
+ this.updateComponent((editFormData === null || editFormData === void 0 ? void 0 : editFormData.componentJson) || editFormData || component);
1283
1290
  this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
1284
1291
  });
1285
1292
  });
@@ -1646,7 +1653,7 @@ class WebformBuilder extends Component_1.default {
1646
1653
  }
1647
1654
  hasEditTabs(type) {
1648
1655
  // If the component type does not exist then it has no edit tabs
1649
- if (!Components_1.default.components[type]) {
1656
+ if (!Components_1.default.components[type === 'custom' ? 'unknown' : type]) {
1650
1657
  return false;
1651
1658
  }
1652
1659
  const editTabs = (0, utils_1.getComponent)(Components_1.default.components[type === 'custom' ? 'unknown' : type].editForm().components, 'tabs', true).components;
@@ -6,7 +6,6 @@ declare class Wizard extends Webform {
6
6
  originalComponents: any[];
7
7
  page: number;
8
8
  currentPanel: any;
9
- currentPanels: any[] | null;
10
9
  currentNextPage: number;
11
10
  _seenPages: number[];
12
11
  subWizards: any[];
@@ -17,7 +16,7 @@ declare class Wizard extends Webform {
17
16
  originalOptions: any;
18
17
  isLastPage(): any;
19
18
  getPages(args?: {}): any[];
20
- get hasExtraPages(): boolean;
19
+ get hasSubWizards(): boolean;
21
20
  get localData(): any;
22
21
  get wizardKey(): string;
23
22
  set wizard(form: object);
package/lib/cjs/Wizard.js CHANGED
@@ -34,7 +34,6 @@ class Wizard extends Webform_1.default {
34
34
  this.originalComponents = [];
35
35
  this.page = 0;
36
36
  this.currentPanel = null;
37
- this.currentPanels = null;
38
37
  this.currentNextPage = 0;
39
38
  this._seenPages = [0];
40
39
  this.subWizards = [];
@@ -53,12 +52,12 @@ class Wizard extends Webform_1.default {
53
52
  }
54
53
  getPages(args = {}) {
55
54
  const { all = false } = args;
56
- const pages = this.hasExtraPages ? this.components : this.pages;
55
+ const pages = this.hasSubWizards ? this.components : this.pages;
57
56
  const filteredPages = pages
58
57
  .filter(all ? lodash_1.default.identity : (p, index) => this._seenPages.includes(index));
59
58
  return filteredPages;
60
59
  }
61
- get hasExtraPages() {
60
+ get hasSubWizards() {
62
61
  return !lodash_1.default.isEmpty(this.subWizards);
63
62
  }
64
63
  get data() {
@@ -187,9 +186,9 @@ class Wizard extends Webform_1.default {
187
186
  }
188
187
  render() {
189
188
  const ctx = this.renderContext;
190
- if (this.component.key) {
191
- ctx.panels.map(panel => {
192
- if (panel.key === this.component.key) {
189
+ if (this.component.id) {
190
+ ctx.panels.forEach(panel => {
191
+ if (panel.id === this.component.id) {
193
192
  this.currentPanel = panel;
194
193
  ctx.wizardPageTooltip = this.getFormattedTooltip(panel.tooltip);
195
194
  }
@@ -587,7 +586,7 @@ class Wizard extends Webform_1.default {
587
586
  this.pageFieldLogic(num);
588
587
  this.getNextPage();
589
588
  let parentNum = num;
590
- if (this.hasExtraPages) {
589
+ if (this.hasSubWizards) {
591
590
  const pageFromPages = this.pages[num];
592
591
  const pageFromComponents = this.components[num];
593
592
  if (!pageFromComponents || (pageFromPages === null || pageFromPages === void 0 ? void 0 : pageFromPages.id) !== pageFromComponents.id) {
@@ -873,7 +872,7 @@ class Wizard extends Webform_1.default {
873
872
  }
874
873
  }
875
874
  onChange(flags, changed, modified, changes) {
876
- var _a, _b;
875
+ var _a;
877
876
  super.onChange(flags, changed, modified, changes);
878
877
  // The onChange loop doesn't need all components for wizards
879
878
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
@@ -881,23 +880,18 @@ class Wizard extends Webform_1.default {
881
880
  this.showErrors(errors, true, true);
882
881
  }
883
882
  // If the pages change, need to redraw the header.
884
- let currentPanels;
885
- let panels;
883
+ const currentPanels = this.pages;
884
+ // calling this.establishPages() updates/mutates this.pages to be the current pages
885
+ this.establishPages();
886
+ const newPanels = this.pages;
886
887
  const currentNextPage = this.currentNextPage;
887
- if (this.hasExtraPages) {
888
- currentPanels = this.pages.map(page => page.component.key);
889
- this.establishPages();
890
- panels = this.pages.map(page => page.component.key);
891
- }
892
- else {
893
- currentPanels = this.currentPanels || this.pages.map(page => page.component.key);
894
- panels = this.establishPages().map(panel => panel.key);
895
- this.currentPanels = panels;
896
- if (((_a = this.currentPanel) === null || _a === void 0 ? void 0 : _a.key) && ((_b = this.currentPanels) === null || _b === void 0 ? void 0 : _b.length)) {
897
- this.setPage(this.currentPanels.findIndex(panel => panel === this.currentPanel.key));
898
- }
888
+ const panelsUpdated = !lodash_1.default.isEqual(newPanels, currentPanels);
889
+ if (((_a = this.currentPanel) === null || _a === void 0 ? void 0 : _a.id) && this.pages.length && (!this.hasSubWizards || (this.hasSubWizards && panelsUpdated))) {
890
+ const newIndex = this.pages.findIndex(page => page.id === this.currentPanel.id);
891
+ if (newIndex !== -1)
892
+ this.setPage(newIndex);
899
893
  }
900
- if (!lodash_1.default.isEqual(panels, currentPanels) || (flags && flags.fromSubmission)) {
894
+ if (panelsUpdated || (flags && flags.fromSubmission)) {
901
895
  this.redrawHeader();
902
896
  }
903
897
  // If the next page changes, then make sure to redraw navigation.
@@ -57,7 +57,7 @@ class Components {
57
57
  // eslint-disable-next-line new-cap
58
58
  comp = new Components.components['datagrid'](component, options, data);
59
59
  }
60
- else if (component.tree) {
60
+ else if (component.tree || (component.input && Array.isArray(component.components))) {
61
61
  // eslint-disable-next-line new-cap
62
62
  comp = new Components.components['nesteddata'](component, options, data);
63
63
  }
@@ -165,10 +165,16 @@ declare class Component extends Element {
165
165
  get componentsMap(): object;
166
166
  /**
167
167
  * Returns if the parent should conditionally clear.
168
+ *
168
169
  * @returns {boolean} - If the parent should conditionally clear.
169
170
  */
170
171
  parentShouldConditionallyClear(): boolean;
171
172
  parentConditionallyHidden(): boolean;
173
+ /**
174
+ * Returns true if any of the parents default their component "hidden" property to true.
175
+ * @returns {boolean} - If any parent defaults the hidden property to true.
176
+ */
177
+ anyParentDefaultsHidden(): boolean;
172
178
  set data(value: any);
173
179
  get data(): any;
174
180
  mergeSchema(component?: {}): any;
@@ -232,8 +238,23 @@ declare class Component extends Element {
232
238
  get visible(): boolean;
233
239
  get logicallyHidden(): any;
234
240
  _logicallyHidden: any;
235
- shouldConditionallyClear(skipParent?: boolean): boolean;
236
- conditionallyHidden(skipParent?: boolean): boolean;
241
+ /**
242
+ * Determines if the component should clear its value when the root form is pristine.
243
+ * @returns {boolean} - If the component should clear its value when the root form is pristine.
244
+ */
245
+ shouldConditionallyClearOnPristine(): boolean;
246
+ /**
247
+ * Returns if the component should clear its value when conditionally hidden.
248
+ * @returns {boolean} - If the component should clear its value when conditionally hidden.
249
+ */
250
+ shouldConditionallyClear(): boolean;
251
+ _conditionallyClear: boolean | undefined;
252
+ /**
253
+ * Returns if the component is conditionally hidden.
254
+ * @returns {boolean} - If the component is conditionally hidden.
255
+ */
256
+ conditionallyHidden(): boolean;
257
+ _conditionallyHidden: boolean | undefined;
237
258
  set currentForm(instance: any);
238
259
  get currentForm(): any;
239
260
  _currentForm: any;
@@ -424,12 +424,14 @@ class Component extends Element_1.default {
424
424
  }
425
425
  /**
426
426
  * Returns if the parent should conditionally clear.
427
+ *
427
428
  * @returns {boolean} - If the parent should conditionally clear.
428
429
  */
429
430
  parentShouldConditionallyClear() {
430
431
  let currentParent = this.parent;
431
432
  while (currentParent) {
432
- if (currentParent.shouldConditionallyClear(true)) {
433
+ if ((currentParent.allowData && currentParent._conditionallyClear) ||
434
+ (!currentParent.allowData && currentParent._conditionallyHidden)) {
433
435
  return true;
434
436
  }
435
437
  currentParent = currentParent.parent;
@@ -439,7 +441,21 @@ class Component extends Element_1.default {
439
441
  parentConditionallyHidden() {
440
442
  let currentParent = this.parent;
441
443
  while (currentParent) {
442
- if (currentParent.conditionallyHidden(true)) {
444
+ if (currentParent._conditionallyHidden) {
445
+ return true;
446
+ }
447
+ currentParent = currentParent.parent;
448
+ }
449
+ return false;
450
+ }
451
+ /**
452
+ * Returns true if any of the parents default their component "hidden" property to true.
453
+ * @returns {boolean} - If any parent defaults the hidden property to true.
454
+ */
455
+ anyParentDefaultsHidden() {
456
+ let currentParent = this.parent;
457
+ while (currentParent) {
458
+ if (currentParent.component.hidden) {
443
459
  return true;
444
460
  }
445
461
  currentParent = currentParent.parent;
@@ -654,48 +670,58 @@ class Component extends Element_1.default {
654
670
  }
655
671
  return this._logicallyHidden;
656
672
  }
657
- shouldConditionallyClear(skipParent = false) {
673
+ /**
674
+ * Determines if the component should clear its value when the root form is pristine.
675
+ * @returns {boolean} - If the component should clear its value when the root form is pristine.
676
+ */
677
+ shouldConditionallyClearOnPristine() {
678
+ // If the form is pristine, we should NOT clear the value of a conditionally hidden child component
679
+ // of a layout component that defaults to hidden using the "hidden" component property.
680
+ return !this.anyParentDefaultsHidden();
681
+ }
682
+ /**
683
+ * Returns if the component should clear its value when conditionally hidden.
684
+ * @returns {boolean} - If the component should clear its value when conditionally hidden.
685
+ */
686
+ shouldConditionallyClear() {
658
687
  // Skip if this component has clearOnHide set to false.
659
688
  if (this.component.clearOnHide === false) {
660
- return false;
689
+ this._conditionallyClear = false;
690
+ return this._conditionallyClear;
661
691
  }
662
692
  // If the component is logically hidden, then it is conditionally hidden and should clear.
663
693
  if (this.logicallyHidden) {
664
- return true;
694
+ this._conditionallyClear = true;
695
+ return this._conditionallyClear;
665
696
  }
666
697
  // If we have a condition and it is not conditionally visible, the it should conditionally clear.
667
- if (this.hasCondition() && !this.conditionallyVisible()) {
668
- return true;
669
- }
670
- if (skipParent) {
671
- // Stop recurrsion for the parent checks.
672
- return false;
673
- }
674
- // If this component has a set value, then it should ONLY clear if a parent is hidden
675
- // and has the clearOnHide set to true.
676
- if (this.hasSetValue) {
677
- return this.parentShouldConditionallyClear();
698
+ if (this.hasCondition() &&
699
+ !this.conditionallyVisible() &&
700
+ (!this.rootPristine || this.shouldConditionallyClearOnPristine())) {
701
+ this._conditionallyClear = true;
702
+ return this._conditionallyClear;
678
703
  }
679
- // Clear the value if the parent is conditionally hidden.
680
- return this.parentConditionallyHidden();
704
+ this._conditionallyClear = this.hasSetValue ? false : this.parentShouldConditionallyClear();
705
+ return this._conditionallyClear;
681
706
  }
682
- conditionallyHidden(skipParent = false) {
707
+ /**
708
+ * Returns if the component is conditionally hidden.
709
+ * @returns {boolean} - If the component is conditionally hidden.
710
+ */
711
+ conditionallyHidden() {
712
+ // If it is logically hidden, then it is conditionally hidden.
683
713
  if (this.logicallyHidden) {
684
- return true;
714
+ this._conditionallyHidden = true;
715
+ return this._conditionallyHidden;
685
716
  }
686
- if (!this.hasCondition() && !skipParent) {
687
- return this.parentConditionallyHidden();
688
- }
689
- // Return if we are not conditionally visible (conditionallyHidden)
690
- if (!this.conditionallyVisible()) {
691
- return true;
692
- }
693
- if (skipParent) {
694
- // Stop recurrsion for the parent checks.
695
- return false;
717
+ // If it has a condition, and is not conditionally visible, then it is conditionally hidden.
718
+ if (this.hasCondition() && !this.conditionallyVisible()) {
719
+ this._conditionallyHidden = true;
720
+ return this._conditionallyHidden;
696
721
  }
697
- // Check the parent.
698
- return this.parentConditionallyHidden();
722
+ // It is conditionally hidden if its parent is conditionally hidden.
723
+ this._conditionallyHidden = this.parentConditionallyHidden();
724
+ return this._conditionallyHidden;
699
725
  }
700
726
  get currentForm() {
701
727
  return this._currentForm;
@@ -3163,6 +3189,9 @@ class Component extends Element_1.default {
3163
3189
  data = data || this.rootValue;
3164
3190
  flags = flags || {};
3165
3191
  row = row || this.data;
3192
+ if (flags.noCheck) {
3193
+ return true;
3194
+ }
3166
3195
  // Some components (for legacy reasons) have calls to "checkData" in inappropriate places such
3167
3196
  // as setValue. Historically, this was bypassed by a series of cached states around the data model
3168
3197
  // which caused its own problems. We need to ensure that premium and custom components do not fall into
@@ -3177,9 +3206,6 @@ class Component extends Element_1.default {
3177
3206
  if (!flags.fromBlur) {
3178
3207
  this.checkRefreshOn(flags.changes, flags);
3179
3208
  }
3180
- if (flags.noCheck) {
3181
- return true;
3182
- }
3183
3209
  this.checkComponentConditions(data, flags, row);
3184
3210
  if (this.id !== flags.triggeredComponentId) {
3185
3211
  this.calculateComponentValue(data, flags, row);
@@ -672,7 +672,7 @@ class NestedComponent extends Field_1.default {
672
672
  validationProcessor({ scope, data, row, instance, paths }, flags) {
673
673
  var _a;
674
674
  const { dirty } = flags;
675
- if (this.root.hasExtraPages && this.page !== this.root.page) {
675
+ if (this.root && this.root.hasSubWizards && this.page !== this.root.page) {
676
676
  instance = ((_a = this.componentsMap) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(paths.dataPath))
677
677
  ? this.componentsMap[paths.dataPath]
678
678
  : this.getComponent(paths.dataPath);
@@ -821,7 +821,7 @@ class NestedComponent extends Field_1.default {
821
821
  return false;
822
822
  }
823
823
  if (component.type === 'components') {
824
- if (component.tree && component.hasValue(value)) {
824
+ if ((component.tree || component.hasInput) && component.hasValue(value)) {
825
825
  return component.setValue(lodash_1.default.get(value, component.key), flags);
826
826
  }
827
827
  return component.setValue(value, flags);
@@ -33,7 +33,7 @@ export default class FileComponent extends Field {
33
33
  get dataReady(): Promise<any>;
34
34
  loadImage(fileInfo: any): any;
35
35
  get emptyValue(): never[];
36
- getValueAsString(value: any): any;
36
+ getValueAsString(value: any, options: any): any;
37
37
  get defaultValue(): any[];
38
38
  get hasTypes(): any;
39
39
  _fileBrowseHidden: any;
@@ -114,7 +114,12 @@ class FileComponent extends Field_1.default {
114
114
  get emptyValue() {
115
115
  return [];
116
116
  }
117
- getValueAsString(value) {
117
+ getValueAsString(value, options) {
118
+ if ((options === null || options === void 0 ? void 0 : options.review) && !this.component.uploadOnly) {
119
+ return lodash_1.default.map(value, (val, index) => {
120
+ return `<a href="${val.url || '#'}" target="_blank" data-path='${this.path}' data-fileindex='${index}'>${val.originalName}</a>`;
121
+ }).join(', ');
122
+ }
118
123
  if (lodash_1.default.isArray(value)) {
119
124
  return lodash_1.default.map(value, 'originalName').join(', ');
120
125
  }
@@ -98,8 +98,6 @@ export default class FormComponent extends Component {
98
98
  * @returns {void}
99
99
  */
100
100
  onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
101
- areAllComponentsEmpty(data: any): boolean;
102
- conditionallyHidden(): boolean;
103
101
  updateSubFormVisibility(): void;
104
102
  /**
105
103
  * Determines if this form is a Nested Wizard
@@ -101,6 +101,9 @@ class FormComponent extends Component_1.default {
101
101
  }
102
102
  return this.createSubForm();
103
103
  }
104
+ shouldConditionallyClearOnPristine() {
105
+ return !this.hasSetValue && super.shouldConditionallyClearOnPristine();
106
+ }
104
107
  get dataReady() {
105
108
  return this.subFormReady || Promise.resolve();
106
109
  }
@@ -292,11 +295,13 @@ class FormComponent extends Component_1.default {
292
295
  }
293
296
  this.subForm.attach(element);
294
297
  this.valueChanged = this.hasSetValue;
295
- if (!this.valueChanged && this.dataValue.state !== 'submitted') {
296
- this.setDefaultValue();
297
- }
298
- else {
299
- this.restoreValue();
298
+ if (!this.shouldConditionallyClear()) {
299
+ if (!this.valueChanged && this.dataValue.state !== 'submitted') {
300
+ this.setDefaultValue();
301
+ }
302
+ else {
303
+ this.restoreValue();
304
+ }
300
305
  }
301
306
  }
302
307
  if (!this.builderMode && this.component.modalEdit) {
@@ -415,7 +420,7 @@ class FormComponent extends Component_1.default {
415
420
  this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
416
421
  this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
417
422
  this.subForm.on('change', () => {
418
- if (this.subForm) {
423
+ if (this.subForm && !this.shouldConditionallyClear()) {
419
424
  this.dataValue = this.subForm.getValue();
420
425
  this.triggerChange({
421
426
  noEmit: true
@@ -680,20 +685,7 @@ class FormComponent extends Component_1.default {
680
685
  this.subForm.setValue(submission, flags);
681
686
  }
682
687
  isEmpty(value = this.dataValue) {
683
- return value === null || lodash_1.default.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value === null || value === void 0 ? void 0 : value.data) && !(value === null || value === void 0 ? void 0 : value._id));
684
- }
685
- areAllComponentsEmpty(data) {
686
- let res = true;
687
- if (this.subForm) {
688
- this.subForm.everyComponent((comp) => {
689
- const componentValue = lodash_1.default.get(data, comp.key);
690
- res &= comp.isEmpty(componentValue);
691
- });
692
- }
693
- else {
694
- res = false;
695
- }
696
- return res;
688
+ return value === null || lodash_1.default.isEqual(value, this.emptyValue);
697
689
  }
698
690
  getValue() {
699
691
  if (this.subForm) {
@@ -126,7 +126,6 @@ export default class SelectComponent extends ListComponent {
126
126
  get isLoadingAvailable(): any;
127
127
  onScroll(): void;
128
128
  attachRefreshOnBlur(): void;
129
- addPlaceholderItem(placeholderValue: any): void;
130
129
  update(): void;
131
130
  addCurrentChoices(values: any, items: any, keyValue: any): any;
132
131
  getValueAsString(data: any, options: any): any;
@@ -768,10 +768,10 @@ class SelectComponent extends ListComponent_1.default {
768
768
  distance: 1000,
769
769
  };
770
770
  return Object.assign({ removeItemButton: this.component.disabled ? false : lodash_1.default.get(this.component, 'removeItemButton', true), itemSelectText: '', classNames: {
771
- containerOuter: 'choices form-group formio-choices',
772
- containerInner: this.transform('class', 'form-control ui fluid selection dropdown')
771
+ containerOuter: ['choices', 'form-group', 'formio-choices'],
772
+ containerInner: this.transform('class', 'form-control ui fluid selection dropdown').split(' '),
773
773
  }, addItemText: false, allowHTML: true, placeholder: !!this.component.placeholder, placeholderValue: placeholderValue, noResultsText: this.t('No results found'), noChoicesText: this.t('No choices to choose from'), searchPlaceholderValue: this.t('Type to search'), shouldSort: false, position: (this.component.dropdown || 'auto'), searchEnabled: useSearch, searchChoices: !this.component.searchField, searchFields: lodash_1.default.get(this, 'component.searchFields', ['label']), shadowRoot: this.root ? this.root.shadowRoot : null, fuseOptions: this.component.useExactSearch
774
- ? Object.assign({ tokenize: true, matchAllTokens: true }, commonFuseOptions) : Object.assign({}, lodash_1.default.get(this, 'component.fuseOptions', {}), Object.assign({ include: 'score', threshold: lodash_1.default.get(this, 'component.selectThreshold', 0.3) }, commonFuseOptions)), valueComparer: lodash_1.default.isEqual, resetScrollPosition: false }, customOptions);
774
+ ? Object.assign({ tokenize: true, matchAllTokens: true }, commonFuseOptions) : Object.assign({}, lodash_1.default.get(this, 'component.fuseOptions', {}), Object.assign({ include: 'score', threshold: lodash_1.default.get(this, 'component.selectThreshold', 0.3) }, commonFuseOptions)), valueComparer: lodash_1.default.isEqual, resetScrollPosition: false, duplicateItemsAllowed: false }, customOptions);
775
775
  }
776
776
  /* eslint-disable max-statements */
777
777
  attach(element) {
@@ -903,12 +903,6 @@ class SelectComponent extends ListComponent_1.default {
903
903
  this.positionDropdown();
904
904
  });
905
905
  }
906
- if (this.choices && choicesOptions.placeholderValue && this.choices._isSelectOneElement) {
907
- this.addPlaceholderItem(choicesOptions.placeholderValue);
908
- this.addEventListener(input, 'removeItem', () => {
909
- this.addPlaceholderItem(choicesOptions.placeholderValue);
910
- });
911
- }
912
906
  // Add value options.
913
907
  this.addValueOptions();
914
908
  this.setChoicesValue(this.dataValue);
@@ -996,20 +990,6 @@ class SelectComponent extends ListComponent_1.default {
996
990
  });
997
991
  }
998
992
  }
999
- addPlaceholderItem(placeholderValue) {
1000
- const items = this.choices._store.activeItems;
1001
- if (!items.length) {
1002
- this.choices._addItem({
1003
- value: '',
1004
- label: placeholderValue,
1005
- choiceId: 0,
1006
- groupId: -1,
1007
- customProperties: null,
1008
- placeholder: true,
1009
- keyCode: null
1010
- });
1011
- }
1012
- }
1013
993
  /* eslint-enable max-statements */
1014
994
  update() {
1015
995
  if (this.component.dataSrc === 'custom') {
@@ -24,4 +24,4 @@ export default class TagsComponent extends Input {
24
24
  getValueAsString(value: any): any;
25
25
  }
26
26
  import Input from '../_classes/input/Input';
27
- import Choices from '@formio/choices.js';
27
+ import Choices from 'choices.js';
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const utils_1 = require("../../utils");
7
7
  const Input_1 = __importDefault(require("../_classes/input/Input"));
8
- const choices_js_1 = __importDefault(require("@formio/choices.js"));
8
+ const choices_js_1 = __importDefault(require("choices.js"));
9
9
  class TagsComponent extends Input_1.default {
10
10
  static schema(...extend) {
11
11
  return Input_1.default.schema({
@@ -129,7 +129,7 @@ class TagsComponent extends Input_1.default {
129
129
  const changed = super.setValue(value, flags);
130
130
  if (this.choices) {
131
131
  let dataValue = this.dataValue;
132
- this.choices.removeActiveItems();
132
+ this.choices.clearStore();
133
133
  if (dataValue) {
134
134
  if (typeof dataValue === 'string') {
135
135
  dataValue = dataValue.split(this.delimiter).filter(result => result);
@@ -73,6 +73,7 @@ function registerModule(mod, defaultFn = null, options = {}) {
73
73
  case 'templates':
74
74
  for (const framework of Object.keys(mod.templates)) {
75
75
  Formio_1.Formio.Templates.extendTemplate(framework, mod.templates[framework]);
76
+ Formio_1.Formio.Templates.defaultTemplates = lodash_1.default.defaults(mod.templates[framework], Formio_1.Formio.Templates.defaultTemplates);
76
77
  }
77
78
  if (mod.templates[current]) {
78
79
  Formio_1.Formio.Templates.current = mod.templates[current];