@formio/js 5.1.0-dev.6112.1314654 → 5.1.0-dev.6112.b627acb
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 +6 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.css +1 -1
- package/dist/formio.embed.min.css +1 -1
- package/dist/formio.form.css +6 -0
- package/dist/formio.form.js +38 -60
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.css +6 -0
- package/dist/formio.full.js +42 -64
- package/dist/formio.full.min.css +1 -1
- 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 +21 -43
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Element.js +2 -2
- package/lib/cjs/PDFBuilder.js +8 -6
- package/lib/cjs/Webform.js +8 -0
- package/lib/cjs/WebformBuilder.js +17 -6
- package/lib/cjs/Wizard.js +7 -6
- package/lib/cjs/WizardBuilder.js +4 -0
- package/lib/cjs/components/_classes/component/Component.d.ts +1 -0
- package/lib/cjs/components/_classes/component/Component.js +17 -15
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +5 -2
- package/lib/cjs/components/address/Address.js +3 -3
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +1 -1
- 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 +2 -1
- package/lib/cjs/components/form/Form.js +32 -20
- package/lib/cjs/components/number/Number.js +4 -1
- package/lib/cjs/components/radio/Radio.js +1 -1
- package/lib/cjs/components/select/Select.js +1 -1
- package/lib/cjs/components/tags/Tags.js +7 -0
- package/lib/cjs/formio.form.d.ts +2 -1
- package/lib/cjs/formio.form.js +2 -1
- package/lib/cjs/utils/formUtils.d.ts +3 -3
- package/lib/cjs/utils/index.d.ts +6 -5
- package/lib/cjs/utils/index.js +2 -1
- package/lib/cjs/widgets/CalendarWidget.js +8 -1
- package/lib/mjs/Element.js +2 -2
- package/lib/mjs/PDFBuilder.js +8 -6
- package/lib/mjs/Webform.js +8 -0
- package/lib/mjs/WebformBuilder.js +17 -6
- package/lib/mjs/Wizard.js +7 -6
- package/lib/mjs/WizardBuilder.js +4 -0
- package/lib/mjs/components/_classes/component/Component.d.ts +1 -0
- package/lib/mjs/components/_classes/component/Component.js +17 -15
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +4 -2
- package/lib/mjs/components/address/Address.js +3 -3
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +1 -1
- 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 +2 -1
- package/lib/mjs/components/form/Form.js +32 -20
- package/lib/mjs/components/number/Number.js +4 -1
- package/lib/mjs/components/radio/Radio.js +1 -1
- package/lib/mjs/components/select/Select.js +1 -1
- package/lib/mjs/components/tags/Tags.js +7 -0
- package/lib/mjs/formio.form.d.ts +2 -1
- package/lib/mjs/formio.form.js +2 -2
- package/lib/mjs/utils/formUtils.d.ts +3 -3
- package/lib/mjs/utils/index.d.ts +6 -5
- package/lib/mjs/utils/index.js +2 -2
- package/lib/mjs/widgets/CalendarWidget.js +8 -1
- package/package.json +2 -2
package/lib/mjs/PDFBuilder.js
CHANGED
|
@@ -447,18 +447,20 @@ export default class PDFBuilder extends WebformBuilder {
|
|
|
447
447
|
const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
|
|
448
448
|
// update elements which path was duplicated if any pathes have been changed
|
|
449
449
|
if (!_.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
this.
|
|
453
|
-
|
|
454
|
-
|
|
450
|
+
if (!_.isEmpty(this.repeatablePathsComps)) {
|
|
451
|
+
eachComponent(this.webform.getComponents(), (comp) => {
|
|
452
|
+
if (this.repeatablePathsComps.includes(comp.component)) {
|
|
453
|
+
this.webform.postMessage({ name: 'updateElement', data: comp.component });
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
455
457
|
this.repeatablePathsComps = repeatablePathsComps;
|
|
456
458
|
}
|
|
457
459
|
if (!repeatablePathsComps.length) {
|
|
458
460
|
return;
|
|
459
461
|
}
|
|
460
462
|
eachComponent(this.webform.getComponents(), (comp) => {
|
|
461
|
-
if (this.repeatablePathsComps.includes(comp)) {
|
|
463
|
+
if (this.repeatablePathsComps.includes(comp.component)) {
|
|
462
464
|
this.webform.postMessage({
|
|
463
465
|
name: 'showBuilderErrors',
|
|
464
466
|
data: {
|
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) {
|
|
@@ -507,8 +515,8 @@ export default class WebformBuilder extends Component {
|
|
|
507
515
|
}
|
|
508
516
|
return elem;
|
|
509
517
|
};
|
|
510
|
-
const hideShow = (group,
|
|
511
|
-
if (show) {
|
|
518
|
+
const hideShow = (group, forceShow, toggle = false) => {
|
|
519
|
+
if (forceShow || (toggle && !Array.from(group.classList).includes('show'))) {
|
|
512
520
|
group.classList.add(['show']);
|
|
513
521
|
group.style.display = 'inherit';
|
|
514
522
|
}
|
|
@@ -530,7 +538,9 @@ export default class WebformBuilder extends Component {
|
|
|
530
538
|
const openByDefault = getAttribute(group, 'default') === 'true';
|
|
531
539
|
const groupId = group.getAttribute('id').slice('group-'.length);
|
|
532
540
|
const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);
|
|
533
|
-
|
|
541
|
+
if (((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index)) {
|
|
542
|
+
hideShow(group, false, true);
|
|
543
|
+
}
|
|
534
544
|
});
|
|
535
545
|
}, true);
|
|
536
546
|
});
|
|
@@ -1082,7 +1092,7 @@ export default class WebformBuilder extends Component {
|
|
|
1082
1092
|
const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);
|
|
1083
1093
|
_.pull(newComp.validators, 'required');
|
|
1084
1094
|
parentComponent.tabs[tabIndex].splice(index, 1, newComp);
|
|
1085
|
-
newComp.
|
|
1095
|
+
newComp.processOwnValidation = true;
|
|
1086
1096
|
newComp.build(defaultValueComponent.element);
|
|
1087
1097
|
if (this.preview && !this.preview.defaultChanged) {
|
|
1088
1098
|
const defaultValue = _.get(this.preview._data, this.editForm._data.key);
|
|
@@ -1180,6 +1190,7 @@ export default class WebformBuilder extends Component {
|
|
|
1180
1190
|
submissionData = submissionData.componentJson || submissionData;
|
|
1181
1191
|
if (submissionData.components && this.originalDefaultValue) {
|
|
1182
1192
|
submissionData.components = this.originalDefaultValue.components;
|
|
1193
|
+
this.originalDefaultValue = null;
|
|
1183
1194
|
}
|
|
1184
1195
|
const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
|
|
1185
1196
|
this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
|
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
|
}
|
package/lib/mjs/WizardBuilder.js
CHANGED
|
@@ -178,6 +178,10 @@ export default class WizardBuilder extends WebformBuilder {
|
|
|
178
178
|
this.navigationDragula = null;
|
|
179
179
|
super.detach();
|
|
180
180
|
}
|
|
181
|
+
destroy(all = false) {
|
|
182
|
+
this.off('saveComponent');
|
|
183
|
+
super.destroy(all);
|
|
184
|
+
}
|
|
181
185
|
rebuild() {
|
|
182
186
|
const page = this.currentPage;
|
|
183
187
|
this.webform.setForm({
|
|
@@ -168,6 +168,7 @@ declare class Component extends Element {
|
|
|
168
168
|
* @returns {boolean} - If the parent should conditionally clear.
|
|
169
169
|
*/
|
|
170
170
|
parentShouldConditionallyClear(): boolean;
|
|
171
|
+
hasCondionallyHiddenLayoutParent(): boolean;
|
|
171
172
|
parentConditionallyHidden(): boolean;
|
|
172
173
|
/**
|
|
173
174
|
* Returns true if any of the parents default their component "hidden" property to true.
|
|
@@ -437,6 +437,16 @@ export default class Component extends Element {
|
|
|
437
437
|
}
|
|
438
438
|
return false;
|
|
439
439
|
}
|
|
440
|
+
hasCondionallyHiddenLayoutParent() {
|
|
441
|
+
let currentParent = this.parent;
|
|
442
|
+
while (currentParent) {
|
|
443
|
+
if (currentParent._conditionallyHidden && FormioUtils.isLayoutComponent(currentParent) && currentParent.component.clearOnHide === true) {
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
446
|
+
currentParent = currentParent.parent;
|
|
447
|
+
}
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
440
450
|
parentConditionallyHidden() {
|
|
441
451
|
let currentParent = this.parent;
|
|
442
452
|
while (currentParent) {
|
|
@@ -620,10 +630,13 @@ export default class Component extends Element {
|
|
|
620
630
|
if (!component) {
|
|
621
631
|
component = this.component;
|
|
622
632
|
}
|
|
633
|
+
if (!this.path) {
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
623
636
|
if (_.isArray(this.options[visibility])) {
|
|
624
|
-
return this.options[visibility].includes(
|
|
637
|
+
return this.options[visibility].includes(this.path);
|
|
625
638
|
}
|
|
626
|
-
return this.options[visibility][
|
|
639
|
+
return this.options[visibility][this.path];
|
|
627
640
|
}
|
|
628
641
|
shouldForceHide(component) {
|
|
629
642
|
return this.shouldForceVisibility(component, 'hide');
|
|
@@ -703,7 +716,7 @@ export default class Component extends Element {
|
|
|
703
716
|
this._conditionallyClear = true;
|
|
704
717
|
return this._conditionallyClear;
|
|
705
718
|
}
|
|
706
|
-
this._conditionallyClear = this.hasSetValue ?
|
|
719
|
+
this._conditionallyClear = this.hasSetValue ? this.hasCondionallyHiddenLayoutParent() : this.parentShouldConditionallyClear();
|
|
707
720
|
return this._conditionallyClear;
|
|
708
721
|
}
|
|
709
722
|
/**
|
|
@@ -2555,7 +2568,7 @@ export default class Component extends Element {
|
|
|
2555
2568
|
if ((value !== null) && (value !== undefined)) {
|
|
2556
2569
|
value = this.hook('setDataValue', value, this.key, this._data);
|
|
2557
2570
|
}
|
|
2558
|
-
if ((value === null) || (value === undefined)) {
|
|
2571
|
+
if ((value === null) || (value === undefined) || _.isNaN(value)) {
|
|
2559
2572
|
this.unset();
|
|
2560
2573
|
return;
|
|
2561
2574
|
}
|
|
@@ -2588,17 +2601,6 @@ export default class Component extends Element {
|
|
|
2588
2601
|
noUpdateEvent: true,
|
|
2589
2602
|
noDefault: true
|
|
2590
2603
|
});
|
|
2591
|
-
if (FormioUtils.isLayoutComponent(this.component) && this.component.clearOnHide === true && !this.hasValue()) {
|
|
2592
|
-
FormioUtils.eachComponent(this.components, (component) => {
|
|
2593
|
-
if (component.component.clearOnHide !== false) {
|
|
2594
|
-
component.setValue(null, {
|
|
2595
|
-
noUpdateEvent: true,
|
|
2596
|
-
noDefault: true
|
|
2597
|
-
});
|
|
2598
|
-
component.unset();
|
|
2599
|
-
}
|
|
2600
|
-
});
|
|
2601
|
-
}
|
|
2602
2604
|
this.unset();
|
|
2603
2605
|
}
|
|
2604
2606
|
getCustomDefaultValue(defaultValue) {
|
|
@@ -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.
|
|
@@ -564,11 +564,11 @@ export default class AddressComponent extends ContainerComponent {
|
|
|
564
564
|
}
|
|
565
565
|
if (valueInManualMode) {
|
|
566
566
|
if (this.component.manualModeViewString) {
|
|
567
|
-
return this.
|
|
567
|
+
return this.evaluate(this.component.manualModeViewString, {
|
|
568
568
|
address,
|
|
569
|
-
data:
|
|
569
|
+
data: value,
|
|
570
570
|
component: this.component,
|
|
571
|
-
});
|
|
571
|
+
}, 'value');
|
|
572
572
|
}
|
|
573
573
|
return this.getComponents()
|
|
574
574
|
.filter((component) => component.hasValue(address))
|
|
@@ -142,7 +142,7 @@ export default [
|
|
|
142
142
|
key: 'manualModeViewString',
|
|
143
143
|
label: 'Manual Mode View String',
|
|
144
144
|
placeholder: 'Enter Manual Mode View String',
|
|
145
|
-
description: '"address"
|
|
145
|
+
description: '"data.address" references component value and "component" - address component schema.',
|
|
146
146
|
weight: 60,
|
|
147
147
|
rows: 5,
|
|
148
148
|
editor: 'ace',
|
|
@@ -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;
|
|
@@ -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
|
+
setComponentsMap(): void;
|
|
45
46
|
/**
|
|
46
47
|
* Create a subform instance.
|
|
47
48
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
|
@@ -286,29 +286,35 @@ 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
|
-
|
|
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
|
+
this.setComponentsMap();
|
|
315
|
+
});
|
|
310
316
|
}
|
|
311
|
-
|
|
317
|
+
postAttach();
|
|
312
318
|
});
|
|
313
319
|
});
|
|
314
320
|
}
|
|
@@ -384,6 +390,14 @@ export default class FormComponent extends Component {
|
|
|
384
390
|
this.emit('subWizardsUpdated', subForm);
|
|
385
391
|
}
|
|
386
392
|
}
|
|
393
|
+
setComponentsMap() {
|
|
394
|
+
if (!this.subForm) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
const componentsMap = this.componentsMap;
|
|
398
|
+
const formComponentsMap = this.subForm.componentsMap;
|
|
399
|
+
_.assign(componentsMap, formComponentsMap);
|
|
400
|
+
}
|
|
387
401
|
/**
|
|
388
402
|
* Create a subform instance.
|
|
389
403
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
|
@@ -408,9 +422,7 @@ export default class FormComponent extends Component {
|
|
|
408
422
|
this.subForm = instance;
|
|
409
423
|
this.subForm.currentForm = this;
|
|
410
424
|
this.subForm.parentVisible = this.visible;
|
|
411
|
-
|
|
412
|
-
const formComponentsMap = this.subForm.componentsMap;
|
|
413
|
-
_.assign(componentsMap, formComponentsMap);
|
|
425
|
+
this.setComponentsMap();
|
|
414
426
|
this.component.components = this.subForm._form?.components;
|
|
415
427
|
this.component.display = this.subForm._form?.display;
|
|
416
428
|
this.subForm.on('change', () => {
|
|
@@ -89,10 +89,13 @@ export default class NumberComponent extends Input {
|
|
|
89
89
|
}
|
|
90
90
|
get defaultValue() {
|
|
91
91
|
let defaultValue = super.defaultValue;
|
|
92
|
-
if (typeof defaultValue === 'string') {
|
|
92
|
+
if (typeof defaultValue === 'string' && defaultValue) {
|
|
93
93
|
// Default value may be a string or have custom thousands separators or decimal symbols, so we need to call
|
|
94
94
|
// parseNumber on it
|
|
95
95
|
defaultValue = this.parseNumber(defaultValue);
|
|
96
|
+
if (_.isNaN(defaultValue)) {
|
|
97
|
+
defaultValue = null;
|
|
98
|
+
}
|
|
96
99
|
}
|
|
97
100
|
if (!defaultValue && this.component.defaultValue === 0) {
|
|
98
101
|
defaultValue = this.component.defaultValue;
|
|
@@ -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.
|
|
@@ -1154,7 +1154,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1154
1154
|
}
|
|
1155
1155
|
// Choices will return undefined if nothing is selected. We really want '' to be empty.
|
|
1156
1156
|
if (value === undefined || value === null) {
|
|
1157
|
-
value =
|
|
1157
|
+
value = this.emptyValue;
|
|
1158
1158
|
}
|
|
1159
1159
|
return value;
|
|
1160
1160
|
}
|
|
@@ -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 '';
|
package/lib/mjs/formio.form.d.ts
CHANGED
|
@@ -23,4 +23,5 @@ import { Formio } from './Formio';
|
|
|
23
23
|
import Licenses from './licenses';
|
|
24
24
|
import EventEmitter from './EventEmitter';
|
|
25
25
|
import Webform from './Webform';
|
|
26
|
-
|
|
26
|
+
import { DefaultEvaluator } from './utils';
|
|
27
|
+
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
|
package/lib/mjs/formio.form.js
CHANGED
|
@@ -12,7 +12,7 @@ import Licenses from './licenses';
|
|
|
12
12
|
import EventEmitter from './EventEmitter';
|
|
13
13
|
import Webform from './Webform';
|
|
14
14
|
import { I18n } from '@formio/core';
|
|
15
|
-
import { Evaluator, registerEvaluator } from './utils';
|
|
15
|
+
import { Evaluator, registerEvaluator, DefaultEvaluator } from './utils';
|
|
16
16
|
Formio.loadModules = (path = `${Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
|
|
17
17
|
Formio.requireLibrary(name, name, path, true)
|
|
18
18
|
.then((modules) => {
|
|
@@ -130,4 +130,4 @@ export function useModule(defaultFn = null) {
|
|
|
130
130
|
Formio.use = useModule();
|
|
131
131
|
export { Formio as FormioCore } from './Formio';
|
|
132
132
|
// Export the components.
|
|
133
|
-
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform };
|
|
133
|
+
export { Components, Displays, Providers, Widgets, Templates, Utils, Form, Formio, Licenses, EventEmitter, Webform, DefaultEvaluator };
|
|
@@ -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
|
@@ -2,7 +2,7 @@ export * from "./utils";
|
|
|
2
2
|
export * from "./formUtils";
|
|
3
3
|
export default FormioUtils;
|
|
4
4
|
declare const FormioUtils: {
|
|
5
|
-
Evaluator:
|
|
5
|
+
Evaluator: DefaultEvaluator;
|
|
6
6
|
interpolate: typeof interpolate;
|
|
7
7
|
ConditionOperators: {
|
|
8
8
|
[x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
|
|
@@ -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;
|
|
@@ -164,7 +164,8 @@ declare const FormioUtils: {
|
|
|
164
164
|
interpolateErrors: (component: Component, errors: FieldError[], interpolateFn: Function) => [];
|
|
165
165
|
};
|
|
166
166
|
import { Evaluator } from './Evaluator';
|
|
167
|
+
import { DefaultEvaluator } from './Evaluator';
|
|
167
168
|
import { registerEvaluator } from './Evaluator';
|
|
168
169
|
import { interpolate } from './Evaluator';
|
|
169
170
|
import moment from 'moment';
|
|
170
|
-
export { FormioUtils as Utils, Evaluator, registerEvaluator };
|
|
171
|
+
export { FormioUtils as Utils, Evaluator, DefaultEvaluator, registerEvaluator };
|
package/lib/mjs/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as utils from './utils';
|
|
2
2
|
import * as formUtils from './formUtils';
|
|
3
|
-
import { Evaluator, registerEvaluator, interpolate } from './Evaluator';
|
|
3
|
+
import { Evaluator, registerEvaluator, interpolate, DefaultEvaluator } from './Evaluator';
|
|
4
4
|
import ConditionOperators from './conditionOperators';
|
|
5
5
|
import _ from 'lodash';
|
|
6
6
|
import moment from 'moment';
|
|
@@ -17,7 +17,7 @@ if (typeof global === 'object') {
|
|
|
17
17
|
global.FormioUtils = FormioUtils;
|
|
18
18
|
}
|
|
19
19
|
export { FormioUtils as Utils };
|
|
20
|
-
export { Evaluator, registerEvaluator };
|
|
20
|
+
export { Evaluator, DefaultEvaluator, registerEvaluator };
|
|
21
21
|
export * from './utils';
|
|
22
22
|
export * from './formUtils';
|
|
23
23
|
export default FormioUtils;
|
|
@@ -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.6112.
|
|
3
|
+
"version": "5.1.0-dev.6112.b627acb",
|
|
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",
|