@makeform/choicegrid 0.0.1
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 +1 -0
- package/README.md +6 -0
- package/index.html +1 -0
- package/package.json +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Change Logs
|
package/README.md
ADDED
package/index.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div><style type="text/css">.grid{display:grid;grid-template-columns:repeat(auto-fill,10em);gap:.25em}.grid .head,.grid .body{display:grid;grid-template-columns:subgrid}.grid .cell{border-radius:.25em;padding:.25em;text-align:center}.grid .head{position:sticky;top:0}.grid .head .cell{border:0}.grid .check{cursor:pointer;color:#d1d2d3;border-radius:.25em;border:1px solid transparent;padding:.25em 1em;width:fit-content;margin:auto}.grid .check:hover{background:rgba(255,255,0,0.25)}.grid .check.active{color:#00c000;border-color:#00c000}</style><script type="@plotdb/block">var mod;module.exports={pkg:{name:"@makeform/choicegrid",extend:{name:"@makeform/common"},i18n:{en:{empty:"(empty)",other:"Other","fill-other":"Please fill"},"zh-TW":{empty:"(未填寫)",other:"其它","fill-other":"請填寫"}}},init:function(e){return e.pubsub.fire("subinit",{mod:mod(e)})}};mod=function(e){var t,n,r,i,o,d,h,s,v;t=e.root,n=e.ctx,r=e.data,i=e.pubsub,o=e.parent,d=e.t,h=e.i18n;s=n.ldview;v={};i.on("init.choice",function(e){return v.defcfg=e});return{init:function(){var i,o,r,u,f,l,e,c,n,a=this;h.on("languageChanged",function(){return l()});i=function(e){if(typeof e==="object"){return e.value}else{return e}};o=function(e){var n,t;n=e.entry;t=((v.value||{})[n]||{}).list||[];return t.filter(function(e){return e})};r=function(e){if(e==="__other__"){return d("other")}else if(typeof e==="object"){return d(e.label)}else{return d(e)}};u=function(n){var e;e=v.values.filter(function(e){return i(e)===n})[0];e=e&&e.label?e.label:e;return e?d(e):typeof n==="string"?d(n):n};f=function(e){return in$(e,(v.values||[]).map(function(e){return i(e)}))};l=debounce(100,function(){if(a.mod.child.optionView){return a.mod.child.optionView.render()}});e=function(){var e,n,t,r;if(!v.defcfg){e=a.mod.info.config||{}}else{e=import$({},v.defcfg.config||{});for(n in t=a.mod.info.config){r=t[n];if(e[n]==null){e[n]=r}}}v.meta=a.mod.info.meta;v.cfg=e;v.other=e.other||(e.other={});v.values=e.values||[];v.entries=e.entries||[];if(a.mod.child.view){a.mod.child.view.render()}return l()};e();this.on("meta",function(){return e()});this.on("change",function(e){var n,t;v.value=e||{};for(n in t=v.value){e=t[n];e.list=(e.list||(e.list=[])).filter(r)}a.mod.child.view.render(["content"]);return l();function r(e){return f(e)}});c=function(e){var n,t,r;n=e.entry,t=e.value;((r=v.value||(v.value={}))[n]||(r[n]={})).list=[t];return a.value(v.value)};return this.mod.child.view=n=new s({root:t,text:{content:function(e){var n,t,r,i,o;n=e.node;if(a.isEmpty()){return d("empty")}t=a.value();r=(t||{}).other;t=typeof t==="string"?[t]:t.list||[];i="";if(in$("__other__",t)&&v.other.enabled){i=d("other");if(v.other.editable&&(r||{}).text){i+=":"+r.text}}t=t.filter(function(e){return e!=="__other__"}).map(function(e){return u(e)});if(v.other.enabled&&i){t.push(i)}t=t.join((o=v.cfg.sep)?o:", ");if(!t){t=d("empty")}return t}},handler:{head:function(e){var n;n=e.node;return n.style.gridColumn="span "+(v.values.length+1)},option:{list:function(){return v.values},key:function(e){return i(e)},view:{handler:{label:function(e){var n,t;n=e.node,t=e.ctx;return n.textContent=r(t)}}}},entry:{list:function(){return v.entries},key:function(e){return i(e)},view:{handler:{"@":function(e){var n;n=e.node;return n.style.gridColumn="span "+(v.values.length+1)},label:function(e){var n,t;n=e.node,t=e.ctx;return n.textContent=r(t)},option:{list:function(){return v.values},key:function(e){return i(e)},view:{action:{click:{"@":function(e){var n,t,r;n=e.node,t=e.ctx,r=e.ctxs;return c({entry:i(r[0]),value:i(t)})}}},handler:{check:function(e){var n,t,r;n=e.node,t=e.ctx,r=e.ctxs;return n.classList.toggle("active",in$(i(t),o({entry:i(r[0])})))}}}}}}},input:function(e){var n;n=e.node}}})},render:function(){return this.mod.child.view.render()},validate:function(){var n=this;return Promise.resolve().then(function(){var e;if(!((n.mod.info.config||{}).other||{}).requireOnCheck){return}e=n.value();if(e&&(e.other||{}).enabled&&!(e.other||{}).text){return["other-error"]}})}}};function in$(e,n){var t=-1,r=n.length>>>0;while(++t<r)if(e===n[t])return true;return false}function import$(e,n){var t={}.hasOwnProperty;for(var r in n)if(t.call(n,r))e[r]=n[r];return e}</script><div plug="body"><div class="m-edit has-tips manual" ld="error-root"><div class="grid" ld="grid"><div class="head" ld="head"><div></div><div class="cell" ld-each="option"><div ld="label"></div></div></div><div class="body" ld-each="entry"><div ld="label"></div><div class="cell" ld-each="option"><div class="check" ld="check"><i class="i-check"></i></div></div></div></div><!--.m-edit: .hover-tip.tip-sm: div(ld-each="error")--></div><!--.m-view: div(ld="content")--></div></div>
|
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@makeform/choicegrid","version":"0.0.1","description":"","scripts":{},"keywords":[],"author":"zbryikt","license":"MIT","dependencies":{"@plotdb/srcbuild":"^0.0.68"},"devDependencies":{"fedep":"^1.4.0"}}
|