@formio/js 5.4.0-api98.1 → 5.4.0
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 +15 -0
- 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 +15 -0
- package/dist/formio.form.js +917 -897
- 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 +15 -0
- package/dist/formio.full.js +1211 -1191
- 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 +832 -812
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +2 -2
- package/dist/formio.utils.js +774 -754
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -2
- package/lib/cjs/Element.d.ts +11 -0
- package/lib/cjs/Element.js +24 -0
- package/lib/cjs/Embed.js +23 -2
- package/lib/cjs/Form.d.ts +1 -1
- package/lib/cjs/Formio.js +1 -1
- package/lib/cjs/PDFBuilder.js +6 -1
- package/lib/cjs/Webform.d.ts +1 -1
- package/lib/cjs/Webform.js +9 -6
- package/lib/cjs/WebformBuilder.js +14 -1
- package/lib/cjs/Wizard.js +15 -11
- package/lib/cjs/components/Components.d.ts +3 -0
- package/lib/cjs/components/Components.js +3 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +8 -0
- package/lib/cjs/components/_classes/component/Component.js +121 -42
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +1 -1
- 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/nested/NestedComponent.js +5 -7
- package/lib/cjs/components/address/Address.js +2 -0
- package/lib/cjs/components/datagrid/DataGrid.js +31 -5
- package/lib/cjs/components/datamap/DataMap.d.ts +1 -4
- package/lib/cjs/components/datamap/DataMap.js +42 -10
- package/lib/cjs/components/datetime/DateTime.js +11 -1
- package/lib/cjs/components/datetime/editForm/DateTime.edit.date.d.ts +18 -1
- package/lib/cjs/components/datetime/editForm/DateTime.edit.date.js +3 -0
- package/lib/cjs/components/datetime/editForm/DateTime.edit.time.d.ts +13 -2
- package/lib/cjs/components/datetime/editForm/DateTime.edit.time.js +3 -0
- package/lib/cjs/components/day/Day.d.ts +0 -15
- package/lib/cjs/components/day/Day.js +8 -17
- package/lib/cjs/components/editgrid/EditGrid.js +13 -3
- package/lib/cjs/components/file/File.js +7 -6
- package/lib/cjs/components/form/Form.d.ts +1 -0
- package/lib/cjs/components/form/Form.js +20 -8
- package/lib/cjs/components/number/Number.d.ts +1 -0
- package/lib/cjs/components/number/Number.js +18 -0
- package/lib/cjs/components/select/Select.js +4 -0
- package/lib/cjs/components/signature/Signature.js +5 -5
- package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
- package/lib/cjs/components/signature/editForm/Signature.edit.display.js +0 -1
- package/lib/cjs/components/textfield/editForm/TextField.edit.display.d.ts +0 -10
- package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +9 -23
- package/lib/cjs/formio.form.js +2 -5
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/providers/storage/azure.js +9 -3
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/index.d.ts +3 -3
- package/lib/cjs/utils/utils.d.ts +1 -1
- package/lib/cjs/utils/utils.js +23 -6
- package/lib/cjs/widgets/CalendarWidget.js +1 -1
- package/lib/mjs/Element.d.ts +11 -0
- package/lib/mjs/Element.js +23 -0
- package/lib/mjs/Embed.js +21 -2
- package/lib/mjs/Form.d.ts +1 -1
- package/lib/mjs/Formio.js +1 -1
- package/lib/mjs/PDFBuilder.js +6 -1
- package/lib/mjs/Webform.d.ts +1 -1
- package/lib/mjs/Webform.js +6 -3
- package/lib/mjs/WebformBuilder.js +13 -1
- package/lib/mjs/Wizard.js +9 -10
- package/lib/mjs/components/Components.d.ts +3 -0
- package/lib/mjs/components/Components.js +3 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +8 -0
- package/lib/mjs/components/_classes/component/Component.js +119 -41
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +1 -1
- 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/nested/NestedComponent.js +5 -6
- package/lib/mjs/components/address/Address.js +2 -0
- package/lib/mjs/components/datagrid/DataGrid.js +34 -5
- package/lib/mjs/components/datamap/DataMap.d.ts +1 -4
- package/lib/mjs/components/datamap/DataMap.js +41 -10
- package/lib/mjs/components/datetime/DateTime.js +11 -1
- package/lib/mjs/components/datetime/editForm/DateTime.edit.date.d.ts +18 -1
- package/lib/mjs/components/datetime/editForm/DateTime.edit.date.js +3 -0
- package/lib/mjs/components/datetime/editForm/DateTime.edit.time.d.ts +13 -2
- package/lib/mjs/components/datetime/editForm/DateTime.edit.time.js +3 -0
- package/lib/mjs/components/day/Day.d.ts +0 -15
- package/lib/mjs/components/day/Day.js +8 -17
- package/lib/mjs/components/editgrid/EditGrid.js +12 -2
- package/lib/mjs/components/file/File.js +7 -6
- package/lib/mjs/components/form/Form.d.ts +1 -0
- package/lib/mjs/components/form/Form.js +18 -6
- package/lib/mjs/components/number/Number.d.ts +1 -0
- package/lib/mjs/components/number/Number.js +17 -0
- package/lib/mjs/components/select/Select.js +4 -0
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
- package/lib/mjs/components/signature/editForm/Signature.edit.display.js +0 -1
- package/lib/mjs/components/textfield/editForm/TextField.edit.display.d.ts +0 -10
- package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +9 -23
- package/lib/mjs/formio.form.js +4 -7
- package/lib/mjs/package.json +1 -1
- package/lib/mjs/providers/storage/azure.js +9 -3
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/index.d.ts +3 -3
- package/lib/mjs/utils/utils.d.ts +1 -1
- package/lib/mjs/utils/utils.js +22 -6
- package/lib/mjs/widgets/CalendarWidget.js +2 -2
- package/package.json +7 -6
|
@@ -166,25 +166,19 @@ export default class DayComponent extends Field {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
get days() {
|
|
169
|
-
|
|
170
|
-
return this._days;
|
|
171
|
-
}
|
|
172
|
-
this._days = [
|
|
169
|
+
const days = [
|
|
173
170
|
{ value: '', label: _.get(this.component, 'fields.day.placeholder', '') },
|
|
174
171
|
];
|
|
175
172
|
for (let x = 1; x <= 31; x++) {
|
|
176
|
-
|
|
173
|
+
days.push({
|
|
177
174
|
value: x,
|
|
178
175
|
label: x.toString(),
|
|
179
176
|
});
|
|
180
177
|
}
|
|
181
|
-
return
|
|
178
|
+
return days;
|
|
182
179
|
}
|
|
183
180
|
get months() {
|
|
184
|
-
|
|
185
|
-
return this._months;
|
|
186
|
-
}
|
|
187
|
-
this._months = [
|
|
181
|
+
const months = [
|
|
188
182
|
{
|
|
189
183
|
value: '',
|
|
190
184
|
label: _.get(this.component, 'fields.month.placeholder') ||
|
|
@@ -203,24 +197,21 @@ export default class DayComponent extends Field {
|
|
|
203
197
|
{ value: 11, label: 'November' },
|
|
204
198
|
{ value: 12, label: 'December' },
|
|
205
199
|
];
|
|
206
|
-
return
|
|
200
|
+
return months;
|
|
207
201
|
}
|
|
208
202
|
get years() {
|
|
209
|
-
|
|
210
|
-
return this._years;
|
|
211
|
-
}
|
|
212
|
-
this._years = [
|
|
203
|
+
const years = [
|
|
213
204
|
{ value: '', label: _.get(this.component, 'fields.year.placeholder', '') },
|
|
214
205
|
];
|
|
215
206
|
const minYears = _.get(this.component, 'fields.year.minYear', 1900) || 1900;
|
|
216
207
|
const maxYears = _.get(this.component, 'fields.year.maxYear', 2030) || 2030;
|
|
217
208
|
for (let x = minYears; x <= maxYears; x++) {
|
|
218
|
-
|
|
209
|
+
years.push({
|
|
219
210
|
value: x,
|
|
220
211
|
label: x.toString(),
|
|
221
212
|
});
|
|
222
213
|
}
|
|
223
|
-
return
|
|
214
|
+
return years;
|
|
224
215
|
}
|
|
225
216
|
setErrorClasses(elements, dirty, hasError) {
|
|
226
217
|
super.setErrorClasses(elements, dirty, hasError);
|
|
@@ -538,7 +538,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
538
538
|
isVisibleInRow: (component) => this.isComponentVisibleInRow(component, flattenedComponents),
|
|
539
539
|
getView: (component, data) => {
|
|
540
540
|
const instance = flattenedComponents[component.key];
|
|
541
|
-
const view = instance ? instance.getView(
|
|
541
|
+
const view = instance ? instance.getView(instance.dataValue) : '';
|
|
542
542
|
// If there is an html tag in view, don't allow it to be injected in template
|
|
543
543
|
const htmlTagRegExp = new RegExp('<(.*?)>');
|
|
544
544
|
return typeof view === 'string' &&
|
|
@@ -859,7 +859,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
859
859
|
if (this.component.rowDrafts) {
|
|
860
860
|
editRow.components.forEach((comp) => comp.setPristine(this.pristine));
|
|
861
861
|
}
|
|
862
|
-
this.checkValidity(null,
|
|
862
|
+
this.checkValidity(null, !this.component.rowDrafts || this.root?.submitted);
|
|
863
863
|
this.redraw();
|
|
864
864
|
if (editRow.alerts) {
|
|
865
865
|
editRow.alerts = false;
|
|
@@ -948,9 +948,19 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
948
948
|
}
|
|
949
949
|
const column = _.clone(col);
|
|
950
950
|
const options = _.clone(this.options);
|
|
951
|
+
const rootSubmissionTz = _.get(this.root, 'options.submissionTimezone');
|
|
952
|
+
if (rootSubmissionTz && !options.submissionTimezone) {
|
|
953
|
+
options.submissionTimezone = rootSubmissionTz;
|
|
954
|
+
}
|
|
951
955
|
options.name += `[${rowIndex}]`;
|
|
952
956
|
options.row = `${rowIndex}-${colIndex}`;
|
|
953
957
|
options.rowIndex = rowIndex;
|
|
958
|
+
if (this.submissionTimezone) {
|
|
959
|
+
options.submissionTimezone = this.submissionTimezone;
|
|
960
|
+
if (column.type === 'datetime') {
|
|
961
|
+
column.widget = { ...column.widget, submissionTimezone: this.submissionTimezone };
|
|
962
|
+
}
|
|
963
|
+
}
|
|
954
964
|
options.onChange = (flags = {}, changed, modified) => {
|
|
955
965
|
if (changed.instance.root?.id && this.root?.id !== changed.instance.root.id) {
|
|
956
966
|
changed.instance.root?.triggerChange?.(flags, changed, modified);
|
|
@@ -963,16 +963,17 @@ export default class FileComponent extends Field {
|
|
|
963
963
|
: false;
|
|
964
964
|
}
|
|
965
965
|
async uploadFile(fileToSync) {
|
|
966
|
-
|
|
966
|
+
const filePromise = this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
|
|
967
967
|
// Progress callback
|
|
968
968
|
this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
|
|
969
|
-
this.emit('fileUploadingStart');
|
|
969
|
+
this.emit('fileUploadingStart', filePromise);
|
|
970
970
|
},
|
|
971
971
|
// Abort upload callback
|
|
972
972
|
(abort) => this.abortUploads.push({
|
|
973
973
|
id: fileToSync.id,
|
|
974
974
|
abort,
|
|
975
975
|
}), this.getMultipartOptions(fileToSync));
|
|
976
|
+
return await filePromise;
|
|
976
977
|
}
|
|
977
978
|
async upload() {
|
|
978
979
|
if (!this.filesToSync.filesToUpload.length) {
|
|
@@ -1008,7 +1009,7 @@ export default class FileComponent extends Field {
|
|
|
1008
1009
|
fileToSync.message = this.t('Succefully uploaded');
|
|
1009
1010
|
fileInfo.originalName = fileToSync.originalName;
|
|
1010
1011
|
fileInfo.hash = fileToSync.hash;
|
|
1011
|
-
this.emit('fileUploadingEnd');
|
|
1012
|
+
this.emit('fileUploadingEnd', Promise.resolve(fileInfo));
|
|
1012
1013
|
}
|
|
1013
1014
|
catch (response) {
|
|
1014
1015
|
fileToSync.status = 'error';
|
|
@@ -1019,8 +1020,8 @@ export default class FileComponent extends Field {
|
|
|
1019
1020
|
: response.type === 'abort'
|
|
1020
1021
|
? this.t('Request was aborted')
|
|
1021
1022
|
: response.toString();
|
|
1022
|
-
this.emit('fileUploadingEnd');
|
|
1023
|
-
this.emit('fileUploadError', {
|
|
1023
|
+
this.emit('fileUploadingEnd', Promise.reject(response));
|
|
1024
|
+
this.emit(_.get(response, 'type') === 'abort' ? 'fileUploadCanceled' : 'fileUploadError', {
|
|
1024
1025
|
fileToSync,
|
|
1025
1026
|
response,
|
|
1026
1027
|
});
|
|
@@ -1029,7 +1030,7 @@ export default class FileComponent extends Field {
|
|
|
1029
1030
|
delete fileToSync.progress;
|
|
1030
1031
|
this.redraw();
|
|
1031
1032
|
const fileExists = this.resolvedFiles.find(x => x.fileInfo.originalName === fileToSync.originalName);
|
|
1032
|
-
if (!fileExists) {
|
|
1033
|
+
if (!fileExists && fileToSync.status !== 'error') {
|
|
1033
1034
|
this.resolvedFiles.push({ fileToSync, fileInfo });
|
|
1034
1035
|
}
|
|
1035
1036
|
}
|
|
@@ -42,6 +42,7 @@ export default class FormComponent extends Component {
|
|
|
42
42
|
everyComponent(...args: any[]): any;
|
|
43
43
|
setSubFormDisabled(subForm: any): void;
|
|
44
44
|
updateSubWizards(subForm: any): void;
|
|
45
|
+
updateTopLevelComponentsMap(): void;
|
|
45
46
|
setComponentsMap(): void;
|
|
46
47
|
/**
|
|
47
48
|
* Create a subform instance.
|
|
@@ -393,13 +393,22 @@ export default class FormComponent extends Component {
|
|
|
393
393
|
this.emit('subWizardsUpdated', subForm);
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
|
+
updateTopLevelComponentsMap() {
|
|
397
|
+
let prevRootId = null;
|
|
398
|
+
let currentRoot = this.root;
|
|
399
|
+
const subFormComponentMap = this.subForm.componentsMap;
|
|
400
|
+
// update components map for all top forms
|
|
401
|
+
while (currentRoot && prevRootId !== currentRoot.id) {
|
|
402
|
+
_.assign(currentRoot.componentsMap, subFormComponentMap);
|
|
403
|
+
prevRootId = currentRoot.id;
|
|
404
|
+
currentRoot = currentRoot.root;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
396
407
|
setComponentsMap() {
|
|
397
408
|
if (!this.subForm) {
|
|
398
409
|
return;
|
|
399
410
|
}
|
|
400
|
-
|
|
401
|
-
const formComponentsMap = this.subForm.componentsMap;
|
|
402
|
-
_.assign(componentsMap, formComponentsMap);
|
|
411
|
+
this.updateTopLevelComponentsMap();
|
|
403
412
|
}
|
|
404
413
|
/**
|
|
405
414
|
* Create a subform instance.
|
|
@@ -428,7 +437,7 @@ export default class FormComponent extends Component {
|
|
|
428
437
|
this.subForm.currentForm = this;
|
|
429
438
|
this.subForm.parentVisible = this.visible;
|
|
430
439
|
this.setComponentsMap();
|
|
431
|
-
this.component.components = this.subForm.
|
|
440
|
+
this.component.components = this.subForm.components.map((comp) => comp.component);
|
|
432
441
|
this.component.display = this.subForm._form?.display;
|
|
433
442
|
this.subForm.on('change', () => {
|
|
434
443
|
if (this.subForm && !this.shouldConditionallyClear()) {
|
|
@@ -552,10 +561,11 @@ export default class FormComponent extends Component {
|
|
|
552
561
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
|
553
562
|
*/
|
|
554
563
|
get shouldSubmit() {
|
|
564
|
+
const hiddenByJsonOnly = !this.hasCondition() && this.component.hidden;
|
|
555
565
|
return (this.subFormReady &&
|
|
556
566
|
(!this.component.hasOwnProperty('reference') || this.component.reference) &&
|
|
557
567
|
!this.shouldConditionallyClear() &&
|
|
558
|
-
!(
|
|
568
|
+
!(hiddenByJsonOnly && this.component.clearOnHide));
|
|
559
569
|
}
|
|
560
570
|
/**
|
|
561
571
|
* Returns the data for the subform.
|
|
@@ -760,7 +770,9 @@ export default class FormComponent extends Component {
|
|
|
760
770
|
}
|
|
761
771
|
this.updateSubFormVisibility();
|
|
762
772
|
this.clearOnHide();
|
|
763
|
-
|
|
773
|
+
if (!isNestedWizard) {
|
|
774
|
+
this.redraw();
|
|
775
|
+
}
|
|
764
776
|
}
|
|
765
777
|
if (!value && isNestedWizard) {
|
|
766
778
|
this.root?.redraw();
|
|
@@ -34,6 +34,7 @@ export default class NumberComponent extends Input {
|
|
|
34
34
|
* @returns {number} a parsed number
|
|
35
35
|
*/
|
|
36
36
|
parseNumber(value: string): number;
|
|
37
|
+
normalizeValue(value: any, flags?: {}, emptyValue?: null): any;
|
|
37
38
|
setInputMask(input: any): void;
|
|
38
39
|
getValueAt(index: any): number | null;
|
|
39
40
|
setValueAt(index: any, value: any, flags?: {}): void;
|
|
@@ -141,6 +141,23 @@ export default class NumberComponent extends Input {
|
|
|
141
141
|
return parseFloat(value);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
+
normalizeValue(value, flags = {}, emptyValue = this.emptyValue) {
|
|
145
|
+
if (typeof value === 'string') {
|
|
146
|
+
const result = this.parseNumber(value);
|
|
147
|
+
value = _.isNaN(result) ? this.emptyValue : result;
|
|
148
|
+
}
|
|
149
|
+
if (this.component?.multiple && Array.isArray(value)) {
|
|
150
|
+
const normilizedValues = value.map((val) => {
|
|
151
|
+
if (typeof val === 'string') {
|
|
152
|
+
const result = this.parseNumber(val);
|
|
153
|
+
return _.isNaN(result) ? this.emptyValue : result;
|
|
154
|
+
}
|
|
155
|
+
return val;
|
|
156
|
+
});
|
|
157
|
+
value = normilizedValues;
|
|
158
|
+
}
|
|
159
|
+
return super.normalizeValue(value, flags, emptyValue);
|
|
160
|
+
}
|
|
144
161
|
setInputMask(input) {
|
|
145
162
|
let numberPattern = '[0-9';
|
|
146
163
|
numberPattern += this.decimalSeparator || '';
|
|
@@ -1366,6 +1366,10 @@ export default class SelectComponent extends ListComponent {
|
|
|
1366
1366
|
}
|
|
1367
1367
|
_.set(submission.metadata.selectData, this.path, templateData);
|
|
1368
1368
|
}
|
|
1369
|
+
else if (!this.templateData[templateValue] &&
|
|
1370
|
+
this.isEmpty(value)) {
|
|
1371
|
+
_.unset(this.root.submission, `metadata.selectData.${this.path}`);
|
|
1372
|
+
}
|
|
1369
1373
|
if (flags.resetValue && this.root?.submission && !this.options.readOnly) {
|
|
1370
1374
|
const submission = this.root.submission;
|
|
1371
1375
|
if (!submission.metadata) {
|
|
@@ -57,7 +57,7 @@ export default class SignatureComponent extends Input {
|
|
|
57
57
|
this.component.height = '200px';
|
|
58
58
|
}
|
|
59
59
|
if (this.component.keepOverlayRatio &&
|
|
60
|
-
this.options
|
|
60
|
+
this.options.pdf &&
|
|
61
61
|
this.component.overlay?.width &&
|
|
62
62
|
this.component.overlay?.height) {
|
|
63
63
|
this.ratio = this.component.overlay?.width / this.component.overlay?.height;
|
|
@@ -7,7 +7,6 @@ declare const _default: ({
|
|
|
7
7
|
placeholder: string;
|
|
8
8
|
weight: number;
|
|
9
9
|
conditional?: undefined;
|
|
10
|
-
customConditional?: undefined;
|
|
11
10
|
ignore?: undefined;
|
|
12
11
|
} | {
|
|
13
12
|
type: string;
|
|
@@ -24,7 +23,6 @@ declare const _default: ({
|
|
|
24
23
|
};
|
|
25
24
|
};
|
|
26
25
|
weight: number;
|
|
27
|
-
customConditional?: undefined;
|
|
28
26
|
ignore?: undefined;
|
|
29
27
|
} | {
|
|
30
28
|
weight: number;
|
|
@@ -32,9 +30,6 @@ declare const _default: ({
|
|
|
32
30
|
label: string;
|
|
33
31
|
tooltip: string;
|
|
34
32
|
key: string;
|
|
35
|
-
customConditional: ({ options }: {
|
|
36
|
-
options: any;
|
|
37
|
-
}) => boolean;
|
|
38
33
|
input: boolean;
|
|
39
34
|
placeholder?: undefined;
|
|
40
35
|
conditional?: undefined;
|
|
@@ -49,6 +44,5 @@ declare const _default: ({
|
|
|
49
44
|
placeholder?: undefined;
|
|
50
45
|
weight?: undefined;
|
|
51
46
|
conditional?: undefined;
|
|
52
|
-
customConditional?: undefined;
|
|
53
47
|
})[];
|
|
54
48
|
export default _default;
|
|
@@ -46,7 +46,6 @@ export default [
|
|
|
46
46
|
label: 'Keep Overlay Aspect Ratio',
|
|
47
47
|
tooltip: 'If checked, the field will have the same aspect ratio as its preview.',
|
|
48
48
|
key: 'keepOverlayRatio',
|
|
49
|
-
customConditional: ({ options }) => options?.editForm?.display === 'pdf',
|
|
50
49
|
input: true,
|
|
51
50
|
},
|
|
52
51
|
{
|
|
@@ -25,7 +25,6 @@ declare const _default: ({
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
clearOnHide?: undefined;
|
|
28
|
-
customDefaultValue?: undefined;
|
|
29
28
|
rows?: undefined;
|
|
30
29
|
editor?: undefined;
|
|
31
30
|
as?: undefined;
|
|
@@ -40,7 +39,6 @@ declare const _default: ({
|
|
|
40
39
|
label: string;
|
|
41
40
|
clearOnHide: boolean;
|
|
42
41
|
onChange: (context: any) => void;
|
|
43
|
-
customDefaultValue: (value: any, component: any, row: any, data: any, instance: any) => any;
|
|
44
42
|
input: boolean;
|
|
45
43
|
rows: number;
|
|
46
44
|
editor: string;
|
|
@@ -79,7 +77,6 @@ declare const _default: ({
|
|
|
79
77
|
data?: undefined;
|
|
80
78
|
conditional?: undefined;
|
|
81
79
|
clearOnHide?: undefined;
|
|
82
|
-
customDefaultValue?: undefined;
|
|
83
80
|
rows?: undefined;
|
|
84
81
|
editor?: undefined;
|
|
85
82
|
as?: undefined;
|
|
@@ -107,7 +104,6 @@ declare const _default: ({
|
|
|
107
104
|
onChange?: undefined;
|
|
108
105
|
conditional?: undefined;
|
|
109
106
|
clearOnHide?: undefined;
|
|
110
|
-
customDefaultValue?: undefined;
|
|
111
107
|
rows?: undefined;
|
|
112
108
|
editor?: undefined;
|
|
113
109
|
as?: undefined;
|
|
@@ -133,7 +129,6 @@ declare const _default: ({
|
|
|
133
129
|
data?: undefined;
|
|
134
130
|
conditional?: undefined;
|
|
135
131
|
clearOnHide?: undefined;
|
|
136
|
-
customDefaultValue?: undefined;
|
|
137
132
|
rows?: undefined;
|
|
138
133
|
editor?: undefined;
|
|
139
134
|
as?: undefined;
|
|
@@ -154,7 +149,6 @@ declare const _default: ({
|
|
|
154
149
|
data?: undefined;
|
|
155
150
|
conditional?: undefined;
|
|
156
151
|
clearOnHide?: undefined;
|
|
157
|
-
customDefaultValue?: undefined;
|
|
158
152
|
rows?: undefined;
|
|
159
153
|
editor?: undefined;
|
|
160
154
|
as?: undefined;
|
|
@@ -177,7 +171,6 @@ declare const _default: ({
|
|
|
177
171
|
data?: undefined;
|
|
178
172
|
conditional?: undefined;
|
|
179
173
|
clearOnHide?: undefined;
|
|
180
|
-
customDefaultValue?: undefined;
|
|
181
174
|
rows?: undefined;
|
|
182
175
|
editor?: undefined;
|
|
183
176
|
as?: undefined;
|
|
@@ -208,7 +201,6 @@ declare const _default: ({
|
|
|
208
201
|
data?: undefined;
|
|
209
202
|
conditional?: undefined;
|
|
210
203
|
clearOnHide?: undefined;
|
|
211
|
-
customDefaultValue?: undefined;
|
|
212
204
|
rows?: undefined;
|
|
213
205
|
editor?: undefined;
|
|
214
206
|
as?: undefined;
|
|
@@ -228,7 +220,6 @@ declare const _default: ({
|
|
|
228
220
|
data?: undefined;
|
|
229
221
|
conditional?: undefined;
|
|
230
222
|
clearOnHide?: undefined;
|
|
231
|
-
customDefaultValue?: undefined;
|
|
232
223
|
rows?: undefined;
|
|
233
224
|
editor?: undefined;
|
|
234
225
|
as?: undefined;
|
|
@@ -251,7 +242,6 @@ declare const _default: ({
|
|
|
251
242
|
data?: undefined;
|
|
252
243
|
conditional?: undefined;
|
|
253
244
|
clearOnHide?: undefined;
|
|
254
|
-
customDefaultValue?: undefined;
|
|
255
245
|
rows?: undefined;
|
|
256
246
|
editor?: undefined;
|
|
257
247
|
as?: undefined;
|
|
@@ -14,30 +14,30 @@ export default [
|
|
|
14
14
|
tooltip: 'The widget is the display UI used to input the value of the field.',
|
|
15
15
|
defaultValue: 'input',
|
|
16
16
|
calculateValue: (context) => {
|
|
17
|
-
let currentType = context.
|
|
17
|
+
let currentType = context.instance._widgetType;
|
|
18
18
|
if (currentType) {
|
|
19
19
|
return currentType;
|
|
20
20
|
}
|
|
21
21
|
const widget = context.data.widget;
|
|
22
22
|
if (isObject(widget) && widget.type) {
|
|
23
|
-
context.
|
|
23
|
+
context.instance._widgetType = widget.type;
|
|
24
24
|
return widget.type;
|
|
25
25
|
}
|
|
26
26
|
if (typeof widget === 'string') {
|
|
27
27
|
const originalType = getOriginalWidget(context.instance)?.type;
|
|
28
28
|
if (originalType) {
|
|
29
|
-
context.
|
|
29
|
+
context.instance._widgetType = originalType;
|
|
30
30
|
return originalType;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
return 'input';
|
|
34
34
|
},
|
|
35
35
|
onChange: (context) => {
|
|
36
|
-
const newType = context.
|
|
36
|
+
const newType = context.instance.dataValue;
|
|
37
37
|
const currentWidget = context.data.widget;
|
|
38
38
|
let oldType;
|
|
39
39
|
if (isObject(currentWidget)) {
|
|
40
|
-
oldType =
|
|
40
|
+
oldType = context.instance._widgetType;
|
|
41
41
|
}
|
|
42
42
|
else if (typeof currentWidget === 'string') {
|
|
43
43
|
oldType = getOriginalWidget(context.instance)?.type;
|
|
@@ -48,10 +48,12 @@ export default [
|
|
|
48
48
|
if (newType !== oldType) {
|
|
49
49
|
if (newType === 'input') {
|
|
50
50
|
context.data.widget = { type: 'input' };
|
|
51
|
+
context.instance._widgetType = newType;
|
|
51
52
|
}
|
|
52
|
-
else {
|
|
53
|
+
else if (newType) {
|
|
53
54
|
const defaultSettings = getDefaultWidgetSettings(newType);
|
|
54
55
|
context.data.widget = defaultSettings || { type: newType };
|
|
56
|
+
context.instance._widgetType = newType;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
else if (!currentWidget) {
|
|
@@ -87,28 +89,12 @@ export default [
|
|
|
87
89
|
return;
|
|
88
90
|
}
|
|
89
91
|
if (isObject(currentWidget)) {
|
|
90
|
-
const currentType = context.
|
|
92
|
+
const currentType = context.instance.root.getComponent('widget.type')._widgetType || currentWidget.type;
|
|
91
93
|
if (currentType && currentWidget.type !== currentType) {
|
|
92
94
|
context.data.widget = { ...currentWidget, type: currentType };
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
},
|
|
96
|
-
customDefaultValue: (value, component, row, data, instance) => {
|
|
97
|
-
if (!data.widget) {
|
|
98
|
-
const originalWidget = getOriginalWidget(instance);
|
|
99
|
-
const widgetType = data['widget.type'] || originalWidget?.type;
|
|
100
|
-
if (widgetType && widgetType !== 'input') {
|
|
101
|
-
if (originalWidget?.type === widgetType && !_.isEmpty(_.omit(originalWidget, 'type'))) {
|
|
102
|
-
return _.omit(originalWidget, 'language');
|
|
103
|
-
}
|
|
104
|
-
const defaultSettings = getDefaultWidgetSettings(widgetType);
|
|
105
|
-
if (defaultSettings) {
|
|
106
|
-
return defaultSettings;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return value;
|
|
111
|
-
},
|
|
112
98
|
input: true,
|
|
113
99
|
rows: 5,
|
|
114
100
|
editor: 'ace',
|
package/lib/mjs/formio.form.js
CHANGED
|
@@ -7,7 +7,7 @@ import Templates from './templates/Templates';
|
|
|
7
7
|
import Providers from './providers';
|
|
8
8
|
import Widgets from './widgets';
|
|
9
9
|
import Form, { FormOptions } from './Form';
|
|
10
|
-
import Utils, { Evaluator, registerEvaluator
|
|
10
|
+
import Utils, { DefaultEvaluator, Evaluator, registerEvaluator } from './utils';
|
|
11
11
|
import Licenses from './licenses';
|
|
12
12
|
import EventEmitter from './EventEmitter';
|
|
13
13
|
import Webform from './Webform';
|
|
@@ -90,12 +90,9 @@ export function registerModule(mod, defaultFn = null, options = {}) {
|
|
|
90
90
|
break;
|
|
91
91
|
default:
|
|
92
92
|
if (defaultFn) {
|
|
93
|
-
|
|
94
|
-
console.warn('Unknown module option', key);
|
|
95
|
-
}
|
|
93
|
+
defaultFn(key, mod);
|
|
96
94
|
break;
|
|
97
95
|
}
|
|
98
|
-
console.log('Unknown module option', key);
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
98
|
}
|
|
@@ -108,7 +105,7 @@ export function useModule(defaultFn = null) {
|
|
|
108
105
|
plugins = _.isArray(plugins)
|
|
109
106
|
? plugins
|
|
110
107
|
: [
|
|
111
|
-
plugins
|
|
108
|
+
plugins
|
|
112
109
|
];
|
|
113
110
|
plugins.forEach((plugin) => {
|
|
114
111
|
if (Array.isArray(plugin)) {
|
|
@@ -129,4 +126,4 @@ export function useModule(defaultFn = null) {
|
|
|
129
126
|
Formio.use = useModule();
|
|
130
127
|
export { Formio as FormioCore } from './Formio';
|
|
131
128
|
// Export the components.
|
|
132
|
-
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator, FormOptions
|
|
129
|
+
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator, FormOptions };
|
package/lib/mjs/package.json
CHANGED
|
@@ -30,9 +30,15 @@ function azure(formio) {
|
|
|
30
30
|
downloadFile(file) {
|
|
31
31
|
return formio.makeRequest('file', `${formio.formUrl}/storage/azure?name=${XHR.trim(file.name)}`, 'GET');
|
|
32
32
|
},
|
|
33
|
-
deleteFile
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
deleteFile(fileInfo, options) {
|
|
34
|
+
const name = XHR.trim(fileInfo.name);
|
|
35
|
+
const key = XHR.trim(fileInfo.key);
|
|
36
|
+
return formio.makeRequest('', `${formio.formUrl}/storage/azure?name=${encodeURIComponent(name)}&key=${encodeURIComponent(key)}`, 'delete').then((response) => {
|
|
37
|
+
return {
|
|
38
|
+
success: true,
|
|
39
|
+
key: response?.key || key,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
36
42
|
},
|
|
37
43
|
};
|
|
38
44
|
}
|
|
@@ -26,8 +26,8 @@ export const getBestMatch: typeof Utils.getBestMatch;
|
|
|
26
26
|
export const getComponentFromPath: typeof Utils.getComponentFromPath;
|
|
27
27
|
export const getComponentValue: typeof Utils.getComponentValue;
|
|
28
28
|
export const findComponents: typeof Utils.findComponents;
|
|
29
|
-
export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined) => Promise<void>;
|
|
30
|
-
export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined) => void;
|
|
29
|
+
export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined, localRoot?: import("@formio/core").LocalRoot | undefined) => Promise<void>;
|
|
30
|
+
export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined, localRoot?: import("@formio/core").LocalRoot | undefined) => void;
|
|
31
31
|
export const getComponentKey: typeof Utils.getComponentKey;
|
|
32
32
|
export const getContextualRowPath: any;
|
|
33
33
|
export const getContextualRowData: typeof Utils.getContextualRowData;
|
package/lib/mjs/utils/index.d.ts
CHANGED
|
@@ -37,8 +37,8 @@ declare const FormioUtils: {
|
|
|
37
37
|
getComponentFromPath: typeof import("@formio/core/lib/utils/formUtil").getComponentFromPath;
|
|
38
38
|
getComponentValue: typeof import("@formio/core/lib/utils/formUtil").getComponentValue;
|
|
39
39
|
findComponents: typeof import("@formio/core/lib/utils/formUtil").findComponents;
|
|
40
|
-
eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined) => Promise<void>;
|
|
41
|
-
eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined) => void;
|
|
40
|
+
eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined, localRoot?: import("@formio/core").LocalRoot | undefined) => Promise<void>;
|
|
41
|
+
eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined, localRoot?: import("@formio/core").LocalRoot | undefined) => void;
|
|
42
42
|
getComponentKey: typeof import("@formio/core/lib/utils/formUtil").getComponentKey;
|
|
43
43
|
getContextualRowPath: any;
|
|
44
44
|
getContextualRowData: typeof import("@formio/core/lib/utils/formUtil").getContextualRowData;
|
|
@@ -94,7 +94,7 @@ declare const FormioUtils: {
|
|
|
94
94
|
offsetDate(date: Date, timezone: string): Date;
|
|
95
95
|
zonesLoaded(): boolean;
|
|
96
96
|
shouldLoadZones(timezone: string): boolean;
|
|
97
|
-
loadZones(url: string,
|
|
97
|
+
loadZones(url: string, _timezone: any): any;
|
|
98
98
|
momentDate(value: string | Date, format: string, timezone: string, options: object): Date;
|
|
99
99
|
formatDate(timezonesUrl: string, value: string | Date, format: string, timezone: string, flatPickrInputFormat: string): string;
|
|
100
100
|
formatOffset(timezonesUrl: string, formatFn: Function, date: string | Date, format: string, timezone: string): string;
|
package/lib/mjs/utils/utils.d.ts
CHANGED
|
@@ -202,7 +202,7 @@ export function shouldLoadZones(timezone: string): boolean;
|
|
|
202
202
|
* @param {string} timezone - The timezone to load.
|
|
203
203
|
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
|
204
204
|
*/
|
|
205
|
-
export function loadZones(url: string,
|
|
205
|
+
export function loadZones(url: string, _timezone: any): Promise<any> | any;
|
|
206
206
|
/**
|
|
207
207
|
* Get the moment date object for translating dates with timezones.
|
|
208
208
|
* @param {string|Date} value - The value to convert into a moment date.
|
package/lib/mjs/utils/utils.js
CHANGED
|
@@ -217,6 +217,16 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
|
217
217
|
}
|
|
218
218
|
else {
|
|
219
219
|
const value = getComponentActualValue(conditionComponentPath, data, row);
|
|
220
|
+
// When inside a DataGrid/EditGrid, construct a row-indexed path so that
|
|
221
|
+
// operators like isEmpty can look up the correct row's component instance.
|
|
222
|
+
let operatorPath = conditionComponentPath;
|
|
223
|
+
const dataParent = getDataParentComponent(instance);
|
|
224
|
+
if (dataParent && !_.isNil(instance?.rowIndex)) {
|
|
225
|
+
const parentPath = dataParent.paths?.localPath;
|
|
226
|
+
if (parentPath && conditionComponentPath.startsWith(`${parentPath}.`)) {
|
|
227
|
+
operatorPath = conditionComponentPath.replace(`${parentPath}.`, `${parentPath}[${instance.rowIndex}].`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
220
230
|
const СonditionOperator = ConditionOperators[operator];
|
|
221
231
|
return СonditionOperator
|
|
222
232
|
? new СonditionOperator().getResult({
|
|
@@ -224,7 +234,7 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
|
224
234
|
comparedValue,
|
|
225
235
|
instance,
|
|
226
236
|
component,
|
|
227
|
-
path:
|
|
237
|
+
path: operatorPath,
|
|
228
238
|
})
|
|
229
239
|
: true;
|
|
230
240
|
}
|
|
@@ -275,7 +285,11 @@ export function getComponentActualValue(compPath, data, row) {
|
|
|
275
285
|
*/
|
|
276
286
|
export function checkCustomConditional(component, custom, row, data, form, variable, onError, instance) {
|
|
277
287
|
if (typeof custom === 'string') {
|
|
278
|
-
custom = `
|
|
288
|
+
custom = `
|
|
289
|
+
var ${variable} = true;
|
|
290
|
+
${custom};
|
|
291
|
+
return ${variable};
|
|
292
|
+
`;
|
|
279
293
|
}
|
|
280
294
|
const value = instance && instance.evaluate
|
|
281
295
|
? instance.evaluate(custom, { row, data, form })
|
|
@@ -606,14 +620,16 @@ export function shouldLoadZones(timezone) {
|
|
|
606
620
|
* @param {string} timezone - The timezone to load.
|
|
607
621
|
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
|
608
622
|
*/
|
|
609
|
-
export function loadZones(url,
|
|
610
|
-
if (
|
|
611
|
-
|
|
612
|
-
return new Promise(_.noop);
|
|
623
|
+
export function loadZones(url, _timezone) {
|
|
624
|
+
if (moment.zonesLoaded) {
|
|
625
|
+
return Promise.resolve();
|
|
613
626
|
}
|
|
614
627
|
if (moment.zonesPromise) {
|
|
615
628
|
return moment.zonesPromise;
|
|
616
629
|
}
|
|
630
|
+
// Always load the full packed dataset once. The previous optimization skipped fetch when the
|
|
631
|
+
// display timezone matched the runtime zone, but moment-timezone still needs `tz.load()` for
|
|
632
|
+
// `.tz(ianaName)` and `z` formatting to work; otherwise conversions silently match server local time.
|
|
617
633
|
return (moment.zonesPromise = fetch(url).then((resp) => resp.json().then((zones) => {
|
|
618
634
|
moment.tz.load(zones);
|
|
619
635
|
moment.zonesLoaded = true;
|