@formio/js 5.1.0-dev.6112.1314654 → 5.1.0-dev.6112.b627acb

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 (69) hide show
  1. package/dist/formio.builder.css +6 -0
  2. package/dist/formio.builder.min.css +1 -1
  3. package/dist/formio.embed.css +1 -1
  4. package/dist/formio.embed.min.css +1 -1
  5. package/dist/formio.form.css +6 -0
  6. package/dist/formio.form.js +38 -60
  7. package/dist/formio.form.min.css +1 -1
  8. package/dist/formio.form.min.js +1 -1
  9. package/dist/formio.full.css +6 -0
  10. package/dist/formio.full.js +42 -64
  11. package/dist/formio.full.min.css +1 -1
  12. package/dist/formio.full.min.js +1 -1
  13. package/dist/formio.js +20 -42
  14. package/dist/formio.min.js +1 -1
  15. package/dist/formio.utils.js +21 -43
  16. package/dist/formio.utils.min.js +1 -1
  17. package/lib/cjs/Element.js +2 -2
  18. package/lib/cjs/PDFBuilder.js +8 -6
  19. package/lib/cjs/Webform.js +8 -0
  20. package/lib/cjs/WebformBuilder.js +17 -6
  21. package/lib/cjs/Wizard.js +7 -6
  22. package/lib/cjs/WizardBuilder.js +4 -0
  23. package/lib/cjs/components/_classes/component/Component.d.ts +1 -0
  24. package/lib/cjs/components/_classes/component/Component.js +17 -15
  25. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  26. package/lib/cjs/components/_classes/nested/NestedComponent.js +5 -2
  27. package/lib/cjs/components/address/Address.js +3 -3
  28. package/lib/cjs/components/address/editForm/Address.edit.provider.js +1 -1
  29. package/lib/cjs/components/datagrid/DataGrid.js +8 -1
  30. package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -2
  31. package/lib/cjs/components/form/Form.d.ts +2 -1
  32. package/lib/cjs/components/form/Form.js +32 -20
  33. package/lib/cjs/components/number/Number.js +4 -1
  34. package/lib/cjs/components/radio/Radio.js +1 -1
  35. package/lib/cjs/components/select/Select.js +1 -1
  36. package/lib/cjs/components/tags/Tags.js +7 -0
  37. package/lib/cjs/formio.form.d.ts +2 -1
  38. package/lib/cjs/formio.form.js +2 -1
  39. package/lib/cjs/utils/formUtils.d.ts +3 -3
  40. package/lib/cjs/utils/index.d.ts +6 -5
  41. package/lib/cjs/utils/index.js +2 -1
  42. package/lib/cjs/widgets/CalendarWidget.js +8 -1
  43. package/lib/mjs/Element.js +2 -2
  44. package/lib/mjs/PDFBuilder.js +8 -6
  45. package/lib/mjs/Webform.js +8 -0
  46. package/lib/mjs/WebformBuilder.js +17 -6
  47. package/lib/mjs/Wizard.js +7 -6
  48. package/lib/mjs/WizardBuilder.js +4 -0
  49. package/lib/mjs/components/_classes/component/Component.d.ts +1 -0
  50. package/lib/mjs/components/_classes/component/Component.js +17 -15
  51. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  52. package/lib/mjs/components/_classes/nested/NestedComponent.js +4 -2
  53. package/lib/mjs/components/address/Address.js +3 -3
  54. package/lib/mjs/components/address/editForm/Address.edit.provider.js +1 -1
  55. package/lib/mjs/components/datagrid/DataGrid.js +7 -1
  56. package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -2
  57. package/lib/mjs/components/form/Form.d.ts +2 -1
  58. package/lib/mjs/components/form/Form.js +32 -20
  59. package/lib/mjs/components/number/Number.js +4 -1
  60. package/lib/mjs/components/radio/Radio.js +1 -1
  61. package/lib/mjs/components/select/Select.js +1 -1
  62. package/lib/mjs/components/tags/Tags.js +7 -0
  63. package/lib/mjs/formio.form.d.ts +2 -1
  64. package/lib/mjs/formio.form.js +2 -2
  65. package/lib/mjs/utils/formUtils.d.ts +3 -3
  66. package/lib/mjs/utils/index.d.ts +6 -5
  67. package/lib/mjs/utils/index.js +2 -2
  68. package/lib/mjs/widgets/CalendarWidget.js +8 -1
  69. package/package.json +2 -2
