@formio/js 5.1.0-dev.6180.de668a0 → 5.1.0-dev.6182.657a3eb

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 (43) 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 +8 -8
  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 +11 -11
  11. package/dist/formio.full.min.css +1 -1
  12. package/dist/formio.full.min.js +1 -1
  13. package/dist/formio.js +1 -1
  14. package/dist/formio.min.js +1 -1
  15. package/lib/cjs/PDFBuilder.js +8 -6
  16. package/lib/cjs/Webform.js +8 -0
  17. package/lib/cjs/WebformBuilder.js +11 -3
  18. package/lib/cjs/Wizard.js +7 -6
  19. package/lib/cjs/components/_classes/component/Component.js +1 -1
  20. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  21. package/lib/cjs/components/_classes/nested/NestedComponent.js +5 -2
  22. package/lib/cjs/components/address/Address.js +3 -3
  23. package/lib/cjs/components/address/editForm/Address.edit.provider.js +1 -1
  24. package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -2
  25. package/lib/cjs/components/form/Form.d.ts +1 -1
  26. package/lib/cjs/components/form/Form.js +22 -17
  27. package/lib/cjs/components/tags/Tags.js +7 -0
  28. package/lib/cjs/providers/storage/url.js +7 -3
  29. package/lib/mjs/PDFBuilder.js +8 -6
  30. package/lib/mjs/Webform.js +8 -0
  31. package/lib/mjs/WebformBuilder.js +11 -3
  32. package/lib/mjs/Wizard.js +7 -6
  33. package/lib/mjs/components/_classes/component/Component.js +1 -1
  34. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  35. package/lib/mjs/components/_classes/nested/NestedComponent.js +4 -2
  36. package/lib/mjs/components/address/Address.js +3 -3
  37. package/lib/mjs/components/address/editForm/Address.edit.provider.js +1 -1
  38. package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -2
  39. package/lib/mjs/components/form/Form.d.ts +1 -1
  40. package/lib/mjs/components/form/Form.js +22 -17
  41. package/lib/mjs/components/tags/Tags.js +7 -0
  42. package/lib/mjs/providers/storage/url.js +7 -3
  43. package/package.json +1 -1
@@ -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) {
@@ -1099,7 +1107,7 @@ class WebformBuilder extends Component_1.default {
1099
1107
  const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
1100
1108
  lodash_1.default.pull(newComp.validators, 'required');
1101
1109
  parentComponent.tabs[tabIndex].splice(index, 1, newComp);
1102
- newComp.checkValidity = () => true;
1110
+ newComp.processOwnValidation = true;
1103
1111
  newComp.build(defaultValueComponent.element);
1104
1112
  if (this.preview && !this.preview.defaultChanged) {
1105
1113
  const defaultValue = lodash_1.default.get(this.preview._data, this.editForm._data.key);
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
  }
@@ -2563,7 +2563,7 @@ class Component extends Element_1.default {
2563
2563
  if ((value !== null) && (value !== undefined)) {
2564
2564
  value = this.hook('setDataValue', value, this.key, this._data);
2565
2565
  }
2566
- if ((value === null) || (value === undefined)) {
2566
+ if ((value === null) || (value === undefined) || lodash_1.default.isNaN(value)) {
2567
2567
  this.unset();
2568
2568
  return;
2569
2569
  }
@@ -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',
@@ -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;
@@ -290,29 +290,34 @@ 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
+ });
314
319
  }
315
- this.calculateValue();
320
+ postAttach();
316
321
  });
317
322
  });
318
323
  }
