@formio/js 5.0.0-rc.52 → 5.0.0-rc.53
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +551 -541
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -1
- package/dist/formio.full.js +553 -543
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -1
- package/dist/formio.js +10 -10
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +14 -4
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +3 -1
- package/lib/cjs/Form.d.ts +281 -10
- package/lib/cjs/Form.js +22 -35
- package/lib/cjs/FormBuilder.d.ts +187 -2
- package/lib/cjs/FormBuilder.js +29 -6
- package/lib/cjs/PDF.d.ts +0 -1
- package/lib/cjs/Webform.d.ts +6 -6
- package/lib/cjs/Webform.js +2 -2
- package/lib/cjs/Wizard.d.ts +1 -1
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +8 -6
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +6 -4
- package/lib/cjs/components/_classes/field/Field.d.ts +11 -2
- package/lib/cjs/components/_classes/field/Field.js +13 -1
- package/lib/cjs/components/_classes/input/Input.d.ts +4 -3
- package/lib/cjs/components/_classes/input/Input.js +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.form.d.ts +4 -5
- package/lib/cjs/components/_classes/list/ListComponent.form.js +3 -2
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +42 -11
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +37 -3
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +127 -33
- package/lib/cjs/components/_classes/nested/NestedComponent.js +133 -15
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +6 -0
- package/lib/cjs/components/address/Address.d.ts +2 -1
- package/lib/cjs/components/button/Button.d.ts +1 -1
- package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/cjs/components/columns/Columns.d.ts +1 -1
- package/lib/cjs/components/container/Container.d.ts +1 -0
- package/lib/cjs/components/datagrid/DataGrid.d.ts +1 -1
- package/lib/cjs/components/day/Day.d.ts +1 -1
- package/lib/cjs/components/editgrid/EditGrid.d.ts +2 -0
- package/lib/cjs/components/file/File.d.ts +2 -2
- package/lib/cjs/components/number/Number.d.ts +1 -1
- package/lib/cjs/components/radio/Radio.d.ts +1 -1
- package/lib/cjs/components/radio/Radio.form.d.ts +1 -3
- package/lib/cjs/components/radio/Radio.js +3 -3
- package/lib/cjs/components/select/Select.d.ts +9 -14
- package/lib/cjs/components/select/Select.form.d.ts +1 -3
- package/lib/cjs/components/select/Select.js +11 -15
- package/lib/cjs/components/selectboxes/SelectBoxes.form.d.ts +1 -3
- package/lib/cjs/components/survey/Survey.d.ts +1 -1
- package/lib/cjs/components/table/Table.d.ts +1 -1
- package/lib/cjs/components/tabs/Tabs.d.ts +1 -1
- package/lib/cjs/components/textfield/TextField.d.ts +1 -1
- package/lib/cjs/providers/address/NominatimAddressProvider.d.ts +1 -1
- package/lib/cjs/providers/address/NominatimAddressProvider.js +5 -1
- package/lib/cjs/providers/processor/fileProcessor.d.ts +7 -1
- package/lib/cjs/providers/processor/fileProcessor.js +6 -0
- package/lib/cjs/providers/storage/azure.d.ts +4 -15
- package/lib/cjs/providers/storage/azure.js +3 -2
- package/lib/cjs/providers/storage/base64.d.ts +3 -7
- package/lib/cjs/providers/storage/base64.js +2 -1
- package/lib/cjs/providers/storage/dropbox.d.ts +4 -6
- package/lib/cjs/providers/storage/dropbox.js +3 -2
- package/lib/cjs/providers/storage/googleDrive.d.ts +4 -6
- package/lib/cjs/providers/storage/googleDrive.js +3 -1
- package/lib/cjs/providers/storage/indexeddb.d.ts +3 -8
- package/lib/cjs/providers/storage/indexeddb.js +2 -1
- package/lib/cjs/providers/storage/s3.d.ts +4 -22
- package/lib/cjs/providers/storage/s3.js +3 -2
- package/lib/cjs/providers/storage/url.d.ts +3 -8
- package/lib/cjs/providers/storage/url.js +4 -3
- package/lib/cjs/providers/storage/util.d.ts +22 -6
- package/lib/cjs/providers/storage/util.js +16 -5
- package/lib/cjs/utils/builder.d.ts +9 -7
- package/lib/cjs/utils/builder.js +10 -5
- package/lib/cjs/utils/calendarUtils.d.ts +6 -10
- package/lib/cjs/utils/calendarUtils.js +7 -11
- package/lib/cjs/utils/formUtils.d.ts +4 -4
- package/lib/cjs/utils/formUtils.js +3 -3
- package/lib/cjs/utils/utils.d.ts +123 -121
- package/lib/cjs/utils/utils.js +99 -94
- package/lib/mjs/Form.d.ts +281 -10
- package/lib/mjs/Form.js +112 -28
- package/lib/mjs/FormBuilder.d.ts +187 -2
- package/lib/mjs/FormBuilder.js +31 -6
- package/lib/mjs/PDF.d.ts +0 -1
- package/lib/mjs/Webform.d.ts +6 -6
- package/lib/mjs/Webform.js +3 -3
- package/lib/mjs/Wizard.d.ts +1 -1
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +8 -6
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +6 -4
- package/lib/mjs/components/_classes/field/Field.d.ts +11 -2
- package/lib/mjs/components/_classes/field/Field.js +13 -1
- package/lib/mjs/components/_classes/input/Input.d.ts +4 -3
- package/lib/mjs/components/_classes/input/Input.js +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.form.d.ts +4 -5
- package/lib/mjs/components/_classes/list/ListComponent.form.js +3 -2
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +42 -11
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +37 -3
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +127 -33
- package/lib/mjs/components/_classes/nested/NestedComponent.js +133 -15
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +6 -0
- package/lib/mjs/components/address/Address.d.ts +2 -1
- package/lib/mjs/components/button/Button.d.ts +1 -1
- package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/mjs/components/columns/Columns.d.ts +1 -1
- package/lib/mjs/components/container/Container.d.ts +1 -0
- package/lib/mjs/components/datagrid/DataGrid.d.ts +1 -1
- package/lib/mjs/components/day/Day.d.ts +1 -1
- package/lib/mjs/components/editgrid/EditGrid.d.ts +2 -0
- package/lib/mjs/components/file/File.d.ts +2 -2
- package/lib/mjs/components/number/Number.d.ts +1 -1
- package/lib/mjs/components/radio/Radio.d.ts +1 -1
- package/lib/mjs/components/radio/Radio.form.d.ts +1 -3
- package/lib/mjs/components/radio/Radio.js +3 -3
- package/lib/mjs/components/select/Select.d.ts +9 -14
- package/lib/mjs/components/select/Select.form.d.ts +1 -3
- package/lib/mjs/components/select/Select.js +11 -15
- package/lib/mjs/components/selectboxes/SelectBoxes.form.d.ts +1 -3
- package/lib/mjs/components/survey/Survey.d.ts +1 -1
- package/lib/mjs/components/table/Table.d.ts +1 -1
- package/lib/mjs/components/tabs/Tabs.d.ts +1 -1
- package/lib/mjs/components/textfield/TextField.d.ts +1 -1
- package/lib/mjs/providers/address/NominatimAddressProvider.d.ts +1 -1
- package/lib/mjs/providers/address/NominatimAddressProvider.js +5 -1
- package/lib/mjs/providers/processor/fileProcessor.d.ts +7 -1
- package/lib/mjs/providers/processor/fileProcessor.js +6 -0
- package/lib/mjs/providers/storage/azure.d.ts +4 -15
- package/lib/mjs/providers/storage/azure.js +3 -2
- package/lib/mjs/providers/storage/base64.d.ts +3 -7
- package/lib/mjs/providers/storage/base64.js +2 -1
- package/lib/mjs/providers/storage/dropbox.d.ts +4 -6
- package/lib/mjs/providers/storage/dropbox.js +3 -2
- package/lib/mjs/providers/storage/googleDrive.d.ts +4 -6
- package/lib/mjs/providers/storage/googleDrive.js +3 -1
- package/lib/mjs/providers/storage/indexeddb.d.ts +3 -8
- package/lib/mjs/providers/storage/indexeddb.js +2 -1
- package/lib/mjs/providers/storage/s3.d.ts +4 -22
- package/lib/mjs/providers/storage/s3.js +3 -2
- package/lib/mjs/providers/storage/url.d.ts +3 -8
- package/lib/mjs/providers/storage/url.js +4 -3
- package/lib/mjs/providers/storage/util.d.ts +22 -6
- package/lib/mjs/providers/storage/util.js +16 -5
- package/lib/mjs/utils/builder.d.ts +9 -7
- package/lib/mjs/utils/builder.js +10 -5
- package/lib/mjs/utils/calendarUtils.d.ts +6 -10
- package/lib/mjs/utils/calendarUtils.js +7 -11
- package/lib/mjs/utils/formUtils.d.ts +4 -4
- package/lib/mjs/utils/formUtils.js +3 -3
- package/lib/mjs/utils/utils.d.ts +123 -121
- package/lib/mjs/utils/utils.js +99 -94
- package/package.json +10 -10
@@ -27,7 +27,9 @@
|
|
27
27
|
|
28
28
|
/*! @license DOMPurify 3.1.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.2/LICENSE */
|
29
29
|
|
30
|
-
/*!
|
30
|
+
/*! @license DOMPurify 3.1.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.3/LICENSE */
|
31
|
+
|
32
|
+
/*! formiojs v5.0.0-rc.53 | https://unpkg.com/formiojs@5.0.0-rc.53/LICENSE.txt */
|
31
33
|
|
32
34
|
/**
|
33
35
|
* @license
|
package/dist/formio.js
CHANGED
@@ -666,7 +666,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
666
666
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
667
667
|
|
668
668
|
"use strict";
|
669
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.NominatimAddressProvider = void 0;\nconst AddressProvider_1 = __webpack_require__(/*! ./AddressProvider */ \"./lib/cjs/providers/address/AddressProvider.js\");\n/**\n * @typedef {object} NominatimAddressProviderOptionsParams\n * @property {{ addressdetails: string, format: string } } params - The parameters for the Nominatim API request.\n */\n/**\n * Represents an Nominatim address provider.\n * {extends AddressProvider}\n */\nclass NominatimAddressProvider extends AddressProvider_1.AddressProvider {\n static get name() {\n return 'nominatim';\n }\n /**\n * Gets the display name of the address provider.\n * @type {string}\n */\n static get displayName() {\n return 'OpenStreetMap Nominatim';\n }\n /**\n * Gets the default options for the address provider.\n * @returns {NominatimAddressProviderOptionsParams} The default options.\n */\n get defaultOptions() {\n return {\n params: {\n addressdetails: '1',\n format: 'json',\n },\n };\n }\n /**\n * Gets the response property for the address provider.\n * @type {string}\n */\n get queryProperty() {\n return 'q';\n }\n /**\n * Gets the display value property for the address provider.\n * @returns {string} The property to use for display value.\n */\n get displayValueProperty() {\n return 'display_name';\n }\n /**\n * Generates the request URL for the address provider with options.\n * @param {NominatimAddressProviderOptionsParams} options
|
669
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.NominatimAddressProvider = void 0;\nconst AddressProvider_1 = __webpack_require__(/*! ./AddressProvider */ \"./lib/cjs/providers/address/AddressProvider.js\");\n/**\n * @typedef {object} NominatimAddressProviderOptionsParams\n * @property {{ addressdetails: string, format: string } } params - The parameters for the Nominatim API request.\n */\n/**\n * Represents an Nominatim address provider.\n * {extends AddressProvider}\n */\nclass NominatimAddressProvider extends AddressProvider_1.AddressProvider {\n /**\n * Gets the name of the address provider.\n * @type {string}\n */\n static get name() {\n return 'nominatim';\n }\n /**\n * Gets the display name of the address provider.\n * @type {string}\n */\n static get displayName() {\n return 'OpenStreetMap Nominatim';\n }\n /**\n * Gets the default options for the address provider.\n * @returns {NominatimAddressProviderOptionsParams} The default options.\n */\n get defaultOptions() {\n return {\n params: {\n addressdetails: '1',\n format: 'json',\n },\n };\n }\n /**\n * Gets the response property for the address provider.\n * @type {string}\n */\n get queryProperty() {\n return 'q';\n }\n /**\n * Gets the display value property for the address provider.\n * @returns {string} The property to use for display value.\n */\n get displayValueProperty() {\n return 'display_name';\n }\n /**\n * Generates the request URL for the address provider with options.\n * @param {NominatimAddressProviderOptionsParams} options - The request options.\n * @returns {string} The formatted Url.\n */\n getRequestUrl(options = {}) {\n const { params } = options;\n return `https://nominatim.openstreetmap.org/search?${this.serialize(params)}`;\n }\n}\nexports.NominatimAddressProvider = NominatimAddressProvider;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/providers/address/NominatimAddressProvider.js?");
|
670
670
|
|
671
671
|
/***/ }),
|
672
672
|
|
@@ -710,7 +710,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
710
710
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
711
711
|
|
712
712
|
"use strict";
|
713
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst xhr_1 = __importDefault(__webpack_require__(/*! ./xhr */ \"./lib/cjs/providers/storage/xhr.js\"));\n/**\n
|
713
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst xhr_1 = __importDefault(__webpack_require__(/*! ./xhr */ \"./lib/cjs/providers/storage/xhr.js\"));\n/**\n * Azure File Services provider for file storage.\n * @param {object} formio formio instance\n * @returns {import('./typedefs').FileProvider} The FileProvider interface defined in index.js.\n */\nfunction azure(formio) {\n return {\n uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback) {\n return xhr_1.default.upload(formio, 'azure', (xhr, response) => {\n xhr.openAndSetHeaders('PUT', response.url);\n xhr.setRequestHeader('Content-Type', file.type);\n xhr.setRequestHeader('x-ms-blob-type', 'BlockBlob');\n return file;\n }, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback).then((response) => {\n return {\n storage: 'azure',\n name: xhr_1.default.path([dir, fileName]),\n size: file.size,\n type: file.type,\n groupPermissions,\n groupId,\n key: response.key,\n };\n });\n },\n downloadFile(file) {\n return formio.makeRequest('file', `${formio.formUrl}/storage/azure?name=${xhr_1.default.trim(file.name)}`, 'GET');\n },\n deleteFile: function deleteFile(fileInfo) {\n var url = `${formio.formUrl}/storage/azure?name=${xhr_1.default.trim(fileInfo.name)}&key=${xhr_1.default.trim(fileInfo.key)}`;\n return formio.makeRequest('', url, 'delete');\n }\n };\n}\nazure.title = 'Azure File Services';\nexports[\"default\"] = azure;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/providers/storage/azure.js?");
|
714
714
|
|
715
715
|
/***/ }),
|
716
716
|
|
@@ -721,7 +721,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
721
721
|
/***/ (function(__unused_webpack_module, exports) {
|
722
722
|
|
723
723
|
"use strict";
|
724
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n/**\n
|
724
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n/**\n * base64 File Services provider for file storage.\n * @returns {import('./typedefs').FileProvider} The FileProvider interface defined in index.js.\n */\nfunction base64() {\n return {\n title: 'Base64',\n name: 'base64',\n uploadFile(file, fileName) {\n const reader = new FileReader();\n return new Promise((resolve, reject) => {\n reader.onload = (event) => {\n const url = event.target.result;\n resolve({\n storage: 'base64',\n name: fileName,\n url: url,\n size: file.size,\n type: file.type,\n });\n };\n reader.onerror = () => {\n return reject(this);\n };\n reader.readAsDataURL(file);\n });\n },\n downloadFile(file) {\n // Return the original as there is nothing to do.\n return Promise.resolve(file);\n },\n };\n}\nbase64.title = 'Base64';\nexports[\"default\"] = base64;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/providers/storage/base64.js?");
|
725
725
|
|
726
726
|
/***/ }),
|
727
727
|
|
@@ -732,7 +732,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n/**\
|
|
732
732
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
733
733
|
|
734
734
|
"use strict";
|
735
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst xhr_1 = __webpack_require__(/*! ./xhr */ \"./lib/cjs/providers/storage/xhr.js\");\n/**\n *\n * @param formio\n */\nfunction googledrive(formio) {\n return {\n uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback) {\n return new Promise(((resolve, reject) => {\n // Send the file with data.\n const xhr = new XMLHttpRequest();\n if (typeof progressCallback === 'function') {\n xhr.upload.onprogress = progressCallback;\n }\n if (typeof abortCallback === 'function') {\n abortCallback(() => xhr.abort());\n }\n const fd = new FormData();\n fd.append('name', fileName);\n fd.append('dir', dir);\n fd.append('file', file);\n // Fire on network error.\n xhr.onerror = (err) => {\n err.networkError = true;\n reject(err);\n };\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n const response = JSON.parse(xhr.response);\n response.storage = 'googledrive';\n response.size = file.size;\n response.type = file.type;\n response.groupId = groupId;\n response.groupPermissions = groupPermissions;\n resolve(response);\n }\n else {\n reject(xhr.response || 'Unable to upload file');\n }\n };\n xhr.onabort = reject;\n xhr.open('POST', `${formio.formUrl}/storage/gdrive`);\n (0, xhr_1.setXhrHeaders)(formio, xhr);\n const token = formio.getToken();\n if (token) {\n xhr.setRequestHeader('x-jwt-token', token);\n }\n xhr.send(fd);\n }));\n },\n downloadFile(file) {\n const token = formio.getToken();\n file.url =\n `${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}`;\n return Promise.resolve(file);\n },\n deleteFile: function deleteFile(fileInfo) {\n var url = ''.concat(formio.formUrl, `/storage/gdrive?id=${fileInfo.id}&name=${fileInfo.originalName}`);\n return formio.makeRequest('', url, 'delete');\n },\n };\n}\ngoogledrive.title = 'Google Drive';\nexports[\"default\"] = googledrive;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/providers/storage/googleDrive.js?");
|
735
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst xhr_1 = __webpack_require__(/*! ./xhr */ \"./lib/cjs/providers/storage/xhr.js\");\n/**\n *\n * Google Drive provider for file storage.\n * @param {object} formio - formio instance\n * @returns {import('./typedefs').FileProvider} The FileProvider interface defined in index.js.\n */\nfunction googledrive(formio) {\n return {\n uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback) {\n return new Promise(((resolve, reject) => {\n // Send the file with data.\n const xhr = new XMLHttpRequest();\n if (typeof progressCallback === 'function') {\n xhr.upload.onprogress = progressCallback;\n }\n if (typeof abortCallback === 'function') {\n abortCallback(() => xhr.abort());\n }\n const fd = new FormData();\n fd.append('name', fileName);\n fd.append('dir', dir);\n fd.append('file', file);\n // Fire on network error.\n xhr.onerror = (err) => {\n err.networkError = true;\n reject(err);\n };\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n const response = JSON.parse(xhr.response);\n response.storage = 'googledrive';\n response.size = file.size;\n response.type = file.type;\n response.groupId = groupId;\n response.groupPermissions = groupPermissions;\n resolve(response);\n }\n else {\n reject(xhr.response || 'Unable to upload file');\n }\n };\n xhr.onabort = reject;\n xhr.open('POST', `${formio.formUrl}/storage/gdrive`);\n (0, xhr_1.setXhrHeaders)(formio, xhr);\n const token = formio.getToken();\n if (token) {\n xhr.setRequestHeader('x-jwt-token', token);\n }\n xhr.send(fd);\n }));\n },\n downloadFile(file) {\n const token = formio.getToken();\n file.url =\n `${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}`;\n return Promise.resolve(file);\n },\n deleteFile: function deleteFile(fileInfo) {\n var url = ''.concat(formio.formUrl, `/storage/gdrive?id=${fileInfo.id}&name=${fileInfo.originalName}`);\n return formio.makeRequest('', url, 'delete');\n },\n };\n}\ngoogledrive.title = 'Google Drive';\nexports[\"default\"] = googledrive;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/providers/storage/googleDrive.js?");
|
736
736
|
|
737
737
|
/***/ }),
|
738
738
|
|
@@ -754,7 +754,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
754
754
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
755
755
|
|
756
756
|
"use strict";
|
757
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst uuid_1 = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/commonjs-browser/index.js\");\n/**\n
|
757
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst uuid_1 = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/commonjs-browser/index.js\");\n/**\n * indexedDb provider for file storage.\n * @returns {import('./typedefs').FileProvider} The FileProvider interface defined in index.js.\n */\nfunction indexeddb() {\n return {\n title: 'indexedDB',\n name: 'indexeddb',\n uploadFile(file, fileName, dir, progressCallback, url, options) {\n if (!('indexedDB' in window)) {\n console.log('This browser doesn\\'t support IndexedDB');\n return;\n }\n return new Promise((resolve) => {\n const request = indexedDB.open(options.indexeddb);\n request.onsuccess = function (event) {\n const db = event.target.result;\n resolve(db);\n };\n request.onupgradeneeded = function (e) {\n const db = e.target.result;\n db.createObjectStore(options.indexeddbTable);\n };\n }).then((db) => {\n const reader = new FileReader();\n return new Promise((resolve, reject) => {\n reader.onload = () => {\n const blobObject = new Blob([file], { type: file.type });\n const id = (0, uuid_1.v4)(blobObject);\n const data = {\n id,\n data: blobObject,\n name: file.name,\n size: file.size,\n type: file.type,\n url,\n };\n const trans = db.transaction([options.indexeddbTable], 'readwrite');\n const addReq = trans.objectStore(options.indexeddbTable).put(data, id);\n addReq.onerror = function (e) {\n console.log('error storing data');\n console.error(e);\n };\n trans.oncomplete = function () {\n resolve({\n storage: 'indexeddb',\n name: file.name,\n size: file.size,\n type: file.type,\n url: url,\n id,\n });\n };\n };\n reader.onerror = () => {\n return reject(this);\n };\n reader.readAsDataURL(file);\n });\n });\n },\n downloadFile(file, options) {\n return new Promise((resolve) => {\n const request = indexedDB.open(options.indexeddb);\n request.onsuccess = function (event) {\n const db = event.target.result;\n resolve(db);\n };\n }).then((db) => {\n return new Promise((resolve, reject) => {\n const trans = db.transaction([options.indexeddbTable], 'readonly');\n const store = trans.objectStore(options.indexeddbTable).get(file.id);\n store.onsuccess = () => {\n trans.oncomplete = () => {\n const result = store.result;\n const dbFile = new File([store.result.data], file.name, {\n type: store.result.type,\n });\n const reader = new FileReader();\n reader.onload = (event) => {\n result.url = event.target.result;\n result.storage = file.storage;\n resolve(result);\n };\n reader.onerror = () => {\n return reject(this);\n };\n reader.readAsDataURL(dbFile);\n };\n };\n store.onerror = () => {\n return reject(this);\n };\n });\n });\n },\n deleteFile(file, options) {\n return new Promise((resolve) => {\n const request = indexedDB.open(options.indexeddb);\n request.onsuccess = function (event) {\n const db = event.target.result;\n resolve(db);\n };\n }).then((db) => {\n return new Promise((resolve, reject) => {\n const trans = db.transaction([options.indexeddbTable], 'readwrite');\n const store = trans.objectStore(options.indexeddbTable).delete(file.id);\n store.onsuccess = () => {\n trans.oncomplete = () => {\n const result = store.result;\n resolve(result);\n };\n };\n store.onerror = () => {\n return reject(this);\n };\n });\n });\n },\n };\n}\nindexeddb.title = 'IndexedDB';\nexports[\"default\"] = indexeddb;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/providers/storage/indexeddb.js?");
|
758
758
|
|
759
759
|
/***/ }),
|
760
760
|
|
@@ -765,7 +765,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\ncons
|
|
765
765
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
766
766
|
|
767
767
|
"use strict";
|
768
|
-
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst xhr_1 = __importDefault(__webpack_require__(/*! ./xhr */ \"./lib/cjs/providers/storage/xhr.js\"));\nconst util_1 = __webpack_require__(/*! ./util */ \"./lib/cjs/providers/storage/util.js\");\nconst loadAbortControllerPolyfill = () => __awaiter(void 0, void 0, void 0, function* () {\n if (typeof AbortController === 'undefined') {\n yield Promise.resolve().then(() => __importStar(__webpack_require__(/*! abortcontroller-polyfill/dist/polyfill-patch-fetch */ \"./node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js\")));\n }\n});\n/**\n *\n * @param formio\n */\nfunction s3(formio) {\n return {\n uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback, multipartOptions) {\n return __awaiter(this, void 0, void 0, function* () {\n const xhrCallback = (xhr, response, abortCallback) => __awaiter(this, void 0, void 0, function* () {\n response.data.fileName = fileName;\n response.data.key = xhr_1.default.path([response.data.key, dir, fileName]);\n if (response.signed) {\n if (multipartOptions && Array.isArray(response.signed)) {\n // patch abort callback\n yield loadAbortControllerPolyfill();\n const abortController = new AbortController();\n const abortSignal = abortController.signal;\n if (typeof abortCallback === 'function') {\n abortCallback(() => abortController.abort());\n }\n try {\n const parts = yield this.uploadParts(file, response.signed, response.data.headers, response.partSizeActual, multipartOptions, abortSignal);\n yield (0, util_1.withRetries)(this.completeMultipartUpload, [response, parts, multipartOptions], 3);\n return;\n }\n catch (err) {\n // abort in-progress fetch requests\n abortController.abort();\n // attempt to cancel the multipart upload\n this.abortMultipartUpload(response);\n throw err;\n }\n }\n else {\n xhr.openAndSetHeaders('PUT', response.signed);\n xhr.setRequestHeader('Content-Type', file.type);\n if (response.data.headers) {\n Object.keys(response.data.headers).forEach((key) => {\n xhr.setRequestHeader(key, response.data.headers[key]);\n });\n }\n return file;\n }\n }\n else {\n const fd = new FormData();\n for (const key in response.data) {\n fd.append(key, response.data[key]);\n }\n fd.append('file', file);\n xhr.openAndSetHeaders('POST', response.url);\n return fd;\n }\n });\n const response = yield xhr_1.default.upload(formio, 's3', xhrCallback, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback, multipartOptions);\n return {\n storage: 's3',\n name: fileName,\n bucket: response.bucket,\n key: response.data.key,\n url: xhr_1.default.path([response.url, response.data.key]),\n acl: response.data.acl,\n size: file.size,\n type: file.type\n };\n });\n },\n completeMultipartUpload(serverResponse, parts, multipart) {\n return __awaiter(this, void 0, void 0, function* () {\n const { changeMessage } = multipart;\n changeMessage('Completing AWS S3 multipart upload...');\n const token = formio.getToken();\n const response = yield fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {\n method: 'POST',\n headers: Object.assign({ 'Content-Type': 'application/json' }, (token ? { 'x-jwt-token': token } : {})),\n body: JSON.stringify({ parts, uploadId: serverResponse.uploadId, key: serverResponse.key })\n });\n const message = yield response.text();\n if (!response.ok) {\n throw new Error(message);\n }\n // the AWS S3 SDK CompleteMultipartUpload command can return a HTTP 200 status header but still error;\n // we need to parse, and according to AWS, to retry\n if (message.match(/Error/)) {\n throw new Error(message);\n }\n });\n },\n abortMultipartUpload(serverResponse) {\n const { uploadId, key } = serverResponse;\n const token = formio.getToken();\n fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {\n method: 'POST',\n headers: Object.assign({ 'Content-Type': 'application/json' }, (token ? { 'x-jwt-token': token } : {})),\n body: JSON.stringify({ uploadId, key })\n }).catch((err) => console.error('Error while aborting multipart upload:', err));\n },\n uploadParts(file, urls, headers, partSize, multipart, abortSignal) {\n const { changeMessage, progressCallback } = multipart;\n changeMessage('Chunking and uploading parts to AWS S3...');\n const promises = [];\n for (let i = 0; i < urls.length; i++) {\n const start = i * partSize;\n const end = (i + 1) * partSize;\n const blob = i < urls.length ? file.slice(start, end) : file.slice(start);\n const promise = fetch(urls[i], {\n method: 'PUT',\n headers,\n body: blob,\n signal: abortSignal,\n }).then((res) => {\n if (res.ok) {\n progressCallback(urls.length);\n const eTag = res.headers.get('etag');\n if (!eTag) {\n throw new Error('ETag header not found; it must be exposed in S3 bucket CORS settings');\n }\n return { ETag: eTag, PartNumber: i + 1 };\n }\n else {\n throw new Error(`Part no ${i} failed with status ${res.status}`);\n }\n });\n promises.push(promise);\n }\n return Promise.all(promises);\n },\n downloadFile(file) {\n if (file.acl !== 'public-read') {\n return formio.makeRequest('file', `${formio.formUrl}/storage/s3?bucket=${xhr_1.default.trim(file.bucket)}&key=${xhr_1.default.trim(file.key)}`, 'GET');\n }\n else {\n return Promise.resolve(file);\n }\n },\n deleteFile(fileInfo) {\n const url = `${formio.formUrl}/storage/s3?bucket=${xhr_1.default.trim(fileInfo.bucket)}&key=${xhr_1.default.trim(fileInfo.key)}`;\n return formio.makeRequest('', url, 'delete');\n },\n };\n}\ns3.title = 'S3';\nexports[\"default\"] = s3;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/providers/storage/s3.js?");
|
768
|
+
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst xhr_1 = __importDefault(__webpack_require__(/*! ./xhr */ \"./lib/cjs/providers/storage/xhr.js\"));\nconst util_1 = __webpack_require__(/*! ./util */ \"./lib/cjs/providers/storage/util.js\");\nconst loadAbortControllerPolyfill = () => __awaiter(void 0, void 0, void 0, function* () {\n if (typeof AbortController === 'undefined') {\n yield Promise.resolve().then(() => __importStar(__webpack_require__(/*! abortcontroller-polyfill/dist/polyfill-patch-fetch */ \"./node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js\")));\n }\n});\n/**\n * S3 File Services provider for file storage.\n * @param {object} formio formio instance\n * @returns {import('./typedefs').FileProvider} The FileProvider interface defined in index.js.\n */\nfunction s3(formio) {\n return {\n uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback, multipartOptions) {\n return __awaiter(this, void 0, void 0, function* () {\n const xhrCallback = (xhr, response, abortCallback) => __awaiter(this, void 0, void 0, function* () {\n response.data.fileName = fileName;\n response.data.key = xhr_1.default.path([response.data.key, dir, fileName]);\n if (response.signed) {\n if (multipartOptions && Array.isArray(response.signed)) {\n // patch abort callback\n yield loadAbortControllerPolyfill();\n const abortController = new AbortController();\n const abortSignal = abortController.signal;\n if (typeof abortCallback === 'function') {\n abortCallback(() => abortController.abort());\n }\n try {\n const parts = yield this.uploadParts(file, response.signed, response.data.headers, response.partSizeActual, multipartOptions, abortSignal);\n yield (0, util_1.withRetries)(this.completeMultipartUpload, [response, parts, multipartOptions], 3);\n return;\n }\n catch (err) {\n // abort in-progress fetch requests\n abortController.abort();\n // attempt to cancel the multipart upload\n this.abortMultipartUpload(response);\n throw err;\n }\n }\n else {\n xhr.openAndSetHeaders('PUT', response.signed);\n xhr.setRequestHeader('Content-Type', file.type);\n if (response.data.headers) {\n Object.keys(response.data.headers).forEach((key) => {\n xhr.setRequestHeader(key, response.data.headers[key]);\n });\n }\n return file;\n }\n }\n else {\n const fd = new FormData();\n for (const key in response.data) {\n fd.append(key, response.data[key]);\n }\n fd.append('file', file);\n xhr.openAndSetHeaders('POST', response.url);\n return fd;\n }\n });\n const response = yield xhr_1.default.upload(formio, 's3', xhrCallback, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback, multipartOptions);\n return {\n storage: 's3',\n name: fileName,\n bucket: response.bucket,\n key: response.data.key,\n url: xhr_1.default.path([response.url, response.data.key]),\n acl: response.data.acl,\n size: file.size,\n type: file.type\n };\n });\n },\n completeMultipartUpload(serverResponse, parts, multipart) {\n return __awaiter(this, void 0, void 0, function* () {\n const { changeMessage } = multipart;\n changeMessage('Completing AWS S3 multipart upload...');\n const token = formio.getToken();\n const response = yield fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {\n method: 'POST',\n headers: Object.assign({ 'Content-Type': 'application/json' }, (token ? { 'x-jwt-token': token } : {})),\n body: JSON.stringify({ parts, uploadId: serverResponse.uploadId, key: serverResponse.key })\n });\n const message = yield response.text();\n if (!response.ok) {\n throw new Error(message);\n }\n // the AWS S3 SDK CompleteMultipartUpload command can return a HTTP 200 status header but still error;\n // we need to parse, and according to AWS, to retry\n if (message.match(/Error/)) {\n throw new Error(message);\n }\n });\n },\n abortMultipartUpload(serverResponse) {\n const { uploadId, key } = serverResponse;\n const token = formio.getToken();\n fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {\n method: 'POST',\n headers: Object.assign({ 'Content-Type': 'application/json' }, (token ? { 'x-jwt-token': token } : {})),\n body: JSON.stringify({ uploadId, key })\n }).catch((err) => console.error('Error while aborting multipart upload:', err));\n },\n uploadParts(file, urls, headers, partSize, multipart, abortSignal) {\n const { changeMessage, progressCallback } = multipart;\n changeMessage('Chunking and uploading parts to AWS S3...');\n const promises = [];\n for (let i = 0; i < urls.length; i++) {\n const start = i * partSize;\n const end = (i + 1) * partSize;\n const blob = i < urls.length ? file.slice(start, end) : file.slice(start);\n const promise = fetch(urls[i], {\n method: 'PUT',\n headers,\n body: blob,\n signal: abortSignal,\n }).then((res) => {\n if (res.ok) {\n progressCallback(urls.length);\n const eTag = res.headers.get('etag');\n if (!eTag) {\n throw new Error('ETag header not found; it must be exposed in S3 bucket CORS settings');\n }\n return { ETag: eTag, PartNumber: i + 1 };\n }\n else {\n throw new Error(`Part no ${i} failed with status ${res.status}`);\n }\n });\n promises.push(promise);\n }\n return Promise.all(promises);\n },\n downloadFile(file) {\n if (file.acl !== 'public-read') {\n return formio.makeRequest('file', `${formio.formUrl}/storage/s3?bucket=${xhr_1.default.trim(file.bucket)}&key=${xhr_1.default.trim(file.key)}`, 'GET');\n }\n else {\n return Promise.resolve(file);\n }\n },\n deleteFile(fileInfo) {\n const url = `${formio.formUrl}/storage/s3?bucket=${xhr_1.default.trim(fileInfo.bucket)}&key=${xhr_1.default.trim(fileInfo.key)}`;\n return formio.makeRequest('', url, 'delete');\n },\n };\n}\ns3.title = 'S3';\nexports[\"default\"] = s3;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/providers/storage/s3.js?");
|
769
769
|
|
770
770
|
/***/ }),
|
771
771
|
|
@@ -776,7 +776,7 @@ eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ?
|
|
776
776
|
/***/ (function(__unused_webpack_module, exports) {
|
777
777
|
|
778
778
|
"use strict";
|
779
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n/**\n *\n * @param formio\n */\nfunction url(formio) {\n /**\n *\n * @param options\n * @param xhr\n */\n function setOptions(options, xhr) {\n const parsedOptions = typeof options === 'string' ? JSON.parse(options) : options;\n for (const prop in parsedOptions) {\n if (prop === 'headers') {\n const headers = parsedOptions['headers'];\n for (const header in headers) {\n xhr.setRequestHeader(header, headers[header]);\n }\n }\n else {\n xhr[prop] = parsedOptions[prop];\n }\n }\n }\n const xhrRequest = (url, name, query, data, options, progressCallback, abortCallback) => {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n const json = (typeof data === 'string');\n const fd = new FormData();\n if (typeof progressCallback === 'function') {\n xhr.upload.onprogress = progressCallback;\n }\n if (typeof abortCallback === 'function') {\n abortCallback(() => xhr.abort());\n }\n if (!json) {\n for (const key in data) {\n fd.append(key, data[key]);\n }\n }\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n // Need to test if xhr.response is decoded or not.\n let respData = {};\n try {\n respData = (typeof xhr.response === 'string') ? JSON.parse(xhr.response) : {};\n respData = (respData && respData.data) ? respData.data : respData;\n }\n catch (err) {\n respData = {};\n }\n // Get the url of the file.\n let respUrl = respData.hasOwnProperty('url') ? respData.url : `${xhr.responseURL}/${name}`;\n // If they provide relative url, then prepend the url.\n if (respUrl && respUrl[0] === '/') {\n respUrl = `${url}${respUrl}`;\n }\n resolve({ url: respUrl, data: respData });\n }\n else {\n reject(xhr.response || 'Unable to upload file');\n }\n };\n xhr.onerror = () => reject(xhr);\n xhr.onabort = () => reject(xhr);\n let requestUrl = url + (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in query) {\n requestUrl += `${key}=${query[key]}&`;\n }\n if (requestUrl[requestUrl.length - 1] === '&') {\n requestUrl = requestUrl.substr(0, requestUrl.length - 1);\n }\n xhr.open('POST', requestUrl);\n if (json) {\n xhr.setRequestHeader('Content-Type', 'application/json');\n }\n const token = formio.getToken();\n if (token) {\n xhr.setRequestHeader('x-jwt-token', token);\n }\n //Overrides previous request props\n if (options) {\n setOptions(options, xhr);\n }\n xhr.send(json ? data : fd);\n });\n };\n return {\n title: 'Url',\n name: 'url',\n uploadFile(file, name, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback) {\n const uploadRequest = function (form) {\n return xhrRequest(url, name, {\n baseUrl: encodeURIComponent(formio.projectUrl),\n project: form ? form.project : '',\n form: form ? form._id : ''\n }, {\n [fileKey]: file,\n name,\n dir\n }, options, progressCallback, abortCallback).then(response => {\n // Store the project and form url along with the metadata.\n response.data = response.data || {};\n response.data.baseUrl = formio.projectUrl;\n response.data.project = form ? form.project : '';\n response.data.form = form ? form._id : '';\n return {\n storage: 'url',\n name,\n url: response.url,\n size: file.size,\n type: file.type,\n data: response.data\n };\n });\n };\n if (file.private && formio.formId) {\n return formio.loadForm().then((form) => uploadRequest(form));\n }\n else {\n return uploadRequest();\n }\n },\n deleteFile(fileInfo, options) {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.open('DELETE', fileInfo.url, true);\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n resolve('File deleted');\n }\n else {\n reject(xhr.response || 'Unable to delete file');\n }\n };\n if (options) {\n setOptions(options, xhr);\n }\n xhr.send(null);\n });\n },\n downloadFile(file) {\n if (file.private) {\n if (formio.submissionId && file.data) {\n file.data.submission = formio.submissionId;\n }\n return xhrRequest(file.url, file.name, {}, JSON.stringify(file)).then(response => response.data);\n }\n // Return the original as there is nothing to do.\n return Promise.resolve(file);\n }\n };\n}\nurl.title = 'Url';\nexports[\"default\"] = url;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/providers/storage/url.js?");
|
779
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n/**\n *\n * @param {object} formio - formio instance\n * @returns {import('./typedefs').FileProvider} The FileProvider interface defined in index.js.\n */\nfunction url(formio) {\n /**\n *\n * @param {object} options - options to set on the xhr\n * @param {object} xhr - the xhr object\n */\n function setOptions(options, xhr) {\n const parsedOptions = typeof options === 'string' ? JSON.parse(options) : options;\n for (const prop in parsedOptions) {\n if (prop === 'headers') {\n const headers = parsedOptions['headers'];\n for (const header in headers) {\n xhr.setRequestHeader(header, headers[header]);\n }\n }\n else {\n xhr[prop] = parsedOptions[prop];\n }\n }\n }\n const xhrRequest = (url, name, query, data, options, progressCallback, abortCallback) => {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n const json = (typeof data === 'string');\n const fd = new FormData();\n if (typeof progressCallback === 'function') {\n xhr.upload.onprogress = progressCallback;\n }\n if (typeof abortCallback === 'function') {\n abortCallback(() => xhr.abort());\n }\n if (!json) {\n for (const key in data) {\n fd.append(key, data[key]);\n }\n }\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n // Need to test if xhr.response is decoded or not.\n let respData = {};\n try {\n respData = (typeof xhr.response === 'string') ? JSON.parse(xhr.response) : {};\n respData = (respData && respData.data) ? respData.data : respData;\n }\n catch (err) {\n respData = {};\n }\n // Get the url of the file.\n let respUrl = respData.hasOwnProperty('url') ? respData.url : `${xhr.responseURL}/${name}`;\n // If they provide relative url, then prepend the url.\n if (respUrl && respUrl[0] === '/') {\n respUrl = `${url}${respUrl}`;\n }\n resolve({ url: respUrl, data: respData });\n }\n else {\n reject(xhr.response || 'Unable to upload file');\n }\n };\n xhr.onerror = () => reject(xhr);\n xhr.onabort = () => reject(xhr);\n let requestUrl = url + (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in query) {\n requestUrl += `${key}=${query[key]}&`;\n }\n if (requestUrl[requestUrl.length - 1] === '&') {\n requestUrl = requestUrl.substr(0, requestUrl.length - 1);\n }\n xhr.open('POST', requestUrl);\n if (json) {\n xhr.setRequestHeader('Content-Type', 'application/json');\n }\n const token = formio.getToken();\n if (token) {\n xhr.setRequestHeader('x-jwt-token', token);\n }\n //Overrides previous request props\n if (options) {\n setOptions(options, xhr);\n }\n xhr.send(json ? data : fd);\n });\n };\n return {\n title: 'Url',\n name: 'url',\n uploadFile(file, name, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback) {\n const uploadRequest = function (form) {\n return xhrRequest(url, name, {\n baseUrl: encodeURIComponent(formio.projectUrl),\n project: form ? form.project : '',\n form: form ? form._id : ''\n }, {\n [fileKey]: file,\n name,\n dir\n }, options, progressCallback, abortCallback).then(response => {\n // Store the project and form url along with the metadata.\n response.data = response.data || {};\n response.data.baseUrl = formio.projectUrl;\n response.data.project = form ? form.project : '';\n response.data.form = form ? form._id : '';\n return {\n storage: 'url',\n name,\n url: response.url,\n size: file.size,\n type: file.type,\n data: response.data\n };\n });\n };\n if (file.private && formio.formId) {\n return formio.loadForm().then((form) => uploadRequest(form));\n }\n else {\n return uploadRequest();\n }\n },\n deleteFile(fileInfo, options) {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.open('DELETE', fileInfo.url, true);\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n resolve('File deleted');\n }\n else {\n reject(xhr.response || 'Unable to delete file');\n }\n };\n if (options) {\n setOptions(options, xhr);\n }\n xhr.send(null);\n });\n },\n downloadFile(file) {\n if (file.private) {\n if (formio.submissionId && file.data) {\n file.data.submission = formio.submissionId;\n }\n return xhrRequest(file.url, file.name, {}, JSON.stringify(file)).then(response => response.data);\n }\n // Return the original as there is nothing to do.\n return Promise.resolve(file);\n }\n };\n}\nurl.title = 'Url';\nexports[\"default\"] = url;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/providers/storage/url.js?");
|
780
780
|
|
781
781
|
/***/ }),
|
782
782
|
|
@@ -787,7 +787,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n/**\
|
|
787
787
|
/***/ (function(__unused_webpack_module, exports) {
|
788
788
|
|
789
789
|
"use strict";
|
790
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.withRetries = void 0;\n/**\n
|
790
|
+
eval("\n/**\n * @typedef {any[]} Args\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.withRetries = void 0;\n/**\n * Function to be retried\n * @callback RetryFunction\n * @param {...Args} args\n * @returns {Promise<any>}\n */\n/**\n * Executes a function with retries in case of failure.\n * @param {RetryFunction} fn - The function to be executed.\n * @param {Args} args - The arguments to be passed to the function.\n * @param {number} [retries] - The number of retries in case of failure.\n * @param {string} [err] - The error message to be thrown after all retries have failed.\n * @returns {Promise<any>} The result of the function execution.\n * @throws {Error} When all retries have failed.\n */\nfunction withRetries(fn, args, retries = 3, err = null) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!retries) {\n throw new Error(err);\n }\n return fn(...args).catch(() => withRetries(fn, args, retries - 1, err));\n });\n}\nexports.withRetries = withRetries;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/providers/storage/util.js?");
|
791
791
|
|
792
792
|
/***/ }),
|
793
793
|
|
@@ -809,7 +809,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
809
809
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
810
810
|
|
811
811
|
"use strict";
|
812
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a;\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.FormBuilder = exports.Form = exports.Formio = void 0;\nconst CDN_js_1 = __importDefault(__webpack_require__(/*! ./CDN.js */ \"./lib/cjs/CDN.js\"));\nclass Formio {\n static setLicense(license, norecurse = false) {\n _a.license = license;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setLicense(license);\n }\n }\n static setBaseUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setBaseUrl(url);\n }\n }\n static setApiUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setApiUrl(url);\n }\n }\n static setProjectUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setProjectUrl(url);\n }\n }\n static setAppUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setAppUrl(url);\n }\n }\n static setPathType(type, norecurse = false) {\n _a.pathType = type;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setPathType(type);\n }\n }\n static debug(...args) {\n if (_a.config.debug) {\n console.log(...args);\n }\n }\n static clearCache() {\n if (_a.FormioClass) {\n _a.FormioClass.clearCache();\n }\n }\n static global(prop, flag = '') {\n const globalValue = window[prop];\n if (flag && globalValue && !globalValue[flag]) {\n return null;\n }\n _a.debug(`Getting global ${prop}`, globalValue);\n return globalValue;\n }\n static use(module) {\n if (_a.FormioClass && _a.FormioClass.isRenderer) {\n _a.FormioClass.use(module);\n }\n else {\n _a.modules.push(module);\n }\n }\n static createElement(type, attrs, children) {\n const element = document.createElement(type);\n Object.keys(attrs).forEach(key => {\n element.setAttribute(key, attrs[key]);\n });\n (children || []).forEach(child => {\n element.appendChild(_a.createElement(child.tag, child.attrs, child.children));\n });\n return element;\n }\n static addScript(wrapper, src, name, flag = '') {\n return __awaiter(this, void 0, void 0, function* () {\n if (!src) {\n return Promise.resolve();\n }\n if (typeof src !== 'string' && src.length) {\n return Promise.all(src.map(ref => _a.addScript(wrapper, ref)));\n }\n if (name && _a.global(name, flag)) {\n _a.debug(`${name} already loaded.`);\n return Promise.resolve(_a.global(name));\n }\n _a.debug('Adding Script', src);\n try {\n wrapper.appendChild(_a.createElement('script', {\n src\n }));\n }\n catch (err) {\n _a.debug(err);\n return Promise.resolve();\n }\n if (!name) {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n _a.debug(`Waiting to load ${name}`);\n const wait = setInterval(() => {\n if (_a.global(name, flag)) {\n clearInterval(wait);\n _a.debug(`${name} loaded.`);\n resolve(_a.global(name));\n }\n }, 100);\n });\n });\n }\n static addStyles(wrapper, href) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!href) {\n return;\n }\n if (typeof href !== 'string' && href.length) {\n href.forEach(ref => _a.addStyles(wrapper, ref));\n return;\n }\n _a.debug('Adding Styles', href);\n wrapper.appendChild(_a.createElement('link', {\n rel: 'stylesheet',\n href\n }));\n });\n }\n static submitDone(instance, submission) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.debug('Submision Complete', submission);\n const successMessage = (_a.config.success || '').toString();\n if (successMessage && successMessage.toLowerCase() !== 'false' && instance.element) {\n instance.element.innerHTML = `<div class=\"alert-success\" role=\"alert\">${successMessage}</div>`;\n }\n let returnUrl = _a.config.redirect;\n // Allow form based configuration for return url.\n if (!returnUrl &&\n (instance._form &&\n instance._form.settings &&\n (instance._form.settings.returnUrl ||\n instance._form.settings.redirect))) {\n _a.debug('Return url found in form configuration');\n returnUrl = instance._form.settings.returnUrl || instance._form.settings.redirect;\n }\n if (returnUrl) {\n const formSrc = instance.formio ? instance.formio.formUrl : '';\n const hasQuery = !!returnUrl.match(/\\?/);\n const isOrigin = returnUrl.indexOf(location.origin) === 0;\n returnUrl += hasQuery ? '&' : '?';\n returnUrl += `sub=${submission._id}`;\n if (!isOrigin && formSrc) {\n returnUrl += `&form=${encodeURIComponent(formSrc)}`;\n }\n _a.debug('Return URL', returnUrl);\n window.location.href = returnUrl;\n if (isOrigin) {\n window.location.reload();\n }\n }\n });\n }\n // Return the full script if the builder is being used.\n static formioScript(script, builder) {\n builder = builder || _a.config.includeBuilder;\n if (_a.fullAdded || builder) {\n _a.fullAdded = true;\n return script.replace('formio.form', 'formio.full');\n }\n return script;\n }\n static addLibrary(wrapper, lib, name) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!lib) {\n return;\n }\n if (lib.dependencies) {\n for (let i = 0; i < lib.dependencies.length; i++) {\n yield _a.addLibrary(wrapper, _a.cdn.libs[lib.dependencies[i]]);\n }\n }\n if (lib.css) {\n yield _a.addStyles(wrapper, lib.css);\n }\n if (lib.js) {\n const module = yield _a.addScript(wrapper, lib.js, lib.use ? name : false);\n if (lib.use) {\n _a.debug(`Using ${name}`);\n const options = lib.options || {};\n if (!options.license && _a.license) {\n options.license = _a.license;\n }\n _a.use((typeof lib.use === 'function' ? lib.use(module) : module), options);\n }\n }\n });\n }\n static addLoader(wrapper) {\n return __awaiter(this, void 0, void 0, function* () {\n wrapper.appendChild(_a.createElement('div', {\n 'class': 'formio-loader'\n }, [{\n tag: 'div',\n attrs: {\n class: 'loader-wrapper'\n },\n children: [{\n tag: 'div',\n attrs: {\n class: 'loader text-center'\n }\n }]\n }]));\n });\n }\n // eslint-disable-next-line max-statements\n static init(element, options = {}, builder = false) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.cdn = new CDN_js_1.default(_a.config.cdn, _a.config.cdnUrls || {});\n _a.config.libs = _a.config.libs || {\n uswds: {\n dependencies: ['fontawesome'],\n js: `${_a.cdn.uswds}/uswds.min.js`,\n css: `${_a.cdn.uswds}/uswds.min.css`,\n use: true\n },\n fontawesome: {\n css: `${_a.cdn['font-awesome']}/css/font-awesome.min.css`\n },\n bootstrap4: {\n dependencies: ['fontawesome'],\n css: `${_a.cdn.bootstrap4}/css/bootstrap.min.css`\n },\n bootstrap: {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootstrap}/css/bootstrap.min.css`\n },\n 'bootstrap-icons': {\n css: `${_a.cdn['bootstrap-icons']}/css/bootstrap-icons.css`\n }\n };\n const id = _a.config.id || `formio-${Math.random().toString(36).substring(7)}`;\n // Create a new wrapper and add the element inside of a new wrapper.\n let wrapper = _a.createElement('div', {\n 'id': `${id}-wrapper`\n });\n element.parentNode.insertBefore(wrapper, element);\n // If we include the libraries, then we will attempt to run this in shadow dom.\n const useShadowDom = _a.config.includeLibs && (typeof wrapper.attachShadow === 'function');\n if (useShadowDom) {\n wrapper = wrapper.attachShadow({\n mode: 'open'\n });\n options.shadowRoot = wrapper;\n }\n element.parentNode.removeChild(element);\n wrapper.appendChild(element);\n // If this is inside of shadow dom, then we need to add the styles and scripts to the shadow dom.\n const libWrapper = useShadowDom ? wrapper : document.body;\n // Load the renderer styles.\n yield _a.addStyles(libWrapper, _a.config.embedCSS || `${_a.cdn.js}/formio.embed.css`);\n // Add a loader.\n _a.addLoader(wrapper);\n const formioSrc = _a.config.full ? 'formio.full' : 'formio.form';\n const renderer = _a.config.debug ? formioSrc : `${formioSrc}.min`;\n _a.FormioClass = yield _a.addScript(libWrapper, _a.formioScript(_a.config.script || `${_a.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');\n _a.FormioClass.cdn = _a.cdn;\n _a.FormioClass.setBaseUrl(options.baseUrl || _a.baseUrl || _a.config.base);\n _a.FormioClass.setProjectUrl(options.projectUrl || _a.projectUrl || _a.config.project);\n _a.FormioClass.language = _a.language;\n _a.setLicense(_a.license || _a.config.license || false);\n _a.modules.forEach((module) => {\n _a.FormioClass.use(module);\n });\n if (_a.icons) {\n _a.FormioClass.icons = _a.icons;\n }\n if (_a.pathType) {\n _a.FormioClass.setPathType(_a.pathType);\n }\n // Add libraries if they wish to include the libs.\n if (_a.config.template && _a.config.includeLibs) {\n yield _a.addLibrary(libWrapper, _a.config.libs[_a.config.template], _a.config.template);\n }\n // Add the premium modules.\n if (_a.config.premium) {\n _a.config.modules.premium = _a.config.premium;\n }\n // Allow adding dynamic modules.\n if (_a.config.modules) {\n for (const name in _a.config.modules) {\n const lib = _a.config.modules[name];\n lib.use = lib.use || true;\n yield _a.addLibrary(libWrapper, lib, name);\n }\n }\n yield _a.addStyles(libWrapper, _a.formioScript(_a.config.style || `${_a.cdn.js}/${renderer}.css`, builder));\n if (_a.config.before) {\n yield _a.config.before(_a.FormioClass, element, _a.config);\n }\n _a.FormioClass.license = true;\n _a._formioReady(_a.FormioClass);\n return wrapper;\n });\n }\n // Called after an instance has been created.\n static afterCreate(instance, wrapper, readyEvent) {\n return __awaiter(this, void 0, void 0, function* () {\n const loader = wrapper.querySelector('.formio-loader');\n if (loader) {\n wrapper.removeChild(loader);\n }\n _a.FormioClass.events.emit(readyEvent, instance);\n if (_a.config.after) {\n _a.debug('Calling ready callback');\n _a.config.after(instance, _a.config);\n }\n return instance;\n });\n }\n // Create a new form.\n static createForm(element, form, options = {}) {\n return __awaiter(this, void 0, void 0, function* () {\n if (_a.FormioClass) {\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true }));\n }\n const wrapper = yield _a.init(element, options);\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true })).then((instance) => {\n // Set the default submission data.\n if (_a.config.submission) {\n _a.debug('Setting submission', _a.config.submission);\n instance.submission = _a.config.submission;\n }\n // Call the after create method.\n _a.afterCreate(instance, wrapper, 'formEmbedded');\n return instance;\n });\n });\n }\n // Create a form builder.\n static builder(element, form, options = {}) {\n var _b;\n return __awaiter(this, void 0, void 0, function* () {\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.builder) {\n return _a.FormioClass.builder(element, form, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.builder(element, form, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'builderEmbedded');\n return instance;\n });\n });\n }\n}\nexports.Formio = Formio;\n_a = Formio;\nFormio.FormioClass = null;\nFormio.config = {};\nFormio.modules = [];\nFormio.icons = '';\nFormio.license = '';\nFormio.formioReady = new Promise((ready, reject) => {\n _a._formioReady = ready;\n _a._formioReadyReject = reject;\n});\nFormio.version = '5.0.0-rc.52';\n// Create a report.\nFormio.Report = {\n create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {\n var _b;\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.Report) {\n return _a.FormioClass.Report.create(element, submission, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.Report.create(element, submission, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'reportEmbedded');\n return instance;\n });\n })\n};\nCDN_js_1.default.defaultCDN = Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';\nclass Form {\n constructor(element, form, options) {\n this.form = form;\n this.element = element;\n this.options = options || {};\n this.init();\n this.instance = {\n proxy: true,\n ready: this.ready,\n destroy: () => { }\n };\n }\n init() {\n if (this.instance && !this.instance.proxy) {\n this.instance.destroy();\n }\n this.element.innerHTML = '';\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.form = instance.form;\n return instance;\n });\n }\n create() {\n return Formio.createForm(this.element, this.form, this.options);\n }\n setForm(form) {\n this.form = form;\n if (this.instance) {\n this.instance.setForm(form);\n }\n }\n setDisplay(display) {\n if (this.instance.proxy) {\n return this.ready;\n }\n this.form.display = display;\n this.instance.destroy();\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.setForm(this.form);\n });\n return this.ready;\n }\n}\nexports.Form = Form;\nclass FormBuilder extends Form {\n create() {\n return Formio.builder(this.element, this.form, this.options);\n }\n}\nexports.FormBuilder = FormBuilder;\nFormio.Form = Form;\nFormio.FormBuilder = FormBuilder;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Embed.js?");
|
812
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a;\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.FormBuilder = exports.Form = exports.Formio = void 0;\nconst CDN_js_1 = __importDefault(__webpack_require__(/*! ./CDN.js */ \"./lib/cjs/CDN.js\"));\nclass Formio {\n static setLicense(license, norecurse = false) {\n _a.license = license;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setLicense(license);\n }\n }\n static setBaseUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setBaseUrl(url);\n }\n }\n static setApiUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setApiUrl(url);\n }\n }\n static setProjectUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setProjectUrl(url);\n }\n }\n static setAppUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setAppUrl(url);\n }\n }\n static setPathType(type, norecurse = false) {\n _a.pathType = type;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setPathType(type);\n }\n }\n static debug(...args) {\n if (_a.config.debug) {\n console.log(...args);\n }\n }\n static clearCache() {\n if (_a.FormioClass) {\n _a.FormioClass.clearCache();\n }\n }\n static global(prop, flag = '') {\n const globalValue = window[prop];\n if (flag && globalValue && !globalValue[flag]) {\n return null;\n }\n _a.debug(`Getting global ${prop}`, globalValue);\n return globalValue;\n }\n static use(module) {\n if (_a.FormioClass && _a.FormioClass.isRenderer) {\n _a.FormioClass.use(module);\n }\n else {\n _a.modules.push(module);\n }\n }\n static createElement(type, attrs, children) {\n const element = document.createElement(type);\n Object.keys(attrs).forEach(key => {\n element.setAttribute(key, attrs[key]);\n });\n (children || []).forEach(child => {\n element.appendChild(_a.createElement(child.tag, child.attrs, child.children));\n });\n return element;\n }\n static addScript(wrapper, src, name, flag = '') {\n return __awaiter(this, void 0, void 0, function* () {\n if (!src) {\n return Promise.resolve();\n }\n if (typeof src !== 'string' && src.length) {\n return Promise.all(src.map(ref => _a.addScript(wrapper, ref)));\n }\n if (name && _a.global(name, flag)) {\n _a.debug(`${name} already loaded.`);\n return Promise.resolve(_a.global(name));\n }\n _a.debug('Adding Script', src);\n try {\n wrapper.appendChild(_a.createElement('script', {\n src\n }));\n }\n catch (err) {\n _a.debug(err);\n return Promise.resolve();\n }\n if (!name) {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n _a.debug(`Waiting to load ${name}`);\n const wait = setInterval(() => {\n if (_a.global(name, flag)) {\n clearInterval(wait);\n _a.debug(`${name} loaded.`);\n resolve(_a.global(name));\n }\n }, 100);\n });\n });\n }\n static addStyles(wrapper, href) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!href) {\n return;\n }\n if (typeof href !== 'string' && href.length) {\n href.forEach(ref => _a.addStyles(wrapper, ref));\n return;\n }\n _a.debug('Adding Styles', href);\n wrapper.appendChild(_a.createElement('link', {\n rel: 'stylesheet',\n href\n }));\n });\n }\n static submitDone(instance, submission) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.debug('Submision Complete', submission);\n const successMessage = (_a.config.success || '').toString();\n if (successMessage && successMessage.toLowerCase() !== 'false' && instance.element) {\n instance.element.innerHTML = `<div class=\"alert-success\" role=\"alert\">${successMessage}</div>`;\n }\n let returnUrl = _a.config.redirect;\n // Allow form based configuration for return url.\n if (!returnUrl &&\n (instance._form &&\n instance._form.settings &&\n (instance._form.settings.returnUrl ||\n instance._form.settings.redirect))) {\n _a.debug('Return url found in form configuration');\n returnUrl = instance._form.settings.returnUrl || instance._form.settings.redirect;\n }\n if (returnUrl) {\n const formSrc = instance.formio ? instance.formio.formUrl : '';\n const hasQuery = !!returnUrl.match(/\\?/);\n const isOrigin = returnUrl.indexOf(location.origin) === 0;\n returnUrl += hasQuery ? '&' : '?';\n returnUrl += `sub=${submission._id}`;\n if (!isOrigin && formSrc) {\n returnUrl += `&form=${encodeURIComponent(formSrc)}`;\n }\n _a.debug('Return URL', returnUrl);\n window.location.href = returnUrl;\n if (isOrigin) {\n window.location.reload();\n }\n }\n });\n }\n // Return the full script if the builder is being used.\n static formioScript(script, builder) {\n builder = builder || _a.config.includeBuilder;\n if (_a.fullAdded || builder) {\n _a.fullAdded = true;\n return script.replace('formio.form', 'formio.full');\n }\n return script;\n }\n static addLibrary(wrapper, lib, name) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!lib) {\n return;\n }\n if (lib.dependencies) {\n for (let i = 0; i < lib.dependencies.length; i++) {\n yield _a.addLibrary(wrapper, _a.cdn.libs[lib.dependencies[i]]);\n }\n }\n if (lib.css) {\n yield _a.addStyles(wrapper, lib.css);\n }\n if (lib.js) {\n const module = yield _a.addScript(wrapper, lib.js, lib.use ? name : false);\n if (lib.use) {\n _a.debug(`Using ${name}`);\n const options = lib.options || {};\n if (!options.license && _a.license) {\n options.license = _a.license;\n }\n _a.use((typeof lib.use === 'function' ? lib.use(module) : module), options);\n }\n }\n });\n }\n static addLoader(wrapper) {\n return __awaiter(this, void 0, void 0, function* () {\n wrapper.appendChild(_a.createElement('div', {\n 'class': 'formio-loader'\n }, [{\n tag: 'div',\n attrs: {\n class: 'loader-wrapper'\n },\n children: [{\n tag: 'div',\n attrs: {\n class: 'loader text-center'\n }\n }]\n }]));\n });\n }\n // eslint-disable-next-line max-statements\n static init(element, options = {}, builder = false) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.cdn = new CDN_js_1.default(_a.config.cdn, _a.config.cdnUrls || {});\n _a.config.libs = _a.config.libs || {\n uswds: {\n dependencies: ['fontawesome'],\n js: `${_a.cdn.uswds}/uswds.min.js`,\n css: `${_a.cdn.uswds}/uswds.min.css`,\n use: true\n },\n fontawesome: {\n css: `${_a.cdn['font-awesome']}/css/font-awesome.min.css`\n },\n bootstrap4: {\n dependencies: ['fontawesome'],\n css: `${_a.cdn.bootstrap4}/css/bootstrap.min.css`\n },\n bootstrap: {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootstrap}/css/bootstrap.min.css`\n },\n 'bootstrap-icons': {\n css: `${_a.cdn['bootstrap-icons']}/css/bootstrap-icons.css`\n }\n };\n const id = _a.config.id || `formio-${Math.random().toString(36).substring(7)}`;\n // Create a new wrapper and add the element inside of a new wrapper.\n let wrapper = _a.createElement('div', {\n 'id': `${id}-wrapper`\n });\n element.parentNode.insertBefore(wrapper, element);\n // If we include the libraries, then we will attempt to run this in shadow dom.\n const useShadowDom = _a.config.includeLibs && (typeof wrapper.attachShadow === 'function');\n if (useShadowDom) {\n wrapper = wrapper.attachShadow({\n mode: 'open'\n });\n options.shadowRoot = wrapper;\n }\n element.parentNode.removeChild(element);\n wrapper.appendChild(element);\n // If this is inside of shadow dom, then we need to add the styles and scripts to the shadow dom.\n const libWrapper = useShadowDom ? wrapper : document.body;\n // Load the renderer styles.\n yield _a.addStyles(libWrapper, _a.config.embedCSS || `${_a.cdn.js}/formio.embed.css`);\n // Add a loader.\n _a.addLoader(wrapper);\n const formioSrc = _a.config.full ? 'formio.full' : 'formio.form';\n const renderer = _a.config.debug ? formioSrc : `${formioSrc}.min`;\n _a.FormioClass = yield _a.addScript(libWrapper, _a.formioScript(_a.config.script || `${_a.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');\n _a.FormioClass.cdn = _a.cdn;\n _a.FormioClass.setBaseUrl(options.baseUrl || _a.baseUrl || _a.config.base);\n _a.FormioClass.setProjectUrl(options.projectUrl || _a.projectUrl || _a.config.project);\n _a.FormioClass.language = _a.language;\n _a.setLicense(_a.license || _a.config.license || false);\n _a.modules.forEach((module) => {\n _a.FormioClass.use(module);\n });\n if (_a.icons) {\n _a.FormioClass.icons = _a.icons;\n }\n if (_a.pathType) {\n _a.FormioClass.setPathType(_a.pathType);\n }\n // Add libraries if they wish to include the libs.\n if (_a.config.template && _a.config.includeLibs) {\n yield _a.addLibrary(libWrapper, _a.config.libs[_a.config.template], _a.config.template);\n }\n // Add the premium modules.\n if (_a.config.premium) {\n _a.config.modules.premium = _a.config.premium;\n }\n // Allow adding dynamic modules.\n if (_a.config.modules) {\n for (const name in _a.config.modules) {\n const lib = _a.config.modules[name];\n lib.use = lib.use || true;\n yield _a.addLibrary(libWrapper, lib, name);\n }\n }\n yield _a.addStyles(libWrapper, _a.formioScript(_a.config.style || `${_a.cdn.js}/${renderer}.css`, builder));\n if (_a.config.before) {\n yield _a.config.before(_a.FormioClass, element, _a.config);\n }\n _a.FormioClass.license = true;\n _a._formioReady(_a.FormioClass);\n return wrapper;\n });\n }\n // Called after an instance has been created.\n static afterCreate(instance, wrapper, readyEvent) {\n return __awaiter(this, void 0, void 0, function* () {\n const loader = wrapper.querySelector('.formio-loader');\n if (loader) {\n wrapper.removeChild(loader);\n }\n _a.FormioClass.events.emit(readyEvent, instance);\n if (_a.config.after) {\n _a.debug('Calling ready callback');\n _a.config.after(instance, _a.config);\n }\n return instance;\n });\n }\n // Create a new form.\n static createForm(element, form, options = {}) {\n return __awaiter(this, void 0, void 0, function* () {\n if (_a.FormioClass) {\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true }));\n }\n const wrapper = yield _a.init(element, options);\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true })).then((instance) => {\n // Set the default submission data.\n if (_a.config.submission) {\n _a.debug('Setting submission', _a.config.submission);\n instance.submission = _a.config.submission;\n }\n // Call the after create method.\n _a.afterCreate(instance, wrapper, 'formEmbedded');\n return instance;\n });\n });\n }\n // Create a form builder.\n static builder(element, form, options = {}) {\n var _b;\n return __awaiter(this, void 0, void 0, function* () {\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.builder) {\n return _a.FormioClass.builder(element, form, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.builder(element, form, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'builderEmbedded');\n return instance;\n });\n });\n }\n}\nexports.Formio = Formio;\n_a = Formio;\nFormio.FormioClass = null;\nFormio.config = {};\nFormio.modules = [];\nFormio.icons = '';\nFormio.license = '';\nFormio.formioReady = new Promise((ready, reject) => {\n _a._formioReady = ready;\n _a._formioReadyReject = reject;\n});\nFormio.version = '5.0.0-rc.53';\n// Create a report.\nFormio.Report = {\n create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {\n var _b;\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.Report) {\n return _a.FormioClass.Report.create(element, submission, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.Report.create(element, submission, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'reportEmbedded');\n return instance;\n });\n })\n};\nCDN_js_1.default.defaultCDN = Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';\nclass Form {\n constructor(element, form, options) {\n this.form = form;\n this.element = element;\n this.options = options || {};\n this.init();\n this.instance = {\n proxy: true,\n ready: this.ready,\n destroy: () => { }\n };\n }\n init() {\n if (this.instance && !this.instance.proxy) {\n this.instance.destroy();\n }\n this.element.innerHTML = '';\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.form = instance.form;\n return instance;\n });\n }\n create() {\n return Formio.createForm(this.element, this.form, this.options);\n }\n setForm(form) {\n this.form = form;\n if (this.instance) {\n this.instance.setForm(form);\n }\n }\n setDisplay(display) {\n if (this.instance.proxy) {\n return this.ready;\n }\n this.form.display = display;\n this.instance.destroy();\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.setForm(this.form);\n });\n return this.ready;\n }\n}\nexports.Form = Form;\nclass FormBuilder extends Form {\n create() {\n return Formio.builder(this.element, this.form, this.options);\n }\n}\nexports.FormBuilder = FormBuilder;\nFormio.Form = Form;\nFormio.FormBuilder = FormBuilder;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Embed.js?");
|
813
813
|
|
814
814
|
/***/ }),
|
815
815
|
|
@@ -820,7 +820,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
820
820
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
821
821
|
|
822
822
|
"use strict";
|
823
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Formio = void 0;\nconst sdk_1 = __webpack_require__(/*! @formio/core/sdk */ \"./node_modules/@formio/core/lib/sdk/index.js\");\nObject.defineProperty(exports, \"Formio\", ({ enumerable: true, get: function () { return sdk_1.Formio; } }));\nconst Embed_1 = __webpack_require__(/*! ./Embed */ \"./lib/cjs/Embed.js\");\nconst CDN_1 = __importDefault(__webpack_require__(/*! ./CDN */ \"./lib/cjs/CDN.js\"));\nconst providers_1 = __importDefault(__webpack_require__(/*! ./providers */ \"./lib/cjs/providers/index.js\"));\nsdk_1.Formio.cdn = new CDN_1.default();\nsdk_1.Formio.Providers = providers_1.default;\nsdk_1.Formio.version = '5.0.0-rc.
|
823
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Formio = void 0;\nconst sdk_1 = __webpack_require__(/*! @formio/core/sdk */ \"./node_modules/@formio/core/lib/sdk/index.js\");\nObject.defineProperty(exports, \"Formio\", ({ enumerable: true, get: function () { return sdk_1.Formio; } }));\nconst Embed_1 = __webpack_require__(/*! ./Embed */ \"./lib/cjs/Embed.js\");\nconst CDN_1 = __importDefault(__webpack_require__(/*! ./CDN */ \"./lib/cjs/CDN.js\"));\nconst providers_1 = __importDefault(__webpack_require__(/*! ./providers */ \"./lib/cjs/providers/index.js\"));\nsdk_1.Formio.cdn = new CDN_1.default();\nsdk_1.Formio.Providers = providers_1.default;\nsdk_1.Formio.version = '5.0.0-rc.53';\nCDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';\nconst isNil = (val) => val === null || val === undefined;\nsdk_1.Formio.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {\n const requestArgs = {\n provider: storage,\n method: 'upload',\n file: file,\n fileName: fileName,\n dir: dir\n };\n fileKey = fileKey || 'file';\n const request = sdk_1.Formio.pluginWait('preRequest', requestArgs)\n .then(() => {\n return sdk_1.Formio.pluginGet('fileRequest', requestArgs)\n .then((result) => {\n if (storage && isNil(result)) {\n const Provider = providers_1.default.getProvider('storage', storage);\n if (Provider) {\n const provider = new Provider(this);\n if (uploadStartCallback) {\n uploadStartCallback();\n }\n return provider.uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback, multipartOptions);\n }\n else {\n throw ('Storage provider not found');\n }\n }\n return result || { url: '' };\n });\n });\n return sdk_1.Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n};\nsdk_1.Formio.prototype.downloadFile = function (file, options) {\n const requestArgs = {\n method: 'download',\n file: file\n };\n const request = sdk_1.Formio.pluginWait('preRequest', requestArgs)\n .then(() => {\n return sdk_1.Formio.pluginGet('fileRequest', requestArgs)\n .then((result) => {\n if (file.storage && isNil(result)) {\n const Provider = providers_1.default.getProvider('storage', file.storage);\n if (Provider) {\n const provider = new Provider(this);\n return provider.downloadFile(file, options);\n }\n else {\n throw ('Storage provider not found');\n }\n }\n return result || { url: '' };\n });\n });\n return sdk_1.Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n};\nsdk_1.Formio.prototype.deleteFile = function (file, options) {\n const requestArgs = {\n method: 'delete',\n file: file\n };\n const request = sdk_1.Formio.pluginWait('preRequest', requestArgs)\n .then(() => {\n return sdk_1.Formio.pluginGet('fileRequest', requestArgs)\n .then((result) => {\n if (file.storage && isNil(result)) {\n const Provider = providers_1.default.getProvider('storage', file.storage);\n if (Provider) {\n const provider = new Provider(this);\n return provider.deleteFile(file, options);\n }\n else {\n throw ('Storage provider not found');\n }\n }\n return result || { url: '' };\n });\n });\n return sdk_1.Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n};\n// Esnure we proxy the following methods to the FormioEmbed class.\n['setBaseUrl', 'setApiUrl', 'setAppUrl', 'setProjectUrl', 'setPathType', 'setLicense'].forEach((fn) => {\n const baseFn = sdk_1.Formio[fn];\n sdk_1.Formio[fn] = function (arg) {\n const retVal = Embed_1.Formio[fn](arg, true);\n return baseFn ? baseFn.call(this, arg) : retVal;\n };\n});\n// For reverse compatability.\nsdk_1.Formio.Promise = Promise;\nsdk_1.Formio.formioReady = Embed_1.Formio.formioReady;\nsdk_1.Formio.config = Embed_1.Formio.config;\nsdk_1.Formio.builder = Embed_1.Formio.builder;\nsdk_1.Formio.Report = Embed_1.Formio.Report;\nsdk_1.Formio.Form = Embed_1.Formio.Form;\nsdk_1.Formio.FormBuilder = Embed_1.Formio.FormBuilder;\nsdk_1.Formio.use = Embed_1.Formio.use;\nsdk_1.Formio.createForm = Embed_1.Formio.createForm;\nsdk_1.Formio.submitDone = Embed_1.Formio.submitDone;\nsdk_1.Formio.addLibrary = Embed_1.Formio.addLibrary;\nsdk_1.Formio.addLoader = Embed_1.Formio.addLoader;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Formio.js?");
|
824
824
|
|
825
825
|
/***/ }),
|
826
826
|
|