@@ -533,9 +533,9 @@ class Element {
533
533
  if (this.component.filter === string && !this.options.building) {
534
534
  const evalContext = this.evalContext(data);
535
535
  evalContext.data = lodash_1.default.mapValues(evalContext.data, (val) => lodash_1.default.isString(val) ? encodeURIComponent(val) : val);
536
- return utils_1.default.Evaluator.interpolate(string, evalContext, options);
536
+ return utils_1.default.interpolate(string, evalContext, options);
537
537
  }
538
- return utils_1.default.Evaluator.interpolate(string, this.evalContext(data), options);
538
+ return utils_1.default.interpolate(string, this.evalContext(data), options);
539
539
  }
540
540
  /**
541
541
  * Performs an evaluation using the evaluation context of this component.
@@ -454,18 +454,20 @@ class PDFBuilder extends WebformBuilder_1.default {
454
454
  const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
455
455
  // update elements which path was duplicated if any pathes have been changed
456
456
  if (!lodash_1.default.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
457
- (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
458
- if (this.repeatablePathsComps.includes(comp.component)) {
459
- this.webform.postMessage({ name: 'updateElement', data: comp.component });
460
- }
461
- });
457
+ if (!lodash_1.default.isEmpty(this.repeatablePathsComps)) {
458
+ (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
459
+ if (this.repeatablePathsComps.includes(comp.component)) {
460
+ this.webform.postMessage({ name: 'updateElement', data: comp.component });
461
+ }
462
+ });
463
+ }
462
464
  this.repeatablePathsComps = repeatablePathsComps;
463
465
  }
464
466
  if (!repeatablePathsComps.length) {
465
467
  return;
466
468
  }
467
469
  (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
468
- if (this.repeatablePathsComps.includes(comp)) {
470
+ if (this.repeatablePathsComps.includes(comp.component)) {
469
471
  this.webform.postMessage({
470
472
  name: 'showBuilderErrors',
471
473
  data: {
@@ -361,6 +361,14 @@ class Webform extends NestedDataComponent_1.default {
361
361
  get shadowRoot() {
362
362
  return this.options.shadowRoot;
363
363
  }
364
+ // Webforms have no default value setting, so this should be always false
365
+ // I does not affect setting default value to nested forms
366
+ get shouldAddDefaultValue() {
367
+ return false;
368
+ }
369
+ get componentsMap() {
370
+ return this.childComponentsMap || {};
371
+ }
364
372
  /**
365
373
  * Add a language for translations
366
374
  * @param {string} code - The language code for the language being added.
@@ -83,8 +83,16 @@ class WebformBuilder extends Component_1.default {
83
83
  }
84
84
  this.groupOrder = this.groupOrder
85
85
  .filter(group => group && !group.ignore)
86
- .sort((a, b) => a.weight - b.weight)
87
- .map(group => group.key);
86
+ .sort((a, b) => a.weight - b.weight);
87
+ const defaultOpenedGroup = this.groupOrder.find(x => x.key !== 'basic' && x.default);
88
+ if (defaultOpenedGroup) {
89
+ this.groupOrder.forEach(x => {
90
+ if ('default' in x && x.key !== defaultOpenedGroup.key) {
91
+ x.default = false;
92
+ }
93
+ });
94
+ }
95
+ this.groupOrder = this.groupOrder.map(group => group.key);
88
96
  for (const type in Components_1.default.components) {
89
97
  const component = Components_1.default.components[type];
90
98
  if (component.builderInfo && component.builderInfo.schema) {
@@ -521,8 +529,8 @@ class WebformBuilder extends Component_1.default {
521
529
  }
522
530
  return elem;
523
531
  };
524
- const hideShow = (group, show) => {
525
- if (show) {
532
+ const hideShow = (group, forceShow, toggle = false) => {
533
+ if (forceShow || (toggle && !Array.from(group.classList).includes('show'))) {
526
534
  group.classList.add(['show']);
527
535
  group.style.display = 'inherit';
528
536
  }
@@ -544,7 +552,9 @@ class WebformBuilder extends Component_1.default {
544
552
  const openByDefault = getAttribute(group, 'default') === 'true';
545
553
  const groupId = group.getAttribute('id').slice('group-'.length);
546
554
  const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);
547
- hideShow(group, ((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index));
555
+ if (((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index)) {
556
+ hideShow(group, false, true);
557
+ }
548
558
  });
549
559
  }, true);
550
560
  });
@@ -1099,7 +1109,7 @@ class WebformBuilder extends Component_1.default {
1099
1109
  const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
1100
1110
  lodash_1.default.pull(newComp.validators, 'required');
1101
1111
  parentComponent.tabs[tabIndex].splice(index, 1, newComp);
1102
- newComp.checkValidity = () => true;
1112
+ newComp.processOwnValidation = true;
1103
1113
  newComp.build(defaultValueComponent.element);
1104
1114
  if (this.preview && !this.preview.defaultChanged) {
1105
1115
  const defaultValue = lodash_1.default.get(this.preview._data, this.editForm._data.key);
@@ -1198,6 +1208,7 @@ class WebformBuilder extends Component_1.default {
1198
1208
  submissionData = submissionData.componentJson || submissionData;
1199
1209
  if (submissionData.components && this.originalDefaultValue) {
1200
1210
  submissionData.components = this.originalDefaultValue.components;
1211
+ this.originalDefaultValue = null;
1201
1212
  }
1202
1213
  const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
1203
1214
  this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
package/lib/cjs/Wizard.js CHANGED
@@ -599,7 +599,7 @@ class Wizard extends Webform_1.default {
599
599
  if (!this._seenPages.includes(parentNum)) {
600
600
  this._seenPages = this._seenPages.concat(parentNum);
601
601
  }
602
- this.redraw().then(() => {
602
+ return this.redraw().then(() => {
603
603
  this.checkData(this.submission.data);
604
604
  this.triggerCaptcha(this.currentPage.components);
605
605
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
@@ -607,7 +607,6 @@ class Wizard extends Webform_1.default {
607
607
  this.showErrors(errors, true, true);
608
608
  }
609
609
  });
610
- return Promise.resolve();
611
610
  }
612
611
  else if (!this.pages.length) {
613
612
  this.redraw();
@@ -821,6 +820,11 @@ class Wizard extends Webform_1.default {
821
820
  }
822
821
  }
823
822
  setValue(submission, flags = {}, ignoreEstablishment) {
823
+ if (!submission || !submission.data) {
824
+ submission = {
825
+ data: {},
826
+ };
827
+ }
824
828
  const changed = this.getPages({ all: true }).reduce((changed, page) => {
825
829
  return this.setNestedValue(page, submission.data, flags, changed) || changed;
826
830
  }, false);
@@ -931,10 +935,7 @@ class Wizard extends Webform_1.default {
931
935
  if (pageIndex >= 0) {
932
936
  const page = this.pages[pageIndex];
933
937
  if (page && page !== this.currentPage) {
934
- return this.setPage(pageIndex).then(() => {
935
- this.showErrors(this.validate(this.localData, { dirty: true }));
936
- super.focusOnComponent(key);
937
- });
938
+ return this.setPage(pageIndex).then(() => super.focusOnComponent(key));
938
939
  }
939
940
  }
940
941
  }
@@ -183,6 +183,10 @@ class WizardBuilder extends WebformBuilder_1.default {
183
183
  this.navigationDragula = null;
184
184
  super.detach();
185
185
  }
186
+ destroy(all = false) {
187
+ this.off('saveComponent');
188
+ super.destroy(all);
189
+ }
186
190
  rebuild() {
187
191
  var _a;
188
192
  const page = this.currentPage;
@@ -168,6 +168,7 @@ declare class Component extends Element {
168
168
  * @returns {boolean} - If the parent should conditionally clear.
169
169
  */
