@formio/js 5.0.0-dev.5723.99bf27e → 5.0.0-dev.5725.d52e1c4

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 (149) hide show
  1. package/Changelog.md +33 -0
  2. package/dist/formio.embed.js +1 -1
  3. package/dist/formio.embed.min.js +1 -1
  4. package/dist/formio.form.js +53 -33
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +2 -0
  7. package/dist/formio.full.js +59 -39
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +2 -0
  10. package/dist/formio.js +1 -1
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.utils.js +24 -4
  13. package/dist/formio.utils.min.js +1 -1
  14. package/dist/formio.utils.min.js.LICENSE.txt +2 -0
  15. package/lib/cjs/CDN.js +1 -2
  16. package/lib/cjs/Form.d.ts +2 -2
  17. package/lib/cjs/Form.js +11 -5
  18. package/lib/cjs/PDF.js +1 -1
  19. package/lib/cjs/PDFBuilder.js +2 -1
  20. package/lib/cjs/Webform.js +0 -1
  21. package/lib/cjs/WebformBuilder.js +8 -2
  22. package/lib/cjs/Wizard.js +1 -1
  23. package/lib/cjs/components/_classes/component/Component.d.ts +1 -1
  24. package/lib/cjs/components/_classes/component/Component.js +5 -4
  25. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
  26. package/lib/cjs/components/_classes/multivalue/Multivalue.js +43 -25
  27. package/lib/cjs/components/_classes/nested/NestedComponent.js +2 -1
  28. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +3 -0
  29. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +56 -29
  30. package/lib/cjs/components/address/Address.d.ts +6 -0
  31. package/lib/cjs/components/address/Address.js +7 -1
  32. package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -1
  33. package/lib/cjs/components/datagrid/DataGrid.js +2 -9
  34. package/lib/cjs/components/datagrid/fixtures/comp11.d.ts +50 -0
  35. package/lib/cjs/components/datagrid/fixtures/comp11.js +55 -0
  36. package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -1
  37. package/lib/cjs/components/datagrid/fixtures/index.js +3 -1
  38. package/lib/cjs/components/datamap/DataMap.js +1 -1
  39. package/lib/cjs/components/day/Day.d.ts +3 -4
  40. package/lib/cjs/components/day/Day.js +31 -10
  41. package/lib/cjs/components/editgrid/EditGrid.js +2 -5
  42. package/lib/cjs/components/editgrid/fixtures/comp17.d.ts +80 -0
  43. package/lib/cjs/components/editgrid/fixtures/comp17.js +99 -0
  44. package/lib/cjs/components/editgrid/fixtures/index.d.ts +8 -7
  45. package/lib/cjs/components/editgrid/fixtures/index.js +3 -1
  46. package/lib/cjs/components/file/File.d.ts +2 -2
  47. package/lib/cjs/components/file/File.js +13 -2
  48. package/lib/cjs/components/file/editForm/File.edit.display.js +1 -1
  49. package/lib/cjs/components/form/editForm/Form.edit.form.js +1 -1
  50. package/lib/cjs/components/form/fixtures/index.d.ts +2 -1
  51. package/lib/cjs/components/form/fixtures/index.js +3 -1
  52. package/lib/cjs/components/form/fixtures/nestedWizardForm.d.ts +771 -0
  53. package/lib/cjs/components/form/fixtures/nestedWizardForm.js +765 -0
  54. package/lib/cjs/components/panel/Panel.d.ts +1 -0
  55. package/lib/cjs/components/panel/Panel.js +1 -0
  56. package/lib/cjs/components/radio/Radio.d.ts +2 -18
  57. package/lib/cjs/components/radio/Radio.js +29 -27
  58. package/lib/cjs/components/radio/fixtures/comp12.d.ts +29 -0
  59. package/lib/cjs/components/radio/fixtures/comp12.js +36 -0
  60. package/lib/cjs/components/radio/fixtures/index.d.ts +2 -1
  61. package/lib/cjs/components/radio/fixtures/index.js +3 -1
  62. package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +6 -0
  63. package/lib/cjs/components/recaptcha/ReCaptcha.js +6 -0
  64. package/lib/cjs/components/select/Select.d.ts +38 -0
  65. package/lib/cjs/components/select/Select.js +13 -3
  66. package/lib/cjs/components/select/fixtures/comp25.d.ts +59 -0
  67. package/lib/cjs/components/select/fixtures/comp25.js +66 -0
  68. package/lib/cjs/components/select/fixtures/comp26.d.ts +44 -0
  69. package/lib/cjs/components/select/fixtures/comp26.js +59 -0
  70. package/lib/cjs/components/select/fixtures/index.d.ts +3 -1
  71. package/lib/cjs/components/select/fixtures/index.js +5 -1
  72. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +0 -22
  73. package/lib/cjs/components/selectboxes/SelectBoxes.js +12 -9
  74. package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
  75. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +0 -1
  76. package/lib/cjs/components/tags/Tags.js +3 -3
  77. package/lib/cjs/components/time/Time.form.js +2 -2
  78. package/lib/cjs/components/time/Time.js +0 -5
  79. package/lib/cjs/templates/Templates.js +1 -1
  80. package/lib/cjs/translations/en.d.ts +1 -0
  81. package/lib/cjs/translations/en.js +1 -0
  82. package/lib/mjs/CDN.js +1 -2
  83. package/lib/mjs/Form.d.ts +2 -2
  84. package/lib/mjs/Form.js +11 -5
  85. package/lib/mjs/PDF.js +1 -1
  86. package/lib/mjs/PDFBuilder.js +1 -1
  87. package/lib/mjs/Webform.js +0 -1
  88. package/lib/mjs/WebformBuilder.js +7 -2
  89. package/lib/mjs/Wizard.js +1 -1
  90. package/lib/mjs/components/_classes/component/Component.d.ts +1 -1
  91. package/lib/mjs/components/_classes/component/Component.js +2 -1
  92. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
  93. package/lib/mjs/components/_classes/multivalue/Multivalue.js +43 -25
  94. package/lib/mjs/components/_classes/nested/NestedComponent.js +2 -1
  95. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +3 -0
  96. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +57 -29
  97. package/lib/mjs/components/address/Address.d.ts +6 -0
  98. package/lib/mjs/components/address/Address.js +10 -1
  99. package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -1
  100. package/lib/mjs/components/datagrid/DataGrid.js +2 -9
  101. package/lib/mjs/components/datagrid/fixtures/comp11.d.ts +50 -0
  102. package/lib/mjs/components/datagrid/fixtures/comp11.js +53 -0
  103. package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -1
  104. package/lib/mjs/components/datagrid/fixtures/index.js +2 -1
  105. package/lib/mjs/components/datamap/DataMap.js +1 -1
  106. package/lib/mjs/components/day/Day.d.ts +3 -4
  107. package/lib/mjs/components/day/Day.js +30 -10
  108. package/lib/mjs/components/editgrid/EditGrid.js +2 -5
  109. package/lib/mjs/components/editgrid/fixtures/comp17.d.ts +80 -0
  110. package/lib/mjs/components/editgrid/fixtures/comp17.js +97 -0
  111. package/lib/mjs/components/editgrid/fixtures/index.d.ts +8 -7
  112. package/lib/mjs/components/editgrid/fixtures/index.js +2 -1
  113. package/lib/mjs/components/file/File.d.ts +2 -2
  114. package/lib/mjs/components/file/File.js +13 -2
  115. package/lib/mjs/components/file/editForm/File.edit.display.js +1 -1
  116. package/lib/mjs/components/form/editForm/Form.edit.form.js +1 -1
  117. package/lib/mjs/components/form/fixtures/index.d.ts +2 -1
  118. package/lib/mjs/components/form/fixtures/index.js +2 -1
  119. package/lib/mjs/components/form/fixtures/nestedWizardForm.d.ts +771 -0
  120. package/lib/mjs/components/form/fixtures/nestedWizardForm.js +763 -0
  121. package/lib/mjs/components/panel/Panel.d.ts +1 -0
  122. package/lib/mjs/components/panel/Panel.js +1 -0
  123. package/lib/mjs/components/radio/Radio.d.ts +2 -18
  124. package/lib/mjs/components/radio/Radio.js +32 -30
  125. package/lib/mjs/components/radio/fixtures/comp12.d.ts +29 -0
  126. package/lib/mjs/components/radio/fixtures/comp12.js +34 -0
  127. package/lib/mjs/components/radio/fixtures/index.d.ts +2 -1
  128. package/lib/mjs/components/radio/fixtures/index.js +2 -1
  129. package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +6 -0
  130. package/lib/mjs/components/recaptcha/ReCaptcha.js +9 -0
  131. package/lib/mjs/components/select/Select.d.ts +38 -0
  132. package/lib/mjs/components/select/Select.js +16 -4
  133. package/lib/mjs/components/select/fixtures/comp25.d.ts +59 -0
  134. package/lib/mjs/components/select/fixtures/comp25.js +64 -0
  135. package/lib/mjs/components/select/fixtures/comp26.d.ts +44 -0
  136. package/lib/mjs/components/select/fixtures/comp26.js +57 -0
  137. package/lib/mjs/components/select/fixtures/index.d.ts +3 -1
  138. package/lib/mjs/components/select/fixtures/index.js +3 -1
  139. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +0 -22
  140. package/lib/mjs/components/selectboxes/SelectBoxes.js +16 -9
  141. package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
  142. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +0 -1
  143. package/lib/mjs/components/tags/Tags.js +3 -3
  144. package/lib/mjs/components/time/Time.form.js +2 -2
  145. package/lib/mjs/components/time/Time.js +0 -11
  146. package/lib/mjs/templates/Templates.js +1 -1
  147. package/lib/mjs/translations/en.d.ts +1 -0
  148. package/lib/mjs/translations/en.js +1 -0
  149. package/package.json +4 -4
@@ -20,6 +20,8 @@
20
20
 
21
21
  /*! @license DOMPurify 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */
22
22
 
23
+ /*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */
24
+
23
25
  /*! formiojs v5.0.0-rc.59 | https://unpkg.com/formiojs@5.0.0-rc.59/LICENSE.txt */
24
26
 
25
27
  /**
package/lib/cjs/CDN.js CHANGED
@@ -64,8 +64,7 @@ class CDN {
64
64
  url += `/${lib}`;
65
65
  }
66
66
  // Only attach the version if this is the hosted cdn.
67
- if (cdnUrl.includes('form.io') &&
68
- version && version !== 'latest') {
67
+ if (cdnUrl.match(/cdn\.(test-)?form.io/) && version && version !== 'latest') {
69
68
  url += `/${version}`;
70
69
  }
71
70
  return url;
package/lib/cjs/Form.d.ts CHANGED
@@ -398,10 +398,10 @@ export default class Form extends Element {
398
398
  getFormInitOptions(url: string, form: import('@formio/core').Form): object;
399
399
  /**
400
400
  * Sets the form to the JSON schema of a form.
401
- * @param {import('@formio/core').Form} formParam - The form JSON to set this form to.
401
+ * @param {import('@formio/core').Form | string} formParam - The form JSON to set this form to.
402
402
  * @returns {Promise<Webform|Wizard|PDF>} - The webform instance that was created.
403
403
  */
