checkboxland
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -5,3 +5,4 @@ import { Checkboxland } from './checkboxland.js'; | ||
import transitionWipe from './plugins/transitionWipe.js'; | ||
import dataUtils from './plugins/dataUtils.js'; // Add built-in plugins | ||
import dataUtils from './plugins/dataUtils.js'; | ||
import onClick from './plugins/onClick.js'; // Add built-in plugins | ||
@@ -12,2 +13,3 @@ Checkboxland.extend(print); | ||
Checkboxland.extend(dataUtils); | ||
Checkboxland.extend(onClick); | ||
export { Checkboxland }; |
@@ -1,2 +0,2 @@ | ||
import{Checkboxland}from"./checkboxland.js";import print from"./plugins/print/print.js";import marquee from"./plugins/marquee.js";import transitionWipe from"./plugins/transitionWipe.js";import dataUtils from"./plugins/dataUtils.js";Checkboxland.extend(print),Checkboxland.extend(marquee),Checkboxland.extend(transitionWipe),Checkboxland.extend(dataUtils);export{Checkboxland}; | ||
import{Checkboxland}from"./checkboxland.js";import print from"./plugins/print/print.js";import marquee from"./plugins/marquee.js";import transitionWipe from"./plugins/transitionWipe.js";import dataUtils from"./plugins/dataUtils.js";import onClick from"./plugins/onClick.js";Checkboxland.extend(print),Checkboxland.extend(marquee),Checkboxland.extend(transitionWipe),Checkboxland.extend(dataUtils),Checkboxland.extend(onClick);export{Checkboxland}; | ||
//# sourceMappingURL=index.min.js.map |
@@ -515,2 +515,62 @@ class Checkboxland { | ||
let handleFun = null; | ||
let displayEl = null; | ||
function onClick(callback) { | ||
displayEl = this.displayEl; | ||
handleFun = handleEvent.bind(this, callback); | ||
displayEl.addEventListener('click', handleFun); | ||
} | ||
function handleEvent(callback, event) { | ||
const coords = findCoodrs(displayEl, event.target); | ||
if (!coords) { | ||
return; | ||
} | ||
const result = { | ||
x: coords.x, | ||
y: coords.y, | ||
checkbox: event.target | ||
}; | ||
if (typeof callback == 'function') { | ||
callback(result); | ||
} else if ('handleEvent' in callback && typeof callback.handleEvent == 'function') { | ||
callback.handleEvent(result); | ||
} else { | ||
throw new TypeError('Callback should be a function or an EventListener object'); | ||
} | ||
} | ||
function findCoodrs(root, target) { | ||
for (let y = 0; y < root.children.length; y += 1) { | ||
const div = root.children[y]; | ||
for (let x = 0; x < div.children.length; x += 1) { | ||
const checkbox = div.children[x]; | ||
if (checkbox === target) { | ||
return { | ||
x, | ||
y | ||
}; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
function cleanUp$2() { | ||
displayEl.removeEventListener('click', handleFun); | ||
} | ||
var onClick$1 = { | ||
name: 'onClick', | ||
exec: onClick, | ||
cleanUp: cleanUp$2 | ||
}; | ||
Checkboxland.extend(print$1); | ||
@@ -520,4 +580,5 @@ Checkboxland.extend(marquee$1); | ||
Checkboxland.extend(dataUtils$1); | ||
Checkboxland.extend(onClick$1); | ||
export { Checkboxland }; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
class Checkboxland{constructor(e={}){void 0!==e.fillValue&&_checkForValidValue(e.fillValue),this.displayEl=document.querySelector(e.selector||"#checkboxland"),this.dimensions=_textDimensionsToArray(e.dimensions||"8x8"),this._data=this.getEmptyMatrix({fillValue:e.fillValue||0}),_createInitialCheckboxDisplay(this.displayEl,this._data)}getCheckboxValue(e,t){if(!(e>=0&&t>=0&&e<this.dimensions[0]&&t<this.dimensions[1]))throw new Error(`The location (x: ${e}, y: ${t}) is outside of this checkbox display`);return this._data[t][e]}setCheckboxValue(e,t,i){const n=e>=0&&t>=0&&e<this.dimensions[0]&&t<this.dimensions[1];if(_checkForValidValue(i),!n)return;this._data[t][e]=i;const a=this.displayEl.children[t].children[e];if(2===i){if(a.indeterminate)return;a.indeterminate=!0,a.checked=!1}else{if(a.indeterminate&&(a.indeterminate=!1),a.checked===Boolean(i))return;a.checked=Boolean(i)}}getData(){return this._data.map(e=>e.slice())}setData(e,t={}){const{x:i=0,y:n=0,fillValue:a}=t,r=void 0!==a,l=this.dimensions[0],o=this.dimensions[1];_checkForValidMatrix(e);for(let t=0;t<o;t++)for(let o=0;o<l;o++){let l=o<i,s=t<n,c=o>=i+e[0].length,h=t>=n+e.length,d=l||s||c||h;if(d&&!r)continue;let u=d?a:e[t-n][o-i];this.setCheckboxValue(o,t,u)}}clearData(){const e=this.getEmptyMatrix();this.setData(e)}getEmptyMatrix(e={}){const{fillValue:t=0,width:i=this.dimensions[0],height:n=this.dimensions[1]}=e,a=[];for(let e=0;e<n;e++){a[e]=[];for(let n=0;n<i;n++)a[e][n]=t}return a}static extend(e={}){const{name:t,exec:i,cleanUp:n}=e;if(!t||!i)throw new Error('Your plugin must have a "name" and an "exec" function.');n&&(i.cleanUp=n),this.prototype[t]=i}}function _checkForValidValue(e){if(0!==e&&1!==e&&2!==e)throw new Error(`${e} is not a valid checkbox value.`)}function _checkForValidMatrix(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new Error(`${e} is not a valid matrix.`)}function _textDimensionsToArray(e){const t="The dimensions you provided are invalid.";if("string"!=typeof e)throw new Error(t);const i=e.split("x").map(e=>Number(e));if(!(2===i.length&&!isNaN(i[0])&&!isNaN(i[0])))throw new Error(t);return e.split("x").map(e=>Number(e))}function _createInitialCheckboxDisplay(e,t){e.innerHTML="",e.style.overflowX="auto",e.setAttribute("aria-hidden",!0),t.forEach(t=>{const i=document.createElement("div");i.style.lineHeight=.75,i.style.whiteSpace="nowrap",t.forEach(e=>{const t=document.createElement("input"),n=2===e,a=!n&&Boolean(e);t.style.margin=0,t.style.verticalAlign="top",t.type="checkbox",t.tabIndex="-1",t.checked=a,t.indeterminate=n,i.appendChild(t)}),e.appendChild(i)})}const fiveBySeven={0:[[0,1,1,1,0],[1,0,0,0,1],[1,0,0,1,1],[1,0,1,0,1],[1,1,0,0,1],[1,0,0,0,1],[0,1,1,1,0]],1:[[0,1,0],[1,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[1,1,1]],2:[[0,1,1,1,0],[1,0,0,0,1],[0,0,0,0,1],[0,1,1,1,0],[1,0,0,0,0],[1,0,0,0,0],[1,1,1,1,1]],3:[[1,1,1,1,1],[0,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0,0,0,0,1],[1,1,1,1,0],[0,0,1,0,0]],"%":[[1,1,0,0,1],[1,1,0,0,1],[0,0,0,1,0],[0,0,1,0,0],[0,1,0,0,0],[1,0,0,1,1],[1,0,0,1,1]],"^":[[0,0,1,0,0],[0,1,0,1,0],[1,0,0,0,1],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]],"&":[[0,1,1,0,0],[1,0,0,1,0],[1,0,1,0,0],[0,1,0,0,0],[1,0,1,0,1],[1,0,0,1,0],[1,1,1,0,1]],"*":[[0,0,0,0,0],[0,0,1,0,0],[1,0,1,0,1],[0,1,1,1,0],[1,0,1,0,1],[0,0,1,0,0],[0,0,0,0,0]],"(":[[0,0,1],[0,1,0],[1,0,0],[1,0,0],[1,0,0],[0,1,0],[0,0,1]],")":[[1,0,0],[0,1,0],[0,0,1],[0,0,1],[0,0,1],[0,1,0],[1,0,0]],"-":[[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[1,1,1,1,1],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]],_:[[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[1,1,1,1,1]],"+":[[0,0,0,0,0],[0,0,1,0,0],[0,0,1,0,0],[1,1,1,1,1],[0,0,1,0,0],[0,0,1,0,0],[0,0,0,0,0]],"=":[[0,0,0,0,0],[0,0,0,0,0],[1,1,1,1,1],[0,0,0,0,0],[1,1,1,1,1],[0,0,0,0,0],[0,0,0,0,0]],"[":[[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,1,1]],"]":[[1,1,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[1,1,1]],"{":[[0,0,1],[0,1,0],[0,1,0],[1,0,0],[0,1,0],[0,1,0],[0,0,1]],"}":[[1,0,0],[0,1,0],[0,1,0],[0,0,1],[0,1,0],[0,1,0],[1,0,0]],"|":[[1],[1],[1],[1],[1],[1],[1]],"\\":[[1,0,0],[1,0,0],[0,1,0],[0,1,0],[0,1,0],[0,0,1],[0,0,1]],"/":[[0,0,1],[0,0,1],[0,1,0],[0,1,0],[0,1,0],[1,0,0],[1,0,0]],";":[[0,0],[0,1],[0,1],[0,0],[0,0],[0,1],[1,0]],'"':[[1,0,1],[1,0,1],[1,0,1],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],"'":[[1,1],[0,1],[1,0],[0,0],[0,0],[0,0],[0,0]],",":[[0,0],[0,0],[0,0],[0,0],[1,1],[0,1],[1,0]],".":[[0],[0],[0],[0],[0],[0],[1]],"<":[[0,0,0],[0,0,1],[0,1,0],[1,0,0],[0,1,0],[0,0,1],[0,0,0]],">":[[0,0,0],[1,0,0],[0,1,0],[0,0,1],[0,1,0],[1,0,0],[0,0,0]],"?":[[0,1,1,1,0],[1,0,0,0,1],[0,0,0,0,1],[0,0,0,1,0],[0,0,1,0,0],[0,0,0,0,0],[0,0,1,0,0]]};function print(e,t={}){const{dataOnly:i=!1,font:n=fiveBySeven,x:a=0,y:r=0,fillValue:l}=t,o=void 0!==l,s=e.split("").reduce((e,t)=>{return _matrixConcat(e,n[t])},[]);if(0===s.length&&s.push([]),i){if(!o)return s;let e=this.getEmptyMatrix({fillValue:l});return s.forEach((t,i)=>{t.forEach((t,n)=>{e[i+r][n+a]=t})}),e}this.setData(s,{x:a,y:r,fillValue:l})}function _matrixConcat(e,t){if(0===e.length)return t;const i=[];return e.forEach((e,n)=>{i.push(e.concat([0]).concat(t[n]))}),i}var print$1={name:"print",exec:print};let intervalId;function marquee(e,t={}){const{interval:i=200,repeat:n=!1,fillValue:a=0,callback:r=(()=>{})}=t,l=this.dimensions[1],o=this.dimensions[0],s=o+e[0].length;let c=1;intervalId=setInterval(()=>{const t=this.getData();for(let i=0;i<l;i++)for(let n=0;n<o;n++){if(n+1===o){const t=c-(o-n),r=e[i]?void 0===e[i][t]?a:e[i][t]:a;this.setCheckboxValue(n,i,r)}else this.setCheckboxValue(n,i,t[i][n+1])}c===s?n?c=1:(clearInterval(intervalId),r()):c++},i)}function cleanUp(){clearInterval(intervalId)}var marquee$1={name:"marquee",exec:marquee,cleanUp:cleanUp};let intervalId$1;function transitionWipe(e,t={}){const{interval:i=200,fillValue:n=0,direction:a="ltr",callback:r=(()=>{})}=t,l=this.dimensions[1],o=this.dimensions[0],s=o+1;let c=1;intervalId$1=setInterval(()=>{let t,i;switch(a){case"ltr":i=(t=c-1)-1;break;case"rtl":i=(t=o-c)+1}for(let a=0;a<l;a++)for(let r=0;r<o;r++)if(r===t)this.setCheckboxValue(r,a,1);else if(r===i){let t=e[a]?void 0===e[a][r]?n:e[a][r]:n;this.setCheckboxValue(r,a,t)}c===s?(clearInterval(intervalId$1),r()):c++},i)}function cleanUp$1(){clearInterval(intervalId$1)}var transitionWipe$1={name:"transitionWipe",exec:transitionWipe,cleanUp:cleanUp$1};function dataUtils(e,t,i){return{invert:invert,pad:pad}[e](t,i)}function invert(e){return e.map(e=>e.map(e=>e?0:1))}function pad(e,t={}){const i=Number.isInteger(t.all),n=i?t.all:t.top,a=i?t.all:t.right,r=i?t.all:t.bottom,l=i?t.all:t.left;let o=e.map(e=>{let t=e;return l&&(t=[...Array(l).fill(0),...t]),a&&(t=[...t,...Array(a).fill(0)]),t});const s=o[0].length,c=(e,t)=>{const i=[];for(let n=0;n<e;n++)i.push(Array(t).fill(0));return i};return n&&(o=[...c(n,s),...o]),r&&(o=[...o,...c(r,s)]),o}var dataUtils$1={name:"dataUtils",exec:dataUtils};Checkboxland.extend(print$1),Checkboxland.extend(marquee$1),Checkboxland.extend(transitionWipe$1),Checkboxland.extend(dataUtils$1);export{Checkboxland}; | ||
class Checkboxland{constructor(e={}){void 0!==e.fillValue&&_checkForValidValue(e.fillValue),this.displayEl=document.querySelector(e.selector||"#checkboxland"),this.dimensions=_textDimensionsToArray(e.dimensions||"8x8"),this._data=this.getEmptyMatrix({fillValue:e.fillValue||0}),_createInitialCheckboxDisplay(this.displayEl,this._data)}getCheckboxValue(e,t){if(!(e>=0&&t>=0&&e<this.dimensions[0]&&t<this.dimensions[1]))throw new Error(`The location (x: ${e}, y: ${t}) is outside of this checkbox display`);return this._data[t][e]}setCheckboxValue(e,t,n){const i=e>=0&&t>=0&&e<this.dimensions[0]&&t<this.dimensions[1];if(_checkForValidValue(n),!i)return;this._data[t][e]=n;const a=this.displayEl.children[t].children[e];if(2===n){if(a.indeterminate)return;a.indeterminate=!0,a.checked=!1}else{if(a.indeterminate&&(a.indeterminate=!1),a.checked===Boolean(n))return;a.checked=Boolean(n)}}getData(){return this._data.map(e=>e.slice())}setData(e,t={}){const{x:n=0,y:i=0,fillValue:a}=t,l=void 0!==a,r=this.dimensions[0],o=this.dimensions[1];_checkForValidMatrix(e);for(let t=0;t<o;t++)for(let o=0;o<r;o++){let r=o<n,s=t<i,c=o>=n+e[0].length,d=t>=i+e.length,h=r||s||c||d;if(h&&!l)continue;let u=h?a:e[t-i][o-n];this.setCheckboxValue(o,t,u)}}clearData(){const e=this.getEmptyMatrix();this.setData(e)}getEmptyMatrix(e={}){const{fillValue:t=0,width:n=this.dimensions[0],height:i=this.dimensions[1]}=e,a=[];for(let e=0;e<i;e++){a[e]=[];for(let i=0;i<n;i++)a[e][i]=t}return a}static extend(e={}){const{name:t,exec:n,cleanUp:i}=e;if(!t||!n)throw new Error('Your plugin must have a "name" and an "exec" function.');i&&(n.cleanUp=i),this.prototype[t]=n}}function _checkForValidValue(e){if(0!==e&&1!==e&&2!==e)throw new Error(`${e} is not a valid checkbox value.`)}function _checkForValidMatrix(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new Error(`${e} is not a valid matrix.`)}function _textDimensionsToArray(e){const t="The dimensions you provided are invalid.";if("string"!=typeof e)throw new Error(t);const n=e.split("x").map(e=>Number(e));if(!(2===n.length&&!isNaN(n[0])&&!isNaN(n[0])))throw new Error(t);return e.split("x").map(e=>Number(e))}function _createInitialCheckboxDisplay(e,t){e.innerHTML="",e.style.overflowX="auto",e.setAttribute("aria-hidden",!0),t.forEach(t=>{const n=document.createElement("div");n.style.lineHeight=.75,n.style.whiteSpace="nowrap",t.forEach(e=>{const t=document.createElement("input"),i=2===e,a=!i&&Boolean(e);t.style.margin=0,t.style.verticalAlign="top",t.type="checkbox",t.tabIndex="-1",t.checked=a,t.indeterminate=i,n.appendChild(t)}),e.appendChild(n)})}const fiveBySeven={0:[[0,1,1,1,0],[1,0,0,0,1],[1,0,0,1,1],[1,0,1,0,1],[1,1,0,0,1],[1,0,0,0,1],[0,1,1,1,0]],1:[[0,1,0],[1,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[1,1,1]],2:[[0,1,1,1,0],[1,0,0,0,1],[0,0,0,0,1],[0,1,1,1,0],[1,0,0,0,0],[1,0,0,0,0],[1,1,1,1,1]],3:[[1,1,1,1,1],[0,0,0,0,1],[0,0,0,1,0],[0,0,1,1,0],[0,0,0,0,1],[1,0,0,0,1],[0,1,1,1,0]],4:[[1,0,0,0,1],[1,0,0,0,1],[1,0,0,0,1],[0,1,1,1,1],[0,0,0,0,1],[0,0,0,0,1],[0,0,0,0,1]],5:[[1,1,1,1,1],[1,0,0,0,0],[1,0,0,0,0],[1,1,1,1,0],[0,0,0,0,1],[1,0,0,0,1],[0,1,1,1,0]],6:[[0,0,1,1,0],[0,1,0,0,0],[1,0,0,0,0],[1,1,1,1,0],[1,0,0,0,1],[1,0,0,0,1],[0,1,1,1,0]],7:[[1,1,1,1,1],[0,0,0,0,1],[0,0,0,1,0],[0,0,1,0,0],[0,1,0,0,0],[0,1,0,0,0],[0,1,0,0,0]],8:[[0,1,1,1,0],[1,0,0,0,1],[1,0,0,0,1],[0,1,1,1,0],[1,0,0,0,1],[1,0,0,0,1],[0,1,1,1,0]],9:[[0,1,1,1,0],[1,0,0,0,1],[1,0,0,0,1],[0,1,1,1,1],[0,0,0,0,1],[0,0,0,1,0],[0,1,1,0,0]],":":[[0],[1],[0],[0],[0],[1],[0]]," ":[[0,0,0,0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,0,0,0],[1,1,1,1,1],[0,0,0,1,0],[0,0,1,0,0],[0,1,0,0,0],[1,1,1,1,1]],"`":[[1,0,0],[0,1,0],[0,0,1],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],"~":[[0,0,0,0,0],[0,0,0,0,0],[0,1,0,0,0],[1,0,1,0,1],[0,0,0,1,0],[0,0,0,0,0],[0,0,0,0,0]],"!":[[1],[1],[1],[1],[1],[0],[1]],"@":[[0,1,1,1,0],[1,0,0,0,1],[0,0,0,0,1],[0,1,1,0,1],[1,0,1,0,1],[1,0,1,0,1],[0,1,1,1,0]],"#":[[0,1,0,1,0],[0,1,0,1,0],[1,1,1,1,1],[0,1,0,1,0],[1,1,1,1,1],[0,1,0,1,0],[0,1,0,1,0]],$:[[0,0,1,0,0],[0,1,1,1,1],[1,0,0,0,0],[0,1,1,1,0],[0,0,0,0,1],[1,1,1,1,0],[0,0,1,0,0]],"%":[[1,1,0,0,1],[1,1,0,0,1],[0,0,0,1,0],[0,0,1,0,0],[0,1,0,0,0],[1,0,0,1,1],[1,0,0,1,1]],"^":[[0,0,1,0,0],[0,1,0,1,0],[1,0,0,0,1],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]],"&":[[0,1,1,0,0],[1,0,0,1,0],[1,0,1,0,0],[0,1,0,0,0],[1,0,1,0,1],[1,0,0,1,0],[1,1,1,0,1]],"*":[[0,0,0,0,0],[0,0,1,0,0],[1,0,1,0,1],[0,1,1,1,0],[1,0,1,0,1],[0,0,1,0,0],[0,0,0,0,0]],"(":[[0,0,1],[0,1,0],[1,0,0],[1,0,0],[1,0,0],[0,1,0],[0,0,1]],")":[[1,0,0],[0,1,0],[0,0,1],[0,0,1],[0,0,1],[0,1,0],[1,0,0]],"-":[[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[1,1,1,1,1],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]],_:[[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[1,1,1,1,1]],"+":[[0,0,0,0,0],[0,0,1,0,0],[0,0,1,0,0],[1,1,1,1,1],[0,0,1,0,0],[0,0,1,0,0],[0,0,0,0,0]],"=":[[0,0,0,0,0],[0,0,0,0,0],[1,1,1,1,1],[0,0,0,0,0],[1,1,1,1,1],[0,0,0,0,0],[0,0,0,0,0]],"[":[[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,1,1]],"]":[[1,1,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[1,1,1]],"{":[[0,0,1],[0,1,0],[0,1,0],[1,0,0],[0,1,0],[0,1,0],[0,0,1]],"}":[[1,0,0],[0,1,0],[0,1,0],[0,0,1],[0,1,0],[0,1,0],[1,0,0]],"|":[[1],[1],[1],[1],[1],[1],[1]],"\\":[[1,0,0],[1,0,0],[0,1,0],[0,1,0],[0,1,0],[0,0,1],[0,0,1]],"/":[[0,0,1],[0,0,1],[0,1,0],[0,1,0],[0,1,0],[1,0,0],[1,0,0]],";":[[0,0],[0,1],[0,1],[0,0],[0,0],[0,1],[1,0]],'"':[[1,0,1],[1,0,1],[1,0,1],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],"'":[[1,1],[0,1],[1,0],[0,0],[0,0],[0,0],[0,0]],",":[[0,0],[0,0],[0,0],[0,0],[1,1],[0,1],[1,0]],".":[[0],[0],[0],[0],[0],[0],[1]],"<":[[0,0,0],[0,0,1],[0,1,0],[1,0,0],[0,1,0],[0,0,1],[0,0,0]],">":[[0,0,0],[1,0,0],[0,1,0],[0,0,1],[0,1,0],[1,0,0],[0,0,0]],"?":[[0,1,1,1,0],[1,0,0,0,1],[0,0,0,0,1],[0,0,0,1,0],[0,0,1,0,0],[0,0,0,0,0],[0,0,1,0,0]]};function print(e,t={}){const{dataOnly:n=!1,font:i=fiveBySeven,x:a=0,y:l=0,fillValue:r}=t,o=void 0!==r,s=e.split("").reduce((e,t)=>{return _matrixConcat(e,i[t])},[]);if(0===s.length&&s.push([]),n){if(!o)return s;let e=this.getEmptyMatrix({fillValue:r});return s.forEach((t,n)=>{t.forEach((t,i)=>{e[n+l][i+a]=t})}),e}this.setData(s,{x:a,y:l,fillValue:r})}function _matrixConcat(e,t){if(0===e.length)return t;const n=[];return e.forEach((e,i)=>{n.push(e.concat([0]).concat(t[i]))}),n}var print$1={name:"print",exec:print};let intervalId;function marquee(e,t={}){const{interval:n=200,repeat:i=!1,fillValue:a=0,callback:l=(()=>{})}=t,r=this.dimensions[1],o=this.dimensions[0],s=o+e[0].length;let c=1;intervalId=setInterval(()=>{const t=this.getData();for(let n=0;n<r;n++)for(let i=0;i<o;i++){if(i+1===o){const t=c-(o-i),l=e[n]?void 0===e[n][t]?a:e[n][t]:a;this.setCheckboxValue(i,n,l)}else this.setCheckboxValue(i,n,t[n][i+1])}c===s?i?c=1:(clearInterval(intervalId),l()):c++},n)}function cleanUp(){clearInterval(intervalId)}var marquee$1={name:"marquee",exec:marquee,cleanUp:cleanUp};let intervalId$1;function transitionWipe(e,t={}){const{interval:n=200,fillValue:i=0,direction:a="ltr",callback:l=(()=>{})}=t,r=this.dimensions[1],o=this.dimensions[0],s=o+1;let c=1;intervalId$1=setInterval(()=>{let t,n;switch(a){case"ltr":n=(t=c-1)-1;break;case"rtl":n=(t=o-c)+1}for(let a=0;a<r;a++)for(let l=0;l<o;l++)if(l===t)this.setCheckboxValue(l,a,1);else if(l===n){let t=e[a]?void 0===e[a][l]?i:e[a][l]:i;this.setCheckboxValue(l,a,t)}c===s?(clearInterval(intervalId$1),l()):c++},n)}function cleanUp$1(){clearInterval(intervalId$1)}var transitionWipe$1={name:"transitionWipe",exec:transitionWipe,cleanUp:cleanUp$1};function dataUtils(e,t,n){return{invert:invert,pad:pad}[e](t,n)}function invert(e){return e.map(e=>e.map(e=>e?0:1))}function pad(e,t={}){const n=Number.isInteger(t.all),i=n?t.all:t.top,a=n?t.all:t.right,l=n?t.all:t.bottom,r=n?t.all:t.left;let o=e.map(e=>{let t=e;return r&&(t=[...Array(r).fill(0),...t]),a&&(t=[...t,...Array(a).fill(0)]),t});const s=o[0].length,c=(e,t)=>{const n=[];for(let i=0;i<e;i++)n.push(Array(t).fill(0));return n};return i&&(o=[...c(i,s),...o]),l&&(o=[...o,...c(l,s)]),o}var dataUtils$1={name:"dataUtils",exec:dataUtils};let handleFun=null,displayEl=null;function onClick(e){displayEl=this.displayEl,handleFun=handleEvent.bind(this,e),displayEl.addEventListener("click",handleFun)}function handleEvent(e,t){const n=findCoodrs(displayEl,t.target);if(!n)return;const i={x:n.x,y:n.y,checkbox:t.target};if("function"==typeof e)e(i);else{if(!("handleEvent"in e&&"function"==typeof e.handleEvent))throw new TypeError("Callback should be a function or an EventListener object");e.handleEvent(i)}}function findCoodrs(e,t){for(let n=0;n<e.children.length;n+=1){const i=e.children[n];for(let e=0;e<i.children.length;e+=1){if(i.children[e]===t)return{x:e,y:n}}}return null}function cleanUp$2(){displayEl.removeEventListener("click",handleFun)}var onClick$1={name:"onClick",exec:onClick,cleanUp:cleanUp$2};Checkboxland.extend(print$1),Checkboxland.extend(marquee$1),Checkboxland.extend(transitionWipe$1),Checkboxland.extend(dataUtils$1),Checkboxland.extend(onClick$1);export{Checkboxland}; | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "checkboxland", | ||
"description": "Render anything as HTML checkboxes", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
179826
26
1293