170
170
  parentShouldConditionallyClear(): boolean;
171
+ hasCondionallyHiddenLayoutParent(): boolean;
171
172
  parentConditionallyHidden(): boolean;
172
173
  /**
173
174
  * Returns true if any of the parents default their component "hidden" property to true.
@@ -450,6 +450,16 @@ class Component extends Element_1.default {
450
450
  }
451
451
  return false;
452
452
  }
453
+ hasCondionallyHiddenLayoutParent() {
454
+ let currentParent = this.parent;
455
+ while (currentParent) {
456
+ if (currentParent._conditionallyHidden && utils_1.default.isLayoutComponent(currentParent) && currentParent.component.clearOnHide === true) {
457
+ return true;
458
+ }
459
+ currentParent = currentParent.parent;
460
+ }
461
+ return false;
462
+ }
453
463
  parentConditionallyHidden() {
454
464
  let currentParent = this.parent;
455
465
  while (currentParent) {
@@ -633,10 +643,13 @@ class Component extends Element_1.default {
633
643
  if (!component) {
634
644
  component = this.component;
635
645
  }
646
+ if (!this.path) {
647
+ return false;
648
+ }
636
649
  if (lodash_1.default.isArray(this.options[visibility])) {
637
- return this.options[visibility].includes(component.key);
650
+ return this.options[visibility].includes(this.path);
638
651
  }
639
- return this.options[visibility][component.key];
652
+ return this.options[visibility][this.path];
640
653
  }
641
654
  shouldForceHide(component) {
642
655
  return this.shouldForceVisibility(component, 'hide');
@@ -716,7 +729,7 @@ class Component extends Element_1.default {
716
729
  this._conditionallyClear = true;
717
730
  return this._conditionallyClear;
718
731
  }
719
- this._conditionallyClear = this.hasSetValue ? false : this.parentShouldConditionallyClear();
732
+ this._conditionallyClear = this.hasSetValue ? this.hasCondionallyHiddenLayoutParent() : this.parentShouldConditionallyClear();
720
733
  return this._conditionallyClear;
721
734
  }
722
735
  /**
@@ -2563,7 +2576,7 @@ class Component extends Element_1.default {
2563
2576
  if ((value !== null) && (value !== undefined)) {
2564
2577
  value = this.hook('setDataValue', value, this.key, this._data);
2565
2578
  }
2566
- if ((value === null) || (value === undefined)) {
2579
+ if ((value === null) || (value === undefined) || lodash_1.default.isNaN(value)) {
2567
2580
  this.unset();
2568
2581
  return;
2569
2582
  }
@@ -2596,17 +2609,6 @@ class Component extends Element_1.default {
2596
2609
  noUpdateEvent: true,
2597
2610
  noDefault: true
2598
2611
  });
2599
- if (utils_1.default.isLayoutComponent(this.component) && this.component.clearOnHide === true && !this.hasValue()) {
2600
- utils_1.default.eachComponent(this.components, (component) => {
2601
- if (component.component.clearOnHide !== false) {
2602
- component.setValue(null, {
2603
- noUpdateEvent: true,
2604
- noDefault: true
2605
- });
2606
- component.unset();
2607
- }
2608
- });
2609
- }
2610
2612
  this.unset();
2611
2613
  }
2612
2614
  getCustomDefaultValue(defaultValue) {
@@ -155,7 +155,7 @@ export default class NestedComponent extends Field {
155
155
  * @param {import('@formio/core').Component[]} components - The components to attach logic to.
156
156
  */
