@makeform/agreement 2.0.0 → 2.1.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Logs
2
2
 
3
+ ## v2.1.0
4
+
5
+ - support @grantdash/composer host
6
+
7
+
3
8
  ## v2.0.0
4
9
 
5
10
  - tweak DOM based on updated `@makeform/common` DOM structure.
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @makeform/agreement
2
2
 
3
+ ## config
4
+
5
+ - `value`: text to be shown besides the checkbox.
6
+ - `document`: Array of URLs of documents (either pdf or html) to be shown as the content of the agreement. (See Note)
7
+
8
+
3
9
  ## Note
4
10
 
5
11
  While not reproducible, occasionally iframe may fails to load. Check this issue before using inline document feature.
package/index.html CHANGED
@@ -1 +1 @@
1
- <div><div plug="body"><div class="m-edit"><div class="d-flex flex-column g-2"><div ld-each="document"><div class="border rounded-sm shadow-sm" style="min-height:300px"><div ld="link"></div><object class="d-none w-100 h-100 flex-grow-1" style="vertical-align:top;min-height:300px" ld="link" data="about:blank" type="application/pdf"><embed class="w-100 border" ld="link" src="about:blank" type="application/pdf"></object><div class="w-100 p-2" ld="for-html"><iframe class="d-none w-100 flex-grow-1 border-0" title="consent-document" ld="link" src="about:blank"></iframe></div></div><div class="text-right" style="margin-top:.1em"><a class="text-sm" ld="link" target="_blank" rel="noopener noreferer"><span class="mr-1" ld="open"></span><i class="i-new-page text-sm"></i></a></div></div></div></div><div class="m-edit" ld="input"><div class="d-flex"><label class="mb-0 clickable position-relative has-tips manual" ld="error-root"><input class="mr-1" ld="checkbox" type="checkbox"><span class="no-select" ld="text"></span><span ld="display" data-display="inline"><span class="text-danger ml-2" ld="is-required">*</span></span><div class="hover-tip tip-sm"><div ld-each="error"></div></div></label></div></div><div class="m-view"><input class="mr-1" ld="checkbox-for-view" type="checkbox" disabled readonly><span ld="text"></span></div></div><script type="@plotdb/block">var mod;module.exports={pkg:{name:"@makeform/agreement",extend:{name:"@makeform/common"},dependencies:[],i18n:{en:{"未勾選":"not checked",open:"Open this document in new window"},"zh-TW":{"未勾選":"未勾選",open:"在新視窗開啟此文件"}}},init:function(e){return e.pubsub.fire("subinit",{mod:mod(e)})}};mod=function(e){var o,t,n,r,i,u,c,d,a,s,l,f;o=e.root,t=e.manager,n=e.ctx,r=e.data,i=e.parent,u=e.t,c=e.i18n;d=n.ldview;a={value:null};s="_"+Math.random().toString(36).substring(2);l=null;f=function(){var n;n={lib:"https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.9.179/pdf.min.js",worker:"https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.9.179/pdf.worker.min.js"};return t.rescope.load([{url:n.lib}]).then(function(e){l=e.pdfjsLib;l.GlobalWorkerOptions.workerSrc=n.worker;return l})};return{init:function(e){var r,n,t=this;this.on("change",function(e){a.value=!!e;return t.mod.child.view.render(["input","checkbox","content"])});r=function(e){return t.value(a.value=!!e)};this.on("meta",function(e){});return this.mod.child.view=n=new d({root:o,action:{change:{checkbox:function(e){var n,t;n=e.node,t=e.ctx;return r(n.checked?true:false)}}},text:{content:function(e){var n;n=e.node;if(t.isEmpty()){return u("未勾選")}else{return t.mod.info.config.value||""}},text:function(e){var n;n=e.node;return u(t.mod.info.config.value||"")}},handler:{document:{list:function(){return t.mod.info.config.documents||[]},key:function(e){return e},view:{init:{link:function(e){var o,n,t,r,i;o=e.node,n=e.ctx;t=n;r=/\.html/.exec(t);i=/\.pdf/.exec(t);return o.addEventListener("load",function(){if(i&&o.nodeName.toLowerCase()==="object"){return f().then(function(){return l.getDocument(n).promise}).then(function(r){return r.getPage(1).then(function(e){var n,t;n=e.getViewport({scale:1});t=o.getBoundingClientRect();n=e.getViewport({scale:1*(t.width/n.width)});return r.numPages>3?window.innerHeight*.66:r.numPages*(t.width/n.width)*n.height+56})}).then(function(e){return o.style.minHeight=e+"px"})}else if(r){return debounce(1e3).then(function(){var e;o.setAttribute("scrolling","no");e=o.contentDocument.body.parentNode.scrollHeight;return o.style.height=e+"px"})}})}},handler:{"for-html":function(e){var n,t,r;n=e.node,t=e.ctx;r=t;return n.classList.toggle("d-none",!/\.html/.exec(r))},open:function(e){var n,t;n=e.node,t=e.ctx;return n.textContent=u("open")},link:function(e){var n,t,r,o,i;n=e.node,t=e.ctx;r=t;o=n.nodeName.toLowerCase();if(r===n.dataset.link){return}n.dataset.link=r;i=/\.html/.exec(r);if(o==="object"||o==="embed"){n.classList.toggle("d-none",i)}if(o==="iframe"){n.classList.toggle("d-none",!i)}if(o==="a"){return n.setAttribute("href",r)}else if(o==="object"){return n.setAttribute("data",r)}else{return n.setAttribute("src",r)}}}}},input:function(e){var n;n=e.node;return n.classList.toggle("text-danger",t.status()===2)},checkbox:function(e){var n;n=e.node;if(!t.mod.info.meta.readonly){n.removeAttribute("disabled")}else{n.setAttribute("disabled",null)}return n.checked=!!a.value},"checkbox-for-view":function(e){var n;n=e.node;return n.checked=!!a.value}}})},render:function(){return this.mod.child.view.render()},isEmpty:function(e){return!e},content:function(e){return!!e}}};</script></div>
1
+ <div><div plug="body"><div class="m-edit"><div class="d-flex flex-column g-2"><div ld-each="document"><div class="border rounded-sm shadow-sm" style="min-height:300px"><div ld="link"></div><object class="d-none w-100 h-100 flex-grow-1" style="vertical-align:top;min-height:300px" ld="link" data="about:blank" type="application/pdf"><embed class="w-100 border" ld="link" src="about:blank" type="application/pdf"></object><div class="w-100 p-2" ld="for-html"><iframe class="d-none w-100 flex-grow-1 border-0" title="consent-document" ld="link" src="about:blank"></iframe></div></div><div class="text-right" style="margin-top:.1em"><a class="text-sm" ld="link" target="_blank" rel="noopener noreferer"><span class="mr-1" ld="open"></span><i class="i-new-page text-sm"></i></a></div></div></div></div><div class="m-edit" ld="input"><div class="d-flex"><label class="mb-0 clickable position-relative has-tips manual" ld="error-root"><input class="mr-1" ld="checkbox" type="checkbox"><span ld="text"></span><span ld="display" data-display="inline"><span class="text-danger ml-2" ld="is-required">*</span></span><div class="hover-tip tip-sm"><div ld-each="error"></div></div></label></div></div><div class="m-view"><input class="mr-1" ld="checkbox-for-view" type="checkbox" disabled readonly><span ld="text"></span></div></div><script type="@plotdb/block">var mod;module.exports={pkg:{name:"@makeform/agreement",extend:{name:"@makeform/common"},host:{name:"@grantdash/composer"},dependencies:[],i18n:{en:{"未勾選":"not checked",open:"Open this document in new window"},"zh-TW":{"未勾選":"未勾選",open:"在新視窗開啟此文件"}}},init:function(e){var t=this;e.pubsub.on("inited",function(e){e==null&&(e={});return import$(t,e)});return e.pubsub.fire("subinit",{mod:mod.call(this,e)})}};mod=function(e){var o,n,t,r,i,c,u,a,d,s,l,f,h,m=this;o=e.root,n=e.manager,t=e.ctx,r=e.data,i=e.parent,c=e.t,u=e.i18n;a=t.ldview;d={value:null};s=function(){return m.hitf};l="_"+Math.random().toString(36).substring(2);f=null;h=function(){var t;t={lib:"https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.9.179/pdf.min.js",worker:"https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.9.179/pdf.worker.min.js"};return n.rescope.load([{url:t.lib}]).then(function(e){f=e.pdfjsLib;f.GlobalWorkerOptions.workerSrc=t.worker;return f})};return{init:function(e){var r,t,n=this;this.on("change",function(e){d.value=!!e;return n.mod.child.view.render(["input","checkbox","content"])});r=function(e){return n.value(d.value=!!e)};this.on("meta",function(e){});return this.mod.child.view=t=new a({root:o,action:{change:{checkbox:function(e){var t,n;t=e.node,n=e.ctx;return r(t.checked?true:false)}},click:{text:s().edit({path:"config.value"})}},text:{content:function(e){var t;t=e.node;if(n.isEmpty()){return c("未勾選")}else{return s().totext(itf().content(n.mod.info.config.value))}}},handler:{text:function(e){var t,n;t=e.node,n=e.ctx;t.classList.toggle("no-select",!!s().get().readonly);return s().render({path:"config.value"})({node:t,ctx:n})},document:{list:function(){return n.mod.info.config.documents||[]},key:function(e){return e},view:{init:{link:function(e){var o,t,n,r,i;o=e.node,t=e.ctx;n=t;r=/\.html/.exec(n);i=/\.pdf/.exec(n);return o.addEventListener("load",function(){if(i&&o.nodeName.toLowerCase()==="object"){return h().then(function(){return f.getDocument(t).promise}).then(function(r){return r.getPage(1).then(function(e){var t,n;t=e.getViewport({scale:1});n=o.getBoundingClientRect();t=e.getViewport({scale:1*(n.width/t.width)});return r.numPages>3?window.innerHeight*.66:r.numPages*(n.width/t.width)*t.height+56})}).then(function(e){return o.style.minHeight=e+"px"})}else if(r){return debounce(1e3).then(function(){var e;o.setAttribute("scrolling","no");e=o.contentDocument.body.parentNode.scrollHeight;return o.style.height=e+"px"})}})}},handler:{"for-html":function(e){var t,n,r;t=e.node,n=e.ctx;r=n;return t.classList.toggle("d-none",!/\.html/.exec(r))},open:function(e){var t,n;t=e.node,n=e.ctx;return t.textContent=c("open")},link:function(e){var t,n,r,o,i;t=e.node,n=e.ctx;r=n;o=t.nodeName.toLowerCase();if(r===t.dataset.link){return}t.dataset.link=r;i=/\.html/.exec(r);if(o==="object"||o==="embed"){t.classList.toggle("d-none",i)}if(o==="iframe"){t.classList.toggle("d-none",!i)}if(o==="a"){return t.setAttribute("href",r)}else if(o==="object"){return t.setAttribute("data",r)}else{return t.setAttribute("src",r)}}}}},input:function(e){var t;t=e.node;return t.classList.toggle("text-danger",n.status()===2)},checkbox:function(e){var t;t=e.node;if(!n.mod.info.meta.readonly){t.removeAttribute("disabled")}else{t.setAttribute("disabled",null)}return t.checked=!!d.value},"checkbox-for-view":function(e){var t;t=e.node;return t.checked=!!d.value}}})},render:function(){return this.mod.child.view.render()},isEmpty:function(e){return!e},content:function(e){return!!e}}};function import$(e,t){var n={}.hasOwnProperty;for(var r in t)if(n.call(t,r))e[r]=t[r];return e}</script></div>
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@makeform/agreement","version":"2.0.0","description":"","scripts":{},"keywords":[],"author":"zbryikt","license":"MIT","dependencies":{"@plotdb/srcbuild":"^0.0.68"},"devDependencies":{"fedep":"^1.3.0"}}
1
+ {"name":"@makeform/agreement","version":"2.1.0","description":"","scripts":{},"keywords":[],"author":"zbryikt","license":"MIT","dependencies":{"@plotdb/srcbuild":"^0.0.69"},"devDependencies":{"fedep":"^1.6.0"}}