@formio/js 5.1.0-dev.6194.87d4d3f → 5.1.0-dev.6204.b833c7c
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.form.js +31 -53
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +32 -54
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +20 -42
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +20 -42
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Webform.js +8 -0
- package/lib/cjs/WebformBuilder.js +11 -3
- package/lib/cjs/Wizard.js +7 -6
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +5 -5
- package/lib/cjs/components/datagrid/DataGrid.js +8 -1
- package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -2
- package/lib/cjs/components/form/Form.d.ts +1 -1
- package/lib/cjs/components/form/Form.js +22 -17
- package/lib/cjs/components/radio/Radio.js +1 -1
- package/lib/cjs/components/tags/Tags.js +7 -0
- package/lib/cjs/utils/formUtils.d.ts +3 -3
- package/lib/cjs/utils/index.d.ts +3 -3
- package/lib/cjs/widgets/CalendarWidget.js +8 -1
- package/lib/mjs/Webform.js +8 -0
- package/lib/mjs/WebformBuilder.js +11 -3
- package/lib/mjs/Wizard.js +7 -6
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +4 -5
- package/lib/mjs/components/datagrid/DataGrid.js +7 -1
- package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -2
- package/lib/mjs/components/form/Form.d.ts +1 -1
- package/lib/mjs/components/form/Form.js +22 -17
- package/lib/mjs/components/radio/Radio.js +1 -1
- package/lib/mjs/components/tags/Tags.js +7 -0
- package/lib/mjs/utils/formUtils.d.ts +3 -3
- package/lib/mjs/utils/index.d.ts +3 -3
- package/lib/mjs/widgets/CalendarWidget.js +8 -1
- package/package.json +2 -2
package/lib/cjs/Webform.js
CHANGED
@@ -361,6 +361,14 @@ class Webform extends NestedDataComponent_1.default {
|
|
361
361
|
get shadowRoot() {
|
362
362
|
return this.options.shadowRoot;
|
363
363
|
}
|
364
|
+
// Webforms have no default value setting, so this should be always false
|
365
|
+
// I does not affect setting default value to nested forms
|
366
|
+
get shouldAddDefaultValue() {
|
367
|
+
return false;
|
368
|
+
}
|
369
|
+
get componentsMap() {
|
370
|
+
return this.childComponentsMap || {};
|
371
|
+
}
|
364
372
|
/**
|
365
373
|
* Add a language for translations
|
366
374
|
* @param {string} code - The language code for the language being added.
|
@@ -83,8 +83,16 @@ class WebformBuilder extends Component_1.default {
|
|
83
83
|
}
|
84
84
|
this.groupOrder = this.groupOrder
|
85
85
|
.filter(group => group && !group.ignore)
|
86
|
-
.sort((a, b) => a.weight - b.weight)
|
87
|
-
|
86
|
+
.sort((a, b) => a.weight - b.weight);
|
87
|
+
const defaultOpenedGroup = this.groupOrder.find(x => x.key !== 'basic' && x.default);
|
88
|
+
if (defaultOpenedGroup) {
|
89
|
+
this.groupOrder.forEach(x => {
|
90
|
+
if ('default' in x && x.key !== defaultOpenedGroup.key) {
|
91
|
+
x.default = false;
|
92
|
+
}
|
93
|
+
});
|
94
|
+
}
|
95
|
+
this.groupOrder = this.groupOrder.map(group => group.key);
|
88
96
|
for (const type in Components_1.default.components) {
|
89
97
|
const component = Components_1.default.components[type];
|
90
98
|
if (component.builderInfo && component.builderInfo.schema) {
|
@@ -1099,7 +1107,7 @@ class WebformBuilder extends Component_1.default {
|
|
1099
1107
|
const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
|
1100
1108
|
lodash_1.default.pull(newComp.validators, 'required');
|
1101
1109
|
parentComponent.tabs[tabIndex].splice(index, 1, newComp);
|
1102
|
-
newComp.
|
1110
|
+
newComp.processOwnValidation = true;
|
1103
1111
|
newComp.build(defaultValueComponent.element);
|
1104
1112
|
if (this.preview && !this.preview.defaultChanged) {
|
1105
1113
|
const defaultValue = lodash_1.default.get(this.preview._data, this.editForm._data.key);
|
package/lib/cjs/Wizard.js
CHANGED
@@ -599,7 +599,7 @@ class Wizard extends Webform_1.default {
|
|
599
599
|
if (!this._seenPages.includes(parentNum)) {
|
600
600
|
this._seenPages = this._seenPages.concat(parentNum);
|
601
601
|
}
|
602
|
-
this.redraw().then(() => {
|
602
|
+
return this.redraw().then(() => {
|
603
603
|
this.checkData(this.submission.data);
|
604
604
|
this.triggerCaptcha(this.currentPage.components);
|
605
605
|
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
@@ -607,7 +607,6 @@ class Wizard extends Webform_1.default {
|
|
607
607
|
this.showErrors(errors, true, true);
|
608
608
|
}
|
609
609
|
});
|
610
|
-
return Promise.resolve();
|
611
610
|
}
|
612
611
|
else if (!this.pages.length) {
|
613
612
|
this.redraw();
|
@@ -821,6 +820,11 @@ class Wizard extends Webform_1.default {
|
|
821
820
|
}
|
822
821
|
}
|
823
822
|
setValue(submission, flags = {}, ignoreEstablishment) {
|
823
|
+
if (!submission || !submission.data) {
|
824
|
+
submission = {
|
825
|
+
data: {},
|
826
|
+
};
|
827
|
+
}
|
824
828
|
const changed = this.getPages({ all: true }).reduce((changed, page) => {
|
825
829
|
return this.setNestedValue(page, submission.data, flags, changed) || changed;
|
826
830
|
}, false);
|
@@ -931,10 +935,7 @@ class Wizard extends Webform_1.default {
|
|
931
935
|
if (pageIndex >= 0) {
|
932
936
|
const page = this.pages[pageIndex];
|
933
937
|
if (page && page !== this.currentPage) {
|
934
|
-
return this.setPage(pageIndex).then(() =>
|
935
|
-
this.showErrors(this.validate(this.localData, { dirty: true }));
|
936
|
-
super.focusOnComponent(key);
|
937
|
-
});
|
938
|
+
return this.setPage(pageIndex).then(() => super.focusOnComponent(key));
|
938
939
|
}
|
939
940
|
}
|
940
941
|
}
|
@@ -155,7 +155,7 @@ export default class NestedComponent extends Field {
|
|
155
155
|
* @param {import('@formio/core').Component[]} components - The components to attach logic to.
|
156
156
|
*/
|
157
157
|
attachComponentsLogic(components: import('@formio/core').Component[]): void;
|
158
|
-
attachComponents(element: any, components: any, container: any): Promise<any>;
|
158
|
+
attachComponents(element: any, components: any, container: any): Promise<void> | Promise<any[]>;
|
159
159
|
/**
|
160
160
|
* Remove a component from the components array and from the children object
|
161
161
|
* @param {import('@formio/core').Component} component - The component to remove from the components.
|
@@ -538,8 +538,7 @@ class NestedComponent extends Field_1.default {
|
|
538
538
|
container = container || this.component.components;
|
539
539
|
element = this.hook('attachComponents', element, components, container, this);
|
540
540
|
if (!element) {
|
541
|
-
|
542
|
-
return (new Promise(() => { }));
|
541
|
+
return Promise.resolve();
|
543
542
|
}
|
544
543
|
let index = 0;
|
545
544
|
const promises = [];
|
@@ -558,12 +557,16 @@ class NestedComponent extends Field_1.default {
|
|
558
557
|
* @param {boolean} [all] - If set to TRUE will cascade remove all components.
|
559
558
|
*/
|
560
559
|
removeComponent(component, components, all = false) {
|
560
|
+
var _a, _b;
|
561
561
|
components = components || this.components;
|
562
562
|
component.destroy(all);
|
563
563
|
lodash_1.default.remove(components, { id: component.id });
|
564
564
|
if (this.componentsMap[component.path]) {
|
565
565
|
delete this.componentsMap[component.path];
|
566
566
|
}
|
567
|
+
if ((_a = this.root) === null || _a === void 0 ? void 0 : _a.componentsMap[component.path]) {
|
568
|
+
(_b = this.root) === null || _b === void 0 ? true : delete _b.componentsMap[component.path];
|
569
|
+
}
|
567
570
|
}
|
568
571
|
/**
|
569
572
|
* Removes a component provided the API key of that component.
|
@@ -838,9 +841,6 @@ class NestedComponent extends Field_1.default {
|
|
838
841
|
}
|
839
842
|
}
|
840
843
|
setValue(value, flags = {}) {
|
841
|
-
if (!value) {
|
842
|
-
return false;
|
843
|
-
}
|
844
844
|
// If the value is equal to the empty value, then this means we need to reset the values.
|
845
845
|
if (lodash_1.default.isEqual(value, this.emptyValue)) {
|
846
846
|
// TO-DO: For a future major release, we need to investigate removing the need for the
|
@@ -496,11 +496,18 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
496
496
|
options.row = `${rowIndex}-${colIndex}`;
|
497
497
|
options.rowIndex = rowIndex;
|
498
498
|
options.onChange = (flags, changed, modified) => {
|
499
|
+
var _a, _b;
|
499
500
|
if (changed.component.type === 'form') {
|
500
501
|
const formComp = (0, utils_1.getComponent)(this.component.components, changed.component.key);
|
501
502
|
lodash_1.default.set(formComp, 'components', changed.component.components);
|
502
503
|
}
|
503
|
-
|
504
|
+
// If we're in a nested form we need to ensure our changes are triggered upstream
|
505
|
+
if (((_a = changed.instance.root) === null || _a === void 0 ? void 0 : _a.id) && (((_b = this.root) === null || _b === void 0 ? void 0 : _b.id) !== changed.instance.root.id)) {
|
506
|
+
changed.instance.root.triggerChange(flags, changed, modified);
|
507
|
+
}
|
508
|
+
else {
|
509
|
+
this.triggerChange({ modified });
|
510
|
+
}
|
504
511
|
};
|
505
512
|
let columnComponent;
|
506
513
|
if (this.builderMode) {
|
@@ -73,10 +73,10 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
73
73
|
rowIndex: any;
|
74
74
|
} | undefined;
|
75
75
|
emptyRow: any;
|
76
|
-
addRowModal(rowIndex: any): Promise<any>;
|
76
|
+
addRowModal(rowIndex: any): Promise<void> | Promise<any[]>;
|
77
77
|
alert: Alert | null | undefined;
|
78
78
|
showDialog(rowIndex: any): Promise<any>;
|
79
|
-
editRow(rowIndex: any): Promise<any>;
|
79
|
+
editRow(rowIndex: any): Promise<void> | Promise<any[]>;
|
80
80
|
clearErrors(rowIndex: any): void;
|
81
81
|
cancelRow(rowIndex: any): void;
|
82
82
|
saveRow(rowIndex: any, modified: any): boolean | undefined;
|
@@ -29,7 +29,7 @@ export default class FormComponent extends Component {
|
|
29
29
|
* Prints out the value of form components as a datagrid value.
|
30
30
|
*/
|
31
31
|
getValueAsString(value: any, options: any): any;
|
32
|
-
attach(element: any): Promise<
|
32
|
+
attach(element: any): Promise<any>;
|
33
33
|
get hasLoadedForm(): any;
|
34
34
|
get isRevisionChanged(): any;
|
35
35
|
get subFormData(): any;
|
@@ -290,29 +290,34 @@ class FormComponent extends Component_1.default {
|
|
290
290
|
return;
|
291
291
|
}
|
292
292
|
this.setContent(element, this.render());
|
293
|
+
const postAttach = () => {
|
294
|
+
if (!this.builderMode && this.component.modalEdit) {
|
295
|
+
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
296
|
+
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
297
|
+
this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
298
|
+
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
299
|
+
this.setOpenModalElement();
|
300
|
+
}
|
301
|
+
this.calculateValue();
|
302
|
+
};
|
293
303
|
if (this.subForm) {
|
294
304
|
if (this.isNestedWizard) {
|
295
305
|
element = this.root.element;
|
296
306
|
}
|
297
|
-
this.subForm.attach(element)
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
307
|
+
return this.subForm.attach(element).then(() => {
|
308
|
+
this.valueChanged = this.hasSetValue;
|
309
|
+
if (!this.shouldConditionallyClear()) {
|
310
|
+
if (!this.valueChanged && this.dataValue.state !== 'submitted') {
|
311
|
+
this.setDefaultValue();
|
312
|
+
}
|
313
|
+
else {
|
314
|
+
this.restoreValue();
|
315
|
+
}
|
305
316
|
}
|
306
|
-
|
307
|
-
|
308
|
-
if (!this.builderMode && this.component.modalEdit) {
|
309
|
-
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
310
|
-
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
311
|
-
this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
312
|
-
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
313
|
-
this.setOpenModalElement();
|
317
|
+
postAttach();
|
318
|
+
});
|
314
319
|
}
|
315
|
-
|
320
|
+
postAttach();
|
316
321
|
});
|
317
322
|
});
|
318
323
|
}
|
@@ -144,7 +144,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
144
144
|
});
|
145
145
|
this.optionsLoaded = !this.component.dataSrc || this.component.dataSrc === 'values';
|
146
146
|
this.loadedOptions = [];
|
147
|
-
if (!this.visible) {
|
147
|
+
if (!this.visible || this.optionsLoaded) {
|
148
148
|
this.itemsLoadedResolve();
|
149
149
|
}
|
150
150
|
// Get the template keys for this radio component.
|
@@ -160,6 +160,13 @@ class TagsComponent extends Input_1.default {
|
|
160
160
|
this.refs.input[0].parentNode.lastChild.focus();
|
161
161
|
}
|
162
162
|
}
|
163
|
+
getValue() {
|
164
|
+
if (this.choices) {
|
165
|
+
const value = this.choices.getValue(true);
|
166
|
+
return value.join(`${this.delimiter}`);
|
167
|
+
}
|
168
|
+
return super.getValue();
|
169
|
+
}
|
163
170
|
getValueAsString(value) {
|
164
171
|
if (!value) {
|
165
172
|
return '';
|
@@ -26,10 +26,10 @@ 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) => 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) => 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) => 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;
|
31
31
|
export const getComponentKey: typeof Utils.getComponentKey;
|
32
|
-
export const getContextualRowPath:
|
32
|
+
export const getContextualRowPath: any;
|
33
33
|
export const getContextualRowData: typeof Utils.getContextualRowData;
|
34
34
|
export const componentInfo: typeof Utils.componentInfo;
|
35
35
|
export const eachComponent: typeof Utils.eachComponent;
|
package/lib/cjs/utils/index.d.ts
CHANGED
@@ -37,10 +37,10 @@ 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) => 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) => 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) => 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;
|
42
42
|
getComponentKey: typeof import("@formio/core/lib/utils/formUtil").getComponentKey;
|
43
|
-
getContextualRowPath:
|
43
|
+
getContextualRowPath: any;
|
44
44
|
getContextualRowData: typeof import("@formio/core/lib/utils/formUtil").getContextualRowData;
|
45
45
|
componentInfo: typeof import("@formio/core/lib/utils/formUtil").componentInfo;
|
46
46
|
eachComponent: typeof import("@formio/core/lib/utils/formUtil").eachComponent;
|
@@ -123,7 +123,14 @@ class CalendarWidget extends InputWidget_1.default {
|
|
123
123
|
if (this._input) {
|
124
124
|
const { locale } = this.settings;
|
125
125
|
if (locale && locale.length >= 2 && locale !== 'en') {
|
126
|
-
return Formio_1.Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr.l10ns.${locale}`, `${Formio_1.Formio.cdn['flatpickr']}/l10n/${locale}.js`, true)
|
126
|
+
return Formio_1.Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr.l10ns.${locale}`, `${Formio_1.Formio.cdn['flatpickr']}/l10n/${locale}.js`, true)
|
127
|
+
.catch(() => {
|
128
|
+
// fallback to en if locale fails to load
|
129
|
+
this.settings.locale = 'en';
|
130
|
+
})
|
131
|
+
.finally(() => {
|
132
|
+
this.initFlatpickr(Flatpickr);
|
133
|
+
});
|
127
134
|
}
|
128
135
|
else {
|
129
136
|
this.initFlatpickr(Flatpickr);
|
package/lib/mjs/Webform.js
CHANGED
@@ -333,6 +333,14 @@ export default class Webform extends NestedDataComponent {
|
|
333
333
|
get shadowRoot() {
|
334
334
|
return this.options.shadowRoot;
|
335
335
|
}
|
336
|
+
// Webforms have no default value setting, so this should be always false
|
337
|
+
// I does not affect setting default value to nested forms
|
338
|
+
get shouldAddDefaultValue() {
|
339
|
+
return false;
|
340
|
+
}
|
341
|
+
get componentsMap() {
|
342
|
+
return this.childComponentsMap || {};
|
343
|
+
}
|
336
344
|
/**
|
337
345
|
* Add a language for translations
|
338
346
|
* @param {string} code - The language code for the language being added.
|
@@ -63,8 +63,16 @@ export default class WebformBuilder extends Component {
|
|
63
63
|
}
|
64
64
|
this.groupOrder = this.groupOrder
|
65
65
|
.filter(group => group && !group.ignore)
|
66
|
-
.sort((a, b) => a.weight - b.weight)
|
67
|
-
|
66
|
+
.sort((a, b) => a.weight - b.weight);
|
67
|
+
const defaultOpenedGroup = this.groupOrder.find(x => x.key !== 'basic' && x.default);
|
68
|
+
if (defaultOpenedGroup) {
|
69
|
+
this.groupOrder.forEach(x => {
|
70
|
+
if ('default' in x && x.key !== defaultOpenedGroup.key) {
|
71
|
+
x.default = false;
|
72
|
+
}
|
73
|
+
});
|
74
|
+
}
|
75
|
+
this.groupOrder = this.groupOrder.map(group => group.key);
|
68
76
|
for (const type in Components.components) {
|
69
77
|
const component = Components.components[type];
|
70
78
|
if (component.builderInfo && component.builderInfo.schema) {
|
@@ -1082,7 +1090,7 @@ export default class WebformBuilder extends Component {
|
|
1082
1090
|
const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
|
1083
1091
|
_.pull(newComp.validators, 'required');
|
1084
1092
|
parentComponent.tabs[tabIndex].splice(index, 1, newComp);
|
1085
|
-
newComp.
|
1093
|
+
newComp.processOwnValidation = true;
|
1086
1094
|
newComp.build(defaultValueComponent.element);
|
1087
1095
|
if (this.preview && !this.preview.defaultChanged) {
|
1088
1096
|
const defaultValue = _.get(this.preview._data, this.editForm._data.key);
|
package/lib/mjs/Wizard.js
CHANGED
@@ -591,7 +591,7 @@ export default class Wizard extends Webform {
|
|
591
591
|
if (!this._seenPages.includes(parentNum)) {
|
592
592
|
this._seenPages = this._seenPages.concat(parentNum);
|
593
593
|
}
|
594
|
-
this.redraw().then(() => {
|
594
|
+
return this.redraw().then(() => {
|
595
595
|
this.checkData(this.submission.data);
|
596
596
|
this.triggerCaptcha(this.currentPage.components);
|
597
597
|
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
@@ -599,7 +599,6 @@ export default class Wizard extends Webform {
|
|
599
599
|
this.showErrors(errors, true, true);
|
600
600
|
}
|
601
601
|
});
|
602
|
-
return Promise.resolve();
|
603
602
|
}
|
604
603
|
else if (!this.pages.length) {
|
605
604
|
this.redraw();
|
@@ -810,6 +809,11 @@ export default class Wizard extends Webform {
|
|
810
809
|
}
|
811
810
|
}
|
812
811
|
setValue(submission, flags = {}, ignoreEstablishment) {
|
812
|
+
if (!submission || !submission.data) {
|
813
|
+
submission = {
|
814
|
+
data: {},
|
815
|
+
};
|
816
|
+
}
|
813
817
|
const changed = this.getPages({ all: true }).reduce((changed, page) => {
|
814
818
|
return this.setNestedValue(page, submission.data, flags, changed) || changed;
|
815
819
|
}, false);
|
@@ -919,10 +923,7 @@ export default class Wizard extends Webform {
|
|
919
923
|
if (pageIndex >= 0) {
|
920
924
|
const page = this.pages[pageIndex];
|
921
925
|
if (page && page !== this.currentPage) {
|
922
|
-
return this.setPage(pageIndex).then(() =>
|
923
|
-
this.showErrors(this.validate(this.localData, { dirty: true }));
|
924
|
-
super.focusOnComponent(key);
|
925
|
-
});
|
926
|
+
return this.setPage(pageIndex).then(() => super.focusOnComponent(key));
|
926
927
|
}
|
927
928
|
}
|
928
929
|
}
|
@@ -155,7 +155,7 @@ export default class NestedComponent extends Field {
|
|
155
155
|
* @param {import('@formio/core').Component[]} components - The components to attach logic to.
|
156
156
|
*/
|
157
157
|
attachComponentsLogic(components: import('@formio/core').Component[]): void;
|
158
|
-
attachComponents(element: any, components: any, container: any): Promise<any>;
|
158
|
+
attachComponents(element: any, components: any, container: any): Promise<void> | Promise<any[]>;
|
159
159
|
/**
|
160
160
|
* Remove a component from the components array and from the children object
|
161
161
|
* @param {import('@formio/core').Component} component - The component to remove from the components.
|
@@ -534,8 +534,7 @@ export default class NestedComponent extends Field {
|
|
534
534
|
container = container || this.component.components;
|
535
535
|
element = this.hook('attachComponents', element, components, container, this);
|
536
536
|
if (!element) {
|
537
|
-
|
538
|
-
return (new Promise(() => { }));
|
537
|
+
return Promise.resolve();
|
539
538
|
}
|
540
539
|
let index = 0;
|
541
540
|
const promises = [];
|
@@ -560,6 +559,9 @@ export default class NestedComponent extends Field {
|
|
560
559
|
if (this.componentsMap[component.path]) {
|
561
560
|
delete this.componentsMap[component.path];
|
562
561
|
}
|
562
|
+
if (this.root?.componentsMap[component.path]) {
|
563
|
+
delete this.root?.componentsMap[component.path];
|
564
|
+
}
|
563
565
|
}
|
564
566
|
/**
|
565
567
|
* Removes a component provided the API key of that component.
|
@@ -833,9 +835,6 @@ export default class NestedComponent extends Field {
|
|
833
835
|
}
|
834
836
|
}
|
835
837
|
setValue(value, flags = {}) {
|
836
|
-
if (!value) {
|
837
|
-
return false;
|
838
|
-
}
|
839
838
|
// If the value is equal to the empty value, then this means we need to reset the values.
|
840
839
|
if (_.isEqual(value, this.emptyValue)) {
|
841
840
|
// TO-DO: For a future major release, we need to investigate removing the need for the
|
@@ -496,7 +496,13 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
496
496
|
const formComp = getComponent(this.component.components, changed.component.key);
|
497
497
|
_.set(formComp, 'components', changed.component.components);
|
498
498
|
}
|
499
|
-
|
499
|
+
// If we're in a nested form we need to ensure our changes are triggered upstream
|
500
|
+
if (changed.instance.root?.id && (this.root?.id !== changed.instance.root.id)) {
|
501
|
+
changed.instance.root.triggerChange(flags, changed, modified);
|
502
|
+
}
|
503
|
+
else {
|
504
|
+
this.triggerChange({ modified });
|
505
|
+
}
|
500
506
|
};
|
501
507
|
let columnComponent;
|
502
508
|
if (this.builderMode) {
|
@@ -73,10 +73,10 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
73
73
|
rowIndex: any;
|
74
74
|
} | undefined;
|
75
75
|
emptyRow: any;
|
76
|
-
addRowModal(rowIndex: any): Promise<any>;
|
76
|
+
addRowModal(rowIndex: any): Promise<void> | Promise<any[]>;
|
77
77
|
alert: Alert | null | undefined;
|
78
78
|
showDialog(rowIndex: any): Promise<any>;
|
79
|
-
editRow(rowIndex: any): Promise<any>;
|
79
|
+
editRow(rowIndex: any): Promise<void> | Promise<any[]>;
|
80
80
|
clearErrors(rowIndex: any): void;
|
81
81
|
cancelRow(rowIndex: any): void;
|
82
82
|
saveRow(rowIndex: any, modified: any): boolean | undefined;
|
@@ -29,7 +29,7 @@ export default class FormComponent extends Component {
|
|
29
29
|
* Prints out the value of form components as a datagrid value.
|
30
30
|
*/
|
31
31
|
getValueAsString(value: any, options: any): any;
|
32
|
-
attach(element: any): Promise<
|
32
|
+
attach(element: any): Promise<any>;
|
33
33
|
get hasLoadedForm(): any;
|
34
34
|
get isRevisionChanged(): any;
|
35
35
|
get subFormData(): any;
|
@@ -286,29 +286,34 @@ export default class FormComponent extends Component {
|
|
286
286
|
return;
|
287
287
|
}
|
288
288
|
this.setContent(element, this.render());
|
289
|
+
const postAttach = () => {
|
290
|
+
if (!this.builderMode && this.component.modalEdit) {
|
291
|
+
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
292
|
+
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
293
|
+
this.componentModal = new ComponentModal(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
294
|
+
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
295
|
+
this.setOpenModalElement();
|
296
|
+
}
|
297
|
+
this.calculateValue();
|
298
|
+
};
|
289
299
|
if (this.subForm) {
|
290
300
|
if (this.isNestedWizard) {
|
291
301
|
element = this.root.element;
|
292
302
|
}
|
293
|
-
this.subForm.attach(element)
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
303
|
+
return this.subForm.attach(element).then(() => {
|
304
|
+
this.valueChanged = this.hasSetValue;
|
305
|
+
if (!this.shouldConditionallyClear()) {
|
306
|
+
if (!this.valueChanged && this.dataValue.state !== 'submitted') {
|
307
|
+
this.setDefaultValue();
|
308
|
+
}
|
309
|
+
else {
|
310
|
+
this.restoreValue();
|
311
|
+
}
|
301
312
|
}
|
302
|
-
|
303
|
-
|
304
|
-
if (!this.builderMode && this.component.modalEdit) {
|
305
|
-
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
306
|
-
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
307
|
-
this.componentModal = new ComponentModal(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
308
|
-
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
309
|
-
this.setOpenModalElement();
|
313
|
+
postAttach();
|
314
|
+
});
|
310
315
|
}
|
311
|
-
|
316
|
+
postAttach();
|
312
317
|
});
|
313
318
|
});
|
314
319
|
}
|
@@ -144,7 +144,7 @@ export default class RadioComponent extends ListComponent {
|
|
144
144
|
});
|
145
145
|
this.optionsLoaded = !this.component.dataSrc || this.component.dataSrc === 'values';
|
146
146
|
this.loadedOptions = [];
|
147
|
-
if (!this.visible) {
|
147
|
+
if (!this.visible || this.optionsLoaded) {
|
148
148
|
this.itemsLoadedResolve();
|
149
149
|
}
|
150
150
|
// Get the template keys for this radio component.
|
@@ -158,6 +158,13 @@ export default class TagsComponent extends Input {
|
|
158
158
|
this.refs.input[0].parentNode.lastChild.focus();
|
159
159
|
}
|
160
160
|
}
|
161
|
+
getValue() {
|
162
|
+
if (this.choices) {
|
163
|
+
const value = this.choices.getValue(true);
|
164
|
+
return value.join(`${this.delimiter}`);
|
165
|
+
}
|
166
|
+
return super.getValue();
|
167
|
+
}
|
161
168
|
getValueAsString(value) {
|
162
169
|
if (!value) {
|
163
170
|
return '';
|
@@ -26,10 +26,10 @@ 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) => 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) => 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) => 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;
|
31
31
|
export const getComponentKey: typeof Utils.getComponentKey;
|
32
|
-
export const getContextualRowPath:
|
32
|
+
export const getContextualRowPath: any;
|
33
33
|
export const getContextualRowData: typeof Utils.getContextualRowData;
|
34
34
|
export const componentInfo: typeof Utils.componentInfo;
|
35
35
|
export const eachComponent: typeof Utils.eachComponent;
|
package/lib/mjs/utils/index.d.ts
CHANGED
@@ -37,10 +37,10 @@ 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) => 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) => 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) => 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;
|
42
42
|
getComponentKey: typeof import("@formio/core/lib/utils/formUtil").getComponentKey;
|
43
|
-
getContextualRowPath:
|
43
|
+
getContextualRowPath: any;
|
44
44
|
getContextualRowData: typeof import("@formio/core/lib/utils/formUtil").getContextualRowData;
|
45
45
|
componentInfo: typeof import("@formio/core/lib/utils/formUtil").componentInfo;
|
46
46
|
eachComponent: typeof import("@formio/core/lib/utils/formUtil").eachComponent;
|
@@ -115,7 +115,14 @@ export default class CalendarWidget extends InputWidget {
|
|
115
115
|
if (this._input) {
|
116
116
|
const { locale } = this.settings;
|
117
117
|
if (locale && locale.length >= 2 && locale !== 'en') {
|
118
|
-
return Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr.l10ns.${locale}`, `${Formio.cdn['flatpickr']}/l10n/${locale}.js`, true)
|
118
|
+
return Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr.l10ns.${locale}`, `${Formio.cdn['flatpickr']}/l10n/${locale}.js`, true)
|
119
|
+
.catch(() => {
|
120
|
+
// fallback to en if locale fails to load
|
121
|
+
this.settings.locale = 'en';
|
122
|
+
})
|
123
|
+
.finally(() => {
|
124
|
+
this.initFlatpickr(Flatpickr);
|
125
|
+
});
|
119
126
|
}
|
120
127
|
else {
|
121
128
|
this.initFlatpickr(Flatpickr);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@formio/js",
|
3
|
-
"version": "5.1.0-dev.
|
3
|
+
"version": "5.1.0-dev.6204.b833c7c",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"exports": {
|
@@ -81,7 +81,7 @@
|
|
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/core": "2.
|
84
|
+
"@formio/core": "2.5.1-rc.6",
|
85
85
|
"@formio/text-mask-addons": "3.8.0-formio.4",
|
86
86
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
87
87
|
"abortcontroller-polyfill": "^1.7.5",
|