@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.
- package/Changelog.md +33 -0
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.form.js +53 -33
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +2 -0
- package/dist/formio.full.js +59 -39
- 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 +24 -4
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -0
- package/lib/cjs/CDN.js +1 -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 +0 -1
- package/lib/cjs/WebformBuilder.js +8 -2
- package/lib/cjs/Wizard.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +1 -1
- package/lib/cjs/components/_classes/component/Component.js +5 -4
- 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.js +2 -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/datagrid/DataGrid.d.ts +0 -1
- package/lib/cjs/components/datagrid/DataGrid.js +2 -9
- 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 +1 -1
- 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 +2 -5
- 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 +8 -7
- package/lib/cjs/components/editgrid/fixtures/index.js +3 -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/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.form.js +2 -2
- package/lib/cjs/components/time/Time.js +0 -5
- 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/mjs/CDN.js +1 -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 +0 -1
- package/lib/mjs/WebformBuilder.js +7 -2
- package/lib/mjs/Wizard.js +1 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +1 -1
- package/lib/mjs/components/_classes/component/Component.js +2 -1
- 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.js +2 -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/datagrid/DataGrid.d.ts +0 -1
- package/lib/mjs/components/datagrid/DataGrid.js +2 -9
- 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 +1 -1
- 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 +2 -5
- 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 +8 -7
- package/lib/mjs/components/editgrid/fixtures/index.js +2 -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/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.form.js +2 -2
- package/lib/mjs/components/time/Time.js +0 -11
- 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/package.json +4 -4
|
@@ -7,7 +7,6 @@ declare const _default: ({
|
|
|
7
7
|
placeholder: string;
|
|
8
8
|
weight: number;
|
|
9
9
|
conditional?: undefined;
|
|
10
|
-
customConditional?: undefined;
|
|
11
10
|
ignore?: undefined;
|
|
12
11
|
} | {
|
|
13
12
|
type: string;
|
|
@@ -24,7 +23,6 @@ declare const _default: ({
|
|
|
24
23
|
};
|
|
25
24
|
};
|
|
26
25
|
weight: number;
|
|
27
|
-
customConditional?: undefined;
|
|
28
26
|
ignore?: undefined;
|
|
29
27
|
} | {
|
|
30
28
|
weight: number;
|
|
@@ -32,9 +30,6 @@ declare const _default: ({
|
|
|
32
30
|
label: string;
|
|
33
31
|
tooltip: string;
|
|
34
32
|
key: string;
|
|
35
|
-
customConditional: ({ options }: {
|
|
36
|
-
options: any;
|
|
37
|
-
}) => boolean;
|
|
38
33
|
input: boolean;
|
|
39
34
|
placeholder?: undefined;
|
|
40
35
|
conditional?: undefined;
|
|
@@ -49,6 +44,5 @@ declare const _default: ({
|
|
|
49
44
|
placeholder?: undefined;
|
|
50
45
|
weight?: undefined;
|
|
51
46
|
conditional?: undefined;
|
|
52
|
-
customConditional?: undefined;
|
|
53
47
|
})[];
|
|
54
48
|
export default _default;
|
|
@@ -39,7 +39,6 @@ exports.default = [
|
|
|
39
39
|
label: 'Keep Overlay Aspect Ratio',
|
|
40
40
|
tooltip: 'If checked, the field will have the same aspect ratio as its preview.',
|
|
41
41
|
key: 'keepOverlayRatio',
|
|
42
|
-
customConditional: ({ options }) => { var _a; return (((_a = options === null || options === void 0 ? void 0 : options.editForm) === null || _a === void 0 ? void 0 : _a.display) === 'pdf'); },
|
|
43
42
|
input: true
|
|
44
43
|
},
|
|
45
44
|
{
|
|
@@ -118,12 +118,12 @@ class TagsComponent extends Input_1.default {
|
|
|
118
118
|
}
|
|
119
119
|
normalizeValue(value) {
|
|
120
120
|
if (this.component.storeas === 'string' && Array.isArray(value)) {
|
|
121
|
-
return value.join(this.delimiter);
|
|
121
|
+
return super.normalizeValue(value.join(this.delimiter));
|
|
122
122
|
}
|
|
123
123
|
else if (this.component.storeas === 'array' && typeof value === 'string') {
|
|
124
|
-
return value.split(this.delimiter).filter(result => result);
|
|
124
|
+
return super.normalizeValue(value.split(this.delimiter).filter(result => result));
|
|
125
125
|
}
|
|
126
|
-
return value;
|
|
126
|
+
return super.normalizeValue(value);
|
|
127
127
|
}
|
|
128
128
|
setValue(value, flags = {}) {
|
|
129
129
|
const changed = super.setValue(value, flags);
|
|
@@ -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
|
-
const
|
|
6
|
+
const Components_1 = __importDefault(require("../Components"));
|
|
7
7
|
const Time_edit_data_1 = __importDefault(require("./editForm/Time.edit.data"));
|
|
8
8
|
const Time_edit_display_1 = __importDefault(require("./editForm/Time.edit.display"));
|
|
9
9
|
/**
|
|
@@ -12,7 +12,7 @@ const Time_edit_display_1 = __importDefault(require("./editForm/Time.edit.displa
|
|
|
12
12
|
* @returns {import('@formio/core').Component[]} - The edit form components.
|
|
13
13
|
*/
|
|
14
14
|
function default_1(...extend) {
|
|
15
|
-
return
|
|
15
|
+
return Components_1.default.baseEditForm([
|
|
16
16
|
{
|
|
17
17
|
key: 'data',
|
|
18
18
|
components: Time_edit_data_1.default,
|
|
@@ -18,11 +18,6 @@ class TimeComponent extends TextField_1.default {
|
|
|
18
18
|
dataFormat: defaultDataFormat,
|
|
19
19
|
}, ...extend);
|
|
20
20
|
}
|
|
21
|
-
static get serverConditionSettings() {
|
|
22
|
-
return Object.assign(Object.assign({}, super.serverConditionSettings), { valueComponent(classComp) {
|
|
23
|
-
return Object.assign(Object.assign({}, classComp), { type: 'time' });
|
|
24
|
-
} });
|
|
25
|
-
}
|
|
26
21
|
constructor(component, options, data) {
|
|
27
22
|
super(component, options, data);
|
|
28
23
|
const { edge: isEdgeBrowser, version: edgeVersion } = (0, utils_1.getBrowserInfo)();
|
|
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const index_1 = __importDefault(require("./index"));
|
|
7
7
|
const experimental_1 = require("@formio/core/experimental");
|
|
8
8
|
experimental_1.Template.addTemplates(index_1.default);
|
|
9
|
-
experimental_1.Template.defaultTemplates =
|
|
9
|
+
experimental_1.Template.defaultTemplates = experimental_1.Template.templates.bootstrap;
|
|
10
10
|
exports.default = experimental_1.Template;
|
|
@@ -77,6 +77,7 @@ exports.default = {
|
|
|
77
77
|
typeRemaining: '{{ remaining }} {{ type }} remaining.',
|
|
78
78
|
typeCount: '{{ count }} {{ type }}',
|
|
79
79
|
requiredDayField: '{{ field }} is required',
|
|
80
|
+
requiredDayEmpty: '{{ field }} is required',
|
|
80
81
|
requiredMonthField: '{{ field }} is required',
|
|
81
82
|
requiredYearField: '{{ field }} is required'
|
|
82
83
|
};
|
package/lib/mjs/CDN.js
CHANGED
|
@@ -63,8 +63,7 @@ class CDN {
|
|
|
63
63
|
url += `/${lib}`;
|
|
64
64
|
}
|
|
65
65
|
// Only attach the version if this is the hosted cdn.
|
|
66
|
-
if (cdnUrl.
|
|
67
|
-
version && version !== 'latest') {
|
|
66
|
+
if (cdnUrl.match(/cdn\.(test-)?form.io/) && version && version !== 'latest') {
|
|
68
67
|
url += `/${version}`;
|
|
69
68
|
}
|
|
70
69
|
return url;
|
package/lib/mjs/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/mjs/Form.js
CHANGED
|
@@ -134,13 +134,13 @@ export default class Form extends Element {
|
|
|
134
134
|
else {
|
|
135
135
|
this.element = null;
|
|
136
136
|
}
|
|
137
|
+
this.options = formOptions;
|
|
138
|
+
this.options.events = this.events;
|
|
137
139
|
if (form) {
|
|
138
140
|
this.setForm(form)
|
|
139
141
|
.then(() => this.readyResolve(this.instance))
|
|
140
142
|
.catch(this.readyReject);
|
|
141
143
|
}
|
|
142
|
-
this.options = formOptions;
|
|
143
|
-
this.options.events = this.events;
|
|
144
144
|
this.display = '';
|
|
145
145
|
}
|
|
146
146
|
createElement(tag, attrs, children) {
|
|
@@ -264,7 +264,7 @@ export default class Form extends Element {
|
|
|
264
264
|
}
|
|
265
265
|
/**
|
|
266
266
|
* Sets the form to the JSON schema of a form.
|
|
267
|
-
* @param {import('@formio/core').Form} formParam - The form JSON to set this form to.
|
|
267
|
+
* @param {import('@formio/core').Form | string} formParam - The form JSON to set this form to.
|
|
268
268
|
* @returns {Promise<Webform|Wizard|PDF>} - The webform instance that was created.
|
|
269
269
|
*/
|
|
270
270
|
setForm(formParam) {
|
|
@@ -291,8 +291,14 @@ export default class Form extends Element {
|
|
|
291
291
|
}
|
|
292
292
|
this.loading = false;
|
|
293
293
|
this.instance = this.instance || this.create(form.display);
|
|
294
|
-
|
|
295
|
-
this.instance.setUrl
|
|
294
|
+
// If we're in builder mode, instance.setUrl is not a function, so just manually set the URL.
|
|
295
|
+
if (this.instance.setUrl) {
|
|
296
|
+
const options = this.getFormInitOptions(formParam, form);
|
|
297
|
+
this.instance.setUrl(formParam, options);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
this.instance.url = formParam;
|
|
301
|
+
}
|
|
296
302
|
this.instance.nosubmit = false;
|
|
297
303
|
this._form = this.instance.form = form;
|
|
298
304
|
if (submission) {
|
package/lib/mjs/PDF.js
CHANGED
|
@@ -65,7 +65,7 @@ export default class PDF extends Webform {
|
|
|
65
65
|
super.destroy(all);
|
|
66
66
|
}
|
|
67
67
|
rebuild() {
|
|
68
|
-
if (this.
|
|
68
|
+
if (this.builderMode && this.component.components) {
|
|
69
69
|
this.destroyComponents();
|
|
70
70
|
this.addComponents();
|
|
71
71
|
return Promise.resolve();
|
package/lib/mjs/PDFBuilder.js
CHANGED
|
@@ -429,7 +429,7 @@ export default class PDFBuilder extends WebformBuilder {
|
|
|
429
429
|
_.merge(schema, info);
|
|
430
430
|
}
|
|
431
431
|
// Set a unique key for this component.
|
|
432
|
-
BuilderUtils.uniquify(
|
|
432
|
+
BuilderUtils.uniquify(this.webform._form?.components || [], schema);
|
|
433
433
|
this.webform._form.components.push(schema);
|
|
434
434
|
schema.overlay = {
|
|
435
435
|
top: layerY ? (layerY - this.itemOffsetY + HEIGHT) : (e.clientY - iframeRect.top - (this.itemOffsetY - HEIGHT) * 2),
|
package/lib/mjs/Webform.js
CHANGED
|
@@ -187,7 +187,8 @@ export default class WebformBuilder extends Component {
|
|
|
187
187
|
params: {
|
|
188
188
|
type: 'resource',
|
|
189
189
|
limit: 1000000,
|
|
190
|
-
select: '_id,title,name,components'
|
|
190
|
+
select: '_id,title,name,components',
|
|
191
|
+
'tags__ne': 'noBuilderResource'
|
|
191
192
|
}
|
|
192
193
|
};
|
|
193
194
|
if (this.options && this.options.resourceTag) {
|
|
@@ -1048,7 +1049,10 @@ export default class WebformBuilder extends Component {
|
|
|
1048
1049
|
'calculateValue',
|
|
1049
1050
|
'conditional',
|
|
1050
1051
|
'customConditional',
|
|
1051
|
-
'id'
|
|
1052
|
+
'id',
|
|
1053
|
+
'fields.day.required',
|
|
1054
|
+
'fields.month.required',
|
|
1055
|
+
'fields.year.required',
|
|
1052
1056
|
]));
|
|
1053
1057
|
const parentComponent = defaultValueComponent.parent;
|
|
1054
1058
|
let tabIndex = -1;
|
|
@@ -1235,6 +1239,7 @@ export default class WebformBuilder extends Component {
|
|
|
1235
1239
|
helplinks: this.helplinks,
|
|
1236
1240
|
}));
|
|
1237
1241
|
this.editForm.attach(this.componentEdit.querySelector(`[${this._referenceAttributeName}="editForm"]`));
|
|
1242
|
+
this.updateComponent(this.editForm.submission.data ?? component);
|
|
1238
1243
|
this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
|
|
1239
1244
|
});
|
|
1240
1245
|
});
|
package/lib/mjs/Wizard.js
CHANGED
|
@@ -13,7 +13,7 @@ export default class Wizard extends Webform {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(elementOrOptions = undefined, _options = undefined) {
|
|
15
15
|
let element, options;
|
|
16
|
-
if (elementOrOptions instanceof HTMLElement ||
|
|
16
|
+
if (elementOrOptions instanceof HTMLElement || _options) {
|
|
17
17
|
element = elementOrOptions;
|
|
18
18
|
options = _options || {};
|
|
19
19
|
}
|
|
@@ -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
|
|
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.
|
|
@@ -3425,10 +3425,11 @@ export default class Component extends Element {
|
|
|
3425
3425
|
const { left, top } = element.getBoundingClientRect();
|
|
3426
3426
|
window.scrollTo(left + window.scrollX, top + window.scrollY);
|
|
3427
3427
|
}
|
|
3428
|
-
focus(index
|
|
3428
|
+
focus(index) {
|
|
3429
3429
|
if ('beforeFocus' in this.parent) {
|
|
3430
3430
|
this.parent.beforeFocus(this);
|
|
3431
3431
|
}
|
|
3432
|
+
index = index || this.refs.input?.length - 1;
|
|
3432
3433
|
if (this.refs.input?.length) {
|
|
3433
3434
|
const focusingInput = this.refs.input[index];
|
|
3434
3435
|
if (this.component.widget?.type === 'calendar') {
|
|
@@ -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 '';
|
|
@@ -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]) {
|
|
@@ -680,7 +681,7 @@ export default class NestedComponent extends Field {
|
|
|
680
681
|
validationProcessor({ scope, data, row, instance, component }, flags) {
|
|
681
682
|
const { dirty } = flags;
|
|
682
683
|
if (this.root.hasExtraPages && this.page !== this.root.page) {
|
|
683
|
-
instance = this.
|
|
684
|
+
instance = this.getComponent(component.path);
|
|
684
685
|
}
|
|
685
686
|
if (!instance) {
|
|
686
687
|
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';
|
|
@@ -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 {
|
|
@@ -260,13 +260,6 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
260
260
|
return hasHeader || ((col.label || col.title) && !col.hideLabel);
|
|
261
261
|
}, false);
|
|
262
262
|
}
|
|
263
|
-
loadRefs(element, refs) {
|
|
264
|
-
super.loadRefs(element, refs);
|
|
265
|
-
if (refs['messageContainer'] === 'single') {
|
|
266
|
-
const container = _.last(element.querySelectorAll(`[${this._referenceAttributeName}=messageContainer]`));
|
|
267
|
-
this.refs['messageContainer'] = container || this.refs['messageContainer'];
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
263
|
attach(element) {
|
|
271
264
|
this.loadRefs(element, {
|
|
272
265
|
[`${this.datagridKey}-row`]: 'multiple',
|
|
@@ -275,7 +268,6 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
275
268
|
[`${this.datagridKey}-removeRow`]: 'multiple',
|
|
276
269
|
[`${this.datagridKey}-group-header`]: 'multiple',
|
|
277
270
|
[this.datagridKey]: 'multiple',
|
|
278
|
-
'messageContainer': 'single'
|
|
279
271
|
});
|
|
280
272
|
if (this.allowReorder) {
|
|
281
273
|
this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
|
|
@@ -440,10 +432,11 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
440
432
|
}
|
|
441
433
|
removeRow(index) {
|
|
442
434
|
const makeEmpty = index === 0 && this.rows.length === 1;
|
|
443
|
-
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
|
|
435
|
+
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty, modified: true };
|
|
444
436
|
this.splice(index, flags);
|
|
445
437
|
this.emit('dataGridDeleteRow', { index });
|
|
446
438
|
const [row] = this.rows.splice(index, 1);
|
|
439
|
+
this.removeSubmissionMetadataRow(index);
|
|
447
440
|
this.removeRowComponents(row);
|
|
448
441
|
this.updateRowsComponents(index);
|
|
449
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;
|