@formio/js 5.1.0-dev.6059.845a6e3 → 5.1.0-dev.6060.19e3bfc
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 +131 -13
- package/README.md +28 -1
- package/dist/formio.builder.css +19 -17
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.css +19 -17
- package/dist/formio.form.js +102 -176
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -3
- package/dist/formio.full.css +19 -17
- package/dist/formio.full.js +123 -101
- package/dist/formio.full.min.css +2 -2
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -3
- package/dist/formio.js +10 -10
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +3 -3
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/CDN.d.ts +1 -1
- package/lib/cjs/CDN.js +2 -2
- package/lib/cjs/Embed.js +1 -1
- package/lib/cjs/Form.d.ts +4 -6
- package/lib/cjs/Form.js +16 -8
- package/lib/cjs/Formio.js +1 -1
- package/lib/cjs/PDFBuilder.js +4 -4
- package/lib/cjs/Webform.d.ts +16 -13
- package/lib/cjs/Webform.js +162 -148
- package/lib/cjs/WebformBuilder.js +17 -28
- package/lib/cjs/Wizard.js +1 -1
- package/lib/cjs/WizardBuilder.js +15 -2
- package/lib/cjs/components/Components.d.ts +3 -0
- package/lib/cjs/components/_classes/component/Component.d.ts +1 -0
- package/lib/cjs/components/_classes/component/Component.js +38 -11
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +37 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +32 -2
- package/lib/cjs/components/_classes/component/editForm/utils.d.ts +1 -0
- package/lib/cjs/components/_classes/component/editForm/utils.js +3 -0
- package/lib/cjs/components/_classes/input/Input.js +23 -1
- package/lib/cjs/components/_classes/list/ListComponent.js +4 -4
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +10 -3
- package/lib/cjs/components/_classes/nested/NestedComponent.form.js +13 -0
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -0
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +52 -31
- package/lib/cjs/components/address/Address.js +14 -1
- package/lib/cjs/components/button/Button.js +6 -6
- package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/cjs/components/checkbox/Checkbox.js +2 -2
- package/lib/cjs/components/content/editForm/Content.edit.display.js +8 -0
- package/lib/cjs/components/currency/editForm/Currency.edit.display.js +12 -0
- package/lib/cjs/components/datagrid/DataGrid.d.ts +2 -0
- package/lib/cjs/components/datagrid/DataGrid.js +41 -26
- package/lib/cjs/components/day/Day.js +9 -7
- package/lib/cjs/components/day/editForm/Day.edit.display.js +8 -0
- package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -1
- package/lib/cjs/components/editgrid/EditGrid.js +26 -8
- package/lib/cjs/components/email/editForm/Email.edit.display.js +12 -0
- package/lib/cjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
- package/lib/cjs/components/file/File.d.ts +1 -1
- package/lib/cjs/components/file/File.js +30 -19
- package/lib/cjs/components/form/Form.d.ts +1 -1
- package/lib/cjs/components/form/Form.js +9 -5
- package/lib/cjs/components/form/editForm/Form.edit.form.js +3 -3
- package/lib/cjs/components/hidden/Hidden.d.ts +0 -1
- package/lib/cjs/components/hidden/Hidden.js +1 -1
- package/lib/cjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
- package/lib/cjs/components/html/editForm/HTML.edit.display.js +8 -0
- package/lib/cjs/components/number/Number.js +12 -5
- package/lib/cjs/components/number/editForm/Number.edit.display.js +12 -0
- package/lib/cjs/components/password/editForm/Password.edit.display.js +13 -1
- package/lib/cjs/components/phonenumber/PhoneNumber.form.js +9 -1
- package/lib/cjs/components/radio/Radio.js +10 -0
- package/lib/cjs/components/recaptcha/ReCaptcha.js +2 -2
- package/lib/cjs/components/select/Select.d.ts +0 -1
- package/lib/cjs/components/select/Select.js +12 -33
- package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +1 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.js +3 -2
- package/lib/cjs/components/selectboxes/SelectBoxes.js +2 -2
- package/lib/cjs/components/signature/Signature.d.ts +1 -1
- package/lib/cjs/components/signature/Signature.js +5 -3
- 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/survey/Survey.js +2 -2
- package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
- package/lib/cjs/components/tags/Tags.d.ts +1 -1
- package/lib/cjs/components/tags/Tags.js +2 -2
- package/lib/cjs/components/textarea/TextArea.js +6 -6
- package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
- package/lib/cjs/components/url/editForm/Url.edit.display.js +12 -0
- package/lib/cjs/components/well/editForm/Well.edit.display.js +8 -0
- package/lib/cjs/formio.form.js +5 -0
- package/lib/cjs/providers/storage/googleDrive.js +3 -2
- package/lib/cjs/providers/storage/s3.js +3 -3
- package/lib/cjs/providers/storage/xhr.d.ts +1 -0
- package/lib/cjs/providers/storage/xhr.js +6 -1
- package/lib/cjs/translations/en.d.ts +234 -81
- package/lib/cjs/translations/en.js +8 -81
- package/lib/cjs/utils/ChoicesWrapper.d.ts +4 -25
- package/lib/cjs/utils/ChoicesWrapper.js +47 -124
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/i18n.d.ts +5 -2
- package/lib/cjs/utils/i18n.js +32 -5
- package/lib/cjs/widgets/CalendarWidget.js +27 -27
- package/lib/mjs/CDN.d.ts +1 -1
- package/lib/mjs/CDN.js +2 -2
- package/lib/mjs/Embed.js +1 -1
- package/lib/mjs/Form.d.ts +4 -6
- package/lib/mjs/Form.js +17 -9
- package/lib/mjs/Formio.js +1 -1
- package/lib/mjs/PDFBuilder.js +4 -4
- package/lib/mjs/Webform.d.ts +16 -13
- package/lib/mjs/Webform.js +171 -158
- package/lib/mjs/WebformBuilder.js +17 -28
- package/lib/mjs/Wizard.js +1 -1
- package/lib/mjs/WizardBuilder.js +15 -2
- package/lib/mjs/components/Components.d.ts +3 -0
- package/lib/mjs/components/_classes/component/Component.d.ts +1 -0
- package/lib/mjs/components/_classes/component/Component.js +27 -11
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +37 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +32 -2
- package/lib/mjs/components/_classes/component/editForm/utils.d.ts +1 -0
- package/lib/mjs/components/_classes/component/editForm/utils.js +3 -0
- package/lib/mjs/components/_classes/input/Input.js +22 -1
- package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +10 -3
- package/lib/mjs/components/_classes/nested/NestedComponent.form.js +13 -0
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -0
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +53 -31
- package/lib/mjs/components/address/Address.js +14 -1
- package/lib/mjs/components/button/Button.js +6 -6
- package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/mjs/components/checkbox/Checkbox.js +2 -2
- package/lib/mjs/components/content/editForm/Content.edit.display.js +8 -0
- package/lib/mjs/components/currency/editForm/Currency.edit.display.js +12 -0
- package/lib/mjs/components/datagrid/DataGrid.d.ts +2 -0
- package/lib/mjs/components/datagrid/DataGrid.js +41 -26
- package/lib/mjs/components/day/Day.js +9 -7
- package/lib/mjs/components/day/editForm/Day.edit.display.js +8 -0
- package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -1
- package/lib/mjs/components/editgrid/EditGrid.js +25 -7
- package/lib/mjs/components/email/editForm/Email.edit.display.js +12 -0
- package/lib/mjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
- package/lib/mjs/components/file/File.d.ts +1 -1
- package/lib/mjs/components/file/File.js +30 -19
- package/lib/mjs/components/form/Form.d.ts +1 -1
- package/lib/mjs/components/form/Form.js +8 -5
- package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -3
- package/lib/mjs/components/hidden/Hidden.d.ts +0 -1
- package/lib/mjs/components/hidden/Hidden.js +1 -1
- package/lib/mjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
- package/lib/mjs/components/html/editForm/HTML.edit.display.js +8 -0
- package/lib/mjs/components/number/Number.js +12 -5
- package/lib/mjs/components/number/editForm/Number.edit.display.js +12 -0
- package/lib/mjs/components/password/editForm/Password.edit.display.js +13 -1
- package/lib/mjs/components/phonenumber/PhoneNumber.form.js +9 -1
- package/lib/mjs/components/radio/Radio.js +10 -0
- package/lib/mjs/components/recaptcha/ReCaptcha.js +2 -2
- package/lib/mjs/components/select/Select.d.ts +0 -1
- package/lib/mjs/components/select/Select.js +14 -34
- package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +1 -1
- package/lib/mjs/components/select/editForm/Select.edit.data.js +3 -2
- package/lib/mjs/components/selectboxes/SelectBoxes.js +2 -2
- package/lib/mjs/components/signature/Signature.d.ts +1 -1
- package/lib/mjs/components/signature/Signature.js +5 -3
- 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/survey/Survey.js +2 -2
- package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
- package/lib/mjs/components/tags/Tags.d.ts +1 -1
- package/lib/mjs/components/tags/Tags.js +2 -2
- package/lib/mjs/components/textarea/TextArea.js +6 -6
- package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
- package/lib/mjs/components/url/editForm/Url.edit.display.js +12 -0
- package/lib/mjs/components/well/editForm/Well.edit.display.js +8 -0
- package/lib/mjs/formio.form.js +5 -0
- package/lib/mjs/providers/storage/googleDrive.js +3 -2
- package/lib/mjs/providers/storage/s3.js +3 -3
- package/lib/mjs/providers/storage/xhr.d.ts +1 -0
- package/lib/mjs/providers/storage/xhr.js +6 -1
- package/lib/mjs/translations/en.d.ts +234 -81
- package/lib/mjs/translations/en.js +87 -1
- package/lib/mjs/utils/ChoicesWrapper.d.ts +4 -25
- package/lib/mjs/utils/ChoicesWrapper.js +26 -119
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/i18n.d.ts +5 -2
- package/lib/mjs/utils/i18n.js +32 -5
- package/lib/mjs/widgets/CalendarWidget.js +27 -27
- package/package.json +27 -11
@@ -22,7 +22,7 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
|
|
22
22
|
return this.iteratableRows[component.rowIndex].data;
|
23
23
|
}
|
24
24
|
get iteratableRows() {
|
25
|
-
throw new Error(
|
25
|
+
throw new Error(this.t('iteratableRowsError'));
|
26
26
|
}
|
27
27
|
get rowIndex() {
|
28
28
|
return this._rowIndex;
|
@@ -65,7 +65,7 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
|
|
65
65
|
return this.validateComponents([this.component], data, flags);
|
66
66
|
}
|
67
67
|
checkRow(...args) {
|
68
|
-
console.log('
|
68
|
+
console.log(this.t('checkRowDeprecation'));
|
69
69
|
return this.processRow.call(this, ...args);
|
70
70
|
}
|
71
71
|
processRow(method, data, opts, row, components, silentCheck) {
|
@@ -112,39 +112,60 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
|
|
112
112
|
}
|
113
113
|
});
|
114
114
|
}
|
115
|
+
_getEmailTableHeader(options) {
|
116
|
+
let row = '';
|
117
|
+
const getHeaderCell = (component) => {
|
118
|
+
if (!component.isInputComponent || !component.visible || component.skipInEmail) {
|
119
|
+
return '';
|
120
|
+
}
|
121
|
+
const label = component.label || component.key;
|
122
|
+
return `<th style="padding: 5px 10px;">${this.t(label, { _userInput: true })}</th>`;
|
123
|
+
};
|
124
|
+
const components = this.getComponents(0);
|
125
|
+
for (const component of components) {
|
126
|
+
if (component.isInputComponent) {
|
127
|
+
row += getHeaderCell(component);
|
128
|
+
}
|
129
|
+
else if ((0, utils_2.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
|
130
|
+
component.everyComponent((comp) => {
|
131
|
+
row += getHeaderCell(comp);
|
132
|
+
}, options);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
return `<thead><tr>${row}</tr></thead>`;
|
136
|
+
}
|
137
|
+
_getEmailTableBody(options) {
|
138
|
+
const getBodyCell = (component) => {
|
139
|
+
if (!component.isInputComponent || !component.visible || component.skipInEmail) {
|
140
|
+
return '';
|
141
|
+
}
|
142
|
+
return `<td style="padding: 5px 10px;">${component.getView(component.dataValue, options)}</td>`;
|
143
|
+
};
|
144
|
+
const rows = [];
|
145
|
+
for (const { components } of this.iteratableRows) {
|
146
|
+
let row = '';
|
147
|
+
for (const component of components) {
|
148
|
+
if (component.isInputComponent) {
|
149
|
+
row += getBodyCell(component);
|
150
|
+
}
|
151
|
+
else if ((0, utils_2.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
|
152
|
+
component.everyComponent((comp) => {
|
153
|
+
row += getBodyCell(comp);
|
154
|
+
}, options);
|
155
|
+
}
|
156
|
+
}
|
157
|
+
rows.push(`<tr>${row}</tr>`);
|
158
|
+
}
|
159
|
+
return `<tbody>${rows.join('')}</tbody>`;
|
160
|
+
}
|
115
161
|
getValueAsString(value, options) {
|
116
|
-
var _a;
|
117
162
|
if (options === null || options === void 0 ? void 0 : options.email) {
|
118
|
-
|
163
|
+
return `
|
119
164
|
<table border="1" style="width:100%">
|
120
|
-
|
121
|
-
|
122
|
-
`);
|
123
|
-
(_a = this.component.components) === null || _a === void 0 ? void 0 : _a.forEach((component) => {
|
124
|
-
const label = component.label || component.key;
|
125
|
-
result += `<th style="padding: 5px 10px;">${label}</th>`;
|
126
|
-
});
|
127
|
-
result += (`
|
128
|
-
</tr>
|
129
|
-
</thead>
|
130
|
-
<tbody>
|
131
|
-
`);
|
132
|
-
this.iteratableRows.forEach(({ components }) => {
|
133
|
-
result += '<tr>';
|
134
|
-
lodash_1.default.each(components, (component) => {
|
135
|
-
result += '<td style="padding:5px 10px;">';
|
136
|
-
if (component.isInputComponent && component.visible && !component.skipInEmail) {
|
137
|
-
result += component.getView(component.dataValue, options);
|
138
|
-
}
|
139
|
-
result += '</td>';
|
140
|
-
});
|
141
|
-
result += '</tr>';
|
142
|
-
});
|
143
|
-
result += (`
|
144
|
-
</tbody>
|
165
|
+
${this._getEmailTableHeader(options)}
|
166
|
+
${this._getEmailTableBody(options)}
|
145
167
|
</table>
|
146
|
-
|
147
|
-
return result;
|
168
|
+
`;
|
148
169
|
}
|
149
170
|
if (!value || !value.length) {
|
150
171
|
return '';
|
@@ -115,6 +115,19 @@ class AddressComponent extends Container_1.default {
|
|
115
115
|
NestedComponent_1.default.prototype.addComponents.call(this, this.manualMode ? this.address : {});
|
116
116
|
}
|
117
117
|
Field_1.default.prototype.init.call(this);
|
118
|
+
// Added for backwards compatibility
|
119
|
+
if (this.component.providerOptions) {
|
120
|
+
const { params, url, queryProperty, responseProperty, displayValueProperty } = this.component.providerOptions;
|
121
|
+
const key = params === null || params === void 0 ? void 0 : params.key;
|
122
|
+
const autocompleteOptions = params === null || params === void 0 ? void 0 : params.autocompleteOptions;
|
123
|
+
delete this.component.providerOptions;
|
124
|
+
this.component.url = url;
|
125
|
+
this.component.queryProperty = queryProperty;
|
126
|
+
this.component.responseProperty = responseProperty;
|
127
|
+
this.component.displayValueProperty = displayValueProperty;
|
128
|
+
this.component.apiKey = key;
|
129
|
+
this.component.autocompleteOptions = autocompleteOptions;
|
130
|
+
}
|
118
131
|
let provider = this.component.provider;
|
119
132
|
const providerOptions = this.providerOptions;
|
120
133
|
const map = this.component.map;
|
@@ -321,7 +334,7 @@ class AddressComponent extends Container_1.default {
|
|
321
334
|
return !this.isMultiple && (this.builderMode || this.manualModeEnabled);
|
322
335
|
}
|
323
336
|
get addAnother() {
|
324
|
-
return this.t(this.component.addAnother || '
|
337
|
+
return this.t(this.component.addAnother || 'addAnother');
|
325
338
|
}
|
326
339
|
renderElement(value) {
|
327
340
|
return this.renderTemplate(this.templateName, {
|
@@ -342,17 +342,17 @@ class ButtonComponent extends Field_1.default {
|
|
342
342
|
break;
|
343
343
|
case 'oauth':
|
344
344
|
if (this.root === this) {
|
345
|
-
console.warn('
|
345
|
+
console.warn(this.t('noOAuthBtn'));
|
346
346
|
return;
|
347
347
|
}
|
348
348
|
// Display Alert if OAuth config is missing
|
349
349
|
if (!this.oauthConfig) {
|
350
|
-
this.root.setAlert('danger',
|
350
|
+
this.root.setAlert('danger', this.t('noOAuthConfiguration'));
|
351
351
|
break;
|
352
352
|
}
|
353
353
|
// Display Alert if oAuth has an error is missing
|
354
354
|
if (this.oauthConfig.error) {
|
355
|
-
this.root.setAlert('danger',
|
355
|
+
this.root.setAlert('danger', `${this.t('oAuthErrorsTitle')} ${this.t(this.oauthConfig.error)}`);
|
356
356
|
break;
|
357
357
|
}
|
358
358
|
this.openOauth(this.oauthConfig);
|
@@ -361,7 +361,7 @@ class ButtonComponent extends Field_1.default {
|
|
361
361
|
}
|
362
362
|
openOauth(settings) {
|
363
363
|
if (!this.root.formio) {
|
364
|
-
console.warn(
|
364
|
+
console.warn(this.t('noOAuthFormUrl'));
|
365
365
|
return;
|
366
366
|
}
|
367
367
|
/*eslint-disable camelcase */
|
@@ -409,7 +409,7 @@ class ButtonComponent extends Field_1.default {
|
|
409
409
|
}
|
410
410
|
// TODO: check for error response here
|
411
411
|
if (settings.state !== params.state) {
|
412
|
-
this.root.setAlert('danger',
|
412
|
+
this.root.setAlert('danger', this.t('oAuthStateError'));
|
413
413
|
return;
|
414
414
|
}
|
415
415
|
// Depending on where the settings came from, submit to either the submission endpoint (old) or oauth endpoint (new).
|
@@ -442,7 +442,7 @@ class ButtonComponent extends Field_1.default {
|
|
442
442
|
}
|
443
443
|
catch (error) {
|
444
444
|
if (error.name !== 'SecurityError' && (error.name !== 'Error' || error.message !== 'Permission denied')) {
|
445
|
-
this.root.setAlert('danger', error.message || error);
|
445
|
+
this.root.setAlert('danger', this.t(`${error.message || error}`));
|
446
446
|
}
|
447
447
|
}
|
448
448
|
if (!popup || popup.closed || popup.closed === undefined) {
|
@@ -43,7 +43,7 @@ export default class CheckBoxComponent extends Field {
|
|
43
43
|
attach(element: any): Promise<void>;
|
44
44
|
input: any;
|
45
45
|
detach(element: any): void;
|
46
|
-
get emptyValue(): false |
|
46
|
+
get emptyValue(): false | "";
|
47
47
|
getValueAt(index: any): any;
|
48
48
|
get checked(): boolean;
|
49
49
|
setCheckedState(value: any): any;
|
@@ -117,7 +117,7 @@ class CheckBoxComponent extends Field_1.default {
|
|
117
117
|
super.detach();
|
118
118
|
}
|
119
119
|
get emptyValue() {
|
120
|
-
return this.component.inputType === 'radio' ?
|
120
|
+
return this.component.inputType === 'radio' ? '' : false;
|
121
121
|
}
|
122
122
|
isEmpty(value = this.dataValue) {
|
123
123
|
return super.isEmpty(value) || value === false;
|
@@ -188,7 +188,7 @@ class CheckBoxComponent extends Field_1.default {
|
|
188
188
|
if (lodash_1.default.isUndefined(value) && this.inDataTable) {
|
189
189
|
return '';
|
190
190
|
}
|
191
|
-
return this.t(hasValue ? '
|
191
|
+
return this.t(hasValue ? 'yes' : 'no');
|
192
192
|
}
|
193
193
|
updateValue(value, flags) {
|
194
194
|
// If this is a radio and is alredy checked, uncheck it.
|
@@ -9,6 +9,18 @@ exports.default = [
|
|
9
9
|
key: 'allowMultipleMasks',
|
10
10
|
ignore: true
|
11
11
|
},
|
12
|
+
{
|
13
|
+
key: 'inputMasks',
|
14
|
+
ignore: true
|
15
|
+
},
|
16
|
+
{
|
17
|
+
key: 'widget.type',
|
18
|
+
ignore: true
|
19
|
+
},
|
20
|
+
{
|
21
|
+
key: 'widget',
|
22
|
+
ignore: true
|
23
|
+
},
|
12
24
|
{
|
13
25
|
key: 'showWordCount',
|
14
26
|
ignore: true
|
@@ -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[];
|
@@ -70,6 +71,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
70
71
|
*/
|
71
72
|
reorderValues(valuesArr: any, oldPosition: number, newPosition: number, movedBelow: boolean | any): void;
|
72
73
|
onReorder(element: any, _target: any, _source: any, sibling: any): void;
|
74
|
+
onCloned(el: any, original: any): void;
|
73
75
|
focusOnNewRowElement(row: any): void;
|
74
76
|
addRow(): void;
|
75
77
|
updateComponentsRowIndex(components: any, rowIndex: any): void;
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
7
|
const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
|
8
8
|
const utils_1 = require("../../utils/utils");
|
9
|
-
const dragula_1 = __importDefault(require("dragula"));
|
10
9
|
class DataGridComponent extends NestedArrayComponent_1.default {
|
11
10
|
static schema(...extend) {
|
12
11
|
return NestedArrayComponent_1.default.schema({
|
@@ -43,6 +42,9 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
43
42
|
if (this.initRows || !lodash_1.default.isEqual(this.dataValue, this.emptyValue)) {
|
44
43
|
this.createRows(true);
|
45
44
|
}
|
45
|
+
if (this.allowReorder) {
|
46
|
+
this.dragulaReady = this.getDragula();
|
47
|
+
}
|
46
48
|
this.visibleColumns = {};
|
47
49
|
this.prevHasAddButton = this.hasAddButton();
|
48
50
|
this.checkColumns();
|
@@ -273,31 +275,25 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
273
275
|
this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
|
274
276
|
row.dragInfo = { index };
|
275
277
|
});
|
276
|
-
this.dragula
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
}
|
278
|
+
this.dragulaReady.then((dragula) => {
|
279
|
+
// The drop event may call redraw twice which calls attach twice and because this block of code is asynchronous
|
280
|
+
// BOTH redraws may be called before this block of code runs (which causes this block of code to run twice sequentially).
|
281
|
+
// This causes two dragula() calls on the same container which breaks dragula. To fix this the return value must
|
282
|
+
// be saved in this.dragula and have its container contents reset if it exists
|
283
|
+
if (this.dragula && this.dragula.containers) {
|
284
|
+
this.dragula.containers = [];
|
284
285
|
}
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
if (
|
291
|
-
|
286
|
+
this.dragula = dragula([this.refs[`${this.datagridKey}-tbody`]], {
|
287
|
+
moves: (_draggedElement, _oldParent, clickedElement) => {
|
288
|
+
const clickedElementKey = clickedElement.getAttribute('data-key');
|
289
|
+
const oldParentKey = _oldParent.getAttribute('data-key');
|
290
|
+
//Check if the clicked button belongs to that container, if false, it belongs to the nested container
|
291
|
+
if (oldParentKey === clickedElementKey) {
|
292
|
+
return clickedElement.classList.contains('formio-drag-button');
|
292
293
|
}
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
}, '');
|
297
|
-
el.children[index].style.cssText = cssText;
|
298
|
-
}
|
299
|
-
});
|
300
|
-
}
|
294
|
+
}
|
295
|
+
}).on('drop', this.onReorder.bind(this))
|
296
|
+
.on('cloned', this.onCloned.bind(this));
|
301
297
|
});
|
302
298
|
}
|
303
299
|
this.refs[`${this.datagridKey}-addRow`].forEach((addButton) => {
|
@@ -346,7 +342,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
346
342
|
}
|
347
343
|
onReorder(element, _target, _source, sibling) {
|
348
344
|
if (!element.dragInfo || (sibling && !sibling.dragInfo)) {
|
349
|
-
console.warn('
|
345
|
+
console.warn(this.t('noDragInfoError'));
|
350
346
|
return;
|
351
347
|
}
|
352
348
|
const oldPosition = element.dragInfo.index;
|
@@ -357,10 +353,29 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
357
353
|
this.reorderValues(dataValue, oldPosition, newPosition, movedBelow);
|
358
354
|
//reorder select data
|
359
355
|
this.reorderValues(lodash_1.default.get(this.root, `submission.metadata.selectData.${this.path}`, []), oldPosition, newPosition, movedBelow);
|
356
|
+
// When components are reordered we need to set the dataGrid and form pristine properties to false
|
357
|
+
this.root.pristine = false;
|
358
|
+
this.pristine = false;
|
360
359
|
//need to re-build rows to re-calculate indexes and other indexed fields for component instance (like rows for ex.)
|
361
360
|
this.setValue(dataValue, { isReordered: true });
|
362
361
|
this.rebuild();
|
363
362
|
}
|
363
|
+
onCloned(el, original) {
|
364
|
+
if (el && el.children && original && original.children) {
|
365
|
+
lodash_1.default.each(original.children, (child, index) => {
|
366
|
+
const styles = getComputedStyle(child, null);
|
367
|
+
if (styles.cssText !== '') {
|
368
|
+
el.children[index].style.cssText = styles.cssText;
|
369
|
+
}
|
370
|
+
else {
|
371
|
+
const cssText = Object.values(styles).reduce((css, propertyName) => {
|
372
|
+
return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
|
373
|
+
}, '');
|
374
|
+
el.children[index].style.cssText = cssText;
|
375
|
+
}
|
376
|
+
});
|
377
|
+
}
|
378
|
+
}
|
364
379
|
focusOnNewRowElement(row) {
|
365
380
|
Object.keys(row).find((key) => {
|
366
381
|
const element = row[key].element;
|
@@ -419,7 +434,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
419
434
|
}
|
420
435
|
removeRow(index) {
|
421
436
|
const makeEmpty = index === 0 && this.rows.length === 1;
|
422
|
-
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
|
437
|
+
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty, modified: true };
|
423
438
|
this.splice(index, flags);
|
424
439
|
this.emit('dataGridDeleteRow', { index });
|
425
440
|
const [row] = this.rows.splice(index, 1);
|
@@ -53,11 +53,13 @@ class DayComponent extends Field_1.default {
|
|
53
53
|
return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.string];
|
54
54
|
}
|
55
55
|
constructor(component, options, data) {
|
56
|
-
if (
|
57
|
-
component.maxDate
|
58
|
-
|
59
|
-
|
60
|
-
component.minDate
|
56
|
+
if (!options.inFormBuilder && !options.building) {
|
57
|
+
if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
|
58
|
+
component.maxDate = (0, moment_1.default)(component.maxDate, 'YYYY-MM-DD').toISOString();
|
59
|
+
}
|
60
|
+
if (component.minDate && component.minDate.indexOf('moment(') === -1) {
|
61
|
+
component.minDate = (0, moment_1.default)(component.minDate, 'YYYY-MM-DD').toISOString();
|
62
|
+
}
|
61
63
|
}
|
62
64
|
super(component, options, data);
|
63
65
|
}
|
@@ -174,7 +176,7 @@ class DayComponent extends Field_1.default {
|
|
174
176
|
this._months = [
|
175
177
|
{
|
176
178
|
value: '',
|
177
|
-
label: lodash_1.default.get(this.component, 'fields.month.placeholder') || (this.hideInputLabels ? this.t('
|
179
|
+
label: lodash_1.default.get(this.component, 'fields.month.placeholder') || (this.hideInputLabels ? this.t('month') : '')
|
178
180
|
},
|
179
181
|
{ value: 1, label: 'January' },
|
180
182
|
{ value: 2, label: 'February' },
|
@@ -268,7 +270,7 @@ class DayComponent extends Field_1.default {
|
|
268
270
|
this.saveCaretPosition(element, name);
|
269
271
|
}
|
270
272
|
catch (err) {
|
271
|
-
console.warn('
|
273
|
+
console.warn(this.t('caretPositionSavingError'), err);
|
272
274
|
}
|
273
275
|
this.updateValue(null, {
|
274
276
|
modified: true,
|
@@ -43,7 +43,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
43
43
|
get defaultValue(): any[];
|
44
44
|
hasRemoveButtons(): boolean;
|
45
45
|
editRows: any;
|
46
|
-
checkRowVariableTypeComponents(editRow: any, rowIndex: any):
|
46
|
+
checkRowVariableTypeComponents(editRow: any, rowIndex: any): boolean;
|
47
47
|
setVariableTypeComponents(): void;
|
48
48
|
variableTypeComponentsIndexes: any[] | undefined;
|
49
49
|
isOpen(editRow: any): boolean;
|
@@ -120,10 +120,10 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
120
120
|
}
|
121
121
|
get defaultDialogTemplate() {
|
122
122
|
return `
|
123
|
-
<h3 ${this._referenceAttributeName}="dialogHeader">${this.t('
|
123
|
+
<h3 ${this._referenceAttributeName}="dialogHeader">${this.t('wantToClearData')}</h3>
|
124
124
|
<div style="display:flex; justify-content: flex-end;">
|
125
|
-
<button ${this._referenceAttributeName}="dialogCancelButton" class="btn btn-secondary" aria-label="${this.t('
|
126
|
-
<button ${this._referenceAttributeName}="dialogYesButton" class="btn btn-danger" aria-label="${this.t('
|
125
|
+
<button ${this._referenceAttributeName}="dialogCancelButton" class="btn btn-secondary" aria-label="${this.t('cancel')}">${this.t('cancel')}</button>
|
126
|
+
<button ${this._referenceAttributeName}="dialogYesButton" class="btn btn-danger" aria-label="${this.t('yesDelete')}">${this.t('yesDelete')}</button>
|
127
127
|
</div>
|
128
128
|
`;
|
129
129
|
}
|
@@ -294,12 +294,15 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
294
294
|
}
|
295
295
|
checkRowVariableTypeComponents(editRow, rowIndex) {
|
296
296
|
const rowComponents = editRow.components;
|
297
|
+
let typeChanged = false;
|
297
298
|
if (lodash_1.default.some(this.variableTypeComponentsIndexes, (compIndex) => {
|
298
299
|
const variableTypeComp = rowComponents[compIndex];
|
299
300
|
return variableTypeComp.type !== variableTypeComp.component.type;
|
300
301
|
})) {
|
301
302
|
editRow.components = this.createRowComponents(editRow.data, rowIndex, true);
|
303
|
+
typeChanged = true;
|
302
304
|
}
|
305
|
+
return typeChanged;
|
303
306
|
}
|
304
307
|
setVariableTypeComponents() {
|
305
308
|
//set components which type is changing within a row (e.g.,by mergeComponentSchema action)
|
@@ -669,6 +672,11 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
669
672
|
}
|
670
673
|
},
|
671
674
|
}, this.component.saveRow || 'Save'));
|
675
|
+
this.emit('editGridOpenModal', {
|
676
|
+
component: this.component,
|
677
|
+
row: editRow,
|
678
|
+
instance: this,
|
679
|
+
});
|
672
680
|
return this.attachComponents(modalContent, components);
|
673
681
|
}
|
674
682
|
showDialog(rowIndex) {
|
@@ -726,6 +734,11 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
726
734
|
editRow.data = dataSnapshot;
|
727
735
|
this.restoreRowContext(editRow);
|
728
736
|
}
|
737
|
+
this.emit('editGridEditRow', {
|
738
|
+
component: this.component,
|
739
|
+
row: editRow,
|
740
|
+
instance: this,
|
741
|
+
});
|
729
742
|
if (this.component.modal) {
|
730
743
|
return this.addRowModal(rowIndex);
|
731
744
|
}
|
@@ -934,8 +947,10 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
934
947
|
this.validateRow(editRow, false, false);
|
935
948
|
}
|
936
949
|
if (this.variableTypeComponentsIndexes.length) {
|
937
|
-
this.checkRowVariableTypeComponents(editRow, rowIndex);
|
938
|
-
|
950
|
+
const typeChanged = this.checkRowVariableTypeComponents(editRow, rowIndex);
|
951
|
+
if (typeChanged) {
|
952
|
+
this.redraw();
|
953
|
+
}
|
939
954
|
}
|
940
955
|
};
|
941
956
|
const comp = this.createComponent(lodash_1.default.assign({}, column, { row: options.row }), options, row, null, recreatePartially && currentRowComponents ? currentRowComponents[colIndex] : null);
|
@@ -970,7 +985,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
970
985
|
dirty;
|
971
986
|
}
|
972
987
|
validateRow(editRow, dirty, forceSilentCheck, fromSubmission) {
|
973
|
-
var _a;
|
988
|
+
var _a, _b;
|
974
989
|
editRow.errors = [];
|
975
990
|
if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
|
976
991
|
const silentCheck = forceSilentCheck === false ? false : ((this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck);
|
@@ -1015,13 +1030,16 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
1015
1030
|
if (valid === null) {
|
1016
1031
|
editRow.errors.push({
|
1017
1032
|
type: 'error',
|
1018
|
-
message:
|
1033
|
+
message: this.t('componentInvalidRowValidation', { componentKey: this.key })
|
1019
1034
|
});
|
1020
1035
|
}
|
1021
1036
|
}
|
1022
|
-
if (!this.component.rowDrafts || ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted)) {
|
1037
|
+
if (editRow.alerts && (!this.component.rowDrafts || ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted))) {
|
1023
1038
|
this.showRowErrorAlerts(editRow, editRow.errors);
|
1024
1039
|
}
|
1040
|
+
else if ((_b = editRow.errors) === null || _b === void 0 ? void 0 : _b.length) {
|
1041
|
+
this.setCustomValidity(editRow.errors, dirty);
|
1042
|
+
}
|
1025
1043
|
return editRow.errors;
|
1026
1044
|
}
|
1027
1045
|
showRowErrorAlerts(editRow, errors) {
|
@@ -9,6 +9,18 @@ exports.default = [
|
|
9
9
|
key: 'allowMultipleMasks',
|
10
10
|
ignore: true,
|
11
11
|
},
|
12
|
+
{
|
13
|
+
key: 'inputMasks',
|
14
|
+
ignore: true
|
15
|
+
},
|
16
|
+
{
|
17
|
+
key: 'widget.type',
|
18
|
+
ignore: true
|
19
|
+
},
|
20
|
+
{
|
21
|
+
key: 'widget',
|
22
|
+
ignore: true
|
23
|
+
},
|
12
24
|
{
|
13
25
|
key: 'showWordCount',
|
14
26
|
ignore: true
|
@@ -33,7 +33,7 @@ export default class FileComponent extends Field {
|
|
33
33
|
get dataReady(): Promise<any>;
|
34
34
|
loadImage(fileInfo: any): any;
|
35
35
|
get emptyValue(): never[];
|
36
|
-
getValueAsString(value: any): any;
|
36
|
+
getValueAsString(value: any, options: any): any;
|
37
37
|
get defaultValue(): any[];
|
38
38
|
get hasTypes(): any;
|
39
39
|
_fileBrowseHidden: any;
|