-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformio-loader.min.js
2 lines (2 loc) · 5.32 KB
/
formio-loader.min.js
1
2
!function(o,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.FormioLoader=e():o.FormioLoader=e()}(self,(()=>(()=>{var o={784:o=>{o.exports={buttonSettings:{showCancel:!1,showPrevious:!0,showNext:!0,showSubmit:!0},i18n:{en:{pattern:"Must use the format shown",error:'<h2><span class="fa fa-exclamation-triangle"></span> Please check your answers</h2>'}}}}},e={};function r(t){var i=e[t];if(void 0!==i)return i.exports;var n=e[t]={exports:{}};return o[t](n,n.exports,r),n.exports}r.n=o=>{var e=o&&o.__esModule?()=>o.default:()=>o;return r.d(e,{a:e}),e},r.d=(o,e)=>{for(var t in e)r.o(e,t)&&!r.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:e[t]})},r.o=(o,e)=>Object.prototype.hasOwnProperty.call(o,e),r.r=o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})};var t={};return(()=>{"use strict";r.r(t),r.d(t,{initFormio:()=>c,initFormioInstance:()=>a});var o=r(784),e=r.n(o);const i=o=>{window.dataLayer=window.dataLayer||[],window.dataLayer.push(o)},n=(o,e)=>{var r;if(null!=o&&o.formio){const e=document.querySelector('[data-formio-form-url="'.concat(o.formio.formUrl,'"]'));e&&(o.formio=JSON.parse(e.dataset.formio),o.opts.formio=o.formio),o.formio.options&&(o.opts.base=o.formio.options.base,o.opts.project=o.formio.options.project,o.opts.namespace=o.formio.options.namespace,o.formio.options.project&&Formio.setProjectUrl(o.formio.options.project),o.formio.options.base&&Formio.setBaseUrl(o.formio.options.base))}return null!=o&&null!==(r=o.url)&&void 0!==r&&r.includes("".concat(e.formio.base,"/recaptcha"))&&(o.url=o.url.replace("".concat(e.formio.base,"/recaptcha"),"".concat(e.formio.projectUrl,"/recaptcha"))),Promise.resolve(null)},a=(o,r)=>{if(o.dataset.formioFormUrl)return;if(!r.envUrl||!r.projectName||!r.formName)return void console.warn("Require envUrl, projectName, formName to initiate the form.",r);const t="https://".concat(r.envUrl.trim());let a="";a=r.formRevision?"".concat(r.formName,"/v/").concat(r.formRevision):r.formName;const{projectName:m}=r,c=r.namespace||"formio-".concat(m),s="".concat(t,"/").concat(m,"/").concat(a),f=new Formio(s,{base:t,project:"".concat(t,"/").concat(m),namespace:c});o.dataset.formio=JSON.stringify(f),o.dataset.formioFormUrl=s;const l={...e(),formio:f,namespace:f.options.namespace},p={...l,..."function"==typeof r.createFormOptions&&r.createFormOptions({...r,defaultOptions:l,elem:o})};Formio.getPlugin("requestPlugin")||Formio.registerPlugin((o=>({priority:0,preRequest:e=>n(e,o),preStaticRequest:e=>n(e,o),request:e=>n(e,o),staticRequest:e=>n(e,o)}))(p),"requestPlugin"),Formio.createForm(o,s,p).then((e=>{e.formio=f,e.options.formio=f;const t={form:e,elem:o,...r};"function"==typeof r.createFormCallback?r.createFormCallback(t):((o,e,r,t)=>{const i=o=>{o.addEventListener("click",(o=>{((o,e)=>(o.matches||o.matchesSelector||o.msMatchesSelector||o.mozMatchesSelector||o.webkitMatchesSelector||o.oMatchesSelector).call(o,e))(o.target,"a")&&(o=>{o.target.target="_blank"})(o)}))};Array.isArray(o)?[].forEach.call(o,i):i(o)})(o),(o=>{let{form:e,formConfirmation:r}=o;e.on("change",(o=>{void 0!==o.changed&&void 0!==o.changed.component&&i({event:"formio-interaction","formio-input-id":o.changed.component.id,"formio-input-type":o.changed.component.type,"formio-input-value":o.changed.value,"formio-input-key":o.changed.component.key,"formio-input-label-raw":o.changed.component.label,"formio-name":e._form.title,"formio-version":e._form.modified,"formio-category":"Form: ".concat(e._form.title),"formio-action":"filled in"})})),e.on("applicationSubmit",(()=>{e.submit()})),e.on("submitDone",(()=>{i({event:"formio-submission","formio-submissionsUrl":"form.io: ".concat(e.formio.submissionsUrl),"formio-name":e._form.title,"formio-version":e._form.modified}),r&&setTimeout((()=>{window.location.href=r}),500)})),e.on("submitError",(o=>{const r=Array.isArray(o)?o.map((o=>o.message)).join(", "):(null==o?void 0:o.message)||o;i({event:"ngErrorEvent",ngErrorLocation:"form.io - ".concat(e._form.title),ngErrorMsg:r,ngErrorStack:""})}))})(t),"function"==typeof r.createFormController&&r.createFormController(t)}))},m=o=>{const e=Formio.Form.prototype.errorForm.bind({});Formio.Form.prototype.errorForm=r=>"string"==typeof r&&-1!==r.indexOf("Could not connect to API server")||"object"==typeof r&&r.networkError?(console.warn("formio error: ",r),e("function"==typeof o?o(r):r)):e(r)},c=function(){let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;Formio.icons="fontawesome",o&&Formio.cdn.setOverrideUrl("grid",o),premium&&Formio.use(premium),"function"==typeof window.initFormioHook?window.initFormioHook({overrideErrorForm:m}):m((()=>"This form is currently unavailable due to maintenance. Please try again later.")),document.querySelectorAll("[data-formio]").forEach((o=>{const{formioProjectName:e,formioFormName:r,formioEnvUrl:t,formioPdfDownload:i,formioFormConfirmation:n,formioFormRevision:m,formioNamespace:c,formioCreateformOptions:s,formioCreateformController:f,formioCreateformCallback:l}=o.dataset;a(o,{projectName:e,formName:r,envUrl:t,pdfDownload:i,formConfirmation:n,formRevision:m,namespace:c,createFormOptions:window[s],createFormController:window[f],createFormCallback:window[l]})}))}})(),t})()));
//# sourceMappingURL=formio-loader.min.js.map