@formio/js 5.1.0-dev.5976.b0f317d → 5.1.0-dev.5976.f61da27
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/dist/formio.builder.css +11 -11
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.form.css +11 -11
- package/dist/formio.form.js +30 -30
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.css +11 -11
- package/dist/formio.full.js +36 -36
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +3 -3
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Form.d.ts +2 -4
- package/lib/cjs/Form.js +3 -1
- package/lib/cjs/PDFBuilder.js +2 -2
- package/lib/cjs/Webform.d.ts +5 -2
- package/lib/cjs/Webform.js +31 -16
- package/lib/cjs/WebformBuilder.d.ts +1 -0
- package/lib/cjs/WebformBuilder.js +14 -3
- package/lib/cjs/Wizard.js +2 -1
- package/lib/cjs/WizardBuilder.js +14 -1
- package/lib/cjs/components/Components.d.ts +3 -0
- package/lib/cjs/components/_classes/component/Component.js +12 -2
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +37 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +13 -2
- package/lib/cjs/components/_classes/component/editForm/utils.d.ts +1 -0
- package/lib/cjs/components/_classes/component/editForm/utils.js +3 -0
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +3 -0
- package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/cjs/components/datetime/DateTime.js +5 -5
- package/lib/cjs/components/day/Day.js +7 -5
- package/lib/cjs/components/file/File.js +2 -1
- package/lib/cjs/components/form/Form.d.ts +4 -2
- package/lib/cjs/components/form/Form.js +25 -10
- package/lib/cjs/components/form/editForm/Form.edit.data.js +1 -1
- package/lib/cjs/components/form/editForm/Form.edit.form.js +2 -2
- package/lib/cjs/components/select/Select.js +1 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -2
- package/lib/cjs/components/tags/Tags.d.ts +1 -1
- package/lib/cjs/components/tags/Tags.js +1 -1
- package/lib/cjs/providers/storage/googleDrive.js +3 -2
- package/lib/cjs/providers/storage/s3.js +3 -3
- package/lib/cjs/providers/storage/xhr.d.ts +1 -0
- package/lib/cjs/providers/storage/xhr.js +6 -1
- package/lib/cjs/utils/ChoicesWrapper.d.ts +1 -1
- package/lib/cjs/utils/ChoicesWrapper.js +1 -1
- package/lib/cjs/utils/utils.d.ts +2 -1
- package/lib/cjs/utils/utils.js +3 -2
- package/lib/cjs/widgets/CalendarWidget.js +0 -14
- package/lib/mjs/Form.d.ts +2 -4
- package/lib/mjs/Form.js +4 -2
- package/lib/mjs/PDFBuilder.js +2 -2
- package/lib/mjs/Webform.d.ts +5 -2
- package/lib/mjs/Webform.js +31 -16
- package/lib/mjs/WebformBuilder.d.ts +1 -0
- package/lib/mjs/WebformBuilder.js +13 -2
- package/lib/mjs/Wizard.js +2 -1
- package/lib/mjs/WizardBuilder.js +14 -1
- package/lib/mjs/components/Components.d.ts +3 -0
- package/lib/mjs/components/_classes/component/Component.js +12 -2
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +37 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +13 -2
- package/lib/mjs/components/_classes/component/editForm/utils.d.ts +1 -0
- package/lib/mjs/components/_classes/component/editForm/utils.js +3 -0
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +3 -0
- package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/mjs/components/datetime/DateTime.js +5 -5
- package/lib/mjs/components/day/Day.js +7 -5
- package/lib/mjs/components/file/File.js +2 -1
- package/lib/mjs/components/form/Form.d.ts +4 -2
- package/lib/mjs/components/form/Form.js +25 -10
- package/lib/mjs/components/form/editForm/Form.edit.data.js +1 -1
- package/lib/mjs/components/form/editForm/Form.edit.form.js +2 -2
- package/lib/mjs/components/select/Select.js +1 -0
- package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -2
- package/lib/mjs/components/tags/Tags.d.ts +1 -1
- package/lib/mjs/components/tags/Tags.js +1 -1
- package/lib/mjs/providers/storage/googleDrive.js +3 -2
- package/lib/mjs/providers/storage/s3.js +3 -3
- package/lib/mjs/providers/storage/xhr.d.ts +1 -0
- package/lib/mjs/providers/storage/xhr.js +6 -1
- package/lib/mjs/utils/ChoicesWrapper.d.ts +1 -1
- package/lib/mjs/utils/ChoicesWrapper.js +1 -1
- package/lib/mjs/utils/utils.d.ts +2 -1
- package/lib/mjs/utils/utils.js +3 -2
- package/lib/mjs/widgets/CalendarWidget.js +0 -14
- package/package.json +2 -2
@@ -87,6 +87,9 @@ declare const _default: ({
|
|
87
87
|
valueProperty?: undefined;
|
88
88
|
data?: undefined;
|
89
89
|
conditional?: undefined;
|
90
|
+
as?: undefined;
|
91
|
+
editor?: undefined;
|
92
|
+
description?: undefined;
|
90
93
|
} | {
|
91
94
|
type: string;
|
92
95
|
label: string;
|
@@ -103,6 +106,9 @@ declare const _default: ({
|
|
103
106
|
valueProperty?: undefined;
|
104
107
|
data?: undefined;
|
105
108
|
conditional?: undefined;
|
109
|
+
as?: undefined;
|
110
|
+
editor?: undefined;
|
111
|
+
description?: undefined;
|
106
112
|
} | {
|
107
113
|
weight: number;
|
108
114
|
type: string;
|
@@ -125,6 +131,9 @@ declare const _default: ({
|
|
125
131
|
valueProperty?: undefined;
|
126
132
|
data?: undefined;
|
127
133
|
conditional?: undefined;
|
134
|
+
as?: undefined;
|
135
|
+
editor?: undefined;
|
136
|
+
description?: undefined;
|
128
137
|
} | {
|
129
138
|
weight: number;
|
130
139
|
type: string;
|
@@ -173,6 +182,9 @@ declare const _default: ({
|
|
173
182
|
valueProperty?: undefined;
|
174
183
|
data?: undefined;
|
175
184
|
conditional?: undefined;
|
185
|
+
as?: undefined;
|
186
|
+
editor?: undefined;
|
187
|
+
description?: undefined;
|
176
188
|
} | {
|
177
189
|
type: string;
|
178
190
|
input: boolean;
|
@@ -200,6 +212,9 @@ declare const _default: ({
|
|
200
212
|
defaultValue?: undefined;
|
201
213
|
values?: undefined;
|
202
214
|
logic?: undefined;
|
215
|
+
as?: undefined;
|
216
|
+
editor?: undefined;
|
217
|
+
description?: undefined;
|
203
218
|
} | {
|
204
219
|
weight: number;
|
205
220
|
type: string;
|
@@ -216,5 +231,27 @@ declare const _default: ({
|
|
216
231
|
valueProperty?: undefined;
|
217
232
|
data?: undefined;
|
218
233
|
conditional?: undefined;
|
234
|
+
as?: undefined;
|
235
|
+
editor?: undefined;
|
236
|
+
description?: undefined;
|
237
|
+
} | {
|
238
|
+
type: string;
|
239
|
+
as: string;
|
240
|
+
editor: string;
|
241
|
+
weight: number;
|
242
|
+
input: boolean;
|
243
|
+
key: string;
|
244
|
+
label: string;
|
245
|
+
tooltip: string;
|
246
|
+
defaultValue: {};
|
247
|
+
description: string;
|
248
|
+
placeholder?: undefined;
|
249
|
+
inline?: undefined;
|
250
|
+
values?: undefined;
|
251
|
+
logic?: undefined;
|
252
|
+
dataSrc?: undefined;
|
253
|
+
valueProperty?: undefined;
|
254
|
+
data?: undefined;
|
255
|
+
conditional?: undefined;
|
219
256
|
})[];
|
220
257
|
export default _default;
|
@@ -135,7 +135,7 @@ export default [
|
|
135
135
|
input: true
|
136
136
|
},
|
137
137
|
EditFormUtils.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 1000, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),
|
138
|
-
EditFormUtils.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="https://help.form.io/userguide/form-building/logic-and-conditions#calculated-values" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>',
|
138
|
+
EditFormUtils.javaScriptValue('Calculated Value', 'calculateValue', 'calculateValue', 1100, '<p><h4>Example:</h4><pre>value = data.a + data.b + data.c;</pre></p>', '<p><h4>Example:</h4><pre>{"+": [{"var": "data.a"}, {"var": "data.b"}, {"var": "data.c"}]}</pre><p><a href="https://help.form.io/userguide/form-building/logic-and-conditions#calculated-values" target="_blank" rel="noopener noreferrer">Click here for an example</a></p>', EditFormUtils.tokenVariableDescription()),
|
139
139
|
{
|
140
140
|
type: 'checkbox',
|
141
141
|
input: true,
|
@@ -152,5 +152,16 @@ export default [
|
|
152
152
|
label: 'Allow Manual Override of Calculated Value',
|
153
153
|
tooltip: 'When checked, this will allow the user to manually override the calculated value.'
|
154
154
|
},
|
155
|
+
{
|
156
|
+
type: 'textarea',
|
157
|
+
as: 'json',
|
158
|
+
editor: 'ace',
|
159
|
+
weight: 1400,
|
160
|
+
input: true,
|
161
|
+
key: 'serverOverride',
|
162
|
+
label: 'Server Override',
|
163
|
+
tooltip: 'A JSON object containing the component settings that should be overriden when the form submission is processed on the server side.',
|
164
|
+
defaultValue: {},
|
165
|
+
description: '<b>Example</b>: { "clearOnHide": true }',
|
166
|
+
}
|
155
167
|
];
|
156
|
-
/* eslint-enable max-len */
|
@@ -2,6 +2,7 @@ export default EditFormUtils;
|
|
2
2
|
declare namespace EditFormUtils {
|
3
3
|
function sortAndFilterComponents(components: any): any;
|
4
4
|
function unifyComponents(objValue: any, srcValue: any): any;
|
5
|
+
function tokenVariableDescription(): string;
|
5
6
|
function logicVariablesTable(additional: any): {
|
6
7
|
type: string;
|
7
8
|
tag: string;
|
@@ -32,6 +32,9 @@ const EditFormUtils = {
|
|
32
32
|
}
|
33
33
|
return _.isEqual(objValue, srcValue);
|
34
34
|
},
|
35
|
+
tokenVariableDescription() {
|
36
|
+
return '<tr><th>token</th><td>The decoded JWT token for the authenticated user.</td></tr>';
|
37
|
+
},
|
35
38
|
logicVariablesTable(additional) {
|
36
39
|
additional = additional || '';
|
37
40
|
return {
|
@@ -3,6 +3,7 @@ export default class NestedDataComponent extends NestedComponent {
|
|
3
3
|
hasChanged(newValue: any, oldValue: any): boolean;
|
4
4
|
get allowData(): boolean;
|
5
5
|
get emptyValue(): {};
|
6
|
+
get shouldAddDefaultValue(): boolean;
|
6
7
|
componentContext(): any;
|
7
8
|
getValueAsString(value: any, options: any): string;
|
8
9
|
getDataValueAsTable(value: any, options: any): string;
|
@@ -22,6 +22,9 @@ export default class NestedDataComponent extends NestedComponent {
|
|
22
22
|
get emptyValue() {
|
23
23
|
return {};
|
24
24
|
}
|
25
|
+
get shouldAddDefaultValue() {
|
26
|
+
return !this.options.noDefaults || !this.options.server;
|
27
|
+
}
|
25
28
|
componentContext() {
|
26
29
|
return this.dataValue;
|
27
30
|
}
|
@@ -20,6 +20,6 @@ export default class DateTimeComponent extends Input {
|
|
20
20
|
get momentFormat(): string;
|
21
21
|
createWrapper(): boolean;
|
22
22
|
checkValidity(data: any, dirty: any, rowData: any): boolean;
|
23
|
-
getValueAsString(value: any): any;
|
23
|
+
getValueAsString(value: any, options: any): any;
|
24
24
|
}
|
25
25
|
import Input from '../_classes/input/Input';
|
@@ -128,8 +128,8 @@ export default class DateTimeComponent extends Input {
|
|
128
128
|
...customOptions,
|
129
129
|
};
|
130
130
|
// update originalComponent to include widget and other updated settings
|
131
|
-
// it is done here since these settings depend on properties present after the component is initialized
|
132
|
-
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
131
|
+
// it is done here since these settings depend on properties present after the component is initialized
|
132
|
+
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
133
133
|
this.originalComponent = fastCloneDeep(this.component);
|
134
134
|
/* eslint-enable camelcase */
|
135
135
|
}
|
@@ -177,15 +177,15 @@ export default class DateTimeComponent extends Input {
|
|
177
177
|
}
|
178
178
|
return super.checkValidity(data, dirty, rowData);
|
179
179
|
}
|
180
|
-
getValueAsString(value) {
|
180
|
+
getValueAsString(value, options) {
|
181
181
|
let format = FormioUtils.convertFormatToMoment(this.component.format);
|
182
182
|
format += format.match(/z$/) ? '' : ' z';
|
183
183
|
const timezone = this.timezone;
|
184
184
|
if (value && !this.attached && timezone) {
|
185
185
|
if (Array.isArray(value) && this.component.multiple) {
|
186
|
-
return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone).format(format))).join(', ');
|
186
|
+
return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone, options).format(format))).join(', ');
|
187
187
|
}
|
188
|
-
return _.trim(FormioUtils.momentDate(value, format, timezone).format(format));
|
188
|
+
return _.trim(FormioUtils.momentDate(value, format, timezone, options).format(format));
|
189
189
|
}
|
190
190
|
if (Array.isArray(value) && this.component.multiple) {
|
191
191
|
return value.map(item => _.trim(moment(item).format(format))).join(', ');
|
@@ -53,11 +53,13 @@ export default class DayComponent extends Field {
|
|
53
53
|
// Empty value used before 9.3.x
|
54
54
|
static oldEmptyValue = '00/00/0000';
|
55
55
|
constructor(component, options, data) {
|
56
|
-
if (
|
57
|
-
component.maxDate
|
58
|
-
|
59
|
-
|
60
|
-
component.minDate
|
56
|
+
if (!options.inFormBuilder && !options.building) {
|
57
|
+
if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
|
58
|
+
component.maxDate = moment(component.maxDate, 'YYYY-MM-DD').toISOString();
|
59
|
+
}
|
60
|
+
if (component.minDate && component.minDate.indexOf('moment(') === -1) {
|
61
|
+
component.minDate = moment(component.minDate, 'YYYY-MM-DD').toISOString();
|
62
|
+
}
|
61
63
|
}
|
62
64
|
super(component, options, data);
|
63
65
|
}
|
@@ -98,7 +98,8 @@ export default class FileComponent extends Field {
|
|
98
98
|
if (this.component.privateDownload) {
|
99
99
|
fileInfo.private = true;
|
100
100
|
}
|
101
|
-
|
101
|
+
// pass the component to the downloadFile method
|
102
|
+
return this.fileService.downloadFile(fileInfo, this.component).then((result) => result.url);
|
102
103
|
}
|
103
104
|
get emptyValue() {
|
104
105
|
return [];
|
@@ -45,16 +45,18 @@ export default class FormComponent extends Component {
|
|
45
45
|
/**
|
46
46
|
* Create a subform instance.
|
47
47
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
48
|
+
* @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
|
48
49
|
* @returns {*} - The subform instance.
|
49
50
|
*/
|
50
|
-
createSubForm(fromAttach?: boolean | undefined): any;
|
51
|
+
createSubForm(fromAttach?: boolean | undefined, beforeSubmit?: boolean | undefined): any;
|
51
52
|
hideSubmitButton(component: any): void;
|
52
53
|
/**
|
53
54
|
* Load the subform.
|
54
55
|
* @param {boolean} fromAttach - This function is being called from an `attach` method.
|
56
|
+
* @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
|
55
57
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
56
58
|
*/
|
57
|
-
loadSubForm(fromAttach: boolean): Promise<any>;
|
59
|
+
loadSubForm(fromAttach: boolean, beforeSubmit: boolean): Promise<any>;
|
58
60
|
subFormLoading: boolean | undefined;
|
59
61
|
checkComponentConditions(data: any, flags: any, row: any): any;
|
60
62
|
calculateValue(data: any, flags: any, row: any): any;
|
@@ -375,10 +375,11 @@ export default class FormComponent extends Component {
|
|
375
375
|
/**
|
376
376
|
* Create a subform instance.
|
377
377
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
378
|
+
* @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
|
378
379
|
* @returns {*} - The subform instance.
|
379
380
|
*/
|
380
|
-
createSubForm(fromAttach) {
|
381
|
-
this.subFormReady = this.loadSubForm(fromAttach).then((form) => {
|
381
|
+
createSubForm(fromAttach, beforeSubmit) {
|
382
|
+
this.subFormReady = this.loadSubForm(fromAttach, beforeSubmit).then((form) => {
|
382
383
|
if (!form) {
|
383
384
|
return;
|
384
385
|
}
|
@@ -435,10 +436,12 @@ export default class FormComponent extends Component {
|
|
435
436
|
/**
|
436
437
|
* Load the subform.
|
437
438
|
* @param {boolean} fromAttach - This function is being called from an `attach` method.
|
439
|
+
* @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
|
438
440
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
439
441
|
*/
|
440
|
-
loadSubForm(fromAttach) {
|
441
|
-
|
442
|
+
loadSubForm(fromAttach, beforeSubmit) {
|
443
|
+
const loadHiddenForm = beforeSubmit && !this.component.clearOnHide;
|
444
|
+
if (this.builderMode || (this.conditionallyHidden && !loadHiddenForm) || (this.isSubFormLazyLoad() && !fromAttach)) {
|
442
445
|
return Promise.resolve();
|
443
446
|
}
|
444
447
|
if (this.hasLoadedForm && !this.isRevisionChanged &&
|
@@ -510,7 +513,7 @@ export default class FormComponent extends Component {
|
|
510
513
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
511
514
|
*/
|
512
515
|
get shouldSubmit() {
|
513
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
|
516
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && (!this.conditionallyHidden || !this.component.clearOnHide);
|
514
517
|
}
|
515
518
|
/**
|
516
519
|
* Returns the data for the subform.
|
@@ -580,11 +583,23 @@ export default class FormComponent extends Component {
|
|
580
583
|
this.dataValue = submission;
|
581
584
|
return Promise.resolve(this.dataValue);
|
582
585
|
}
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
586
|
+
// we need to load a hidden form (when clearOnHide is disabled) in order to get and submit (if needed) its data
|
587
|
+
const loadHiddenForm = !this.subForm && !this.component.clearOnHide;
|
588
|
+
if ((this.isSubFormLazyLoad() || loadHiddenForm) && !this.subFormLoading) {
|
589
|
+
return this.createSubForm(true, true)
|
590
|
+
.then(this.submitSubForm(false))
|
591
|
+
.then(() => {
|
592
|
+
return this.dataValue;
|
593
|
+
})
|
594
|
+
.then(() => super.beforeSubmit());
|
595
|
+
}
|
596
|
+
else {
|
597
|
+
return this.submitSubForm(false)
|
598
|
+
.then(() => {
|
599
|
+
return this.dataValue;
|
600
|
+
})
|
601
|
+
.then(() => super.beforeSubmit());
|
602
|
+
}
|
588
603
|
}
|
589
604
|
isSubFormLazyLoad() {
|
590
605
|
return this.root?._form?.display === 'wizard' && this.component.lazyLoad;
|
@@ -66,7 +66,7 @@ export default [
|
|
66
66
|
input: true,
|
67
67
|
weight: 20,
|
68
68
|
key: 'reference',
|
69
|
-
label: '
|
70
|
-
tooltip: '
|
69
|
+
label: 'Submit as reference',
|
70
|
+
tooltip: 'When "Submit as reference" is enabled, the form submission will be recorded against the Parent Form as well as the Child Form. When a submission recorded with "Submit as reference" is edited, the update is applied to each submission made against the Parent Form and Child Form.'
|
71
71
|
}
|
72
72
|
];
|
@@ -635,8 +635,8 @@ export default [
|
|
635
635
|
input: true,
|
636
636
|
weight: 25,
|
637
637
|
key: 'reference',
|
638
|
-
label: '
|
639
|
-
tooltip: 'Using this option will
|
638
|
+
label: 'Submit as reference',
|
639
|
+
tooltip: 'Using this option will submit this field as a reference id and link its value to the value of the origin record.',
|
640
640
|
conditional: {
|
641
641
|
json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },
|
642
642
|
},
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
|
2
2
|
import Input from '../_classes/input/Input';
|
3
|
-
import Choices from '
|
3
|
+
import Choices from 'choices.js';
|
4
4
|
export default class TagsComponent extends Input {
|
5
5
|
static schema(...extend) {
|
6
6
|
return Input.schema({
|
@@ -50,10 +50,11 @@ function googledrive(formio) {
|
|
50
50
|
xhr.send(fd);
|
51
51
|
}));
|
52
52
|
},
|
53
|
-
downloadFile(file) {
|
53
|
+
downloadFile(file, component) {
|
54
54
|
const token = formio.getToken();
|
55
|
+
// Constructed the url with the fileId, fileName, displayImage, imageSize if applicable
|
55
56
|
file.url =
|
56
|
-
`${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}`;
|
57
|
+
`${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}${component.image ? '&displayImage=true' : ''}${component.imageSize ? `&imageSize=${component.imageSize}` : ''}`;
|
57
58
|
return Promise.resolve(file);
|
58
59
|
},
|
59
60
|
deleteFile: function deleteFile(fileInfo) {
|
@@ -75,7 +75,7 @@ function s3(formio) {
|
|
75
75
|
const { changeMessage } = multipart;
|
76
76
|
changeMessage('Completing AWS S3 multipart upload...');
|
77
77
|
const token = formio.getToken();
|
78
|
-
const response = await fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
|
78
|
+
const response = await XHR.fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
|
79
79
|
method: 'POST',
|
80
80
|
headers: {
|
81
81
|
'Content-Type': 'application/json',
|
@@ -96,7 +96,7 @@ function s3(formio) {
|
|
96
96
|
abortMultipartUpload(serverResponse) {
|
97
97
|
const { uploadId, key } = serverResponse;
|
98
98
|
const token = formio.getToken();
|
99
|
-
fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
|
99
|
+
XHR.fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
|
100
100
|
method: 'POST',
|
101
101
|
headers: {
|
102
102
|
'Content-Type': 'application/json',
|
@@ -113,7 +113,7 @@ function s3(formio) {
|
|
113
113
|
const start = i * partSize;
|
114
114
|
const end = (i + 1) * partSize;
|
115
115
|
const blob = i < urls.length ? file.slice(start, end) : file.slice(start);
|
116
|
-
const promise = fetch(urls[i], {
|
116
|
+
const promise = XHR.fetch(urls[i], {
|
117
117
|
method: 'PUT',
|
118
118
|
headers,
|
119
119
|
body: blob,
|
@@ -3,6 +3,7 @@ export default XHR;
|
|
3
3
|
declare namespace XHR {
|
4
4
|
function trim(text: any): any;
|
5
5
|
function path(items: any): any;
|
6
|
+
function fetch(url: any, options: any): Promise<Response>;
|
6
7
|
function upload(formio: any, type: any, xhrCallback: any, file: any, fileName: any, dir: any, progressCallback: any, groupPermissions: any, groupId: any, abortCallback: any, multipartOptions: any): Promise<any>;
|
7
8
|
function makeXhrRequest(formio: any, xhrCallback: any, serverResponse: any, progressCallback: any, abortCallback: any): Promise<any>;
|
8
9
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import _trim from 'lodash/trim';
|
2
|
+
import { Formio } from '../../Formio';
|
2
3
|
export const setXhrHeaders = (formio, xhr) => {
|
3
4
|
const { headers } = formio.options;
|
4
5
|
if (headers) {
|
@@ -20,12 +21,16 @@ const XHR = {
|
|
20
21
|
path(items) {
|
21
22
|
return items.filter(item => !!item).map(XHR.trim).join('/');
|
22
23
|
},
|
24
|
+
fetch(url, options) {
|
25
|
+
options = Formio.pluginAlter('requestOptions', options, url);
|
26
|
+
return fetch(url, options);
|
27
|
+
},
|
23
28
|
async upload(formio, type, xhrCallback, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback, multipartOptions) {
|
24
29
|
// make request to Form.io server
|
25
30
|
const token = formio.getToken();
|
26
31
|
let response;
|
27
32
|
try {
|
28
|
-
response = await fetch(`${formio.formUrl}/storage/${type}`, {
|
33
|
+
response = await XHR.fetch(`${formio.formUrl}/storage/${type}`, {
|
29
34
|
method: 'POST',
|
30
35
|
headers: {
|
31
36
|
'Accept': 'application/json',
|
package/lib/mjs/utils/utils.d.ts
CHANGED
@@ -208,9 +208,10 @@ export function loadZones(url: string, timezone: string): Promise<any> | any;
|
|
208
208
|
* @param {string|Date} value - The value to convert into a moment date.
|
209
209
|
* @param {string} format - The format to convert the date to.
|
210
210
|
* @param {string} timezone - The timezone to convert the date to.
|
211
|
+
* @param {object} options - The options object
|
211
212
|
* @returns {Date} - The moment date object.
|
212
213
|
*/
|
213
|
-
export function momentDate(value: string | Date, format: string, timezone: string): Date;
|
214
|
+
export function momentDate(value: string | Date, format: string, timezone: string, options: object): Date;
|
214
215
|
/**
|
215
216
|
* Format a date provided a value, format, and timezone object.
|
216
217
|
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
package/lib/mjs/utils/utils.js
CHANGED
@@ -632,9 +632,10 @@ export function loadZones(url, timezone) {
|
|
632
632
|
* @param {string|Date} value - The value to convert into a moment date.
|
633
633
|
* @param {string} format - The format to convert the date to.
|
634
634
|
* @param {string} timezone - The timezone to convert the date to.
|
635
|
+
* @param {object} options - The options object
|
635
636
|
* @returns {Date} - The moment date object.
|
636
637
|
*/
|
637
|
-
export function momentDate(value, format, timezone) {
|
638
|
+
export function momentDate(value, format, timezone, options) {
|
638
639
|
const momentDate = moment(value);
|
639
640
|
if (!timezone) {
|
640
641
|
return momentDate;
|
@@ -642,7 +643,7 @@ export function momentDate(value, format, timezone) {
|
|
642
643
|
if (timezone === 'UTC') {
|
643
644
|
timezone = 'Etc/UTC';
|
644
645
|
}
|
645
|
-
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && moment.zonesLoaded) {
|
646
|
+
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (moment.zonesLoaded || options?.email)) {
|
646
647
|
return momentDate.tz(timezone);
|
647
648
|
}
|
648
649
|
return momentDate;
|
@@ -87,8 +87,6 @@ export default class CalendarWidget extends InputWidget {
|
|
87
87
|
this.settings.disableWeekends ? this.settings.disable.push(this.disableWeekends) : '';
|
88
88
|
this.settings.disableWeekdays ? this.settings.disable.push(this.disableWeekdays) : '';
|
89
89
|
this.settings.disableFunction ? this.settings.disable.push(this.disableFunction) : '';
|
90
|
-
this.settings.wasDefaultValueChanged = false;
|
91
|
-
this.settings.defaultValue = '';
|
92
90
|
this.settings.manualInputValue = '';
|
93
91
|
this.settings.isManuallyOverriddenValue = false;
|
94
92
|
this.settings.currentValue = '';
|
@@ -109,10 +107,6 @@ export default class CalendarWidget extends InputWidget {
|
|
109
107
|
this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
|
110
108
|
this.emit('update');
|
111
109
|
}
|
112
|
-
if (this.settings.wasDefaultValueChanged) {
|
113
|
-
this.calendar._input.value = this.settings.defaultValue;
|
114
|
-
this.settings.wasDefaultValueChanged = false;
|
115
|
-
}
|
116
110
|
if (this.calendar) {
|
117
111
|
this.emit('blur');
|
118
112
|
}
|
@@ -351,14 +345,6 @@ export default class CalendarWidget extends InputWidget {
|
|
351
345
|
this.settings.currentValue = event.target.value;
|
352
346
|
this.emit('update');
|
353
347
|
}
|
354
|
-
if (event.target.value === '' && this.calendar.selectedDates.length > 0) {
|
355
|
-
this.settings.wasDefaultValueChanged = true;
|
356
|
-
this.settings.defaultValue = event.target.value;
|
357
|
-
this.calendar.clear();
|
358
|
-
}
|
359
|
-
else {
|
360
|
-
this.settings.wasDefaultValueChanged = false;
|
361
|
-
}
|
362
348
|
});
|
363
349
|
if (this.calendar.daysContainer) {
|
364
350
|
this.calendar.daysContainer.addEventListener('click', () => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@formio/js",
|
3
|
-
"version": "5.1.0-dev.5976.
|
3
|
+
"version": "5.1.0-dev.5976.f61da27",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"exports": {
|
@@ -81,7 +81,6 @@
|
|
81
81
|
"homepage": "https://github.com/formio/formio.js#readme",
|
82
82
|
"dependencies": {
|
83
83
|
"@formio/bootstrap": "v3.0.0-dev.121.085d187",
|
84
|
-
"@formio/choices.js": "11.0.3-rc.1",
|
85
84
|
"@formio/core": "v2.4.0-dev.2",
|
86
85
|
"@formio/text-mask-addons": "3.8.0-formio.4",
|
87
86
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
@@ -90,6 +89,7 @@
|
|
90
89
|
"bootstrap": "^5.3.3",
|
91
90
|
"browser-cookies": "^1.2.0",
|
92
91
|
"browser-md5-file": "^1.1.1",
|
92
|
+
"choices.js": "^11.0.6",
|
93
93
|
"compare-versions": "^6.1.1",
|
94
94
|
"core-js": "^3.37.1",
|
95
95
|
"dialog-polyfill": "^0.5.6",
|