157
157
  attachComponentsLogic(components: import('@formio/core').Component[]): void;
158
- attachComponents(element: any, components: any, container: any): Promise<any>;
158
+ attachComponents(element: any, components: any, container: any): Promise<void> | Promise<any[]>;
159
159
  /**
160
160
  * Remove a component from the components array and from the children object
161
161
  * @param {import('@formio/core').Component} component - The component to remove from the components.
@@ -538,8 +538,7 @@ class NestedComponent extends Field_1.default {
538
538
  container = container || this.component.components;
539
539
  element = this.hook('attachComponents', element, components, container, this);
540
540
  if (!element) {
541
- // Return a non-resolving promise.
542
- return (new Promise(() => { }));
541
+ return Promise.resolve();
543
542
  }
544
543
  let index = 0;
545
544
  const promises = [];
@@ -558,12 +557,16 @@ class NestedComponent extends Field_1.default {
558
557
  * @param {boolean} [all] - If set to TRUE will cascade remove all components.
559
558
  */
560
559
  removeComponent(component, components, all = false) {
560
+ var _a, _b;
561
561
  components = components || this.components;
562
562
  component.destroy(all);
563
563
  lodash_1.default.remove(components, { id: component.id });
564
564
  if (this.componentsMap[component.path]) {
565
565
  delete this.componentsMap[component.path];
566
566
  }
567
+ if ((_a = this.root) === null || _a === void 0 ? void 0 : _a.componentsMap[component.path]) {
568
+ (_b = this.root) === null || _b === void 0 ? true : delete _b.componentsMap[component.path];
569
+ }
567
570
  }
