@formio/js 5.0.0-rc.18 → 5.0.0-rc.20
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/formio.builder.css +14 -22
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.css +1 -2
- package/dist/formio.embed.js +2 -2
- package/dist/formio.embed.min.css +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.css +10 -2
- package/dist/formio.form.js +333 -361
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -8
- package/dist/formio.full.css +14 -22
- package/dist/formio.full.js +353 -370
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -8
- package/dist/formio.js +208 -121
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +2 -7
- package/dist/formio.utils.js +220 -13
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -7
- package/lib/cjs/CDN.js +1 -1
- package/lib/cjs/Element.js +7 -2
- package/lib/cjs/Embed.js +1 -1
- package/lib/cjs/Form.d.ts +8 -5
- package/lib/cjs/Form.js +52 -10
- package/lib/cjs/PDF.d.ts +11 -3
- package/lib/cjs/PDF.js +4 -5
- package/lib/cjs/PDFBuilder.js +2 -3
- package/lib/cjs/Webform.d.ts +4 -7
- package/lib/cjs/Webform.js +40 -119
- package/lib/cjs/WebformBuilder.d.ts +6 -1
- package/lib/cjs/WebformBuilder.js +104 -64
- package/lib/cjs/Wizard.d.ts +8 -5
- package/lib/cjs/Wizard.js +14 -14
- package/lib/cjs/WizardBuilder.d.ts +6 -4
- package/lib/cjs/WizardBuilder.js +20 -3
- package/lib/cjs/addons/FormioAddon.d.ts +1 -1
- package/lib/cjs/addons/FormioAddon.js +1 -2
- package/lib/cjs/components/_classes/component/Component.d.ts +17 -8
- package/lib/cjs/components/_classes/component/Component.js +52 -18
- package/lib/cjs/components/_classes/input/Input.d.ts +1 -1
- package/lib/cjs/components/_classes/input/Input.js +1 -2
- package/lib/cjs/components/_classes/list/ListComponent.d.ts +4 -0
- package/lib/cjs/components/_classes/list/ListComponent.js +43 -6
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +1 -0
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +10 -4
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +5 -2
- package/lib/cjs/components/_classes/nested/NestedComponent.js +11 -12
- package/lib/cjs/components/address/Address.d.ts +8 -0
- package/lib/cjs/components/button/Button.js +2 -3
- package/lib/cjs/components/checkbox/Checkbox.d.ts +13 -0
- package/lib/cjs/components/checkbox/Checkbox.js +17 -5
- package/lib/cjs/components/columns/Columns.d.ts +1 -0
- package/lib/cjs/components/columns/Columns.js +1 -0
- package/lib/cjs/components/container/Container.d.ts +1 -0
- package/lib/cjs/components/container/Container.js +1 -0
- package/lib/cjs/components/content/Content.d.ts +1 -0
- package/lib/cjs/components/content/Content.js +1 -2
- package/lib/cjs/components/currency/editForm/Currency.edit.data.d.ts +14 -2
- package/lib/cjs/components/currency/editForm/Currency.edit.data.js +4 -0
- package/lib/cjs/components/currency/editForm/Currency.edit.display.js +4 -0
- package/lib/cjs/components/datagrid/DataGrid.d.ts +1 -0
- package/lib/cjs/components/datagrid/DataGrid.js +8 -1
- package/lib/cjs/components/datamap/DataMap.js +1 -0
- package/lib/cjs/components/datetime/DateTime.d.ts +4 -0
- package/lib/cjs/components/datetime/DateTime.js +21 -1
- package/lib/cjs/components/day/Day.d.ts +1 -1
- package/lib/cjs/components/day/Day.js +22 -6
- package/lib/cjs/components/day/fixtures/comp3.js +2 -2
- package/lib/cjs/components/editgrid/EditGrid.d.ts +4 -3
- package/lib/cjs/components/editgrid/EditGrid.js +11 -6
- package/lib/cjs/components/editgrid/fixtures/comp-with-custom-default-value.d.ts +190 -0
- package/lib/cjs/components/editgrid/fixtures/comp-with-custom-default-value.js +227 -0
- package/lib/cjs/components/editgrid/fixtures/comp15.d.ts +54 -0
- package/lib/cjs/components/editgrid/fixtures/comp15.js +51 -0
- package/lib/cjs/components/editgrid/fixtures/index.d.ts +3 -1
- package/lib/cjs/components/editgrid/fixtures/index.js +5 -1
- package/lib/cjs/components/fieldset/Fieldset.d.ts +1 -0
- package/lib/cjs/components/fieldset/Fieldset.js +1 -0
- package/lib/cjs/components/file/File.d.ts +7 -5
- package/lib/cjs/components/file/File.js +26 -9
- package/lib/cjs/components/file/editForm/File.edit.file.d.ts +62 -0
- package/lib/cjs/components/file/editForm/File.edit.file.js +29 -2
- package/lib/cjs/components/form/Form.d.ts +3 -0
- package/lib/cjs/components/form/Form.js +9 -10
- package/lib/cjs/components/hidden/Hidden.d.ts +1 -0
- package/lib/cjs/components/hidden/Hidden.js +1 -0
- package/lib/cjs/components/html/HTML.d.ts +1 -0
- package/lib/cjs/components/html/HTML.js +1 -0
- package/lib/cjs/components/number/Number.d.ts +5 -1
- package/lib/cjs/components/number/Number.js +24 -7
- package/lib/cjs/components/phonenumber/PhoneNumber.form.js +9 -0
- package/lib/cjs/components/radio/Radio.d.ts +5 -3
- package/lib/cjs/components/radio/Radio.js +59 -18
- package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -1
- package/lib/cjs/components/recaptcha/ReCaptcha.js +4 -5
- package/lib/cjs/components/resource/Resource.d.ts +7 -0
- package/lib/cjs/components/resource/Resource.js +0 -1
- package/lib/cjs/components/resource/editForm/Resource.edit.display.js +1 -1
- package/lib/cjs/components/select/Select.d.ts +7 -5
- package/lib/cjs/components/select/Select.js +15 -49
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +12 -0
- package/lib/cjs/components/selectboxes/SelectBoxes.js +53 -25
- package/lib/cjs/components/selectboxes/fixtures/comp4.d.ts +30 -27
- package/lib/cjs/components/selectboxes/fixtures/comp4.js +47 -32
- package/lib/cjs/components/selectboxes/fixtures/comp6.d.ts +14 -0
- package/lib/cjs/components/selectboxes/fixtures/comp6.js +15 -0
- package/lib/cjs/components/selectboxes/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/selectboxes/fixtures/index.js +3 -1
- package/lib/cjs/components/signature/Signature.d.ts +1 -1
- package/lib/cjs/components/signature/Signature.js +8 -3
- package/lib/cjs/components/survey/Survey.js +3 -0
- package/lib/cjs/components/table/Table.d.ts +1 -0
- package/lib/cjs/components/table/Table.js +1 -0
- package/lib/cjs/components/tabs/Tabs.d.ts +1 -0
- package/lib/cjs/components/tabs/Tabs.js +1 -0
- package/lib/cjs/components/tags/Tags.js +3 -0
- package/lib/cjs/components/textarea/TextArea.d.ts +3 -2
- package/lib/cjs/components/textarea/TextArea.js +4 -5
- package/lib/cjs/components/textarea/fixtures/comp4.d.ts +30 -0
- package/lib/cjs/components/textarea/fixtures/comp4.js +27 -0
- package/lib/cjs/components/textarea/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/textarea/fixtures/index.js +3 -1
- package/lib/cjs/components/textfield/TextField.d.ts +1 -0
- package/lib/cjs/components/textfield/TextField.js +5 -3
- package/lib/cjs/components/time/Time.d.ts +4 -0
- package/lib/cjs/components/time/Time.js +6 -1
- package/lib/cjs/components/tree/Tree.d.ts +5 -4
- package/lib/cjs/components/tree/Tree.form.js +5 -0
- package/lib/cjs/components/tree/Tree.js +8 -9
- package/lib/cjs/components/tree/editForm/Tree.edit.display.d.ts +9 -0
- package/lib/cjs/components/tree/editForm/Tree.edit.display.js +12 -0
- package/lib/cjs/components/well/Well.d.ts +1 -0
- package/lib/cjs/components/well/Well.js +1 -0
- package/lib/cjs/providers/Providers.d.ts +31 -11
- package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +2 -2
- package/lib/cjs/providers/address/GoogleAddressProvider.js +2 -3
- package/lib/cjs/providers/processor/fileProcessor.d.ts +1 -1
- package/lib/cjs/providers/processor/fileProcessor.js +1 -5
- package/lib/cjs/providers/storage/azure.d.ts +10 -1
- package/lib/cjs/providers/storage/azure.js +7 -2
- package/lib/cjs/providers/storage/base64.d.ts +2 -2
- package/lib/cjs/providers/storage/base64.js +2 -6
- package/lib/cjs/providers/storage/dropbox.d.ts +2 -2
- package/lib/cjs/providers/storage/dropbox.js +2 -6
- package/lib/cjs/providers/storage/googleDrive.d.ts +3 -2
- package/lib/cjs/providers/storage/googleDrive.js +6 -6
- package/lib/cjs/providers/storage/indexeddb.d.ts +3 -3
- package/lib/cjs/providers/storage/indexeddb.js +9 -13
- package/lib/cjs/providers/storage/s3.d.ts +11 -1
- package/lib/cjs/providers/storage/s3.js +5 -2
- package/lib/cjs/providers/storage/uploadAdapter.js +1 -5
- package/lib/cjs/providers/storage/url.d.ts +2 -2
- package/lib/cjs/providers/storage/url.js +12 -8
- package/lib/cjs/providers/storage/xhr.d.ts +1 -1
- package/lib/cjs/providers/storage/xhr.js +1 -2
- package/lib/cjs/templates/index.d.ts +226 -1
- package/lib/cjs/utils/Evaluator.js +4 -33
- package/lib/cjs/utils/i18n.d.ts +16 -0
- package/lib/cjs/utils/i18n.js +88 -0
- package/lib/cjs/utils/utils.d.ts +1 -1
- package/lib/cjs/utils/utils.js +8 -9
- package/lib/cjs/validator/Validator.d.ts +30 -2
- package/lib/cjs/validator/Validator.js +32 -9
- package/lib/cjs/validator/rules/Select.js +1 -2
- package/lib/cjs/validator/rules/Unique.d.ts +1 -1
- package/lib/cjs/validator/rules/Unique.js +1 -2
- package/lib/cjs/widgets/CalendarWidget.d.ts +1 -0
- package/lib/cjs/widgets/InputWidget.d.ts +1 -1
- package/lib/cjs/widgets/InputWidget.js +1 -2
- package/lib/mjs/CDN.js +1 -1
- package/lib/mjs/Element.js +6 -2
- package/lib/mjs/Embed.js +4 -1
- package/lib/mjs/Form.d.ts +8 -5
- package/lib/mjs/Form.js +52 -10
- package/lib/mjs/PDF.d.ts +11 -3
- package/lib/mjs/PDF.js +4 -5
- package/lib/mjs/PDFBuilder.js +2 -3
- package/lib/mjs/Webform.d.ts +4 -7
- package/lib/mjs/Webform.js +40 -122
- package/lib/mjs/WebformBuilder.d.ts +6 -1
- package/lib/mjs/WebformBuilder.js +102 -64
- package/lib/mjs/Wizard.d.ts +8 -5
- package/lib/mjs/Wizard.js +14 -14
- package/lib/mjs/WizardBuilder.d.ts +6 -4
- package/lib/mjs/WizardBuilder.js +20 -3
- package/lib/mjs/addons/FormioAddon.d.ts +1 -1
- package/lib/mjs/addons/FormioAddon.js +1 -2
- package/lib/mjs/components/_classes/component/Component.d.ts +17 -8
- package/lib/mjs/components/_classes/component/Component.js +52 -18
- package/lib/mjs/components/_classes/input/Input.d.ts +1 -1
- package/lib/mjs/components/_classes/input/Input.js +1 -2
- package/lib/mjs/components/_classes/list/ListComponent.d.ts +4 -0
- package/lib/mjs/components/_classes/list/ListComponent.js +43 -5
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +1 -0
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +10 -4
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +5 -2
- package/lib/mjs/components/_classes/nested/NestedComponent.js +11 -12
- package/lib/mjs/components/address/Address.d.ts +8 -0
- package/lib/mjs/components/button/Button.js +2 -3
- package/lib/mjs/components/checkbox/Checkbox.d.ts +13 -0
- package/lib/mjs/components/checkbox/Checkbox.js +21 -5
- package/lib/mjs/components/columns/Columns.d.ts +1 -0
- package/lib/mjs/components/columns/Columns.js +1 -0
- package/lib/mjs/components/container/Container.d.ts +1 -0
- package/lib/mjs/components/container/Container.js +1 -0
- package/lib/mjs/components/content/Content.d.ts +1 -0
- package/lib/mjs/components/content/Content.js +1 -2
- package/lib/mjs/components/currency/editForm/Currency.edit.data.d.ts +14 -2
- package/lib/mjs/components/currency/editForm/Currency.edit.data.js +4 -0
- package/lib/mjs/components/currency/editForm/Currency.edit.display.js +4 -0
- package/lib/mjs/components/datagrid/DataGrid.d.ts +1 -0
- package/lib/mjs/components/datagrid/DataGrid.js +8 -1
- package/lib/mjs/components/datamap/DataMap.js +1 -0
- package/lib/mjs/components/datetime/DateTime.d.ts +4 -0
- package/lib/mjs/components/datetime/DateTime.js +28 -1
- package/lib/mjs/components/day/Day.d.ts +1 -1
- package/lib/mjs/components/day/Day.js +25 -6
- package/lib/mjs/components/day/fixtures/comp3.js +2 -2
- package/lib/mjs/components/editgrid/EditGrid.d.ts +4 -3
- package/lib/mjs/components/editgrid/EditGrid.js +11 -6
- package/lib/mjs/components/editgrid/fixtures/comp-with-custom-default-value.d.ts +190 -0
- package/lib/mjs/components/editgrid/fixtures/comp-with-custom-default-value.js +225 -0
- package/lib/mjs/components/editgrid/fixtures/comp15.d.ts +54 -0
- package/lib/mjs/components/editgrid/fixtures/comp15.js +49 -0
- package/lib/mjs/components/editgrid/fixtures/index.d.ts +3 -1
- package/lib/mjs/components/editgrid/fixtures/index.js +3 -1
- package/lib/mjs/components/fieldset/Fieldset.d.ts +1 -0
- package/lib/mjs/components/fieldset/Fieldset.js +1 -0
- package/lib/mjs/components/file/File.d.ts +7 -5
- package/lib/mjs/components/file/File.js +29 -9
- package/lib/mjs/components/file/editForm/File.edit.file.d.ts +62 -0
- package/lib/mjs/components/file/editForm/File.edit.file.js +29 -2
- package/lib/mjs/components/form/Form.d.ts +3 -0
- package/lib/mjs/components/form/Form.js +9 -10
- package/lib/mjs/components/hidden/Hidden.d.ts +1 -0
- package/lib/mjs/components/hidden/Hidden.js +1 -0
- package/lib/mjs/components/html/HTML.d.ts +1 -0
- package/lib/mjs/components/html/HTML.js +1 -0
- package/lib/mjs/components/number/Number.d.ts +5 -1
- package/lib/mjs/components/number/Number.js +24 -7
- package/lib/mjs/components/phonenumber/PhoneNumber.form.js +9 -0
- package/lib/mjs/components/radio/Radio.d.ts +5 -3
- package/lib/mjs/components/radio/Radio.js +59 -18
- package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -1
- package/lib/mjs/components/recaptcha/ReCaptcha.js +4 -5
- package/lib/mjs/components/resource/Resource.d.ts +7 -0
- package/lib/mjs/components/resource/Resource.js +0 -1
- package/lib/mjs/components/resource/editForm/Resource.edit.display.js +1 -1
- package/lib/mjs/components/select/Select.d.ts +7 -5
- package/lib/mjs/components/select/Select.js +18 -49
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +12 -0
- package/lib/mjs/components/selectboxes/SelectBoxes.js +56 -25
- package/lib/mjs/components/selectboxes/fixtures/comp4.d.ts +30 -27
- package/lib/mjs/components/selectboxes/fixtures/comp4.js +47 -32
- package/lib/mjs/components/selectboxes/fixtures/comp6.d.ts +14 -0
- package/lib/mjs/components/selectboxes/fixtures/comp6.js +13 -0
- package/lib/mjs/components/selectboxes/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/selectboxes/fixtures/index.js +2 -1
- package/lib/mjs/components/signature/Signature.d.ts +1 -1
- package/lib/mjs/components/signature/Signature.js +11 -3
- package/lib/mjs/components/survey/Survey.js +6 -0
- package/lib/mjs/components/table/Table.d.ts +1 -0
- package/lib/mjs/components/table/Table.js +1 -0
- package/lib/mjs/components/tabs/Tabs.d.ts +1 -0
- package/lib/mjs/components/tabs/Tabs.js +1 -0
- package/lib/mjs/components/tags/Tags.js +6 -0
- package/lib/mjs/components/textarea/TextArea.d.ts +3 -2
- package/lib/mjs/components/textarea/TextArea.js +4 -5
- package/lib/mjs/components/textarea/fixtures/comp4.d.ts +30 -0
- package/lib/mjs/components/textarea/fixtures/comp4.js +25 -0
- package/lib/mjs/components/textarea/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/textarea/fixtures/index.js +2 -1
- package/lib/mjs/components/textfield/TextField.d.ts +1 -0
- package/lib/mjs/components/textfield/TextField.js +8 -3
- package/lib/mjs/components/time/Time.d.ts +4 -0
- package/lib/mjs/components/time/Time.js +12 -1
- package/lib/mjs/components/tree/Tree.d.ts +5 -4
- package/lib/mjs/components/tree/Tree.form.js +5 -0
- package/lib/mjs/components/tree/Tree.js +8 -9
- package/lib/mjs/components/tree/editForm/Tree.edit.display.d.ts +9 -0
- package/lib/mjs/components/tree/editForm/Tree.edit.display.js +10 -0
- package/lib/mjs/components/well/Well.d.ts +1 -0
- package/lib/mjs/components/well/Well.js +1 -0
- package/lib/mjs/providers/Providers.d.ts +31 -11
- package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +2 -2
- package/lib/mjs/providers/address/GoogleAddressProvider.js +2 -3
- package/lib/mjs/providers/processor/fileProcessor.d.ts +1 -1
- package/lib/mjs/providers/processor/fileProcessor.js +1 -2
- package/lib/mjs/providers/storage/azure.d.ts +10 -1
- package/lib/mjs/providers/storage/azure.js +7 -2
- package/lib/mjs/providers/storage/base64.d.ts +2 -2
- package/lib/mjs/providers/storage/base64.js +2 -3
- package/lib/mjs/providers/storage/dropbox.d.ts +2 -2
- package/lib/mjs/providers/storage/dropbox.js +2 -3
- package/lib/mjs/providers/storage/googleDrive.d.ts +3 -2
- package/lib/mjs/providers/storage/googleDrive.js +6 -3
- package/lib/mjs/providers/storage/indexeddb.d.ts +3 -3
- package/lib/mjs/providers/storage/indexeddb.js +9 -10
- package/lib/mjs/providers/storage/s3.d.ts +11 -1
- package/lib/mjs/providers/storage/s3.js +5 -2
- package/lib/mjs/providers/storage/uploadAdapter.js +1 -2
- package/lib/mjs/providers/storage/url.d.ts +2 -2
- package/lib/mjs/providers/storage/url.js +12 -5
- package/lib/mjs/providers/storage/xhr.d.ts +1 -1
- package/lib/mjs/providers/storage/xhr.js +1 -2
- package/lib/mjs/templates/index.d.ts +226 -1
- package/lib/mjs/utils/Evaluator.js +4 -33
- package/lib/mjs/utils/i18n.d.ts +16 -0
- package/lib/mjs/utils/i18n.js +81 -0
- package/lib/mjs/utils/utils.d.ts +1 -1
- package/lib/mjs/utils/utils.js +8 -9
- package/lib/mjs/validator/Validator.d.ts +30 -2
- package/lib/mjs/validator/Validator.js +31 -9
- package/lib/mjs/validator/rules/Select.js +1 -2
- package/lib/mjs/validator/rules/Unique.d.ts +1 -1
- package/lib/mjs/validator/rules/Unique.js +1 -2
- package/lib/mjs/widgets/CalendarWidget.d.ts +1 -0
- package/lib/mjs/widgets/InputWidget.d.ts +1 -1
- package/lib/mjs/widgets/InputWidget.js +1 -2
- package/package.json +24 -25
@@ -49,6 +49,7 @@ export default class WebformBuilder extends Component {
|
|
49
49
|
weight: number;
|
50
50
|
};
|
51
51
|
};
|
52
|
+
redraw(): Promise<void> | Promise<boolean>;
|
52
53
|
set form(arg: any);
|
53
54
|
get form(): any;
|
54
55
|
get container(): any;
|
@@ -60,6 +61,7 @@ export default class WebformBuilder extends Component {
|
|
60
61
|
findNamespaceRoot(component: any): any;
|
61
62
|
recurseNamespace(component: any): any;
|
62
63
|
render(): any;
|
64
|
+
attach(element: any): Promise<any>;
|
63
65
|
searchFields(searchString?: string): void;
|
64
66
|
orderComponents(groupInfo: any, foundComponents: any): void;
|
65
67
|
updateDragAndDrop(): any;
|
@@ -86,6 +88,9 @@ export default class WebformBuilder extends Component {
|
|
86
88
|
saveComponent(component: any, parent: any, isNew: any, original: any): boolean;
|
87
89
|
isComponentCreated: boolean | undefined;
|
88
90
|
emitSaveComponentEvent(schema: any, originalComp: any, parentComponentSchema: any, path: any, index: any, isNew: any, originalComponentSchema: any): void;
|
91
|
+
attachEditComponentControls(component: any, parent: any, isNew: any, original: any, ComponentClass: any): void;
|
92
|
+
saved: boolean | undefined;
|
93
|
+
showPreview: any;
|
89
94
|
editComponent(component: any, parent: any, isNew: any, isJsonEdit: any, original: any, flags?: {}): void;
|
90
95
|
editForm: Webform | undefined;
|
91
96
|
preview: Webform | null | undefined;
|
@@ -93,7 +98,7 @@ export default class WebformBuilder extends Component {
|
|
93
98
|
dialog: any;
|
94
99
|
updateComponentKey(data: any): any;
|
95
100
|
moveComponent(component: any): void;
|
96
|
-
|
101
|
+
selectedComponent: any;
|
97
102
|
moveHandler: (e: any) => void;
|
98
103
|
updateComponentPlacement(direction: any): void;
|
99
104
|
stopMoving(comp: any): void;
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Webform_1 = __importDefault(require("./Webform"));
|
7
7
|
const Component_1 = __importDefault(require("./components/_classes/component/Component"));
|
8
8
|
const tippy_js_1 = __importDefault(require("tippy.js"));
|
9
|
-
const native_promise_only_1 = __importDefault(require("native-promise-only"));
|
10
9
|
const Components_1 = __importDefault(require("./components/Components"));
|
11
10
|
const Formio_1 = require("./Formio");
|
12
11
|
const utils_1 = require("./utils/utils");
|
@@ -37,8 +36,10 @@ class WebformBuilder extends Component_1.default {
|
|
37
36
|
options.display = options.display || 'form';
|
38
37
|
super(null, options);
|
39
38
|
this.moveHandler = (e) => {
|
40
|
-
e.
|
41
|
-
|
39
|
+
if (e.keyCode === 38 || e.keyCode === 40 || e.keyCode === 13) {
|
40
|
+
e.stopPropagation();
|
41
|
+
e.preventDefault();
|
42
|
+
}
|
42
43
|
if (e.keyCode === 38) {
|
43
44
|
this.updateComponentPlacement(true);
|
44
45
|
}
|
@@ -46,7 +47,7 @@ class WebformBuilder extends Component_1.default {
|
|
46
47
|
this.updateComponentPlacement(false);
|
47
48
|
}
|
48
49
|
if (e.keyCode === 13) {
|
49
|
-
this.stopMoving(this.
|
50
|
+
this.stopMoving(this.selectedComponent);
|
50
51
|
}
|
51
52
|
};
|
52
53
|
this.setElement(element);
|
@@ -317,6 +318,9 @@ class WebformBuilder extends Component_1.default {
|
|
317
318
|
});
|
318
319
|
}
|
319
320
|
attachComponent(element, component) {
|
321
|
+
if (component instanceof WebformBuilder) {
|
322
|
+
return;
|
323
|
+
}
|
320
324
|
// Add component to element for later reference.
|
321
325
|
element.formioComponent = component;
|
322
326
|
component.loadRefs(element, {
|
@@ -583,7 +587,7 @@ class WebformBuilder extends Component_1.default {
|
|
583
587
|
const { subgroups = [], components } = result;
|
584
588
|
const filteredComponents = [];
|
585
589
|
for (const key in components) {
|
586
|
-
const isMatchedToTitle = components[key].title.toLowerCase().match(searchValue);
|
590
|
+
const isMatchedToTitle = this.t(components[key].title).toLowerCase().match(searchValue);
|
587
591
|
const isMatchedToKey = components[key].key.toLowerCase().match(searchValue);
|
588
592
|
if (isMatchedToTitle || isMatchedToKey) {
|
589
593
|
filteredComponents.push(components[key]);
|
@@ -701,8 +705,17 @@ class WebformBuilder extends Component_1.default {
|
|
701
705
|
}
|
702
706
|
getComponentInfo(key, group) {
|
703
707
|
let info;
|
708
|
+
// Need to check in first order as resource component key can be the same as from webform default components
|
709
|
+
if (group && group.slice(0, group.indexOf('-')) === 'resource') {
|
710
|
+
// This is an existing resource field.
|
711
|
+
const resourceGroups = this.groups.resource.subgroups;
|
712
|
+
const resourceGroup = lodash_1.default.find(resourceGroups, { key: group });
|
713
|
+
if (resourceGroup && resourceGroup.components.hasOwnProperty(`component-${key}`)) {
|
714
|
+
info = (0, utils_1.fastCloneDeep)(resourceGroup.components[`component-${key}`].schema);
|
715
|
+
}
|
716
|
+
}
|
704
717
|
// This is a new component
|
705
|
-
if (this.schemas.hasOwnProperty(key)) {
|
718
|
+
else if (this.schemas.hasOwnProperty(key)) {
|
706
719
|
info = (0, utils_1.fastCloneDeep)(this.schemas[key]);
|
707
720
|
}
|
708
721
|
else if (this.groups.hasOwnProperty(group)) {
|
@@ -711,14 +724,6 @@ class WebformBuilder extends Component_1.default {
|
|
711
724
|
info = (0, utils_1.fastCloneDeep)(groupComponents[key].schema);
|
712
725
|
}
|
713
726
|
}
|
714
|
-
else if (group.slice(0, group.indexOf('-')) === 'resource') {
|
715
|
-
// This is an existing resource field.
|
716
|
-
const resourceGroups = this.groups.resource.subgroups;
|
717
|
-
const resourceGroup = lodash_1.default.find(resourceGroups, { key: group });
|
718
|
-
if (resourceGroup && resourceGroup.components.hasOwnProperty(`component-${key}`)) {
|
719
|
-
info = (0, utils_1.fastCloneDeep)(resourceGroup.components[`component-${key}`].schema);
|
720
|
-
}
|
721
|
-
}
|
722
727
|
else if (group === 'searchFields') { //Search components go into this group
|
723
728
|
const resourceGroups = this.groups.resource.subgroups;
|
724
729
|
for (let ix = 0; ix < resourceGroups.length; ix++) {
|
@@ -866,7 +871,7 @@ class WebformBuilder extends Component_1.default {
|
|
866
871
|
rebuild = target.formioComponent.rebuild();
|
867
872
|
}
|
868
873
|
if (!rebuild) {
|
869
|
-
rebuild =
|
874
|
+
rebuild = Promise.resolve();
|
870
875
|
}
|
871
876
|
return rebuild.then(() => {
|
872
877
|
this.emit('addComponent', info, parent, path, index, isNew && !this.options.noNewEdit && !info.noNewEdit);
|
@@ -885,7 +890,7 @@ class WebformBuilder extends Component_1.default {
|
|
885
890
|
}
|
886
891
|
this.keyboardActionsEnabled = lodash_1.default.get(this.options, 'keyboardBuilder', false) || ((_a = this.options.properties) === null || _a === void 0 ? void 0 : _a.keyboardBuilder);
|
887
892
|
const isShowSubmitButton = !this.options.noDefaultSubmitButton
|
888
|
-
&& !form.components.length;
|
893
|
+
&& (!form.components.length || !form.components.find(comp => comp.key === 'submit'));
|
889
894
|
// Ensure there is at least a submit button.
|
890
895
|
if (isShowSubmitButton) {
|
891
896
|
form.components.push({
|
@@ -912,7 +917,7 @@ class WebformBuilder extends Component_1.default {
|
|
912
917
|
return this.rebuild().then(() => this.form);
|
913
918
|
});
|
914
919
|
}
|
915
|
-
return
|
920
|
+
return Promise.resolve(form);
|
916
921
|
}
|
917
922
|
populateRecaptchaSettings(form) {
|
918
923
|
//populate isEnabled for recaptcha form settings
|
@@ -961,7 +966,7 @@ class WebformBuilder extends Component_1.default {
|
|
961
966
|
else if (parent.formioComponent && parent.formioComponent.removeChildComponent) {
|
962
967
|
parent.formioComponent.removeChildComponent(component);
|
963
968
|
}
|
964
|
-
const rebuild = parent.formioComponent.rebuild() ||
|
969
|
+
const rebuild = parent.formioComponent.rebuild() || Promise.resolve();
|
965
970
|
rebuild.then(() => {
|
966
971
|
this.emit('removeComponent', component, parent.formioComponent.schema, path, index);
|
967
972
|
this.emit('change', this.form);
|
@@ -1010,6 +1015,9 @@ class WebformBuilder extends Component_1.default {
|
|
1010
1015
|
lodash_1.default.assign(defaultValueComponent.component, lodash_1.default.omit(Object.assign({}, component), [
|
1011
1016
|
'key',
|
1012
1017
|
'label',
|
1018
|
+
'labelPosition',
|
1019
|
+
'labelMargin',
|
1020
|
+
'labelWidth',
|
1013
1021
|
'placeholder',
|
1014
1022
|
'tooltip',
|
1015
1023
|
'hidden',
|
@@ -1139,7 +1147,7 @@ class WebformBuilder extends Component_1.default {
|
|
1139
1147
|
else if (isParentSaveChildMethod) {
|
1140
1148
|
parent.formioComponent.saveChildComponent(submissionData);
|
1141
1149
|
}
|
1142
|
-
const rebuild = parentComponent.rebuild() ||
|
1150
|
+
const rebuild = parentComponent.rebuild() || Promise.resolve();
|
1143
1151
|
return rebuild.then(() => {
|
1144
1152
|
const schema = parentContainer ? parentContainer[index] : (comp ? comp.schema : []);
|
1145
1153
|
this.emitSaveComponentEvent(schema, originalComp, parentComponent.schema, path, index, isNew, originalComponentSchema);
|
@@ -1153,16 +1161,71 @@ class WebformBuilder extends Component_1.default {
|
|
1153
1161
|
});
|
1154
1162
|
}
|
1155
1163
|
this.highlightInvalidComponents();
|
1156
|
-
return
|
1164
|
+
return Promise.resolve();
|
1157
1165
|
}
|
1158
1166
|
emitSaveComponentEvent(schema, originalComp, parentComponentSchema, path, index, isNew, originalComponentSchema) {
|
1159
1167
|
this.emit('saveComponent', schema, originalComp, parentComponentSchema, path, index, isNew, originalComponentSchema);
|
1160
1168
|
}
|
1169
|
+
attachEditComponentControls(component, parent, isNew, original, ComponentClass) {
|
1170
|
+
const cancelButtons = this.componentEdit.querySelectorAll('[ref="cancelButton"]');
|
1171
|
+
cancelButtons.forEach((cancelButton) => {
|
1172
|
+
this.editForm.addEventListener(cancelButton, 'click', (event) => {
|
1173
|
+
event.preventDefault();
|
1174
|
+
this.editForm.detach();
|
1175
|
+
this.emit('cancelComponent', component);
|
1176
|
+
this.dialog.close();
|
1177
|
+
this.highlightInvalidComponents();
|
1178
|
+
});
|
1179
|
+
});
|
1180
|
+
const removeButtons = this.componentEdit.querySelectorAll('[ref="removeButton"]');
|
1181
|
+
removeButtons.forEach((removeButton) => {
|
1182
|
+
this.editForm.addEventListener(removeButton, 'click', (event) => {
|
1183
|
+
event.preventDefault();
|
1184
|
+
// Since we are already removing the component, don't trigger another remove.
|
1185
|
+
this.saved = true;
|
1186
|
+
this.editForm.detach();
|
1187
|
+
this.removeComponent(component, parent, original);
|
1188
|
+
this.dialog.close();
|
1189
|
+
this.highlightInvalidComponents();
|
1190
|
+
});
|
1191
|
+
});
|
1192
|
+
const saveButtons = this.componentEdit.querySelectorAll('[ref="saveButton"]');
|
1193
|
+
saveButtons.forEach((saveButton) => {
|
1194
|
+
this.editForm.addEventListener(saveButton, 'click', (event) => {
|
1195
|
+
event.preventDefault();
|
1196
|
+
if (!this.editForm.checkValidity(this.editForm.data, true, this.editForm.data)) {
|
1197
|
+
this.editForm.setPristine(false);
|
1198
|
+
this.editForm.showErrors();
|
1199
|
+
return false;
|
1200
|
+
}
|
1201
|
+
this.saved = true;
|
1202
|
+
this.saveComponent(component, parent, isNew, original);
|
1203
|
+
});
|
1204
|
+
});
|
1205
|
+
const previewButtons = this.componentEdit.querySelectorAll('[ref="previewButton"]');
|
1206
|
+
previewButtons.forEach((previewButton) => {
|
1207
|
+
this.editForm.addEventListener(previewButton, 'click', (event) => {
|
1208
|
+
event.preventDefault();
|
1209
|
+
this.showPreview = !this.showPreview;
|
1210
|
+
this.editForm.detach();
|
1211
|
+
this.setContent(this.componentEdit, this.renderTemplate('builderEditForm', {
|
1212
|
+
componentInfo: ComponentClass.builderInfo,
|
1213
|
+
editForm: this.editForm.render(),
|
1214
|
+
preview: this.preview ? this.preview.render() : false,
|
1215
|
+
showPreview: this.showPreview,
|
1216
|
+
helplinks: this.helplinks,
|
1217
|
+
}));
|
1218
|
+
this.editForm.attach(this.componentEdit.querySelector('[ref="editForm"]'));
|
1219
|
+
this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
|
1220
|
+
});
|
1221
|
+
});
|
1222
|
+
}
|
1161
1223
|
editComponent(component, parent, isNew, isJsonEdit, original, flags = {}) {
|
1224
|
+
var _a;
|
1162
1225
|
if (!component.key) {
|
1163
1226
|
return;
|
1164
1227
|
}
|
1165
|
-
|
1228
|
+
this.saved = false;
|
1166
1229
|
const componentCopy = (0, utils_1.fastCloneDeep)(component);
|
1167
1230
|
let ComponentClass = Components_1.default.components[componentCopy.type];
|
1168
1231
|
const isCustom = ComponentClass === undefined;
|
@@ -1206,7 +1269,9 @@ class WebformBuilder extends Component_1.default {
|
|
1206
1269
|
}
|
1207
1270
|
]
|
1208
1271
|
} : ComponentClass.editForm(lodash_1.default.cloneDeep(overrides));
|
1209
|
-
const instanceOptions = {
|
1272
|
+
const instanceOptions = {
|
1273
|
+
inFormBuilder: true,
|
1274
|
+
};
|
1210
1275
|
this.hook('instanceOptionsPreview', instanceOptions);
|
1211
1276
|
const instance = new ComponentClass(componentCopy, instanceOptions);
|
1212
1277
|
const schema = this.hook('builderComponentSchema', component, instance);
|
@@ -1231,12 +1296,14 @@ class WebformBuilder extends Component_1.default {
|
|
1231
1296
|
]));
|
1232
1297
|
this.hook('previewFormSettitngs', schema, isJsonEdit);
|
1233
1298
|
}
|
1299
|
+
this.showPreview = (_a = ComponentClass.builderInfo.showPreview) !== null && _a !== void 0 ? _a : true;
|
1234
1300
|
this.componentEdit = this.ce('div', { 'class': 'component-edit-container' });
|
1235
1301
|
this.setContent(this.componentEdit, this.renderTemplate('builderEditForm', {
|
1236
1302
|
componentInfo: ComponentClass.builderInfo,
|
1237
1303
|
editForm: this.editForm.render(),
|
1238
1304
|
preview: this.preview ? this.preview.render() : false,
|
1239
|
-
|
1305
|
+
showPreview: this.showPreview,
|
1306
|
+
helplinks: this.helplinks
|
1240
1307
|
}));
|
1241
1308
|
this.dialog = this.createModal(this.componentEdit, lodash_1.default.get(this.options, 'dialogAttr', {}));
|
1242
1309
|
// This is the attach step.
|
@@ -1290,48 +1357,14 @@ class WebformBuilder extends Component_1.default {
|
|
1290
1357
|
this.updateComponent(event.data.componentJson || event.data, event.changed);
|
1291
1358
|
}
|
1292
1359
|
});
|
1293
|
-
|
1294
|
-
cancelButtons.forEach((cancelButton) => {
|
1295
|
-
this.addEventListener(cancelButton, 'click', (event) => {
|
1296
|
-
event.preventDefault();
|
1297
|
-
this.editForm.detach();
|
1298
|
-
this.emit('cancelComponent', component);
|
1299
|
-
this.dialog.close();
|
1300
|
-
this.highlightInvalidComponents();
|
1301
|
-
});
|
1302
|
-
});
|
1303
|
-
const removeButtons = this.componentEdit.querySelectorAll('[ref="removeButton"]');
|
1304
|
-
removeButtons.forEach((removeButton) => {
|
1305
|
-
this.addEventListener(removeButton, 'click', (event) => {
|
1306
|
-
event.preventDefault();
|
1307
|
-
// Since we are already removing the component, don't trigger another remove.
|
1308
|
-
saved = true;
|
1309
|
-
this.editForm.detach();
|
1310
|
-
this.removeComponent(component, parent, original);
|
1311
|
-
this.dialog.close();
|
1312
|
-
this.highlightInvalidComponents();
|
1313
|
-
});
|
1314
|
-
});
|
1315
|
-
const saveButtons = this.componentEdit.querySelectorAll('[ref="saveButton"]');
|
1316
|
-
saveButtons.forEach((saveButton) => {
|
1317
|
-
this.addEventListener(saveButton, 'click', (event) => {
|
1318
|
-
event.preventDefault();
|
1319
|
-
if (!this.editForm.checkValidity(this.editForm.data, true, this.editForm.data)) {
|
1320
|
-
this.editForm.setPristine(false);
|
1321
|
-
this.editForm.showErrors();
|
1322
|
-
return false;
|
1323
|
-
}
|
1324
|
-
saved = true;
|
1325
|
-
this.saveComponent(component, parent, isNew, original);
|
1326
|
-
});
|
1327
|
-
});
|
1360
|
+
this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
|
1328
1361
|
const dialogClose = () => {
|
1329
1362
|
this.editForm.destroy(true);
|
1330
1363
|
if (this.preview) {
|
1331
1364
|
this.preview.destroy(true);
|
1332
1365
|
this.preview = null;
|
1333
1366
|
}
|
1334
|
-
if (isNew && !saved) {
|
1367
|
+
if (isNew && !this.saved) {
|
1335
1368
|
this.removeComponent(component, parent, original);
|
1336
1369
|
this.highlightInvalidComponents();
|
1337
1370
|
}
|
@@ -1350,14 +1383,19 @@ class WebformBuilder extends Component_1.default {
|
|
1350
1383
|
data.type).replace(/^[0-9]*/, '');
|
1351
1384
|
}
|
1352
1385
|
moveComponent(component) {
|
1386
|
+
var _a;
|
1387
|
+
if (this.selectedComponent) {
|
1388
|
+
const prevSelected = this.selectedComponent;
|
1389
|
+
(_a = prevSelected.element) === null || _a === void 0 ? void 0 : _a.classList.remove('builder-component-selected');
|
1390
|
+
this.removeEventListener(document, 'keydown');
|
1391
|
+
}
|
1353
1392
|
component.element.focus();
|
1354
|
-
component.element.classList.add('builder-selected');
|
1355
|
-
this.
|
1356
|
-
this.
|
1357
|
-
this.addEventListener(component.element, 'keydown', this.moveHandler.bind(this));
|
1393
|
+
component.element.classList.add('builder-component-selected');
|
1394
|
+
this.selectedComponent = component;
|
1395
|
+
this.addEventListener(document, 'keydown', this.moveHandler.bind(this));
|
1358
1396
|
}
|
1359
1397
|
updateComponentPlacement(direction) {
|
1360
|
-
const component = this.
|
1398
|
+
const component = this.selectedComponent;
|
1361
1399
|
let index, info;
|
1362
1400
|
const step = direction ? -1 : 1;
|
1363
1401
|
if (component) {
|
@@ -1400,7 +1438,9 @@ class WebformBuilder extends Component_1.default {
|
|
1400
1438
|
}
|
1401
1439
|
stopMoving(comp) {
|
1402
1440
|
const parent = comp.element.parentNode;
|
1441
|
+
this.removeEventListener(document, 'keydown');
|
1403
1442
|
parent.formioComponent.rebuild();
|
1443
|
+
this.selectedComponent = null;
|
1404
1444
|
}
|
1405
1445
|
addNewComponent(element) {
|
1406
1446
|
var _a;
|
package/lib/cjs/Wizard.d.ts
CHANGED
@@ -11,7 +11,7 @@ declare class Wizard extends Webform {
|
|
11
11
|
_seenPages: number[];
|
12
12
|
subWizards: any[];
|
13
13
|
allPages: any[];
|
14
|
-
lastPromise:
|
14
|
+
lastPromise: Promise<void>;
|
15
15
|
enabledIndex: number;
|
16
16
|
editMode: boolean;
|
17
17
|
originalOptions: any;
|
@@ -40,6 +40,7 @@ declare class Wizard extends Webform {
|
|
40
40
|
prepareHeaderSettings(ctx: any, headerType: any): any;
|
41
41
|
redrawNavigation(): void;
|
42
42
|
redrawHeader(): void;
|
43
|
+
attach(element: any): Promise<void>;
|
43
44
|
scrollPageToTop(): void;
|
44
45
|
isBreadcrumbClickable(): any;
|
45
46
|
isAllowPrevious(): any;
|
@@ -60,16 +61,18 @@ declare class Wizard extends Webform {
|
|
60
61
|
establishPages(data?: any): any[];
|
61
62
|
updatePages(): void;
|
62
63
|
addComponents(): void;
|
63
|
-
setPage(num: any):
|
64
|
+
setPage(num: any): Promise<void>;
|
64
65
|
pageFieldLogic(page: any): void;
|
65
66
|
get currentPage(): any;
|
66
67
|
getNextPage(): number | null;
|
67
68
|
getPreviousPage(): number;
|
69
|
+
beforeSubmit(): Promise<any[]>;
|
70
|
+
beforePage(next: any): Promise<any>;
|
68
71
|
emitNextPage(): void;
|
69
|
-
nextPage():
|
72
|
+
nextPage(): Promise<void>;
|
70
73
|
emitPrevPage(): void;
|
71
|
-
prevPage():
|
72
|
-
cancel(noconfirm: any):
|
74
|
+
prevPage(): Promise<void>;
|
75
|
+
cancel(noconfirm: any): Promise<void> | Promise<number>;
|
73
76
|
getPageIndexByKey(key: any): number;
|
74
77
|
get schema(): Object;
|
75
78
|
setComponentSchema(): void;
|
package/lib/cjs/Wizard.js
CHANGED
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const native_promise_only_1 = __importDefault(require("native-promise-only"));
|
7
6
|
const lodash_1 = __importDefault(require("lodash"));
|
8
7
|
const Webform_1 = __importDefault(require("./Webform"));
|
9
8
|
const Formio_1 = require("./Formio");
|
@@ -40,7 +39,7 @@ class Wizard extends Webform_1.default {
|
|
40
39
|
this._seenPages = [0];
|
41
40
|
this.subWizards = [];
|
42
41
|
this.allPages = [];
|
43
|
-
this.lastPromise =
|
42
|
+
this.lastPromise = Promise.resolve();
|
44
43
|
this.enabledIndex = 0;
|
45
44
|
this.editMode = false;
|
46
45
|
this.originalOptions = lodash_1.default.cloneDeep(this.options);
|
@@ -503,8 +502,8 @@ class Wizard extends Webform_1.default {
|
|
503
502
|
item.key = item.title;
|
504
503
|
}
|
505
504
|
let page = currentPages[item.key];
|
506
|
-
const forceShow = this.
|
507
|
-
const forceHide = this.
|
505
|
+
const forceShow = this.shouldForceShow(item);
|
506
|
+
const forceHide = this.shouldForceHide(item);
|
508
507
|
let isVisible = !page
|
509
508
|
? (0, utils_1.checkCondition)(item, data, data, this.component, this) && !item.hidden
|
510
509
|
: page.visible;
|
@@ -556,7 +555,7 @@ class Wizard extends Webform_1.default {
|
|
556
555
|
}
|
557
556
|
setPage(num) {
|
558
557
|
if (num === this.page) {
|
559
|
-
return
|
558
|
+
return Promise.resolve();
|
560
559
|
}
|
561
560
|
if (num >= 0 && num < this.pages.length) {
|
562
561
|
this.page = num;
|
@@ -579,13 +578,13 @@ class Wizard extends Webform_1.default {
|
|
579
578
|
this.redraw().then(() => {
|
580
579
|
this.checkData(this.submission.data);
|
581
580
|
});
|
582
|
-
return
|
581
|
+
return Promise.resolve();
|
583
582
|
}
|
584
583
|
else if (!this.pages.length) {
|
585
584
|
this.redraw();
|
586
|
-
return
|
585
|
+
return Promise.resolve();
|
587
586
|
}
|
588
|
-
return
|
587
|
+
return Promise.reject('Page not found');
|
589
588
|
}
|
590
589
|
pageFieldLogic(page) {
|
591
590
|
var _a;
|
@@ -640,13 +639,13 @@ class Wizard extends Webform_1.default {
|
|
640
639
|
}
|
641
640
|
beforeSubmit() {
|
642
641
|
const pages = this.getPages();
|
643
|
-
return
|
642
|
+
return Promise.all(pages.map((page) => {
|
644
643
|
page.options.beforeSubmit = true;
|
645
644
|
return page.beforeSubmit();
|
646
645
|
}));
|
647
646
|
}
|
648
647
|
beforePage(next) {
|
649
|
-
return new
|
648
|
+
return new Promise((resolve, reject) => {
|
650
649
|
this.hook(next ? 'beforeNext' : 'beforePrev', this.currentPage, this.submission, (err) => {
|
651
650
|
if (err) {
|
652
651
|
this.showErrors(err, true);
|
@@ -690,7 +689,7 @@ class Wizard extends Webform_1.default {
|
|
690
689
|
else {
|
691
690
|
this.currentPage.components.forEach((comp) => comp.setPristine(false));
|
692
691
|
this.scrollIntoView(this.element);
|
693
|
-
return
|
692
|
+
return Promise.reject(this.showErrors([], true));
|
694
693
|
}
|
695
694
|
}
|
696
695
|
emitPrevPage() {
|
@@ -705,7 +704,7 @@ class Wizard extends Webform_1.default {
|
|
705
704
|
}
|
706
705
|
cancel(noconfirm) {
|
707
706
|
if (this.options.readOnly) {
|
708
|
-
return
|
707
|
+
return Promise.resolve();
|
709
708
|
}
|
710
709
|
if (super.cancel(noconfirm)) {
|
711
710
|
this.setPristine(true);
|
@@ -718,7 +717,7 @@ class Wizard extends Webform_1.default {
|
|
718
717
|
return this.page;
|
719
718
|
});
|
720
719
|
}
|
721
|
-
return
|
720
|
+
return Promise.resolve();
|
722
721
|
}
|
723
722
|
getPageIndexByKey(key) {
|
724
723
|
let pageIndex = this.page;
|
@@ -781,7 +780,8 @@ class Wizard extends Webform_1.default {
|
|
781
780
|
setValue(submission, flags = {}, ignoreEstablishment) {
|
782
781
|
this._submission = submission;
|
783
782
|
if ((flags && flags.fromSubmission && (this.options.readOnly || this.editMode) && !this.isHtmlRenderMode()) ||
|
784
|
-
(flags && flags.fromSubmission && (this.prefixComps.length || this.suffixComps.length) && submission._id)
|
783
|
+
(flags && flags.fromSubmission && (this.prefixComps.length || this.suffixComps.length) && submission._id) ||
|
784
|
+
(this.options.server && (this.prefixComps.length || this.suffixComps.length))) {
|
785
785
|
this._data = submission.data;
|
786
786
|
}
|
787
787
|
if (!ignoreEstablishment) {
|
@@ -30,10 +30,12 @@ export default class WizardBuilder extends WebformBuilder {
|
|
30
30
|
components: any[];
|
31
31
|
}[];
|
32
32
|
};
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
navigationDragula: any;
|
34
|
+
rebuild(): Promise<void> | Promise<boolean>;
|
35
|
+
addPage(page: any): Promise<void> | Promise<boolean>;
|
36
|
+
removePage(pageIndex: any, componentIndex: any): Promise<void> | Promise<boolean> | undefined;
|
37
|
+
onReorder(element: any, _target: any, _source: any, sibling: any): Promise<void> | undefined;
|
38
|
+
setPage(index: any): Promise<void> | Promise<boolean> | undefined;
|
37
39
|
getPageConfig(index: any, components?: any[]): {
|
38
40
|
title: string;
|
39
41
|
label: string;
|
package/lib/cjs/WizardBuilder.js
CHANGED
@@ -106,6 +106,11 @@ class WizardBuilder extends WebformBuilder_1.default {
|
|
106
106
|
const components = this._form.components.filter((component) => component.type !== 'button');
|
107
107
|
this._form.components = [this.getPageConfig(1, components)];
|
108
108
|
}
|
109
|
+
else {
|
110
|
+
const components = this._form.components
|
111
|
+
.filter((component) => component.type !== 'button' || component.action !== 'submit');
|
112
|
+
this._form.components = components;
|
113
|
+
}
|
109
114
|
this.rebuild();
|
110
115
|
}
|
111
116
|
get form() {
|
@@ -148,7 +153,10 @@ class WizardBuilder extends WebformBuilder_1.default {
|
|
148
153
|
page.parentNode.dragInfo = { index };
|
149
154
|
});
|
150
155
|
if (this.dragulaLib) {
|
151
|
-
this.dragulaLib([this.element.querySelector('.wizard-pages')]
|
156
|
+
this.navigationDragula = this.dragulaLib([this.element.querySelector('.wizard-pages')], {
|
157
|
+
moves: (el) => (!el.classList.contains('wizard-add-page')),
|
158
|
+
accepts: (el, target, source, sibling) => (sibling ? true : false),
|
159
|
+
})
|
152
160
|
.on('drop', this.onReorder.bind(this));
|
153
161
|
}
|
154
162
|
this.refs.addPage.forEach(link => {
|
@@ -165,6 +173,13 @@ class WizardBuilder extends WebformBuilder_1.default {
|
|
165
173
|
});
|
166
174
|
return super.attach(element);
|
167
175
|
}
|
176
|
+
detach() {
|
177
|
+
if (this.navigationDragula) {
|
178
|
+
this.navigationDragula.destroy();
|
179
|
+
}
|
180
|
+
this.navigationDragula = null;
|
181
|
+
super.detach();
|
182
|
+
}
|
168
183
|
rebuild() {
|
169
184
|
var _a;
|
170
185
|
const page = this.currentPage;
|
@@ -202,13 +217,15 @@ class WizardBuilder extends WebformBuilder_1.default {
|
|
202
217
|
}
|
203
218
|
}
|
204
219
|
onReorder(element, _target, _source, sibling) {
|
205
|
-
|
220
|
+
const isSiblingAnAddPageButton = sibling === null || sibling === void 0 ? void 0 : sibling.classList.contains('wizard-add-page');
|
221
|
+
// We still can paste before Add Page button
|
222
|
+
if (!element.dragInfo || (sibling && !sibling.dragInfo && !isSiblingAnAddPageButton)) {
|
206
223
|
console.warn('There is no Drag Info available for either dragged or sibling element');
|
207
224
|
return;
|
208
225
|
}
|
209
226
|
const oldPosition = element.dragInfo.index;
|
210
227
|
//should drop at next sibling position; no next sibling means drop to last position
|
211
|
-
const newPosition = (sibling ? sibling.dragInfo.index : this.pages.length);
|
228
|
+
const newPosition = (sibling && sibling.dragInfo ? sibling.dragInfo.index : this.pages.length);
|
212
229
|
const movedBelow = newPosition > oldPosition;
|
213
230
|
const formComponents = (0, utils_1.fastCloneDeep)(this._form.components);
|
214
231
|
const draggedRowData = this._form.components[oldPosition];
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const Element_1 = __importDefault(require("../Element"));
|
7
|
-
const native_promise_only_1 = __importDefault(require("native-promise-only"));
|
8
7
|
const lodash_1 = __importDefault(require("lodash"));
|
9
8
|
class FormioAddon extends Element_1.default {
|
10
9
|
static get info() {
|
@@ -30,7 +29,7 @@ class FormioAddon extends Element_1.default {
|
|
30
29
|
}
|
31
30
|
attach(element) {
|
32
31
|
this._element = element;
|
33
|
-
return
|
32
|
+
return Promise.resolve();
|
34
33
|
}
|
35
34
|
destroy() { }
|
36
35
|
}
|