@@ -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 '';
@@ -127,13 +127,17 @@ function url(formio) {
127
127
  deleteFile(fileInfo, options) {
128
128
  return new Promise((resolve, reject) => {
129
129
  const xhr = new XMLHttpRequest();
130
- xhr.open('DELETE', fileInfo.url, true);
130
+ xhr.open("DELETE", fileInfo.url, true);
131
+ const token = formio.getToken();
132
+ if (token) {
133
+ xhr.setRequestHeader("x-jwt-token", token);
134
+ }
131
135
  xhr.onload = () => {
132
136
  if (xhr.status >= 200 && xhr.status < 300) {
133
- resolve('File deleted');
137
+ resolve("File deleted");
134
138
  }
135
139
  else {
136
- reject(xhr.response || 'Unable to delete file');
140
+ reject(xhr.response || "Unable to delete file");
137
141
  }
138
142
  };
139
143
  if (options) {
@@ -447,18 +447,20 @@ export default class PDFBuilder extends WebformBuilder {
447
447
  const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
448
448
  // update elements which path was duplicated if any pathes have been changed
449
449
  if (!_.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
450
- eachComponent(this.webform.getComponents(), (comp) => {
451
- if (this.repeatablePathsComps.includes(comp.component)) {
452
- this.webform.postMessage({ name: 'updateElement', data: comp.component });
453
- }
454
- });
450
+ if (!_.isEmpty(this.repeatablePathsComps)) {
451
+ eachComponent(this.webform.getComponents(), (comp) => {
452
+ if (this.repeatablePathsComps.includes(comp.component)) {
453
+ this.webform.postMessage({ name: 'updateElement', data: comp.component });
454
+ }
455
+ });
456
+ }
455
457
  this.repeatablePathsComps = repeatablePathsComps;
456
458
  }
457
459
  if (!repeatablePathsComps.length) {
458
460
  return;
459
461
  }
460
462
  eachComponent(this.webform.getComponents(), (comp) => {
461
- if (this.repeatablePathsComps.includes(comp)) {
463
+ if (this.repeatablePathsComps.includes(comp.component)) {
462
464
  this.webform.postMessage({
463
465
  name: 'showBuilderErrors',
464
466
  data: {
@@ -333,6 +333,14 @@ export default class Webform extends NestedDataComponent {
333
333
  get shadowRoot() {
334
334
  return this.options.shadowRoot;
335
335
  }
336
+ // Webforms have no default value setting, so this should be always false
337
+ // I does not affect setting default value to nested forms
338
+ get shouldAddDefaultValue() {
339
+ return false;
340
+ }
341
+ get componentsMap() {
342
+ return this.childComponentsMap || {};
343
+ }
336
344
  /**
337
345
  * Add a language for translations
338
346
  * @param {string} code - The language code for the language being added.
@@ -63,8 +63,16 @@ export default class WebformBuilder extends Component {
63
63
  }
64
64
  this.groupOrder = this.groupOrder
65
65
  .filter(group => group && !group.ignore)
66
- .sort((a, b) => a.weight - b.weight)
67
- .map(group => group.key);
66
+ .sort((a, b) => a.weight - b.weight);
67
+ const defaultOpenedGroup = this.groupOrder.find(x => x.key !== 'basic' && x.default);
68
+ if (defaultOpenedGroup) {
69
+ this.groupOrder.forEach(x => {
70
+ if ('default' in x && x.key !== defaultOpenedGroup.key) {
71
+ x.default = false;
72
+ }
73
+ });
74
+ }
75
+ this.groupOrder = this.groupOrder.map(group => group.key);
68
76
  for (const type in Components.components) {
69
77
  const component = Components.components[type];
70
78
  if (component.builderInfo && component.builderInfo.schema) {
@@ -1082,7 +1090,7 @@ export default class WebformBuilder extends Component {
1082
1090
  const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
1083
1091
  _.pull(newComp.validators, 'required');
1084
1092
  parentComponent.tabs[tabIndex].splice(index, 1, newComp);
1085
- newComp.checkValidity = () => true;
1093
+ newComp.processOwnValidation = true;
1086
1094
  newComp.build(defaultValueComponent.element);
1087
1095
  if (this.preview && !this.preview.defaultChanged) {
1088
1096
  const defaultValue = _.get(this.preview._data, this.editForm._data.key);
package/lib/mjs/Wizard.js CHANGED
@@ -591,7 +591,7 @@ export default class Wizard extends Webform {
591
591
  if (!this._seenPages.includes(parentNum)) {
592
592
  this._seenPages = this._seenPages.concat(parentNum);
593
593
  }
594
- this.redraw().then(() => {
594
+ return this.redraw().then(() => {
595
595
  this.checkData(this.submission.data);
596
596
  this.triggerCaptcha(this.currentPage.components);
597
597
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
@@ -599,7 +599,6 @@ export default class Wizard extends Webform {
599
599
  this.showErrors(errors, true, true);
600
600
  }
601
601
  });
602
- return Promise.resolve();
603
602
  }
604
603
  else if (!this.pages.length) {
605
604
  this.redraw();
@@ -810,6 +809,11 @@ export default class Wizard extends Webform {
810
809
  }
811
810
  }
812
811
  setValue(submission, flags = {}, ignoreEstablishment) {
812
+ if (!submission || !submission.data) {
813
+ submission = {
814
+ data: {},
815
+ };
816
+ }
813
817
  const changed = this.getPages({ all: true }).reduce((changed, page) => {
814
818
  return this.setNestedValue(page, submission.data, flags, changed) || changed;
815
819
  }, false);
@@ -919,10 +923,7 @@ export default class Wizard extends Webform {
919
923
  if (pageIndex >= 0) {
920
924
  const page = this.pages[pageIndex];
921
925
  if (page && page !== this.currentPage) {
922
- return this.setPage(pageIndex).then(() => {
923
- this.showErrors(this.validate(this.localData, { dirty: true }));
924
- super.focusOnComponent(key);
925
- });
926
+ return this.setPage(pageIndex).then(() => super.focusOnComponent(key));
926
927
  }
927
928
  }
928
929
  }
@@ -2555,7 +2555,7 @@ export default class Component extends Element {
2555
2555
  if ((value !== null) && (value !== undefined)) {
2556
2556
  value = this.hook('setDataValue', value, this.key, this._data);
2557
2557
  }
2558
- if ((value === null) || (value === undefined)) {
2558
+ if ((value === null) || (value === undefined) || _.isNaN(value)) {
2559
2559
  this.unset();
2560
2560
  return;
2561
2561
  }
@@ -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.
@@ -534,8 +534,7 @@ export default class NestedComponent extends Field {
534
534
  container = container || this.component.components;
535
535
  element = this.hook('attachComponents', element, components, container, this);
536
536
  if (!element) {
537
- // Return a non-resolving promise.
538
- return (new Promise(() => { }));
537
+ return Promise.resolve();
539
538
  }
540
539
  let index = 0;
541
540
  const promises = [];
@@ -560,6 +559,9 @@ export default class NestedComponent extends Field {
560
559
  if (this.componentsMap[component.path]) {
561
560
  delete this.componentsMap[component.path];
562
561
  }
562
+ if (this.root?.componentsMap[component.path]) {
563
+ delete this.root?.componentsMap[component.path];
564
+ }
563
565
  }
564
566
  /**
565
567
  * Removes a component provided the API key of that component.
@@ -564,11 +564,11 @@ export default class AddressComponent extends ContainerComponent {
564
564
  }
565
565
  if (valueInManualMode) {
566
566
  if (this.component.manualModeViewString) {
567
- return this.interpolate(this.component.manualModeViewString, {
567
+ return this.evaluate(this.component.manualModeViewString, {
568
568
  address,
569
- data: this.data,
569
+ data: value,
570
570
  component: this.component,
571
- });
571
+ }, 'value');
572
572
  }
573
573
  return this.getComponents()
574
574
  .filter((component) => component.hasValue(address))
@@ -142,7 +142,7 @@ export default [
142
142
  key: 'manualModeViewString',
143
143
  label: 'Manual Mode View String',
144
144
  placeholder: 'Enter Manual Mode View String',
145
- description: '"address" variable references component value, "data" - submission data and "component" - address component schema.',
145
+ description: '"data.address" references component value and "component" - address component schema.',
146
146
  weight: 60,
147
147
  rows: 5,
148
148
  editor: 'ace',
@@ -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;
@@ -286,29 +286,34 @@ export default class FormComponent extends Component {
286
286
  return;
287
287
  }
288
288
  this.setContent(element, this.render());
289
+ const postAttach = () => {
290
+ if (!this.builderMode && this.component.modalEdit) {
291
+ const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
292
+ const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
293
+ this.componentModal = new ComponentModal(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
294
+ this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
295
+ this.setOpenModalElement();
296
+ }
297
+ this.calculateValue();
298
+ };
289
299
  if (this.subForm) {
290
300
  if (this.isNestedWizard) {
291
301
  element = this.root.element;
292
302
  }
293
- this.subForm.attach(element);
294
- this.valueChanged = this.hasSetValue;
295
- if (!this.shouldConditionallyClear()) {
296
- if (!this.valueChanged && this.dataValue.state !== 'submitted') {
297
- this.setDefaultValue();
298
- }
299
- else {
300
- this.restoreValue();
303
+ return this.subForm.attach(element).then(() => {
304
+ this.valueChanged = this.hasSetValue;
305
+ if (!this.shouldConditionallyClear()) {
306
+ if (!this.valueChanged && this.dataValue.state !== 'submitted') {
307
+ this.setDefaultValue();
308
+ }
309
+ else {
310
+ this.restoreValue();
311
+ }
301
312
  }
302
- }
303
- }
304
- if (!this.builderMode && this.component.modalEdit) {
305
- const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
306
- const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
307
- this.componentModal = new ComponentModal(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
308
- this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
309
- this.setOpenModalElement();
313
+ postAttach();
314
+ });
310
315
  }
311
- this.calculateValue();
316
+ postAttach();
312
317
  });
313
318
  });
314
319
  }
@@ -158,6 +158,13 @@ export default class TagsComponent extends Input {
158
158
  this.refs.input[0].parentNode.lastChild.focus();
159
159
  }
160
160
  }
161
+ getValue() {
162
+ if (this.choices) {
163
+ const value = this.choices.getValue(true);
164
+ return value.join(`${this.delimiter}`);
165
+ }
166
+ return super.getValue();
167
+ }
161
168
  getValueAsString(value) {
162
169
  if (!value) {
163
170
  return '';
@@ -125,13 +125,17 @@ function url(formio) {
125
125
  deleteFile(fileInfo, options) {
126
126
  return new Promise((resolve, reject) => {
127
127
  const xhr = new XMLHttpRequest();
128
- xhr.open('DELETE', fileInfo.url, true);
128
+ xhr.open("DELETE", fileInfo.url, true);
129
+ const token = formio.getToken();
130
+ if (token) {
131
+ xhr.setRequestHeader("x-jwt-token", token);
132
+ }
129
133
  xhr.onload = () => {
130
134
  if (xhr.status >= 200 && xhr.status < 300) {
131
- resolve('File deleted');
135
+ resolve("File deleted");
132
136
  }
133
137
  else {
134
- reject(xhr.response || 'Unable to delete file');
138
+ reject(xhr.response || "Unable to delete file");
135
139
  }
136
140
  };
137
141
  if (options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6180.de668a0",
3
+ "version": "5.1.0-dev.6182.657a3eb",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {