@formio/js 5.0.0-dev.5725.1c71137 → 5.0.0-dev.5727.73c63c0

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 (38) hide show
  1. package/Changelog.md +3 -0
  2. package/dist/formio.form.js +5 -5
  3. package/dist/formio.form.min.js +1 -1
  4. package/dist/formio.full.js +6 -6
  5. package/dist/formio.full.min.js +1 -1
  6. package/lib/cjs/WebformBuilder.js +11 -2
  7. package/lib/cjs/components/_classes/component/Component.js +1 -1
  8. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -0
  9. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +50 -29
  10. package/lib/cjs/components/editgrid/fixtures/comp17.d.ts +59 -29
  11. package/lib/cjs/components/editgrid/fixtures/comp17.js +86 -36
  12. package/lib/cjs/components/editgrid/fixtures/index.d.ts +7 -7
  13. package/lib/cjs/components/editgrid/fixtures/index.js +1 -1
  14. package/lib/cjs/components/panel/Panel.d.ts +1 -0
  15. package/lib/cjs/components/panel/Panel.js +1 -0
  16. package/lib/cjs/components/radio/Radio.js +7 -6
  17. package/lib/cjs/components/radio/fixtures/comp12.d.ts +29 -0
  18. package/lib/cjs/components/radio/fixtures/comp12.js +36 -0
  19. package/lib/cjs/components/radio/fixtures/index.d.ts +2 -1
  20. package/lib/cjs/components/radio/fixtures/index.js +3 -1
  21. package/lib/cjs/templates/Templates.js +1 -1
  22. package/lib/mjs/WebformBuilder.js +10 -2
  23. package/lib/mjs/components/_classes/component/Component.js +1 -1
  24. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -0
  25. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +51 -29
  26. package/lib/mjs/components/editgrid/fixtures/comp17.d.ts +59 -29
  27. package/lib/mjs/components/editgrid/fixtures/comp17.js +86 -36
  28. package/lib/mjs/components/editgrid/fixtures/index.d.ts +7 -7
  29. package/lib/mjs/components/editgrid/fixtures/index.js +1 -1
  30. package/lib/mjs/components/panel/Panel.d.ts +1 -0
  31. package/lib/mjs/components/panel/Panel.js +1 -0
  32. package/lib/mjs/components/radio/Radio.js +7 -6
  33. package/lib/mjs/components/radio/fixtures/comp12.d.ts +29 -0
  34. package/lib/mjs/components/radio/fixtures/comp12.js +34 -0
  35. package/lib/mjs/components/radio/fixtures/index.d.ts +2 -1
  36. package/lib/mjs/components/radio/fixtures/index.js +2 -1
  37. package/lib/mjs/templates/Templates.js +1 -1
  38. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  import _ from 'lodash';
3
- import { componentValueTypes, getStringFromComponentPath } from '../../../utils/utils';
3
+ import { componentValueTypes, getStringFromComponentPath, isLayoutComponent } from '../../../utils/utils';
4
4
  import Component from '../component/Component';
5
5
  import NestedDataComponent from '../nesteddata/NestedDataComponent';
6
6
  export default class NestedArrayComponent extends NestedDataComponent {
@@ -145,38 +145,60 @@ export default class NestedArrayComponent extends NestedDataComponent {
145
145
  }
146
146
  });
147
147
  }
