@formio/js 5.0.0-rc.23 → 5.0.0-rc.25
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +24 -30
- 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 +8 -19
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +9 -20
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +1 -1
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Embed.d.ts +4 -2
- package/lib/cjs/Embed.js +55 -42
- package/lib/cjs/WebformBuilder.js +1 -1
- package/lib/cjs/components/_classes/list/ListComponent.d.ts +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.js +6 -3
- package/lib/cjs/components/radio/Radio.js +22 -12
- package/lib/cjs/components/select/Select.d.ts +2 -0
- package/lib/cjs/components/select/Select.js +6 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.js +9 -0
- package/lib/cjs/components/selectboxes/fixtures/comp7.d.ts +18 -0
- package/lib/cjs/components/selectboxes/fixtures/comp7.js +31 -0
- package/lib/cjs/components/selectboxes/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/selectboxes/fixtures/index.js +3 -1
- package/lib/cjs/components/signature/Signature.d.ts +1 -2
- package/lib/cjs/components/signature/Signature.js +1 -2
- package/lib/cjs/utils/ChoicesWrapper.d.ts +1 -0
- package/lib/cjs/utils/ChoicesWrapper.js +19 -0
- package/lib/mjs/Embed.d.ts +4 -2
- package/lib/mjs/Embed.js +54 -43
- package/lib/mjs/WebformBuilder.js +1 -1
- package/lib/mjs/components/_classes/list/ListComponent.d.ts +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.js +6 -3
- package/lib/mjs/components/radio/Radio.js +22 -12
- package/lib/mjs/components/select/Select.d.ts +2 -0
- package/lib/mjs/components/select/Select.js +6 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.js +10 -1
- package/lib/mjs/components/selectboxes/fixtures/comp7.d.ts +18 -0
- package/lib/mjs/components/selectboxes/fixtures/comp7.js +29 -0
- package/lib/mjs/components/selectboxes/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/selectboxes/fixtures/index.js +2 -1
- package/lib/mjs/components/signature/Signature.d.ts +1 -2
- package/lib/mjs/components/signature/Signature.js +1 -2
- package/lib/mjs/utils/ChoicesWrapper.d.ts +1 -0
- package/lib/mjs/utils/ChoicesWrapper.js +19 -0
- package/package.json +3 -4
package/README.md
CHANGED
@@ -14,7 +14,7 @@ To find out more about this library as well as see a demonstration of what you c
|
|
14
14
|
To install this SDK into your project, you can use the following command within your terminal.
|
15
15
|
|
16
16
|
```
|
17
|
-
npm install --save
|
17
|
+
npm install --save @formio/js
|
18
18
|
```
|
19
19
|
|
20
20
|
## Form Building
|
@@ -23,17 +23,15 @@ This library has a very powerful JSON form builder, and can be used like the fol
|
|
23
23
|
```html
|
24
24
|
<html>
|
25
25
|
<head>
|
26
|
-
<link rel=
|
27
|
-
<link rel=
|
28
|
-
<script src='https://cdn.form.io/
|
29
|
-
<script type='text/javascript'>
|
30
|
-
window.onload = function() {
|
31
|
-
Formio.builder(document.getElementById('builder'), {}, {});
|
32
|
-
};
|
33
|
-
</script>
|
26
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css">
|
27
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css">
|
28
|
+
<script src='https://cdn.form.io/js/formio.full.min.js'></script>
|
34
29
|
</head>
|
35
30
|
<body>
|
36
31
|
<div id='builder'></div>
|
32
|
+
<script type='text/javascript'>
|
33
|
+
Formio.builder(document.getElementById('builder'), {}, {});
|
34
|
+
</script>
|
37
35
|
</body>
|
38
36
|
</html>
|
39
37
|
```
|
@@ -49,17 +47,15 @@ The following is a simple example on how to render a form within your HTML appli
|
|
49
47
|
```html
|
50
48
|
<html>
|
51
49
|
<head>
|
52
|
-
<link rel=
|
53
|
-
<link rel=
|
54
|
-
<script src=
|
55
|
-
<script type='text/javascript'>
|
56
|
-
window.onload = function() {
|
57
|
-
Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/example');
|
58
|
-
};
|
59
|
-
</script>
|
50
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css">
|
51
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css">
|
52
|
+
<script src="https://cdn.form.io/js/formio.embed.js"></script>
|
60
53
|
</head>
|
61
54
|
<body>
|
62
55
|
<div id='formio'></div>
|
56
|
+
<script type='text/javascript'>
|
57
|
+
Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/example');
|
58
|
+
</script>
|
63
59
|
</body>
|
64
60
|
</html>
|
65
61
|
```
|
@@ -102,7 +98,7 @@ This will render the JSON schema of the form within your application.
|
|
102
98
|
### JSFiddle Example
|
103
99
|
A great way to play around with this renderer is to use JSFiddle, which serves as a good sandbox environment. Here is an example that you can fork and make your own!
|
104
100
|
|
105
|
-
http://jsfiddle.net/travistidwell/
|
101
|
+
http://jsfiddle.net/travistidwell/z63jvwkp/
|
106
102
|
|
107
103
|
### Form Renderer Documentation
|
108
104
|
For a more complete documentation of how to utilize this library within your application go to the [Form Renderer](https://help.form.io/developers/form-renderer) documentation.
|
@@ -115,17 +111,15 @@ being set to ```wizard```.
|
|
115
111
|
```html
|
116
112
|
<html>
|
117
113
|
<head>
|
118
|
-
<link rel=
|
119
|
-
<link rel=
|
120
|
-
<script src=
|
121
|
-
<script type='text/javascript'>
|
122
|
-
window.onload = function() {
|
123
|
-
Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/wizard');
|
124
|
-
};
|
125
|
-
</script>
|
114
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css">
|
115
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css">
|
116
|
+
<script src="https://cdn.form.io/js/formio.embed.js"></script>
|
126
117
|
</head>
|
127
118
|
<body>
|
128
119
|
<div id='formio'></div>
|
120
|
+
<script type='text/javascript'>
|
121
|
+
Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/wizard');
|
122
|
+
</script>
|
129
123
|
</body>
|
130
124
|
</html>
|
131
125
|
```
|
@@ -134,10 +128,10 @@ being set to ```wizard```.
|
|
134
128
|
You can also use this library as a JavaScript embedding of the form using a single line of code. For example, to embed the https://examples.form.io/example form within your application you can simply use the following embed code.
|
135
129
|
|
136
130
|
```html
|
137
|
-
<script src="https://cdn.form.io/
|
131
|
+
<script src="https://cdn.form.io/js/formio.embed.min.js?src=https://examples.form.io/example&libs=true"></script>
|
138
132
|
```
|
139
133
|
|
140
|
-
For an example of how this looks and works, check out the following [Form.io
|
134
|
+
For an example of how this looks and works, check out the following [Form.io Inline Embedding](https://jsfiddle.net/travistidwell/uys26qpf/)
|
141
135
|
|
142
136
|
## Form Embedding Documentation
|
143
137
|
For a more complete documentation of how to embed forms, go to the [Form Embedding Documentation](https://help.form.io/developers/rendering).
|
@@ -148,7 +142,7 @@ In addition to having a Form Renderer within this application, you can also use
|
|
148
142
|
```html
|
149
143
|
<html>
|
150
144
|
<head>
|
151
|
-
<script src='https://cdn.form.io/
|
145
|
+
<script src='https://cdn.form.io/js/formio.min.js'></script>
|
152
146
|
<script type='text/javascript'>
|
153
147
|
var formio = new Formio('https://examples.form.io/example');
|
154
148
|
formio.loadForm().then(function(form) {
|
@@ -174,7 +168,7 @@ In addition to having a Form Renderer within this application, you can also use
|
|
174
168
|
You can also use this within an ES6 application as follows.
|
175
169
|
|
176
170
|
```js
|
177
|
-
import Formio from '
|
171
|
+
import { Formio } from '@formio/js/sdk';
|
178
172
|
let formio = new Formio('https://examples.form.io/example');
|
179
173
|
formio.loadForm((form) => {
|
180
174
|
console.log(form);
|
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={36310:function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.default=class{constructor(e){this.baseUrl=e||"https://cdn.form.io",this.overrides={},this.libs={js:"",ace:"1.4.12",bootstrap:"4.6.2",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,i){let t;return t="latest"===i||""===i?`${e}/${o}`:`${e}/${o}/${i}`,t}updateUrls(){for(const e in this.libs)e in this.overrides?this[e]=this.buildUrl(this.overrides[e],e,this.libs[e]):this[e]=this.buildUrl(this.baseUrl,e,this.libs[e])}}},3805:function(e,o,i){var t=this&&this.__awaiter||function(e,o,i,t){return new(i||(i=Promise))((function(r,s){function n(e){try{l(t.next(e))}catch(e){s(e)}}function d(e){try{l(t.throw(e))}catch(e){s(e)}}function l(e){var o;e.done?r(e.value):(o=e.value,o instanceof i?o:new i((function(e){e(o)}))).then(n,d)}l((t=t.apply(e,o||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.Formio=void 0;const s=r(i(36310));class n{static setBaseUrl(e){return t(this,void 0,void 0,(function*(){n.baseUrl=e}))}static setProjectUrl(e){return t(this,void 0,void 0,(function*(){n.projectUrl=e}))}static debug(...e){n.config.debug&&console.log(...e)}static global(e){const o=window[e];return o&&o.proxy?null:(n.debug(`Getting global ${e}`,o),o)}static createElement(e,o,i){const t=document.createElement(e);return Object.keys(o).forEach((e=>{t.setAttribute(e,o[e])})),(i||[]).forEach((e=>{t.appendChild(n.createElement(e.tag,e.attrs,e.children))})),t}static addScript(e,o){return t(this,void 0,void 0,(function*(){return e?"string"!=typeof e&&e.length?Promise.all(e.map((e=>n.addScript(e)))):o&&n.global(o)?(n.debug(`${o} already loaded.`),Promise.resolve(n.global(o))):(n.debug("Adding Script",e),n.wrapper.appendChild(n.createElement("script",{src:e})),o?new Promise((e=>{n.debug(`Waiting to load ${o}`);const i=setInterval((()=>{n.global(o)&&(clearInterval(i),n.debug(`${o} loaded.`),e(n.global(o)))}),100)})):Promise.resolve()):Promise.resolve()}))}static addStyles(e
|
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={36310:function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.default=class{constructor(e){this.baseUrl=e||"https://cdn.form.io",this.overrides={},this.libs={js:"",ace:"1.4.12",bootstrap:"4.6.2",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,i){let t;return t="latest"===i||""===i?`${e}/${o}`:`${e}/${o}/${i}`,t}updateUrls(){for(const e in this.libs)e in this.overrides?this[e]=this.buildUrl(this.overrides[e],e,this.libs[e]):this[e]=this.buildUrl(this.baseUrl,e,this.libs[e])}}},3805:function(e,o,i){var t=this&&this.__awaiter||function(e,o,i,t){return new(i||(i=Promise))((function(r,s){function n(e){try{l(t.next(e))}catch(e){s(e)}}function d(e){try{l(t.throw(e))}catch(e){s(e)}}function l(e){var o;e.done?r(e.value):(o=e.value,o instanceof i?o:new i((function(e){e(o)}))).then(n,d)}l((t=t.apply(e,o||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.Formio=void 0;const s=r(i(36310));class n{static setBaseUrl(e){return t(this,void 0,void 0,(function*(){n.baseUrl=e}))}static setProjectUrl(e){return t(this,void 0,void 0,(function*(){n.projectUrl=e}))}static debug(...e){n.config.debug&&console.log(...e)}static global(e){const o=window[e];return o&&o.proxy?null:(n.debug(`Getting global ${e}`,o),o)}static createElement(e,o,i){const t=document.createElement(e);return Object.keys(o).forEach((e=>{t.setAttribute(e,o[e])})),(i||[]).forEach((e=>{t.appendChild(n.createElement(e.tag,e.attrs,e.children))})),t}static addScript(e,o){return t(this,void 0,void 0,(function*(){return e?"string"!=typeof e&&e.length?Promise.all(e.map((e=>n.addScript(e)))):o&&n.global(o)?(n.debug(`${o} already loaded.`),Promise.resolve(n.global(o))):(n.debug("Adding Script",e),n.wrapper.appendChild(n.createElement("script",{src:e})),o?new Promise((e=>{n.debug(`Waiting to load ${o}`);const i=setInterval((()=>{n.global(o)&&(clearInterval(i),n.debug(`${o} loaded.`),e(n.global(o)))}),100)})):Promise.resolve()):Promise.resolve()}))}static addStyles(e){return t(this,void 0,void 0,(function*(){e&&("string"!=typeof e&&e.length?e.forEach((e=>n.addStyles(e))):(n.debug("Adding Styles",e),n.wrapper.appendChild(n.createElement("link",{rel:"stylesheet",href:e}))))}))}static submitDone(e,o){return t(this,void 0,void 0,(function*(){n.debug("Submision Complete",o);let i=n.config.redirect;if(!i&&e._form&&e._form.settings&&(e._form.settings.returnUrl||e._form.settings.redirect)&&(n.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(/\?/),s=0===i.indexOf(location.origin);i+=r?"&":"?",i+=`sub=${o._id}`,!s&&t&&(i+=`&form=${encodeURIComponent(t)}`),n.debug("Return URL",i),window.location.href=i,s&&window.location.reload()}}))}static formioScript(e,o){return o?e.replace("formio.form","formio.full"):e}static init(e,o=!1){return t(this,void 0,void 0,(function*(){if(n.element=e,n.cdn=new s.default(n.config.cdn),n.config.libs=n.config.libs||{uswds:{fa:!0,js:`${n.cdn.uswds}/uswds.min.js`,css:`${n.cdn.uswds}/uswds.min.css`},fontawesome:{css:`${n.cdn["font-awesome"]}/css/font-awesome.min.css`},bootstrap:{css:`${n.cdn.bootstrap}/css/bootstrap.min.css`}},n.config.id=n.config.id||`formio-${Math.random().toString(36).substring(7)}`,n.wrapper=n.createElement("div",{id:`"${n.config.id}-wrapper"`}),e.parentNode.insertBefore(n.wrapper,e),e.parentNode.removeChild(e),n.wrapper.appendChild(e),yield n.addStyles(n.config.embedCSS||`${n.cdn.js}/formio.embed.css`),n.loader=n.createElement("div",{class:"formio-loader"},[{tag:"div",attrs:{class:"loader-wrapper"},children:[{tag:"div",attrs:{class:"loader text-center"}}]}]),n.wrapper.appendChild(n.loader),n.FormioClass=yield n.addScript(n.formioScript(n.config.script||`${n.cdn.js}/formio.form.min.js`,o),"Formio"),n.FormioClass.setBaseUrl(n.baseUrl||n.config.base),n.FormioClass.setProjectUrl(n.projectUrl||n.config.project),n.FormioClass.language=n.language,n.global("premium")&&(n.debug("Using premium module."),n.FormioClass.use(n.global("premium"))),n.global("vpat")&&(n.debug("Using vpat module."),n.FormioClass.use(n.global("vpat"))),n.config.template){if(n.config.includeLibs&&(yield n.addStyles(n.config.libs[n.config.template].css),yield n.addScript(n.config.libs[n.config.template].js),n.config.libs[n.config.template].fa&&(yield n.addStyles(n.config.libs.fontawesome.css))),n.cdn[n.config.template]){const e=`${n.cdn[n.config.template]}/${n.config.template}.min`;yield n.addStyles(`${e}.css`),n.debug(`Using ${n.config.template}`),n.FormioClass.use(yield n.addScript(`${e}.js`,n.config.template))}}else n.global("uswds")?(n.debug("Using uswds module."),n.FormioClass.use(n.global("uswds"))):n.config.includeLibs&&(yield n.addStyles(n.config.libs.fontawesome.css),yield n.addStyles(n.config.libs.bootstrap.css));n.config.premium&&(yield n.addStyles(n.config.premium.css),n.debug("Using premium"),n.FormioClass.use(yield n.addScript(n.config.premium.js,"premium"))),yield n.addStyles(n.formioScript(n.config.style||`${n.cdn.js}/formio.form.min.css`,o)),n.config.before&&(yield n.config.before(n.FormioClass,n.element,n.config)),n.FormioClass.license=!0}))}static createForm(e,o,i){return t(this,void 0,void 0,(function*(){return yield n.init(e),n.FormioClass.createForm(n.element,o,Object.assign(Object.assign({},i),{noLoader:!0})).then((e=>(n.debug("Form created",e),n.debug("Removing loader"),n.wrapper.removeChild(n.loader),n.config.submission&&(n.debug("Setting submission",n.config.submission),e.submission=n.config.submission),n.debug("Triggering embed event"),n.FormioClass.events.emit("formEmbedded",e),n.config.after&&(n.debug("Calling ready callback"),n.config.after(e,n.config)),e)))}))}static builder(e,o,i){return t(this,void 0,void 0,(function*(){return yield n.init(e,!0),n.FormioClass.builder(n.element,o,i).then((e=>(n.debug("Builder created",e),n.debug("Removing loader"),n.wrapper.removeChild(n.loader),n.debug("Triggering embed event"),n.FormioClass.events.emit("builderEmbedded",e),n.config.after&&(n.debug("Calling ready callback"),n.config.after(e,n.config)),e)))}))}}n.config={},n.loader=null,n.cdn=null,n.proxy=!0,o.Formio=n}},o={};function i(t){var r=o[t];if(void 0!==r)return r.exports;var s=o[t]={exports:{}};return e[t].call(s.exports,s,s.exports,i),s.exports}var t={};return function(){var e=t;e.Formio=void 0;const o=i(3805);Object.defineProperty(e,"Formio",{enumerable:!0,get:function(){return o.Formio}});const r=document.getElementsByTagName("script"),s=window.FormioConfig||{};let n=null,d=r.length;const l=s.scriptName||"formio.embed.";for(;d--;)if(r[d].src&&-1!==r[d].src.indexOf(l)){n=r[d];break}if(n){const e={};n.src.replace(/^[^?]+\??/,"").replace(/\?/g,"&").split("&").forEach((o=>{e[o.split("=")[0]]=o.split("=")[1]&&decodeURIComponent(o.split("=")[1])}));let i=n.src.replace(/^([^?]+).*/,"$1").split("/");i.pop(),s.formioPath&&s.formioPath(i),i=i.join("/"),o.Formio.config=Object.assign({script:e.script||`${s.updatePath?s.updatePath():i}/formio.form.min.js`,style:e.styles||`${s.updatePath?s.updatePath():i}/formio.form.min.css`,cdn:e.cdn,class:e.class||"formio-form-wrapper",src:e.src,form:null,submission:null,project:e.project,base:e.base||"https://api.form.io",submit:e.submit,includeLibs:"true"===e.libs||"1"===e.libs,template:e.template,debug:"true"===e.debug||"1"===e.debug,config:{},redirect:e.return||e.redirect,embedCSS:`${s.updatePath?s.updatePath():i}/formio.embed.css`,before:null,after:null},s);const t=o.Formio.config.form||o.Formio.config.src;if(t){o.Formio.debug("Embedding Configuration",s),o.Formio.config.addPremiumLib&&o.Formio.config.addPremiumLib(o.Formio.config,i),o.Formio.config.id=`formio-${Math.random().toString(36).substring(7)}`,o.Formio.debug("Creating form element");const e=o.Formio.createElement("div",{id:o.Formio.config.id,class:o.Formio.config.class});n.parentNode.insertBefore(e,n.parentNode.firstElementChild.nextSibling),o.Formio.createForm(e,t,o.Formio.config.config).then((e=>{o.Formio.config.submit&&(e.nosubmit=!0),e.on("submit",(i=>{if(o.Formio.debug("on('submit')",i),o.Formio.config.submit){o.Formio.debug(`Sending submission to ${o.Formio.config.submit}`);const t={"content-type":"application/json"},r=o.Formio.FormioClass.getToken();r&&(t["x-jwt-token"]=r),o.Formio.FormioClass.fetch(o.Formio.config.submit,{body:JSON.stringify(i),headers:t,method:"POST",mode:"cors"}).then((e=>e.json())).then((i=>o.Formio.submitDone(e,i)))}else o.Formio.submitDone(e,i)}))}))}}else document.write("<span>Could not locate the Embedded form.</span>")}(),t.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={36310:function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.default=class{constructor(e){this.baseUrl=e||"https://cdn.form.io",this.overrides={},this.libs={js:"",ace:"1.4.12",bootstrap:"4.6.2",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,i){let t;return t="latest"===i||""===i?`${e}/${o}`:`${e}/${o}/${i}`,t}updateUrls(){for(const e in this.libs)e in this.overrides?this[e]=this.buildUrl(this.overrides[e],e,this.libs[e]):this[e]=this.buildUrl(this.baseUrl,e,this.libs[e])}}},3805:function(e,o,i){var t=this&&this.__awaiter||function(e,o,i,t){return new(i||(i=Promise))((function(r,s){function n(e){try{l(t.next(e))}catch(e){s(e)}}function d(e){try{l(t.throw(e))}catch(e){s(e)}}function l(e){var o;e.done?r(e.value):(o=e.value,o instanceof i?o:new i((function(e){e(o)}))).then(n,d)}l((t=t.apply(e,o||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.Formio=void 0;const s=r(i(36310));class n{static setBaseUrl(e){return t(this,void 0,void 0,(function*(){n.baseUrl=e}))}static setProjectUrl(e){return t(this,void 0,void 0,(function*(){n.projectUrl=e}))}static debug(...e){n.config.debug&&console.log(...e)}static global(e){const o=window[e];return o&&o.proxy?null:(n.debug(`Getting global ${e}`,o),o)}static createElement(e,o,i){const t=document.createElement(e);return Object.keys(o).forEach((e=>{t.setAttribute(e,o[e])})),(i||[]).forEach((e=>{t.appendChild(n.createElement(e.tag,e.attrs,e.children))})),t}static addScript(e,o){return t(this,void 0,void 0,(function*(){return e?"string"!=typeof e&&e.length?Promise.all(e.map((e=>n.addScript(e)))):o&&n.global(o)?(n.debug(`${o} already loaded.`),Promise.resolve(n.global(o))):(n.debug("Adding Script",e),n.wrapper.appendChild(n.createElement("script",{src:e})),o?new Promise((e=>{n.debug(`Waiting to load ${o}`);const i=setInterval((()=>{n.global(o)&&(clearInterval(i),n.debug(`${o} loaded.`),e(n.global(o)))}),100)})):Promise.resolve()):Promise.resolve()}))}static addStyles(e
|
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={36310:function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.default=class{constructor(e){this.baseUrl=e||"https://cdn.form.io",this.overrides={},this.libs={js:"",ace:"1.4.12",bootstrap:"4.6.2",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,i){let t;return t="latest"===i||""===i?`${e}/${o}`:`${e}/${o}/${i}`,t}updateUrls(){for(const e in this.libs)e in this.overrides?this[e]=this.buildUrl(this.overrides[e],e,this.libs[e]):this[e]=this.buildUrl(this.baseUrl,e,this.libs[e])}}},3805:function(e,o,i){var t=this&&this.__awaiter||function(e,o,i,t){return new(i||(i=Promise))((function(r,s){function n(e){try{l(t.next(e))}catch(e){s(e)}}function d(e){try{l(t.throw(e))}catch(e){s(e)}}function l(e){var o;e.done?r(e.value):(o=e.value,o instanceof i?o:new i((function(e){e(o)}))).then(n,d)}l((t=t.apply(e,o||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.Formio=void 0;const s=r(i(36310));class n{static setBaseUrl(e){return t(this,void 0,void 0,(function*(){n.baseUrl=e}))}static setProjectUrl(e){return t(this,void 0,void 0,(function*(){n.projectUrl=e}))}static debug(...e){n.config.debug&&console.log(...e)}static global(e){const o=window[e];return o&&o.proxy?null:(n.debug(`Getting global ${e}`,o),o)}static createElement(e,o,i){const t=document.createElement(e);return Object.keys(o).forEach((e=>{t.setAttribute(e,o[e])})),(i||[]).forEach((e=>{t.appendChild(n.createElement(e.tag,e.attrs,e.children))})),t}static addScript(e,o){return t(this,void 0,void 0,(function*(){return e?"string"!=typeof e&&e.length?Promise.all(e.map((e=>n.addScript(e)))):o&&n.global(o)?(n.debug(`${o} already loaded.`),Promise.resolve(n.global(o))):(n.debug("Adding Script",e),n.wrapper.appendChild(n.createElement("script",{src:e})),o?new Promise((e=>{n.debug(`Waiting to load ${o}`);const i=setInterval((()=>{n.global(o)&&(clearInterval(i),n.debug(`${o} loaded.`),e(n.global(o)))}),100)})):Promise.resolve()):Promise.resolve()}))}static addStyles(e){return t(this,void 0,void 0,(function*(){e&&("string"!=typeof e&&e.length?e.forEach((e=>n.addStyles(e))):(n.debug("Adding Styles",e),n.wrapper.appendChild(n.createElement("link",{rel:"stylesheet",href:e}))))}))}static submitDone(e,o){return t(this,void 0,void 0,(function*(){n.debug("Submision Complete",o);let i=n.config.redirect;if(!i&&e._form&&e._form.settings&&(e._form.settings.returnUrl||e._form.settings.redirect)&&(n.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(/\?/),s=0===i.indexOf(location.origin);i+=r?"&":"?",i+=`sub=${o._id}`,!s&&t&&(i+=`&form=${encodeURIComponent(t)}`),n.debug("Return URL",i),window.location.href=i,s&&window.location.reload()}}))}static formioScript(e,o){return o?e.replace("formio.form","formio.full"):e}static init(e,o=!1){return t(this,void 0,void 0,(function*(){if(n.element=e,n.cdn=new s.default(n.config.cdn),n.config.libs=n.config.libs||{uswds:{fa:!0,js:`${n.cdn.uswds}/uswds.min.js`,css:`${n.cdn.uswds}/uswds.min.css`},fontawesome:{css:`${n.cdn["font-awesome"]}/css/font-awesome.min.css`},bootstrap:{css:`${n.cdn.bootstrap}/css/bootstrap.min.css`}},n.config.id=n.config.id||`formio-${Math.random().toString(36).substring(7)}`,n.wrapper=n.createElement("div",{id:`"${n.config.id}-wrapper"`}),e.parentNode.insertBefore(n.wrapper,e),e.parentNode.removeChild(e),n.wrapper.appendChild(e),yield n.addStyles(n.config.embedCSS||`${n.cdn.js}/formio.embed.css`),n.loader=n.createElement("div",{class:"formio-loader"},[{tag:"div",attrs:{class:"loader-wrapper"},children:[{tag:"div",attrs:{class:"loader text-center"}}]}]),n.wrapper.appendChild(n.loader),n.FormioClass=yield n.addScript(n.formioScript(n.config.script||`${n.cdn.js}/formio.form.min.js`,o),"Formio"),n.FormioClass.setBaseUrl(n.baseUrl||n.config.base),n.FormioClass.setProjectUrl(n.projectUrl||n.config.project),n.FormioClass.language=n.language,n.global("premium")&&(n.debug("Using premium module."),n.FormioClass.use(n.global("premium"))),n.global("vpat")&&(n.debug("Using vpat module."),n.FormioClass.use(n.global("vpat"))),n.config.template){if(n.config.includeLibs&&(yield n.addStyles(n.config.libs[n.config.template].css),yield n.addScript(n.config.libs[n.config.template].js),n.config.libs[n.config.template].fa&&(yield n.addStyles(n.config.libs.fontawesome.css))),n.cdn[n.config.template]){const e=`${n.cdn[n.config.template]}/${n.config.template}.min`;yield n.addStyles(`${e}.css`),n.debug(`Using ${n.config.template}`),n.FormioClass.use(yield n.addScript(`${e}.js`,n.config.template))}}else n.global("uswds")?(n.debug("Using uswds module."),n.FormioClass.use(n.global("uswds"))):n.config.includeLibs&&(yield n.addStyles(n.config.libs.fontawesome.css),yield n.addStyles(n.config.libs.bootstrap.css));n.config.premium&&(yield n.addStyles(n.config.premium.css),n.debug("Using premium"),n.FormioClass.use(yield n.addScript(n.config.premium.js,"premium"))),yield n.addStyles(n.formioScript(n.config.style||`${n.cdn.js}/formio.form.min.css`,o)),n.config.before&&(yield n.config.before(n.FormioClass,n.element,n.config)),n.FormioClass.license=!0}))}static createForm(e,o,i){return t(this,void 0,void 0,(function*(){return yield n.init(e),n.FormioClass.createForm(n.element,o,Object.assign(Object.assign({},i),{noLoader:!0})).then((e=>(n.debug("Form created",e),n.debug("Removing loader"),n.wrapper.removeChild(n.loader),n.config.submission&&(n.debug("Setting submission",n.config.submission),e.submission=n.config.submission),n.debug("Triggering embed event"),n.FormioClass.events.emit("formEmbedded",e),n.config.after&&(n.debug("Calling ready callback"),n.config.after(e,n.config)),e)))}))}static builder(e,o,i){return t(this,void 0,void 0,(function*(){return yield n.init(e,!0),n.FormioClass.builder(n.element,o,i).then((e=>(n.debug("Builder created",e),n.debug("Removing loader"),n.wrapper.removeChild(n.loader),n.debug("Triggering embed event"),n.FormioClass.events.emit("builderEmbedded",e),n.config.after&&(n.debug("Calling ready callback"),n.config.after(e,n.config)),e)))}))}}n.config={},n.loader=null,n.cdn=null,n.proxy=!0,o.Formio=n}},o={};function i(t){var r=o[t];if(void 0!==r)return r.exports;var s=o[t]={exports:{}};return e[t].call(s.exports,s,s.exports,i),s.exports}var t={};return function(){var e=t;e.Formio=void 0;const o=i(3805);Object.defineProperty(e,"Formio",{enumerable:!0,get:function(){return o.Formio}});const r=document.getElementsByTagName("script"),s=window.FormioConfig||{};let n=null,d=r.length;const l=s.scriptName||"formio.embed.";for(;d--;)if(r[d].src&&-1!==r[d].src.indexOf(l)){n=r[d];break}if(n){const e={};n.src.replace(/^[^?]+\??/,"").replace(/\?/g,"&").split("&").forEach((o=>{e[o.split("=")[0]]=o.split("=")[1]&&decodeURIComponent(o.split("=")[1])}));let i=n.src.replace(/^([^?]+).*/,"$1").split("/");i.pop(),s.formioPath&&s.formioPath(i),i=i.join("/"),o.Formio.config=Object.assign({script:e.script||`${s.updatePath?s.updatePath():i}/formio.form.min.js`,style:e.styles||`${s.updatePath?s.updatePath():i}/formio.form.min.css`,cdn:e.cdn,class:e.class||"formio-form-wrapper",src:e.src,form:null,submission:null,project:e.project,base:e.base||"https://api.form.io",submit:e.submit,includeLibs:"true"===e.libs||"1"===e.libs,template:e.template,debug:"true"===e.debug||"1"===e.debug,config:{},redirect:e.return||e.redirect,embedCSS:`${s.updatePath?s.updatePath():i}/formio.embed.css`,before:null,after:null},s);const t=o.Formio.config.form||o.Formio.config.src;if(t){o.Formio.debug("Embedding Configuration",s),o.Formio.config.addPremiumLib&&o.Formio.config.addPremiumLib(o.Formio.config,i),o.Formio.config.id=`formio-${Math.random().toString(36).substring(7)}`,o.Formio.debug("Creating form element");const e=o.Formio.createElement("div",{id:o.Formio.config.id,class:o.Formio.config.class});n.parentNode.insertBefore(e,n.parentNode.firstElementChild.nextSibling),o.Formio.createForm(e,t,o.Formio.config.config).then((e=>{o.Formio.config.submit&&(e.nosubmit=!0),e.on("submit",(i=>{if(o.Formio.debug("on('submit')",i),o.Formio.config.submit){o.Formio.debug(`Sending submission to ${o.Formio.config.submit}`);const t={"content-type":"application/json"},r=o.Formio.FormioClass.getToken();r&&(t["x-jwt-token"]=r),o.Formio.FormioClass.fetch(o.Formio.config.submit,{body:JSON.stringify(i),headers:t,method:"POST",mode:"cors"}).then((e=>e.json())).then((i=>o.Formio.submitDone(e,i)))}else o.Formio.submitDone(e,i)}))}))}}else document.write("<span>Could not locate the Embedded form.</span>")}(),t.Formio}()}));
|
@@ -1 +1 @@
|
|
1
|
-
/*! formiojs v5.0.0-rc.
|
1
|
+
/*! formiojs v5.0.0-rc.25 | https://unpkg.com/formiojs@5.0.0-rc.25/LICENSE.txt */
|