@formio/js 5.0.0-rc.36 → 5.0.0-rc.37
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 +3 -3
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +3 -3
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +3 -3
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Embed.js +19 -14
- package/lib/cjs/Formio.js +3 -0
- package/lib/mjs/Embed.js +17 -14
- package/lib/mjs/Formio.js +3 -0
- package/package.json +1 -1
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
/*! @license DOMPurify 3.0.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.6/LICENSE */
|
21
21
|
|
22
|
-
/*! formiojs v5.0.0-rc.
|
22
|
+
/*! formiojs v5.0.0-rc.37 | https://unpkg.com/formiojs@5.0.0-rc.37/LICENSE.txt */
|
23
23
|
|
24
24
|
/**
|
25
25
|
* @license
|
package/dist/formio.js
CHANGED
@@ -513,7 +513,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
|
|
513
513
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
514
514
|
|
515
515
|
"use strict";
|
516
|
-
eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nexports.unsafeStringify = unsafeStringify;\n\nvar _validate = _interopRequireDefault(__webpack_require__(/*! ./validate.js */ \"./node_modules/uuid/dist/commonjs-browser/validate.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nfunction unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return
|
516
|
+
eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nexports.unsafeStringify = unsafeStringify;\n\nvar _validate = _interopRequireDefault(__webpack_require__(/*! ./validate.js */ \"./node_modules/uuid/dist/commonjs-browser/validate.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nfunction unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!(0, _validate.default)(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nvar _default = stringify;\nexports[\"default\"] = _default;\n\n//# sourceURL=webpack://Formio/./node_modules/uuid/dist/commonjs-browser/stringify.js?");
|
517
517
|
|
518
518
|
/***/ }),
|
519
519
|
|
@@ -810,7 +810,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
810
810
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
811
811
|
|
812
812
|
"use strict";
|
813
|
-
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 Formio.license = license;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setLicense(license);\n }\n }\n static setBaseUrl(url, norecurse = false) {\n Formio.baseUrl = url;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setBaseUrl(url);\n }\n }\n static setApiUrl(url, norecurse = false) {\n Formio.baseUrl = url;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setApiUrl(url);\n }\n }\n static setProjectUrl(url, norecurse = false) {\n Formio.projectUrl = url;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setProjectUrl(url);\n }\n }\n static setAppUrl(url, norecurse = false) {\n Formio.projectUrl = url;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setAppUrl(url);\n }\n }\n static setPathType(type, norecurse = false) {\n Formio.pathType = type;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setPathType(type);\n }\n }\n static debug(...args) {\n if (Formio.config.debug) {\n console.log(...args);\n }\n }\n static clearCache() {\n if (Formio.FormioClass) {\n Formio.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 Formio.debug(`Getting global ${prop}`, globalValue);\n return globalValue;\n }\n static use(module) {\n if (Formio.FormioClass && Formio.FormioClass.isRenderer) {\n Formio.FormioClass.use(module);\n }\n else {\n Formio.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(Formio.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 => Formio.addScript(wrapper, ref)));\n }\n if (name && Formio.global(name, flag)) {\n Formio.debug(`${name} already loaded.`);\n return Promise.resolve(Formio.global(name));\n }\n Formio.debug('Adding Script', src);\n try {\n wrapper.appendChild(Formio.createElement('script', {\n src\n }));\n }\n catch (err) {\n Formio.debug(err);\n return Promise.resolve();\n }\n if (!name) {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n Formio.debug(`Waiting to load ${name}`);\n const wait = setInterval(() => {\n if (Formio.global(name, flag)) {\n clearInterval(wait);\n Formio.debug(`${name} loaded.`);\n resolve(Formio.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 => Formio.addStyles(wrapper, ref));\n return;\n }\n Formio.debug('Adding Styles', href);\n wrapper.appendChild(Formio.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 Formio.debug('Submision Complete', submission);\n const successMessage = (Formio.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 = Formio.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 Formio.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 Formio.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 || Formio.config.includeBuilder;\n if (Formio.fullAdded || builder) {\n Formio.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 Formio.addLibrary(wrapper, Formio.cdn.libs[lib.dependencies[i]]);\n }\n }\n if (lib.css) {\n yield Formio.addStyles(wrapper, lib.css);\n }\n if (lib.js) {\n const module = yield Formio.addScript(wrapper, lib.js, lib.use ? name : false);\n if (lib.use) {\n Formio.debug(`Using ${name}`);\n const options = lib.options || {};\n if (!options.license && Formio.license) {\n options.license = Formio.license;\n }\n Formio.use((typeof lib.use === 'function' ? lib.use(module) : module), options);\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 Formio.cdn = new CDN_js_1.default(Formio.config.cdn, Formio.config.cdnUrls || {});\n Formio.config.libs = Formio.config.libs || {\n uswds: {\n dependencies: ['fontawesome'],\n js: `${Formio.cdn.uswds}/uswds.min.js`,\n css: `${Formio.cdn.uswds}/uswds.min.css`,\n use: true\n },\n fontawesome: {\n css: `${Formio.cdn['font-awesome']}/css/font-awesome.min.css`\n },\n bootstrap4: {\n dependencies: ['fontawesome'],\n css: `${Formio.cdn.bootstrap4}/css/bootstrap.min.css`\n },\n bootstrap: {\n dependencies: ['bootstrap-icons'],\n css: `${Formio.cdn.bootstrap}/css/bootstrap.min.css`\n },\n 'bootstrap-icons': {\n css: `${Formio.cdn['bootstrap-icons']}/css/bootstrap-icons.css`\n }\n };\n const id = Formio.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 = Formio.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 if (Formio.config.includeLibs && (typeof wrapper.attachShadow === 'function') && !Formio.config.premium) {\n wrapper = wrapper.attachShadow({\n mode: 'open'\n });\n options.shadowRoot = wrapper;\n }\n element.parentNode.removeChild(element);\n wrapper.appendChild(element);\n // Load the renderer styles.\n yield Formio.addStyles(wrapper, Formio.config.embedCSS || `${Formio.cdn.js}/formio.embed.css`);\n // Add a loader.\n wrapper.appendChild(Formio.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 const formioSrc = Formio.config.full ? 'formio.full' : 'formio.form';\n const renderer = Formio.config.debug ? formioSrc : `${formioSrc}.min`;\n Formio.FormioClass = yield Formio.addScript(wrapper, Formio.formioScript(Formio.config.script || `${Formio.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');\n Formio.FormioClass.cdn = Formio.cdn;\n Formio.FormioClass.setBaseUrl(options.baseUrl || Formio.baseUrl || Formio.config.base);\n Formio.FormioClass.setProjectUrl(options.projectUrl || Formio.projectUrl || Formio.config.project);\n Formio.FormioClass.language = Formio.language;\n Formio.setLicense(Formio.license || Formio.config.license || false);\n Formio.modules.forEach((module) => {\n Formio.FormioClass.use(module);\n });\n if (Formio.icons) {\n Formio.FormioClass.icons = Formio.icons;\n }\n if (Formio.pathType) {\n Formio.FormioClass.setPathType(Formio.pathType);\n }\n // Add libraries if they wish to include the libs.\n if (Formio.config.template && Formio.config.includeLibs) {\n yield Formio.addLibrary(wrapper, Formio.config.libs[Formio.config.template], Formio.config.template);\n }\n // Add the premium modules.\n if (Formio.config.premium) {\n Formio.config.modules.premium = Formio.config.premium;\n }\n // Allow adding dynamic modules.\n if (Formio.config.modules) {\n for (const name in Formio.config.modules) {\n const lib = Formio.config.modules[name];\n lib.use = lib.use || true;\n yield Formio.addLibrary(wrapper, lib, name);\n }\n }\n yield Formio.addStyles(wrapper, Formio.formioScript(Formio.config.style || `${Formio.cdn.js}/${renderer}.css`, builder));\n if (Formio.config.before) {\n yield Formio.config.before(Formio.FormioClass, element, Formio.config);\n }\n Formio.FormioClass.license = true;\n Formio._formioReady(Formio.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 Formio.FormioClass.events.emit(readyEvent, instance);\n if (Formio.config.after) {\n Formio.debug('Calling ready callback');\n Formio.config.after(instance, Formio.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 (Formio.FormioClass) {\n return Formio.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true }));\n }\n const wrapper = yield Formio.init(element, options);\n return Formio.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true })).then((instance) => {\n // Set the default submission data.\n if (Formio.config.submission) {\n Formio.debug('Setting submission', Formio.config.submission);\n instance.submission = Formio.config.submission;\n }\n // Call the after create method.\n Formio.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 = Formio.FormioClass) === null || _b === void 0 ? void 0 : _b.builder) {\n return Formio.FormioClass.builder(element, form, options);\n }\n const wrapper = yield Formio.init(element, options, true);\n return Formio.FormioClass.builder(element, form, options).then((instance) => {\n Formio.afterCreate(instance, wrapper, 'builderEmbedded');\n return instance;\n });\n });\n }\n}\n_a = Formio;\nFormio.FormioClass = null;\nFormio.config = {};\nFormio.modules = [];\nFormio.icons = '';\nFormio.license = '';\nFormio.formioReady = new Promise((ready, reject) => {\n Formio._formioReady = ready;\n Formio._formioReadyReject = reject;\n});\nFormio.version = '5.0.0-rc.34';\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 = Formio.FormioClass) === null || _b === void 0 ? void 0 : _b.Report) {\n return Formio.FormioClass.Report.create(element, submission, options);\n }\n const wrapper = yield Formio.init(element, options, true);\n return Formio.FormioClass.Report.create(element, submission, options).then((instance) => {\n Formio.afterCreate(instance, wrapper, 'reportEmbedded');\n return instance;\n });\n })\n};\nexports.Formio = Formio;\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
|
+
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 Formio.license = license;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setLicense(license);\n }\n }\n static setBaseUrl(url, norecurse = false) {\n Formio.baseUrl = url;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setBaseUrl(url);\n }\n }\n static setApiUrl(url, norecurse = false) {\n Formio.baseUrl = url;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setApiUrl(url);\n }\n }\n static setProjectUrl(url, norecurse = false) {\n Formio.projectUrl = url;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setProjectUrl(url);\n }\n }\n static setAppUrl(url, norecurse = false) {\n Formio.projectUrl = url;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setAppUrl(url);\n }\n }\n static setPathType(type, norecurse = false) {\n Formio.pathType = type;\n if (!norecurse && Formio.FormioClass) {\n Formio.FormioClass.setPathType(type);\n }\n }\n static debug(...args) {\n if (Formio.config.debug) {\n console.log(...args);\n }\n }\n static clearCache() {\n if (Formio.FormioClass) {\n Formio.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 Formio.debug(`Getting global ${prop}`, globalValue);\n return globalValue;\n }\n static use(module) {\n if (Formio.FormioClass && Formio.FormioClass.isRenderer) {\n Formio.FormioClass.use(module);\n }\n else {\n Formio.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(Formio.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 => Formio.addScript(wrapper, ref)));\n }\n if (name && Formio.global(name, flag)) {\n Formio.debug(`${name} already loaded.`);\n return Promise.resolve(Formio.global(name));\n }\n Formio.debug('Adding Script', src);\n try {\n wrapper.appendChild(Formio.createElement('script', {\n src\n }));\n }\n catch (err) {\n Formio.debug(err);\n return Promise.resolve();\n }\n if (!name) {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n Formio.debug(`Waiting to load ${name}`);\n const wait = setInterval(() => {\n if (Formio.global(name, flag)) {\n clearInterval(wait);\n Formio.debug(`${name} loaded.`);\n resolve(Formio.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 => Formio.addStyles(wrapper, ref));\n return;\n }\n Formio.debug('Adding Styles', href);\n wrapper.appendChild(Formio.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 Formio.debug('Submision Complete', submission);\n const successMessage = (Formio.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 = Formio.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 Formio.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 Formio.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 || Formio.config.includeBuilder;\n if (Formio.fullAdded || builder) {\n Formio.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 Formio.addLibrary(wrapper, Formio.cdn.libs[lib.dependencies[i]]);\n }\n }\n if (lib.css) {\n yield Formio.addStyles(wrapper, lib.css);\n }\n if (lib.js) {\n const module = yield Formio.addScript(wrapper, lib.js, lib.use ? name : false);\n if (lib.use) {\n Formio.debug(`Using ${name}`);\n const options = lib.options || {};\n if (!options.license && Formio.license) {\n options.license = Formio.license;\n }\n Formio.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(Formio.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 Formio.cdn = new CDN_js_1.default(Formio.config.cdn, Formio.config.cdnUrls || {});\n Formio.config.libs = Formio.config.libs || {\n uswds: {\n dependencies: ['fontawesome'],\n js: `${Formio.cdn.uswds}/uswds.min.js`,\n css: `${Formio.cdn.uswds}/uswds.min.css`,\n use: true\n },\n fontawesome: {\n css: `${Formio.cdn['font-awesome']}/css/font-awesome.min.css`\n },\n bootstrap4: {\n dependencies: ['fontawesome'],\n css: `${Formio.cdn.bootstrap4}/css/bootstrap.min.css`\n },\n bootstrap: {\n dependencies: ['bootstrap-icons'],\n css: `${Formio.cdn.bootstrap}/css/bootstrap.min.css`\n },\n 'bootstrap-icons': {\n css: `${Formio.cdn['bootstrap-icons']}/css/bootstrap-icons.css`\n }\n };\n const id = Formio.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 = Formio.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 if (Formio.config.includeLibs && (typeof wrapper.attachShadow === 'function') && !Formio.config.premium) {\n wrapper = wrapper.attachShadow({\n mode: 'open'\n });\n options.shadowRoot = wrapper;\n }\n element.parentNode.removeChild(element);\n wrapper.appendChild(element);\n // Load the renderer styles.\n yield Formio.addStyles(wrapper, Formio.config.embedCSS || `${Formio.cdn.js}/formio.embed.css`);\n // Add a loader.\n Formio.addLoader(wrapper);\n const formioSrc = Formio.config.full ? 'formio.full' : 'formio.form';\n const renderer = Formio.config.debug ? formioSrc : `${formioSrc}.min`;\n Formio.FormioClass = yield Formio.addScript(wrapper, Formio.formioScript(Formio.config.script || `${Formio.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');\n Formio.FormioClass.cdn = Formio.cdn;\n Formio.FormioClass.setBaseUrl(options.baseUrl || Formio.baseUrl || Formio.config.base);\n Formio.FormioClass.setProjectUrl(options.projectUrl || Formio.projectUrl || Formio.config.project);\n Formio.FormioClass.language = Formio.language;\n Formio.setLicense(Formio.license || Formio.config.license || false);\n Formio.modules.forEach((module) => {\n Formio.FormioClass.use(module);\n });\n if (Formio.icons) {\n Formio.FormioClass.icons = Formio.icons;\n }\n if (Formio.pathType) {\n Formio.FormioClass.setPathType(Formio.pathType);\n }\n // Add libraries if they wish to include the libs.\n if (Formio.config.template && Formio.config.includeLibs) {\n yield Formio.addLibrary(wrapper, Formio.config.libs[Formio.config.template], Formio.config.template);\n }\n // Add the premium modules.\n if (Formio.config.premium) {\n Formio.config.modules.premium = Formio.config.premium;\n }\n // Allow adding dynamic modules.\n if (Formio.config.modules) {\n for (const name in Formio.config.modules) {\n const lib = Formio.config.modules[name];\n lib.use = lib.use || true;\n yield Formio.addLibrary(wrapper, lib, name);\n }\n }\n yield Formio.addStyles(wrapper, Formio.formioScript(Formio.config.style || `${Formio.cdn.js}/${renderer}.css`, builder));\n if (Formio.config.before) {\n yield Formio.config.before(Formio.FormioClass, element, Formio.config);\n }\n Formio.FormioClass.license = true;\n Formio._formioReady(Formio.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 Formio.FormioClass.events.emit(readyEvent, instance);\n if (Formio.config.after) {\n Formio.debug('Calling ready callback');\n Formio.config.after(instance, Formio.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 (Formio.FormioClass) {\n return Formio.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true }));\n }\n const wrapper = yield Formio.init(element, options);\n return Formio.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true })).then((instance) => {\n // Set the default submission data.\n if (Formio.config.submission) {\n Formio.debug('Setting submission', Formio.config.submission);\n instance.submission = Formio.config.submission;\n }\n // Call the after create method.\n Formio.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 = Formio.FormioClass) === null || _b === void 0 ? void 0 : _b.builder) {\n return Formio.FormioClass.builder(element, form, options);\n }\n const wrapper = yield Formio.init(element, options, true);\n return Formio.FormioClass.builder(element, form, options).then((instance) => {\n Formio.afterCreate(instance, wrapper, 'builderEmbedded');\n return instance;\n });\n });\n }\n}\n_a = Formio;\nFormio.FormioClass = null;\nFormio.config = {};\nFormio.modules = [];\nFormio.icons = '';\nFormio.license = '';\nFormio.formioReady = new Promise((ready, reject) => {\n Formio._formioReady = ready;\n Formio._formioReadyReject = reject;\n});\nFormio.version = '5.0.0-rc.37';\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 = Formio.FormioClass) === null || _b === void 0 ? void 0 : _b.Report) {\n return Formio.FormioClass.Report.create(element, submission, options);\n }\n const wrapper = yield Formio.init(element, options, true);\n return Formio.FormioClass.Report.create(element, submission, options).then((instance) => {\n Formio.afterCreate(instance, wrapper, 'reportEmbedded');\n return instance;\n });\n })\n};\nexports.Formio = Formio;\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?");
|
814
814
|
|
815
815
|
/***/ }),
|
816
816
|
|
@@ -821,7 +821,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
821
821
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
822
822
|
|
823
823
|
"use strict";
|
824
|
-
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.
|
824
|
+
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.37';\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?");
|
825
825
|
|
826
826
|
/***/ })
|
827
827
|
|