148
+ _getEmailTableHeader(options) {
149
+ let row = '';
150
+ const getHeaderCell = (component) => {
151
+ if (!component.isInputComponent || !component.visible || component.skipInEmail) {
152
+ return '';
153
+ }
154
+ const label = component.label || component.key;
155
+ return `<th style="padding: 5px 10px;">${label}</th>`;
156
+ };
157
+ const components = this.getComponents(0);
158
+ for (const component of components) {
159
+ if (component.isInputComponent) {
160
+ row += getHeaderCell(component);
161
+ }
162
+ else if (isLayoutComponent(component) && typeof component.everyComponent === 'function') {
163
+ component.everyComponent((comp) => {
164
+ row += getHeaderCell(comp);
165
+ }, options);
166
+ }
167
+ }
168
+ return `<thead><tr>${row}</tr></thead>`;
169
+ }
170
+ _getEmailTableBody(options) {
171
+ const getBodyCell = (component) => {
172
+ if (!component.isInputComponent || !component.visible || component.skipInEmail) {
173
+ return '';
174
+ }
175
+ return `<td style="padding: 5px 10px;">${component.getView(component.dataValue, options)}</td>`;
176
+ };
177
+ const rows = [];
178
+ for (const { components } of this.iteratableRows) {
179
+ let row = '';
180
+ for (const component of components) {
181
+ if (component.isInputComponent) {
182
+ row += getBodyCell(component);
183
+ }
184
+ else if (isLayoutComponent(component) && typeof component.everyComponent === 'function') {
185
+ component.everyComponent((comp) => {
186
+ row += getBodyCell(comp);
187
+ }, options);
188
+ }
189
+ }
190
+ rows.push(`<tr>${row}</tr>`);
191
+ }
192
+ return `<tbody>${rows.join('')}</tbody>`;
193
+ }
148
194
  getValueAsString(value, options) {
149
195
  if (options?.email) {
150
- let result = (`
196
+ return `
151
197
  <table border="1" style="width:100%">
152
- <thead>
153
- <tr>
154
- `);
155
- this.component.components?.forEach((component) => {
156
- const label = component.label || component.key;
157
- result += `<th style="padding: 5px 10px;">${label}</th>`;
158
- });
159
- result += (`
160
- </tr>
161
- </thead>
162
- <tbody>
163
- `);
164
- this.iteratableRows.forEach(({ components }) => {
165
- result += '<tr>';
166
- _.each(components, (component) => {
167
- result += '<td style="padding:5px 10px;">';
168
- if (component.isInputComponent && component.visible && !component.skipInEmail) {
169
- result += component.getView(component.dataValue, options);
170
- }
171
- result += '</td>';
172
- });
173
- result += '</tr>';
174
- });
175
- result += (`
176
- </tbody>
198
+ ${this._getEmailTableHeader(options)}
199
+ ${this._getEmailTableBody(options)}
177
200
  </table>
178
- `);
179
- return result;
201
+ `;
180
202
  }
181
203
  if (!value || !value.length) {
182
204
  return '';
@@ -1,49 +1,79 @@
1
1
  declare namespace _default {
2
+ let type: string;
3
+ let display: string;
2
4
  let components: ({
3
5
  label: string;
4
6
  tableView: boolean;
5
- modalEdit: boolean;
6
- validateWhenHidden: boolean;
7
7
  rowDrafts: boolean;
8
8
  key: string;
9
9
  type: string;
10
- displayAsTable: boolean;
11
10
  input: boolean;
12
- components: ({
13
- label: string;
14
- applyMaskOn: string;
15
- tableView: boolean;
16
- validate: {
17
- required: boolean;
18
- };
19
- validateWhenHidden: boolean;
11
+ components: {
12
+ collapsible: boolean;
20
13
  key: string;
21
14
  type: string;
22
- input: boolean;
23
- } | {
24
15
  label: string;
25
- applyMaskOn: string;
26
- tableView: boolean;
27
- validateWhenHidden: boolean;
28
- key: string;
29
- type: string;
30
16
  input: boolean;
31
- validate?: undefined;
32
- })[];
33
- showValidations?: undefined;
34
- saveOnEnter?: undefined;
17
+ tableView: boolean;
18
+ components: {
19
+ label: string;
20
+ columns: ({
21
+ components: {
22
+ label: string;
23
+ optionsLabelPosition: string;
24
+ inline: boolean;
25
+ tableView: boolean;
26
+ values: {
27
+ label: string;
28
+ value: string;
29
+ shortcut: string;
30
+ }[];
31
+ key: string;
32
+ type: string;
33
+ input: boolean;
34
+ }[];
35
+ width: number;
36
+ offset: number;
37
+ push: number;
38
+ pull: number;
39
+ size: string;
40
+ currentWidth: number;
41
+ } | {
42
+ components: {
43
+ label: string;
44
+ applyMaskOn: string;
45
+ autoExpand: boolean;
46
+ tableView: boolean;
47
+ key: string;
48
+ conditional: {
49
+ show: boolean;
50
+ conjunction: string;
51
+ };
52
+ type: string;
53
+ input: boolean;
54
+ }[];
55
+ width: number;
56
+ offset: number;
57
+ push: number;
58
+ pull: number;
59
+ size: string;
60
+ currentWidth: number;
61
+ })[];
62
+ key: string;
63
+ type: string;
64
+ input: boolean;
65
+ tableView: boolean;
66
+ }[];
67
+ }[];
68
+ disableOnInvalid?: undefined;
35
69
  } | {
70
+ type: string;
36
71
  label: string;
37
- showValidations: boolean;
38
- tableView: boolean;
39
72
  key: string;
40
- type: string;
73
+ disableOnInvalid: boolean;
41
74
  input: boolean;
42
- saveOnEnter: boolean;
43
- modalEdit?: undefined;
44
- validateWhenHidden?: undefined;
75
+ tableView: boolean;
45
76
  rowDrafts?: undefined;
46
- displayAsTable?: undefined;
47
77
  components?: undefined;
48
78
  })[];
49
79
  }
@@ -1,47 +1,97 @@
1
1
  export default {
2
+ type: 'form',
3
+ display: 'form',
2
4
  components: [
3
5
  {
4
- "label": "Edit Grid",
5
- "tableView": false,
6
- "modalEdit": true,
7
- "validateWhenHidden": false,
8
- "rowDrafts": false,
9
- "key": "editGrid",
10
- "type": "editgrid",
11
- "displayAsTable": false,
12
- "input": true,
13
- "components": [
6
+ label: 'Edit Grid',
7
+ tableView: false,
8
+ rowDrafts: false,
9
+ key: 'editGrid',
10
+ type: 'editgrid',
11
+ input: true,
12
+ components: [
14
13
  {
15
- "label": "Text Field",
16
- "applyMaskOn": "change",
17
- "tableView": true,
18
- "validate": {
19
- "required": true
20
- },
21
- "validateWhenHidden": false,
22
- "key": "textField1",
23
- "type": "textfield",
24
- "input": true
25
- },
26
- {
27
- "label": "Text Field",
28
- "applyMaskOn": "change",
29
- "tableView": true,
30
- "validateWhenHidden": false,
31
- "key": "textField",
32
- "type": "textfield",
33
- "input": true
14
+ collapsible: false,
15
+ key: 'panel',
16
+ type: 'panel',
17
+ label: 'Panel',
18
+ input: false,
19
+ tableView: false,
20
+ components: [
21
+ {
22
+ label: 'Columns',
23
+ columns: [
24
+ {
25
+ components: [
26
+ {
27
+ label: 'Radio',
28
+ optionsLabelPosition: 'right',
29
+ inline: false,
30
+ tableView: true,
31
+ values: [
32
+ {
33
+ label: 'yes',
34
+ value: 'yes',
35
+ shortcut: ''
36
+ },
37
+ {
38
+ label: 'no',
39
+ value: 'no',
40
+ shortcut: ''
41
+ }
42
+ ],
43
+ key: 'radio',
44
+ type: 'radio',
45
+ input: true
46
+ }
47
+ ],
48
+ width: 6,
49
+ offset: 0,
50
+ push: 0,
51
+ pull: 0,
52
+ size: 'md',
53
+ currentWidth: 6
54
+ },
55
+ {
56
+ components: [
57
+ {
58
+ label: 'Text Area',
59
+ applyMaskOn: 'change',
60
+ autoExpand: false,
61
+ tableView: true,
62
+ key: 'textArea',
63
+ conditional: {
64
+ show: true,
65
+ conjunction: 'all'
66
+ },
67
+ type: 'textarea',
68
+ input: true
69
+ }
70
+ ],
71
+ width: 6,
72
+ offset: 0,
73
+ push: 0,
74
+ pull: 0,
75
+ size: 'md',
76
+ currentWidth: 6
77
+ }
78
+ ],
79
+ key: 'columns',
80
+ type: 'columns',
81
+ input: false,
82
+ tableView: false
83
+ }
84
+ ]
34
85
  }
35
86
  ]
36
87
  },
37
88
  {
38
- "label": "Submit",
39
- "showValidations": false,
40
- "tableView": false,
41
- "key": "submit",
42
- "type": "button",
43
- "input": true,
44
- "saveOnEnter": false
89
+ type: 'button',
90
+ label: 'Submit',
91
+ key: 'submit',
92
+ disableOnInvalid: true,
93
+ input: true,
94
+ tableView: false
45
95
  }
46
96
  ]
47
97
  };
@@ -1,22 +1,22 @@
1
1
  import comp1 from './comp1';
2
2
  import comp2 from './comp2';
3
3
  import comp3 from './comp3';
4
- import comp4 from './comp4';
5
- import comp5 from './comp5';
6
- import comp6 from './comp6';
7
- import comp7 from './comp7';
8
- import comp8 from './comp8';
9
- import comp9 from './comp9';
10
4
  import comp10 from './comp10';
11
5
  import comp11 from './comp11';
12
6
  import comp12 from './comp12';
13
7
  import comp13 from './comp13';
14
8
  import comp14 from './comp14';
15
9
  import comp15 from './comp15';
10
+ import comp4 from './comp4';
11
+ import comp5 from './comp5';
12
+ import comp6 from './comp6';
13
+ import comp7 from './comp7';
14
+ import comp8 from './comp8';
15
+ import comp9 from './comp9';
16
16
  import comp16 from './comp16';
17
17
  import comp17 from './comp17';
18
18
  import compOpenWhenEmpty from './comp-openWhenEmpty';
19
19
  import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenEmpty';
20
20
  import compWithCustomDefaultValue from './comp-with-custom-default-value';
21
21
  import compTestEvents from './comp-test-events';
22
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
22
+ export { comp1, comp2, comp3, comp10, comp11, comp12, comp13, comp14, comp15, comp4, comp5, comp6, comp7, comp8, comp9, comp16, comp17, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
@@ -19,4 +19,4 @@ import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenE
19
19
  import compOpenWhenEmpty from './comp-openWhenEmpty';
20
20
  import compWithCustomDefaultValue from './comp-with-custom-default-value';
21
21
  import compTestEvents from './comp-test-events';
22
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
22
+ export { comp1, comp2, comp3, comp10, comp11, comp12, comp13, comp14, comp15, comp4, comp5, comp6, comp7, comp8, comp9, comp16, comp17, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
@@ -4,6 +4,7 @@ export default class PanelComponent extends NestedComponent {
4
4
  icon: string;
5
5
  group: string;
6
6
  documentation: string;
7
+ showPreview: boolean;
7
8
  weight: number;
8
9
  schema: any;
9
10
  };
@@ -22,6 +22,7 @@ export default class PanelComponent extends NestedComponent {
22
22
  icon: 'list-alt',
23
23
  group: 'layout',
24
24
  documentation: '/userguide/form-building/layout-components#panel',
25
+ showPreview: false,
25
26
  weight: 30,
26
27
  schema: PanelComponent.schema()
27
28
  };
@@ -295,14 +295,15 @@ export default class RadioComponent extends ListComponent {
295
295
  setItems(items) {
296
296
  const listData = [];
297
297
  items?.forEach((item, i) => {
298
+ const valueAtProperty = _.get(item, this.component.valueProperty);
298
299
  this.loadedOptions[i] = {
299
- value: this.component.valueProperty ? item[this.component.valueProperty] : item,
300
- label: this.component.valueProperty ? this.itemTemplate(item, item[this.component.valueProperty]) : this.itemTemplate(item, item, i)
300
+ value: this.component.valueProperty ? valueAtProperty : item,
301
+ label: this.component.valueProperty ? this.itemTemplate(item, valueAtProperty) : this.itemTemplate(item, item, i)
301
302
  };
302
- listData.push(this.templateData[this.component.valueProperty ? item[this.component.valueProperty] : i]);
303
- if ((this.component.valueProperty || !this.isRadio) && (_.isUndefined(item[this.component.valueProperty]) ||
304
- (!this.isRadio && _.isObject(item[this.component.valueProperty])) ||
305
- (!this.isRadio && _.isBoolean(item[this.component.valueProperty])))) {
303
+ listData.push(this.templateData[this.component.valueProperty ? valueAtProperty : i]);
304
+ if ((this.component.valueProperty || !this.isRadio) && (_.isUndefined(valueAtProperty) ||
305
+ (!this.isRadio && _.isObject(valueAtProperty)) ||
306
+ (!this.isRadio && _.isBoolean(valueAtProperty)))) {
306
307
  this.loadedOptions[i].invalid = true;
307
308
  }
308
309
  });
@@ -0,0 +1,29 @@
1
+ declare namespace _default {
2
+ let components: {
3
+ label: string;
4
+ optionsLabelPosition: string;
5
+ tableView: boolean;
6
+ dataSrc: string;
7
+ values: {
8
+ label: string;
9
+ value: string;
10
+ shortcut: string;
11
+ }[];
12
+ valueProperty: string;
13
+ validateWhenHidden: boolean;
14
+ key: string;
15
+ type: string;
16
+ data: {
17
+ url: string;
18
+ headers: {
19
+ key: string;
20
+ value: string;
21
+ }[];
22
+ };
23
+ template: string;
24
+ authenticate: boolean;
25
+ input: boolean;
26
+ inputType: string;
27
+ }[];
28
+ }
29
+ export default _default;
@@ -0,0 +1,34 @@
1
+ export default {
2
+ components: [
3
+ {
4
+ "label": "Select Boxes",
5
+ "optionsLabelPosition": "right",
6
+ "tableView": false,
7
+ "dataSrc": "url",
8
+ "values": [
9
+ {
10
+ "label": "",
11
+ "value": "",
12
+ "shortcut": ""
13
+ }
14
+ ],
15
+ "valueProperty": "data.name",
16
+ "validateWhenHidden": false,
17
+ "key": "selectBoxes",
18
+ "type": "selectboxes",
19
+ "data": {
20
+ "url": "https://remote-dev.form.io/projectId/name/submission",
21
+ "headers": [
22
+ {
23
+ "key": "",
24
+ "value": ""
25
+ }
26
+ ]
27
+ },
28
+ "template": "<span>{{ item.data.name }}</span>",
29
+ "authenticate": true,
30
+ "input": true,
31
+ "inputType": "checkbox"
32
+ }
33
+ ]
34
+ };
@@ -9,4 +9,5 @@ import comp8 from './comp8';
9
9
  import comp9 from './comp9';
10
10
  import comp10 from './comp10';
11
11
  import comp11 from './comp11';
12
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11 };
12
+ import comp12 from './comp12';
13
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12 };
@@ -9,4 +9,5 @@ import comp8 from './comp8';
9
9
  import comp9 from './comp9';
10
10
  import comp10 from './comp10';
11
11
  import comp11 from './comp11';
12
- export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11 };
12
+ import comp12 from './comp12';
13
+ export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12 };
@@ -1,5 +1,5 @@
1
1
  import templates from './index';
2
2
  import { Template } from '@formio/core/experimental';
3
3
  Template.addTemplates(templates);
4
- Template.defaultTemplates = templates.bootstrap;
4
+ Template.defaultTemplates = Template.templates.bootstrap;
5
5
  export default Template;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5725.1c71137",
3
+ "version": "5.0.0-dev.5727.73c63c0",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {