@formio/js 5.1.0-dev.6048.c77fe06 → 5.1.0-dev.6049.6110ca0
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 +99 -310
- package/README.md +7 -0
- package/dist/formio.builder.css +1 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.form.css +1 -0
- package/dist/formio.form.js +658 -669
- 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 -1
- package/dist/formio.full.css +1 -0
- package/dist/formio.full.js +685 -696
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -1
- package/dist/formio.js +90 -68
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +103 -81
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +3 -1
- package/lib/cjs/Element.d.ts +2 -1
- package/lib/cjs/Element.js +18 -39
- package/lib/cjs/EventEmitter.js +2 -25
- package/lib/cjs/Form.js +2 -25
- package/lib/cjs/PDF.js +1 -1
- package/lib/cjs/PDFBuilder.d.ts +1 -0
- package/lib/cjs/PDFBuilder.js +10 -11
- package/lib/cjs/Webform.d.ts +2 -2
- package/lib/cjs/Webform.js +14 -15
- package/lib/cjs/WebformBuilder.d.ts +2 -1
- package/lib/cjs/WebformBuilder.js +62 -20
- package/lib/cjs/Wizard.d.ts +2 -2
- package/lib/cjs/Wizard.js +35 -24
- package/lib/cjs/WizardBuilder.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +44 -13
- package/lib/cjs/components/_classes/component/Component.js +156 -95
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/utils.js +1 -1
- package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
- package/lib/cjs/components/_classes/input/Input.js +1 -1
- package/lib/cjs/components/_classes/list/ListComponent.js +3 -3
- package/lib/cjs/components/_classes/nested/NestedComponent.form.js +13 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.js +15 -8
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -12
- package/lib/cjs/components/address/Address.d.ts +8 -0
- package/lib/cjs/components/address/Address.js +32 -9
- package/lib/cjs/components/address/editForm/Address.edit.display.d.ts +4 -0
- package/lib/cjs/components/address/editForm/Address.edit.display.js +1 -0
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -8
- package/lib/cjs/components/alert/Alert.js +1 -1
- package/lib/cjs/components/button/Button.d.ts +1 -1
- package/lib/cjs/components/button/Button.js +7 -11
- package/lib/cjs/components/checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/container/Container.js +1 -1
- package/lib/cjs/components/content/editForm/Content.edit.display.js +8 -0
- package/lib/cjs/components/currency/Currency.js +1 -1
- package/lib/cjs/components/currency/editForm/Currency.edit.display.js +12 -0
- package/lib/cjs/components/datagrid/DataGrid.js +5 -1
- package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/cjs/components/datetime/DateTime.js +15 -13
- package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
- package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
- package/lib/cjs/components/day/Day.js +2 -2
- package/lib/cjs/components/day/editForm/Day.edit.display.js +8 -0
- package/lib/cjs/components/editgrid/EditGrid.js +4 -2
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- 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.js +6 -2
- package/lib/cjs/components/file/editForm/File.edit.file.d.ts +13 -0
- package/lib/cjs/components/file/editForm/File.edit.file.js +1 -0
- package/lib/cjs/components/form/Form.d.ts +0 -1
- package/lib/cjs/components/form/Form.js +31 -23
- package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
- 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 +1 -1
- package/lib/cjs/components/number/editForm/Number.edit.display.js +12 -0
- package/lib/cjs/components/panel/Panel.js +1 -1
- 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.d.ts +8 -0
- package/lib/cjs/components/radio/Radio.js +16 -6
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/cjs/components/select/Select.d.ts +1 -0
- package/lib/cjs/components/select/Select.js +21 -5
- package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +68 -110
- package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -37
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/cjs/components/selectboxes/SelectBoxes.js +7 -1
- package/lib/cjs/components/signature/Signature.js +1 -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.js +1 -1
- package/lib/cjs/components/textarea/TextArea.js +10 -2
- package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
- package/lib/cjs/components/textfield/TextField.js +9 -32
- package/lib/cjs/components/time/Time.js +1 -1
- package/lib/cjs/components/unknown/Unknown.form.d.ts +2 -1
- package/lib/cjs/components/unknown/Unknown.form.js +13 -9
- 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 -5
- package/lib/cjs/providers/storage/uploadAdapter.js +8 -6
- package/lib/cjs/translations/en.d.ts +1 -234
- package/lib/cjs/translations/en.js +4 -2
- package/lib/cjs/utils/Evaluator.d.ts +20 -6
- package/lib/cjs/utils/Evaluator.js +38 -15
- package/lib/cjs/utils/builder.js +5 -5
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/index.d.ts +169 -2
- package/lib/cjs/utils/index.js +22 -2
- package/lib/cjs/utils/utils.d.ts +31 -37
- package/lib/cjs/utils/utils.js +80 -135
- package/lib/cjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/cjs/widgets/CalendarWidget.js +19 -40
- package/lib/mjs/Element.d.ts +2 -1
- package/lib/mjs/Element.js +11 -9
- package/lib/mjs/EventEmitter.js +2 -2
- package/lib/mjs/Form.js +1 -1
- package/lib/mjs/PDF.js +1 -1
- package/lib/mjs/PDFBuilder.d.ts +1 -0
- package/lib/mjs/PDFBuilder.js +9 -10
- package/lib/mjs/Webform.d.ts +2 -2
- package/lib/mjs/Webform.js +12 -13
- package/lib/mjs/WebformBuilder.d.ts +2 -1
- package/lib/mjs/WebformBuilder.js +53 -13
- package/lib/mjs/Wizard.d.ts +2 -2
- package/lib/mjs/Wizard.js +34 -23
- package/lib/mjs/WizardBuilder.js +1 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +44 -13
- package/lib/mjs/components/_classes/component/Component.js +129 -45
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/utils.js +1 -1
- package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
- package/lib/mjs/components/_classes/input/Input.js +1 -1
- package/lib/mjs/components/_classes/list/ListComponent.js +3 -3
- package/lib/mjs/components/_classes/nested/NestedComponent.form.js +13 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.js +15 -8
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -12
- package/lib/mjs/components/address/Address.d.ts +8 -0
- package/lib/mjs/components/address/Address.js +32 -9
- package/lib/mjs/components/address/editForm/Address.edit.display.d.ts +4 -0
- package/lib/mjs/components/address/editForm/Address.edit.display.js +1 -0
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -8
- package/lib/mjs/components/alert/Alert.js +1 -1
- package/lib/mjs/components/button/Button.d.ts +1 -1
- package/lib/mjs/components/button/Button.js +7 -10
- package/lib/mjs/components/checkbox/Checkbox.js +1 -1
- package/lib/mjs/components/container/Container.js +1 -1
- package/lib/mjs/components/content/editForm/Content.edit.display.js +8 -0
- package/lib/mjs/components/currency/Currency.js +1 -1
- package/lib/mjs/components/currency/editForm/Currency.edit.display.js +12 -0
- package/lib/mjs/components/datagrid/DataGrid.js +5 -1
- package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/mjs/components/datetime/DateTime.js +15 -13
- package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
- package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
- package/lib/mjs/components/day/Day.js +2 -2
- package/lib/mjs/components/day/editForm/Day.edit.display.js +8 -0
- package/lib/mjs/components/editgrid/EditGrid.js +4 -2
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- 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.js +6 -2
- package/lib/mjs/components/file/editForm/File.edit.file.d.ts +13 -0
- package/lib/mjs/components/file/editForm/File.edit.file.js +1 -0
- package/lib/mjs/components/form/Form.d.ts +0 -1
- package/lib/mjs/components/form/Form.js +30 -23
- package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
- 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 +1 -1
- package/lib/mjs/components/number/editForm/Number.edit.display.js +12 -0
- package/lib/mjs/components/panel/Panel.js +1 -1
- 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.d.ts +8 -0
- package/lib/mjs/components/radio/Radio.js +16 -6
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/mjs/components/select/Select.d.ts +1 -0
- package/lib/mjs/components/select/Select.js +21 -5
- package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +68 -110
- package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -37
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/mjs/components/selectboxes/SelectBoxes.js +7 -1
- package/lib/mjs/components/signature/Signature.js +1 -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.js +1 -1
- package/lib/mjs/components/textarea/TextArea.js +10 -2
- package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
- package/lib/mjs/components/textfield/TextField.js +3 -3
- package/lib/mjs/components/time/Time.js +1 -1
- package/lib/mjs/components/unknown/Unknown.form.d.ts +2 -1
- package/lib/mjs/components/unknown/Unknown.form.js +13 -9
- 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 +3 -3
- package/lib/mjs/providers/storage/uploadAdapter.js +8 -6
- package/lib/mjs/translations/en.d.ts +1 -234
- package/lib/mjs/translations/en.js +6 -47
- package/lib/mjs/utils/Evaluator.d.ts +20 -6
- package/lib/mjs/utils/Evaluator.js +31 -13
- package/lib/mjs/utils/builder.js +1 -1
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/index.d.ts +169 -2
- package/lib/mjs/utils/index.js +18 -1
- package/lib/mjs/utils/utils.d.ts +31 -37
- package/lib/mjs/utils/utils.js +72 -109
- package/lib/mjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/mjs/widgets/CalendarWidget.js +19 -40
- package/package.json +8 -6
- package/lib/cjs/i18n.d.ts +0 -13
- package/lib/cjs/i18n.js +0 -19
- package/lib/cjs/utils/i18n.d.ts +0 -19
- package/lib/cjs/utils/i18n.js +0 -120
- package/lib/mjs/i18n.d.ts +0 -13
- package/lib/mjs/i18n.js +0 -14
- package/lib/mjs/utils/i18n.d.ts +0 -19
- package/lib/mjs/utils/i18n.js +0 -112
@@ -1,5 +1,5 @@
|
|
1
1
|
import Field from '../_classes/field/Field';
|
2
|
-
import { componentValueTypes, getComponentSavedTypes, uniqueName } from '../../utils
|
2
|
+
import { componentValueTypes, getComponentSavedTypes, uniqueName } from '../../utils';
|
3
3
|
import download from 'downloadjs';
|
4
4
|
import _ from 'lodash';
|
5
5
|
import fileProcessor from '../../providers/processor/fileProcessor';
|
@@ -905,7 +905,9 @@ export default class FileComponent extends Field {
|
|
905
905
|
async uploadFile(fileToSync) {
|
906
906
|
return await this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
|
907
907
|
// Progress callback
|
908
|
-
this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
|
908
|
+
this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
|
909
|
+
this.emit('fileUploadingStart');
|
910
|
+
},
|
909
911
|
// Abort upload callback
|
910
912
|
(abort) => this.abortUploads.push({
|
911
913
|
id: fileToSync.id,
|
@@ -930,6 +932,7 @@ export default class FileComponent extends Field {
|
|
930
932
|
fileToSync.message = this.t('succefullyUploaded');
|
931
933
|
fileInfo.originalName = fileToSync.originalName;
|
932
934
|
fileInfo.hash = fileToSync.hash;
|
935
|
+
this.emit('fileUploadingEnd');
|
933
936
|
}
|
934
937
|
catch (response) {
|
935
938
|
fileToSync.status = 'error';
|
@@ -939,6 +942,7 @@ export default class FileComponent extends Field {
|
|
939
942
|
: response.type === 'abort'
|
940
943
|
? this.t('Request was aborted')
|
941
944
|
: response.toString();
|
945
|
+
this.emit('fileUploadingEnd');
|
942
946
|
this.emit('fileUploadError', {
|
943
947
|
fileToSync,
|
944
948
|
response,
|
@@ -16,6 +16,7 @@ declare const _default: ({
|
|
16
16
|
components?: undefined;
|
17
17
|
rows?: undefined;
|
18
18
|
editor?: undefined;
|
19
|
+
as?: undefined;
|
19
20
|
optionsLabelPosition?: undefined;
|
20
21
|
inline?: undefined;
|
21
22
|
defaultValue?: undefined;
|
@@ -45,6 +46,7 @@ declare const _default: ({
|
|
45
46
|
components?: undefined;
|
46
47
|
rows?: undefined;
|
47
48
|
editor?: undefined;
|
49
|
+
as?: undefined;
|
48
50
|
optionsLabelPosition?: undefined;
|
49
51
|
inline?: undefined;
|
50
52
|
defaultValue?: undefined;
|
@@ -91,6 +93,7 @@ declare const _default: ({
|
|
91
93
|
data?: undefined;
|
92
94
|
rows?: undefined;
|
93
95
|
editor?: undefined;
|
96
|
+
as?: undefined;
|
94
97
|
optionsLabelPosition?: undefined;
|
95
98
|
inline?: undefined;
|
96
99
|
defaultValue?: undefined;
|
@@ -120,6 +123,7 @@ declare const _default: ({
|
|
120
123
|
components?: undefined;
|
121
124
|
rows?: undefined;
|
122
125
|
editor?: undefined;
|
126
|
+
as?: undefined;
|
123
127
|
optionsLabelPosition?: undefined;
|
124
128
|
inline?: undefined;
|
125
129
|
defaultValue?: undefined;
|
@@ -149,6 +153,7 @@ declare const _default: ({
|
|
149
153
|
components?: undefined;
|
150
154
|
rows?: undefined;
|
151
155
|
editor?: undefined;
|
156
|
+
as?: undefined;
|
152
157
|
optionsLabelPosition?: undefined;
|
153
158
|
inline?: undefined;
|
154
159
|
defaultValue?: undefined;
|
@@ -160,6 +165,7 @@ declare const _default: ({
|
|
160
165
|
tooltip: string;
|
161
166
|
rows: number;
|
162
167
|
editor: string;
|
168
|
+
as: string;
|
163
169
|
input: boolean;
|
164
170
|
weight: number;
|
165
171
|
placeholder: string;
|
@@ -207,6 +213,7 @@ declare const _default: ({
|
|
207
213
|
components?: undefined;
|
208
214
|
rows?: undefined;
|
209
215
|
editor?: undefined;
|
216
|
+
as?: undefined;
|
210
217
|
optionsLabelPosition?: undefined;
|
211
218
|
inline?: undefined;
|
212
219
|
defaultValue?: undefined;
|
@@ -227,6 +234,7 @@ declare const _default: ({
|
|
227
234
|
components?: undefined;
|
228
235
|
rows?: undefined;
|
229
236
|
editor?: undefined;
|
237
|
+
as?: undefined;
|
230
238
|
optionsLabelPosition?: undefined;
|
231
239
|
inline?: undefined;
|
232
240
|
defaultValue?: undefined;
|
@@ -247,6 +255,7 @@ declare const _default: ({
|
|
247
255
|
components?: undefined;
|
248
256
|
rows?: undefined;
|
249
257
|
editor?: undefined;
|
258
|
+
as?: undefined;
|
250
259
|
optionsLabelPosition?: undefined;
|
251
260
|
inline?: undefined;
|
252
261
|
defaultValue?: undefined;
|
@@ -276,6 +285,7 @@ declare const _default: ({
|
|
276
285
|
components?: undefined;
|
277
286
|
rows?: undefined;
|
278
287
|
editor?: undefined;
|
288
|
+
as?: undefined;
|
279
289
|
optionsLabelPosition?: undefined;
|
280
290
|
inline?: undefined;
|
281
291
|
defaultValue?: undefined;
|
@@ -305,6 +315,7 @@ declare const _default: ({
|
|
305
315
|
components?: undefined;
|
306
316
|
rows?: undefined;
|
307
317
|
editor?: undefined;
|
318
|
+
as?: undefined;
|
308
319
|
optionsLabelPosition?: undefined;
|
309
320
|
inline?: undefined;
|
310
321
|
defaultValue?: undefined;
|
@@ -332,6 +343,7 @@ declare const _default: ({
|
|
332
343
|
components?: undefined;
|
333
344
|
rows?: undefined;
|
334
345
|
editor?: undefined;
|
346
|
+
as?: undefined;
|
335
347
|
} | {
|
336
348
|
type: string;
|
337
349
|
input: boolean;
|
@@ -353,6 +365,7 @@ declare const _default: ({
|
|
353
365
|
tableView?: undefined;
|
354
366
|
rows?: undefined;
|
355
367
|
editor?: undefined;
|
368
|
+
as?: undefined;
|
356
369
|
optionsLabelPosition?: undefined;
|
357
370
|
inline?: undefined;
|
358
371
|
defaultValue?: undefined;
|
@@ -98,7 +98,6 @@ export default class FormComponent extends Component {
|
|
98
98
|
* @returns {void}
|
99
99
|
*/
|
100
100
|
onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
|
101
|
-
areAllComponentsEmpty(data: any): boolean;
|
102
101
|
updateSubFormVisibility(): void;
|
103
102
|
/**
|
104
103
|
* Determines if this form is a Nested Wizard
|
@@ -3,7 +3,7 @@ import _ from 'lodash';
|
|
3
3
|
import Component from '../_classes/component/Component';
|
4
4
|
import ComponentModal from '../_classes/componentModal/ComponentModal';
|
5
5
|
import EventEmitter from 'eventemitter3';
|
6
|
-
import { isMongoId, eachComponent, componentValueTypes } from '../../utils
|
6
|
+
import { isMongoId, eachComponent, componentValueTypes } from '../../utils';
|
7
7
|
import { Formio } from '../../Formio';
|
8
8
|
import Form from '../../Form';
|
9
9
|
export default class FormComponent extends Component {
|
@@ -96,6 +96,9 @@ export default class FormComponent extends Component {
|
|
96
96
|
}
|
97
97
|
return this.createSubForm();
|
98
98
|
}
|
99
|
+
shouldConditionallyClearOnPristine() {
|
100
|
+
return !this.hasSetValue && super.shouldConditionallyClearOnPristine();
|
101
|
+
}
|
99
102
|
get dataReady() {
|
100
103
|
return this.subForm?.dataReady || this.subFormReady || Promise.resolve();
|
101
104
|
}
|
@@ -109,6 +112,10 @@ export default class FormComponent extends Component {
|
|
109
112
|
get emptyValue() {
|
110
113
|
return { data: {} };
|
111
114
|
}
|
115
|
+
// In order for the subform values to set properly, we must always say that nested forms have a default value.
|
116
|
+
get hasDefaultValue() {
|
117
|
+
return true;
|
118
|
+
}
|
112
119
|
get ready() {
|
113
120
|
return this.subFormReady || Promise.resolve();
|
114
121
|
}
|
@@ -267,6 +274,9 @@ export default class FormComponent extends Component {
|
|
267
274
|
if (this.isSubFormLazyLoad() && !this.hasLoadedForm && !this.subFormLoading) {
|
268
275
|
this.createSubForm(true);
|
269
276
|
}
|
277
|
+
if (!this.subFormReady) {
|
278
|
+
return Promise.resolve();
|
279
|
+
}
|
270
280
|
return this.subFormReady.then(() => {
|
271
281
|
this.empty(element);
|
272
282
|
if (this.options.builder) {
|
@@ -282,11 +292,13 @@ export default class FormComponent extends Component {
|
|
282
292
|
}
|
283
293
|
this.subForm.attach(element);
|
284
294
|
this.valueChanged = this.hasSetValue;
|
285
|
-
if (!this.
|
286
|
-
this.
|
287
|
-
|
288
|
-
|
289
|
-
|
295
|
+
if (!this.shouldConditionallyClear()) {
|
296
|
+
if (!this.valueChanged && this.dataValue.state !== 'submitted') {
|
297
|
+
this.setDefaultValue();
|
298
|
+
}
|
299
|
+
else {
|
300
|
+
this.restoreValue();
|
301
|
+
}
|
290
302
|
}
|
291
303
|
}
|
292
304
|
if (!this.builderMode && this.component.modalEdit) {
|
@@ -399,9 +411,10 @@ export default class FormComponent extends Component {
|
|
399
411
|
const componentsMap = this.componentsMap;
|
400
412
|
const formComponentsMap = this.subForm.componentsMap;
|
401
413
|
_.assign(componentsMap, formComponentsMap);
|
402
|
-
this.component.components = this.subForm.components
|
414
|
+
this.component.components = this.subForm._form?.components;
|
415
|
+
this.component.display = this.subForm._form?.display;
|
403
416
|
this.subForm.on('change', () => {
|
404
|
-
if (this.subForm) {
|
417
|
+
if (this.subForm && !this.shouldConditionallyClear()) {
|
405
418
|
this.dataValue = this.subForm.getValue();
|
406
419
|
this.triggerChange({
|
407
420
|
noEmit: true
|
@@ -513,7 +526,7 @@ export default class FormComponent extends Component {
|
|
513
526
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
514
527
|
*/
|
515
528
|
get shouldSubmit() {
|
516
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) &&
|
529
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.shouldConditionallyClear();
|
517
530
|
}
|
518
531
|
/**
|
519
532
|
* Returns the data for the subform.
|
@@ -664,20 +677,7 @@ export default class FormComponent extends Component {
|
|
664
677
|
}
|
665
678
|
}
|
666
679
|
isEmpty(value = this.dataValue) {
|
667
|
-
return value === null || _.isEqual(value, this.emptyValue)
|
668
|
-
}
|
669
|
-
areAllComponentsEmpty(data) {
|
670
|
-
let res = true;
|
671
|
-
if (this.subForm) {
|
672
|
-
this.subForm.everyComponent((comp) => {
|
673
|
-
const componentValue = _.get(data, comp.key);
|
674
|
-
res &= comp.isEmpty(componentValue);
|
675
|
-
});
|
676
|
-
}
|
677
|
-
else {
|
678
|
-
res = false;
|
679
|
-
}
|
680
|
-
return res;
|
680
|
+
return value === null || _.isEqual(value, this.emptyValue);
|
681
681
|
}
|
682
682
|
getValue() {
|
683
683
|
if (this.subForm) {
|
@@ -692,6 +692,13 @@ export default class FormComponent extends Component {
|
|
692
692
|
}
|
693
693
|
return errors;
|
694
694
|
}
|
695
|
+
conditionallyHidden() {
|
696
|
+
const conditionallyHidden = super.conditionallyHidden();
|
697
|
+
if (this.subForm) {
|
698
|
+
this.subForm._conditionallyHidden = conditionallyHidden;
|
699
|
+
}
|
700
|
+
return conditionallyHidden;
|
701
|
+
}
|
695
702
|
updateSubFormVisibility() {
|
696
703
|
if (this.subForm) {
|
697
704
|
this.subForm.parentVisible = this.visible;
|
@@ -30,9 +30,10 @@ export default [
|
|
30
30
|
tooltip: 'if it is checked, the subform is loaded after navigation to the page with this component within the wizard.',
|
31
31
|
input: true,
|
32
32
|
customConditional({ instance, data }) {
|
33
|
-
const
|
33
|
+
const formComp = instance.root?.getComponent('form');
|
34
|
+
const formInfo = formComp?.defaultDownloadedResources.find(res => res._id === data.form);
|
34
35
|
const displayMode = 'wizard';
|
35
|
-
return instance.options?.editForm?.display === displayMode && formInfo && formInfo.display !== displayMode;
|
36
|
+
return instance.options?.editForm?.display === displayMode && ((data.form && !formInfo) || (formInfo && formInfo.display !== displayMode));
|
36
37
|
},
|
37
38
|
},
|
38
39
|
{
|
@@ -2,7 +2,7 @@ import { createNumberMask } from '@formio/text-mask-addons';
|
|
2
2
|
import { conformToMask, maskInput } from '@formio/vanilla-text-mask';
|
3
3
|
import _ from 'lodash';
|
4
4
|
import Input from '../_classes/input/Input';
|
5
|
-
import { getNumberSeparators, getNumberDecimalLimit, componentValueTypes, getComponentSavedTypes } from '../../utils/
|
5
|
+
import { getNumberSeparators, getNumberDecimalLimit, componentValueTypes, getComponentSavedTypes } from '../../utils/';
|
6
6
|
export default class NumberComponent extends Input {
|
7
7
|
static schema(...extend) {
|
8
8
|
return Input.schema({
|
@@ -11,6 +11,18 @@ export default [
|
|
11
11
|
key: 'allowMultipleMasks',
|
12
12
|
ignore: true
|
13
13
|
},
|
14
|
+
{
|
15
|
+
key: 'inputMasks',
|
16
|
+
ignore: true
|
17
|
+
},
|
18
|
+
{
|
19
|
+
key: 'widget.type',
|
20
|
+
ignore: true
|
21
|
+
},
|
22
|
+
{
|
23
|
+
key: 'widget',
|
24
|
+
ignore: true
|
25
|
+
},
|
14
26
|
{
|
15
27
|
key: 'showWordCount',
|
16
28
|
ignore: true,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import NestedComponent from '../_classes/nested/NestedComponent';
|
2
|
-
import { isChildOf } from '../../utils
|
2
|
+
import { isChildOf } from '../../utils';
|
3
3
|
export default class PanelComponent extends NestedComponent {
|
4
4
|
static schema(...extend) {
|
5
5
|
return NestedComponent.schema({
|
@@ -28,6 +28,7 @@ export default class RadioComponent extends ListComponent {
|
|
28
28
|
optionsLoaded: boolean | undefined;
|
29
29
|
loadedOptions: any[] | undefined;
|
30
30
|
beforeSubmit(): Promise<any>;
|
31
|
+
convertValues(values: any): any;
|
31
32
|
render(): string;
|
32
33
|
attach(element: any): Promise<void>;
|
33
34
|
detach(element: any): void;
|
@@ -41,5 +42,12 @@ export default class RadioComponent extends ListComponent {
|
|
41
42
|
setSelectedClasses(): void;
|
42
43
|
updateValue(value: any, flags: any): boolean;
|
43
44
|
currentValue: any;
|
45
|
+
/**
|
46
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
47
|
+
* @param {*} value - The value to normalize
|
48
|
+
* @returns {*} - Returns the normalized value
|
49
|
+
*/
|
50
|
+
convertByDataType(value: any): any;
|
51
|
+
normalizeValue(value: any): any;
|
44
52
|
}
|
45
53
|
import ListComponent from '../_classes/list/ListComponent';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import ListComponent from '../_classes/list/ListComponent';
|
3
3
|
import { Formio } from '../../Formio';
|
4
|
-
import { boolValue, componentValueTypes, getComponentSavedTypes } from '../../utils
|
4
|
+
import { boolValue, componentValueTypes, getComponentSavedTypes } from '../../utils';
|
5
5
|
export default class RadioComponent extends ListComponent {
|
6
6
|
static schema(...extend) {
|
7
7
|
return ListComponent.schema({
|
@@ -153,6 +153,12 @@ export default class RadioComponent extends ListComponent {
|
|
153
153
|
this.dataReady.then(() => res(true));
|
154
154
|
});
|
155
155
|
}
|
156
|
+
convertValues(values) {
|
157
|
+
if (this.options.renderMode === 'html' && this.type === 'radio') {
|
158
|
+
return values.map(x => ({ ...x, value: this.convertByDataType(x.value) }));
|
159
|
+
}
|
160
|
+
return values;
|
161
|
+
}
|
156
162
|
render() {
|
157
163
|
if (!this.optionsLoaded) {
|
158
164
|
return super.render(this.renderTemplate('loader'));
|
@@ -160,7 +166,7 @@ export default class RadioComponent extends ListComponent {
|
|
160
166
|
return super.render(this.renderTemplate('radio', {
|
161
167
|
input: this.inputInfo,
|
162
168
|
inline: this.component.inline,
|
163
|
-
values: this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions,
|
169
|
+
values: this.component.dataSrc === 'values' ? this.convertValues(this.component.values) : this.loadedOptions,
|
164
170
|
value: this.dataValue,
|
165
171
|
row: this.row,
|
166
172
|
}));
|
@@ -406,7 +412,7 @@ export default class RadioComponent extends ListComponent {
|
|
406
412
|
* @param {*} value - The value to normalize
|
407
413
|
* @returns {*} - Returns the normalized value
|
408
414
|
*/
|
409
|
-
|
415
|
+
convertByDataType(value) {
|
410
416
|
const dataType = this.component.dataType || 'auto';
|
411
417
|
if (value === this.emptyValue) {
|
412
418
|
return value;
|
@@ -438,13 +444,17 @@ export default class RadioComponent extends ListComponent {
|
|
438
444
|
value = !(!value || value.toString() === 'false');
|
439
445
|
break;
|
440
446
|
}
|
441
|
-
|
447
|
+
return value;
|
448
|
+
}
|
449
|
+
normalizeValue(value) {
|
450
|
+
const valueConverted = this.convertByDataType(value);
|
451
|
+
if (this.isSelectURL && this.templateData && this.templateData[valueConverted]) {
|
442
452
|
const submission = this.root.submission;
|
443
453
|
if (!submission.metadata.selectData) {
|
444
454
|
submission.metadata.selectData = {};
|
445
455
|
}
|
446
|
-
_.set(submission.metadata.selectData, this.path, this.templateData[
|
456
|
+
_.set(submission.metadata.selectData, this.path, this.templateData[valueConverted]);
|
447
457
|
}
|
448
|
-
return super.normalizeValue(
|
458
|
+
return super.normalizeValue(valueConverted);
|
449
459
|
}
|
450
460
|
}
|
@@ -89,6 +89,7 @@ export default class SelectComponent extends ListComponent {
|
|
89
89
|
disableInfiniteScroll(): void;
|
90
90
|
set serverCount(value: any);
|
91
91
|
get serverCount(): any;
|
92
|
+
shouldResetChoicesItems(items: any): boolean;
|
92
93
|
setItems(items: any, fromSearch: any): void;
|
93
94
|
selectItems: any;
|
94
95
|
set downloadedResources(value: any);
|
@@ -2,7 +2,7 @@ import _ from 'lodash';
|
|
2
2
|
import { Formio } from '../../Formio';
|
3
3
|
import ListComponent from '../_classes/list/ListComponent';
|
4
4
|
import Form from '../../Form';
|
5
|
-
import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes, isSelectResourceWithObjectValue, removeHTML } from '../../utils
|
5
|
+
import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes, isSelectResourceWithObjectValue, removeHTML } from '../../utils';
|
6
6
|
import Choices from '../../utils/ChoicesWrapper';
|
7
7
|
export default class SelectComponent extends ListComponent {
|
8
8
|
static schema(...extend) {
|
@@ -359,6 +359,18 @@ export default class SelectComponent extends ListComponent {
|
|
359
359
|
this.downloadedResources.serverCount = this.downloadedResources.length;
|
360
360
|
this.serverCount = this.downloadedResources.length;
|
361
361
|
}
|
362
|
+
shouldResetChoicesItems(items) {
|
363
|
+
if (this.choices._store.choices.length !== items.length) {
|
364
|
+
return true;
|
365
|
+
}
|
366
|
+
for (let item of items) {
|
367
|
+
const choicesItem = this.choices._store.choices.find((i) => i.label === item.label);
|
368
|
+
if (!choicesItem) {
|
369
|
+
return true;
|
370
|
+
}
|
371
|
+
}
|
372
|
+
return false;
|
373
|
+
}
|
362
374
|
/* eslint-disable max-statements */
|
363
375
|
setItems(items, fromSearch) {
|
364
376
|
this.selectItems = items;
|
@@ -444,7 +456,7 @@ export default class SelectComponent extends ListComponent {
|
|
444
456
|
this.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, _.get(item, this.component.idPath, String(index)));
|
445
457
|
});
|
446
458
|
if (this.choices) {
|
447
|
-
this.choices.setChoices(this.selectOptions, 'value', 'label', true);
|
459
|
+
this.choices.setChoices(this.selectOptions, 'value', 'label', true, true, !fromSearch && this.shouldResetChoicesItems(this.selectOptions));
|
448
460
|
}
|
449
461
|
else if (this.loading) {
|
450
462
|
// Re-attach select input.
|
@@ -935,8 +947,9 @@ export default class SelectComponent extends ListComponent {
|
|
935
947
|
});
|
936
948
|
}
|
937
949
|
// Add value options.
|
950
|
+
const value = this.undoValueTyping(this.dataValue);
|
938
951
|
this.addValueOptions();
|
939
|
-
this.setChoicesValue(
|
952
|
+
this.setChoicesValue(value);
|
940
953
|
if (this.isSelectResource && this.refs.addResource) {
|
941
954
|
this.addEventListener(this.refs.addResource, 'click', (event) => {
|
942
955
|
event.preventDefault();
|
@@ -1248,7 +1261,7 @@ export default class SelectComponent extends ListComponent {
|
|
1248
1261
|
}
|
1249
1262
|
_.set(submission.metadata.selectData, this.path, templateData);
|
1250
1263
|
}
|
1251
|
-
if (flags.resetValue && this.root?.submission && !this.options.readOnly) {
|
1264
|
+
if (flags.resetValue && !flags.fromSubmission && this.root?.submission && !this.options.readOnly) {
|
1252
1265
|
const submission = this.root.submission;
|
1253
1266
|
if (!submission.metadata) {
|
1254
1267
|
submission.metadata = {};
|
@@ -1312,6 +1325,9 @@ export default class SelectComponent extends ListComponent {
|
|
1312
1325
|
this.lazyLoadInit = true;
|
1313
1326
|
const searchProperty = this.component.searchField || this.component.valueProperty;
|
1314
1327
|
this.triggerUpdate(_.get(value.data || value, searchProperty, value), true);
|
1328
|
+
this.itemsLoaded.then(() => {
|
1329
|
+
this.setChoicesValue(value, hasPreviousValue, flags);
|
1330
|
+
});
|
1315
1331
|
return changed;
|
1316
1332
|
}
|
1317
1333
|
// Add the value options.
|
@@ -1487,7 +1503,7 @@ export default class SelectComponent extends ListComponent {
|
|
1487
1503
|
}
|
1488
1504
|
asString(value, options = {}) {
|
1489
1505
|
value = value ?? this.getValue();
|
1490
|
-
if (options.modalPreview || this.inDataTable) {
|
1506
|
+
if (options.modalPreview || this.inDataTable || options.email) {
|
1491
1507
|
if (this.inDataTable) {
|
1492
1508
|
value = this.undoValueTyping(value);
|
1493
1509
|
}
|