@formio/js 5.1.2-rc.5 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formio.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.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Embed.js +1 -1
- package/lib/cjs/Formio.js +1 -1
- package/lib/mjs/Embed.js +1 -1
- package/lib/mjs/Formio.js +1 -1
- package/package.json +3 -3
package/dist/formio.embed.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
/*! For license information please see formio.embed.min.js.LICENSE.txt */
|
2
|
-
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.Formio=o():e.Formio=o()}(self,(function(){return function(){"use strict";var e={56036:function(e,o){Object.defineProperty(o,"__esModule",{value:!0});class t{constructor(e,o={}){this.baseUrl=e||t.defaultCDN,this.overrides=o,this.libs={js:"",ace:"1.4.12",bootstrap:"5.3.3",bootstrap4:"4.6.2",bootstrap5:"5.3.3",bootswatch:"5.3.3","bootstrap-icons":"1.11.1",ckeditor:"19.0.0",flatpickr:"4.6.8","flatpickr-formio":"4.6.13-formio.3","font-awesome":"4.7.0",grid:"latest","moment-timezone":"latest",quill:"2.0.0-dev.3","shortcut-buttons-flatpickr":"0.4.0",uswds:"2.4.8",core:""},this.updateUrls()}getVersion(e){return this.libs[e]}setVersion(e,o){this.libs[e]=o,this.updateUrls()}setBaseUrl(e){this.baseUrl=e,this.updateUrls()}setOverrideUrl(e,o){this.overrides[e]=o,this.updateUrls()}removeOverride(e){delete this.overrides[e],this.updateUrls()}removeOverrides(){this.overrides={},this.updateUrls()}buildUrl(e,o,t){let s=e;return o&&(s+=`/${o}`),e.match(/cdn\.(test-)?form.io/)&&t&&"latest"!==t&&(s+=`/${t}`),s}updateUrls(){for(const e in this.libs)if(e in this.overrides)if("string"==typeof this.overrides[e])this[e]=this.buildUrl(this.overrides[e],e,this.libs[e]);else{const o=this.overrides[e];this[e]=this.buildUrl(o.cdn,o.lib||"",o.version||"")}else this[e]=this.buildUrl(this.baseUrl,e,this.libs[e])}}t.defaultCDN="https://cdn.form.io",o.default=t},96517:function(e,o,t){Object.defineProperty(o,"__esModule",{value:!0}),o.Formio=o.embed=void 0;const s=t(95413);Object.defineProperty(o,"Formio",{enumerable:!0,get:function(){return s.Formio}}),o.embed=function(e={}){const o=document.getElementsByTagName("script");e=Object.assign({},window.FormioConfig||{},e);let t=null,i=o.length;const r=e.scriptName||"formio.embed.";for(;i--;)if(o[i].src&&-1!==o[i].src.indexOf(r)){t=o[i];break}if(t){const o={};t.src.replace(/^[^?]+\??/,"").replace(/\?/g,"&").split("&").forEach((e=>{o[e.split("=")[0]]=e.split("=")[1]&&decodeURIComponent(e.split("=")[1])}));let i=t.src.replace(/^([^?]+).*/,"$1").split("/");i.pop();let r="";["js","offline"].includes(i[i.length-1])?(i.pop(),i=r=i.join("/"),i+="/js"):i=i.join("/");const n="true"===o.debug||"1"===o.debug,a=n?"formio.form":"formio.form.min";s.Formio.config=Object.assign({script:o.script||`${i}/${a}.js`,style:o.styles||`${i}/${a}.css`,cdn:o.cdn||r,class:o.class||"formio-form-wrapper",src:o.src,form:null,submission:null,project:o.project,base:o.base||"https://api.form.io",submit:o.submit,includeLibs:"true"===o.libs||"1"===o.libs,noshadow:"false"===o.shadow||"0"===o.shadow,template:o.template||"bootstrap",debug:n,config:{},redirect:o.return||o.redirect,embedCSS:`${i}/formio.embed.css`,success:o.success||"Thank you for your submission!",before:null,after:null},e),s.Formio.config.alter&&s.Formio.config.alter(s.Formio.config);const c=s.Formio.config.form||s.Formio.config.src;if(c){s.Formio.debug("Embedding Configuration",e),s.Formio.config.id=`formio-${Math.random().toString(36).substring(7)}`,s.Formio.debug("Creating form element");const o=s.Formio.createElement("div",{id:s.Formio.config.id,class:s.Formio.config.class});t.parentNode.insertBefore(o,t.parentNode.firstElementChild.nextSibling),s.Formio.createForm(o,c,s.Formio.config.config).then((e=>{s.Formio.config.submit&&(e.nosubmit=!0),e.on("submitDone",(o=>s.Formio.submitDone(e,o))),e.on("submit",(o=>{if(s.Formio.debug("on('submit')",o),s.Formio.config.submit){s.Formio.debug(`Sending submission to ${s.Formio.config.submit}`);const t={"content-type":"application/json"},i=s.Formio.FormioClass.getToken();i&&(t["x-jwt-token"]=i),s.Formio.FormioClass.fetch(s.Formio.config.submit,{body:JSON.stringify(o),headers:t,method:"POST",mode:"cors"}).then((e=>e.json())).then((o=>{s.Formio.submitDone(e,o)}))}}))}))}}else document.write("<span>Could not locate the Embedded form.</span>")}},95413:function(e,o,t){var s,i=this&&this.__awaiter||function(e,o,t,s){return new(t||(t=Promise))((function(i,r){function n(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var o;e.done?i(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(n,a)}c((s=s.apply(e,o||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.FormBuilder=o.Form=o.Formio=void 0;const n=r(t(56036));class a{static setLicense(e,o=!1){s.license=e,!o&&s.FormioClass&&s.FormioClass.setLicense(e)}static setBaseUrl(e,o=!1){s.baseUrl=e,!o&&s.FormioClass&&s.FormioClass.setBaseUrl(e)}static setApiUrl(e,o=!1){s.baseUrl=e,!o&&s.FormioClass&&s.FormioClass.setApiUrl(e)}static setProjectUrl(e,o=!1){s.projectUrl=e,!o&&s.FormioClass&&s.FormioClass.setProjectUrl(e)}static setAppUrl(e,o=!1){s.projectUrl=e,!o&&s.FormioClass&&s.FormioClass.setAppUrl(e)}static setPathType(e,o=!1){s.pathType=e,!o&&s.FormioClass&&s.FormioClass.setPathType(e)}static debug(...e){s.config.debug&&console.log(...e)}static clearCache(){s.FormioClass&&s.FormioClass.clearCache()}static global(e,o=""){const t=window[e];return o&&t&&!t[o]?null:(s.debug(`Getting global ${e}`,t),t)}static use(e){s.FormioClass&&s.FormioClass.isRenderer?s.FormioClass.use(e):s.modules.push(e)}static createElement(e,o,t){const i=document.createElement(e);return o?(Object.keys(o).forEach((e=>{i.setAttribute(e,o[e])})),(t||[]).forEach((e=>{i.appendChild(s.createElement(e.tag,e.attrs,e.children))})),i):i}static addScript(e,o,t,r=""){return i(this,void 0,void 0,(function*(){if(!o)return Promise.resolve();if("string"!=typeof o&&o.length)return Promise.all(o.map((o=>s.addScript(e,o))));if(t&&s.global(t,r))return s.debug(`${t} already loaded.`),Promise.resolve(s.global(t));s.debug("Adding Script",o);try{e.appendChild(s.createElement("script",{src:o}))}catch(e){return s.debug(e),Promise.resolve()}return t?new Promise((e=>{s.debug(`Waiting to load ${t}`);const o=setInterval((()=>{s.global(t,r)&&(clearInterval(o),s.debug(`${t} loaded.`),e(s.global(t)))}),100)})):Promise.resolve()}))}static addStyles(e,o){return i(this,void 0,void 0,(function*(){o&&("string"!=typeof o&&o.length?o.forEach((o=>s.addStyles(e,o))):(s.debug("Adding Styles",o),e.appendChild(s.createElement("link",{rel:"stylesheet",href:o}))))}))}static submitDone(e,o){return i(this,void 0,void 0,(function*(){s.debug("Submision Complete",o),s.config.submitDone&&s.config.submitDone(o,e);const t=(s.config.success||"").toString();t&&"false"!==t.toLowerCase()&&e.element&&(e.element.innerHTML=`<div class="alert-success" role="alert">${t}</div>`);let i=s.config.redirect;if(!i&&e._form&&e._form.settings&&(e._form.settings.returnUrl||e._form.settings.redirect)&&(s.debug("Return url found in form configuration"),i=e._form.settings.returnUrl||e._form.settings.redirect),i){const t=e.formio?e.formio.formUrl:"",r=!!i.match(/\?/),n=0===i.indexOf(location.origin);i+=r?"&":"?",i+=`sub=${o._id}`,!n&&t&&(i+=`&form=${encodeURIComponent(t)}`),s.debug("Return URL",i),window.location.href=i,n&&window.location.reload()}}))}static formioScript(e,o){return o=o||s.config.includeBuilder,s.fullAdded||o?(s.fullAdded=!0,e.replace("formio.form","formio.full")):e}static addLibrary(e,o,t){return i(this,void 0,void 0,(function*(){if(o){if(o.dependencies)for(let t=0;t<o.dependencies.length;t++){const i=o.dependencies[t];yield s.addLibrary(e,s.config.libs[i],i)}if(o.css&&(yield s.addStyles(o.global?document.body:e,o.css)),o.js){const i=yield s.addScript(o.global?document.body:e,o.js,!!o.use&&t);if(o.use){s.debug(`Using ${t}`);const e=o.options||{};!e.license&&s.license&&(e.license=s.license),s.use("function"==typeof o.use?o.use(i):i,e)}}if(o.globalStyle){const e=s.createElement("style");e.type="text/css",e.innerHTML=o.globalStyle,document.body.appendChild(e)}}}))}static addLoader(e){return i(this,void 0,void 0,(function*(){e.appendChild(s.createElement("div",{class:"formio-loader"},[{tag:"div",attrs:{class:"loader-wrapper"},children:[{tag:"div",attrs:{class:"loader text-center"}}]}]))}))}static init(e,o={},t=!1){return i(this,void 0,void 0,(function*(){s.cdn=new n.default(s.config.cdn,s.config.cdnUrls||{}),s.config.libs=s.config.libs||{uswds:{dependencies:["fontawesome"],js:`${s.cdn.uswds}/uswds.min.js`,css:`${s.cdn.uswds}/uswds.min.css`,use:!0},fontawesome:{css:"https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css",globalStyle:"@font-face {\n font-family: 'FontAwesome';\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');\n font-weight: normal;\n font-style: normal;\n }"},bootstrap4:{dependencies:["fontawesome"],css:`${s.cdn.bootstrap4}/css/bootstrap.min.css`},bootstrap:{dependencies:["bootstrap-icons"],css:`${s.cdn.bootstrap}/css/bootstrap.min.css`},"bootstrap-icons":{css:"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css",globalStyle:'@font-face {\n font-display: block;\n font-family: "bootstrap-icons";\n src: url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6") format("woff2"),\n url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6") format("woff");\n }'}},["cerulean","cosmo","cyborg","darkly","flatly","journal","litera","lumen","lux","materia","minty","pulse","sandstone","simplex","sketchy","slate","solar","spacelab","superhero","united","yeti"].forEach((e=>{s.config.libs[e]={dependencies:["bootstrap-icons"],css:`${s.cdn.bootswatch}/dist/${e}/bootstrap.min.css`}}));const i=s.config.id||`formio-${Math.random().toString(36).substring(7)}`;let r=s.createElement("div",{id:`${i}-wrapper`});e.parentNode.insertBefore(r,e);const a=s.config.includeLibs&&!s.config.noshadow&&"function"==typeof r.attachShadow;a&&(r=r.attachShadow({mode:"open"}),o.shadowRoot=r),e.parentNode.removeChild(e),r.appendChild(e);const c=a?r:document.body;yield s.addStyles(c,s.config.embedCSS||`${s.cdn.js}/formio.embed.css`),s.addLoader(r);const l=s.config.full?"formio.full":"formio.form",d=s.config.debug?l:`${l}.min`;if(s.FormioClass=yield s.addScript(c,s.formioScript(s.config.script||`${s.cdn.js}/${d}.js`,t),"Formio",t?"isBuilder":"isRenderer"),s.FormioClass.cdn=s.cdn,s.FormioClass.setBaseUrl(o.baseUrl||s.baseUrl||s.config.base),s.FormioClass.setProjectUrl(o.projectUrl||s.projectUrl||s.config.project),s.FormioClass.language=s.language,s.setLicense(s.license||s.config.license||!1),s.modules.forEach((e=>{s.FormioClass.use(e)})),s.icons&&(s.FormioClass.icons=s.icons),s.pathType&&s.FormioClass.setPathType(s.pathType),s.config.template&&s.config.includeLibs&&(yield s.addLibrary(c,s.config.libs[s.config.template],s.config.template)),s.config.libraries||(s.config.libraries=s.config.modules||{}),s.config.premium&&(s.config.libraries.premium=s.config.premium),s.config.libraries)for(const e in s.config.libraries){const o=s.config.libraries[e];o.use=o.use||!0,yield s.addLibrary(c,o,e)}return yield s.addStyles(c,s.formioScript(s.config.style||`${s.cdn.js}/${d}.css`,t)),s.config.before&&(yield s.config.before(s.FormioClass,e,s.config)),s.FormioClass.license=!0,s._formioReady(s.FormioClass),r}))}static afterCreate(e,o,t){return i(this,void 0,void 0,(function*(){const i=o.querySelector(".formio-loader");return i&&o.removeChild(i),s.FormioClass.events.emit(t,e),s.config.after&&(s.debug("Calling ready callback"),s.config.after(e,s.config)),e}))}static createForm(e,o,t={}){return i(this,void 0,void 0,(function*(){if(s.FormioClass)return s.FormioClass.createForm(e,o,Object.assign(Object.assign({},t),{noLoader:!0}));const i=yield s.init(e,t);return s.FormioClass.createForm(e,o,Object.assign(Object.assign({},t),{noLoader:!0})).then((e=>(s.config.submission&&(s.debug("Setting submission",s.config.submission),e.submission=s.config.submission),s.afterCreate(e,i,"formEmbedded"),e)))}))}static builder(e,o,t={}){var r;return i(this,void 0,void 0,(function*(){if(null===(r=s.FormioClass)||void 0===r?void 0:r.builder)return s.FormioClass.builder(e,o,t);const i=yield s.init(e,t,!0);return s.FormioClass.builder(e,o,t).then((e=>(s.afterCreate(e,i,"builderEmbedded"),e)))}))}}o.Formio=a,s=a,a.FormioClass=null,a.config={},a.modules=[],a.icons="",a.license="",a.formioReady=new Promise(((e,o)=>{s._formioReady=e,s._formioReadyReject=o})),a.version="5.1.2-rc.5",a.Report={create:(e,o,t={})=>i(void 0,void 0,void 0,(function*(){var i;if(null===(i=s.FormioClass)||void 0===i?void 0:i.Report)return s.FormioClass.Report.create(e,o,t);const r=yield s.init(e,t,!0);return s.FormioClass.Report.create(e,o,t).then((e=>(s.afterCreate(e,r,"reportEmbedded"),e)))}))},n.default.defaultCDN=a.version.includes("rc")?"https://cdn.test-form.io":"https://cdn.form.io";class c{constructor(e,o,t){this.form=o,this.element=e,this.options=t||{},this.init(),this.instance={proxy:!0,ready:this.ready,destroy:()=>{}}}init(){this.instance&&!this.instance.proxy&&this.instance.destroy(),this.element.innerHTML="",this.ready=this.create().then((e=>(this.instance=e,this.form=e.form,e)))}create(){return a.createForm(this.element,this.form,this.options)}setForm(e){this.form=e,this.instance&&this.instance.setForm(e)}setDisplay(e){return this.instance.proxy||(this.form.display=e,this.instance.destroy(),this.ready=this.create().then((e=>{this.instance=e,this.setForm(this.form)}))),this.ready}}o.Form=c;class l extends c{create(){return a.builder(this.element,this.form,this.options)}}o.FormBuilder=l,a.Form=c,a.FormBuilder=l}},o={};function t(s){var i=o[s];if(void 0!==i)return i.exports;var r=o[s]={exports:{}};return e[s].call(r.exports,r,r.exports,t),r.exports}var s={};return function(){var e=s;e.Formio=void 0,(0,t(96517).embed)();var o=t(96517);Object.defineProperty(e,"Formio",{enumerable:!0,get:function(){return o.Formio}})}(),s.Formio}()}));
|
2
|
+
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.Formio=o():e.Formio=o()}(self,(function(){return function(){"use strict";var e={56036:function(e,o){Object.defineProperty(o,"__esModule",{value:!0});class t{constructor(e,o={}){this.baseUrl=e||t.defaultCDN,this.overrides=o,this.libs={js:"",ace:"1.4.12",bootstrap:"5.3.3",bootstrap4:"4.6.2",bootstrap5:"5.3.3",bootswatch:"5.3.3","bootstrap-icons":"1.11.1",ckeditor:"19.0.0",flatpickr:"4.6.8","flatpickr-formio":"4.6.13-formio.3","font-awesome":"4.7.0",grid:"latest","moment-timezone":"latest",quill:"2.0.0-dev.3","shortcut-buttons-flatpickr":"0.4.0",uswds:"2.4.8",core:""},this.updateUrls()}getVersion(e){return this.libs[e]}setVersion(e,o){this.libs[e]=o,this.updateUrls()}setBaseUrl(e){this.baseUrl=e,this.updateUrls()}setOverrideUrl(e,o){this.overrides[e]=o,this.updateUrls()}removeOverride(e){delete this.overrides[e],this.updateUrls()}removeOverrides(){this.overrides={},this.updateUrls()}buildUrl(e,o,t){let s=e;return o&&(s+=`/${o}`),e.match(/cdn\.(test-)?form.io/)&&t&&"latest"!==t&&(s+=`/${t}`),s}updateUrls(){for(const e in this.libs)if(e in this.overrides)if("string"==typeof this.overrides[e])this[e]=this.buildUrl(this.overrides[e],e,this.libs[e]);else{const o=this.overrides[e];this[e]=this.buildUrl(o.cdn,o.lib||"",o.version||"")}else this[e]=this.buildUrl(this.baseUrl,e,this.libs[e])}}t.defaultCDN="https://cdn.form.io",o.default=t},96517:function(e,o,t){Object.defineProperty(o,"__esModule",{value:!0}),o.Formio=o.embed=void 0;const s=t(95413);Object.defineProperty(o,"Formio",{enumerable:!0,get:function(){return s.Formio}}),o.embed=function(e={}){const o=document.getElementsByTagName("script");e=Object.assign({},window.FormioConfig||{},e);let t=null,i=o.length;const r=e.scriptName||"formio.embed.";for(;i--;)if(o[i].src&&-1!==o[i].src.indexOf(r)){t=o[i];break}if(t){const o={};t.src.replace(/^[^?]+\??/,"").replace(/\?/g,"&").split("&").forEach((e=>{o[e.split("=")[0]]=e.split("=")[1]&&decodeURIComponent(e.split("=")[1])}));let i=t.src.replace(/^([^?]+).*/,"$1").split("/");i.pop();let r="";["js","offline"].includes(i[i.length-1])?(i.pop(),i=r=i.join("/"),i+="/js"):i=i.join("/");const n="true"===o.debug||"1"===o.debug,a=n?"formio.form":"formio.form.min";s.Formio.config=Object.assign({script:o.script||`${i}/${a}.js`,style:o.styles||`${i}/${a}.css`,cdn:o.cdn||r,class:o.class||"formio-form-wrapper",src:o.src,form:null,submission:null,project:o.project,base:o.base||"https://api.form.io",submit:o.submit,includeLibs:"true"===o.libs||"1"===o.libs,noshadow:"false"===o.shadow||"0"===o.shadow,template:o.template||"bootstrap",debug:n,config:{},redirect:o.return||o.redirect,embedCSS:`${i}/formio.embed.css`,success:o.success||"Thank you for your submission!",before:null,after:null},e),s.Formio.config.alter&&s.Formio.config.alter(s.Formio.config);const c=s.Formio.config.form||s.Formio.config.src;if(c){s.Formio.debug("Embedding Configuration",e),s.Formio.config.id=`formio-${Math.random().toString(36).substring(7)}`,s.Formio.debug("Creating form element");const o=s.Formio.createElement("div",{id:s.Formio.config.id,class:s.Formio.config.class});t.parentNode.insertBefore(o,t.parentNode.firstElementChild.nextSibling),s.Formio.createForm(o,c,s.Formio.config.config).then((e=>{s.Formio.config.submit&&(e.nosubmit=!0),e.on("submitDone",(o=>s.Formio.submitDone(e,o))),e.on("submit",(o=>{if(s.Formio.debug("on('submit')",o),s.Formio.config.submit){s.Formio.debug(`Sending submission to ${s.Formio.config.submit}`);const t={"content-type":"application/json"},i=s.Formio.FormioClass.getToken();i&&(t["x-jwt-token"]=i),s.Formio.FormioClass.fetch(s.Formio.config.submit,{body:JSON.stringify(o),headers:t,method:"POST",mode:"cors"}).then((e=>e.json())).then((o=>{s.Formio.submitDone(e,o)}))}}))}))}}else document.write("<span>Could not locate the Embedded form.</span>")}},95413:function(e,o,t){var s,i=this&&this.__awaiter||function(e,o,t,s){return new(t||(t=Promise))((function(i,r){function n(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var o;e.done?i(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(n,a)}c((s=s.apply(e,o||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.FormBuilder=o.Form=o.Formio=void 0;const n=r(t(56036));class a{static setLicense(e,o=!1){s.license=e,!o&&s.FormioClass&&s.FormioClass.setLicense(e)}static setBaseUrl(e,o=!1){s.baseUrl=e,!o&&s.FormioClass&&s.FormioClass.setBaseUrl(e)}static setApiUrl(e,o=!1){s.baseUrl=e,!o&&s.FormioClass&&s.FormioClass.setApiUrl(e)}static setProjectUrl(e,o=!1){s.projectUrl=e,!o&&s.FormioClass&&s.FormioClass.setProjectUrl(e)}static setAppUrl(e,o=!1){s.projectUrl=e,!o&&s.FormioClass&&s.FormioClass.setAppUrl(e)}static setPathType(e,o=!1){s.pathType=e,!o&&s.FormioClass&&s.FormioClass.setPathType(e)}static debug(...e){s.config.debug&&console.log(...e)}static clearCache(){s.FormioClass&&s.FormioClass.clearCache()}static global(e,o=""){const t=window[e];return o&&t&&!t[o]?null:(s.debug(`Getting global ${e}`,t),t)}static use(e){s.FormioClass&&s.FormioClass.isRenderer?s.FormioClass.use(e):s.modules.push(e)}static createElement(e,o,t){const i=document.createElement(e);return o?(Object.keys(o).forEach((e=>{i.setAttribute(e,o[e])})),(t||[]).forEach((e=>{i.appendChild(s.createElement(e.tag,e.attrs,e.children))})),i):i}static addScript(e,o,t,r=""){return i(this,void 0,void 0,(function*(){if(!o)return Promise.resolve();if("string"!=typeof o&&o.length)return Promise.all(o.map((o=>s.addScript(e,o))));if(t&&s.global(t,r))return s.debug(`${t} already loaded.`),Promise.resolve(s.global(t));s.debug("Adding Script",o);try{e.appendChild(s.createElement("script",{src:o}))}catch(e){return s.debug(e),Promise.resolve()}return t?new Promise((e=>{s.debug(`Waiting to load ${t}`);const o=setInterval((()=>{s.global(t,r)&&(clearInterval(o),s.debug(`${t} loaded.`),e(s.global(t)))}),100)})):Promise.resolve()}))}static addStyles(e,o){return i(this,void 0,void 0,(function*(){o&&("string"!=typeof o&&o.length?o.forEach((o=>s.addStyles(e,o))):(s.debug("Adding Styles",o),e.appendChild(s.createElement("link",{rel:"stylesheet",href:o}))))}))}static submitDone(e,o){return i(this,void 0,void 0,(function*(){s.debug("Submision Complete",o),s.config.submitDone&&s.config.submitDone(o,e);const t=(s.config.success||"").toString();t&&"false"!==t.toLowerCase()&&e.element&&(e.element.innerHTML=`<div class="alert-success" role="alert">${t}</div>`);let i=s.config.redirect;if(!i&&e._form&&e._form.settings&&(e._form.settings.returnUrl||e._form.settings.redirect)&&(s.debug("Return url found in form configuration"),i=e._form.settings.returnUrl||e._form.settings.redirect),i){const t=e.formio?e.formio.formUrl:"",r=!!i.match(/\?/),n=0===i.indexOf(location.origin);i+=r?"&":"?",i+=`sub=${o._id}`,!n&&t&&(i+=`&form=${encodeURIComponent(t)}`),s.debug("Return URL",i),window.location.href=i,n&&window.location.reload()}}))}static formioScript(e,o){return o=o||s.config.includeBuilder,s.fullAdded||o?(s.fullAdded=!0,e.replace("formio.form","formio.full")):e}static addLibrary(e,o,t){return i(this,void 0,void 0,(function*(){if(o){if(o.dependencies)for(let t=0;t<o.dependencies.length;t++){const i=o.dependencies[t];yield s.addLibrary(e,s.config.libs[i],i)}if(o.css&&(yield s.addStyles(o.global?document.body:e,o.css)),o.js){const i=yield s.addScript(o.global?document.body:e,o.js,!!o.use&&t);if(o.use){s.debug(`Using ${t}`);const e=o.options||{};!e.license&&s.license&&(e.license=s.license),s.use("function"==typeof o.use?o.use(i):i,e)}}if(o.globalStyle){const e=s.createElement("style");e.type="text/css",e.innerHTML=o.globalStyle,document.body.appendChild(e)}}}))}static addLoader(e){return i(this,void 0,void 0,(function*(){e.appendChild(s.createElement("div",{class:"formio-loader"},[{tag:"div",attrs:{class:"loader-wrapper"},children:[{tag:"div",attrs:{class:"loader text-center"}}]}]))}))}static init(e,o={},t=!1){return i(this,void 0,void 0,(function*(){s.cdn=new n.default(s.config.cdn,s.config.cdnUrls||{}),s.config.libs=s.config.libs||{uswds:{dependencies:["fontawesome"],js:`${s.cdn.uswds}/uswds.min.js`,css:`${s.cdn.uswds}/uswds.min.css`,use:!0},fontawesome:{css:"https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css",globalStyle:"@font-face {\n font-family: 'FontAwesome';\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');\n font-weight: normal;\n font-style: normal;\n }"},bootstrap4:{dependencies:["fontawesome"],css:`${s.cdn.bootstrap4}/css/bootstrap.min.css`},bootstrap:{dependencies:["bootstrap-icons"],css:`${s.cdn.bootstrap}/css/bootstrap.min.css`},"bootstrap-icons":{css:"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css",globalStyle:'@font-face {\n font-display: block;\n font-family: "bootstrap-icons";\n src: url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6") format("woff2"),\n url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6") format("woff");\n }'}},["cerulean","cosmo","cyborg","darkly","flatly","journal","litera","lumen","lux","materia","minty","pulse","sandstone","simplex","sketchy","slate","solar","spacelab","superhero","united","yeti"].forEach((e=>{s.config.libs[e]={dependencies:["bootstrap-icons"],css:`${s.cdn.bootswatch}/dist/${e}/bootstrap.min.css`}}));const i=s.config.id||`formio-${Math.random().toString(36).substring(7)}`;let r=s.createElement("div",{id:`${i}-wrapper`});e.parentNode.insertBefore(r,e);const a=s.config.includeLibs&&!s.config.noshadow&&"function"==typeof r.attachShadow;a&&(r=r.attachShadow({mode:"open"}),o.shadowRoot=r),e.parentNode.removeChild(e),r.appendChild(e);const c=a?r:document.body;yield s.addStyles(c,s.config.embedCSS||`${s.cdn.js}/formio.embed.css`),s.addLoader(r);const l=s.config.full?"formio.full":"formio.form",d=s.config.debug?l:`${l}.min`;if(s.FormioClass=yield s.addScript(c,s.formioScript(s.config.script||`${s.cdn.js}/${d}.js`,t),"Formio",t?"isBuilder":"isRenderer"),s.FormioClass.cdn=s.cdn,s.FormioClass.setBaseUrl(o.baseUrl||s.baseUrl||s.config.base),s.FormioClass.setProjectUrl(o.projectUrl||s.projectUrl||s.config.project),s.FormioClass.language=s.language,s.setLicense(s.license||s.config.license||!1),s.modules.forEach((e=>{s.FormioClass.use(e)})),s.icons&&(s.FormioClass.icons=s.icons),s.pathType&&s.FormioClass.setPathType(s.pathType),s.config.template&&s.config.includeLibs&&(yield s.addLibrary(c,s.config.libs[s.config.template],s.config.template)),s.config.libraries||(s.config.libraries=s.config.modules||{}),s.config.premium&&(s.config.libraries.premium=s.config.premium),s.config.libraries)for(const e in s.config.libraries){const o=s.config.libraries[e];o.use=o.use||!0,yield s.addLibrary(c,o,e)}return yield s.addStyles(c,s.formioScript(s.config.style||`${s.cdn.js}/${d}.css`,t)),s.config.before&&(yield s.config.before(s.FormioClass,e,s.config)),s.FormioClass.license=!0,s._formioReady(s.FormioClass),r}))}static afterCreate(e,o,t){return i(this,void 0,void 0,(function*(){const i=o.querySelector(".formio-loader");return i&&o.removeChild(i),s.FormioClass.events.emit(t,e),s.config.after&&(s.debug("Calling ready callback"),s.config.after(e,s.config)),e}))}static createForm(e,o,t={}){return i(this,void 0,void 0,(function*(){if(s.FormioClass)return s.FormioClass.createForm(e,o,Object.assign(Object.assign({},t),{noLoader:!0}));const i=yield s.init(e,t);return s.FormioClass.createForm(e,o,Object.assign(Object.assign({},t),{noLoader:!0})).then((e=>(s.config.submission&&(s.debug("Setting submission",s.config.submission),e.submission=s.config.submission),s.afterCreate(e,i,"formEmbedded"),e)))}))}static builder(e,o,t={}){var r;return i(this,void 0,void 0,(function*(){if(null===(r=s.FormioClass)||void 0===r?void 0:r.builder)return s.FormioClass.builder(e,o,t);const i=yield s.init(e,t,!0);return s.FormioClass.builder(e,o,t).then((e=>(s.afterCreate(e,i,"builderEmbedded"),e)))}))}}o.Formio=a,s=a,a.FormioClass=null,a.config={},a.modules=[],a.icons="",a.license="",a.formioReady=new Promise(((e,o)=>{s._formioReady=e,s._formioReadyReject=o})),a.version="5.1.2",a.Report={create:(e,o,t={})=>i(void 0,void 0,void 0,(function*(){var i;if(null===(i=s.FormioClass)||void 0===i?void 0:i.Report)return s.FormioClass.Report.create(e,o,t);const r=yield s.init(e,t,!0);return s.FormioClass.Report.create(e,o,t).then((e=>(s.afterCreate(e,r,"reportEmbedded"),e)))}))},n.default.defaultCDN=a.version.includes("rc")?"https://cdn.test-form.io":"https://cdn.form.io";class c{constructor(e,o,t){this.form=o,this.element=e,this.options=t||{},this.init(),this.instance={proxy:!0,ready:this.ready,destroy:()=>{}}}init(){this.instance&&!this.instance.proxy&&this.instance.destroy(),this.element.innerHTML="",this.ready=this.create().then((e=>(this.instance=e,this.form=e.form,e)))}create(){return a.createForm(this.element,this.form,this.options)}setForm(e){this.form=e,this.instance&&this.instance.setForm(e)}setDisplay(e){return this.instance.proxy||(this.form.display=e,this.instance.destroy(),this.ready=this.create().then((e=>{this.instance=e,this.setForm(this.form)}))),this.ready}}o.Form=c;class l extends c{create(){return a.builder(this.element,this.form,this.options)}}o.FormBuilder=l,a.Form=c,a.FormBuilder=l}},o={};function t(s){var i=o[s];if(void 0!==i)return i.exports;var r=o[s]={exports:{}};return e[s].call(r.exports,r,r.exports,t),r.exports}var s={};return function(){var e=s;e.Formio=void 0,(0,t(96517).embed)();var o=t(96517);Object.defineProperty(e,"Formio",{enumerable:!0,get:function(){return o.Formio}})}(),s.Formio}()}));
|
package/dist/formio.embed.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
/*! For license information please see formio.embed.min.js.LICENSE.txt */
|
2
|
-
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.Formio=o():e.Formio=o()}(self,(function(){return function(){"use strict";var e={56036:function(e,o){Object.defineProperty(o,"__esModule",{value:!0});class t{constructor(e,o={}){this.baseUrl=e||t.defaultCDN,this.overrides=o,this.libs={js:"",ace:"1.4.12",bootstrap:"5.3.3",bootstrap4:"4.6.2",bootstrap5:"5.3.3",bootswatch:"5.3.3","bootstrap-icons":"1.11.1",ckeditor:"19.0.0",flatpickr:"4.6.8","flatpickr-formio":"4.6.13-formio.3","font-awesome":"4.7.0",grid:"latest","moment-timezone":"latest",quill:"2.0.0-dev.3","shortcut-buttons-flatpickr":"0.4.0",uswds:"2.4.8",core:""},this.updateUrls()}getVersion(e){return this.libs[e]}setVersion(e,o){this.libs[e]=o,this.updateUrls()}setBaseUrl(e){this.baseUrl=e,this.updateUrls()}setOverrideUrl(e,o){this.overrides[e]=o,this.updateUrls()}removeOverride(e){delete this.overrides[e],this.updateUrls()}removeOverrides(){this.overrides={},this.updateUrls()}buildUrl(e,o,t){let s=e;return o&&(s+=`/${o}`),e.match(/cdn\.(test-)?form.io/)&&t&&"latest"!==t&&(s+=`/${t}`),s}updateUrls(){for(const e in this.libs)if(e in this.overrides)if("string"==typeof this.overrides[e])this[e]=this.buildUrl(this.overrides[e],e,this.libs[e]);else{const o=this.overrides[e];this[e]=this.buildUrl(o.cdn,o.lib||"",o.version||"")}else this[e]=this.buildUrl(this.baseUrl,e,this.libs[e])}}t.defaultCDN="https://cdn.form.io",o.default=t},96517:function(e,o,t){Object.defineProperty(o,"__esModule",{value:!0}),o.Formio=o.embed=void 0;const s=t(95413);Object.defineProperty(o,"Formio",{enumerable:!0,get:function(){return s.Formio}}),o.embed=function(e={}){const o=document.getElementsByTagName("script");e=Object.assign({},window.FormioConfig||{},e);let t=null,i=o.length;const r=e.scriptName||"formio.embed.";for(;i--;)if(o[i].src&&-1!==o[i].src.indexOf(r)){t=o[i];break}if(t){const o={};t.src.replace(/^[^?]+\??/,"").replace(/\?/g,"&").split("&").forEach((e=>{o[e.split("=")[0]]=e.split("=")[1]&&decodeURIComponent(e.split("=")[1])}));let i=t.src.replace(/^([^?]+).*/,"$1").split("/");i.pop();let r="";["js","offline"].includes(i[i.length-1])?(i.pop(),i=r=i.join("/"),i+="/js"):i=i.join("/");const n="true"===o.debug||"1"===o.debug,a=n?"formio.form":"formio.form.min";s.Formio.config=Object.assign({script:o.script||`${i}/${a}.js`,style:o.styles||`${i}/${a}.css`,cdn:o.cdn||r,class:o.class||"formio-form-wrapper",src:o.src,form:null,submission:null,project:o.project,base:o.base||"https://api.form.io",submit:o.submit,includeLibs:"true"===o.libs||"1"===o.libs,noshadow:"false"===o.shadow||"0"===o.shadow,template:o.template||"bootstrap",debug:n,config:{},redirect:o.return||o.redirect,embedCSS:`${i}/formio.embed.css`,success:o.success||"Thank you for your submission!",before:null,after:null},e),s.Formio.config.alter&&s.Formio.config.alter(s.Formio.config);const c=s.Formio.config.form||s.Formio.config.src;if(c){s.Formio.debug("Embedding Configuration",e),s.Formio.config.id=`formio-${Math.random().toString(36).substring(7)}`,s.Formio.debug("Creating form element");const o=s.Formio.createElement("div",{id:s.Formio.config.id,class:s.Formio.config.class});t.parentNode.insertBefore(o,t.parentNode.firstElementChild.nextSibling),s.Formio.createForm(o,c,s.Formio.config.config).then((e=>{s.Formio.config.submit&&(e.nosubmit=!0),e.on("submitDone",(o=>s.Formio.submitDone(e,o))),e.on("submit",(o=>{if(s.Formio.debug("on('submit')",o),s.Formio.config.submit){s.Formio.debug(`Sending submission to ${s.Formio.config.submit}`);const t={"content-type":"application/json"},i=s.Formio.FormioClass.getToken();i&&(t["x-jwt-token"]=i),s.Formio.FormioClass.fetch(s.Formio.config.submit,{body:JSON.stringify(o),headers:t,method:"POST",mode:"cors"}).then((e=>e.json())).then((o=>{s.Formio.submitDone(e,o)}))}}))}))}}else document.write("<span>Could not locate the Embedded form.</span>")}},95413:function(e,o,t){var s,i=this&&this.__awaiter||function(e,o,t,s){return new(t||(t=Promise))((function(i,r){function n(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var o;e.done?i(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(n,a)}c((s=s.apply(e,o||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.FormBuilder=o.Form=o.Formio=void 0;const n=r(t(56036));class a{static setLicense(e,o=!1){s.license=e,!o&&s.FormioClass&&s.FormioClass.setLicense(e)}static setBaseUrl(e,o=!1){s.baseUrl=e,!o&&s.FormioClass&&s.FormioClass.setBaseUrl(e)}static setApiUrl(e,o=!1){s.baseUrl=e,!o&&s.FormioClass&&s.FormioClass.setApiUrl(e)}static setProjectUrl(e,o=!1){s.projectUrl=e,!o&&s.FormioClass&&s.FormioClass.setProjectUrl(e)}static setAppUrl(e,o=!1){s.projectUrl=e,!o&&s.FormioClass&&s.FormioClass.setAppUrl(e)}static setPathType(e,o=!1){s.pathType=e,!o&&s.FormioClass&&s.FormioClass.setPathType(e)}static debug(...e){s.config.debug&&console.log(...e)}static clearCache(){s.FormioClass&&s.FormioClass.clearCache()}static global(e,o=""){const t=window[e];return o&&t&&!t[o]?null:(s.debug(`Getting global ${e}`,t),t)}static use(e){s.FormioClass&&s.FormioClass.isRenderer?s.FormioClass.use(e):s.modules.push(e)}static createElement(e,o,t){const i=document.createElement(e);return o?(Object.keys(o).forEach((e=>{i.setAttribute(e,o[e])})),(t||[]).forEach((e=>{i.appendChild(s.createElement(e.tag,e.attrs,e.children))})),i):i}static addScript(e,o,t,r=""){return i(this,void 0,void 0,(function*(){if(!o)return Promise.resolve();if("string"!=typeof o&&o.length)return Promise.all(o.map((o=>s.addScript(e,o))));if(t&&s.global(t,r))return s.debug(`${t} already loaded.`),Promise.resolve(s.global(t));s.debug("Adding Script",o);try{e.appendChild(s.createElement("script",{src:o}))}catch(e){return s.debug(e),Promise.resolve()}return t?new Promise((e=>{s.debug(`Waiting to load ${t}`);const o=setInterval((()=>{s.global(t,r)&&(clearInterval(o),s.debug(`${t} loaded.`),e(s.global(t)))}),100)})):Promise.resolve()}))}static addStyles(e,o){return i(this,void 0,void 0,(function*(){o&&("string"!=typeof o&&o.length?o.forEach((o=>s.addStyles(e,o))):(s.debug("Adding Styles",o),e.appendChild(s.createElement("link",{rel:"stylesheet",href:o}))))}))}static submitDone(e,o){return i(this,void 0,void 0,(function*(){s.debug("Submision Complete",o),s.config.submitDone&&s.config.submitDone(o,e);const t=(s.config.success||"").toString();t&&"false"!==t.toLowerCase()&&e.element&&(e.element.innerHTML=`<div class="alert-success" role="alert">${t}</div>`);let i=s.config.redirect;if(!i&&e._form&&e._form.settings&&(e._form.settings.returnUrl||e._form.settings.redirect)&&(s.debug("Return url found in form configuration"),i=e._form.settings.returnUrl||e._form.settings.redirect),i){const t=e.formio?e.formio.formUrl:"",r=!!i.match(/\?/),n=0===i.indexOf(location.origin);i+=r?"&":"?",i+=`sub=${o._id}`,!n&&t&&(i+=`&form=${encodeURIComponent(t)}`),s.debug("Return URL",i),window.location.href=i,n&&window.location.reload()}}))}static formioScript(e,o){return o=o||s.config.includeBuilder,s.fullAdded||o?(s.fullAdded=!0,e.replace("formio.form","formio.full")):e}static addLibrary(e,o,t){return i(this,void 0,void 0,(function*(){if(o){if(o.dependencies)for(let t=0;t<o.dependencies.length;t++){const i=o.dependencies[t];yield s.addLibrary(e,s.config.libs[i],i)}if(o.css&&(yield s.addStyles(o.global?document.body:e,o.css)),o.js){const i=yield s.addScript(o.global?document.body:e,o.js,!!o.use&&t);if(o.use){s.debug(`Using ${t}`);const e=o.options||{};!e.license&&s.license&&(e.license=s.license),s.use("function"==typeof o.use?o.use(i):i,e)}}if(o.globalStyle){const e=s.createElement("style");e.type="text/css",e.innerHTML=o.globalStyle,document.body.appendChild(e)}}}))}static addLoader(e){return i(this,void 0,void 0,(function*(){e.appendChild(s.createElement("div",{class:"formio-loader"},[{tag:"div",attrs:{class:"loader-wrapper"},children:[{tag:"div",attrs:{class:"loader text-center"}}]}]))}))}static init(e,o={},t=!1){return i(this,void 0,void 0,(function*(){s.cdn=new n.default(s.config.cdn,s.config.cdnUrls||{}),s.config.libs=s.config.libs||{uswds:{dependencies:["fontawesome"],js:`${s.cdn.uswds}/uswds.min.js`,css:`${s.cdn.uswds}/uswds.min.css`,use:!0},fontawesome:{css:"https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css",globalStyle:"@font-face {\n font-family: 'FontAwesome';\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');\n font-weight: normal;\n font-style: normal;\n }"},bootstrap4:{dependencies:["fontawesome"],css:`${s.cdn.bootstrap4}/css/bootstrap.min.css`},bootstrap:{dependencies:["bootstrap-icons"],css:`${s.cdn.bootstrap}/css/bootstrap.min.css`},"bootstrap-icons":{css:"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css",globalStyle:'@font-face {\n font-display: block;\n font-family: "bootstrap-icons";\n src: url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6") format("woff2"),\n url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6") format("woff");\n }'}},["cerulean","cosmo","cyborg","darkly","flatly","journal","litera","lumen","lux","materia","minty","pulse","sandstone","simplex","sketchy","slate","solar","spacelab","superhero","united","yeti"].forEach((e=>{s.config.libs[e]={dependencies:["bootstrap-icons"],css:`${s.cdn.bootswatch}/dist/${e}/bootstrap.min.css`}}));const i=s.config.id||`formio-${Math.random().toString(36).substring(7)}`;let r=s.createElement("div",{id:`${i}-wrapper`});e.parentNode.insertBefore(r,e);const a=s.config.includeLibs&&!s.config.noshadow&&"function"==typeof r.attachShadow;a&&(r=r.attachShadow({mode:"open"}),o.shadowRoot=r),e.parentNode.removeChild(e),r.appendChild(e);const c=a?r:document.body;yield s.addStyles(c,s.config.embedCSS||`${s.cdn.js}/formio.embed.css`),s.addLoader(r);const l=s.config.full?"formio.full":"formio.form",d=s.config.debug?l:`${l}.min`;if(s.FormioClass=yield s.addScript(c,s.formioScript(s.config.script||`${s.cdn.js}/${d}.js`,t),"Formio",t?"isBuilder":"isRenderer"),s.FormioClass.cdn=s.cdn,s.FormioClass.setBaseUrl(o.baseUrl||s.baseUrl||s.config.base),s.FormioClass.setProjectUrl(o.projectUrl||s.projectUrl||s.config.project),s.FormioClass.language=s.language,s.setLicense(s.license||s.config.license||!1),s.modules.forEach((e=>{s.FormioClass.use(e)})),s.icons&&(s.FormioClass.icons=s.icons),s.pathType&&s.FormioClass.setPathType(s.pathType),s.config.template&&s.config.includeLibs&&(yield s.addLibrary(c,s.config.libs[s.config.template],s.config.template)),s.config.libraries||(s.config.libraries=s.config.modules||{}),s.config.premium&&(s.config.libraries.premium=s.config.premium),s.config.libraries)for(const e in s.config.libraries){const o=s.config.libraries[e];o.use=o.use||!0,yield s.addLibrary(c,o,e)}return yield s.addStyles(c,s.formioScript(s.config.style||`${s.cdn.js}/${d}.css`,t)),s.config.before&&(yield s.config.before(s.FormioClass,e,s.config)),s.FormioClass.license=!0,s._formioReady(s.FormioClass),r}))}static afterCreate(e,o,t){return i(this,void 0,void 0,(function*(){const i=o.querySelector(".formio-loader");return i&&o.removeChild(i),s.FormioClass.events.emit(t,e),s.config.after&&(s.debug("Calling ready callback"),s.config.after(e,s.config)),e}))}static createForm(e,o,t={}){return i(this,void 0,void 0,(function*(){if(s.FormioClass)return s.FormioClass.createForm(e,o,Object.assign(Object.assign({},t),{noLoader:!0}));const i=yield s.init(e,t);return s.FormioClass.createForm(e,o,Object.assign(Object.assign({},t),{noLoader:!0})).then((e=>(s.config.submission&&(s.debug("Setting submission",s.config.submission),e.submission=s.config.submission),s.afterCreate(e,i,"formEmbedded"),e)))}))}static builder(e,o,t={}){var r;return i(this,void 0,void 0,(function*(){if(null===(r=s.FormioClass)||void 0===r?void 0:r.builder)return s.FormioClass.builder(e,o,t);const i=yield s.init(e,t,!0);return s.FormioClass.builder(e,o,t).then((e=>(s.afterCreate(e,i,"builderEmbedded"),e)))}))}}o.Formio=a,s=a,a.FormioClass=null,a.config={},a.modules=[],a.icons="",a.license="",a.formioReady=new Promise(((e,o)=>{s._formioReady=e,s._formioReadyReject=o})),a.version="5.1.2-rc.5",a.Report={create:(e,o,t={})=>i(void 0,void 0,void 0,(function*(){var i;if(null===(i=s.FormioClass)||void 0===i?void 0:i.Report)return s.FormioClass.Report.create(e,o,t);const r=yield s.init(e,t,!0);return s.FormioClass.Report.create(e,o,t).then((e=>(s.afterCreate(e,r,"reportEmbedded"),e)))}))},n.default.defaultCDN=a.version.includes("rc")?"https://cdn.test-form.io":"https://cdn.form.io";class c{constructor(e,o,t){this.form=o,this.element=e,this.options=t||{},this.init(),this.instance={proxy:!0,ready:this.ready,destroy:()=>{}}}init(){this.instance&&!this.instance.proxy&&this.instance.destroy(),this.element.innerHTML="",this.ready=this.create().then((e=>(this.instance=e,this.form=e.form,e)))}create(){return a.createForm(this.element,this.form,this.options)}setForm(e){this.form=e,this.instance&&this.instance.setForm(e)}setDisplay(e){return this.instance.proxy||(this.form.display=e,this.instance.destroy(),this.ready=this.create().then((e=>{this.instance=e,this.setForm(this.form)}))),this.ready}}o.Form=c;class l extends c{create(){return a.builder(this.element,this.form,this.options)}}o.FormBuilder=l,a.Form=c,a.FormBuilder=l}},o={};function t(s){var i=o[s];if(void 0!==i)return i.exports;var r=o[s]={exports:{}};return e[s].call(r.exports,r,r.exports,t),r.exports}var s={};return function(){var e=s;e.Formio=void 0,(0,t(96517).embed)();var o=t(96517);Object.defineProperty(e,"Formio",{enumerable:!0,get:function(){return o.Formio}})}(),s.Formio}()}));
|
2
|
+
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.Formio=o():e.Formio=o()}(self,(function(){return function(){"use strict";var e={56036:function(e,o){Object.defineProperty(o,"__esModule",{value:!0});class t{constructor(e,o={}){this.baseUrl=e||t.defaultCDN,this.overrides=o,this.libs={js:"",ace:"1.4.12",bootstrap:"5.3.3",bootstrap4:"4.6.2",bootstrap5:"5.3.3",bootswatch:"5.3.3","bootstrap-icons":"1.11.1",ckeditor:"19.0.0",flatpickr:"4.6.8","flatpickr-formio":"4.6.13-formio.3","font-awesome":"4.7.0",grid:"latest","moment-timezone":"latest",quill:"2.0.0-dev.3","shortcut-buttons-flatpickr":"0.4.0",uswds:"2.4.8",core:""},this.updateUrls()}getVersion(e){return this.libs[e]}setVersion(e,o){this.libs[e]=o,this.updateUrls()}setBaseUrl(e){this.baseUrl=e,this.updateUrls()}setOverrideUrl(e,o){this.overrides[e]=o,this.updateUrls()}removeOverride(e){delete this.overrides[e],this.updateUrls()}removeOverrides(){this.overrides={},this.updateUrls()}buildUrl(e,o,t){let s=e;return o&&(s+=`/${o}`),e.match(/cdn\.(test-)?form.io/)&&t&&"latest"!==t&&(s+=`/${t}`),s}updateUrls(){for(const e in this.libs)if(e in this.overrides)if("string"==typeof this.overrides[e])this[e]=this.buildUrl(this.overrides[e],e,this.libs[e]);else{const o=this.overrides[e];this[e]=this.buildUrl(o.cdn,o.lib||"",o.version||"")}else this[e]=this.buildUrl(this.baseUrl,e,this.libs[e])}}t.defaultCDN="https://cdn.form.io",o.default=t},96517:function(e,o,t){Object.defineProperty(o,"__esModule",{value:!0}),o.Formio=o.embed=void 0;const s=t(95413);Object.defineProperty(o,"Formio",{enumerable:!0,get:function(){return s.Formio}}),o.embed=function(e={}){const o=document.getElementsByTagName("script");e=Object.assign({},window.FormioConfig||{},e);let t=null,i=o.length;const r=e.scriptName||"formio.embed.";for(;i--;)if(o[i].src&&-1!==o[i].src.indexOf(r)){t=o[i];break}if(t){const o={};t.src.replace(/^[^?]+\??/,"").replace(/\?/g,"&").split("&").forEach((e=>{o[e.split("=")[0]]=e.split("=")[1]&&decodeURIComponent(e.split("=")[1])}));let i=t.src.replace(/^([^?]+).*/,"$1").split("/");i.pop();let r="";["js","offline"].includes(i[i.length-1])?(i.pop(),i=r=i.join("/"),i+="/js"):i=i.join("/");const n="true"===o.debug||"1"===o.debug,a=n?"formio.form":"formio.form.min";s.Formio.config=Object.assign({script:o.script||`${i}/${a}.js`,style:o.styles||`${i}/${a}.css`,cdn:o.cdn||r,class:o.class||"formio-form-wrapper",src:o.src,form:null,submission:null,project:o.project,base:o.base||"https://api.form.io",submit:o.submit,includeLibs:"true"===o.libs||"1"===o.libs,noshadow:"false"===o.shadow||"0"===o.shadow,template:o.template||"bootstrap",debug:n,config:{},redirect:o.return||o.redirect,embedCSS:`${i}/formio.embed.css`,success:o.success||"Thank you for your submission!",before:null,after:null},e),s.Formio.config.alter&&s.Formio.config.alter(s.Formio.config);const c=s.Formio.config.form||s.Formio.config.src;if(c){s.Formio.debug("Embedding Configuration",e),s.Formio.config.id=`formio-${Math.random().toString(36).substring(7)}`,s.Formio.debug("Creating form element");const o=s.Formio.createElement("div",{id:s.Formio.config.id,class:s.Formio.config.class});t.parentNode.insertBefore(o,t.parentNode.firstElementChild.nextSibling),s.Formio.createForm(o,c,s.Formio.config.config).then((e=>{s.Formio.config.submit&&(e.nosubmit=!0),e.on("submitDone",(o=>s.Formio.submitDone(e,o))),e.on("submit",(o=>{if(s.Formio.debug("on('submit')",o),s.Formio.config.submit){s.Formio.debug(`Sending submission to ${s.Formio.config.submit}`);const t={"content-type":"application/json"},i=s.Formio.FormioClass.getToken();i&&(t["x-jwt-token"]=i),s.Formio.FormioClass.fetch(s.Formio.config.submit,{body:JSON.stringify(o),headers:t,method:"POST",mode:"cors"}).then((e=>e.json())).then((o=>{s.Formio.submitDone(e,o)}))}}))}))}}else document.write("<span>Could not locate the Embedded form.</span>")}},95413:function(e,o,t){var s,i=this&&this.__awaiter||function(e,o,t,s){return new(t||(t=Promise))((function(i,r){function n(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var o;e.done?i(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(n,a)}c((s=s.apply(e,o||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.FormBuilder=o.Form=o.Formio=void 0;const n=r(t(56036));class a{static setLicense(e,o=!1){s.license=e,!o&&s.FormioClass&&s.FormioClass.setLicense(e)}static setBaseUrl(e,o=!1){s.baseUrl=e,!o&&s.FormioClass&&s.FormioClass.setBaseUrl(e)}static setApiUrl(e,o=!1){s.baseUrl=e,!o&&s.FormioClass&&s.FormioClass.setApiUrl(e)}static setProjectUrl(e,o=!1){s.projectUrl=e,!o&&s.FormioClass&&s.FormioClass.setProjectUrl(e)}static setAppUrl(e,o=!1){s.projectUrl=e,!o&&s.FormioClass&&s.FormioClass.setAppUrl(e)}static setPathType(e,o=!1){s.pathType=e,!o&&s.FormioClass&&s.FormioClass.setPathType(e)}static debug(...e){s.config.debug&&console.log(...e)}static clearCache(){s.FormioClass&&s.FormioClass.clearCache()}static global(e,o=""){const t=window[e];return o&&t&&!t[o]?null:(s.debug(`Getting global ${e}`,t),t)}static use(e){s.FormioClass&&s.FormioClass.isRenderer?s.FormioClass.use(e):s.modules.push(e)}static createElement(e,o,t){const i=document.createElement(e);return o?(Object.keys(o).forEach((e=>{i.setAttribute(e,o[e])})),(t||[]).forEach((e=>{i.appendChild(s.createElement(e.tag,e.attrs,e.children))})),i):i}static addScript(e,o,t,r=""){return i(this,void 0,void 0,(function*(){if(!o)return Promise.resolve();if("string"!=typeof o&&o.length)return Promise.all(o.map((o=>s.addScript(e,o))));if(t&&s.global(t,r))return s.debug(`${t} already loaded.`),Promise.resolve(s.global(t));s.debug("Adding Script",o);try{e.appendChild(s.createElement("script",{src:o}))}catch(e){return s.debug(e),Promise.resolve()}return t?new Promise((e=>{s.debug(`Waiting to load ${t}`);const o=setInterval((()=>{s.global(t,r)&&(clearInterval(o),s.debug(`${t} loaded.`),e(s.global(t)))}),100)})):Promise.resolve()}))}static addStyles(e,o){return i(this,void 0,void 0,(function*(){o&&("string"!=typeof o&&o.length?o.forEach((o=>s.addStyles(e,o))):(s.debug("Adding Styles",o),e.appendChild(s.createElement("link",{rel:"stylesheet",href:o}))))}))}static submitDone(e,o){return i(this,void 0,void 0,(function*(){s.debug("Submision Complete",o),s.config.submitDone&&s.config.submitDone(o,e);const t=(s.config.success||"").toString();t&&"false"!==t.toLowerCase()&&e.element&&(e.element.innerHTML=`<div class="alert-success" role="alert">${t}</div>`);let i=s.config.redirect;if(!i&&e._form&&e._form.settings&&(e._form.settings.returnUrl||e._form.settings.redirect)&&(s.debug("Return url found in form configuration"),i=e._form.settings.returnUrl||e._form.settings.redirect),i){const t=e.formio?e.formio.formUrl:"",r=!!i.match(/\?/),n=0===i.indexOf(location.origin);i+=r?"&":"?",i+=`sub=${o._id}`,!n&&t&&(i+=`&form=${encodeURIComponent(t)}`),s.debug("Return URL",i),window.location.href=i,n&&window.location.reload()}}))}static formioScript(e,o){return o=o||s.config.includeBuilder,s.fullAdded||o?(s.fullAdded=!0,e.replace("formio.form","formio.full")):e}static addLibrary(e,o,t){return i(this,void 0,void 0,(function*(){if(o){if(o.dependencies)for(let t=0;t<o.dependencies.length;t++){const i=o.dependencies[t];yield s.addLibrary(e,s.config.libs[i],i)}if(o.css&&(yield s.addStyles(o.global?document.body:e,o.css)),o.js){const i=yield s.addScript(o.global?document.body:e,o.js,!!o.use&&t);if(o.use){s.debug(`Using ${t}`);const e=o.options||{};!e.license&&s.license&&(e.license=s.license),s.use("function"==typeof o.use?o.use(i):i,e)}}if(o.globalStyle){const e=s.createElement("style");e.type="text/css",e.innerHTML=o.globalStyle,document.body.appendChild(e)}}}))}static addLoader(e){return i(this,void 0,void 0,(function*(){e.appendChild(s.createElement("div",{class:"formio-loader"},[{tag:"div",attrs:{class:"loader-wrapper"},children:[{tag:"div",attrs:{class:"loader text-center"}}]}]))}))}static init(e,o={},t=!1){return i(this,void 0,void 0,(function*(){s.cdn=new n.default(s.config.cdn,s.config.cdnUrls||{}),s.config.libs=s.config.libs||{uswds:{dependencies:["fontawesome"],js:`${s.cdn.uswds}/uswds.min.js`,css:`${s.cdn.uswds}/uswds.min.css`,use:!0},fontawesome:{css:"https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css",globalStyle:"@font-face {\n font-family: 'FontAwesome';\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');\n font-weight: normal;\n font-style: normal;\n }"},bootstrap4:{dependencies:["fontawesome"],css:`${s.cdn.bootstrap4}/css/bootstrap.min.css`},bootstrap:{dependencies:["bootstrap-icons"],css:`${s.cdn.bootstrap}/css/bootstrap.min.css`},"bootstrap-icons":{css:"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css",globalStyle:'@font-face {\n font-display: block;\n font-family: "bootstrap-icons";\n src: url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6") format("woff2"),\n url("https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6") format("woff");\n }'}},["cerulean","cosmo","cyborg","darkly","flatly","journal","litera","lumen","lux","materia","minty","pulse","sandstone","simplex","sketchy","slate","solar","spacelab","superhero","united","yeti"].forEach((e=>{s.config.libs[e]={dependencies:["bootstrap-icons"],css:`${s.cdn.bootswatch}/dist/${e}/bootstrap.min.css`}}));const i=s.config.id||`formio-${Math.random().toString(36).substring(7)}`;let r=s.createElement("div",{id:`${i}-wrapper`});e.parentNode.insertBefore(r,e);const a=s.config.includeLibs&&!s.config.noshadow&&"function"==typeof r.attachShadow;a&&(r=r.attachShadow({mode:"open"}),o.shadowRoot=r),e.parentNode.removeChild(e),r.appendChild(e);const c=a?r:document.body;yield s.addStyles(c,s.config.embedCSS||`${s.cdn.js}/formio.embed.css`),s.addLoader(r);const l=s.config.full?"formio.full":"formio.form",d=s.config.debug?l:`${l}.min`;if(s.FormioClass=yield s.addScript(c,s.formioScript(s.config.script||`${s.cdn.js}/${d}.js`,t),"Formio",t?"isBuilder":"isRenderer"),s.FormioClass.cdn=s.cdn,s.FormioClass.setBaseUrl(o.baseUrl||s.baseUrl||s.config.base),s.FormioClass.setProjectUrl(o.projectUrl||s.projectUrl||s.config.project),s.FormioClass.language=s.language,s.setLicense(s.license||s.config.license||!1),s.modules.forEach((e=>{s.FormioClass.use(e)})),s.icons&&(s.FormioClass.icons=s.icons),s.pathType&&s.FormioClass.setPathType(s.pathType),s.config.template&&s.config.includeLibs&&(yield s.addLibrary(c,s.config.libs[s.config.template],s.config.template)),s.config.libraries||(s.config.libraries=s.config.modules||{}),s.config.premium&&(s.config.libraries.premium=s.config.premium),s.config.libraries)for(const e in s.config.libraries){const o=s.config.libraries[e];o.use=o.use||!0,yield s.addLibrary(c,o,e)}return yield s.addStyles(c,s.formioScript(s.config.style||`${s.cdn.js}/${d}.css`,t)),s.config.before&&(yield s.config.before(s.FormioClass,e,s.config)),s.FormioClass.license=!0,s._formioReady(s.FormioClass),r}))}static afterCreate(e,o,t){return i(this,void 0,void 0,(function*(){const i=o.querySelector(".formio-loader");return i&&o.removeChild(i),s.FormioClass.events.emit(t,e),s.config.after&&(s.debug("Calling ready callback"),s.config.after(e,s.config)),e}))}static createForm(e,o,t={}){return i(this,void 0,void 0,(function*(){if(s.FormioClass)return s.FormioClass.createForm(e,o,Object.assign(Object.assign({},t),{noLoader:!0}));const i=yield s.init(e,t);return s.FormioClass.createForm(e,o,Object.assign(Object.assign({},t),{noLoader:!0})).then((e=>(s.config.submission&&(s.debug("Setting submission",s.config.submission),e.submission=s.config.submission),s.afterCreate(e,i,"formEmbedded"),e)))}))}static builder(e,o,t={}){var r;return i(this,void 0,void 0,(function*(){if(null===(r=s.FormioClass)||void 0===r?void 0:r.builder)return s.FormioClass.builder(e,o,t);const i=yield s.init(e,t,!0);return s.FormioClass.builder(e,o,t).then((e=>(s.afterCreate(e,i,"builderEmbedded"),e)))}))}}o.Formio=a,s=a,a.FormioClass=null,a.config={},a.modules=[],a.icons="",a.license="",a.formioReady=new Promise(((e,o)=>{s._formioReady=e,s._formioReadyReject=o})),a.version="5.1.2",a.Report={create:(e,o,t={})=>i(void 0,void 0,void 0,(function*(){var i;if(null===(i=s.FormioClass)||void 0===i?void 0:i.Report)return s.FormioClass.Report.create(e,o,t);const r=yield s.init(e,t,!0);return s.FormioClass.Report.create(e,o,t).then((e=>(s.afterCreate(e,r,"reportEmbedded"),e)))}))},n.default.defaultCDN=a.version.includes("rc")?"https://cdn.test-form.io":"https://cdn.form.io";class c{constructor(e,o,t){this.form=o,this.element=e,this.options=t||{},this.init(),this.instance={proxy:!0,ready:this.ready,destroy:()=>{}}}init(){this.instance&&!this.instance.proxy&&this.instance.destroy(),this.element.innerHTML="",this.ready=this.create().then((e=>(this.instance=e,this.form=e.form,e)))}create(){return a.createForm(this.element,this.form,this.options)}setForm(e){this.form=e,this.instance&&this.instance.setForm(e)}setDisplay(e){return this.instance.proxy||(this.form.display=e,this.instance.destroy(),this.ready=this.create().then((e=>{this.instance=e,this.setForm(this.form)}))),this.ready}}o.Form=c;class l extends c{create(){return a.builder(this.element,this.form,this.options)}}o.FormBuilder=l,a.Form=c,a.FormBuilder=l}},o={};function t(s){var i=o[s];if(void 0!==i)return i.exports;var r=o[s]={exports:{}};return e[s].call(r.exports,r,r.exports,t),r.exports}var s={};return function(){var e=s;e.Formio=void 0,(0,t(96517).embed)();var o=t(96517);Object.defineProperty(e,"Formio",{enumerable:!0,get:function(){return o.Formio}})}(),s.Formio}()}));
|
@@ -1 +1 @@
|
|
1
|
-
/*! formiojs v5.1.2
|
1
|
+
/*! formiojs v5.1.2 | https://unpkg.com/formiojs@5.1.2/LICENSE.txt */
|
package/dist/formio.form.js
CHANGED
@@ -1685,7 +1685,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
1685
1685
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1686
1686
|
|
1687
1687
|
"use strict";
|
1688
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponentDataAsync = exports.eachComponentAsync = exports.eachComponentData = exports.eachComponent = exports.normalizeContext = exports.getComponentErrorField = exports.compareSelectResourceWithObjectTypeValues = exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.findComponents = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentValue = exports.getComponentData = exports.componentInfo = exports.shouldProcessComponent = exports.getComponentLocalData = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.getComponentFromPath = exports.getBestMatch = exports.componentMatches = exports.getStringFromComponentPath = exports.getComponentPaths = exports.componentPath = exports.resetComponentScope = exports.setComponentScope = exports.isComponentNestedDataType = exports.getModelType = exports.MODEL_TYPES_OF_KNOWN_COMPONENTS = exports.uniqueName = exports.guid = exports.flattenComponents = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst fast_json_patch_1 = __webpack_require__(/*! fast-json-patch */ \"./node_modules/fast-json-patch/index.mjs\");\nconst types_1 = __webpack_require__(/*! ../../types */ \"./node_modules/@formio/core/lib/types/index.js\");\nconst Evaluator_1 = __webpack_require__(/*! ../Evaluator */ \"./node_modules/@formio/core/lib/utils/Evaluator.js\");\nconst eachComponent_1 = __webpack_require__(/*! ./eachComponent */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponent.js\");\nObject.defineProperty(exports, \"eachComponent\", ({ enumerable: true, get: function () { return eachComponent_1.eachComponent; } }));\nconst eachComponentData_1 = __webpack_require__(/*! ./eachComponentData */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentData.js\");\nObject.defineProperty(exports, \"eachComponentData\", ({ enumerable: true, get: function () { return eachComponentData_1.eachComponentData; } }));\nconst eachComponentAsync_1 = __webpack_require__(/*! ./eachComponentAsync */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentAsync.js\");\nObject.defineProperty(exports, \"eachComponentAsync\", ({ enumerable: true, get: function () { return eachComponentAsync_1.eachComponentAsync; } }));\nconst eachComponentDataAsync_1 = __webpack_require__(/*! ./eachComponentDataAsync */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentDataAsync.js\");\nObject.defineProperty(exports, \"eachComponentDataAsync\", ({ enumerable: true, get: function () { return eachComponentDataAsync_1.eachComponentDataAsync; } }));\n/**\n * Flatten the form components for data manipulation.\n *\n * @param {Object} components\n * The components to iterate.\n * @param {Boolean} includeAll\n * Whether or not to include layout components.\n *\n * @returns {Object}\n * The flattened components map.\n */\nfunction flattenComponents(components, includeAll = false) {\n const flattened = {};\n (0, eachComponent_1.eachComponent)(components, (component, path) => {\n flattened[path] = component;\n }, includeAll);\n return flattened;\n}\nexports.flattenComponents = flattenComponents;\nfunction guid() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\nexports.guid = guid;\n/**\n * Make a filename guaranteed to be unique.\n * @param name\n * @param template\n * @param evalContext\n * @returns {string}\n */\nfunction uniqueName(name, template, evalContext) {\n template = template || '{{fileName}}-{{guid}}';\n //include guid in template anyway, to prevent overwriting issue if filename matches existing file\n if (!template.includes('{{guid}}')) {\n template = `${template}-{{guid}}`;\n }\n const parts = name.split('.');\n let fileName = parts.slice(0, parts.length - 1).join('.');\n const extension = parts.length > 1 ? `.${(0, lodash_1.last)(parts)}` : '';\n //allow only 100 characters from original name to avoid issues with filename length restrictions\n fileName = fileName.substr(0, 100);\n evalContext = Object.assign(evalContext || {}, {\n fileName,\n guid: guid(),\n });\n //only letters, numbers, dots, dashes, underscores and spaces are allowed. Anything else will be replaced with dash\n const uniqueName = `${Evaluator_1.Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\\-_ ]/g, '-');\n return uniqueName;\n}\nexports.uniqueName = uniqueName;\n/**\n * Defines model types for known components.\n * For now, these will be the only model types supported by the @formio/core library.\n *\n * nestedArray: for components that store their data as an array and have nested components.\n * nestedDataArray: for components that store their data as an array and have nested components, but keeps the value of nested components inside 'data' property.\n * array: for components that store their data as an array.\n * dataObject: for components that store their data in a nested { data: {} } object.\n * object: for components that store their data in an object.\n * map: for components that store their data in a map.\n * content: for components that do not store data.\n * string: for components that store their data as a string.\n * number: for components that store their data as a number.\n * boolean: for components that store their data as a boolean.\n * none: for components that do not store data and should not be included in the submission.\n * any: for components that can store any type of data.\n *\n */\nexports.MODEL_TYPES_OF_KNOWN_COMPONENTS = {\n nestedArray: ['datagrid', 'editgrid', 'datatable', 'dynamicWizard'],\n nestedDataArray: ['tagpad'],\n dataObject: ['form'],\n object: ['container', 'address'],\n map: ['datamap'],\n content: ['htmlelement', 'content'],\n string: [\n 'textfield',\n 'password',\n 'email',\n 'url',\n 'phoneNumber',\n 'day',\n 'datetime',\n 'time',\n 'signature',\n ],\n number: ['number', 'currency'],\n boolean: ['checkbox', 'radio'],\n none: ['table', 'well', 'columns', 'fieldset', 'panel', 'tabs'],\n any: [\n 'survey',\n 'captcha',\n 'textarea',\n 'selectboxes',\n 'tags',\n 'select',\n 'hidden',\n 'button',\n 'datasource',\n 'sketchpad',\n 'reviewpage',\n 'file',\n ],\n};\nfunction getModelType(component) {\n // If the component JSON asserts a model type, use that.\n if (component.modelType) {\n return component.modelType;\n }\n let modelType = 'any';\n // Otherwise, check for known component types.\n for (const type of Object.keys(exports.MODEL_TYPES_OF_KNOWN_COMPONENTS)) {\n if (exports.MODEL_TYPES_OF_KNOWN_COMPONENTS[type].includes(component.type)) {\n modelType = type;\n break;\n }\n }\n // Otherwise check for components that assert no value.\n if (modelType === 'any' && component.input === false) {\n modelType = 'none';\n }\n // To speed up performance of getModelType, we will set the modelType on the component as a non-enumerable property.\n Object.defineProperty(component, 'modelType', {\n enumerable: false,\n writable: true,\n value: modelType,\n });\n // Otherwise default to any.\n return modelType;\n}\nexports.getModelType = getModelType;\nfunction isComponentNestedDataType(component) {\n return (component.tree ||\n getModelType(component) === 'nestedArray' ||\n getModelType(component) === 'nestedDataArray' ||\n getModelType(component) === 'dataObject' ||\n getModelType(component) === 'object' ||\n getModelType(component) === 'map');\n}\nexports.isComponentNestedDataType = isComponentNestedDataType;\nfunction setComponentScope(component, name, value) {\n if (!component) {\n return;\n }\n if (!component.scope) {\n Object.defineProperty(component, 'scope', {\n enumerable: false,\n configurable: true,\n writable: true,\n value: {},\n });\n }\n Object.defineProperty(component.scope, name, {\n enumerable: false,\n writable: false,\n configurable: true,\n value,\n });\n}\nexports.setComponentScope = setComponentScope;\nfunction resetComponentScope(component) {\n if (component.scope) {\n delete component.scope;\n }\n}\nexports.resetComponentScope = resetComponentScope;\n/**\n * Return the component path provided the type of the component path.\n * @param component - The component JSON.\n * @param type - The type of path to return.\n * @returns\n */\nfunction componentPath(component, parent, parentPaths, type) {\n if (!component) {\n return '';\n }\n if (component.component) {\n component = component.component;\n }\n const compModel = getModelType(component);\n // Relative paths are only referenced from the current form.\n const relative = type === types_1.ComponentPath.localPath ||\n type === types_1.ComponentPath.fullLocalPath ||\n type === types_1.ComponentPath.localDataPath;\n // Full paths include all layout component ids in the path.\n const fullPath = type === types_1.ComponentPath.fullPath || type === types_1.ComponentPath.fullLocalPath;\n // See if this is a data path.\n const dataPath = type === types_1.ComponentPath.dataPath || type === types_1.ComponentPath.localDataPath;\n // Determine if this component should include its key.\n const includeKey = fullPath || (!!component.type && compModel !== 'none' && compModel !== 'content');\n // The key is provided if the component can have data or if we are fetching the full path.\n const key = includeKey ? getComponentKey(component) : '';\n if (!parent) {\n // Return the key if there is no parent.\n return key;\n }\n // Get the parent model type.\n const parentModel = getModelType(parent);\n // If there is a parent, then we only return the key if the parent is a nested form and it is a relative path.\n if (relative && parentModel === 'dataObject') {\n return key;\n }\n // Return the parent path.\n let parentPath = (parentPaths === null || parentPaths === void 0 ? void 0 : parentPaths.hasOwnProperty(type)) ? parentPaths[type] || '' : '';\n // For data paths (where we wish to get the path to the data), we need to ensure we append the parent\n // paths to the end of the path so that any component within this component properly references their data.\n if (dataPath && parentPath) {\n if (parentModel === 'nestedArray' || parentModel === 'nestedDataArray') {\n parentPath += `[${(parentPaths === null || parentPaths === void 0 ? void 0 : parentPaths.dataIndex) || 0}]`;\n }\n if (parentModel === 'dataObject' || parentModel === 'nestedDataArray') {\n parentPath += '.data';\n }\n }\n // Return the parent path with its relative component path (if applicable).\n return parentPath ? (key ? `${parentPath}.${key}` : parentPath) : key;\n}\nexports.componentPath = componentPath;\n/**\n * This method determines a components paths provided the component JSON, the parent and the parent paths.\n * @param component\n * @param parent\n * @param parentPaths\n * @returns\n */\nfunction getComponentPaths(component, parent, parentPaths) {\n return {\n path: componentPath(component, parent, parentPaths, types_1.ComponentPath.path),\n fullPath: componentPath(component, parent, parentPaths, types_1.ComponentPath.fullPath),\n localPath: componentPath(component, parent, parentPaths, types_1.ComponentPath.localPath),\n fullLocalPath: componentPath(component, parent, parentPaths, types_1.ComponentPath.fullLocalPath),\n dataPath: componentPath(component, parent, parentPaths, types_1.ComponentPath.dataPath),\n localDataPath: componentPath(component, parent, parentPaths, types_1.ComponentPath.localDataPath),\n dataIndex: parentPaths === null || parentPaths === void 0 ? void 0 : parentPaths.dataIndex,\n };\n}\nexports.getComponentPaths = getComponentPaths;\nfunction getStringFromComponentPath(path) {\n if (!(0, lodash_1.isArray)(path)) {\n return path;\n }\n let strPath = '';\n path.forEach((part, i) => {\n if ((0, lodash_1.isNumber)(part)) {\n strPath += `[${part}]`;\n }\n else {\n strPath += i === 0 ? part : `.${part}`;\n }\n });\n return strPath;\n}\nexports.getStringFromComponentPath = getStringFromComponentPath;\n/**\n * Determines if a component has a match at any of the path types.\n * @param component {Component} - The component JSON to check for matches.\n * @param paths {ComponentPaths} - The current component paths object.\n * @param path {string} - Either the \"form\" or \"data\" path to see if a match occurs.\n * @param dataIndex {number | undefined} - The data index for the current component to match.\n * @param matches {Record<string, ComponentMatch | undefined>} - The current matches object.\n * @param addMatch {(type: ComponentPath | 'key', match: ComponentMatch) => ComponentMatch} - A callback function to allow modules to decorate the match object.\n */\nfunction componentMatches(component, paths, path, dataIndex, matches = {\n path: undefined,\n fullPath: undefined,\n localPath: undefined,\n dataPath: undefined,\n localDataPath: undefined,\n fullLocalPath: undefined,\n key: undefined,\n}, addMatch = (type, match) => {\n return match;\n}) {\n let dataProperty = '';\n if (component.type === 'selectboxes') {\n const valuePath = new RegExp(`(\\\\.${(0, lodash_1.escapeRegExp)(component.key)})(\\\\.[^\\\\.]+)$`);\n const pathMatches = path.match(valuePath);\n if ((pathMatches === null || pathMatches === void 0 ? void 0 : pathMatches.length) === 3) {\n dataProperty = pathMatches[2];\n path = path.replace(valuePath, '$1');\n }\n }\n // Get the current model type.\n const modelType = getModelType(component);\n const dataModel = modelType !== 'none' && modelType !== 'content';\n [\n types_1.ComponentPath.path,\n types_1.ComponentPath.fullPath,\n types_1.ComponentPath.localPath,\n types_1.ComponentPath.fullLocalPath,\n types_1.ComponentPath.dataPath,\n types_1.ComponentPath.localDataPath,\n ].forEach((type) => {\n const dataPath = type === types_1.ComponentPath.dataPath || type === types_1.ComponentPath.localDataPath;\n if (paths[type] === path) {\n const currentMatch = matches[type];\n const currentModelType = (currentMatch === null || currentMatch === void 0 ? void 0 : currentMatch.component)\n ? getModelType(currentMatch.component)\n : 'none';\n const currentDataModel = currentModelType !== 'none' && currentModelType !== 'content';\n if (!currentMatch ||\n (dataPath && dataModel && currentDataModel) || // Replace the current match if this is a dataPath and both are dataModels.\n (!dataPath && dataIndex === paths.dataIndex) // Replace the current match if this is not a dataPath and the indexes are the same.\n ) {\n if (dataPath) {\n const dataPaths = {\n dataPath: paths.dataPath || '',\n localDataPath: paths.localDataPath || '',\n };\n if (dataProperty) {\n dataPaths.dataPath += dataProperty;\n dataPaths.localDataPath += dataProperty;\n }\n matches[type] = addMatch(type, {\n component,\n paths: Object.assign(Object.assign({}, paths), dataPaths),\n });\n }\n else {\n matches[type] = addMatch(type, { component, paths });\n }\n }\n }\n });\n if (!matches.key && component.key === path) {\n matches.key = addMatch('key', { component, paths });\n }\n}\nexports.componentMatches = componentMatches;\nfunction getBestMatch(matches) {\n if (matches.dataPath) {\n return matches.dataPath;\n }\n if (matches.localDataPath) {\n return matches.localDataPath;\n }\n if (matches.fullPath) {\n return matches.fullPath;\n }\n if (matches.path) {\n return matches.path;\n }\n if (matches.fullLocalPath) {\n return matches.fullLocalPath;\n }\n if (matches.localPath) {\n return matches.localPath;\n }\n if (matches.key) {\n return matches.key;\n }\n return undefined;\n}\nexports.getBestMatch = getBestMatch;\n/**\n * This method performs a fuzzy search for a component within a form provided a number of different\n * paths to search.\n */\nfunction getComponentFromPath(components, path, data, dataIndex, includeAll = false) {\n const matches = {\n path: undefined,\n fullPath: undefined,\n localPath: undefined,\n fullLocalPath: undefined,\n dataPath: undefined,\n localDataPath: undefined,\n key: undefined,\n };\n if (data) {\n (0, eachComponentData_1.eachComponentData)(components, data, (component, data, row, compPath, comps, index, parent, paths) => {\n componentMatches(component, paths || {}, path, dataIndex, matches);\n }, includeAll);\n }\n else {\n (0, eachComponent_1.eachComponent)(components, (component, compPath, componentComponents, compParent, paths) => {\n componentMatches(component, paths || {}, path, dataIndex, matches);\n }, includeAll);\n }\n return getBestMatch(matches);\n}\nexports.getComponentFromPath = getComponentFromPath;\n/**\n * Provided a component, this will return the \"data\" key for that component in the contextual data\n * object.\n *\n * @param component\n * @returns\n */\nfunction getComponentKey(component) {\n if (!component) {\n return '';\n }\n if (component.type === 'checkbox' &&\n component.inputType === 'radio' &&\n component.name) {\n return component.name;\n }\n return component.key;\n}\nexports.getComponentKey = getComponentKey;\nfunction getContextualRowPath(component, paths, local) {\n if (!paths) {\n return '';\n }\n const dataPath = local ? paths.localDataPath : paths.dataPath;\n return (dataPath === null || dataPath === void 0 ? void 0 : dataPath.replace(new RegExp(`.?${(0, lodash_1.escapeRegExp)(getComponentKey(component))}$`), '')) || '';\n}\nexports.getContextualRowPath = getContextualRowPath;\nfunction getContextualRowData(component, data, paths, local) {\n const rowPath = getContextualRowPath(component, paths, local);\n return rowPath ? (0, lodash_1.get)(data, rowPath, null) : data;\n}\nexports.getContextualRowData = getContextualRowData;\nfunction getComponentLocalData(paths, data, local) {\n var _a;\n if (local) {\n return data;\n }\n const parentPath = ((_a = paths.dataPath) === null || _a === void 0 ? void 0 : _a.replace(new RegExp(`.?${(0, lodash_1.escapeRegExp)(paths.localDataPath)}$`), '')) || '';\n return parentPath ? (0, lodash_1.get)(data, parentPath, null) : data;\n}\nexports.getComponentLocalData = getComponentLocalData;\nfunction shouldProcessComponent(comp, row, value) {\n var _a;\n if (getModelType(comp) === 'dataObject') {\n const noReferenceAttached = (value === null || value === void 0 ? void 0 : value._id) ? (0, lodash_1.isEmpty)(value.data) && !(0, lodash_1.has)(value, 'form') : false;\n const shouldBeCleared = (!comp.hasOwnProperty('clearOnHide') || comp.clearOnHide) &&\n (comp.hidden || ((_a = comp.scope) === null || _a === void 0 ? void 0 : _a.conditionallyHidden));\n const shouldSkipProcessingNestedFormData = noReferenceAttached || shouldBeCleared;\n if (shouldSkipProcessingNestedFormData) {\n return false;\n }\n }\n return true;\n}\nexports.shouldProcessComponent = shouldProcessComponent;\nfunction componentInfo(component) {\n const hasColumns = component.columns && Array.isArray(component.columns);\n const hasRows = component.rows && Array.isArray(component.rows);\n const hasComps = component.components && Array.isArray(component.components);\n const isContent = getModelType(component) === 'content';\n const isLayout = getModelType(component) === 'none';\n const isInput = !component.hasOwnProperty('input') || !!component.input;\n return {\n hasColumns,\n hasRows,\n hasComps,\n layout: hasColumns || hasRows || (hasComps && !isInput) || isLayout || isContent,\n iterable: hasColumns || hasRows || hasComps || isContent,\n };\n}\nexports.componentInfo = componentInfo;\n// Provided components, data, and a key, this will return the components data.\nfunction getComponentData(components, data, path) {\n const compData = { component: null, data: null };\n (0, eachComponentData_1.eachComponentData)(components, data, (component, data, row, compPath) => {\n if (compPath === path) {\n compData.component = component;\n compData.data = row;\n return true;\n }\n });\n return compData;\n}\nexports.getComponentData = getComponentData;\nfunction getComponentValue(form, data, path, dataIndex, local) {\n var _a, _b;\n const match = getComponentFromPath((form === null || form === void 0 ? void 0 : form.components) || [], path, data, dataIndex);\n if (!match) {\n // Fall back to get the value from the data object.\n return (0, lodash_1.get)(data, path, undefined);\n }\n if (local) {\n return ((_a = match === null || match === void 0 ? void 0 : match.paths) === null || _a === void 0 ? void 0 : _a.localDataPath) ? (0, lodash_1.get)(data, match.paths.localDataPath, undefined) : null;\n }\n return ((_b = match === null || match === void 0 ? void 0 : match.paths) === null || _b === void 0 ? void 0 : _b.dataPath) ? (0, lodash_1.get)(data, match.paths.dataPath, undefined) : null;\n}\nexports.getComponentValue = getComponentValue;\n/**\n * Determine if a component is a layout component or not.\n *\n * @param {Object} component\n * The component to check.\n *\n * @returns {Boolean}\n * Whether or not the component is a layout component.\n */\nfunction isLayoutComponent(component) {\n return Boolean((component.columns &&\n Array.isArray(component.columns)) ||\n (component.rows && Array.isArray(component.rows)) ||\n (component.components &&\n Array.isArray(component.components)));\n}\nexports.isLayoutComponent = isLayoutComponent;\n/**\n * Matches if a component matches the query.\n *\n * @param component\n * @param query\n * @return {boolean}\n */\nfunction matchComponent(component, query, paths) {\n if ((0, lodash_1.isString)(query)) {\n return component.key === query || (paths === null || paths === void 0 ? void 0 : paths.localPath) === query || (paths === null || paths === void 0 ? void 0 : paths.path) === query;\n }\n else {\n let matches = false;\n (0, lodash_1.forOwn)(query, (value, key) => {\n matches = (0, lodash_1.get)(component, key) === value;\n if (!matches) {\n return false;\n }\n });\n return matches;\n }\n}\nexports.matchComponent = matchComponent;\n/**\n * Get a component by its path.\n *\n * @param {Object} components - The components to iterate.\n * @param {String|Object} path - The key of the component to get, or a query of the component to search.\n * @param {boolean} includeAll - Whether or not to include layout components.\n * @returns {Component} - The component that matches the given key, or undefined if not found.\n */\nfunction getComponent(components, path, includeAll = true, dataIndex) {\n var _a;\n return (_a = getComponentFromPath(components, path, undefined, dataIndex, includeAll)) === null || _a === void 0 ? void 0 : _a.component;\n}\nexports.getComponent = getComponent;\n/**\n * Finds a component provided a query of properties of that component.\n *\n * @param components\n * @param query\n * @return {*}\n */\nfunction searchComponents(components, query) {\n const results = [];\n (0, eachComponent_1.eachComponent)(components, (component, compPath, components, parent, compPaths) => {\n if (matchComponent(component, query, compPaths)) {\n results.push(component);\n }\n }, true);\n return results;\n}\nexports.searchComponents = searchComponents;\n/**\n * Deprecated version of findComponents. Renamed to searchComponents.\n * @param {import('@formio/core').Component[]} components - The components to find components within.\n * @param {object} query - The query to use when searching for the components.\n * @returns {import('@formio/core').Component[]} - The result of the component that is found.\n */\nfunction findComponents(components, query) {\n console.warn('formio.js/utils findComponents is deprecated. Use searchComponents instead.');\n return searchComponents(components, query);\n}\nexports.findComponents = findComponents;\n/**\n * Remove a component by path.\n *\n * @param components\n * @param path\n */\nfunction removeComponent(components, path) {\n // @ts-expect-error - I'm not sure why we're using `pop` here if it's a string\n const index = path.pop();\n if (path.length !== 0) {\n components = (0, lodash_1.get)(components, path);\n }\n components.splice(index, 1);\n}\nexports.removeComponent = removeComponent;\n/**\n * Returns if this component has a conditional statement.\n *\n * @param component - The component JSON schema.\n *\n * @returns {boolean} - TRUE - This component has a conditional, FALSE - No conditional provided.\n */\nfunction hasCondition(component) {\n return Boolean(component.customConditional ||\n (component.conditional &&\n (component.conditional.when ||\n component.conditional.json ||\n (component.conditional.conjunction &&\n ((0, lodash_1.isBoolean)(component.conditional.show) ||\n component.conditional.show) &&\n !(0, lodash_1.isEmpty)(component.conditional.conditions)))));\n}\nexports.hasCondition = hasCondition;\n/**\n * Extension of standard #parseFloat(value) function, that also clears input string.\n *\n * @param {any} value\n * The value to parse.\n *\n * @returns {Number}\n * Parsed value.\n */\nfunction parseFloatExt(value) {\n return parseFloat((0, lodash_1.isString)(value) ? value.replace(/[^\\de.+-]/gi, '') : value);\n}\nexports.parseFloatExt = parseFloatExt;\n/**\n * Formats provided value in way how Currency component uses it.\n *\n * @param {any} value\n * The value to format.\n *\n * @returns {String}\n * Value formatted for Currency component.\n */\nfunction formatAsCurrency(value) {\n const parsedValue = parseFloatExt(value);\n if (isNaN(parsedValue)) {\n return '';\n }\n const parts = (0, lodash_1.round)(parsedValue, 2).toString().split('.');\n parts[0] = (0, lodash_1.chunk)(Array.from(parts[0]).reverse(), 3)\n .reverse()\n .map((part) => part.reverse().join(''))\n .join(',');\n parts[1] = (0, lodash_1.pad)(parts[1], 2, '0');\n return parts.join('.');\n}\nexports.formatAsCurrency = formatAsCurrency;\n/**\n * Escapes RegEx characters in provided String value.\n *\n * @param {String} value\n * String for escaping RegEx characters.\n * @returns {string}\n * String with escaped RegEx characters.\n */\nfunction escapeRegExCharacters(value) {\n return value.replace(/[-[\\]/{}()*+?.\\\\^$|]/g, '\\\\$&');\n}\nexports.escapeRegExCharacters = escapeRegExCharacters;\n/**\n * Get the value for a component key, in the given submission.\n *\n * @param {Object} submission\n * A submission object to search.\n * @param {String} key\n * A for components API key to search for.\n */\nfunction getValue(submission, key) {\n const search = (data) => {\n if ((0, lodash_1.isPlainObject)(data)) {\n if ((0, lodash_1.has)(data, key)) {\n return (0, lodash_1.get)(data, key);\n }\n let value = null;\n (0, lodash_1.forOwn)(data, (prop) => {\n const result = search(prop);\n if (!(0, lodash_1.isNil)(result)) {\n value = result;\n return false;\n }\n });\n return value;\n }\n else {\n return null;\n }\n };\n return search(submission.data);\n}\nexports.getValue = getValue;\n/**\n * Iterate over all components in a form and get string values for translation.\n * @param form\n */\nfunction getStrings(form) {\n const properties = [\n 'label',\n 'title',\n 'legend',\n 'tooltip',\n 'description',\n 'placeholder',\n 'prefix',\n 'suffix',\n 'errorLabel',\n 'content',\n 'html',\n ];\n const strings = [];\n (0, eachComponent_1.eachComponent)(form.components, (component) => {\n properties.forEach((property) => {\n if (component.hasOwnProperty(property) && component[property]) {\n strings.push({\n key: component.key,\n type: component.type,\n property,\n string: component[property],\n });\n }\n });\n if ((!component.dataSrc || component.dataSrc === 'values') &&\n component.hasOwnProperty('values') &&\n Array.isArray(component.values) &&\n component.values.length) {\n component.values.forEach((value, index) => {\n strings.push({\n key: component.key,\n property: `value[${index}].label`,\n string: component.values[index].label,\n });\n });\n }\n // Hard coded values from Day component\n if (component.type === 'day') {\n [\n 'day',\n 'month',\n 'year',\n 'Day',\n 'Month',\n 'Year',\n 'january',\n 'february',\n 'march',\n 'april',\n 'may',\n 'june',\n 'july',\n 'august',\n 'september',\n 'october',\n 'november',\n 'december',\n ].forEach((string) => {\n strings.push({\n key: component.key,\n property: 'day',\n string,\n });\n });\n if (component.fields.day.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.day.placeholder',\n string: component.fields.day.placeholder,\n });\n }\n if (component.fields.month.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.month.placeholder',\n string: component.fields.month.placeholder,\n });\n }\n if (component.fields.year.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.year.placeholder',\n string: component.fields.year.placeholder,\n });\n }\n }\n if (component.type === 'editgrid') {\n const string = component.addAnother || 'Add Another';\n if (component.addAnother) {\n strings.push({\n key: component.key,\n property: 'addAnother',\n string,\n });\n }\n }\n if (component.type === 'select') {\n ['loading...', 'Type to search'].forEach((string) => {\n strings.push({\n key: component.key,\n property: 'select',\n string,\n });\n });\n }\n }, true);\n return strings;\n}\nexports.getStrings = getStrings;\n// ?????????????????????????\n// questionable section\nfunction generateFormChange(type, data) {\n let change;\n switch (type) {\n case 'add':\n change = {\n op: 'add',\n key: data.component.key,\n container: data.parent.key, // Parent component\n path: data.path, // Path to container within parent component.\n index: data.index, // Index of component in parent container.\n component: data.component,\n };\n break;\n case 'edit':\n change = {\n op: 'edit',\n key: data.originalComponent.key,\n patches: (0, fast_json_patch_1.compare)(data.originalComponent, data.component),\n };\n // Don't save if nothing changed.\n if (!change.patches.length) {\n change = null;\n }\n break;\n case 'remove':\n change = {\n op: 'remove',\n key: data.component.key,\n };\n break;\n }\n return change;\n}\nexports.generateFormChange = generateFormChange;\nfunction applyFormChanges(form, changes) {\n const failed = [];\n changes.forEach(function (change) {\n let found = false;\n switch (change.op) {\n case 'add': {\n let newComponent = change.component;\n // Find the container to set the component in.\n findComponent(form.components, change.container, null, function (parent) {\n if (!change.container) {\n parent = form;\n }\n // A move will first run an add so remove any existing components with matching key before inserting.\n findComponent(form.components, change.key, null, function (component, path) {\n // If found, use the existing component. (If someone else edited it, the changes would be here)\n newComponent = component;\n removeComponent(form.components, path);\n });\n found = true;\n const container = (0, lodash_1.get)(parent, change.path);\n container.splice(change.index, 0, newComponent);\n });\n break;\n }\n case 'remove':\n findComponent(form.components, change.key, null, function (component, path) {\n found = true;\n const oldComponent = (0, lodash_1.get)(form.components, path);\n if (oldComponent.key !== component.key) {\n path.pop();\n }\n removeComponent(form.components, path);\n });\n break;\n case 'edit':\n findComponent(form.components, change.key, null, function (component, path) {\n found = true;\n try {\n const oldComponent = (0, lodash_1.get)(form.components, path);\n const newComponent = (0, fast_json_patch_1.applyPatch)(component, change.patches).newDocument;\n if (oldComponent.key !== newComponent.key) {\n path.pop();\n }\n (0, lodash_1.set)(form.components, path, newComponent);\n }\n catch (ignoreErr) {\n failed.push(change);\n }\n });\n break;\n case 'move':\n break;\n }\n if (!found) {\n failed.push(change);\n }\n });\n return {\n form,\n failed,\n };\n}\nexports.applyFormChanges = applyFormChanges;\n/**\n * This function will find a component in a form and return the component AND THE PATH to the component in the form.\n * Path to the component is stored as an array of nested components and their indexes.The Path is being filled recursively\n * when you iterating through the nested structure.\n * If the component is not found the callback won't be called and function won't return anything.\n *\n * @param components\n * @param key\n * @param fn\n * @param path\n * @returns {*}\n */\nfunction findComponent(components, key, path, fn) {\n if (!components)\n return;\n path = path || [];\n if (!key) {\n return fn(components);\n }\n components.forEach(function (component, index) {\n const newPath = path.slice();\n // Add an index of the component it iterates through in nested structure\n newPath.push(index);\n if (!component)\n return;\n if (component.hasOwnProperty('columns') && Array.isArray(component.columns)) {\n newPath.push('columns');\n component.columns.forEach(function (column, index) {\n const colPath = newPath.slice();\n colPath.push(index);\n colPath.push('components');\n findComponent(column.components, key, colPath, fn);\n });\n }\n if (component.hasOwnProperty('rows') && Array.isArray(component.rows)) {\n newPath.push('rows');\n component.rows.forEach(function (row, index) {\n const rowPath = newPath.slice();\n rowPath.push(index);\n row.forEach(function (column, index) {\n const colPath = rowPath.slice();\n colPath.push(index);\n colPath.push('components');\n findComponent(column.components, key, colPath, fn);\n });\n });\n }\n if (component.hasOwnProperty('components') && Array.isArray(component.components)) {\n newPath.push('components');\n findComponent(component.components, key, newPath, fn);\n }\n if (component.key === key) {\n //Final callback if the component is found\n fn(component, newPath, components);\n }\n });\n}\nexports.findComponent = findComponent;\nconst isCheckboxComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'checkbox';\nconst isDataGridComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datagrid';\nconst isEditGridComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'editgrid';\nconst isAddressComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'address';\nconst isDataTableComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datatable';\nconst hasChildComponents = (component) => (component === null || component === void 0 ? void 0 : component.components) != null;\nconst isDateTimeComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datetime';\nconst isSelectBoxesComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'selectboxes';\nconst isTextAreaComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'textarea';\nconst isTextFieldComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'textfield';\nfunction getEmptyValue(component) {\n switch (component.type) {\n case 'textarea':\n case 'textfield':\n case 'time':\n case 'datetime':\n case 'day':\n return '';\n case 'datagrid':\n case 'editgrid':\n return [];\n default:\n return null;\n }\n}\nexports.getEmptyValue = getEmptyValue;\nconst replaceBlanks = (value) => {\n const nbsp = '<p> </p>';\n const br = '<p><br></p>';\n const brNbsp = '<p><br> </p>';\n const regExp = new RegExp(`^${nbsp}|${nbsp}$|^${br}|${br}$|^${brNbsp}|${brNbsp}$`, 'g');\n return typeof value === 'string' ? value.replace(regExp, '').trim() : value;\n};\nfunction trimBlanks(value) {\n if (!value) {\n return value;\n }\n if (Array.isArray(value)) {\n value = value.map((val) => replaceBlanks(val));\n }\n else {\n value = replaceBlanks(value);\n }\n return value;\n}\nfunction isValueEmpty(component, value) {\n const compValueIsEmptyArray = (0, lodash_1.isArray)(value) && value.length === 1 ? (0, lodash_1.isEqual)(value[0], getEmptyValue(component)) : false;\n return (value == null || value === '' || ((0, lodash_1.isArray)(value) && value.length === 0) || compValueIsEmptyArray);\n}\nfunction isComponentDataEmpty(component, data, path, valueCond) {\n var _a;\n const value = (0, lodash_1.isNil)(valueCond) ? (0, lodash_1.get)(data, path) : valueCond;\n const addressIgnoreProperties = ['mode', 'address'];\n if (isCheckboxComponent(component)) {\n return isValueEmpty(component, value) || value === false;\n }\n else if (isAddressComponent(component)) {\n if (Object.keys(value).length === 0) {\n return true;\n }\n return !Object.values((0, lodash_1.omit)(value, addressIgnoreProperties)).some(Boolean);\n }\n else if (isDataGridComponent(component) ||\n isEditGridComponent(component) ||\n isDataTableComponent(component) ||\n hasChildComponents(component)) {\n if ((_a = component.components) === null || _a === void 0 ? void 0 : _a.length) {\n let childrenEmpty = true;\n // wrap component in an array to let eachComponentData handle introspection to child components (e.g. this will be different\n // for data grids versus nested forms, etc.)\n (0, eachComponentData_1.eachComponentData)([component], data, (thisComponent, data, row, path) => {\n if (component.key === thisComponent.key)\n return;\n if (!isComponentDataEmpty(thisComponent, data, path)) {\n childrenEmpty = false;\n }\n });\n return isValueEmpty(component, value) || childrenEmpty;\n }\n return isValueEmpty(component, value);\n }\n else if (isDateTimeComponent(component)) {\n return isValueEmpty(component, value) || value.toString() === 'Invalid date';\n }\n else if (isSelectBoxesComponent(component)) {\n let selectBoxEmpty = true;\n for (const key in value) {\n if (value[key]) {\n selectBoxEmpty = false;\n break;\n }\n }\n return isValueEmpty(component, value) || selectBoxEmpty;\n }\n else if (isTextAreaComponent(component)) {\n const isPlain = !component.wysiwyg && !component.editor;\n return isPlain\n ? typeof value === 'string'\n ? isValueEmpty(component, value.trim())\n : isValueEmpty(component, value)\n : isValueEmpty(component, trimBlanks(value));\n }\n else if (isTextFieldComponent(component)) {\n if (component.allowMultipleMasks && !!component.inputMasks && !!component.inputMasks.length) {\n return (isValueEmpty(component, value) ||\n (component.multiple ? value.length === 0 : !value.maskName || !value.value));\n }\n return isValueEmpty(component, value === null || value === void 0 ? void 0 : value.toString().trim());\n }\n return isValueEmpty(component, value);\n}\nexports.isComponentDataEmpty = isComponentDataEmpty;\n/**\n * Returns the template keys inside the template code.\n * @param {string} template - The template to get the keys from.\n * @returns {Array<string>} - The keys inside the template.\n */\nfunction getItemTemplateKeys(template) {\n const templateKeys = [];\n if (!template) {\n return templateKeys;\n }\n const keys = template.match(/({{\\s*(.*?)\\s*}})/g);\n if (keys) {\n keys.forEach((key) => {\n const propKey = key.match(/{{\\s*item\\.(.*?)\\s*}}/);\n if (propKey && propKey.length > 1) {\n templateKeys.push(propKey[1]);\n }\n });\n }\n return templateKeys;\n}\nexports.getItemTemplateKeys = getItemTemplateKeys;\n/**\n * Returns if the component is a select resource with an object for its value.\n * @param {Component} comp - The component to check.\n * @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.\n */\nfunction isSelectResourceWithObjectValue(comp = {}) {\n const { reference, dataSrc, valueProperty } = comp;\n return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));\n}\nexports.isSelectResourceWithObjectValue = isSelectResourceWithObjectValue;\n/**\n * Compares real select resource value with expected value in condition.\n * @param {any} value - current value of selectcomponent.\n * @param {any} comparedValue - expocted value of select component.\n * @param {SelectComponent} conditionComponent - select component on which the condtion is based.\n * @returns {boolean} - TRUE if the select component current value is equal to the expected value; FALSE otherwise.\n */\nfunction compareSelectResourceWithObjectTypeValues(value, comparedValue, conditionComponent) {\n if (!value || !(0, lodash_1.isPlainObject)(value)) {\n return false;\n }\n const { template, valueProperty } = conditionComponent;\n if (valueProperty === 'data') {\n value = { data: value };\n comparedValue = { data: comparedValue };\n }\n return (0, lodash_1.every)(getItemTemplateKeys(template) || [], (k) => (0, lodash_1.isEqual)((0, lodash_1.get)(value, k), (0, lodash_1.get)(comparedValue, k)));\n}\nexports.compareSelectResourceWithObjectTypeValues = compareSelectResourceWithObjectTypeValues;\nfunction getComponentErrorField(component, context) {\n const toInterpolate = component.errorLabel || component.label || component.placeholder || component.key;\n return Evaluator_1.Evaluator.interpolate(toInterpolate, context);\n}\nexports.getComponentErrorField = getComponentErrorField;\nfunction normalizeContext(context) {\n const { data, paths, local } = context;\n return paths\n ? Object.assign(Object.assign({}, context), {\n path: paths.localDataPath,\n data: getComponentLocalData(paths, data, local),\n }) : context;\n}\nexports.normalizeContext = normalizeContext;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/formUtil/index.js?");
|
1688
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponentDataAsync = exports.eachComponentAsync = exports.eachComponentData = exports.eachComponent = exports.normalizeContext = exports.getComponentErrorField = exports.compareSelectResourceWithObjectTypeValues = exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.findComponents = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentValue = exports.getComponentData = exports.componentInfo = exports.shouldProcessComponent = exports.getComponentLocalData = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.getComponentFromPath = exports.getBestMatch = exports.componentMatches = exports.getStringFromComponentPath = exports.getComponentPaths = exports.componentPath = exports.resetComponentScope = exports.setComponentScope = exports.isComponentNestedDataType = exports.getModelType = exports.MODEL_TYPES_OF_KNOWN_COMPONENTS = exports.uniqueName = exports.guid = exports.flattenComponents = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst fast_json_patch_1 = __webpack_require__(/*! fast-json-patch */ \"./node_modules/fast-json-patch/index.mjs\");\nconst types_1 = __webpack_require__(/*! ../../types */ \"./node_modules/@formio/core/lib/types/index.js\");\nconst Evaluator_1 = __webpack_require__(/*! ../Evaluator */ \"./node_modules/@formio/core/lib/utils/Evaluator.js\");\nconst eachComponent_1 = __webpack_require__(/*! ./eachComponent */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponent.js\");\nObject.defineProperty(exports, \"eachComponent\", ({ enumerable: true, get: function () { return eachComponent_1.eachComponent; } }));\nconst eachComponentData_1 = __webpack_require__(/*! ./eachComponentData */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentData.js\");\nObject.defineProperty(exports, \"eachComponentData\", ({ enumerable: true, get: function () { return eachComponentData_1.eachComponentData; } }));\nconst eachComponentAsync_1 = __webpack_require__(/*! ./eachComponentAsync */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentAsync.js\");\nObject.defineProperty(exports, \"eachComponentAsync\", ({ enumerable: true, get: function () { return eachComponentAsync_1.eachComponentAsync; } }));\nconst eachComponentDataAsync_1 = __webpack_require__(/*! ./eachComponentDataAsync */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentDataAsync.js\");\nObject.defineProperty(exports, \"eachComponentDataAsync\", ({ enumerable: true, get: function () { return eachComponentDataAsync_1.eachComponentDataAsync; } }));\n/**\n * Flatten the form components for data manipulation.\n *\n * @param {Object} components\n * The components to iterate.\n * @param {Boolean} includeAll\n * Whether or not to include layout components.\n *\n * @returns {Object}\n * The flattened components map.\n */\nfunction flattenComponents(components, includeAll = false) {\n const flattened = {};\n (0, eachComponent_1.eachComponent)(components, (component, path) => {\n flattened[path] = component;\n }, includeAll);\n return flattened;\n}\nexports.flattenComponents = flattenComponents;\nfunction guid() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\nexports.guid = guid;\n/**\n * Make a filename guaranteed to be unique.\n * @param name\n * @param template\n * @param evalContext\n * @returns {string}\n */\nfunction uniqueName(name, template, evalContext) {\n template = template || '{{fileName}}-{{guid}}';\n //include guid in template anyway, to prevent overwriting issue if filename matches existing file\n if (!template.includes('{{guid}}')) {\n template = `${template}-{{guid}}`;\n }\n const parts = name.split('.');\n let fileName = parts.slice(0, parts.length - 1).join('.');\n const extension = parts.length > 1 ? `.${(0, lodash_1.last)(parts)}` : '';\n //allow only 100 characters from original name to avoid issues with filename length restrictions\n fileName = fileName.substr(0, 100);\n evalContext = Object.assign(evalContext || {}, {\n fileName,\n guid: guid(),\n });\n //only letters, numbers, dots, dashes, underscores and spaces are allowed. Anything else will be replaced with dash\n const uniqueName = `${Evaluator_1.Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\\-_ ]/g, '-');\n return uniqueName;\n}\nexports.uniqueName = uniqueName;\n/**\n * Defines model types for known components.\n * For now, these will be the only model types supported by the @formio/core library.\n *\n * nestedArray: for components that store their data as an array and have nested components.\n * nestedDataArray: for components that store their data as an array and have nested components, but keeps the value of nested components inside 'data' property.\n * array: for components that store their data as an array.\n * dataObject: for components that store their data in a nested { data: {} } object.\n * object: for components that store their data in an object.\n * map: for components that store their data in a map.\n * content: for components that do not store data.\n * string: for components that store their data as a string.\n * number: for components that store their data as a number.\n * boolean: for components that store their data as a boolean.\n * none: for components that do not store data and should not be included in the submission.\n * any: for components that can store any type of data.\n *\n */\nexports.MODEL_TYPES_OF_KNOWN_COMPONENTS = {\n nestedArray: ['datagrid', 'editgrid', 'datatable', 'dynamicWizard'],\n nestedDataArray: ['tagpad'],\n dataObject: ['form'],\n object: ['container', 'address'],\n map: ['datamap'],\n content: ['htmlelement', 'content'],\n string: [\n 'textfield',\n 'password',\n 'email',\n 'url',\n 'phoneNumber',\n 'day',\n 'datetime',\n 'time',\n 'signature',\n ],\n number: ['number', 'currency'],\n boolean: ['checkbox', 'radio'],\n none: ['table', 'well', 'columns', 'fieldset', 'panel', 'tabs'],\n any: [\n 'survey',\n 'captcha',\n 'textarea',\n 'selectboxes',\n 'tags',\n 'select',\n 'hidden',\n 'button',\n 'datasource',\n 'sketchpad',\n 'reviewpage',\n 'file',\n ],\n};\nfunction getModelType(component) {\n // If the component JSON asserts a model type, use that.\n if (component.modelType) {\n return component.modelType;\n }\n let modelType = 'any';\n // Otherwise, check for known component types.\n for (const type of Object.keys(exports.MODEL_TYPES_OF_KNOWN_COMPONENTS)) {\n if (exports.MODEL_TYPES_OF_KNOWN_COMPONENTS[type].includes(component.type)) {\n modelType = type;\n break;\n }\n }\n // Otherwise check for components that assert no value.\n if (modelType === 'any' && component.input === false) {\n modelType = 'none';\n }\n // To speed up performance of getModelType, we will set the modelType on the component as a non-enumerable property.\n Object.defineProperty(component, 'modelType', {\n enumerable: false,\n writable: true,\n value: modelType,\n });\n // Otherwise default to any.\n return modelType;\n}\nexports.getModelType = getModelType;\nfunction isComponentNestedDataType(component) {\n return (component.tree ||\n getModelType(component) === 'nestedArray' ||\n getModelType(component) === 'nestedDataArray' ||\n getModelType(component) === 'dataObject' ||\n getModelType(component) === 'object' ||\n getModelType(component) === 'map');\n}\nexports.isComponentNestedDataType = isComponentNestedDataType;\nfunction setComponentScope(component, name, value) {\n if (!component) {\n return;\n }\n if (!component.scope) {\n Object.defineProperty(component, 'scope', {\n enumerable: false,\n configurable: true,\n writable: true,\n value: {},\n });\n }\n Object.defineProperty(component.scope, name, {\n enumerable: false,\n writable: false,\n configurable: true,\n value,\n });\n}\nexports.setComponentScope = setComponentScope;\nfunction resetComponentScope(component) {\n if (component.scope) {\n delete component.scope;\n }\n}\nexports.resetComponentScope = resetComponentScope;\n/**\n * Return the component path provided the type of the component path.\n * @param component - The component JSON.\n * @param type - The type of path to return.\n * @returns\n */\nfunction componentPath(component, parent, parentPaths, type) {\n if (!component) {\n return '';\n }\n if (component.component) {\n component = component.component;\n }\n const compModel = getModelType(component);\n // Relative paths are only referenced from the current form.\n const relative = type === types_1.ComponentPath.localPath ||\n type === types_1.ComponentPath.fullLocalPath ||\n type === types_1.ComponentPath.localDataPath;\n // Full paths include all layout component ids in the path.\n const fullPath = type === types_1.ComponentPath.fullPath || type === types_1.ComponentPath.fullLocalPath;\n // See if this is a data path.\n const dataPath = type === types_1.ComponentPath.dataPath || type === types_1.ComponentPath.localDataPath;\n // Determine if this component should include its key.\n const includeKey = fullPath || (!!component.type && compModel !== 'none');\n // The key is provided if the component can have data or if we are fetching the full path.\n const key = includeKey ? getComponentKey(component) : '';\n if (!parent) {\n // Return the key if there is no parent.\n return key;\n }\n // Get the parent model type.\n const parentModel = getModelType(parent);\n // If there is a parent, then we only return the key if the parent is a nested form and it is a relative path.\n if (relative && parentModel === 'dataObject') {\n return key;\n }\n // Return the parent path.\n let parentPath = (parentPaths === null || parentPaths === void 0 ? void 0 : parentPaths.hasOwnProperty(type)) ? parentPaths[type] || '' : '';\n // For data paths (where we wish to get the path to the data), we need to ensure we append the parent\n // paths to the end of the path so that any component within this component properly references their data.\n if (dataPath && parentPath) {\n if (parentModel === 'nestedArray' || parentModel === 'nestedDataArray') {\n parentPath += `[${(parentPaths === null || parentPaths === void 0 ? void 0 : parentPaths.dataIndex) || 0}]`;\n }\n if (parentModel === 'dataObject' || parentModel === 'nestedDataArray') {\n parentPath += '.data';\n }\n }\n // Return the parent path with its relative component path (if applicable).\n return parentPath ? (key ? `${parentPath}.${key}` : parentPath) : key;\n}\nexports.componentPath = componentPath;\n/**\n * This method determines a components paths provided the component JSON, the parent and the parent paths.\n * @param component\n * @param parent\n * @param parentPaths\n * @returns\n */\nfunction getComponentPaths(component, parent, parentPaths) {\n return {\n path: componentPath(component, parent, parentPaths, types_1.ComponentPath.path),\n fullPath: componentPath(component, parent, parentPaths, types_1.ComponentPath.fullPath),\n localPath: componentPath(component, parent, parentPaths, types_1.ComponentPath.localPath),\n fullLocalPath: componentPath(component, parent, parentPaths, types_1.ComponentPath.fullLocalPath),\n dataPath: componentPath(component, parent, parentPaths, types_1.ComponentPath.dataPath),\n localDataPath: componentPath(component, parent, parentPaths, types_1.ComponentPath.localDataPath),\n dataIndex: parentPaths === null || parentPaths === void 0 ? void 0 : parentPaths.dataIndex,\n };\n}\nexports.getComponentPaths = getComponentPaths;\nfunction getStringFromComponentPath(path) {\n if (!(0, lodash_1.isArray)(path)) {\n return path;\n }\n let strPath = '';\n path.forEach((part, i) => {\n if ((0, lodash_1.isNumber)(part)) {\n strPath += `[${part}]`;\n }\n else {\n strPath += i === 0 ? part : `.${part}`;\n }\n });\n return strPath;\n}\nexports.getStringFromComponentPath = getStringFromComponentPath;\n/**\n * Determines if a component has a match at any of the path types.\n * @param component {Component} - The component JSON to check for matches.\n * @param paths {ComponentPaths} - The current component paths object.\n * @param path {string} - Either the \"form\" or \"data\" path to see if a match occurs.\n * @param dataIndex {number | undefined} - The data index for the current component to match.\n * @param matches {Record<string, ComponentMatch | undefined>} - The current matches object.\n * @param addMatch {(type: ComponentPath | 'key', match: ComponentMatch) => ComponentMatch} - A callback function to allow modules to decorate the match object.\n */\nfunction componentMatches(component, paths, path, dataIndex, matches = {\n path: undefined,\n fullPath: undefined,\n localPath: undefined,\n dataPath: undefined,\n localDataPath: undefined,\n fullLocalPath: undefined,\n key: undefined,\n}, addMatch = (type, match) => {\n return match;\n}) {\n let dataProperty = '';\n if (component.type === 'selectboxes') {\n const valuePath = new RegExp(`(\\\\.${(0, lodash_1.escapeRegExp)(component.key)})(\\\\.[^\\\\.]+)$`);\n const pathMatches = path.match(valuePath);\n if ((pathMatches === null || pathMatches === void 0 ? void 0 : pathMatches.length) === 3) {\n dataProperty = pathMatches[2];\n path = path.replace(valuePath, '$1');\n }\n }\n // Get the current model type.\n const modelType = getModelType(component);\n const dataModel = modelType !== 'none' && modelType !== 'content';\n [\n types_1.ComponentPath.path,\n types_1.ComponentPath.fullPath,\n types_1.ComponentPath.localPath,\n types_1.ComponentPath.fullLocalPath,\n types_1.ComponentPath.dataPath,\n types_1.ComponentPath.localDataPath,\n ].forEach((type) => {\n const dataPath = type === types_1.ComponentPath.dataPath || type === types_1.ComponentPath.localDataPath;\n if (paths[type] === path) {\n const currentMatch = matches[type];\n const currentModelType = (currentMatch === null || currentMatch === void 0 ? void 0 : currentMatch.component)\n ? getModelType(currentMatch.component)\n : 'none';\n const currentDataModel = currentModelType !== 'none' && currentModelType !== 'content';\n if (!currentMatch ||\n (dataPath && dataModel && currentDataModel) || // Replace the current match if this is a dataPath and both are dataModels.\n (!dataPath && dataIndex === paths.dataIndex) // Replace the current match if this is not a dataPath and the indexes are the same.\n ) {\n if (dataPath) {\n const dataPaths = {\n dataPath: paths.dataPath || '',\n localDataPath: paths.localDataPath || '',\n };\n if (dataProperty) {\n dataPaths.dataPath += dataProperty;\n dataPaths.localDataPath += dataProperty;\n }\n matches[type] = addMatch(type, {\n component,\n paths: Object.assign(Object.assign({}, paths), dataPaths),\n });\n }\n else {\n matches[type] = addMatch(type, { component, paths });\n }\n }\n }\n });\n if (!matches.key && component.key === path) {\n matches.key = addMatch('key', { component, paths });\n }\n}\nexports.componentMatches = componentMatches;\nfunction getBestMatch(matches) {\n if (matches.dataPath) {\n return matches.dataPath;\n }\n if (matches.localDataPath) {\n return matches.localDataPath;\n }\n if (matches.fullPath) {\n return matches.fullPath;\n }\n if (matches.path) {\n return matches.path;\n }\n if (matches.fullLocalPath) {\n return matches.fullLocalPath;\n }\n if (matches.localPath) {\n return matches.localPath;\n }\n if (matches.key) {\n return matches.key;\n }\n return undefined;\n}\nexports.getBestMatch = getBestMatch;\n/**\n * This method performs a fuzzy search for a component within a form provided a number of different\n * paths to search.\n */\nfunction getComponentFromPath(components, path, data, dataIndex, includeAll = false) {\n const matches = {\n path: undefined,\n fullPath: undefined,\n localPath: undefined,\n fullLocalPath: undefined,\n dataPath: undefined,\n localDataPath: undefined,\n key: undefined,\n };\n if (data) {\n (0, eachComponentData_1.eachComponentData)(components, data, (component, data, row, compPath, comps, index, parent, paths) => {\n componentMatches(component, paths || {}, path, dataIndex, matches);\n }, includeAll);\n }\n else {\n (0, eachComponent_1.eachComponent)(components, (component, compPath, componentComponents, compParent, paths) => {\n componentMatches(component, paths || {}, path, dataIndex, matches);\n }, includeAll);\n }\n return getBestMatch(matches);\n}\nexports.getComponentFromPath = getComponentFromPath;\n/**\n * Provided a component, this will return the \"data\" key for that component in the contextual data\n * object.\n *\n * @param component\n * @returns\n */\nfunction getComponentKey(component) {\n if (!component) {\n return '';\n }\n if (component.type === 'checkbox' &&\n component.inputType === 'radio' &&\n component.name) {\n return component.name;\n }\n return component.key;\n}\nexports.getComponentKey = getComponentKey;\nfunction getContextualRowPath(component, paths, local) {\n if (!paths) {\n return '';\n }\n const dataPath = local ? paths.localDataPath : paths.dataPath;\n return (dataPath === null || dataPath === void 0 ? void 0 : dataPath.replace(new RegExp(`.?${(0, lodash_1.escapeRegExp)(getComponentKey(component))}$`), '')) || '';\n}\nexports.getContextualRowPath = getContextualRowPath;\nfunction getContextualRowData(component, data, paths, local) {\n const rowPath = getContextualRowPath(component, paths, local);\n return rowPath ? (0, lodash_1.get)(data, rowPath, null) : data;\n}\nexports.getContextualRowData = getContextualRowData;\nfunction getComponentLocalData(paths, data, local) {\n var _a;\n if (local) {\n return data;\n }\n const parentPath = ((_a = paths.dataPath) === null || _a === void 0 ? void 0 : _a.replace(new RegExp(`.?${(0, lodash_1.escapeRegExp)(paths.localDataPath)}$`), '')) || '';\n return parentPath ? (0, lodash_1.get)(data, parentPath, null) : data;\n}\nexports.getComponentLocalData = getComponentLocalData;\nfunction shouldProcessComponent(comp, row, value) {\n var _a;\n if (getModelType(comp) === 'dataObject') {\n const noReferenceAttached = (value === null || value === void 0 ? void 0 : value._id) ? (0, lodash_1.isEmpty)(value.data) && !(0, lodash_1.has)(value, 'form') : false;\n const shouldBeCleared = (!comp.hasOwnProperty('clearOnHide') || comp.clearOnHide) &&\n (comp.hidden || ((_a = comp.scope) === null || _a === void 0 ? void 0 : _a.conditionallyHidden));\n const shouldSkipProcessingNestedFormData = noReferenceAttached || shouldBeCleared;\n if (shouldSkipProcessingNestedFormData) {\n return false;\n }\n }\n return true;\n}\nexports.shouldProcessComponent = shouldProcessComponent;\nfunction componentInfo(component) {\n const hasColumns = component.columns && Array.isArray(component.columns);\n const hasRows = component.rows && Array.isArray(component.rows);\n const hasComps = component.components && Array.isArray(component.components);\n const isContent = getModelType(component) === 'content';\n const isLayout = getModelType(component) === 'none';\n const isInput = !component.hasOwnProperty('input') || !!component.input;\n return {\n hasColumns,\n hasRows,\n hasComps,\n layout: hasColumns || hasRows || (hasComps && !isInput) || isLayout || isContent,\n iterable: hasColumns || hasRows || hasComps || isContent,\n };\n}\nexports.componentInfo = componentInfo;\n// Provided components, data, and a key, this will return the components data.\nfunction getComponentData(components, data, path) {\n const compData = { component: null, data: null };\n (0, eachComponentData_1.eachComponentData)(components, data, (component, data, row, compPath) => {\n if (compPath === path) {\n compData.component = component;\n compData.data = row;\n return true;\n }\n });\n return compData;\n}\nexports.getComponentData = getComponentData;\nfunction getComponentValue(form, data, path, dataIndex, local) {\n var _a, _b;\n const match = getComponentFromPath((form === null || form === void 0 ? void 0 : form.components) || [], path, data, dataIndex);\n if (!match) {\n // Fall back to get the value from the data object.\n return (0, lodash_1.get)(data, path, undefined);\n }\n if (local) {\n return ((_a = match === null || match === void 0 ? void 0 : match.paths) === null || _a === void 0 ? void 0 : _a.localDataPath) ? (0, lodash_1.get)(data, match.paths.localDataPath, undefined) : null;\n }\n return ((_b = match === null || match === void 0 ? void 0 : match.paths) === null || _b === void 0 ? void 0 : _b.dataPath) ? (0, lodash_1.get)(data, match.paths.dataPath, undefined) : null;\n}\nexports.getComponentValue = getComponentValue;\n/**\n * Determine if a component is a layout component or not.\n *\n * @param {Object} component\n * The component to check.\n *\n * @returns {Boolean}\n * Whether or not the component is a layout component.\n */\nfunction isLayoutComponent(component) {\n return Boolean((component.columns &&\n Array.isArray(component.columns)) ||\n (component.rows && Array.isArray(component.rows)) ||\n (component.components &&\n Array.isArray(component.components)));\n}\nexports.isLayoutComponent = isLayoutComponent;\n/**\n * Matches if a component matches the query.\n *\n * @param component\n * @param query\n * @return {boolean}\n */\nfunction matchComponent(component, query, paths) {\n if ((0, lodash_1.isString)(query)) {\n return component.key === query || (paths === null || paths === void 0 ? void 0 : paths.localPath) === query || (paths === null || paths === void 0 ? void 0 : paths.path) === query;\n }\n else {\n let matches = false;\n (0, lodash_1.forOwn)(query, (value, key) => {\n matches = (0, lodash_1.get)(component, key) === value;\n if (!matches) {\n return false;\n }\n });\n return matches;\n }\n}\nexports.matchComponent = matchComponent;\n/**\n * Get a component by its path.\n *\n * @param {Object} components - The components to iterate.\n * @param {String|Object} path - The key of the component to get, or a query of the component to search.\n * @param {boolean} includeAll - Whether or not to include layout components.\n * @returns {Component} - The component that matches the given key, or undefined if not found.\n */\nfunction getComponent(components, path, includeAll = true, dataIndex) {\n var _a;\n return (_a = getComponentFromPath(components, path, undefined, dataIndex, includeAll)) === null || _a === void 0 ? void 0 : _a.component;\n}\nexports.getComponent = getComponent;\n/**\n * Finds a component provided a query of properties of that component.\n *\n * @param components\n * @param query\n * @return {*}\n */\nfunction searchComponents(components, query) {\n const results = [];\n (0, eachComponent_1.eachComponent)(components, (component, compPath, components, parent, compPaths) => {\n if (matchComponent(component, query, compPaths)) {\n results.push(component);\n }\n }, true);\n return results;\n}\nexports.searchComponents = searchComponents;\n/**\n * Deprecated version of findComponents. Renamed to searchComponents.\n * @param {import('@formio/core').Component[]} components - The components to find components within.\n * @param {object} query - The query to use when searching for the components.\n * @returns {import('@formio/core').Component[]} - The result of the component that is found.\n */\nfunction findComponents(components, query) {\n console.warn('formio.js/utils findComponents is deprecated. Use searchComponents instead.');\n return searchComponents(components, query);\n}\nexports.findComponents = findComponents;\n/**\n * Remove a component by path.\n *\n * @param components\n * @param path\n */\nfunction removeComponent(components, path) {\n // @ts-expect-error - I'm not sure why we're using `pop` here if it's a string\n const index = path.pop();\n if (path.length !== 0) {\n components = (0, lodash_1.get)(components, path);\n }\n components.splice(index, 1);\n}\nexports.removeComponent = removeComponent;\n/**\n * Returns if this component has a conditional statement.\n *\n * @param component - The component JSON schema.\n *\n * @returns {boolean} - TRUE - This component has a conditional, FALSE - No conditional provided.\n */\nfunction hasCondition(component) {\n return Boolean(component.customConditional ||\n (component.conditional &&\n (component.conditional.when ||\n component.conditional.json ||\n (component.conditional.conjunction &&\n ((0, lodash_1.isBoolean)(component.conditional.show) ||\n component.conditional.show) &&\n !(0, lodash_1.isEmpty)(component.conditional.conditions)))));\n}\nexports.hasCondition = hasCondition;\n/**\n * Extension of standard #parseFloat(value) function, that also clears input string.\n *\n * @param {any} value\n * The value to parse.\n *\n * @returns {Number}\n * Parsed value.\n */\nfunction parseFloatExt(value) {\n return parseFloat((0, lodash_1.isString)(value) ? value.replace(/[^\\de.+-]/gi, '') : value);\n}\nexports.parseFloatExt = parseFloatExt;\n/**\n * Formats provided value in way how Currency component uses it.\n *\n * @param {any} value\n * The value to format.\n *\n * @returns {String}\n * Value formatted for Currency component.\n */\nfunction formatAsCurrency(value) {\n const parsedValue = parseFloatExt(value);\n if (isNaN(parsedValue)) {\n return '';\n }\n const parts = (0, lodash_1.round)(parsedValue, 2).toString().split('.');\n parts[0] = (0, lodash_1.chunk)(Array.from(parts[0]).reverse(), 3)\n .reverse()\n .map((part) => part.reverse().join(''))\n .join(',');\n parts[1] = (0, lodash_1.pad)(parts[1], 2, '0');\n return parts.join('.');\n}\nexports.formatAsCurrency = formatAsCurrency;\n/**\n * Escapes RegEx characters in provided String value.\n *\n * @param {String} value\n * String for escaping RegEx characters.\n * @returns {string}\n * String with escaped RegEx characters.\n */\nfunction escapeRegExCharacters(value) {\n return value.replace(/[-[\\]/{}()*+?.\\\\^$|]/g, '\\\\$&');\n}\nexports.escapeRegExCharacters = escapeRegExCharacters;\n/**\n * Get the value for a component key, in the given submission.\n *\n * @param {Object} submission\n * A submission object to search.\n * @param {String} key\n * A for components API key to search for.\n */\nfunction getValue(submission, key) {\n const search = (data) => {\n if ((0, lodash_1.isPlainObject)(data)) {\n if ((0, lodash_1.has)(data, key)) {\n return (0, lodash_1.get)(data, key);\n }\n let value = null;\n (0, lodash_1.forOwn)(data, (prop) => {\n const result = search(prop);\n if (!(0, lodash_1.isNil)(result)) {\n value = result;\n return false;\n }\n });\n return value;\n }\n else {\n return null;\n }\n };\n return search(submission.data);\n}\nexports.getValue = getValue;\n/**\n * Iterate over all components in a form and get string values for translation.\n * @param form\n */\nfunction getStrings(form) {\n const properties = [\n 'label',\n 'title',\n 'legend',\n 'tooltip',\n 'description',\n 'placeholder',\n 'prefix',\n 'suffix',\n 'errorLabel',\n 'content',\n 'html',\n ];\n const strings = [];\n (0, eachComponent_1.eachComponent)(form.components, (component) => {\n properties.forEach((property) => {\n if (component.hasOwnProperty(property) && component[property]) {\n strings.push({\n key: component.key,\n type: component.type,\n property,\n string: component[property],\n });\n }\n });\n if ((!component.dataSrc || component.dataSrc === 'values') &&\n component.hasOwnProperty('values') &&\n Array.isArray(component.values) &&\n component.values.length) {\n component.values.forEach((value, index) => {\n strings.push({\n key: component.key,\n property: `value[${index}].label`,\n string: component.values[index].label,\n });\n });\n }\n // Hard coded values from Day component\n if (component.type === 'day') {\n [\n 'day',\n 'month',\n 'year',\n 'Day',\n 'Month',\n 'Year',\n 'january',\n 'february',\n 'march',\n 'april',\n 'may',\n 'june',\n 'july',\n 'august',\n 'september',\n 'october',\n 'november',\n 'december',\n ].forEach((string) => {\n strings.push({\n key: component.key,\n property: 'day',\n string,\n });\n });\n if (component.fields.day.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.day.placeholder',\n string: component.fields.day.placeholder,\n });\n }\n if (component.fields.month.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.month.placeholder',\n string: component.fields.month.placeholder,\n });\n }\n if (component.fields.year.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.year.placeholder',\n string: component.fields.year.placeholder,\n });\n }\n }\n if (component.type === 'editgrid') {\n const string = component.addAnother || 'Add Another';\n if (component.addAnother) {\n strings.push({\n key: component.key,\n property: 'addAnother',\n string,\n });\n }\n }\n if (component.type === 'select') {\n ['loading...', 'Type to search'].forEach((string) => {\n strings.push({\n key: component.key,\n property: 'select',\n string,\n });\n });\n }\n }, true);\n return strings;\n}\nexports.getStrings = getStrings;\n// ?????????????????????????\n// questionable section\nfunction generateFormChange(type, data) {\n let change;\n switch (type) {\n case 'add':\n change = {\n op: 'add',\n key: data.component.key,\n container: data.parent.key, // Parent component\n path: data.path, // Path to container within parent component.\n index: data.index, // Index of component in parent container.\n component: data.component,\n };\n break;\n case 'edit':\n change = {\n op: 'edit',\n key: data.originalComponent.key,\n patches: (0, fast_json_patch_1.compare)(data.originalComponent, data.component),\n };\n // Don't save if nothing changed.\n if (!change.patches.length) {\n change = null;\n }\n break;\n case 'remove':\n change = {\n op: 'remove',\n key: data.component.key,\n };\n break;\n }\n return change;\n}\nexports.generateFormChange = generateFormChange;\nfunction applyFormChanges(form, changes) {\n const failed = [];\n changes.forEach(function (change) {\n let found = false;\n switch (change.op) {\n case 'add': {\n let newComponent = change.component;\n // Find the container to set the component in.\n findComponent(form.components, change.container, null, function (parent) {\n if (!change.container) {\n parent = form;\n }\n // A move will first run an add so remove any existing components with matching key before inserting.\n findComponent(form.components, change.key, null, function (component, path) {\n // If found, use the existing component. (If someone else edited it, the changes would be here)\n newComponent = component;\n removeComponent(form.components, path);\n });\n found = true;\n const container = (0, lodash_1.get)(parent, change.path);\n container.splice(change.index, 0, newComponent);\n });\n break;\n }\n case 'remove':\n findComponent(form.components, change.key, null, function (component, path) {\n found = true;\n const oldComponent = (0, lodash_1.get)(form.components, path);\n if (oldComponent.key !== component.key) {\n path.pop();\n }\n removeComponent(form.components, path);\n });\n break;\n case 'edit':\n findComponent(form.components, change.key, null, function (component, path) {\n found = true;\n try {\n const oldComponent = (0, lodash_1.get)(form.components, path);\n const newComponent = (0, fast_json_patch_1.applyPatch)(component, change.patches).newDocument;\n if (oldComponent.key !== newComponent.key) {\n path.pop();\n }\n (0, lodash_1.set)(form.components, path, newComponent);\n }\n catch (ignoreErr) {\n failed.push(change);\n }\n });\n break;\n case 'move':\n break;\n }\n if (!found) {\n failed.push(change);\n }\n });\n return {\n form,\n failed,\n };\n}\nexports.applyFormChanges = applyFormChanges;\n/**\n * This function will find a component in a form and return the component AND THE PATH to the component in the form.\n * Path to the component is stored as an array of nested components and their indexes.The Path is being filled recursively\n * when you iterating through the nested structure.\n * If the component is not found the callback won't be called and function won't return anything.\n *\n * @param components\n * @param key\n * @param fn\n * @param path\n * @returns {*}\n */\nfunction findComponent(components, key, path, fn) {\n if (!components)\n return;\n path = path || [];\n if (!key) {\n return fn(components);\n }\n components.forEach(function (component, index) {\n const newPath = path.slice();\n // Add an index of the component it iterates through in nested structure\n newPath.push(index);\n if (!component)\n return;\n if (component.hasOwnProperty('columns') && Array.isArray(component.columns)) {\n newPath.push('columns');\n component.columns.forEach(function (column, index) {\n const colPath = newPath.slice();\n colPath.push(index);\n colPath.push('components');\n findComponent(column.components, key, colPath, fn);\n });\n }\n if (component.hasOwnProperty('rows') && Array.isArray(component.rows)) {\n newPath.push('rows');\n component.rows.forEach(function (row, index) {\n const rowPath = newPath.slice();\n rowPath.push(index);\n row.forEach(function (column, index) {\n const colPath = rowPath.slice();\n colPath.push(index);\n colPath.push('components');\n findComponent(column.components, key, colPath, fn);\n });\n });\n }\n if (component.hasOwnProperty('components') && Array.isArray(component.components)) {\n newPath.push('components');\n findComponent(component.components, key, newPath, fn);\n }\n if (component.key === key) {\n //Final callback if the component is found\n fn(component, newPath, components);\n }\n });\n}\nexports.findComponent = findComponent;\nconst isCheckboxComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'checkbox';\nconst isDataGridComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datagrid';\nconst isEditGridComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'editgrid';\nconst isAddressComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'address';\nconst isDataTableComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datatable';\nconst hasChildComponents = (component) => (component === null || component === void 0 ? void 0 : component.components) != null;\nconst isDateTimeComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datetime';\nconst isSelectBoxesComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'selectboxes';\nconst isTextAreaComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'textarea';\nconst isTextFieldComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'textfield';\nfunction getEmptyValue(component) {\n switch (component.type) {\n case 'textarea':\n case 'textfield':\n case 'time':\n case 'datetime':\n case 'day':\n return '';\n case 'datagrid':\n case 'editgrid':\n return [];\n default:\n return null;\n }\n}\nexports.getEmptyValue = getEmptyValue;\nconst replaceBlanks = (value) => {\n const nbsp = '<p> </p>';\n const br = '<p><br></p>';\n const brNbsp = '<p><br> </p>';\n const regExp = new RegExp(`^${nbsp}|${nbsp}$|^${br}|${br}$|^${brNbsp}|${brNbsp}$`, 'g');\n return typeof value === 'string' ? value.replace(regExp, '').trim() : value;\n};\nfunction trimBlanks(value) {\n if (!value) {\n return value;\n }\n if (Array.isArray(value)) {\n value = value.map((val) => replaceBlanks(val));\n }\n else {\n value = replaceBlanks(value);\n }\n return value;\n}\nfunction isValueEmpty(component, value) {\n const compValueIsEmptyArray = (0, lodash_1.isArray)(value) && value.length === 1 ? (0, lodash_1.isEqual)(value[0], getEmptyValue(component)) : false;\n return (value == null || value === '' || ((0, lodash_1.isArray)(value) && value.length === 0) || compValueIsEmptyArray);\n}\nfunction isComponentDataEmpty(component, data, path, valueCond) {\n var _a;\n const value = (0, lodash_1.isNil)(valueCond) ? (0, lodash_1.get)(data, path) : valueCond;\n const addressIgnoreProperties = ['mode', 'address'];\n if (isCheckboxComponent(component)) {\n return isValueEmpty(component, value) || value === false;\n }\n else if (isAddressComponent(component)) {\n if (Object.keys(value).length === 0) {\n return true;\n }\n return !Object.values((0, lodash_1.omit)(value, addressIgnoreProperties)).some(Boolean);\n }\n else if (isDataGridComponent(component) ||\n isEditGridComponent(component) ||\n isDataTableComponent(component) ||\n hasChildComponents(component)) {\n if ((_a = component.components) === null || _a === void 0 ? void 0 : _a.length) {\n let childrenEmpty = true;\n // wrap component in an array to let eachComponentData handle introspection to child components (e.g. this will be different\n // for data grids versus nested forms, etc.)\n (0, eachComponentData_1.eachComponentData)([component], data, (thisComponent, data, row, path) => {\n if (component.key === thisComponent.key)\n return;\n if (!isComponentDataEmpty(thisComponent, data, path)) {\n childrenEmpty = false;\n }\n });\n return isValueEmpty(component, value) || childrenEmpty;\n }\n return isValueEmpty(component, value);\n }\n else if (isDateTimeComponent(component)) {\n return isValueEmpty(component, value) || value.toString() === 'Invalid date';\n }\n else if (isSelectBoxesComponent(component)) {\n let selectBoxEmpty = true;\n for (const key in value) {\n if (value[key]) {\n selectBoxEmpty = false;\n break;\n }\n }\n return isValueEmpty(component, value) || selectBoxEmpty;\n }\n else if (isTextAreaComponent(component)) {\n const isPlain = !component.wysiwyg && !component.editor;\n return isPlain\n ? typeof value === 'string'\n ? isValueEmpty(component, value.trim())\n : isValueEmpty(component, value)\n : isValueEmpty(component, trimBlanks(value));\n }\n else if (isTextFieldComponent(component)) {\n if (component.allowMultipleMasks && !!component.inputMasks && !!component.inputMasks.length) {\n return (isValueEmpty(component, value) ||\n (component.multiple ? value.length === 0 : !value.maskName || !value.value));\n }\n return isValueEmpty(component, value === null || value === void 0 ? void 0 : value.toString().trim());\n }\n return isValueEmpty(component, value);\n}\nexports.isComponentDataEmpty = isComponentDataEmpty;\n/**\n * Returns the template keys inside the template code.\n * @param {string} template - The template to get the keys from.\n * @returns {Array<string>} - The keys inside the template.\n */\nfunction getItemTemplateKeys(template) {\n const templateKeys = [];\n if (!template) {\n return templateKeys;\n }\n const keys = template.match(/({{\\s*(.*?)\\s*}})/g);\n if (keys) {\n keys.forEach((key) => {\n const propKey = key.match(/{{\\s*item\\.(.*?)\\s*}}/);\n if (propKey && propKey.length > 1) {\n templateKeys.push(propKey[1]);\n }\n });\n }\n return templateKeys;\n}\nexports.getItemTemplateKeys = getItemTemplateKeys;\n/**\n * Returns if the component is a select resource with an object for its value.\n * @param {Component} comp - The component to check.\n * @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.\n */\nfunction isSelectResourceWithObjectValue(comp = {}) {\n const { reference, dataSrc, valueProperty } = comp;\n return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));\n}\nexports.isSelectResourceWithObjectValue = isSelectResourceWithObjectValue;\n/**\n * Compares real select resource value with expected value in condition.\n * @param {any} value - current value of selectcomponent.\n * @param {any} comparedValue - expocted value of select component.\n * @param {SelectComponent} conditionComponent - select component on which the condtion is based.\n * @returns {boolean} - TRUE if the select component current value is equal to the expected value; FALSE otherwise.\n */\nfunction compareSelectResourceWithObjectTypeValues(value, comparedValue, conditionComponent) {\n if (!value || !(0, lodash_1.isPlainObject)(value)) {\n return false;\n }\n const { template, valueProperty } = conditionComponent;\n if (valueProperty === 'data') {\n value = { data: value };\n comparedValue = { data: comparedValue };\n }\n return (0, lodash_1.every)(getItemTemplateKeys(template) || [], (k) => (0, lodash_1.isEqual)((0, lodash_1.get)(value, k), (0, lodash_1.get)(comparedValue, k)));\n}\nexports.compareSelectResourceWithObjectTypeValues = compareSelectResourceWithObjectTypeValues;\nfunction getComponentErrorField(component, context) {\n const toInterpolate = component.errorLabel || component.label || component.placeholder || component.key;\n return Evaluator_1.Evaluator.interpolate(toInterpolate, context);\n}\nexports.getComponentErrorField = getComponentErrorField;\nfunction normalizeContext(context) {\n const { data, paths, local } = context;\n return paths\n ? Object.assign(Object.assign({}, context), {\n path: paths.localDataPath,\n data: getComponentLocalData(paths, data, local),\n }) : context;\n}\nexports.normalizeContext = normalizeContext;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/formUtil/index.js?");
|
1689
1689
|
|
1690
1690
|
/***/ }),
|
1691
1691
|
|
@@ -8916,7 +8916,7 @@ eval("\nvar parent = __webpack_require__(/*! ../../es/object/from-entries */ \".
|
|
8916
8916
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
8917
8917
|
|
8918
8918
|
"use strict";
|
8919
|
-
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 if (!attrs) {\n return element;\n }\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 if (_a.config.submitDone) {\n _a.config.submitDone(submission, instance);\n }\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(libWrapper, 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 const libName = lib.dependencies[i];\n yield _a.addLibrary(libWrapper, _a.config.libs[libName], libName);\n }\n }\n if (lib.css) {\n yield _a.addStyles((lib.global ? document.body : libWrapper), lib.css);\n }\n if (lib.js) {\n const module = yield _a.addScript((lib.global ? document.body : libWrapper), 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 if (lib.globalStyle) {\n const style = _a.createElement('style');\n style.type = 'text/css';\n style.innerHTML = lib.globalStyle;\n document.body.appendChild(style);\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 // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: `https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css`,\n globalStyle: `@font-face {\n font-family: 'FontAwesome';\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');\n font-weight: normal;\n font-style: normal;\n }`\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 // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: 'https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css',\n globalStyle: `@font-face {\n font-display: block;\n font-family: \"bootstrap-icons\";\n src: url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6\") format(\"woff2\"),\n url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6\") format(\"woff\");\n }`\n }\n };\n // Add all bootswatch templates.\n ['cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'litera', 'lumen', 'lux', 'materia', 'minty', 'pulse', 'sandstone', 'simplex', 'sketchy', 'slate', 'solar', 'spacelab', 'superhero', 'united', 'yeti'].forEach((template) => {\n _a.config.libs[template] = {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootswatch}/dist/${template}/bootstrap.min.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 && !_a.config.noshadow && (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 if (!_a.config.libraries) {\n _a.config.libraries = _a.config.modules || {};\n }\n // Adding premium if it is provided via the config.\n if (_a.config.premium) {\n _a.config.libraries.premium = _a.config.premium;\n }\n // Allow adding dynamic modules.\n if (_a.config.libraries) {\n for (const name in _a.config.libraries) {\n const lib = _a.config.libraries[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.1.2-rc.5';\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?");
|
8919
|
+
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 if (!attrs) {\n return element;\n }\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 if (_a.config.submitDone) {\n _a.config.submitDone(submission, instance);\n }\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(libWrapper, 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 const libName = lib.dependencies[i];\n yield _a.addLibrary(libWrapper, _a.config.libs[libName], libName);\n }\n }\n if (lib.css) {\n yield _a.addStyles((lib.global ? document.body : libWrapper), lib.css);\n }\n if (lib.js) {\n const module = yield _a.addScript((lib.global ? document.body : libWrapper), 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 if (lib.globalStyle) {\n const style = _a.createElement('style');\n style.type = 'text/css';\n style.innerHTML = lib.globalStyle;\n document.body.appendChild(style);\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 // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: `https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css`,\n globalStyle: `@font-face {\n font-family: 'FontAwesome';\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');\n font-weight: normal;\n font-style: normal;\n }`\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 // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: 'https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css',\n globalStyle: `@font-face {\n font-display: block;\n font-family: \"bootstrap-icons\";\n src: url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6\") format(\"woff2\"),\n url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6\") format(\"woff\");\n }`\n }\n };\n // Add all bootswatch templates.\n ['cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'litera', 'lumen', 'lux', 'materia', 'minty', 'pulse', 'sandstone', 'simplex', 'sketchy', 'slate', 'solar', 'spacelab', 'superhero', 'united', 'yeti'].forEach((template) => {\n _a.config.libs[template] = {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootswatch}/dist/${template}/bootstrap.min.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 && !_a.config.noshadow && (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 if (!_a.config.libraries) {\n _a.config.libraries = _a.config.modules || {};\n }\n // Adding premium if it is provided via the config.\n if (_a.config.premium) {\n _a.config.libraries.premium = _a.config.premium;\n }\n // Allow adding dynamic modules.\n if (_a.config.libraries) {\n for (const name in _a.config.libraries) {\n const lib = _a.config.libraries[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.1.2';\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?");
|
8920
8920
|
|
8921
8921
|
/***/ }),
|
8922
8922
|
|
@@ -8927,7 +8927,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
8927
8927
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
8928
8928
|
|
8929
8929
|
"use strict";
|
8930
|
-
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.1.2
|
8930
|
+
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.1.2';\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;\nsdk_1.Formio.addToGlobal = (global) => {\n if (typeof global === 'object' && !global.Formio) {\n global.Formio = sdk_1.Formio;\n }\n};\nif (typeof __webpack_require__.g !== 'undefined') {\n sdk_1.Formio.addToGlobal(__webpack_require__.g);\n}\nif (typeof window !== 'undefined') {\n sdk_1.Formio.addToGlobal(window);\n}\nEmbed_1.Formio._formioReady(sdk_1.Formio);\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Formio.js?");
|
8931
8931
|
|
8932
8932
|
/***/ }),
|
8933
8933
|
|