@formio/js 5.0.0-dev.5704.492ccdf → 5.0.0-dev.5704.50db01f
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.
- package/Changelog.md +47 -0
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.form.js +55 -131
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +2 -0
- package/dist/formio.full.js +61 -41
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +2 -0
- package/dist/formio.js +1 -1
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +25 -5
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -0
- package/lib/cjs/CDN.d.ts +1 -0
- package/lib/cjs/CDN.js +2 -2
- package/lib/cjs/Form.d.ts +2 -2
- package/lib/cjs/Form.js +11 -5
- package/lib/cjs/PDF.js +1 -1
- package/lib/cjs/PDFBuilder.js +2 -1
- package/lib/cjs/Webform.js +3 -6
- package/lib/cjs/WebformBuilder.js +13 -3
- package/lib/cjs/Wizard.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +2 -1
- package/lib/cjs/components/_classes/component/Component.js +25 -6
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +43 -25
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +2 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +5 -1
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +3 -0
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +56 -29
- package/lib/cjs/components/address/Address.d.ts +6 -0
- package/lib/cjs/components/address/Address.js +7 -1
- package/lib/cjs/components/currency/Currency.d.ts +2 -0
- package/lib/cjs/components/datagrid/DataGrid.d.ts +2 -1
- package/lib/cjs/components/datagrid/DataGrid.js +40 -35
- package/lib/cjs/components/datagrid/fixtures/comp11.d.ts +50 -0
- package/lib/cjs/components/datagrid/fixtures/comp11.js +55 -0
- package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/datagrid/fixtures/index.js +3 -1
- package/lib/cjs/components/datamap/DataMap.js +2 -2
- package/lib/cjs/components/day/Day.d.ts +3 -4
- package/lib/cjs/components/day/Day.js +31 -10
- package/lib/cjs/components/editgrid/EditGrid.js +14 -6
- package/lib/cjs/components/editgrid/fixtures/comp-test-events.d.ts +54 -0
- package/lib/cjs/components/editgrid/fixtures/comp-test-events.js +54 -0
- package/lib/cjs/components/editgrid/fixtures/comp16.d.ts +52 -0
- package/lib/cjs/components/editgrid/fixtures/comp16.js +71 -0
- package/lib/cjs/components/editgrid/fixtures/comp17.d.ts +80 -0
- package/lib/cjs/components/editgrid/fixtures/comp17.js +99 -0
- package/lib/cjs/components/editgrid/fixtures/index.d.ts +10 -7
- package/lib/cjs/components/editgrid/fixtures/index.js +7 -1
- package/lib/cjs/components/file/File.d.ts +2 -2
- package/lib/cjs/components/file/File.js +13 -2
- package/lib/cjs/components/file/editForm/File.edit.display.js +1 -1
- package/lib/cjs/components/form/editForm/Form.edit.form.js +1 -1
- package/lib/cjs/components/form/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/form/fixtures/index.js +3 -1
- package/lib/cjs/components/form/fixtures/nestedWizardForm.d.ts +771 -0
- package/lib/cjs/components/form/fixtures/nestedWizardForm.js +765 -0
- package/lib/cjs/components/number/Number.d.ts +17 -2
- package/lib/cjs/components/number/Number.js +26 -6
- package/lib/cjs/components/number/fixtures/comp10.d.ts +18 -0
- package/lib/cjs/components/number/fixtures/comp10.js +21 -0
- package/lib/cjs/components/number/fixtures/comp9.d.ts +18 -0
- package/lib/cjs/components/number/fixtures/comp9.js +21 -0
- package/lib/cjs/components/number/fixtures/index.d.ts +3 -1
- package/lib/cjs/components/number/fixtures/index.js +5 -1
- package/lib/cjs/components/panel/Panel.d.ts +1 -0
- package/lib/cjs/components/panel/Panel.js +1 -0
- package/lib/cjs/components/radio/Radio.d.ts +2 -18
- package/lib/cjs/components/radio/Radio.js +29 -27
- package/lib/cjs/components/radio/fixtures/comp12.d.ts +29 -0
- package/lib/cjs/components/radio/fixtures/comp12.js +36 -0
- package/lib/cjs/components/radio/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/radio/fixtures/index.js +3 -1
- package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +6 -0
- package/lib/cjs/components/recaptcha/ReCaptcha.js +6 -0
- package/lib/cjs/components/select/Select.d.ts +38 -0
- package/lib/cjs/components/select/Select.js +13 -3
- package/lib/cjs/components/select/fixtures/comp25.d.ts +59 -0
- package/lib/cjs/components/select/fixtures/comp25.js +66 -0
- package/lib/cjs/components/select/fixtures/comp26.d.ts +44 -0
- package/lib/cjs/components/select/fixtures/comp26.js +59 -0
- package/lib/cjs/components/select/fixtures/index.d.ts +3 -1
- package/lib/cjs/components/select/fixtures/index.js +5 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +0 -22
- package/lib/cjs/components/selectboxes/SelectBoxes.js +12 -9
- package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
- package/lib/cjs/components/signature/editForm/Signature.edit.display.js +0 -1
- package/lib/cjs/components/tags/Tags.js +3 -3
- package/lib/cjs/components/time/Time.d.ts +2 -2
- package/lib/cjs/components/time/Time.form.js +2 -2
- package/lib/cjs/components/time/Time.js +3 -7
- package/lib/cjs/components/time/fixtures/comp4.d.ts +166 -0
- package/lib/cjs/components/time/fixtures/comp4.js +171 -0
- package/lib/cjs/components/time/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/time/fixtures/index.js +3 -1
- package/lib/cjs/templates/Templates.js +1 -1
- package/lib/cjs/translations/en.d.ts +1 -0
- package/lib/cjs/translations/en.js +1 -0
- package/lib/cjs/utils/utils.d.ts +9 -1
- package/lib/cjs/utils/utils.js +14 -13
- package/lib/mjs/CDN.d.ts +1 -0
- package/lib/mjs/CDN.js +2 -2
- package/lib/mjs/Form.d.ts +2 -2
- package/lib/mjs/Form.js +11 -5
- package/lib/mjs/PDF.js +1 -1
- package/lib/mjs/PDFBuilder.js +1 -1
- package/lib/mjs/Webform.js +7 -6
- package/lib/mjs/WebformBuilder.js +12 -3
- package/lib/mjs/Wizard.js +1 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +2 -1
- package/lib/mjs/components/_classes/component/Component.js +11 -3
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +43 -25
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +2 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +5 -1
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +3 -0
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +57 -29
- package/lib/mjs/components/address/Address.d.ts +6 -0
- package/lib/mjs/components/address/Address.js +10 -1
- package/lib/mjs/components/currency/Currency.d.ts +2 -0
- package/lib/mjs/components/datagrid/DataGrid.d.ts +2 -1
- package/lib/mjs/components/datagrid/DataGrid.js +39 -34
- package/lib/mjs/components/datagrid/fixtures/comp11.d.ts +50 -0
- package/lib/mjs/components/datagrid/fixtures/comp11.js +53 -0
- package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/datagrid/fixtures/index.js +2 -1
- package/lib/mjs/components/datamap/DataMap.js +2 -2
- package/lib/mjs/components/day/Day.d.ts +3 -4
- package/lib/mjs/components/day/Day.js +30 -10
- package/lib/mjs/components/editgrid/EditGrid.js +14 -6
- package/lib/mjs/components/editgrid/fixtures/comp-test-events.d.ts +54 -0
- package/lib/mjs/components/editgrid/fixtures/comp-test-events.js +52 -0
- package/lib/mjs/components/editgrid/fixtures/comp16.d.ts +52 -0
- package/lib/mjs/components/editgrid/fixtures/comp16.js +69 -0
- package/lib/mjs/components/editgrid/fixtures/comp17.d.ts +80 -0
- package/lib/mjs/components/editgrid/fixtures/comp17.js +97 -0
- package/lib/mjs/components/editgrid/fixtures/index.d.ts +10 -7
- package/lib/mjs/components/editgrid/fixtures/index.js +4 -1
- package/lib/mjs/components/file/File.d.ts +2 -2
- package/lib/mjs/components/file/File.js +13 -2
- package/lib/mjs/components/file/editForm/File.edit.display.js +1 -1
- package/lib/mjs/components/form/editForm/Form.edit.form.js +1 -1
- package/lib/mjs/components/form/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/form/fixtures/index.js +2 -1
- package/lib/mjs/components/form/fixtures/nestedWizardForm.d.ts +771 -0
- package/lib/mjs/components/form/fixtures/nestedWizardForm.js +763 -0
- package/lib/mjs/components/number/Number.d.ts +17 -2
- package/lib/mjs/components/number/Number.js +25 -5
- package/lib/mjs/components/number/fixtures/comp10.d.ts +18 -0
- package/lib/mjs/components/number/fixtures/comp10.js +19 -0
- package/lib/mjs/components/number/fixtures/comp9.d.ts +18 -0
- package/lib/mjs/components/number/fixtures/comp9.js +19 -0
- package/lib/mjs/components/number/fixtures/index.d.ts +3 -1
- package/lib/mjs/components/number/fixtures/index.js +3 -1
- package/lib/mjs/components/panel/Panel.d.ts +1 -0
- package/lib/mjs/components/panel/Panel.js +1 -0
- package/lib/mjs/components/radio/Radio.d.ts +2 -18
- package/lib/mjs/components/radio/Radio.js +32 -30
- package/lib/mjs/components/radio/fixtures/comp12.d.ts +29 -0
- package/lib/mjs/components/radio/fixtures/comp12.js +34 -0
- package/lib/mjs/components/radio/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/radio/fixtures/index.js +2 -1
- package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +6 -0
- package/lib/mjs/components/recaptcha/ReCaptcha.js +9 -0
- package/lib/mjs/components/select/Select.d.ts +38 -0
- package/lib/mjs/components/select/Select.js +16 -4
- package/lib/mjs/components/select/fixtures/comp25.d.ts +59 -0
- package/lib/mjs/components/select/fixtures/comp25.js +64 -0
- package/lib/mjs/components/select/fixtures/comp26.d.ts +44 -0
- package/lib/mjs/components/select/fixtures/comp26.js +57 -0
- package/lib/mjs/components/select/fixtures/index.d.ts +3 -1
- package/lib/mjs/components/select/fixtures/index.js +3 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +0 -22
- package/lib/mjs/components/selectboxes/SelectBoxes.js +16 -9
- package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
- package/lib/mjs/components/signature/editForm/Signature.edit.display.js +0 -1
- package/lib/mjs/components/tags/Tags.js +3 -3
- package/lib/mjs/components/time/Time.d.ts +2 -2
- package/lib/mjs/components/time/Time.form.js +2 -2
- package/lib/mjs/components/time/Time.js +3 -13
- package/lib/mjs/components/time/fixtures/comp4.d.ts +166 -0
- package/lib/mjs/components/time/fixtures/comp4.js +169 -0
- package/lib/mjs/components/time/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/time/fixtures/index.js +2 -1
- package/lib/mjs/templates/Templates.js +1 -1
- package/lib/mjs/translations/en.d.ts +1 -0
- package/lib/mjs/translations/en.js +1 -0
- package/lib/mjs/utils/utils.d.ts +9 -1
- package/lib/mjs/utils/utils.js +14 -2
- package/package.json +4 -4
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
import Field from '../field/Field';
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
export default class Multivalue extends Field {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Normalize values coming into updateValue.
|
|
6
|
+
* @param {*} value - The value to normalize before setting.
|
|
7
|
+
* @returns {*} - The normalized value.
|
|
8
|
+
*/
|
|
9
|
+
normalizeValue(value) {
|
|
10
|
+
if (this.component.multiple) {
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
if (value.length === 0) {
|
|
13
|
+
return [this.emptyValue];
|
|
14
|
+
}
|
|
15
|
+
if (this.component.storeas === 'array') {
|
|
16
|
+
return super.normalizeValue([value]);
|
|
17
|
+
}
|
|
18
|
+
return super.normalizeValue(value);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return super.normalizeValue(value == null ? [this.emptyValue] : [value]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (Array.isArray(value) && this.component.storeas !== 'array') {
|
|
26
|
+
if (this.component.storeas === 'string') {
|
|
27
|
+
return super.normalizeValue(value.join(this.delimiter || ''));
|
|
28
|
+
}
|
|
29
|
+
return super.normalizeValue(value[0] || this.emptyValue);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return super.normalizeValue(value);
|
|
33
|
+
}
|
|
8
34
|
}
|
|
9
|
-
|
|
35
|
+
}
|
|
36
|
+
get dataValue() {
|
|
37
|
+
return super.dataValue;
|
|
10
38
|
}
|
|
11
39
|
set dataValue(value) {
|
|
12
40
|
super.dataValue = value;
|
|
@@ -26,30 +54,20 @@ export default class Multivalue extends Field {
|
|
|
26
54
|
get addAnother() {
|
|
27
55
|
return this.t(this.component.addAnother || 'Add Another');
|
|
28
56
|
}
|
|
29
|
-
useWrapper() {
|
|
30
|
-
return this.component.hasOwnProperty('multiple') && this.component.multiple;
|
|
31
|
-
}
|
|
32
57
|
/**
|
|
33
58
|
* @returns {Field} - The created field.
|
|
34
59
|
*/
|
|
35
60
|
render() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
// If multiple value field.
|
|
48
|
-
return super.render(this.renderTemplate('multiValueTable', {
|
|
49
|
-
rows: dataValue.map(this.renderRow.bind(this)).join(''),
|
|
50
|
-
disabled: this.disabled,
|
|
51
|
-
addAnother: this.addAnother,
|
|
52
|
-
}));
|
|
61
|
+
let dataValue = this.normalizeValue(this.dataValue);
|
|
62
|
+
return this.component.hasOwnProperty('multiple') && this.component.multiple
|
|
63
|
+
? super.render(this.renderTemplate('multiValueTable', {
|
|
64
|
+
rows: dataValue.map(this.renderRow.bind(this)).join(''),
|
|
65
|
+
disabled: this.disabled,
|
|
66
|
+
addAnother: this.addAnother,
|
|
67
|
+
}))
|
|
68
|
+
: super.render(`<div ${this._referenceAttributeName}="element">
|
|
69
|
+
${this.renderElement(this.component.type !== 'hidden' ? dataValue : '')}
|
|
70
|
+
</div>`);
|
|
53
71
|
}
|
|
54
72
|
renderElement() {
|
|
55
73
|
return '';
|
|
@@ -211,11 +211,12 @@ export default class NestedComponent extends Field {
|
|
|
211
211
|
calculateValue(data: any, flags: any, row: any): any;
|
|
212
212
|
isLastPage(): boolean;
|
|
213
213
|
isValid(data: any, dirty: any): any;
|
|
214
|
-
validationProcessor({ scope, data, row, instance }: {
|
|
214
|
+
validationProcessor({ scope, data, row, instance, component }: {
|
|
215
215
|
scope: any;
|
|
216
216
|
data: any;
|
|
217
217
|
row: any;
|
|
218
218
|
instance: any;
|
|
219
|
+
component: any;
|
|
219
220
|
}, flags: any): void;
|
|
220
221
|
/**
|
|
221
222
|
* Perform a validation on all child components of this nested component.
|
|
@@ -493,6 +493,7 @@ export default class NestedComponent extends Field {
|
|
|
493
493
|
header: 'single',
|
|
494
494
|
collapsed: this.collapsed,
|
|
495
495
|
[this.nestedKey]: 'single',
|
|
496
|
+
messageContainer: 'single-scope',
|
|
496
497
|
});
|
|
497
498
|
let childPromise = Promise.resolve();
|
|
498
499
|
if (this.refs[this.nestedKey]) {
|
|
@@ -677,8 +678,11 @@ export default class NestedComponent extends Field {
|
|
|
677
678
|
isValid(data, dirty) {
|
|
678
679
|
return this.getComponents().reduce((valid, comp) => comp.isValid(data, dirty) && valid, super.isValid(data, dirty));
|
|
679
680
|
}
|
|
680
|
-
validationProcessor({ scope, data, row, instance }, flags) {
|
|
681
|
+
validationProcessor({ scope, data, row, instance, component }, flags) {
|
|
681
682
|
const { dirty } = flags;
|
|
683
|
+
if (this.root.hasExtraPages && this.page !== this.root.page) {
|
|
684
|
+
instance = this.getComponent(component.path);
|
|
685
|
+
}
|
|
682
686
|
if (!instance) {
|
|
683
687
|
return;
|
|
684
688
|
}
|
|
@@ -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';
|
|
@@ -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
|
-
|
|
196
|
+
return `
|
|
151
197
|
<table border="1" style="width:100%">
|
|
152
|
-
|
|
153
|
-
|
|
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 '';
|
|
@@ -192,4 +214,10 @@ export default class NestedArrayComponent extends NestedDataComponent {
|
|
|
192
214
|
}
|
|
193
215
|
return super.getComponents();
|
|
194
216
|
}
|
|
217
|
+
removeSubmissionMetadataRow(index) {
|
|
218
|
+
const componentMetadata = _.get(this.root, `submission.metadata.selectData.${this.path}`, null);
|
|
219
|
+
if (_.isArray(componentMetadata)) {
|
|
220
|
+
componentMetadata.splice(index, 1);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
195
223
|
}
|
|
@@ -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;
|
|
@@ -91,6 +91,15 @@ export default class AddressComponent extends ContainerComponent {
|
|
|
91
91
|
schema: AddressComponent.schema(),
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
+
static get serverConditionSettings() {
|
|
95
|
+
return AddressComponent.conditionOperatorsSettings;
|
|
96
|
+
}
|
|
97
|
+
static get conditionOperatorsSettings() {
|
|
98
|
+
return {
|
|
99
|
+
...super.conditionOperatorsSettings,
|
|
100
|
+
operators: ['isEmpty', 'isNotEmpty'],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
94
103
|
mergeSchema(component = {}) {
|
|
95
104
|
let { defaultSchema } = this;
|
|
96
105
|
if (component.components) {
|
|
@@ -181,7 +190,7 @@ export default class AddressComponent extends ContainerComponent {
|
|
|
181
190
|
return (this.manualModeEnabled && this.dataValue) ? this.dataValue.address : this.dataValue;
|
|
182
191
|
}
|
|
183
192
|
set address(value) {
|
|
184
|
-
if (this.manualModeEnabled && !this.isMultiple) {
|
|
193
|
+
if (this.manualModeEnabled && !this.isMultiple && !_.isEqual(value, this.emptyValue)) {
|
|
185
194
|
this.dataValue.address = value;
|
|
186
195
|
}
|
|
187
196
|
else {
|
|
@@ -2,6 +2,8 @@ export default class CurrencyComponent extends NumberComponent {
|
|
|
2
2
|
constructor(component: any, options: any, data: any);
|
|
3
3
|
currencyPrefix: any;
|
|
4
4
|
currencySuffix: any;
|
|
5
|
+
parseNumber(value: any): number;
|
|
6
|
+
parseValue(value: any): string | null;
|
|
5
7
|
addZerosAndFormatValue(value: any): any;
|
|
6
8
|
stripPrefixSuffix(value: any): any;
|
|
7
9
|
}
|
|
@@ -12,6 +12,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
12
12
|
tabIndex: number;
|
|
13
13
|
rows: any[] | undefined;
|
|
14
14
|
columns: any[] | undefined;
|
|
15
|
+
dragulaReady: Promise<any> | undefined;
|
|
15
16
|
visibleColumns: {} | undefined;
|
|
16
17
|
set dataValue(value: any[]);
|
|
17
18
|
get dataValue(): any[];
|
|
@@ -58,7 +59,6 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
58
59
|
getRows(): {}[];
|
|
59
60
|
getColumns(): any[];
|
|
60
61
|
hasHeader(): any;
|
|
61
|
-
loadRefs(element: any, refs: any): void;
|
|
62
62
|
dragula: any;
|
|
63
63
|
getComponentsContainer(): any;
|
|
64
64
|
/**
|
|
@@ -71,6 +71,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
71
71
|
*/
|
|
72
72
|
reorderValues(valuesArr: any, oldPosition: number, newPosition: number, movedBelow: boolean | any): void;
|
|
73
73
|
onReorder(element: any, _target: any, _source: any, sibling: any): void;
|
|
74
|
+
onCloned(el: any, original: any): void;
|
|
74
75
|
focusOnNewRowElement(row: any): void;
|
|
75
76
|
addRow(): void;
|
|
76
77
|
updateComponentsRowIndex(components: any, rowIndex: any): void;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
|
|
3
3
|
import { fastCloneDeep, getFocusableElements } from '../../utils/utils';
|
|
4
|
-
import
|
|
5
|
-
import dragula from 'dragula';
|
|
4
|
+
import Components from '../Components';
|
|
6
5
|
export default class DataGridComponent extends NestedArrayComponent {
|
|
7
6
|
static schema(...extend) {
|
|
8
7
|
return NestedArrayComponent.schema({
|
|
@@ -39,6 +38,9 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
39
38
|
if (this.initRows || !_.isEqual(this.dataValue, this.emptyValue)) {
|
|
40
39
|
this.createRows(true);
|
|
41
40
|
}
|
|
41
|
+
if (this.allowReorder) {
|
|
42
|
+
this.dragulaReady = this.getDragula();
|
|
43
|
+
}
|
|
42
44
|
this.visibleColumns = {};
|
|
43
45
|
this.prevHasAddButton = this.hasAddButton();
|
|
44
46
|
this.checkColumns();
|
|
@@ -258,13 +260,6 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
258
260
|
return hasHeader || ((col.label || col.title) && !col.hideLabel);
|
|
259
261
|
}, false);
|
|
260
262
|
}
|
|
261
|
-
loadRefs(element, refs) {
|
|
262
|
-
super.loadRefs(element, refs);
|
|
263
|
-
if (refs['messageContainer'] === 'single') {
|
|
264
|
-
const container = _.last(element.querySelectorAll(`[${this._referenceAttributeName}=messageContainer]`));
|
|
265
|
-
this.refs['messageContainer'] = container || this.refs['messageContainer'];
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
263
|
attach(element) {
|
|
269
264
|
this.loadRefs(element, {
|
|
270
265
|
[`${this.datagridKey}-row`]: 'multiple',
|
|
@@ -273,37 +268,30 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
273
268
|
[`${this.datagridKey}-removeRow`]: 'multiple',
|
|
274
269
|
[`${this.datagridKey}-group-header`]: 'multiple',
|
|
275
270
|
[this.datagridKey]: 'multiple',
|
|
276
|
-
'messageContainer': 'single'
|
|
277
271
|
});
|
|
278
272
|
if (this.allowReorder) {
|
|
279
273
|
this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
|
|
280
274
|
row.dragInfo = { index };
|
|
281
275
|
});
|
|
282
|
-
this.dragula
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
276
|
+
this.dragulaReady.then((dragula) => {
|
|
277
|
+
// The drop event may call redraw twice which calls attach twice and because this block of code is asynchronous
|
|
278
|
+
// BOTH redraws may be called before this block of code runs (which causes this block of code to run twice sequentially).
|
|
279
|
+
// This causes two dragula() calls on the same container which breaks dragula. To fix this the return value must
|
|
280
|
+
// be saved in this.dragula and have its container contents reset if it exists
|
|
281
|
+
if (this.dragula && this.dragula.containers) {
|
|
282
|
+
this.dragula.containers = [];
|
|
290
283
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
const cssText = Object.values(styles).reduce((css, propertyName) => {
|
|
301
|
-
return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
|
|
302
|
-
}, '');
|
|
303
|
-
el.children[index].style.cssText = cssText;
|
|
284
|
+
this.dragula = dragula([this.refs[`${this.datagridKey}-tbody`]], {
|
|
285
|
+
moves: (_draggedElement, _oldParent, clickedElement) => {
|
|
286
|
+
const clickedElementKey = clickedElement.getAttribute('data-key');
|
|
287
|
+
const oldParentKey = _oldParent.getAttribute('data-key');
|
|
288
|
+
//Check if the clicked button belongs to that container, if false, it belongs to the nested container
|
|
289
|
+
if (oldParentKey === clickedElementKey) {
|
|
290
|
+
return clickedElement.classList.contains('formio-drag-button');
|
|
304
291
|
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
292
|
+
}
|
|
293
|
+
}).on('drop', this.onReorder.bind(this))
|
|
294
|
+
.on('cloned', this.onCloned.bind(this));
|
|
307
295
|
});
|
|
308
296
|
}
|
|
309
297
|
this.refs[`${this.datagridKey}-addRow`].forEach((addButton) => {
|
|
@@ -370,6 +358,22 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
370
358
|
this.setValue(dataValue, { isReordered: true });
|
|
371
359
|
this.rebuild();
|
|
372
360
|
}
|
|
361
|
+
onCloned(el, original) {
|
|
362
|
+
if (el && el.children && original && original.children) {
|
|
363
|
+
_.each(original.children, (child, index) => {
|
|
364
|
+
const styles = getComputedStyle(child, null);
|
|
365
|
+
if (styles.cssText !== '') {
|
|
366
|
+
el.children[index].style.cssText = styles.cssText;
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
const cssText = Object.values(styles).reduce((css, propertyName) => {
|
|
370
|
+
return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
|
|
371
|
+
}, '');
|
|
372
|
+
el.children[index].style.cssText = cssText;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}
|
|
373
377
|
focusOnNewRowElement(row) {
|
|
374
378
|
Object.keys(row).find((key) => {
|
|
375
379
|
const element = row[key].element;
|
|
@@ -428,10 +432,11 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
428
432
|
}
|
|
429
433
|
removeRow(index) {
|
|
430
434
|
const makeEmpty = index === 0 && this.rows.length === 1;
|
|
431
|
-
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
|
|
435
|
+
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty, modified: true };
|
|
432
436
|
this.splice(index, flags);
|
|
433
437
|
this.emit('dataGridDeleteRow', { index });
|
|
434
438
|
const [row] = this.rows.splice(index, 1);
|
|
439
|
+
this.removeSubmissionMetadataRow(index);
|
|
435
440
|
this.removeRowComponents(row);
|
|
436
441
|
this.updateRowsComponents(index);
|
|
437
442
|
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,53 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
title: 'Select in Data Grid',
|
|
3
|
+
name: 'selectInDataGrid',
|
|
4
|
+
path: 'selectInDataGrid',
|
|
5
|
+
type: 'form',
|
|
6
|
+
display: 'form',
|
|
7
|
+
components: [
|
|
8
|
+
{
|
|
9
|
+
label: 'Data Grid',
|
|
10
|
+
reorder: false,
|
|
11
|
+
addAnotherPosition: 'bottom',
|
|
12
|
+
layoutFixed: false,
|
|
13
|
+
enableRowGroups: false,
|
|
14
|
+
initEmpty: false,
|
|
15
|
+
tableView: false,
|
|
16
|
+
key: 'dataGrid',
|
|
17
|
+
type: 'datagrid',
|
|
18
|
+
input: true,
|
|
19
|
+
components: [
|
|
20
|
+
{
|
|
21
|
+
label: 'Select',
|
|
22
|
+
widget: 'choicesjs',
|
|
23
|
+
tableView: true,
|
|
24
|
+
data: {
|
|
25
|
+
values: [
|
|
26
|
+
{
|
|
27
|
+
label: 'Individual',
|
|
28
|
+
value: 'individual'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: 'Entity',
|
|
32
|
+
value: 'entity'
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
validateWhenHidden: false,
|
|
37
|
+
key: 'select',
|
|
38
|
+
type: 'select',
|
|
39
|
+
input: true,
|
|
40
|
+
defaultValue: 'entity'
|
|
41
|
+
},
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'button',
|
|
46
|
+
label: 'Submit',
|
|
47
|
+
key: 'submit',
|
|
48
|
+
disableOnInvalid: true,
|
|
49
|
+
input: true,
|
|
50
|
+
tableView: false
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
};
|
|
@@ -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 };
|
|
@@ -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 withDefValue from './comp-with-def-value';
|
|
12
13
|
import withRowGroupsAndDefValue from './comp-row-groups-with-def-value';
|
|
13
14
|
import modalWithRequiredFields from './comp-modal-with-required-fields';
|
|
@@ -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 @@ import DataGridComponent from '../datagrid/DataGrid';
|
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import EventEmitter from 'eventemitter3';
|
|
5
5
|
import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/utils';
|
|
6
|
-
import
|
|
6
|
+
import Components from '../Components';
|
|
7
7
|
export default class DataMapComponent extends DataGridComponent {
|
|
8
8
|
static schema(...extend) {
|
|
9
9
|
return Component.schema({
|
|
@@ -236,7 +236,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
|
236
236
|
delete dataValue[key];
|
|
237
237
|
const comp = components[this.valueKey];
|
|
238
238
|
comp.component.key = newKey;
|
|
239
|
-
comp.path = Components.
|
|
239
|
+
comp.path = Components.getComponentPath(comp);
|
|
240
240
|
key = newKey;
|
|
241
241
|
});
|
|
242
242
|
const valueComponent = _.clone(this.component.valueComponent);
|
|
@@ -17,9 +17,9 @@ export default class DayComponent extends Field {
|
|
|
17
17
|
constructor(component: any, options: any, data: any);
|
|
18
18
|
/**
|
|
19
19
|
* The empty value for day component.
|
|
20
|
-
* @returns {'
|
|
20
|
+
* @returns {''} - The empty value of the day component.
|
|
21
21
|
*/
|
|
22
|
-
get emptyValue(): "
|
|
22
|
+
get emptyValue(): "";
|
|
23
23
|
get valueMask(): RegExp;
|
|
24
24
|
get dayRequired(): any;
|
|
25
25
|
get showDay(): boolean;
|
|
@@ -130,8 +130,7 @@ export default class DayComponent extends Field {
|
|
|
130
130
|
* @returns {string|null} - The string value of the date.
|
|
131
131
|
*/
|
|
132
132
|
getValueAsString(value: any): string | null;
|
|
133
|
-
focus(field: any): void;
|
|
134
133
|
isPartialDay(value: any): boolean;
|
|
135
|
-
getValidationFormat():
|
|
134
|
+
getValidationFormat(): string;
|
|
136
135
|
}
|
|
137
136
|
import Field from '../_classes/field/Field';
|