404
- setForm(formParam: import('@formio/core').Form): Promise<Webform | Wizard | PDF>;
404
+ setForm(formParam: import('@formio/core').Form | string): Promise<Webform | Wizard | PDF>;
405
405
  _form: any;
406
406
  getSubmission(formio: any, opts: any): any;
407
407
  /**
package/lib/cjs/Form.js CHANGED
@@ -65,13 +65,13 @@ class Form extends Element_1.default {
65
65
  else {
66
66
  this.element = null;
67
67
  }
68
+ this.options = formOptions;
69
+ this.options.events = this.events;
68
70
  if (form) {
69
71
  this.setForm(form)
70
72
  .then(() => this.readyResolve(this.instance))
71
73
  .catch(this.readyReject);
72
74
  }
73
- this.options = formOptions;
74
- this.options.events = this.events;
75
75
  this.display = '';
76
76
  }
77
77
  createElement(tag, attrs, children) {
@@ -195,7 +195,7 @@ class Form extends Element_1.default {
195
195
  }
196
196
  /**
197
197
  * Sets the form to the JSON schema of a form.
198
- * @param {import('@formio/core').Form} formParam - The form JSON to set this form to.
198
+ * @param {import('@formio/core').Form | string} formParam - The form JSON to set this form to.
199
199
  * @returns {Promise<Webform|Wizard|PDF>} - The webform instance that was created.
200
200
  */
201
201
  setForm(formParam) {
@@ -222,8 +222,14 @@ class Form extends Element_1.default {
222
222
  }
223
223
  this.loading = false;
224
224
  this.instance = this.instance || this.create(form.display);
225
- const options = this.getFormInitOptions(formParam, form);
226
- this.instance.setUrl(formParam, options);
225
+ // If we're in builder mode, instance.setUrl is not a function, so just manually set the URL.
226
+ if (this.instance.setUrl) {
227
+ const options = this.getFormInitOptions(formParam, form);
228
+ this.instance.setUrl(formParam, options);
229
+ }
230
+ else {
231
+ this.instance.url = formParam;
232
+ }
227
233
  this.instance.nosubmit = false;
228
234
  this._form = this.instance.form = form;
229
235
  if (submission) {
package/lib/cjs/PDF.js CHANGED
@@ -70,7 +70,7 @@ class PDF extends Webform_1.default {
70
70
  super.destroy(all);
71
71
  }
72
72
  rebuild() {
73
- if (this.attached && this.builderMode && this.component.components) {
73
+ if (this.builderMode && this.component.components) {
74
74
  this.destroyComponents();
75
75
  this.addComponents();
76
76
  return Promise.resolve();
@@ -403,6 +403,7 @@ class PDFBuilder extends WebformBuilder_1.default {
403
403
  return false;
404
404
  }
405
405
  onDragEnd(e) {
406
+ var _a;
406
407
  // IMPORTANT - must retrieve offsets BEFORE disabling the dropzone - offsets will
407
408
  // reflect absolute positioning if accessed after the target element is hidden
408
409
  const iframeRect = this.webform.refs.iframeContainer.getBoundingClientRect();
@@ -435,7 +436,7 @@ class PDFBuilder extends WebformBuilder_1.default {
435
436
  lodash_1.default.merge(schema, info);
436
437
  }
437
438
  // Set a unique key for this component.
438
- builder_1.default.uniquify([this.webform._form], schema);
439
+ builder_1.default.uniquify(((_a = this.webform._form) === null || _a === void 0 ? void 0 : _a.components) || [], schema);
439
440
  this.webform._form.components.push(schema);
440
441
  schema.overlay = {
441
442
  top: layerY ? (layerY - this.itemOffsetY + HEIGHT) : (e.clientY - iframeRect.top - (this.itemOffsetY - HEIGHT) * 2),
@@ -826,7 +826,6 @@ class Webform extends NestedDataComponent_1.default {
826
826
  if (!submission || !submission.data) {
827
827
  submission = {
828
828
  data: {},
829
- metadata: submission.metadata,
830
829
  };
831
830
  }
832
831
  // Metadata needs to be available before setValue
@@ -208,7 +208,8 @@ class WebformBuilder extends Component_1.default {
208
208
  params: {
209
209
  type: 'resource',
210
210
  limit: 1000000,
211
- select: '_id,title,name,components'
211
+ select: '_id,title,name,components',
212
+ 'tags__ne': 'noBuilderResource'
212
213
  }
213
214
  };
214
215
  if (this.options && this.options.resourceTag) {
@@ -1064,7 +1065,10 @@ class WebformBuilder extends Component_1.default {
1064
1065
  'calculateValue',
1065
1066
  'conditional',
1066
1067
  'customConditional',
1067
- 'id'
1068
+ 'id',
1069
+ 'fields.day.required',
1070
+ 'fields.month.required',
1071
+ 'fields.year.required',
1068
1072
  ]));
1069
1073
  const parentComponent = defaultValueComponent.parent;
1070
1074
  let tabIndex = -1;
@@ -1240,6 +1244,7 @@ class WebformBuilder extends Component_1.default {
1240
1244
  const previewButtons = this.componentEdit.querySelectorAll(`[${this._referenceAttributeName}="previewButton"]`);
1241
1245
  previewButtons.forEach((previewButton) => {
1242
1246
  this.editForm.addEventListener(previewButton, 'click', (event) => {
1247
+ var _a;
1243
1248
  event.preventDefault();
1244
1249
  this.showPreview = !this.showPreview;
1245
1250
  this.editForm.detach();
@@ -1251,6 +1256,7 @@ class WebformBuilder extends Component_1.default {
1251
1256
  helplinks: this.helplinks,
1252
1257
  }));
1253
1258
  this.editForm.attach(this.componentEdit.querySelector(`[${this._referenceAttributeName}="editForm"]`));
1259
+ this.updateComponent((_a = this.editForm.submission.data) !== null && _a !== void 0 ? _a : component);
1254
1260
  this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
1255
1261
  });
1256
1262
  });
package/lib/cjs/Wizard.js CHANGED
@@ -18,7 +18,7 @@ class Wizard extends Webform_1.default {
18
18
  */
19
19
  constructor(elementOrOptions = undefined, _options = undefined) {
20
20
  let element, options;
21
- if (elementOrOptions instanceof HTMLElement || options) {
21
+ if (elementOrOptions instanceof HTMLElement || _options) {
22
22
  element = elementOrOptions;
23
23
  options = _options || {};
24
24
  }
@@ -1076,7 +1076,7 @@ declare class Component extends Element {
1076
1076
  elementInfo(): any;
1077
1077
  autofocus(): void;
1078
1078
  scrollIntoView(element?: any): void;
1079
- focus(index?: number): void;
1079
+ focus(index: any): void;
1080
1080
  /**
1081
1081
  * Get `Formio` instance for working with files
1082
1082
  * @returns {import('@formio/core').Formio} - The Formio instance file service.
@@ -3463,14 +3463,15 @@ class Component extends Element_1.default {
3463
3463
  const { left, top } = element.getBoundingClientRect();
3464
3464
  window.scrollTo(left + window.scrollX, top + window.scrollY);
3465
3465
  }
3466
- focus(index = (this.refs.input.length - 1)) {
3467
- var _a, _b;
3466
+ focus(index) {
3467
+ var _a, _b, _c;
3468
3468
  if ('beforeFocus' in this.parent) {
3469
3469
  this.parent.beforeFocus(this);
3470
3470
  }
3471
- if ((_a = this.refs.input) === null || _a === void 0 ? void 0 : _a.length) {
3471
+ index = index || ((_a = this.refs.input) === null || _a === void 0 ? void 0 : _a.length) - 1;
3472
+ if ((_b = this.refs.input) === null || _b === void 0 ? void 0 : _b.length) {
3472
3473
  const focusingInput = this.refs.input[index];
3473
- if (((_b = this.component.widget) === null || _b === void 0 ? void 0 : _b.type) === 'calendar') {
3474
+ if (((_c = this.component.widget) === null || _c === void 0 ? void 0 : _c.type) === 'calendar') {
3474
3475
  const sibling = focusingInput.nextSibling;
3475
3476
  if (sibling) {
3476
3477
  sibling.focus();
@@ -1,6 +1,5 @@
1
1
  export default class Multivalue extends Field {
2
2
  get addAnother(): string;
3
- useWrapper(): any;
4
3
  /**
5
4
  * @returns {Field} - The created field.
6
5
  */
@@ -6,12 +6,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Field_1 = __importDefault(require("../field/Field"));
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  class Multivalue extends Field_1.default {
9
- get dataValue() {
10
- const parent = super.dataValue;
11
- if (!parent && this.component.multiple) {
12
- return [];
9
+ /**
10
+ * Normalize values coming into updateValue.
11
+ * @param {*} value - The value to normalize before setting.
12
+ * @returns {*} - The normalized value.
13
+ */
14
+ normalizeValue(value) {
15
+ if (this.component.multiple) {
16
+ if (Array.isArray(value)) {
17
+ if (value.length === 0) {
18
+ return [this.emptyValue];
19
+ }
20
+ if (this.component.storeas === 'array') {
21
+ return super.normalizeValue([value]);
22
+ }
23
+ return super.normalizeValue(value);
24
+ }
25
+ else {
26
+ return super.normalizeValue(value == null ? [this.emptyValue] : [value]);
27
+ }
28
+ }
29
+ else {
30
+ if (Array.isArray(value) && this.component.storeas !== 'array') {
31
+ if (this.component.storeas === 'string') {
32
+ return super.normalizeValue(value.join(this.delimiter || ''));
33
+ }
34
+ return super.normalizeValue(value[0] || this.emptyValue);
35
+ }
36
+ else {
37
+ return super.normalizeValue(value);
38
+ }
13
39
  }
14
- return parent;
40
+ }
41
+ get dataValue() {
42
+ return super.dataValue;
15
43
  }
16
44
  set dataValue(value) {
17
45
  super.dataValue = value;
@@ -31,30 +59,20 @@ class Multivalue extends Field_1.default {
31
59
  get addAnother() {
32
60
  return this.t(this.component.addAnother || 'Add Another');
33
61
  }
34
- useWrapper() {
35
- return this.component.hasOwnProperty('multiple') && this.component.multiple;
36
- }
37
62
  /**
38
63
  * @returns {Field} - The created field.
39
64
  */
40
65
  render() {
41
- // If single value field.
42
- if (!this.useWrapper()) {
43
- return super.render(`<div ${this._referenceAttributeName}="element">
44
- ${this.renderElement(this.component.type !== 'hidden' ? this.dataValue : '')}
45
- </div>`);
46
- }
47
- // Make sure dataValue is in the correct array format.
48
- let dataValue = this.dataValue;
49
- if (!Array.isArray(dataValue)) {
50
- dataValue = dataValue ? [dataValue] : [];
51
- }
52
- // If multiple value field.
53
- return super.render(this.renderTemplate('multiValueTable', {
54
- rows: dataValue.map(this.renderRow.bind(this)).join(''),
55
- disabled: this.disabled,
56
- addAnother: this.addAnother,
57
- }));
66
+ let dataValue = this.normalizeValue(this.dataValue);
67
+ return this.component.hasOwnProperty('multiple') && this.component.multiple
68
+ ? super.render(this.renderTemplate('multiValueTable', {
69
+ rows: dataValue.map(this.renderRow.bind(this)).join(''),
70
+ disabled: this.disabled,
71
+ addAnother: this.addAnother,
72
+ }))
73
+ : super.render(`<div ${this._referenceAttributeName}="element">
74
+ ${this.renderElement(this.component.type !== 'hidden' ? dataValue : '')}
75
+ </div>`);
58
76
  }
59
77
  renderElement() {
60
78
  return '';
@@ -497,6 +497,7 @@ class NestedComponent extends Field_1.default {
497
497
  header: 'single',
498
498
  collapsed: this.collapsed,
499
499
  [this.nestedKey]: 'single',
500
+ messageContainer: 'single-scope',
500
501
  });
501
502
  let childPromise = Promise.resolve();
502
503
  if (this.refs[this.nestedKey]) {
@@ -684,7 +685,7 @@ class NestedComponent extends Field_1.default {
684
685
  validationProcessor({ scope, data, row, instance, component }, flags) {
685
686
  const { dirty } = flags;
686
687
  if (this.root.hasExtraPages && this.page !== this.root.page) {
687
- instance = this.getComponentById(component.id);
688
+ instance = this.getComponent(component.path);
688
689
  }
689
690
  if (!instance) {
690
691
  return;
@@ -12,6 +12,9 @@ export default class NestedArrayComponent extends NestedDataComponent {
12
12
  hasAddButton(): any;
13
13
  getComponent(path: any, fn: any, originalPath: any): any;
14
14
  everyComponent(fn: any, rowIndex: any, options?: {}): void;
15
+ _getEmailTableHeader(options: any): string;
16
+ _getEmailTableBody(options: any): string;
15
17
  getComponents(rowIndex: any): any;
18
+ removeSubmissionMetadataRow(index: any): void;
16
19
  }
17
20
  import NestedDataComponent from '../nesteddata/NestedDataComponent';
@@ -149,39 +149,60 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
149
149
  }
150
150
  });
151
151
  }
152
+ _getEmailTableHeader(options) {
153
+ let row = '';
154
+ const getHeaderCell = (component) => {
155
+ if (!component.isInputComponent || !component.visible || component.skipInEmail) {
156
+ return '';
157
+ }
158
+ const label = component.label || component.key;
159
+ return `<th style="padding: 5px 10px;">${label}</th>`;
160
+ };
161
+ const components = this.getComponents(0);
162
+ for (const component of components) {
163
+ if (component.isInputComponent) {
164
+ row += getHeaderCell(component);
165
+ }
166
+ else if ((0, utils_1.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
167
+ component.everyComponent((comp) => {
168
+ row += getHeaderCell(comp);
169
+ }, options);
170
+ }
171
+ }
172
+ return `<thead><tr>${row}</tr></thead>`;
173
+ }
174
+ _getEmailTableBody(options) {
175
+ const getBodyCell = (component) => {
176
+ if (!component.isInputComponent || !component.visible || component.skipInEmail) {
177
+ return '';
178
+ }
179
+ return `<td style="padding: 5px 10px;">${component.getView(component.dataValue, options)}</td>`;
180
+ };
181
+ const rows = [];
182
+ for (const { components } of this.iteratableRows) {
183
+ let row = '';
184
+ for (const component of components) {
185
+ if (component.isInputComponent) {
186
+ row += getBodyCell(component);
187
+ }
188
+ else if ((0, utils_1.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
189
+ component.everyComponent((comp) => {
190
+ row += getBodyCell(comp);
191
+ }, options);
192
+ }
193
+ }
194
+ rows.push(`<tr>${row}</tr>`);
195
+ }
196
+ return `<tbody>${rows.join('')}</tbody>`;
197
+ }
152
198
  getValueAsString(value, options) {
153
- var _a;
154
199
  if (options === null || options === void 0 ? void 0 : options.email) {
155
- let result = (`
200
+ return `
156
201
  <table border="1" style="width:100%">
157
- <thead>
158
- <tr>
159
- `);
160
- (_a = this.component.components) === null || _a === void 0 ? void 0 : _a.forEach((component) => {
161
- const label = component.label || component.key;
162
- result += `<th style="padding: 5px 10px;">${label}</th>`;
163
- });
164
- result += (`
165
- </tr>
166
- </thead>
167
- <tbody>
168
- `);
169
- this.iteratableRows.forEach(({ components }) => {
170
- result += '<tr>';
171
- lodash_1.default.each(components, (component) => {
172
- result += '<td style="padding:5px 10px;">';
173
- if (component.isInputComponent && component.visible && !component.skipInEmail) {
174
- result += component.getView(component.dataValue, options);
175
- }
176
- result += '</td>';
177
- });
178
- result += '</tr>';
179
- });
180
- result += (`
181
- </tbody>
202
+ ${this._getEmailTableHeader(options)}
203
+ ${this._getEmailTableBody(options)}
182
204
  </table>
183
- `);
184
- return result;
205
+ `;
185
206
  }
186
207
  if (!value || !value.length) {
187
208
  return '';
@@ -197,5 +218,11 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
197
218
  }
198
219
  return super.getComponents();
199
220
  }
221
+ removeSubmissionMetadataRow(index) {
222
+ const componentMetadata = lodash_1.default.get(this.root, `submission.metadata.selectData.${this.path}`, null);
223
+ if (lodash_1.default.isArray(componentMetadata)) {
224
+ componentMetadata.splice(index, 1);
225
+ }
226
+ }
200
227
  }
201
228
  exports.default = NestedArrayComponent;
@@ -11,6 +11,12 @@ export default class AddressComponent extends ContainerComponent {
11
11
  weight: number;
12
12
  schema: any;
13
13
  };
14
+ static get serverConditionSettings(): {
15
+ operators: string[];
16
+ };
17
+ static get conditionOperatorsSettings(): {
18
+ operators: string[];
19
+ };
14
20
  static get modeSwitcherRef(): string;
15
21
  static get removeValueIconRef(): string;
16
22
  static get searchInputRef(): string;
@@ -97,6 +97,12 @@ class AddressComponent extends Container_1.default {
97
97
  schema: AddressComponent.schema(),
98
98
  };
99
99
  }
100
+ static get serverConditionSettings() {
101
+ return AddressComponent.conditionOperatorsSettings;
102
+ }
103
+ static get conditionOperatorsSettings() {
104
+ return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: ['isEmpty', 'isNotEmpty'] });
105
+ }
100
106
  mergeSchema(component = {}) {
101
107
  let { defaultSchema } = this;
102
108
  if (component.components) {
@@ -188,7 +194,7 @@ class AddressComponent extends Container_1.default {
188
194
  return (this.manualModeEnabled && this.dataValue) ? this.dataValue.address : this.dataValue;
189
195
  }
190
196
  set address(value) {
191
- if (this.manualModeEnabled && !this.isMultiple) {
197
+ if (this.manualModeEnabled && !this.isMultiple && !lodash_1.default.isEqual(value, this.emptyValue)) {
192
198
  this.dataValue.address = value;
193
199
  }
194
200
  else {
@@ -59,7 +59,6 @@ export default class DataGridComponent extends NestedArrayComponent {
59
59
  getRows(): {}[];
60
60
  getColumns(): any[];
61
61
  hasHeader(): any;
62
- loadRefs(element: any, refs: any): void;
63
62
  dragula: any;
64
63
  getComponentsContainer(): any;
65
64
  /**
@@ -263,13 +263,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
263
263
  return hasHeader || ((col.label || col.title) && !col.hideLabel);
264
264
  }, false);
265
265
  }
266
- loadRefs(element, refs) {
267
- super.loadRefs(element, refs);
268
- if (refs['messageContainer'] === 'single') {
269
- const container = lodash_1.default.last(element.querySelectorAll(`[${this._referenceAttributeName}=messageContainer]`));
270
- this.refs['messageContainer'] = container || this.refs['messageContainer'];
271
- }
272
- }
273
266
  attach(element) {
274
267
  this.loadRefs(element, {
275
268
  [`${this.datagridKey}-row`]: 'multiple',
@@ -278,7 +271,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
278
271
  [`${this.datagridKey}-removeRow`]: 'multiple',
279
272
  [`${this.datagridKey}-group-header`]: 'multiple',
280
273
  [this.datagridKey]: 'multiple',
281
- 'messageContainer': 'single'
282
274
  });
283
275
  if (this.allowReorder) {
284
276
  this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
@@ -444,10 +436,11 @@ class DataGridComponent extends NestedArrayComponent_1.default {
444
436
  }
445
437
  removeRow(index) {
446
438
  const makeEmpty = index === 0 && this.rows.length === 1;
447
- const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
439
+ const flags = { isReordered: !makeEmpty, resetValue: makeEmpty, modified: true };
448
440
  this.splice(index, flags);
449
441
  this.emit('dataGridDeleteRow', { index });
450
442
  const [row] = this.rows.splice(index, 1);
443
+ this.removeSubmissionMetadataRow(index);
451
444
  this.removeRowComponents(row);
452
445
  this.updateRowsComponents(index);
453
446
  this.setValue(this.dataValue, flags);
@@ -0,0 +1,50 @@
1
+ declare namespace _default {
2
+ let title: string;
3
+ let name: string;
4
+ let path: string;
5
+ let type: string;
6
+ let display: string;
7
+ let components: ({
8
+ label: string;
9
+ reorder: boolean;
10
+ addAnotherPosition: string;
11
+ layoutFixed: boolean;
12
+ enableRowGroups: boolean;
13
+ initEmpty: boolean;
14
+ tableView: boolean;
15
+ key: string;
16
+ type: string;
17
+ input: boolean;
18
+ components: {
19
+ label: string;
20
+ widget: string;
21
+ tableView: boolean;
22
+ data: {
23
+ values: {
24
+ label: string;
25
+ value: string;
26
+ }[];
27
+ };
28
+ validateWhenHidden: boolean;
29
+ key: string;
30
+ type: string;
31
+ input: boolean;
32
+ defaultValue: string;
33
+ }[];
34
+ disableOnInvalid?: undefined;
35
+ } | {
36
+ type: string;
37
+ label: string;
38
+ key: string;
39
+ disableOnInvalid: boolean;
40
+ input: boolean;
41
+ tableView: boolean;
42
+ reorder?: undefined;
43
+ addAnotherPosition?: undefined;
44
+ layoutFixed?: undefined;
45
+ enableRowGroups?: undefined;
46
+ initEmpty?: undefined;
47
+ components?: undefined;
48
+ })[];
49
+ }
50
+ export default _default;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ title: 'Select in Data Grid',
5
+ name: 'selectInDataGrid',
6
+ path: 'selectInDataGrid',
7
+ type: 'form',
8
+ display: 'form',
9
+ components: [
10
+ {
11
+ label: 'Data Grid',
12
+ reorder: false,
13
+ addAnotherPosition: 'bottom',
14
+ layoutFixed: false,
15
+ enableRowGroups: false,
16
+ initEmpty: false,
17
+ tableView: false,
18
+ key: 'dataGrid',
19
+ type: 'datagrid',
20
+ input: true,
21
+ components: [
22
+ {
23
+ label: 'Select',
24
+ widget: 'choicesjs',
25
+ tableView: true,
26
+ data: {
27
+ values: [
28
+ {
29
+ label: 'Individual',
30
+ value: 'individual'
31
+ },
32
+ {
33
+ label: 'Entity',
34
+ value: 'entity'
35
+ }
36
+ ]
37
+ },
38
+ validateWhenHidden: false,
39
+ key: 'select',
40
+ type: 'select',
41
+ input: true,
42
+ defaultValue: 'entity'
43
+ },
44
+ ]
45
+ },
46
+ {
47
+ type: 'button',
48
+ label: 'Submit',
49
+ key: 'submit',
50
+ disableOnInvalid: true,
51
+ input: true,
52
+ tableView: false
53
+ }
54
+ ]
55
+ };
@@ -8,6 +8,7 @@ import comp7 from './comp7';
8
8
  import comp8 from './comp8';
9
9
  import comp9 from './comp9';
10
10
  import comp10 from './comp10';
11
+ import comp11 from './comp11';
11
12
  import withCollapsibleRowGroups from './comp-with-collapsible-groups';
12
13
  import withConditionalFieldsAndValidations from './comp-with-conditional-components-and-validations';
13
14
  import withDefValue from './comp-with-def-value';
@@ -18,4 +19,4 @@ import withAllowCalculateOverride from './comp-with-allow-calculate-override';
18
19
  import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
19
20
  import withCheckboxes from './comp-with-checkboxes';
20
21
  import withReorder from './comp-with-reorder';
21
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes, withReorder };
22
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes, withReorder };
@@ -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.withReorder = exports.withCheckboxes = exports.twoWithAllowCalculatedOverride = exports.withAllowCalculateOverride = exports.modalWithRequiredFields = exports.withRowGroupsAndDefValue = exports.withLogic = exports.withDefValue = exports.withConditionalFieldsAndValidations = exports.withCollapsibleRowGroups = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
6
+ exports.withReorder = exports.withCheckboxes = exports.twoWithAllowCalculatedOverride = exports.withAllowCalculateOverride = exports.modalWithRequiredFields = exports.withRowGroupsAndDefValue = exports.withLogic = exports.withDefValue = exports.withConditionalFieldsAndValidations = exports.withCollapsibleRowGroups = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
7
7
  const comp1_1 = __importDefault(require("./comp1"));
8
8
  exports.comp1 = comp1_1.default;
9
9
  const comp2_1 = __importDefault(require("./comp2"));
@@ -24,6 +24,8 @@ const comp9_1 = __importDefault(require("./comp9"));
24
24
  exports.comp9 = comp9_1.default;
25
25
  const comp10_1 = __importDefault(require("./comp10"));
26
26
  exports.comp10 = comp10_1.default;
27
+ const comp11_1 = __importDefault(require("./comp11"));
28
+ exports.comp11 = comp11_1.default;
27
29
  const comp_with_def_value_1 = __importDefault(require("./comp-with-def-value"));
28
30
  exports.withDefValue = comp_with_def_value_1.default;
29
31
  const comp_row_groups_with_def_value_1 = __importDefault(require("./comp-row-groups-with-def-value"));
@@ -241,7 +241,7 @@ class DataMapComponent extends DataGrid_1.default {
241
241
  delete dataValue[key];
242
242
  const comp = components[this.valueKey];
243
243
  comp.component.key = newKey;
244
- comp.path = Components_1.default.calculateComponentPath(comp);
244
+ comp.path = Components_1.default.getComponentPath(comp);
245
245
  key = newKey;
246
246
  });
247
247
  const valueComponent = lodash_1.default.clone(this.component.valueComponent);