@formio/js 5.4.0 → 5.4.2
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/README.md +11 -5
- package/dist/formio.builder.css +12 -5
- 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 +12 -5
- package/dist/formio.form.js +2883 -2867
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +2 -2
- package/dist/formio.full.css +12 -5
- package/dist/formio.full.js +3507 -3491
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +2 -2
- package/dist/formio.js +1139 -1145
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +2 -2
- package/dist/formio.utils.js +1066 -1072
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -2
- package/lib/cjs/Embed.js +8 -16
- package/lib/cjs/Form.js +4 -4
- package/lib/cjs/Formio.js +2 -9
- package/lib/cjs/InlineEmbed.js +1 -4
- package/lib/cjs/PDF.js +28 -8
- package/lib/cjs/PDFBuilder.js +6 -10
- package/lib/cjs/Webform.d.ts +1 -0
- package/lib/cjs/Webform.js +19 -34
- package/lib/cjs/WebformBuilder.js +27 -68
- package/lib/cjs/Wizard.d.ts +1 -0
- package/lib/cjs/Wizard.js +44 -31
- package/lib/cjs/WizardBuilder.js +5 -15
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
- package/lib/cjs/addons/index.js +1 -3
- package/lib/cjs/components/_classes/component/Component.d.ts +10 -5
- package/lib/cjs/components/_classes/component/Component.js +76 -134
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
- package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
- package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
- package/lib/cjs/components/_classes/field/Field.js +1 -4
- package/lib/cjs/components/_classes/input/Input.js +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.js +4 -4
- package/lib/cjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +8 -26
- package/lib/cjs/components/_classes/nested/NestedComponent.js +1 -4
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
- package/lib/cjs/components/address/Address.js +10 -30
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -32
- package/lib/cjs/components/alert/Alert.js +3 -6
- package/lib/cjs/components/button/Button.d.ts +1 -0
- package/lib/cjs/components/button/Button.js +31 -17
- package/lib/cjs/components/button/editForm/Button.edit.display.js +8 -32
- package/lib/cjs/components/checkbox/Checkbox.js +4 -10
- package/lib/cjs/components/checkbox/editForm/Checkbox.edit.display.js +2 -8
- package/lib/cjs/components/columns/Columns.js +5 -17
- package/lib/cjs/components/container/Container.js +1 -3
- package/lib/cjs/components/currency/Currency.js +2 -7
- package/lib/cjs/components/datagrid/DataGrid.js +27 -68
- package/lib/cjs/components/datamap/DataMap.js +4 -16
- package/lib/cjs/components/datetime/DateTime.js +2 -6
- package/lib/cjs/components/datetime/editForm/DateTime.edit.display.js +1 -4
- package/lib/cjs/components/day/Day.js +12 -70
- package/lib/cjs/components/day/editForm/Day.edit.day.js +1 -3
- package/lib/cjs/components/day/editForm/Day.edit.month.js +1 -3
- package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -0
- package/lib/cjs/components/editgrid/EditGrid.js +18 -44
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -4
- package/lib/cjs/components/file/File.js +40 -70
- package/lib/cjs/components/file/editForm/File.edit.display.js +1 -5
- package/lib/cjs/components/file/editForm/File.edit.file.js +8 -30
- package/lib/cjs/components/form/Form.js +5 -7
- package/lib/cjs/components/html/HTML.js +1 -5
- package/lib/cjs/components/number/Number.js +2 -4
- package/lib/cjs/components/panel/editForm/Panel.edit.display.js +3 -12
- package/lib/cjs/components/password/Password.js +1 -4
- package/lib/cjs/components/radio/Radio.js +7 -17
- package/lib/cjs/components/radio/editForm/Radio.edit.data.js +4 -14
- package/lib/cjs/components/recaptcha/ReCaptcha.js +3 -6
- package/lib/cjs/components/select/Select.js +49 -94
- package/lib/cjs/components/select/editForm/Select.edit.data.js +37 -182
- package/lib/cjs/components/select/editForm/Select.edit.validation.js +1 -9
- package/lib/cjs/components/selectboxes/SelectBoxes.js +3 -6
- package/lib/cjs/components/signature/Signature.d.ts +1 -1
- package/lib/cjs/components/signature/Signature.js +5 -10
- package/lib/cjs/components/signature/editForm/Signature.edit.display.js +2 -6
- package/lib/cjs/components/survey/Survey.js +6 -17
- package/lib/cjs/components/survey/editForm/Survey.edit.data.js +4 -12
- package/lib/cjs/components/table/editForm/Table.edit.display.js +3 -3
- package/lib/cjs/components/tabs/Tabs.js +4 -19
- package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
- package/lib/cjs/components/tags/Tags.js +4 -14
- package/lib/cjs/components/textarea/TextArea.js +8 -15
- package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
- package/lib/cjs/components/textfield/TextField.js +4 -4
- package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +2 -8
- package/lib/cjs/components/time/Time.js +1 -4
- package/lib/cjs/components/time/editForm/Time.edit.display.js +1 -4
- package/lib/cjs/formio.form.js +5 -5
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/providers/address/AddressProvider.js +1 -1
- package/lib/cjs/providers/address/GoogleAddressProvider.js +2 -4
- package/lib/cjs/providers/processor/fileProcessor.js +1 -3
- package/lib/cjs/providers/storage/azure.js +5 -6
- package/lib/cjs/providers/storage/indexeddb.js +5 -15
- package/lib/cjs/providers/storage/s3.js +3 -14
- package/lib/cjs/providers/storage/xhr.js +19 -28
- package/lib/cjs/templates/Templates.js +1 -0
- package/lib/cjs/translations/en.d.ts +237 -81
- package/lib/cjs/translations/en.js +10 -81
- package/lib/cjs/utils/ChoicesWrapper.js +1 -1
- package/lib/cjs/utils/builder.js +5 -26
- package/lib/cjs/utils/i18n.d.ts +5 -2
- package/lib/cjs/utils/i18n.js +33 -12
- package/lib/cjs/utils/utils.js +42 -52
- package/lib/cjs/widgets/CalendarWidget.js +2 -6
- package/lib/mjs/Embed.js +8 -16
- package/lib/mjs/Form.js +4 -4
- package/lib/mjs/Formio.js +2 -9
- package/lib/mjs/InlineEmbed.js +1 -4
- package/lib/mjs/PDF.js +27 -8
- package/lib/mjs/PDFBuilder.js +6 -10
- package/lib/mjs/Webform.d.ts +1 -0
- package/lib/mjs/Webform.js +19 -31
- package/lib/mjs/WebformBuilder.js +27 -68
- package/lib/mjs/Wizard.d.ts +1 -0
- package/lib/mjs/Wizard.js +39 -27
- package/lib/mjs/WizardBuilder.js +5 -15
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
- package/lib/mjs/addons/index.js +1 -3
- package/lib/mjs/components/_classes/component/Component.d.ts +10 -5
- package/lib/mjs/components/_classes/component/Component.js +75 -134
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
- package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
- package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
- package/lib/mjs/components/_classes/field/Field.js +1 -4
- package/lib/mjs/components/_classes/input/Input.js +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
- package/lib/mjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +8 -26
- package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -4
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
- package/lib/mjs/components/address/Address.js +10 -30
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -32
- package/lib/mjs/components/alert/Alert.js +3 -6
- package/lib/mjs/components/button/Button.d.ts +1 -0
- package/lib/mjs/components/button/Button.js +29 -16
- package/lib/mjs/components/button/editForm/Button.edit.display.js +8 -32
- package/lib/mjs/components/checkbox/Checkbox.js +4 -10
- package/lib/mjs/components/checkbox/editForm/Checkbox.edit.display.js +2 -8
- package/lib/mjs/components/columns/Columns.js +5 -17
- package/lib/mjs/components/container/Container.js +1 -3
- package/lib/mjs/components/currency/Currency.js +2 -7
- package/lib/mjs/components/datagrid/DataGrid.js +28 -69
- package/lib/mjs/components/datamap/DataMap.js +12 -18
- package/lib/mjs/components/datetime/DateTime.js +2 -6
- package/lib/mjs/components/datetime/editForm/DateTime.edit.display.js +1 -4
- package/lib/mjs/components/day/Day.js +12 -70
- package/lib/mjs/components/day/editForm/Day.edit.day.js +1 -3
- package/lib/mjs/components/day/editForm/Day.edit.month.js +1 -3
- package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -0
- package/lib/mjs/components/editgrid/EditGrid.js +18 -44
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -4
- package/lib/mjs/components/file/File.js +40 -70
- package/lib/mjs/components/file/editForm/File.edit.display.js +1 -5
- package/lib/mjs/components/file/editForm/File.edit.file.js +8 -30
- package/lib/mjs/components/form/Form.js +5 -7
- package/lib/mjs/components/html/HTML.js +1 -5
- package/lib/mjs/components/number/Number.js +2 -4
- package/lib/mjs/components/panel/editForm/Panel.edit.display.js +3 -12
- package/lib/mjs/components/password/Password.js +1 -4
- package/lib/mjs/components/radio/Radio.js +7 -17
- package/lib/mjs/components/radio/editForm/Radio.edit.data.js +4 -14
- package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -6
- package/lib/mjs/components/select/Select.js +52 -97
- package/lib/mjs/components/select/editForm/Select.edit.data.js +37 -182
- package/lib/mjs/components/select/editForm/Select.edit.validation.js +1 -9
- package/lib/mjs/components/selectboxes/SelectBoxes.js +3 -6
- package/lib/mjs/components/signature/Signature.d.ts +1 -1
- package/lib/mjs/components/signature/Signature.js +5 -10
- package/lib/mjs/components/signature/editForm/Signature.edit.display.js +2 -6
- package/lib/mjs/components/survey/Survey.js +6 -17
- package/lib/mjs/components/survey/editForm/Survey.edit.data.js +4 -12
- package/lib/mjs/components/table/editForm/Table.edit.display.js +3 -3
- package/lib/mjs/components/tabs/Tabs.js +4 -19
- package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
- package/lib/mjs/components/tags/Tags.js +4 -14
- package/lib/mjs/components/textarea/TextArea.js +8 -15
- package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
- package/lib/mjs/components/textfield/TextField.js +4 -4
- package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +2 -8
- package/lib/mjs/components/time/Time.js +1 -4
- package/lib/mjs/components/time/editForm/Time.edit.display.js +1 -4
- package/lib/mjs/formio.form.js +6 -6
- package/lib/mjs/package.json +1 -1
- package/lib/mjs/providers/address/AddressProvider.js +1 -1
- package/lib/mjs/providers/address/GoogleAddressProvider.js +2 -4
- package/lib/mjs/providers/processor/fileProcessor.js +1 -3
- package/lib/mjs/providers/storage/azure.js +5 -6
- package/lib/mjs/providers/storage/indexeddb.js +5 -15
- package/lib/mjs/providers/storage/s3.js +3 -14
- package/lib/mjs/providers/storage/xhr.js +19 -32
- package/lib/mjs/templates/Templates.js +1 -0
- package/lib/mjs/translations/en.d.ts +237 -81
- package/lib/mjs/translations/en.js +91 -1
- package/lib/mjs/utils/ChoicesWrapper.js +1 -1
- package/lib/mjs/utils/builder.js +5 -26
- package/lib/mjs/utils/i18n.d.ts +5 -2
- package/lib/mjs/utils/i18n.js +33 -12
- package/lib/mjs/utils/utils.js +42 -52
- package/lib/mjs/widgets/CalendarWidget.js +2 -6
- package/package.json +8 -6
|
@@ -30,9 +30,7 @@ export default class CheckBoxComponent extends Field {
|
|
|
30
30
|
static get conditionOperatorsSettings() {
|
|
31
31
|
return {
|
|
32
32
|
...super.conditionOperatorsSettings,
|
|
33
|
-
operators: [
|
|
34
|
-
'isEqual',
|
|
35
|
-
],
|
|
33
|
+
operators: ['isEqual'],
|
|
36
34
|
valueComponent() {
|
|
37
35
|
return {
|
|
38
36
|
valueType: 'boolean',
|
|
@@ -54,13 +52,9 @@ export default class CheckBoxComponent extends Field {
|
|
|
54
52
|
return types;
|
|
55
53
|
}
|
|
56
54
|
if (schema.inputType === 'radio') {
|
|
57
|
-
return [
|
|
58
|
-
componentValueTypes.string,
|
|
59
|
-
];
|
|
55
|
+
return [componentValueTypes.string];
|
|
60
56
|
}
|
|
61
|
-
return [
|
|
62
|
-
componentValueTypes.boolean,
|
|
63
|
-
];
|
|
57
|
+
return [componentValueTypes.boolean];
|
|
64
58
|
}
|
|
65
59
|
get defaultSchema() {
|
|
66
60
|
return CheckBoxComponent.schema();
|
|
@@ -195,7 +189,7 @@ export default class CheckBoxComponent extends Field {
|
|
|
195
189
|
if (_.isUndefined(value) && this.inDataTable) {
|
|
196
190
|
return '';
|
|
197
191
|
}
|
|
198
|
-
return this.t(hasValue ? '
|
|
192
|
+
return this.t(hasValue ? 'yes' : 'no');
|
|
199
193
|
}
|
|
200
194
|
updateValue(value, flags) {
|
|
201
195
|
// If this is a radio and is alredy checked, uncheck it.
|
|
@@ -58,10 +58,7 @@ export default [
|
|
|
58
58
|
weight: 420,
|
|
59
59
|
conditional: {
|
|
60
60
|
json: {
|
|
61
|
-
'===': [
|
|
62
|
-
{ var: 'data.inputType' },
|
|
63
|
-
'radio',
|
|
64
|
-
],
|
|
61
|
+
'===': [{ var: 'data.inputType' }, 'radio'],
|
|
65
62
|
},
|
|
66
63
|
},
|
|
67
64
|
},
|
|
@@ -74,10 +71,7 @@ export default [
|
|
|
74
71
|
weight: 430,
|
|
75
72
|
conditional: {
|
|
76
73
|
json: {
|
|
77
|
-
'===': [
|
|
78
|
-
{ var: 'data.inputType' },
|
|
79
|
-
'radio',
|
|
80
|
-
],
|
|
74
|
+
'===': [{ var: 'data.inputType' }, 'radio'],
|
|
81
75
|
},
|
|
82
76
|
},
|
|
83
77
|
},
|
|
@@ -36,9 +36,7 @@ export default class ColumnsComponent extends NestedComponent {
|
|
|
36
36
|
this.rows = [];
|
|
37
37
|
}
|
|
38
38
|
get schema() {
|
|
39
|
-
const schema = _.omit(super.schema, [
|
|
40
|
-
'components',
|
|
41
|
-
]);
|
|
39
|
+
const schema = _.omit(super.schema, ['components']);
|
|
42
40
|
schema.columns?.map((column, colIndex) => {
|
|
43
41
|
column.components.map((comp, compIndex) => {
|
|
44
42
|
const clonedComp = _.clone(comp);
|
|
@@ -122,28 +120,18 @@ export default class ColumnsComponent extends NestedComponent {
|
|
|
122
120
|
const initVal = { stack: [], rows: [] };
|
|
123
121
|
const width = (x) => x.component.width;
|
|
124
122
|
const result = _.reduce(this.components, (acc, next) => {
|
|
125
|
-
const stack = [
|
|
126
|
-
...acc.stack,
|
|
127
|
-
next,
|
|
128
|
-
];
|
|
123
|
+
const stack = [...acc.stack, next];
|
|
129
124
|
if (_.sumBy(stack, width) <= this.gridSize) {
|
|
130
125
|
acc.stack = stack;
|
|
131
126
|
return acc;
|
|
132
127
|
}
|
|
133
128
|
else {
|
|
134
|
-
acc.rows = [
|
|
135
|
-
|
|
136
|
-
acc.stack,
|
|
137
|
-
];
|
|
138
|
-
acc.stack = [
|
|
139
|
-
next,
|
|
140
|
-
];
|
|
129
|
+
acc.rows = [...acc.rows, acc.stack];
|
|
130
|
+
acc.stack = [next];
|
|
141
131
|
return acc;
|
|
142
132
|
}
|
|
143
133
|
}, initVal);
|
|
144
|
-
return _.concat(result.rows, [
|
|
145
|
-
result.stack,
|
|
146
|
-
]);
|
|
134
|
+
return _.concat(result.rows, [result.stack]);
|
|
147
135
|
}
|
|
148
136
|
checkData(data, flags, row, components) {
|
|
149
137
|
super.checkData(data, flags, row, components);
|
|
@@ -32,9 +32,7 @@ export default class ContainerComponent extends NestedDataComponent {
|
|
|
32
32
|
this.type = 'container';
|
|
33
33
|
}
|
|
34
34
|
static savedValueTypes(schema) {
|
|
35
|
-
return
|
|
36
|
-
componentValueTypes.object,
|
|
37
|
-
]);
|
|
35
|
+
return getComponentSavedTypes(schema) || [componentValueTypes.object];
|
|
38
36
|
}
|
|
39
37
|
addComponents(data, options) {
|
|
40
38
|
return super.addComponents(this.dataValue, options);
|
|
@@ -104,13 +104,8 @@ export default class CurrencyComponent extends NumberComponent {
|
|
|
104
104
|
const isNegative = value.includes(negativeValueSymbol) || false;
|
|
105
105
|
value = this.stripPrefixSuffix(isNegative ? value.replace(negativeValueSymbol, '') : value);
|
|
106
106
|
if (value.includes(this.decimalSeparator)) {
|
|
107
|
-
[
|
|
108
|
-
|
|
109
|
-
decimalPart,
|
|
110
|
-
] = value.split(this.decimalSeparator);
|
|
111
|
-
decimalPartNumbers = [
|
|
112
|
-
...decimalPart.split(''),
|
|
113
|
-
];
|
|
107
|
+
[integerPart, decimalPart] = value.split(this.decimalSeparator);
|
|
108
|
+
decimalPartNumbers = [...decimalPart.split('')];
|
|
114
109
|
}
|
|
115
110
|
else {
|
|
116
111
|
integerPart = value;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
|
|
3
|
-
import { fastCloneDeep, getFocusableElements, getComponent, eachComponent
|
|
3
|
+
import { fastCloneDeep, getFocusableElements, getComponent, eachComponent } from '../../utils';
|
|
4
4
|
import dragula from 'dragula';
|
|
5
5
|
export default class DataGridComponent extends NestedArrayComponent {
|
|
6
6
|
static schema(...extend) {
|
|
@@ -34,9 +34,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
34
34
|
this.components = this.components || [];
|
|
35
35
|
// Add new values based on minLength.
|
|
36
36
|
this.rows = [];
|
|
37
|
-
this.columns = [
|
|
38
|
-
...this.component.components,
|
|
39
|
-
];
|
|
37
|
+
this.columns = [...this.component.components];
|
|
40
38
|
if (this.initRows || !_.isEqual(this.dataValue, this.emptyValue)) {
|
|
41
39
|
this.createRows(true);
|
|
42
40
|
}
|
|
@@ -64,11 +62,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
64
62
|
return this.builderMode || this.path === 'defaultValue' || !this.initEmpty;
|
|
65
63
|
}
|
|
66
64
|
get emptyValue() {
|
|
67
|
-
return this.initEmpty
|
|
68
|
-
? []
|
|
69
|
-
: [
|
|
70
|
-
{},
|
|
71
|
-
];
|
|
65
|
+
return this.initEmpty ? [] : [{}];
|
|
72
66
|
}
|
|
73
67
|
get addAnotherPosition() {
|
|
74
68
|
return _.get(this.component, 'addAnotherPosition', 'bottom');
|
|
@@ -86,11 +80,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
86
80
|
const isEmptyInit = this.initEmpty;
|
|
87
81
|
// Ensure we have one and only one row in builder mode.
|
|
88
82
|
if (isBuilderMode || (isEmptyInit && !this.dataValue.length)) {
|
|
89
|
-
return isEmptyInit && !isBuilderMode
|
|
90
|
-
? []
|
|
91
|
-
: [
|
|
92
|
-
{},
|
|
93
|
-
];
|
|
83
|
+
return isEmptyInit && !isBuilderMode ? [] : [{}];
|
|
94
84
|
}
|
|
95
85
|
const value = super.defaultValue;
|
|
96
86
|
let defaultValue;
|
|
@@ -98,9 +88,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
98
88
|
defaultValue = value;
|
|
99
89
|
}
|
|
100
90
|
else if (value && typeof value === 'object') {
|
|
101
|
-
defaultValue = [
|
|
102
|
-
value,
|
|
103
|
-
];
|
|
91
|
+
defaultValue = [value];
|
|
104
92
|
}
|
|
105
93
|
else {
|
|
106
94
|
defaultValue = this.emptyValue;
|
|
@@ -160,22 +148,10 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
160
148
|
* @returns {Array<T[]>} - The chunked rows
|
|
161
149
|
*/
|
|
162
150
|
getRowChunks(groups, rows) {
|
|
163
|
-
const [, chunks
|
|
151
|
+
const [, chunks] = groups.reduce(([startIndex, acc], size) => {
|
|
164
152
|
const endIndex = startIndex + size;
|
|
165
|
-
return [
|
|
166
|
-
|
|
167
|
-
[
|
|
168
|
-
...acc,
|
|
169
|
-
[
|
|
170
|
-
startIndex,
|
|
171
|
-
endIndex,
|
|
172
|
-
],
|
|
173
|
-
],
|
|
174
|
-
];
|
|
175
|
-
}, [
|
|
176
|
-
0,
|
|
177
|
-
[],
|
|
178
|
-
]);
|
|
153
|
+
return [endIndex, [...acc, [startIndex, endIndex]]];
|
|
154
|
+
}, [0, []]);
|
|
179
155
|
return chunks.map((range) => _.slice(rows, ...range));
|
|
180
156
|
}
|
|
181
157
|
/**
|
|
@@ -189,9 +165,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
189
165
|
const indexes = sizes.reduce((groupIndexes, size) => {
|
|
190
166
|
const last = groupIndexes[groupIndexes.length - 1];
|
|
191
167
|
return groupIndexes.concat(last + size);
|
|
192
|
-
}, [
|
|
193
|
-
0,
|
|
194
|
-
]);
|
|
168
|
+
}, [0]);
|
|
195
169
|
return groups.reduce((gidxs, group, idx) => {
|
|
196
170
|
return {
|
|
197
171
|
...gidxs,
|
|
@@ -227,18 +201,10 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
227
201
|
this.dataValue.length > _.get(this.component, 'validate.minLength', 0));
|
|
228
202
|
}
|
|
229
203
|
hasTopSubmit() {
|
|
230
|
-
return
|
|
231
|
-
[
|
|
232
|
-
'top',
|
|
233
|
-
'both',
|
|
234
|
-
].includes(this.addAnotherPosition));
|
|
204
|
+
return this.hasAddButton() && ['top', 'both'].includes(this.addAnotherPosition);
|
|
235
205
|
}
|
|
236
206
|
hasBottomSubmit() {
|
|
237
|
-
return
|
|
238
|
-
[
|
|
239
|
-
'bottom',
|
|
240
|
-
'both',
|
|
241
|
-
].includes(this.addAnotherPosition));
|
|
207
|
+
return this.hasAddButton() && ['bottom', 'both'].includes(this.addAnotherPosition);
|
|
242
208
|
}
|
|
243
209
|
get canAddColumn() {
|
|
244
210
|
return this.builderMode && !this.options.design;
|
|
@@ -315,9 +281,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
315
281
|
this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
|
|
316
282
|
row.dragInfo = { index };
|
|
317
283
|
});
|
|
318
|
-
this.dragula = dragula([
|
|
319
|
-
this.refs[`${this.datagridKey}-tbody`],
|
|
320
|
-
], {
|
|
284
|
+
this.dragula = dragula([this.refs[`${this.datagridKey}-tbody`]], {
|
|
321
285
|
moves: (_draggedElement, _oldParent, clickedElement) => {
|
|
322
286
|
const clickedElementKey = clickedElement.getAttribute('data-key');
|
|
323
287
|
const oldParentKey = _oldParent.getAttribute('data-key');
|
|
@@ -361,9 +325,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
361
325
|
this.rows.forEach((row, rowIndex) => {
|
|
362
326
|
let columnIndex = 0;
|
|
363
327
|
columns.forEach((col) => {
|
|
364
|
-
this.attachComponents(this.refs[this.datagridKey][rowIndex * rowLength + columnIndex], [
|
|
365
|
-
this.rows[rowIndex][col.key],
|
|
366
|
-
], this.getComponentsContainer());
|
|
328
|
+
this.attachComponents(this.refs[this.datagridKey][rowIndex * rowLength + columnIndex], [this.rows[rowIndex][col.key]], this.getComponentsContainer());
|
|
367
329
|
columnIndex++;
|
|
368
330
|
});
|
|
369
331
|
});
|
|
@@ -392,7 +354,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
392
354
|
}
|
|
393
355
|
onReorder(element, _target, _source, sibling) {
|
|
394
356
|
if (!element.dragInfo || (sibling && !sibling.dragInfo)) {
|
|
395
|
-
console.warn('
|
|
357
|
+
console.warn(this.t('noDragInfoError'));
|
|
396
358
|
return;
|
|
397
359
|
}
|
|
398
360
|
const oldPosition = element.dragInfo.index;
|
|
@@ -441,11 +403,11 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
441
403
|
component: this.component,
|
|
442
404
|
row,
|
|
443
405
|
});
|
|
444
|
-
screenReaderSpeech('Row has been added');
|
|
445
406
|
this.checkConditions();
|
|
446
407
|
this.triggerChange?.({ modified: true, noPristineChangeOnModified: true });
|
|
447
408
|
this.redraw().then(() => {
|
|
448
409
|
this.focusOnNewRowElement(this.rows[index]);
|
|
410
|
+
this.announce(this.t('Row has been added'));
|
|
449
411
|
});
|
|
450
412
|
}
|
|
451
413
|
updateComponentsRowIndex(components, rowIndex) {
|
|
@@ -484,18 +446,22 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
484
446
|
}
|
|
485
447
|
removeRow(index) {
|
|
486
448
|
const makeEmpty = index === 0 && this.rows.length === 1;
|
|
487
|
-
const flags = {
|
|
449
|
+
const flags = {
|
|
450
|
+
isReordered: !makeEmpty,
|
|
451
|
+
resetValue: makeEmpty,
|
|
452
|
+
modified: true,
|
|
453
|
+
noPristineChangeOnModified: true,
|
|
454
|
+
};
|
|
488
455
|
this.splice(index, flags);
|
|
489
456
|
this.emit('dataGridDeleteRow', { index });
|
|
490
|
-
|
|
491
|
-
screenReaderSpeech('Row has been deleted');
|
|
492
|
-
}
|
|
493
|
-
const [row,] = this.rows.splice(index, 1);
|
|
457
|
+
const [row] = this.rows.splice(index, 1);
|
|
494
458
|
this.removeSubmissionMetadataRow(index);
|
|
495
459
|
this.removeRowComponents(row);
|
|
496
460
|
this.updateRowsComponents(index);
|
|
497
461
|
this.setValue(this.dataValue, flags);
|
|
498
|
-
this.redraw()
|
|
462
|
+
this.redraw().then(() => {
|
|
463
|
+
this.announce(this.t('Row has been deleted'));
|
|
464
|
+
});
|
|
499
465
|
}
|
|
500
466
|
removeRowComponents(row) {
|
|
501
467
|
_.each(row, (component) => this.removeComponent(component));
|
|
@@ -610,10 +576,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
610
576
|
!!visibility[key] ||
|
|
611
577
|
(col.checkConditions(data, flags, dataValue[rowIndex]) && col.type !== 'hidden');
|
|
612
578
|
if (col.component.logic && firstRowCheck) {
|
|
613
|
-
const compIndex = _.findIndex(this.columns, [
|
|
614
|
-
'key',
|
|
615
|
-
key,
|
|
616
|
-
]);
|
|
579
|
+
const compIndex = _.findIndex(this.columns, ['key', key]);
|
|
617
580
|
const equalColumns = _.isEqualWith(this.columns[compIndex], col.component, (col1, col2, key) => {
|
|
618
581
|
// Don't compare columns by their auto-generated ids.
|
|
619
582
|
if (key === 'id') {
|
|
@@ -657,15 +620,11 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
657
620
|
}
|
|
658
621
|
if (!Array.isArray(value)) {
|
|
659
622
|
if (typeof value === 'object') {
|
|
660
|
-
value = [
|
|
661
|
-
value,
|
|
662
|
-
];
|
|
623
|
+
value = [value];
|
|
663
624
|
}
|
|
664
625
|
else {
|
|
665
626
|
this.createRows();
|
|
666
|
-
value = [
|
|
667
|
-
{},
|
|
668
|
-
];
|
|
627
|
+
value = [{}];
|
|
669
628
|
}
|
|
670
629
|
}
|
|
671
630
|
// Make sure we always have at least one row.
|
|
@@ -45,9 +45,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
|
45
45
|
return _.omit(schema, 'components');
|
|
46
46
|
}
|
|
47
47
|
static savedValueTypes(schema) {
|
|
48
|
-
return
|
|
49
|
-
componentValueTypes.object,
|
|
50
|
-
]);
|
|
48
|
+
return getComponentSavedTypes(schema) || [componentValueTypes.object];
|
|
51
49
|
}
|
|
52
50
|
constructor(component, options, data) {
|
|
53
51
|
super(component, options, data);
|
|
@@ -101,9 +99,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
|
101
99
|
getRowValues() {
|
|
102
100
|
const dataValue = this.dataValue;
|
|
103
101
|
if (this.builderMode) {
|
|
104
|
-
return [
|
|
105
|
-
dataValue,
|
|
106
|
-
];
|
|
102
|
+
return [dataValue];
|
|
107
103
|
}
|
|
108
104
|
if (_.isEmpty(dataValue)) {
|
|
109
105
|
return [];
|
|
@@ -120,7 +116,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
|
120
116
|
return this.rows.map((row) => {
|
|
121
117
|
return {
|
|
122
118
|
components: row,
|
|
123
|
-
data: _.mapValues(row, (comp) => comp.dataValue)
|
|
119
|
+
data: _.mapValues(row, (comp) => comp.dataValue),
|
|
124
120
|
};
|
|
125
121
|
});
|
|
126
122
|
}
|
|
@@ -141,15 +137,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
|
141
137
|
const valueSchema = Object.assign({}, this.component.valueComponent);
|
|
142
138
|
keySchema.hideLabel = false;
|
|
143
139
|
valueSchema.hideLabel = false;
|
|
144
|
-
return this.component.keyBeforeValue
|
|
145
|
-
? [
|
|
146
|
-
keySchema,
|
|
147
|
-
valueSchema,
|
|
148
|
-
]
|
|
149
|
-
: [
|
|
150
|
-
valueSchema,
|
|
151
|
-
keySchema,
|
|
152
|
-
];
|
|
140
|
+
return this.component.keyBeforeValue ? [keySchema, valueSchema] : [valueSchema, keySchema];
|
|
153
141
|
}
|
|
154
142
|
getRowKey(rowIndex) {
|
|
155
143
|
const keys = Object.keys(this.dataValue);
|
|
@@ -273,13 +261,19 @@ export default class DataMapComponent extends DataGridComponent {
|
|
|
273
261
|
if (this.submissionTimezone) {
|
|
274
262
|
componentOptions.submissionTimezone = this.submissionTimezone;
|
|
275
263
|
if (valueComponent.type === 'datetime') {
|
|
276
|
-
valueComponent.widget = {
|
|
264
|
+
valueComponent.widget = {
|
|
265
|
+
...valueComponent.widget,
|
|
266
|
+
submissionTimezone: this.submissionTimezone,
|
|
267
|
+
};
|
|
277
268
|
}
|
|
278
269
|
}
|
|
279
270
|
const createdComponent = this.createComponent(valueComponent, componentOptions, this.dataValue);
|
|
280
271
|
// Ensure submissionTimezone is set on datetime component instance's widget and options
|
|
281
272
|
if (createdComponent?.type === 'datetime' && this.submissionTimezone) {
|
|
282
|
-
createdComponent.component.widget = {
|
|
273
|
+
createdComponent.component.widget = {
|
|
274
|
+
...createdComponent.component.widget,
|
|
275
|
+
submissionTimezone: this.submissionTimezone,
|
|
276
|
+
};
|
|
283
277
|
createdComponent.options.submissionTimezone = this.submissionTimezone;
|
|
284
278
|
}
|
|
285
279
|
components[this.valueKey] = createdComponent;
|
|
@@ -77,9 +77,7 @@ export default class DateTimeComponent extends Input {
|
|
|
77
77
|
}
|
|
78
78
|
static savedValueTypes(schema) {
|
|
79
79
|
schema = schema || {};
|
|
80
|
-
return
|
|
81
|
-
componentValueTypes.date,
|
|
82
|
-
]);
|
|
80
|
+
return getComponentSavedTypes(schema) || [componentValueTypes.date];
|
|
83
81
|
}
|
|
84
82
|
constructor(component, options, data) {
|
|
85
83
|
super(component, options, data);
|
|
@@ -201,9 +199,7 @@ export default class DateTimeComponent extends Input {
|
|
|
201
199
|
let format = FormioUtils.convertFormatToMoment(this.component.format);
|
|
202
200
|
format += format.match(/z$/) ? '' : ' z';
|
|
203
201
|
const timezone = this.timezone;
|
|
204
|
-
const useTimezoneAwareFormat = value &&
|
|
205
|
-
timezone &&
|
|
206
|
-
(this.options.pdf || options?.email);
|
|
202
|
+
const useTimezoneAwareFormat = value && timezone && (this.options.pdf || options?.email);
|
|
207
203
|
if (useTimezoneAwareFormat) {
|
|
208
204
|
if (Array.isArray(value) && this.component.multiple) {
|
|
209
205
|
return value
|
|
@@ -57,9 +57,7 @@ export default class DayComponent extends Field {
|
|
|
57
57
|
}
|
|
58
58
|
static savedValueTypes(schema) {
|
|
59
59
|
schema = schema || {};
|
|
60
|
-
return
|
|
61
|
-
componentValueTypes.string,
|
|
62
|
-
]);
|
|
60
|
+
return getComponentSavedTypes(schema) || [componentValueTypes.string];
|
|
63
61
|
}
|
|
64
62
|
// Empty value used before 9.3.x
|
|
65
63
|
static oldEmptyValue = '00/00/0000';
|
|
@@ -166,9 +164,7 @@ export default class DayComponent extends Field {
|
|
|
166
164
|
};
|
|
167
165
|
}
|
|
168
166
|
get days() {
|
|
169
|
-
const days = [
|
|
170
|
-
{ value: '', label: _.get(this.component, 'fields.day.placeholder', '') },
|
|
171
|
-
];
|
|
167
|
+
const days = [{ value: '', label: _.get(this.component, 'fields.day.placeholder', '') }];
|
|
172
168
|
for (let x = 1; x <= 31; x++) {
|
|
173
169
|
days.push({
|
|
174
170
|
value: x,
|
|
@@ -182,7 +178,7 @@ export default class DayComponent extends Field {
|
|
|
182
178
|
{
|
|
183
179
|
value: '',
|
|
184
180
|
label: _.get(this.component, 'fields.month.placeholder') ||
|
|
185
|
-
(this.hideInputLabels ? this.t('
|
|
181
|
+
(this.hideInputLabels ? this.t('month') : ''),
|
|
186
182
|
},
|
|
187
183
|
{ value: 1, label: 'January' },
|
|
188
184
|
{ value: 2, label: 'February' },
|
|
@@ -200,9 +196,7 @@ export default class DayComponent extends Field {
|
|
|
200
196
|
return months;
|
|
201
197
|
}
|
|
202
198
|
get years() {
|
|
203
|
-
const years = [
|
|
204
|
-
{ value: '', label: _.get(this.component, 'fields.year.placeholder', '') },
|
|
205
|
-
];
|
|
199
|
+
const years = [{ value: '', label: _.get(this.component, 'fields.year.placeholder', '') }];
|
|
206
200
|
const minYears = _.get(this.component, 'fields.year.minYear', 1900) || 1900;
|
|
207
201
|
const maxYears = _.get(this.component, 'fields.year.maxYear', 2030) || 2030;
|
|
208
202
|
for (let x = minYears; x <= maxYears; x++) {
|
|
@@ -215,18 +209,10 @@ export default class DayComponent extends Field {
|
|
|
215
209
|
}
|
|
216
210
|
setErrorClasses(elements, dirty, hasError) {
|
|
217
211
|
super.setErrorClasses(elements, dirty, hasError);
|
|
218
|
-
super.setErrorClasses([
|
|
219
|
-
this.refs.day,
|
|
220
|
-
this.refs.month,
|
|
221
|
-
this.refs.year,
|
|
222
|
-
], dirty, hasError);
|
|
212
|
+
super.setErrorClasses([this.refs.day, this.refs.month, this.refs.year], dirty, hasError);
|
|
223
213
|
}
|
|
224
214
|
removeInputError(elements) {
|
|
225
|
-
super.removeInputError([
|
|
226
|
-
this.refs.day,
|
|
227
|
-
this.refs.month,
|
|
228
|
-
this.refs.year,
|
|
229
|
-
]);
|
|
215
|
+
super.removeInputError([this.refs.day, this.refs.month, this.refs.year]);
|
|
230
216
|
super.removeInputError(elements);
|
|
231
217
|
}
|
|
232
218
|
init() {
|
|
@@ -282,7 +268,7 @@ export default class DayComponent extends Field {
|
|
|
282
268
|
this.saveCaretPosition(element, name);
|
|
283
269
|
}
|
|
284
270
|
catch (err) {
|
|
285
|
-
console.warn('
|
|
271
|
+
console.warn(this.t('caretPositionSavingError'), err);
|
|
286
272
|
}
|
|
287
273
|
this.updateValue(null, {
|
|
288
274
|
modified: true,
|
|
@@ -317,11 +303,7 @@ export default class DayComponent extends Field {
|
|
|
317
303
|
this.addEventListener(this.refs.input, this.info.changeEvent, () => this.updateValue(null, {
|
|
318
304
|
modified: true,
|
|
319
305
|
}));
|
|
320
|
-
[
|
|
321
|
-
this.refs.day,
|
|
322
|
-
this.refs.month,
|
|
323
|
-
this.refs.year,
|
|
324
|
-
]
|
|
306
|
+
[this.refs.day, this.refs.month, this.refs.year]
|
|
325
307
|
.filter((element) => !!element)
|
|
326
308
|
.forEach((element) => {
|
|
327
309
|
super.addFocusBlurEvents(element);
|
|
@@ -374,17 +356,7 @@ export default class DayComponent extends Field {
|
|
|
374
356
|
}
|
|
375
357
|
const dateParts = [];
|
|
376
358
|
const valueParts = value.split('/');
|
|
377
|
-
const [DAY, MONTH, YEAR
|
|
378
|
-
? [
|
|
379
|
-
0,
|
|
380
|
-
1,
|
|
381
|
-
2,
|
|
382
|
-
]
|
|
383
|
-
: [
|
|
384
|
-
1,
|
|
385
|
-
0,
|
|
386
|
-
2,
|
|
387
|
-
];
|
|
359
|
+
const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
388
360
|
const defaultValue = this.component.defaultValue ? this.component.defaultValue.split('/') : '';
|
|
389
361
|
let defaultDay = '';
|
|
390
362
|
let defaultMonth = '';
|
|
@@ -461,17 +433,7 @@ export default class DayComponent extends Field {
|
|
|
461
433
|
}
|
|
462
434
|
}
|
|
463
435
|
getDayWithHiddenFields(parts) {
|
|
464
|
-
let [DAY, MONTH, YEAR
|
|
465
|
-
? [
|
|
466
|
-
0,
|
|
467
|
-
1,
|
|
468
|
-
2,
|
|
469
|
-
]
|
|
470
|
-
: [
|
|
471
|
-
1,
|
|
472
|
-
0,
|
|
473
|
-
2,
|
|
474
|
-
];
|
|
436
|
+
let [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
475
437
|
if (!this.showDay) {
|
|
476
438
|
MONTH = MONTH === 0 ? 0 : MONTH - 1;
|
|
477
439
|
YEAR = YEAR - 1;
|
|
@@ -532,17 +494,7 @@ export default class DayComponent extends Field {
|
|
|
532
494
|
getDate(value) {
|
|
533
495
|
let defaults = [], day, month, year;
|
|
534
496
|
// Map positions to identifiers to get default values for each part of day
|
|
535
|
-
const [DAY, MONTH, YEAR
|
|
536
|
-
? [
|
|
537
|
-
0,
|
|
538
|
-
1,
|
|
539
|
-
2,
|
|
540
|
-
]
|
|
541
|
-
: [
|
|
542
|
-
1,
|
|
543
|
-
0,
|
|
544
|
-
2,
|
|
545
|
-
];
|
|
497
|
+
const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
546
498
|
const defaultValue = value || this.component.defaultValue;
|
|
547
499
|
if (defaultValue) {
|
|
548
500
|
defaults = defaultValue.split('/').map((x) => parseInt(x, 10));
|
|
@@ -686,17 +638,7 @@ export default class DayComponent extends Field {
|
|
|
686
638
|
if (!value) {
|
|
687
639
|
return true;
|
|
688
640
|
}
|
|
689
|
-
const [DAY, MONTH, YEAR
|
|
690
|
-
? [
|
|
691
|
-
0,
|
|
692
|
-
1,
|
|
693
|
-
2,
|
|
694
|
-
]
|
|
695
|
-
: [
|
|
696
|
-
1,
|
|
697
|
-
0,
|
|
698
|
-
2,
|
|
699
|
-
];
|
|
641
|
+
const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
700
642
|
const values = value.split('/');
|
|
701
643
|
if (values.length < 3) {
|
|
702
644
|
return true;
|
|
@@ -38,9 +38,7 @@ export default [
|
|
|
38
38
|
if (data.defaultValue) {
|
|
39
39
|
const defaultValueParts = data.defaultValue.split('/');
|
|
40
40
|
if (!data.fields.day.hide && defaultValueParts.length !== 3) {
|
|
41
|
-
const newDefaultValue = [
|
|
42
|
-
'00',
|
|
43
|
-
];
|
|
41
|
+
const newDefaultValue = ['00'];
|
|
44
42
|
if (!data.fields.month.hide) {
|
|
45
43
|
data.dayFirst
|
|
46
44
|
? newDefaultValue.push(defaultValueParts[0])
|
|
@@ -38,9 +38,7 @@ export default [
|
|
|
38
38
|
if (data.defaultValue) {
|
|
39
39
|
const defaultValueParts = data.defaultValue.split('/');
|
|
40
40
|
if (!data.fields.month.hide && defaultValueParts.length !== 3) {
|
|
41
|
-
const newDefaultValue = [
|
|
42
|
-
'00',
|
|
43
|
-
];
|
|
41
|
+
const newDefaultValue = ['00'];
|
|
44
42
|
if (!data.fields.day.hide) {
|
|
45
43
|
data.dayFirst
|
|
46
44
|
? newDefaultValue.unshift(defaultValueParts[0])
|
|
@@ -42,6 +42,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
42
42
|
get iteratableRows(): any;
|
|
43
43
|
get defaultValue(): any[];
|
|
44
44
|
hasRemoveButtons(): boolean;
|
|
45
|
+
checkData(data: any, flags: any, row: any): Promise<void> | undefined;
|
|
45
46
|
editRows: any;
|
|
46
47
|
checkRowVariableTypeComponents(editRow: any, rowIndex: any): void;
|
|
47
48
|
setVariableTypeComponents(): void;
|