@formio/js 5.0.0-rc.19 → 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 +1239 -1097
- 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 +1271 -1118
- 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 +713 -626
- 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 +12 -12
- 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 +14 -8
- package/lib/cjs/components/_classes/component/Component.js +24 -14
- 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 +9 -10
- 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 +12 -12
- 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 +14 -8
- package/lib/mjs/components/_classes/component/Component.js +24 -14
- 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 +9 -10
- 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 +14 -15
@@ -1,8 +1,7 @@
|
|
1
|
-
import NativePromise from 'native-promise-only';
|
2
1
|
import { setXhrHeaders } from './xhr';
|
3
2
|
const dropbox = (formio) => ({
|
4
3
|
uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback) {
|
5
|
-
return new
|
4
|
+
return new Promise(((resolve, reject) => {
|
6
5
|
// Send the file with data.
|
7
6
|
const xhr = new XMLHttpRequest();
|
8
7
|
if (typeof progressCallback === 'function') {
|
@@ -49,7 +48,7 @@ const dropbox = (formio) => ({
|
|
49
48
|
const token = formio.getToken();
|
50
49
|
file.url =
|
51
50
|
`${formio.formUrl}/storage/dropbox?path_lower=${file.path_lower}${token ? `&x-jwt-token=${token}` : ''}`;
|
52
|
-
return
|
51
|
+
return Promise.resolve(file);
|
53
52
|
}
|
54
53
|
});
|
55
54
|
dropbox.title = 'Dropbox';
|
@@ -1,7 +1,8 @@
|
|
1
1
|
export default googledrive;
|
2
2
|
declare function googledrive(formio: any): {
|
3
|
-
uploadFile(file: any, fileName: any, dir: any, progressCallback: any, url: any, options: any, fileKey: any, groupPermissions: any, groupId: any, abortCallback: any): any
|
4
|
-
downloadFile(file: any): any
|
3
|
+
uploadFile(file: any, fileName: any, dir: any, progressCallback: any, url: any, options: any, fileKey: any, groupPermissions: any, groupId: any, abortCallback: any): Promise<any>;
|
4
|
+
downloadFile(file: any): Promise<any>;
|
5
|
+
deleteFile: (fileInfo: any) => any;
|
5
6
|
};
|
6
7
|
declare namespace googledrive {
|
7
8
|
const title: string;
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import NativePromise from 'native-promise-only';
|
2
1
|
import { setXhrHeaders } from './xhr';
|
3
2
|
const googledrive = (formio) => ({
|
4
3
|
uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback) {
|
5
|
-
return new
|
4
|
+
return new Promise(((resolve, reject) => {
|
6
5
|
// Send the file with data.
|
7
6
|
const xhr = new XMLHttpRequest();
|
8
7
|
if (typeof progressCallback === 'function') {
|
@@ -48,7 +47,11 @@ const googledrive = (formio) => ({
|
|
48
47
|
const token = formio.getToken();
|
49
48
|
file.url =
|
50
49
|
`${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}`;
|
51
|
-
return
|
50
|
+
return Promise.resolve(file);
|
51
|
+
},
|
52
|
+
deleteFile: function deleteFile(fileInfo) {
|
53
|
+
var url = ''.concat(formio.formUrl, `/storage/gdrive?id=${fileInfo.id}&name=${fileInfo.originalName}`);
|
54
|
+
return formio.makeRequest('', url, 'delete');
|
52
55
|
}
|
53
56
|
});
|
54
57
|
googledrive.title = 'Google Drive';
|
@@ -2,9 +2,9 @@ export default indexeddb;
|
|
2
2
|
declare function indexeddb(): {
|
3
3
|
title: string;
|
4
4
|
name: string;
|
5
|
-
uploadFile(file: any, fileName: any, dir: any, progressCallback: any, url: any, options: any): any;
|
6
|
-
downloadFile(file: any, options: any): any
|
7
|
-
deleteFile(file: any, options: any): any
|
5
|
+
uploadFile(file: any, fileName: any, dir: any, progressCallback: any, url: any, options: any): Promise<any> | undefined;
|
6
|
+
downloadFile(file: any, options: any): Promise<any>;
|
7
|
+
deleteFile(file: any, options: any): Promise<any>;
|
8
8
|
};
|
9
9
|
declare namespace indexeddb {
|
10
10
|
const title: string;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
2
|
-
import NativePromise from 'native-promise-only';
|
3
2
|
const indexeddb = () => ({
|
4
3
|
title: 'indexedDB',
|
5
4
|
name: 'indexeddb',
|
@@ -8,8 +7,8 @@ const indexeddb = () => ({
|
|
8
7
|
console.log('This browser doesn\'t support IndexedDB');
|
9
8
|
return;
|
10
9
|
}
|
11
|
-
return new
|
12
|
-
const request = indexedDB.open(options.indexeddb
|
10
|
+
return new Promise((resolve) => {
|
11
|
+
const request = indexedDB.open(options.indexeddb);
|
13
12
|
request.onsuccess = function (event) {
|
14
13
|
const db = event.target.result;
|
15
14
|
resolve(db);
|
@@ -20,7 +19,7 @@ const indexeddb = () => ({
|
|
20
19
|
};
|
21
20
|
}).then((db) => {
|
22
21
|
const reader = new FileReader();
|
23
|
-
return new
|
22
|
+
return new Promise((resolve, reject) => {
|
24
23
|
reader.onload = () => {
|
25
24
|
const blobObject = new Blob([file], { type: file.type });
|
26
25
|
const id = uuidv4(blobObject);
|
@@ -57,14 +56,14 @@ const indexeddb = () => ({
|
|
57
56
|
});
|
58
57
|
},
|
59
58
|
downloadFile(file, options) {
|
60
|
-
return new
|
61
|
-
const request = indexedDB.open(options.indexeddb
|
59
|
+
return new Promise((resolve) => {
|
60
|
+
const request = indexedDB.open(options.indexeddb);
|
62
61
|
request.onsuccess = function (event) {
|
63
62
|
const db = event.target.result;
|
64
63
|
resolve(db);
|
65
64
|
};
|
66
65
|
}).then((db) => {
|
67
|
-
return new
|
66
|
+
return new Promise((resolve, reject) => {
|
68
67
|
const trans = db.transaction([options.indexeddbTable], 'readonly');
|
69
68
|
const store = trans.objectStore(options.indexeddbTable).get(file.id);
|
70
69
|
store.onsuccess = () => {
|
@@ -92,14 +91,14 @@ const indexeddb = () => ({
|
|
92
91
|
});
|
93
92
|
},
|
94
93
|
deleteFile(file, options) {
|
95
|
-
return new
|
96
|
-
const request = indexedDB.open(options.indexeddb
|
94
|
+
return new Promise((resolve) => {
|
95
|
+
const request = indexedDB.open(options.indexeddb);
|
97
96
|
request.onsuccess = function (event) {
|
98
97
|
const db = event.target.result;
|
99
98
|
resolve(db);
|
100
99
|
};
|
101
100
|
}).then((db) => {
|
102
|
-
return new
|
101
|
+
return new Promise((resolve, reject) => {
|
103
102
|
const trans = db.transaction([options.indexeddbTable], 'readwrite');
|
104
103
|
const store = trans.objectStore(options.indexeddbTable).delete(file.id);
|
105
104
|
store.onsuccess = () => {
|
@@ -1,7 +1,17 @@
|
|
1
1
|
export default s3;
|
2
2
|
declare function s3(formio: any): {
|
3
|
-
uploadFile(file: any, fileName: any, dir: any, progressCallback: any, url: any, options: any, fileKey: any, groupPermissions: any, groupId: any, abortCallback: any):
|
3
|
+
uploadFile(file: any, fileName: any, dir: any, progressCallback: any, url: any, options: any, fileKey: any, groupPermissions: any, groupId: any, abortCallback: any): Promise<{
|
4
|
+
storage: string;
|
5
|
+
name: any;
|
6
|
+
bucket: any;
|
7
|
+
key: any;
|
8
|
+
url: any;
|
9
|
+
acl: any;
|
10
|
+
size: any;
|
11
|
+
type: any;
|
12
|
+
}>;
|
4
13
|
downloadFile(file: any): any;
|
14
|
+
deleteFile(fileInfo: any): any;
|
5
15
|
};
|
6
16
|
declare namespace s3 {
|
7
17
|
const title: string;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import NativePromise from 'native-promise-only';
|
2
1
|
import XHR from './xhr';
|
3
2
|
const s3 = (formio) => ({
|
4
3
|
uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback) {
|
@@ -37,8 +36,12 @@ const s3 = (formio) => ({
|
|
37
36
|
return formio.makeRequest('file', `${formio.formUrl}/storage/s3?bucket=${XHR.trim(file.bucket)}&key=${XHR.trim(file.key)}`, 'GET');
|
38
37
|
}
|
39
38
|
else {
|
40
|
-
return
|
39
|
+
return Promise.resolve(file);
|
41
40
|
}
|
41
|
+
},
|
42
|
+
deleteFile(fileInfo) {
|
43
|
+
const url = `${formio.formUrl}/file/${XHR.trim(fileInfo.name)}?bucket=${XHR.trim(fileInfo.bucket)}&key=${XHR.trim(fileInfo.key)}`;
|
44
|
+
return formio.makeRequest('', url, 'delete');
|
42
45
|
}
|
43
46
|
});
|
44
47
|
s3.title = 'S3';
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { uniqueName } from '../../utils/utils';
|
2
|
-
import NativePromise from 'native-promise-only';
|
3
2
|
/**
|
4
3
|
* UploadAdapter for CKEditor https://ckeditor.com/docs/ckeditor5/latest/framework/guides/deep-dive/upload-adapter.html
|
5
4
|
*/
|
@@ -11,7 +10,7 @@ class FormioUploadAdapter {
|
|
11
10
|
}
|
12
11
|
upload() {
|
13
12
|
return this.loader.file
|
14
|
-
.then(file => new
|
13
|
+
.then(file => new Promise((resolve, reject) => {
|
15
14
|
const { uploadStorage, uploadUrl, uploadOptions, uploadDir, fileKey } = this.component.component;
|
16
15
|
const uploadParams = [
|
17
16
|
uploadStorage,
|
@@ -3,8 +3,8 @@ declare function url(formio: any): {
|
|
3
3
|
title: string;
|
4
4
|
name: string;
|
5
5
|
uploadFile(file: any, name: any, dir: any, progressCallback: any, url: any, options: any, fileKey: any, groupPermissions: any, groupId: any, abortCallback: any): any;
|
6
|
-
deleteFile(fileInfo: any): any
|
7
|
-
downloadFile(file: any): any
|
6
|
+
deleteFile(fileInfo: any): Promise<any>;
|
7
|
+
downloadFile(file: any): Promise<any>;
|
8
8
|
};
|
9
9
|
declare namespace url {
|
10
10
|
const title: string;
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import NativePromise from 'native-promise-only';
|
2
1
|
const url = (formio) => {
|
3
2
|
const xhrRequest = (url, name, query, data, options, progressCallback, abortCallback) => {
|
4
|
-
return new
|
3
|
+
return new Promise((resolve, reject) => {
|
5
4
|
const xhr = new XMLHttpRequest();
|
6
5
|
const json = (typeof data === 'string');
|
7
6
|
const fd = new FormData();
|
@@ -60,7 +59,15 @@ const url = (formio) => {
|
|
60
59
|
if (options) {
|
61
60
|
const parsedOptions = typeof options === 'string' ? JSON.parse(options) : options;
|
62
61
|
for (const prop in parsedOptions) {
|
63
|
-
|
62
|
+
if (prop === 'headers') {
|
63
|
+
const headers = parsedOptions['headers'];
|
64
|
+
for (const header in headers) {
|
65
|
+
xhr.setRequestHeader(header, headers[header]);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
xhr[prop] = parsedOptions[prop];
|
70
|
+
}
|
64
71
|
}
|
65
72
|
}
|
66
73
|
xhr.send(json ? data : fd);
|
@@ -103,7 +110,7 @@ const url = (formio) => {
|
|
103
110
|
}
|
104
111
|
},
|
105
112
|
deleteFile(fileInfo) {
|
106
|
-
return new
|
113
|
+
return new Promise((resolve, reject) => {
|
107
114
|
const xhr = new XMLHttpRequest();
|
108
115
|
xhr.open('DELETE', fileInfo.url, true);
|
109
116
|
xhr.onload = () => {
|
@@ -125,7 +132,7 @@ const url = (formio) => {
|
|
125
132
|
return xhrRequest(file.url, file.name, {}, JSON.stringify(file)).then(response => response.data);
|
126
133
|
}
|
127
134
|
// Return the original as there is nothing to do.
|
128
|
-
return
|
135
|
+
return Promise.resolve(file);
|
129
136
|
}
|
130
137
|
};
|
131
138
|
};
|
@@ -3,5 +3,5 @@ export default XHR;
|
|
3
3
|
declare namespace XHR {
|
4
4
|
function trim(text: any): any;
|
5
5
|
function path(items: any): any;
|
6
|
-
function upload(formio: any, type: any, xhrCb: any, file: any, fileName: any, dir: any, progressCallback: any, groupPermissions: any, groupId: any, abortCallback: any): any
|
6
|
+
function upload(formio: any, type: any, xhrCb: any, file: any, fileName: any, dir: any, progressCallback: any, groupPermissions: any, groupId: any, abortCallback: any): Promise<any>;
|
7
7
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import NativePromise from 'native-promise-only';
|
2
1
|
import _trim from 'lodash/trim';
|
3
2
|
export const setXhrHeaders = (formio, xhr) => {
|
4
3
|
const { headers } = formio.options;
|
@@ -22,7 +21,7 @@ const XHR = {
|
|
22
21
|
return items.filter(item => !!item).map(XHR.trim).join('/');
|
23
22
|
},
|
24
23
|
upload(formio, type, xhrCb, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback) {
|
25
|
-
return new
|
24
|
+
return new Promise(((resolve, reject) => {
|
26
25
|
// Send the pre response to sign the upload.
|
27
26
|
const pre = new XMLHttpRequest();
|
28
27
|
// This only fires on a network error.
|
@@ -1,4 +1,229 @@
|
|
1
1
|
declare namespace _default {
|
2
|
-
const bootstrap:
|
2
|
+
const bootstrap: {
|
3
|
+
webform: {
|
4
|
+
form: string;
|
5
|
+
builder: string;
|
6
|
+
};
|
7
|
+
well: {
|
8
|
+
form: string;
|
9
|
+
};
|
10
|
+
wizard: {
|
11
|
+
form: string;
|
12
|
+
builder: string;
|
13
|
+
};
|
14
|
+
wizardHeader: {
|
15
|
+
form: string;
|
16
|
+
};
|
17
|
+
wizardHeaderClassic: {
|
18
|
+
form: string;
|
19
|
+
};
|
20
|
+
wizardHeaderVertical: {
|
21
|
+
form: string;
|
22
|
+
};
|
23
|
+
wizardNav: {
|
24
|
+
form: string;
|
25
|
+
};
|
26
|
+
errorsList: {
|
27
|
+
form: string;
|
28
|
+
};
|
29
|
+
alert: {
|
30
|
+
form: string;
|
31
|
+
};
|
32
|
+
treeView: {
|
33
|
+
form: string;
|
34
|
+
};
|
35
|
+
treeEdit: {
|
36
|
+
form: string;
|
37
|
+
};
|
38
|
+
transform(type: any, text: any, instance: any): any;
|
39
|
+
defaultIconset: string;
|
40
|
+
iconClass: (iconset: any, name: any, spinning: any) => string;
|
41
|
+
cssClasses: {
|
42
|
+
'border-default': string;
|
43
|
+
'formio-tab-panel-active': string;
|
44
|
+
'formio-tab-link-active': string;
|
45
|
+
'formio-tab-link-container-active': string;
|
46
|
+
'formio-form-error': string;
|
47
|
+
'formio-form-alert': string;
|
48
|
+
'formio-label-error': string;
|
49
|
+
'formio-input-error': string;
|
50
|
+
'formio-alert-danger': string;
|
51
|
+
'formio-alert-success': string;
|
52
|
+
'formio-alert-warning': string;
|
53
|
+
'formio-modal-cancel-button': string;
|
54
|
+
'formio-modal-confirm-button': string;
|
55
|
+
'form-group': string;
|
56
|
+
};
|
57
|
+
address: {
|
58
|
+
form: string;
|
59
|
+
html: string;
|
60
|
+
};
|
61
|
+
builder: {
|
62
|
+
form: string;
|
63
|
+
};
|
64
|
+
builderComponent: {
|
65
|
+
form: string;
|
66
|
+
};
|
67
|
+
builderComponents: {
|
68
|
+
form: string;
|
69
|
+
};
|
70
|
+
builderEditForm: {
|
71
|
+
form: string;
|
72
|
+
};
|
73
|
+
builderPlaceholder: {
|
74
|
+
form: string;
|
75
|
+
};
|
76
|
+
builderSidebar: {
|
77
|
+
form: string;
|
78
|
+
};
|
79
|
+
builderSidebarGroup: {
|
80
|
+
form: string;
|
81
|
+
};
|
82
|
+
builderWizard: {
|
83
|
+
form: string;
|
84
|
+
};
|
85
|
+
button: {
|
86
|
+
form: string;
|
87
|
+
html: string;
|
88
|
+
};
|
89
|
+
checkbox: {
|
90
|
+
form: string;
|
91
|
+
html: string;
|
92
|
+
};
|
93
|
+
columns: {
|
94
|
+
form: string;
|
95
|
+
};
|
96
|
+
component: {
|
97
|
+
form: string;
|
98
|
+
};
|
99
|
+
componentModal: {
|
100
|
+
form: string;
|
101
|
+
};
|
102
|
+
components: {
|
103
|
+
form: string;
|
104
|
+
};
|
105
|
+
tableComponents: {
|
106
|
+
form: string;
|
107
|
+
};
|
108
|
+
container: {
|
109
|
+
form: string;
|
110
|
+
};
|
111
|
+
datagrid: {
|
112
|
+
form: string;
|
113
|
+
html: string;
|
114
|
+
};
|
115
|
+
day: {
|
116
|
+
form: string;
|
117
|
+
};
|
118
|
+
dialog: {
|
119
|
+
form: string;
|
120
|
+
};
|
121
|
+
editgrid: {
|
122
|
+
form: string;
|
123
|
+
html: string;
|
124
|
+
};
|
125
|
+
editgridTable: {
|
126
|
+
form: string;
|
127
|
+
html: string;
|
128
|
+
};
|
129
|
+
field: {
|
130
|
+
form: string;
|
131
|
+
align: string;
|
132
|
+
};
|
133
|
+
fieldset: {
|
134
|
+
form: string;
|
135
|
+
};
|
136
|
+
file: {
|
137
|
+
form: string;
|
138
|
+
};
|
139
|
+
html: {
|
140
|
+
form: string;
|
141
|
+
};
|
142
|
+
icon: {
|
143
|
+
form: string;
|
144
|
+
};
|
145
|
+
input: {
|
146
|
+
form: string;
|
147
|
+
html: string;
|
148
|
+
};
|
149
|
+
label: {
|
150
|
+
form: string;
|
151
|
+
};
|
152
|
+
loader: {
|
153
|
+
form: string;
|
154
|
+
};
|
155
|
+
loading: {
|
156
|
+
form: string;
|
157
|
+
};
|
158
|
+
map: {
|
159
|
+
form: string;
|
160
|
+
};
|
161
|
+
message: {
|
162
|
+
form: string;
|
163
|
+
};
|
164
|
+
modaledit: {
|
165
|
+
form: string;
|
166
|
+
};
|
167
|
+
modaldialog: {
|
168
|
+
form: string;
|
169
|
+
};
|
170
|
+
modalPreview: {
|
171
|
+
form: string;
|
172
|
+
};
|
173
|
+
multipleMasksInput: {
|
174
|
+
form: string;
|
175
|
+
};
|
176
|
+
multiValueRow: {
|
177
|
+
form: string;
|
178
|
+
};
|
179
|
+
multiValueTable: {
|
180
|
+
form: string;
|
181
|
+
};
|
182
|
+
panel: {
|
183
|
+
form: string;
|
184
|
+
};
|
185
|
+
pdf: {
|
186
|
+
form: string;
|
187
|
+
};
|
188
|
+
pdfBuilder: {
|
189
|
+
form: string;
|
190
|
+
};
|
191
|
+
pdfBuilderUpload: {
|
192
|
+
form: string;
|
193
|
+
};
|
194
|
+
radio: {
|
195
|
+
form: string;
|
196
|
+
html: string;
|
197
|
+
};
|
198
|
+
resourceAdd: {
|
199
|
+
form: string;
|
200
|
+
};
|
201
|
+
select: {
|
202
|
+
form: string;
|
203
|
+
html: string;
|
204
|
+
};
|
205
|
+
selectOption: {
|
206
|
+
form: string;
|
207
|
+
html: string;
|
208
|
+
};
|
209
|
+
signature: {
|
210
|
+
form: string;
|
211
|
+
html: string;
|
212
|
+
};
|
213
|
+
survey: {
|
214
|
+
form: string;
|
215
|
+
html: string;
|
216
|
+
};
|
217
|
+
tab: {
|
218
|
+
flat: string;
|
219
|
+
form: string;
|
220
|
+
};
|
221
|
+
table: {
|
222
|
+
form: string;
|
223
|
+
};
|
224
|
+
tree: {
|
225
|
+
form: string;
|
226
|
+
};
|
227
|
+
};
|
3
228
|
}
|
4
229
|
export default _default;
|
@@ -1,24 +1,12 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import stringHash from 'string-hash';
|
3
|
+
import { Evaluator as CoreEvaluator } from '@formio/core/utils';
|
3
4
|
const Evaluator = {
|
4
5
|
noeval: false,
|
5
6
|
protectedEval: false,
|
6
7
|
cache: {},
|
7
|
-
templateSettings:
|
8
|
-
|
9
|
-
interpolate: /\{\{([\s\S]+?)\}\}/g,
|
10
|
-
escape: /\{\{\{([\s\S]+?)\}\}\}/g
|
11
|
-
},
|
12
|
-
evaluator(func, ...params) {
|
13
|
-
if (Evaluator.noeval) {
|
14
|
-
console.warn('No evaluations allowed for this renderer.');
|
15
|
-
return _.noop;
|
16
|
-
}
|
17
|
-
if (typeof params[0] === 'object') {
|
18
|
-
params = _.keys(params[0]);
|
19
|
-
}
|
20
|
-
return new Function(...params, func);
|
21
|
-
},
|
8
|
+
templateSettings: CoreEvaluator.templateSettings,
|
9
|
+
evaluator: CoreEvaluator.evaluator,
|
22
10
|
template(template, hash) {
|
23
11
|
hash = hash || stringHash(template);
|
24
12
|
if (Evaluator.cache[hash]) {
|
@@ -48,24 +36,7 @@ const Evaluator = {
|
|
48
36
|
rawTemplate = String(rawTemplate);
|
49
37
|
let template;
|
50
38
|
if (Evaluator.noeval || options.noeval) {
|
51
|
-
|
52
|
-
return rawTemplate.replace(/({{\s*(.*?)\s*}})/g, (match, $1, $2) => {
|
53
|
-
// Allow for conditional values.
|
54
|
-
const parts = $2.split('||').map(item => item.trim());
|
55
|
-
let value = '';
|
56
|
-
let path = '';
|
57
|
-
for (let i = 0; i < parts.length; i++) {
|
58
|
-
path = parts[i];
|
59
|
-
value = _.get(data, path);
|
60
|
-
if (value) {
|
61
|
-
break;
|
62
|
-
}
|
63
|
-
}
|
64
|
-
if (options.data) {
|
65
|
-
_.set(options.data, path, value);
|
66
|
-
}
|
67
|
-
return value;
|
68
|
-
});
|
39
|
+
return CoreEvaluator.interpolateString(rawTemplate, data, _options);
|
69
40
|
}
|
70
41
|
else {
|
71
42
|
template = Evaluator.template(rawTemplate);
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* This file is used to mimic the i18n library interface.
|
3
|
+
*/
|
4
|
+
export class I18n {
|
5
|
+
static init(languages?: {}): I18n;
|
6
|
+
static createInstance(): I18n;
|
7
|
+
constructor(languages?: {});
|
8
|
+
languages: {};
|
9
|
+
language: string;
|
10
|
+
currentLanguage: any;
|
11
|
+
setLanguages(languages: any): void;
|
12
|
+
dir(lang?: string): "rtl" | "ltr";
|
13
|
+
changeLanguage(language: any, ready?: null): void;
|
14
|
+
addResourceBundle(language: any, type: any, strings: any): void;
|
15
|
+
t(text: any, ...args: any[]): any;
|
16
|
+
}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import { Evaluator } from '@formio/core/utils';
|
2
|
+
import i18n from '../i18n';
|
3
|
+
const i18Defaults = {};
|
4
|
+
for (const lang in i18n.resources) {
|
5
|
+
if (i18n.resources.hasOwnProperty(lang)) {
|
6
|
+
i18Defaults[lang] = i18n.resources[lang].translation;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* This file is used to mimic the i18n library interface.
|
11
|
+
*/
|
12
|
+
export class I18n {
|
13
|
+
languages = i18Defaults;
|
14
|
+
language = 'en';
|
15
|
+
currentLanguage = i18Defaults.en;
|
16
|
+
constructor(languages = {}) {
|
17
|
+
this.setLanguages(languages);
|
18
|
+
this.changeLanguage(this.language);
|
19
|
+
}
|
20
|
+
setLanguages(languages) {
|
21
|
+
if (languages.resources) {
|
22
|
+
for (const lang in languages.resources) {
|
23
|
+
if (languages.resources.hasOwnProperty(lang)) {
|
24
|
+
languages[lang] = languages.resources[lang].translation;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
delete languages.resources;
|
28
|
+
}
|
29
|
+
if (languages.lng) {
|
30
|
+
languages.language = languages.lng;
|
31
|
+
delete languages.lng;
|
32
|
+
}
|
33
|
+
// Do not use these configurations.
|
34
|
+
delete languages.nsSeparator;
|
35
|
+
delete languages.keySeparator;
|
36
|
+
delete languages.pluralSeparator;
|
37
|
+
delete languages.contextSeparator;
|
38
|
+
// Now establish the languages default.
|
39
|
+
if (languages.language) {
|
40
|
+
this.language = languages.language;
|
41
|
+
}
|
42
|
+
for (const lang in languages) {
|
43
|
+
if (lang !== 'language' && languages.hasOwnProperty(lang)) {
|
44
|
+
if (!this.languages[lang]) {
|
45
|
+
this.languages[lang] = {};
|
46
|
+
}
|
47
|
+
this.languages[lang] = { ...this.languages[lang], ...languages[lang] };
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
static init(languages = {}) {
|
52
|
+
return new I18n(languages);
|
53
|
+
}
|
54
|
+
dir(lang = '') {
|
55
|
+
lang = lang || this.language;
|
56
|
+
const rtls = ['ar', 'he', 'fa', 'ps', 'ur'];
|
57
|
+
return rtls.includes(lang) ? 'rtl' : 'ltr';
|
58
|
+
}
|
59
|
+
static createInstance() {
|
60
|
+
return new I18n();
|
61
|
+
}
|
62
|
+
changeLanguage(language, ready = null) {
|
63
|
+
if (!this.languages[language]) {
|
64
|
+
language = 'en';
|
65
|
+
}
|
66
|
+
this.language = language;
|
67
|
+
this.currentLanguage = this.languages[language] ? this.languages[language] : {};
|
68
|
+
if (ready) {
|
69
|
+
ready();
|
70
|
+
}
|
71
|
+
}
|
72
|
+
addResourceBundle(language, type, strings) {
|
73
|
+
this.languages[language] = strings;
|
74
|
+
}
|
75
|
+
t(text, ...args) {
|
76
|
+
if (this.currentLanguage[text]) {
|
77
|
+
return Evaluator.interpolateString(this.currentLanguage[text], ...args);
|
78
|
+
}
|
79
|
+
return Evaluator.interpolateString(text, ...args);
|
80
|
+
}
|
81
|
+
}
|
package/lib/mjs/utils/utils.d.ts
CHANGED
@@ -223,7 +223,7 @@ export function getNumberSeparators(lang?: string): {
|
|
223
223
|
};
|
224
224
|
export function getNumberDecimalLimit(component: any, defaultLimit: any): any;
|
225
225
|
export function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, }: {
|
226
|
-
currency
|
226
|
+
currency: any;
|
227
227
|
decimalLimit: any;
|
228
228
|
decimalSeparator: any;
|
229
229
|
lang: any;
|