@formio/js 5.3.2 → 5.3.4
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.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.js +922 -922
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +2 -2
- package/dist/formio.full.js +1201 -1201
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +2 -2
- package/dist/formio.js +841 -841
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +2 -2
- package/dist/formio.utils.js +786 -786
- 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 +1 -1
- package/lib/cjs/Formio.js +1 -1
- package/lib/cjs/Webform.js +7 -4
- package/lib/cjs/Wizard.js +15 -11
- package/lib/cjs/components/Components.js +9 -1
- package/lib/cjs/components/_classes/component/Component.js +13 -18
- package/lib/cjs/components/_classes/nested/NestedComponent.js +9 -6
- package/lib/cjs/components/datagrid/DataGrid.js +3 -2
- package/lib/cjs/components/editgrid/EditGrid.js +2 -2
- package/lib/cjs/components/file/File.js +6 -5
- package/lib/cjs/components/form/Form.d.ts +1 -0
- package/lib/cjs/components/form/Form.js +18 -7
- 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/package.json +1 -1
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/index.d.ts +2 -2
- package/lib/mjs/Element.d.ts +11 -0
- package/lib/mjs/Element.js +23 -0
- package/lib/mjs/Embed.js +1 -1
- package/lib/mjs/Formio.js +1 -1
- package/lib/mjs/Webform.js +5 -1
- package/lib/mjs/Wizard.js +9 -10
- package/lib/mjs/components/Components.js +9 -1
- package/lib/mjs/components/_classes/component/Component.js +12 -18
- package/lib/mjs/components/_classes/nested/NestedComponent.js +8 -5
- package/lib/mjs/components/datagrid/DataGrid.js +3 -2
- package/lib/mjs/components/editgrid/EditGrid.js +1 -1
- package/lib/mjs/components/file/File.js +6 -5
- package/lib/mjs/components/form/Form.d.ts +1 -0
- package/lib/mjs/components/form/Form.js +16 -5
- 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/package.json +1 -1
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/index.d.ts +2 -2
- package/package.json +2 -2
package/lib/cjs/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;
|
package/lib/mjs/Element.d.ts
CHANGED
|
@@ -210,6 +210,17 @@ export default class Element {
|
|
|
210
210
|
* @returns {this} - The instance of the element.
|
|
211
211
|
*/
|
|
212
212
|
removeClass(element: HTMLElement, className: string): this;
|
|
213
|
+
/**
|
|
214
|
+
* Idempotently add or remove a class on a DOM element based on a boolean.
|
|
215
|
+
* Skips the mutation when the element is already in the desired state, so
|
|
216
|
+
* callers can safely invoke it on every change without triggering redundant
|
|
217
|
+
* CSS transitions or attribute writes.
|
|
218
|
+
* @param {HTMLElement} element - The DOM element to toggle the class on.
|
|
219
|
+
* @param {string} className - The class name to add or remove.
|
|
220
|
+
* @param {boolean} want - TRUE to ensure the class is present, FALSE to ensure it is absent.
|
|
221
|
+
* @returns {this} - The instance of the element.
|
|
222
|
+
*/
|
|
223
|
+
toggleClass(element: HTMLElement, className: string, want: boolean): this;
|
|
213
224
|
/**
|
|
214
225
|
* Empty's an HTML DOM element.
|
|
215
226
|
* @param {HTMLElement} element - The element you wish to empty.
|
package/lib/mjs/Element.js
CHANGED
|
@@ -477,6 +477,29 @@ export default class Element {
|
|
|
477
477
|
}
|
|
478
478
|
return this;
|
|
479
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* Idempotently add or remove a class on a DOM element based on a boolean.
|
|
482
|
+
* Skips the mutation when the element is already in the desired state, so
|
|
483
|
+
* callers can safely invoke it on every change without triggering redundant
|
|
484
|
+
* CSS transitions or attribute writes.
|
|
485
|
+
* @param {HTMLElement} element - The DOM element to toggle the class on.
|
|
486
|
+
* @param {string} className - The class name to add or remove.
|
|
487
|
+
* @param {boolean} want - TRUE to ensure the class is present, FALSE to ensure it is absent.
|
|
488
|
+
* @returns {this} - The instance of the element.
|
|
489
|
+
*/
|
|
490
|
+
toggleClass(element, className, want) {
|
|
491
|
+
if (!element || !className || !(element instanceof HTMLElement)) {
|
|
492
|
+
return this;
|
|
493
|
+
}
|
|
494
|
+
const has = !!element.classList?.contains(className);
|
|
495
|
+
if (want && !has) {
|
|
496
|
+
this.addClass(element, className);
|
|
497
|
+
}
|
|
498
|
+
else if (!want && has) {
|
|
499
|
+
this.removeClass(element, className);
|
|
500
|
+
}
|
|
501
|
+
return this;
|
|
502
|
+
}
|
|
480
503
|
/**
|
|
481
504
|
* Empty's an HTML DOM element.
|
|
482
505
|
* @param {HTMLElement} element - The element you wish to empty.
|
package/lib/mjs/Embed.js
CHANGED
|
@@ -14,7 +14,7 @@ export class Formio {
|
|
|
14
14
|
Formio._formioReady = ready;
|
|
15
15
|
Formio._formioReadyReject = reject;
|
|
16
16
|
});
|
|
17
|
-
static version = '5.3.
|
|
17
|
+
static version = '5.3.4';
|
|
18
18
|
static setLicense(license, norecurse = false) {
|
|
19
19
|
Formio.license = license;
|
|
20
20
|
if (!norecurse && Formio.FormioClass) {
|
package/lib/mjs/Formio.js
CHANGED
|
@@ -4,7 +4,7 @@ import CDN from './CDN';
|
|
|
4
4
|
import Providers from './providers';
|
|
5
5
|
FormioCore.cdn = new CDN();
|
|
6
6
|
FormioCore.Providers = Providers;
|
|
7
|
-
FormioCore.version = '5.3.
|
|
7
|
+
FormioCore.version = '5.3.4';
|
|
8
8
|
CDN.defaultCDN = FormioCore.version.includes('rc')
|
|
9
9
|
? 'https://cdn.test-form.io'
|
|
10
10
|
: 'https://cdn.form.io';
|
package/lib/mjs/Webform.js
CHANGED
|
@@ -1094,7 +1094,10 @@ export default class Webform extends NestedDataComponent {
|
|
|
1094
1094
|
});
|
|
1095
1095
|
}
|
|
1096
1096
|
const errorsList = this.renderTemplate('errorsList', { errors: displayedErrors });
|
|
1097
|
-
|
|
1097
|
+
// Only paint the alert from a subform when the root won't double paint it to avoid a painful flicker
|
|
1098
|
+
if (this === this.root || !this.root?.submitted) {
|
|
1099
|
+
this.root?.setAlert('danger', errorsList);
|
|
1100
|
+
}
|
|
1098
1101
|
if (triggerEvent) {
|
|
1099
1102
|
this.emit('error', errors);
|
|
1100
1103
|
}
|
|
@@ -1215,6 +1218,7 @@ export default class Webform extends NestedDataComponent {
|
|
|
1215
1218
|
...flags,
|
|
1216
1219
|
noValidate: false,
|
|
1217
1220
|
process: 'change',
|
|
1221
|
+
dirty: flags.dirty ?? this.submitted,
|
|
1218
1222
|
})
|
|
1219
1223
|
: [];
|
|
1220
1224
|
value.isValid = (errors || []).filter((err) => !err.fromServer).length === 0;
|
package/lib/mjs/Wizard.js
CHANGED
|
@@ -200,7 +200,7 @@ export default class Wizard extends Webform {
|
|
|
200
200
|
wizardNav,
|
|
201
201
|
components: this.renderComponents([
|
|
202
202
|
...this.prefixComps,
|
|
203
|
-
...this.currentPage
|
|
203
|
+
...this.currentPage?.components || [],
|
|
204
204
|
...this.suffixComps,
|
|
205
205
|
]),
|
|
206
206
|
}, this.builderMode ? 'builder' : 'form');
|
|
@@ -262,7 +262,7 @@ export default class Wizard extends Webform {
|
|
|
262
262
|
this.hook('attachWebform', element, this);
|
|
263
263
|
const promises = this.attachComponents(this.refs[this.wizardKey], [
|
|
264
264
|
...this.prefixComps,
|
|
265
|
-
...this.currentPage
|
|
265
|
+
...this.currentPage?.components || [],
|
|
266
266
|
...this.suffixComps,
|
|
267
267
|
]);
|
|
268
268
|
this.attachNav();
|
|
@@ -289,7 +289,7 @@ export default class Wizard extends Webform {
|
|
|
289
289
|
isBreadcrumbClickable() {
|
|
290
290
|
let currentPage = null;
|
|
291
291
|
this.pages.map((page) => {
|
|
292
|
-
if (_.isEqual(this.currentPage
|
|
292
|
+
if (_.isEqual(this.currentPage?.component, page.component)) {
|
|
293
293
|
currentPage = page;
|
|
294
294
|
}
|
|
295
295
|
});
|
|
@@ -304,11 +304,11 @@ export default class Wizard extends Webform {
|
|
|
304
304
|
isAllowPrevious() {
|
|
305
305
|
let currentPage = null;
|
|
306
306
|
this.pages.map((page) => {
|
|
307
|
-
if (_.isEqual(this.currentPage
|
|
307
|
+
if (_.isEqual(this.currentPage?.component, page.component)) {
|
|
308
308
|
currentPage = page;
|
|
309
309
|
}
|
|
310
310
|
});
|
|
311
|
-
return _.get(currentPage
|
|
311
|
+
return _.get(currentPage?.component, 'allowPrevious', this.options.allowPrevious);
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
314
314
|
* Handles navigate on 'Enter' key event in a wizard form.
|
|
@@ -537,7 +537,7 @@ export default class Wizard extends Webform {
|
|
|
537
537
|
const forceShow = this.shouldForceShow(item);
|
|
538
538
|
const forceHide = this.shouldForceHide(item);
|
|
539
539
|
let isVisible = !page
|
|
540
|
-
? checkCondition(item, data, data, this.component, this) && !item.hidden
|
|
540
|
+
? (checkCondition(item, data, data, this.component, this) && !item.hidden)
|
|
541
541
|
: page.visible;
|
|
542
542
|
if (forceShow) {
|
|
543
543
|
isVisible = true;
|
|
@@ -608,7 +608,7 @@ export default class Wizard extends Webform {
|
|
|
608
608
|
}
|
|
609
609
|
return this.redraw().then(() => {
|
|
610
610
|
this.checkData(this.submission.data);
|
|
611
|
-
this.triggerCaptcha(this.currentPage
|
|
611
|
+
this.triggerCaptcha(this.currentPage?.components);
|
|
612
612
|
const errors = this.submitted
|
|
613
613
|
? this.validate(this.localData, { dirty: true })
|
|
614
614
|
: this.validateCurrentPage();
|
|
@@ -822,8 +822,7 @@ export default class Wizard extends Webform {
|
|
|
822
822
|
return super.setForm(form, flags);
|
|
823
823
|
}
|
|
824
824
|
onSetForm(clonedForm, initialForm) {
|
|
825
|
-
this.component.components =
|
|
826
|
-
(this.parent ? initialForm.components : clonedForm.components) || [];
|
|
825
|
+
this.component.components = (this.parent ? initialForm.components : clonedForm.components) || [];
|
|
827
826
|
this.setComponentSchema();
|
|
828
827
|
}
|
|
829
828
|
setEditMode(submission) {
|
|
@@ -936,7 +935,7 @@ export default class Wizard extends Webform {
|
|
|
936
935
|
this.setCustomValidity('');
|
|
937
936
|
return true;
|
|
938
937
|
}
|
|
939
|
-
const components = !currentPageOnly || this.isLastPage() ? this.getComponents() : this.currentPage
|
|
938
|
+
const components = !currentPageOnly || this.isLastPage() ? this.getComponents() : this.currentPage?.components;
|
|
940
939
|
return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
|
|
941
940
|
}
|
|
942
941
|
get errors() {
|
|
@@ -66,7 +66,15 @@ export default class Components {
|
|
|
66
66
|
comp = new Component(component, options, data);
|
|
67
67
|
}
|
|
68
68
|
if (comp.path) {
|
|
69
|
-
|
|
69
|
+
let currentRoot = comp.root;
|
|
70
|
+
let prevRootId = null;
|
|
71
|
+
while (currentRoot && currentRoot.id !== prevRootId) {
|
|
72
|
+
if (currentRoot.childComponentsMap) {
|
|
73
|
+
currentRoot.childComponentsMap[comp.path] = comp;
|
|
74
|
+
}
|
|
75
|
+
prevRootId = currentRoot.id;
|
|
76
|
+
currentRoot = currentRoot.root;
|
|
77
|
+
}
|
|
70
78
|
}
|
|
71
79
|
// Reset the componentMatches on the root element if any new component is created.
|
|
72
80
|
let parent = comp.parent;
|
|
@@ -2266,29 +2266,23 @@ export default class Component extends Element {
|
|
|
2266
2266
|
* @returns {void}
|
|
2267
2267
|
*/
|
|
2268
2268
|
setErrorClasses(elements, dirty, hasErrors, hasMessages, element = this.element) {
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
this.setElementInvalid(this.performInputMapping(element), hasErrors);
|
|
2269
|
+
elements.forEach((el) => {
|
|
2270
|
+
this.setElementInvalid(this.performInputMapping(el), hasErrors);
|
|
2272
2271
|
});
|
|
2273
2272
|
this.setInputWidgetErrorClasses(elements, hasErrors);
|
|
2274
2273
|
// do not set error classes for hidden components
|
|
2275
2274
|
if (!this.visible) {
|
|
2275
|
+
this.clearErrorClasses(element);
|
|
2276
2276
|
return;
|
|
2277
2277
|
}
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
else {
|
|
2287
|
-
this.addClass(element, 'has-error');
|
|
2288
|
-
}
|
|
2289
|
-
}
|
|
2290
|
-
if (hasMessages) {
|
|
2291
|
-
this.addClass(element, 'has-message');
|
|
2278
|
+
const wantHighlight = hasErrors && !!dirty && !!this.options.highlightErrors;
|
|
2279
|
+
const wantHasError = hasErrors && !wantHighlight;
|
|
2280
|
+
this.toggleClass(element, this.options.componentErrorClass, wantHighlight);
|
|
2281
|
+
this.toggleClass(element, 'has-error', wantHasError);
|
|
2282
|
+
this.toggleClass(element, 'has-message', hasMessages);
|
|
2283
|
+
// Preserve previous clearErrorClasses() behavior: drop the 'alert alert-danger' pair if left over.
|
|
2284
|
+
if (element?.classList?.contains('alert-danger')) {
|
|
2285
|
+
this.removeClass(element, 'alert alert-danger');
|
|
2292
2286
|
}
|
|
2293
2287
|
}
|
|
2294
2288
|
/**
|
|
@@ -3182,7 +3176,7 @@ export default class Component extends Element {
|
|
|
3182
3176
|
if (flags.silentCheck) {
|
|
3183
3177
|
return [];
|
|
3184
3178
|
}
|
|
3185
|
-
let isDirty = flags.dirty
|
|
3179
|
+
let isDirty = flags.dirty || this.dirty;
|
|
3186
3180
|
if (this.options.alwaysDirty) {
|
|
3187
3181
|
isDirty = true;
|
|
3188
3182
|
}
|
|
@@ -556,11 +556,14 @@ export default class NestedComponent extends Field {
|
|
|
556
556
|
components = components || this.components;
|
|
557
557
|
component.destroy(all);
|
|
558
558
|
_.remove(components, { id: component.id });
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
559
|
+
let currentRoot = component.root;
|
|
560
|
+
let prevRootId = null;
|
|
561
|
+
while (currentRoot && currentRoot.id !== prevRootId) {
|
|
562
|
+
if (currentRoot.childComponentsMap?.[component.path]) {
|
|
563
|
+
delete currentRoot.childComponentsMap[component.path];
|
|
564
|
+
}
|
|
565
|
+
prevRootId = currentRoot.id;
|
|
566
|
+
currentRoot = currentRoot.root;
|
|
564
567
|
}
|
|
565
568
|
}
|
|
566
569
|
/**
|
|
@@ -530,8 +530,9 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
530
530
|
options.row = `${rowIndex}-${colIndex}`;
|
|
531
531
|
options.rowIndex = rowIndex;
|
|
532
532
|
options.onChange = (flags, changed, modified) => {
|
|
533
|
-
|
|
534
|
-
|
|
533
|
+
const changedComponent = changed.component;
|
|
534
|
+
if (changedComponent?.type === 'form' && changedComponent?.key) {
|
|
535
|
+
const formComp = getComponent(this.component.components, changedComponent.key);
|
|
535
536
|
_.set(formComp, 'components', changed.component.components);
|
|
536
537
|
}
|
|
537
538
|
// If we're in a nested form we need to ensure our changes are triggered upstream
|
|
@@ -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;
|
|
@@ -941,16 +941,17 @@ export default class FileComponent extends Field {
|
|
|
941
941
|
: false;
|
|
942
942
|
}
|
|
943
943
|
async uploadFile(fileToSync) {
|
|
944
|
-
|
|
944
|
+
const filePromise = this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
|
|
945
945
|
// Progress callback
|
|
946
946
|
this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
|
|
947
|
-
this.emit('fileUploadingStart');
|
|
947
|
+
this.emit('fileUploadingStart', filePromise);
|
|
948
948
|
},
|
|
949
949
|
// Abort upload callback
|
|
950
950
|
(abort) => this.abortUploads.push({
|
|
951
951
|
id: fileToSync.id,
|
|
952
952
|
abort,
|
|
953
953
|
}), this.getMultipartOptions(fileToSync));
|
|
954
|
+
return await filePromise;
|
|
954
955
|
}
|
|
955
956
|
async upload() {
|
|
956
957
|
if (!this.filesToSync.filesToUpload.length) {
|
|
@@ -970,7 +971,7 @@ export default class FileComponent extends Field {
|
|
|
970
971
|
fileToSync.message = this.t('Succefully uploaded');
|
|
971
972
|
fileInfo.originalName = fileToSync.originalName;
|
|
972
973
|
fileInfo.hash = fileToSync.hash;
|
|
973
|
-
this.emit('fileUploadingEnd');
|
|
974
|
+
this.emit('fileUploadingEnd', Promise.resolve(fileInfo));
|
|
974
975
|
}
|
|
975
976
|
catch (response) {
|
|
976
977
|
fileToSync.status = 'error';
|
|
@@ -981,8 +982,8 @@ export default class FileComponent extends Field {
|
|
|
981
982
|
: response.type === 'abort'
|
|
982
983
|
? this.t('Request was aborted')
|
|
983
984
|
: response.toString();
|
|
984
|
-
this.emit('fileUploadingEnd');
|
|
985
|
-
this.emit('fileUploadError', {
|
|
985
|
+
this.emit('fileUploadingEnd', Promise.reject(response));
|
|
986
|
+
this.emit(_.get(response, 'type') === 'abort' ? 'fileUploadCanceled' : 'fileUploadError', {
|
|
986
987
|
fileToSync,
|
|
987
988
|
response,
|
|
988
989
|
});
|
|
@@ -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()) {
|
|
@@ -759,7 +768,9 @@ export default class FormComponent extends Component {
|
|
|
759
768
|
}
|
|
760
769
|
this.updateSubFormVisibility();
|
|
761
770
|
this.clearOnHide();
|
|
762
|
-
|
|
771
|
+
if (!isNestedWizard) {
|
|
772
|
+
this.redraw();
|
|
773
|
+
}
|
|
763
774
|
}
|
|
764
775
|
if (!value && isNestedWizard) {
|
|
765
776
|
this.root?.redraw();
|
|
@@ -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/package.json
CHANGED
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/js",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.4",
|
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"uuid": "^9.0.0",
|
|
90
90
|
"vanilla-picker": "^2.12.3",
|
|
91
91
|
"@formio/bootstrap": "^3.2.2",
|
|
92
|
-
"@formio/core": "^2.6.
|
|
92
|
+
"@formio/core": "^2.6.4"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@types/node": "^22.15.19",
|