568
571
  /**
569
572
  * Removes a component provided the API key of that component.
@@ -571,11 +571,11 @@ class AddressComponent extends Container_1.default {
571
571
  }
572
572
  if (valueInManualMode) {
573
573
  if (this.component.manualModeViewString) {
574
- return this.interpolate(this.component.manualModeViewString, {
574
+ return this.evaluate(this.component.manualModeViewString, {
575
575
  address,
576
- data: this.data,
576
+ data: value,
577
577
  component: this.component,
578
- });
578
+ }, 'value');
579
579
  }
580
580
  return this.getComponents()
581
581
  .filter((component) => component.hasValue(address))
@@ -147,7 +147,7 @@ exports.default = [
147
147
  key: 'manualModeViewString',
148
148
  label: 'Manual Mode View String',
149
149
  placeholder: 'Enter Manual Mode View String',
150
- description: '"address" variable references component value, "data" - submission data and "component" - address component schema.',
150
+ description: '"data.address" references component value and "component" - address component schema.',
151
151
  weight: 60,
152
152
  rows: 5,
153
153
  editor: 'ace',
@@ -496,11 +496,18 @@ class DataGridComponent extends NestedArrayComponent_1.default {
496
496
  options.row = `${rowIndex}-${colIndex}`;
497
497
  options.rowIndex = rowIndex;
498
498
  options.onChange = (flags, changed, modified) => {
499
+ var _a, _b;
499
500
  if (changed.component.type === 'form') {
500
501
  const formComp = (0, utils_1.getComponent)(this.component.components, changed.component.key);
501
502
  lodash_1.default.set(formComp, 'components', changed.component.components);
502
503
  }
503
- this.triggerChange({ modified });
504
+ // If we're in a nested form we need to ensure our changes are triggered upstream
505
+ if (((_a = changed.instance.root) === null || _a === void 0 ? void 0 : _a.id) && (((_b = this.root) === null || _b === void 0 ? void 0 : _b.id) !== changed.instance.root.id)) {
506
+ changed.instance.root.triggerChange(flags, changed, modified);
507
+ }
508
+ else {
509
+ this.triggerChange({ modified });
510
+ }
504
511
  };
505
512
  let columnComponent;
506
513
  if (this.builderMode) {
@@ -73,10 +73,10 @@ export default class EditGridComponent extends NestedArrayComponent {
73
73
  rowIndex: any;
74
74
  } | undefined;
75
75
  emptyRow: any;
76
- addRowModal(rowIndex: any): Promise<any>;
76
+ addRowModal(rowIndex: any): Promise<void> | Promise<any[]>;
77
77
  alert: Alert | null | undefined;
78
78
  showDialog(rowIndex: any): Promise<any>;
79
- editRow(rowIndex: any): Promise<any>;
79
+ editRow(rowIndex: any): Promise<void> | Promise<any[]>;
80
80
  clearErrors(rowIndex: any): void;
81
81
  cancelRow(rowIndex: any): void;
82
82
  saveRow(rowIndex: any, modified: any): boolean | undefined;
@@ -29,7 +29,7 @@ export default class FormComponent extends Component {
29
29
  * Prints out the value of form components as a datagrid value.
30
30
  */
31
31
  getValueAsString(value: any, options: any): any;
32
- attach(element: any): Promise<void>;
32
+ attach(element: any): Promise<any>;
33
33
  get hasLoadedForm(): any;
34
34
  get isRevisionChanged(): any;
35
35
  get subFormData(): any;
