@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
|
@@ -33,9 +33,7 @@ class CheckBoxComponent extends Field_1.default {
|
|
|
33
33
|
return CheckBoxComponent.conditionOperatorsSettings;
|
|
34
34
|
}
|
|
35
35
|
static get conditionOperatorsSettings() {
|
|
36
|
-
return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: [
|
|
37
|
-
'isEqual',
|
|
38
|
-
], valueComponent() {
|
|
36
|
+
return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: ['isEqual'], valueComponent() {
|
|
39
37
|
return {
|
|
40
38
|
valueType: 'boolean',
|
|
41
39
|
data: {
|
|
@@ -55,13 +53,9 @@ class CheckBoxComponent extends Field_1.default {
|
|
|
55
53
|
return types;
|
|
56
54
|
}
|
|
57
55
|
if (schema.inputType === 'radio') {
|
|
58
|
-
return [
|
|
59
|
-
utils_1.componentValueTypes.string,
|
|
60
|
-
];
|
|
56
|
+
return [utils_1.componentValueTypes.string];
|
|
61
57
|
}
|
|
62
|
-
return [
|
|
63
|
-
utils_1.componentValueTypes.boolean,
|
|
64
|
-
];
|
|
58
|
+
return [utils_1.componentValueTypes.boolean];
|
|
65
59
|
}
|
|
66
60
|
get defaultSchema() {
|
|
67
61
|
return CheckBoxComponent.schema();
|
|
@@ -196,7 +190,7 @@ class CheckBoxComponent extends Field_1.default {
|
|
|
196
190
|
if (lodash_1.default.isUndefined(value) && this.inDataTable) {
|
|
197
191
|
return '';
|
|
198
192
|
}
|
|
199
|
-
return this.t(hasValue ? '
|
|
193
|
+
return this.t(hasValue ? 'yes' : 'no');
|
|
200
194
|
}
|
|
201
195
|
updateValue(value, flags) {
|
|
202
196
|
// If this is a radio and is alredy checked, uncheck it.
|
|
@@ -63,10 +63,7 @@ exports.default = [
|
|
|
63
63
|
weight: 420,
|
|
64
64
|
conditional: {
|
|
65
65
|
json: {
|
|
66
|
-
'===': [
|
|
67
|
-
{ var: 'data.inputType' },
|
|
68
|
-
'radio',
|
|
69
|
-
],
|
|
66
|
+
'===': [{ var: 'data.inputType' }, 'radio'],
|
|
70
67
|
},
|
|
71
68
|
},
|
|
72
69
|
},
|
|
@@ -79,10 +76,7 @@ exports.default = [
|
|
|
79
76
|
weight: 430,
|
|
80
77
|
conditional: {
|
|
81
78
|
json: {
|
|
82
|
-
'===': [
|
|
83
|
-
{ var: 'data.inputType' },
|
|
84
|
-
'radio',
|
|
85
|
-
],
|
|
79
|
+
'===': [{ var: 'data.inputType' }, 'radio'],
|
|
86
80
|
},
|
|
87
81
|
},
|
|
88
82
|
},
|
|
@@ -42,9 +42,7 @@ class ColumnsComponent extends NestedComponent_1.default {
|
|
|
42
42
|
}
|
|
43
43
|
get schema() {
|
|
44
44
|
var _a;
|
|
45
|
-
const schema = lodash_1.default.omit(super.schema, [
|
|
46
|
-
'components',
|
|
47
|
-
]);
|
|
45
|
+
const schema = lodash_1.default.omit(super.schema, ['components']);
|
|
48
46
|
(_a = schema.columns) === null || _a === void 0 ? void 0 : _a.map((column, colIndex) => {
|
|
49
47
|
column.components.map((comp, compIndex) => {
|
|
50
48
|
const clonedComp = lodash_1.default.clone(comp);
|
|
@@ -128,28 +126,18 @@ class ColumnsComponent extends NestedComponent_1.default {
|
|
|
128
126
|
const initVal = { stack: [], rows: [] };
|
|
129
127
|
const width = (x) => x.component.width;
|
|
130
128
|
const result = lodash_1.default.reduce(this.components, (acc, next) => {
|
|
131
|
-
const stack = [
|
|
132
|
-
...acc.stack,
|
|
133
|
-
next,
|
|
134
|
-
];
|
|
129
|
+
const stack = [...acc.stack, next];
|
|
135
130
|
if (lodash_1.default.sumBy(stack, width) <= this.gridSize) {
|
|
136
131
|
acc.stack = stack;
|
|
137
132
|
return acc;
|
|
138
133
|
}
|
|
139
134
|
else {
|
|
140
|
-
acc.rows = [
|
|
141
|
-
|
|
142
|
-
acc.stack,
|
|
143
|
-
];
|
|
144
|
-
acc.stack = [
|
|
145
|
-
next,
|
|
146
|
-
];
|
|
135
|
+
acc.rows = [...acc.rows, acc.stack];
|
|
136
|
+
acc.stack = [next];
|
|
147
137
|
return acc;
|
|
148
138
|
}
|
|
149
139
|
}, initVal);
|
|
150
|
-
return lodash_1.default.concat(result.rows, [
|
|
151
|
-
result.stack,
|
|
152
|
-
]);
|
|
140
|
+
return lodash_1.default.concat(result.rows, [result.stack]);
|
|
153
141
|
}
|
|
154
142
|
checkData(data, flags, row, components) {
|
|
155
143
|
super.checkData(data, flags, row, components);
|
|
@@ -37,9 +37,7 @@ class ContainerComponent extends NestedDataComponent_1.default {
|
|
|
37
37
|
this.type = 'container';
|
|
38
38
|
}
|
|
39
39
|
static savedValueTypes(schema) {
|
|
40
|
-
return (
|
|
41
|
-
utils_1.componentValueTypes.object,
|
|
42
|
-
]);
|
|
40
|
+
return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.object];
|
|
43
41
|
}
|
|
44
42
|
addComponents(data, options) {
|
|
45
43
|
return super.addComponents(this.dataValue, options);
|
|
@@ -109,13 +109,8 @@ class CurrencyComponent extends Number_1.default {
|
|
|
109
109
|
const isNegative = value.includes(negativeValueSymbol) || false;
|
|
110
110
|
value = this.stripPrefixSuffix(isNegative ? value.replace(negativeValueSymbol, '') : value);
|
|
111
111
|
if (value.includes(this.decimalSeparator)) {
|
|
112
|
-
[
|
|
113
|
-
|
|
114
|
-
decimalPart,
|
|
115
|
-
] = value.split(this.decimalSeparator);
|
|
116
|
-
decimalPartNumbers = [
|
|
117
|
-
...decimalPart.split(''),
|
|
118
|
-
];
|
|
112
|
+
[integerPart, decimalPart] = value.split(this.decimalSeparator);
|
|
113
|
+
decimalPartNumbers = [...decimalPart.split('')];
|
|
119
114
|
}
|
|
120
115
|
else {
|
|
121
116
|
integerPart = value;
|
|
@@ -39,9 +39,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
39
39
|
this.components = this.components || [];
|
|
40
40
|
// Add new values based on minLength.
|
|
41
41
|
this.rows = [];
|
|
42
|
-
this.columns = [
|
|
43
|
-
...this.component.components,
|
|
44
|
-
];
|
|
42
|
+
this.columns = [...this.component.components];
|
|
45
43
|
if (this.initRows || !lodash_1.default.isEqual(this.dataValue, this.emptyValue)) {
|
|
46
44
|
this.createRows(true);
|
|
47
45
|
}
|
|
@@ -69,11 +67,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
69
67
|
return this.builderMode || this.path === 'defaultValue' || !this.initEmpty;
|
|
70
68
|
}
|
|
71
69
|
get emptyValue() {
|
|
72
|
-
return this.initEmpty
|
|
73
|
-
? []
|
|
74
|
-
: [
|
|
75
|
-
{},
|
|
76
|
-
];
|
|
70
|
+
return this.initEmpty ? [] : [{}];
|
|
77
71
|
}
|
|
78
72
|
get addAnotherPosition() {
|
|
79
73
|
return lodash_1.default.get(this.component, 'addAnotherPosition', 'bottom');
|
|
@@ -91,11 +85,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
91
85
|
const isEmptyInit = this.initEmpty;
|
|
92
86
|
// Ensure we have one and only one row in builder mode.
|
|
93
87
|
if (isBuilderMode || (isEmptyInit && !this.dataValue.length)) {
|
|
94
|
-
return isEmptyInit && !isBuilderMode
|
|
95
|
-
? []
|
|
96
|
-
: [
|
|
97
|
-
{},
|
|
98
|
-
];
|
|
88
|
+
return isEmptyInit && !isBuilderMode ? [] : [{}];
|
|
99
89
|
}
|
|
100
90
|
const value = super.defaultValue;
|
|
101
91
|
let defaultValue;
|
|
@@ -103,9 +93,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
103
93
|
defaultValue = value;
|
|
104
94
|
}
|
|
105
95
|
else if (value && typeof value === 'object') {
|
|
106
|
-
defaultValue = [
|
|
107
|
-
value,
|
|
108
|
-
];
|
|
96
|
+
defaultValue = [value];
|
|
109
97
|
}
|
|
110
98
|
else {
|
|
111
99
|
defaultValue = this.emptyValue;
|
|
@@ -167,22 +155,10 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
167
155
|
* @returns {Array<T[]>} - The chunked rows
|
|
168
156
|
*/
|
|
169
157
|
getRowChunks(groups, rows) {
|
|
170
|
-
const [, chunks
|
|
158
|
+
const [, chunks] = groups.reduce(([startIndex, acc], size) => {
|
|
171
159
|
const endIndex = startIndex + size;
|
|
172
|
-
return [
|
|
173
|
-
|
|
174
|
-
[
|
|
175
|
-
...acc,
|
|
176
|
-
[
|
|
177
|
-
startIndex,
|
|
178
|
-
endIndex,
|
|
179
|
-
],
|
|
180
|
-
],
|
|
181
|
-
];
|
|
182
|
-
}, [
|
|
183
|
-
0,
|
|
184
|
-
[],
|
|
185
|
-
]);
|
|
160
|
+
return [endIndex, [...acc, [startIndex, endIndex]]];
|
|
161
|
+
}, [0, []]);
|
|
186
162
|
return chunks.map((range) => lodash_1.default.slice(rows, ...range));
|
|
187
163
|
}
|
|
188
164
|
/**
|
|
@@ -196,9 +172,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
196
172
|
const indexes = sizes.reduce((groupIndexes, size) => {
|
|
197
173
|
const last = groupIndexes[groupIndexes.length - 1];
|
|
198
174
|
return groupIndexes.concat(last + size);
|
|
199
|
-
}, [
|
|
200
|
-
0,
|
|
201
|
-
]);
|
|
175
|
+
}, [0]);
|
|
202
176
|
return groups.reduce((gidxs, group, idx) => {
|
|
203
177
|
return Object.assign(Object.assign({}, gidxs), { [indexes[idx]]: group });
|
|
204
178
|
}, {});
|
|
@@ -231,18 +205,10 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
231
205
|
this.dataValue.length > lodash_1.default.get(this.component, 'validate.minLength', 0));
|
|
232
206
|
}
|
|
233
207
|
hasTopSubmit() {
|
|
234
|
-
return
|
|
235
|
-
[
|
|
236
|
-
'top',
|
|
237
|
-
'both',
|
|
238
|
-
].includes(this.addAnotherPosition));
|
|
208
|
+
return this.hasAddButton() && ['top', 'both'].includes(this.addAnotherPosition);
|
|
239
209
|
}
|
|
240
210
|
hasBottomSubmit() {
|
|
241
|
-
return
|
|
242
|
-
[
|
|
243
|
-
'bottom',
|
|
244
|
-
'both',
|
|
245
|
-
].includes(this.addAnotherPosition));
|
|
211
|
+
return this.hasAddButton() && ['bottom', 'both'].includes(this.addAnotherPosition);
|
|
246
212
|
}
|
|
247
213
|
get canAddColumn() {
|
|
248
214
|
return this.builderMode && !this.options.design;
|
|
@@ -319,9 +285,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
319
285
|
this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
|
|
320
286
|
row.dragInfo = { index };
|
|
321
287
|
});
|
|
322
|
-
this.dragula = (0, dragula_1.default)([
|
|
323
|
-
this.refs[`${this.datagridKey}-tbody`],
|
|
324
|
-
], {
|
|
288
|
+
this.dragula = (0, dragula_1.default)([this.refs[`${this.datagridKey}-tbody`]], {
|
|
325
289
|
moves: (_draggedElement, _oldParent, clickedElement) => {
|
|
326
290
|
const clickedElementKey = clickedElement.getAttribute('data-key');
|
|
327
291
|
const oldParentKey = _oldParent.getAttribute('data-key');
|
|
@@ -365,9 +329,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
365
329
|
this.rows.forEach((row, rowIndex) => {
|
|
366
330
|
let columnIndex = 0;
|
|
367
331
|
columns.forEach((col) => {
|
|
368
|
-
this.attachComponents(this.refs[this.datagridKey][rowIndex * rowLength + columnIndex], [
|
|
369
|
-
this.rows[rowIndex][col.key],
|
|
370
|
-
], this.getComponentsContainer());
|
|
332
|
+
this.attachComponents(this.refs[this.datagridKey][rowIndex * rowLength + columnIndex], [this.rows[rowIndex][col.key]], this.getComponentsContainer());
|
|
371
333
|
columnIndex++;
|
|
372
334
|
});
|
|
373
335
|
});
|
|
@@ -396,7 +358,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
396
358
|
}
|
|
397
359
|
onReorder(element, _target, _source, sibling) {
|
|
398
360
|
if (!element.dragInfo || (sibling && !sibling.dragInfo)) {
|
|
399
|
-
console.warn('
|
|
361
|
+
console.warn(this.t('noDragInfoError'));
|
|
400
362
|
return;
|
|
401
363
|
}
|
|
402
364
|
const oldPosition = element.dragInfo.index;
|
|
@@ -446,11 +408,11 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
446
408
|
component: this.component,
|
|
447
409
|
row,
|
|
448
410
|
});
|
|
449
|
-
(0, utils_1.screenReaderSpeech)('Row has been added');
|
|
450
411
|
this.checkConditions();
|
|
451
412
|
(_a = this.triggerChange) === null || _a === void 0 ? void 0 : _a.call(this, { modified: true, noPristineChangeOnModified: true });
|
|
452
413
|
this.redraw().then(() => {
|
|
453
414
|
this.focusOnNewRowElement(this.rows[index]);
|
|
415
|
+
this.announce(this.t('Row has been added'));
|
|
454
416
|
});
|
|
455
417
|
}
|
|
456
418
|
updateComponentsRowIndex(components, rowIndex) {
|
|
@@ -490,18 +452,22 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
490
452
|
}
|
|
491
453
|
removeRow(index) {
|
|
492
454
|
const makeEmpty = index === 0 && this.rows.length === 1;
|
|
493
|
-
const flags = {
|
|
455
|
+
const flags = {
|
|
456
|
+
isReordered: !makeEmpty,
|
|
457
|
+
resetValue: makeEmpty,
|
|
458
|
+
modified: true,
|
|
459
|
+
noPristineChangeOnModified: true,
|
|
460
|
+
};
|
|
494
461
|
this.splice(index, flags);
|
|
495
462
|
this.emit('dataGridDeleteRow', { index });
|
|
496
|
-
|
|
497
|
-
(0, utils_1.screenReaderSpeech)('Row has been deleted');
|
|
498
|
-
}
|
|
499
|
-
const [row,] = this.rows.splice(index, 1);
|
|
463
|
+
const [row] = this.rows.splice(index, 1);
|
|
500
464
|
this.removeSubmissionMetadataRow(index);
|
|
501
465
|
this.removeRowComponents(row);
|
|
502
466
|
this.updateRowsComponents(index);
|
|
503
467
|
this.setValue(this.dataValue, flags);
|
|
504
|
-
this.redraw()
|
|
468
|
+
this.redraw().then(() => {
|
|
469
|
+
this.announce(this.t('Row has been deleted'));
|
|
470
|
+
});
|
|
505
471
|
}
|
|
506
472
|
removeRowComponents(row) {
|
|
507
473
|
lodash_1.default.each(row, (component) => this.removeComponent(component));
|
|
@@ -614,10 +580,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
614
580
|
!!visibility[key] ||
|
|
615
581
|
(col.checkConditions(data, flags, dataValue[rowIndex]) && col.type !== 'hidden');
|
|
616
582
|
if (col.component.logic && firstRowCheck) {
|
|
617
|
-
const compIndex = lodash_1.default.findIndex(this.columns, [
|
|
618
|
-
'key',
|
|
619
|
-
key,
|
|
620
|
-
]);
|
|
583
|
+
const compIndex = lodash_1.default.findIndex(this.columns, ['key', key]);
|
|
621
584
|
const equalColumns = lodash_1.default.isEqualWith(this.columns[compIndex], col.component, (col1, col2, key) => {
|
|
622
585
|
// Don't compare columns by their auto-generated ids.
|
|
623
586
|
if (key === 'id') {
|
|
@@ -661,15 +624,11 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
661
624
|
}
|
|
662
625
|
if (!Array.isArray(value)) {
|
|
663
626
|
if (typeof value === 'object') {
|
|
664
|
-
value = [
|
|
665
|
-
value,
|
|
666
|
-
];
|
|
627
|
+
value = [value];
|
|
667
628
|
}
|
|
668
629
|
else {
|
|
669
630
|
this.createRows();
|
|
670
|
-
value = [
|
|
671
|
-
{},
|
|
672
|
-
];
|
|
631
|
+
value = [{}];
|
|
673
632
|
}
|
|
674
633
|
}
|
|
675
634
|
// Make sure we always have at least one row.
|
|
@@ -50,9 +50,7 @@ class DataMapComponent extends DataGrid_1.default {
|
|
|
50
50
|
return lodash_1.default.omit(schema, 'components');
|
|
51
51
|
}
|
|
52
52
|
static savedValueTypes(schema) {
|
|
53
|
-
return (
|
|
54
|
-
utils_1.componentValueTypes.object,
|
|
55
|
-
]);
|
|
53
|
+
return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.object];
|
|
56
54
|
}
|
|
57
55
|
constructor(component, options, data) {
|
|
58
56
|
super(component, options, data);
|
|
@@ -106,9 +104,7 @@ class DataMapComponent extends DataGrid_1.default {
|
|
|
106
104
|
getRowValues() {
|
|
107
105
|
const dataValue = this.dataValue;
|
|
108
106
|
if (this.builderMode) {
|
|
109
|
-
return [
|
|
110
|
-
dataValue,
|
|
111
|
-
];
|
|
107
|
+
return [dataValue];
|
|
112
108
|
}
|
|
113
109
|
if (lodash_1.default.isEmpty(dataValue)) {
|
|
114
110
|
return [];
|
|
@@ -125,7 +121,7 @@ class DataMapComponent extends DataGrid_1.default {
|
|
|
125
121
|
return this.rows.map((row) => {
|
|
126
122
|
return {
|
|
127
123
|
components: row,
|
|
128
|
-
data: lodash_1.default.mapValues(row, (comp) => comp.dataValue)
|
|
124
|
+
data: lodash_1.default.mapValues(row, (comp) => comp.dataValue),
|
|
129
125
|
};
|
|
130
126
|
});
|
|
131
127
|
}
|
|
@@ -146,15 +142,7 @@ class DataMapComponent extends DataGrid_1.default {
|
|
|
146
142
|
const valueSchema = Object.assign({}, this.component.valueComponent);
|
|
147
143
|
keySchema.hideLabel = false;
|
|
148
144
|
valueSchema.hideLabel = false;
|
|
149
|
-
return this.component.keyBeforeValue
|
|
150
|
-
? [
|
|
151
|
-
keySchema,
|
|
152
|
-
valueSchema,
|
|
153
|
-
]
|
|
154
|
-
: [
|
|
155
|
-
valueSchema,
|
|
156
|
-
keySchema,
|
|
157
|
-
];
|
|
145
|
+
return this.component.keyBeforeValue ? [keySchema, valueSchema] : [valueSchema, keySchema];
|
|
158
146
|
}
|
|
159
147
|
getRowKey(rowIndex) {
|
|
160
148
|
const keys = Object.keys(this.dataValue);
|
|
@@ -75,9 +75,7 @@ class DateTimeComponent extends Input_1.default {
|
|
|
75
75
|
}
|
|
76
76
|
static savedValueTypes(schema) {
|
|
77
77
|
schema = schema || {};
|
|
78
|
-
return (
|
|
79
|
-
utils_2.componentValueTypes.date,
|
|
80
|
-
]);
|
|
78
|
+
return (0, utils_2.getComponentSavedTypes)(schema) || [utils_2.componentValueTypes.date];
|
|
81
79
|
}
|
|
82
80
|
constructor(component, options, data) {
|
|
83
81
|
super(component, options, data);
|
|
@@ -177,9 +175,7 @@ class DateTimeComponent extends Input_1.default {
|
|
|
177
175
|
let format = utils_1.default.convertFormatToMoment(this.component.format);
|
|
178
176
|
format += format.match(/z$/) ? '' : ' z';
|
|
179
177
|
const timezone = this.timezone;
|
|
180
|
-
const useTimezoneAwareFormat = value &&
|
|
181
|
-
timezone &&
|
|
182
|
-
(this.options.pdf || (options === null || options === void 0 ? void 0 : options.email));
|
|
178
|
+
const useTimezoneAwareFormat = value && timezone && (this.options.pdf || (options === null || options === void 0 ? void 0 : options.email));
|
|
183
179
|
if (useTimezoneAwareFormat) {
|
|
184
180
|
if (Array.isArray(value) && this.component.multiple) {
|
|
185
181
|
return value
|
|
@@ -59,9 +59,7 @@ class DayComponent extends Field_1.default {
|
|
|
59
59
|
}
|
|
60
60
|
static savedValueTypes(schema) {
|
|
61
61
|
schema = schema || {};
|
|
62
|
-
return (
|
|
63
|
-
utils_1.componentValueTypes.string,
|
|
64
|
-
]);
|
|
62
|
+
return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.string];
|
|
65
63
|
}
|
|
66
64
|
constructor(component, options, data) {
|
|
67
65
|
if (options && !options.inFormBuilder && !options.building) {
|
|
@@ -166,9 +164,7 @@ class DayComponent extends Field_1.default {
|
|
|
166
164
|
};
|
|
167
165
|
}
|
|
168
166
|
get days() {
|
|
169
|
-
const days = [
|
|
170
|
-
{ value: '', label: lodash_1.default.get(this.component, 'fields.day.placeholder', '') },
|
|
171
|
-
];
|
|
167
|
+
const days = [{ value: '', label: lodash_1.default.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 @@ class DayComponent extends Field_1.default {
|
|
|
182
178
|
{
|
|
183
179
|
value: '',
|
|
184
180
|
label: lodash_1.default.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 @@ class DayComponent extends Field_1.default {
|
|
|
200
196
|
return months;
|
|
201
197
|
}
|
|
202
198
|
get years() {
|
|
203
|
-
const years = [
|
|
204
|
-
{ value: '', label: lodash_1.default.get(this.component, 'fields.year.placeholder', '') },
|
|
205
|
-
];
|
|
199
|
+
const years = [{ value: '', label: lodash_1.default.get(this.component, 'fields.year.placeholder', '') }];
|
|
206
200
|
const minYears = lodash_1.default.get(this.component, 'fields.year.minYear', 1900) || 1900;
|
|
207
201
|
const maxYears = lodash_1.default.get(this.component, 'fields.year.maxYear', 2030) || 2030;
|
|
208
202
|
for (let x = minYears; x <= maxYears; x++) {
|
|
@@ -215,18 +209,10 @@ class DayComponent extends Field_1.default {
|
|
|
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 @@ class DayComponent extends Field_1.default {
|
|
|
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 @@ class DayComponent extends Field_1.default {
|
|
|
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 @@ class DayComponent extends Field_1.default {
|
|
|
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 @@ class DayComponent extends Field_1.default {
|
|
|
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;
|
|
@@ -533,17 +495,7 @@ class DayComponent extends Field_1.default {
|
|
|
533
495
|
var _a;
|
|
534
496
|
let defaults = [], day, month, year;
|
|
535
497
|
// Map positions to identifiers to get default values for each part of day
|
|
536
|
-
const [DAY, MONTH, YEAR
|
|
537
|
-
? [
|
|
538
|
-
0,
|
|
539
|
-
1,
|
|
540
|
-
2,
|
|
541
|
-
]
|
|
542
|
-
: [
|
|
543
|
-
1,
|
|
544
|
-
0,
|
|
545
|
-
2,
|
|
546
|
-
];
|
|
498
|
+
const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
547
499
|
const defaultValue = value || this.component.defaultValue;
|
|
548
500
|
if (defaultValue) {
|
|
549
501
|
defaults = defaultValue.split('/').map((x) => parseInt(x, 10));
|
|
@@ -689,17 +641,7 @@ class DayComponent extends Field_1.default {
|
|
|
689
641
|
if (!value) {
|
|
690
642
|
return true;
|
|
691
643
|
}
|
|
692
|
-
const [DAY, MONTH, YEAR
|
|
693
|
-
? [
|
|
694
|
-
0,
|
|
695
|
-
1,
|
|
696
|
-
2,
|
|
697
|
-
]
|
|
698
|
-
: [
|
|
699
|
-
1,
|
|
700
|
-
0,
|
|
701
|
-
2,
|
|
702
|
-
];
|
|
644
|
+
const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
703
645
|
const values = value.split('/');
|
|
704
646
|
if (values.length < 3) {
|
|
705
647
|
return true;
|
|
@@ -43,9 +43,7 @@ exports.default = [
|
|
|
43
43
|
if (data.defaultValue) {
|
|
44
44
|
const defaultValueParts = data.defaultValue.split('/');
|
|
45
45
|
if (!data.fields.day.hide && defaultValueParts.length !== 3) {
|
|
46
|
-
const newDefaultValue = [
|
|
47
|
-
'00',
|
|
48
|
-
];
|
|
46
|
+
const newDefaultValue = ['00'];
|
|
49
47
|
if (!data.fields.month.hide) {
|
|
50
48
|
data.dayFirst
|
|
51
49
|
? newDefaultValue.push(defaultValueParts[0])
|
|
@@ -43,9 +43,7 @@ exports.default = [
|
|
|
43
43
|
if (data.defaultValue) {
|
|
44
44
|
const defaultValueParts = data.defaultValue.split('/');
|
|
45
45
|
if (!data.fields.month.hide && defaultValueParts.length !== 3) {
|
|
46
|
-
const newDefaultValue = [
|
|
47
|
-
'00',
|
|
48
|
-
];
|
|
46
|
+
const newDefaultValue = ['00'];
|
|
49
47
|
if (!data.fields.day.hide) {
|
|
50
48
|
data.dayFirst
|
|
51
49
|
? 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;
|