@@ -42,6 +42,7 @@ export default class FormComponent extends Component {
42
42
  everyComponent(...args: any[]): any;
43
43
  setSubFormDisabled(subForm: any): void;
44
44
  updateSubWizards(subForm: any): void;
45
+ setComponentsMap(): void;
45
46
  /**
46
47
  * Create a subform instance.
47
48
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
@@ -290,29 +290,35 @@ class FormComponent extends Component_1.default {
290
290
  return;
291
291
  }
292
292
  this.setContent(element, this.render());
293
+ const postAttach = () => {
294
+ if (!this.builderMode && this.component.modalEdit) {
295
+ const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
296
+ const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
297
+ this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
298
+ this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
299
+ this.setOpenModalElement();
300
+ }
301
+ this.calculateValue();
302
+ };
293
303
  if (this.subForm) {
294
304
  if (this.isNestedWizard) {
295
305
  element = this.root.element;
296
306
  }
297
- this.subForm.attach(element);
298
- this.valueChanged = this.hasSetValue;
299
- if (!this.shouldConditionallyClear()) {
300
- if (!this.valueChanged && this.dataValue.state !== 'submitted') {
301
- this.setDefaultValue();
302
- }
303
- else {
304
- this.restoreValue();
307
+ return this.subForm.attach(element).then(() => {
308
+ this.valueChanged = this.hasSetValue;
309
+ if (!this.shouldConditionallyClear()) {
310
+ if (!this.valueChanged && this.dataValue.state !== 'submitted') {
311
+ this.setDefaultValue();
312
+ }
313
+ else {
314
+ this.restoreValue();
315
+ }
305
316
  }
306
- }
307
- }
308
- if (!this.builderMode && this.component.modalEdit) {
309
- const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
310
- const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
311
- this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
312
- this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
313
- this.setOpenModalElement();
317
+ postAttach();
318
+ this.setComponentsMap();
319
+ });
314
320
  }
315
- this.calculateValue();
321
+ postAttach();
316
322
  });
317
323
  });
318
324
  }
@@ -390,6 +396,14 @@ class FormComponent extends Component_1.default {
390
396
  this.emit('subWizardsUpdated', subForm);
391
397
  }
392
398
  }
399
+ setComponentsMap() {
400
+ if (!this.subForm) {
401
+ return;
402
+ }
403
+ const componentsMap = this.componentsMap;
404
+ const formComponentsMap = this.subForm.componentsMap;
405
+ lodash_1.default.assign(componentsMap, formComponentsMap);
406
+ }
393
407
  /**
394
408
  * Create a subform instance.
395
409
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
@@ -415,9 +429,7 @@ class FormComponent extends Component_1.default {
415
429
  this.subForm = instance;
416
430
  this.subForm.currentForm = this;
417
431
  this.subForm.parentVisible = this.visible;
418
- const componentsMap = this.componentsMap;
419
- const formComponentsMap = this.subForm.componentsMap;
420
- lodash_1.default.assign(componentsMap, formComponentsMap);
432
+ this.setComponentsMap();
421
433
  this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
422
434
  this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
423
435
  this.subForm.on('change', () => {
@@ -91,10 +91,13 @@ class NumberComponent extends Input_1.default {
91
91
  }
92
92
  get defaultValue() {
93
93
  let defaultValue = super.defaultValue;
94
- if (typeof defaultValue === 'string') {
94
+ if (typeof defaultValue === 'string' && defaultValue) {
95
95
  // Default value may be a string or have custom thousands separators or decimal symbols, so we need to call
96
96
  // parseNumber on it
97
97
  defaultValue = this.parseNumber(defaultValue);
98
+ if (lodash_1.default.isNaN(defaultValue)) {
99
+ defaultValue = null;
100
+ }
98
101
  }
99
102
  if (!defaultValue && this.component.defaultValue === 0) {
100
103
  defaultValue = this.component.defaultValue;
@@ -144,7 +144,7 @@ class RadioComponent extends ListComponent_1.default {
144
144
  });
145
145
  this.optionsLoaded = !this.component.dataSrc || this.component.dataSrc === 'values';
146
146
  this.loadedOptions = [];
147
- if (!this.visible) {
147
+ if (!this.visible || this.optionsLoaded) {
148
148
  this.itemsLoadedResolve();
149
149
  }
150
150
  // Get the template keys for this radio component.
@@ -1124,7 +1124,7 @@ class SelectComponent extends ListComponent_1.default {
1124
1124
  }
1125
1125
  // Choices will return undefined if nothing is selected. We really want '' to be empty.
1126
1126
  if (value === undefined || value === null) {
1127
- value = '';
1127
+ value = this.emptyValue;
1128
1128
  }
1129
1129
  return value;
1130
1130
  }
@@ -160,6 +160,13 @@ class TagsComponent extends Input_1.default {
160
160
  this.refs.input[0].parentNode.lastChild.focus();
161
161
  }
162
162
  }
163
+ getValue() {
164
+ if (this.choices) {
165
+ const value = this.choices.getValue(true);
166
+ return value.join(`${this.delimiter}`);
167
+ }
168
+ return super.getValue();
169
+ }
163
170
  getValueAsString(value) {
164
171
  if (!value) {
165
172
  return '';
@@ -23,4 +23,5 @@ import { Formio } from './Formio';
23
23
  import Licenses from './licenses';
24
24
  import EventEmitter from './EventEmitter';
25
25
  import Webform from './Webform';
26
- export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform };
26
+ import { DefaultEvaluator } from './utils';
27
+ export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Webform = exports.EventEmitter = exports.Licenses = exports.Formio = exports.Form = exports.Utils = exports.Templates = exports.Widgets = exports.Providers = exports.Displays = exports.Components = exports.FormioCore = exports.useModule = exports.registerModule = void 0;
6
+ exports.DefaultEvaluator = exports.Webform = exports.EventEmitter = exports.Licenses = exports.Formio = exports.Form = exports.Utils = exports.Templates = exports.Widgets = exports.Providers = exports.Displays = exports.Components = exports.FormioCore = exports.useModule = exports.registerModule = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const Formio_1 = require("./Formio");
9
9
  Object.defineProperty(exports, "Formio", { enumerable: true, get: function () { return Formio_1.Formio; } });
@@ -30,6 +30,7 @@ const Webform_1 = __importDefault(require("./Webform"));
30
30
  exports.Webform = Webform_1.default;
31
31
  const core_1 = require("@formio/core");
32
32
  const utils_2 = require("./utils");
33
+ Object.defineProperty(exports, "DefaultEvaluator", { enumerable: true, get: function () { return utils_2.DefaultEvaluator; } });
33
34
  Formio_1.Formio.loadModules = (path = `${Formio_1.Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
34
35
  Formio_1.Formio.requireLibrary(name, name, path, true)
35
36
  .then((modules) => {
@@ -26,10 +26,10 @@ export const getBestMatch: typeof Utils.getBestMatch;
26
26
  export const getComponentFromPath: typeof Utils.getComponentFromPath;
27
27
  export const getComponentValue: typeof Utils.getComponentValue;
28
28
  export const findComponents: typeof Utils.findComponents;
29
- export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => Promise<void>;
30
- export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => void;
29
+ export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined) => Promise<void>;
30
+ export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined) => void;
31
31
  export const getComponentKey: typeof Utils.getComponentKey;
32
- export const getContextualRowPath: typeof Utils.getContextualRowPath;
32
+ export const getContextualRowPath: any;
33
33
  export const getContextualRowData: typeof Utils.getContextualRowData;
34
34
  export const componentInfo: typeof Utils.componentInfo;
35
35
  export const eachComponent: typeof Utils.eachComponent;
@@ -2,7 +2,7 @@ export * from "./utils";
2
2
  export * from "./formUtils";
3
3
  export default FormioUtils;
4
4
  declare const FormioUtils: {
5
- Evaluator: import("./Evaluator").DefaultEvaluator;
5
+ Evaluator: DefaultEvaluator;
6
6
  interpolate: typeof interpolate;
7
7
  ConditionOperators: {
8
8
  [x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
@@ -37,10 +37,10 @@ declare const FormioUtils: {
37
37
  getComponentFromPath: typeof import("@formio/core/lib/utils/formUtil").getComponentFromPath;
38
38
  getComponentValue: typeof import("@formio/core/lib/utils/formUtil").getComponentValue;
39
39
  findComponents: typeof import("@formio/core/lib/utils/formUtil").findComponents;
40
- eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => Promise<void>;
41
- eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => void;
40
+ eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined) => Promise<void>;
41
+ eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined) => void;
42
42
  getComponentKey: typeof import("@formio/core/lib/utils/formUtil").getComponentKey;
43
- getContextualRowPath: typeof import("@formio/core/lib/utils/formUtil").getContextualRowPath;
43
+ getContextualRowPath: any;
44
44
  getContextualRowData: typeof import("@formio/core/lib/utils/formUtil").getContextualRowData;
45
45
  componentInfo: typeof import("@formio/core/lib/utils/formUtil").componentInfo;
46
46
  eachComponent: typeof import("@formio/core/lib/utils/formUtil").eachComponent;
@@ -164,7 +164,8 @@ declare const FormioUtils: {
164
164
  interpolateErrors: (component: Component, errors: FieldError[], interpolateFn: Function) => [];
165
165
  };
166
166
  import { Evaluator } from './Evaluator';
167
+ import { DefaultEvaluator } from './Evaluator';
167
168
  import { registerEvaluator } from './Evaluator';
168
169
  import { interpolate } from './Evaluator';
169
170
  import moment from 'moment';
170
- export { FormioUtils as Utils, Evaluator, registerEvaluator };
171
+ export { FormioUtils as Utils, Evaluator, DefaultEvaluator, registerEvaluator };
@@ -29,12 +29,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.registerEvaluator = exports.Evaluator = exports.Utils = void 0;
32
+ exports.registerEvaluator = exports.DefaultEvaluator = exports.Evaluator = exports.Utils = void 0;
33
33
  const utils = __importStar(require("./utils"));
34
34
  const formUtils = __importStar(require("./formUtils"));
35
35
  const Evaluator_1 = require("./Evaluator");
36
36
  Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
37
37
  Object.defineProperty(exports, "registerEvaluator", { enumerable: true, get: function () { return Evaluator_1.registerEvaluator; } });
38
+ Object.defineProperty(exports, "DefaultEvaluator", { enumerable: true, get: function () { return Evaluator_1.DefaultEvaluator; } });
38
39
  const conditionOperators_1 = __importDefault(require("./conditionOperators"));
39
40
  const lodash_1 = __importDefault(require("lodash"));
40
41
  const moment_1 = __importDefault(require("moment"));
@@ -123,7 +123,14 @@ class CalendarWidget extends InputWidget_1.default {
123
123
  if (this._input) {
124
124
  const { locale } = this.settings;
125
125
  if (locale && locale.length >= 2 && locale !== 'en') {
126
- return Formio_1.Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr.l10ns.${locale}`, `${Formio_1.Formio.cdn['flatpickr']}/l10n/${locale}.js`, true).then(() => this.initFlatpickr(Flatpickr));
126
+ return Formio_1.Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr.l10ns.${locale}`, `${Formio_1.Formio.cdn['flatpickr']}/l10n/${locale}.js`, true)
127
+ .catch(() => {
128
+ // fallback to en if locale fails to load
129
+ this.settings.locale = 'en';
130
+ })
131
+ .finally(() => {
132
+ this.initFlatpickr(Flatpickr);
133
+ });
127
134
  }
128
135
  else {
129
136
  this.initFlatpickr(Flatpickr);
@@ -525,9 +525,9 @@ export default class Element {
525
525
  if (this.component.filter === string && !this.options.building) {
526
526
  const evalContext = this.evalContext(data);
527
527
  evalContext.data = _.mapValues(evalContext.data, (val) => _.isString(val) ? encodeURIComponent(val) : val);
528
- return FormioUtils.Evaluator.interpolate(string, evalContext, options);
528
+ return FormioUtils.interpolate(string, evalContext, options);
529
529
  }
530
- return FormioUtils.Evaluator.interpolate(string, this.evalContext(data), options);
530
+ return FormioUtils.interpolate(string, this.evalContext(data), options);
531
531
  }
532
532
  /**
533
533
  * Performs an evaluation using the evaluation context of this component.