checkboxland
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -14,18 +14,19 @@ export class Checkboxland { | ||
getCheckboxValue(x, y) { | ||
// @todo: needs a isWithinDisplay check. | ||
return this._data[y][x]; | ||
} | ||
setCheckboxValue(x, y, val) { | ||
const isValueValid = val === 0 || val === 1; | ||
setCheckboxValue(x, y, value) { | ||
const isValueValid = value === 0 || value === 1; | ||
const isWithinDisplay = typeof this._data[y] !== 'undefined' && typeof this._data[y][x] !== 'undefined'; | ||
if (!isValueValid) { | ||
throw new Error(`${val} is not a valid checkbox value`); | ||
throw new Error(`${value} is not a valid checkbox value`); | ||
} | ||
if (!isWithinDisplay) return; | ||
this._data[y][x] = val; // We can assume the checkboxEl exists because it's within the display. | ||
this._data[y][x] = value; // We can assume the checkboxEl exists because it's within the display. | ||
const checkboxEl = this.displayEl.children[y].children[x]; | ||
const isCellChecked = Boolean(val); | ||
const isCellChecked = Boolean(value); | ||
if (checkboxEl.checked === isCellChecked) return; | ||
@@ -91,2 +92,3 @@ checkboxEl.checked = isCellChecked; | ||
displayEl.style.overflowX = 'auto'; | ||
displayEl.setAttribute('aria-hidden', true); | ||
data.forEach(rowData => { | ||
@@ -101,2 +103,3 @@ const rowEl = document.createElement('div'); | ||
checkboxEl.type = 'checkbox'; | ||
checkboxEl.tabIndex = '-1'; | ||
rowEl.appendChild(checkboxEl); | ||
@@ -103,0 +106,0 @@ }); |
@@ -17,8 +17,8 @@ export function dataUtils(actionName, matrix, options) { | ||
function pad(matrix, options = 1) { | ||
const isPaddingAllSidesEqually = Number.isInteger(options); | ||
const topPadding = isPaddingAllSidesEqually ? options : options.top; | ||
const rightPadding = isPaddingAllSidesEqually ? options : options.right; | ||
const bottomPadding = isPaddingAllSidesEqually ? options : options.bottom; | ||
const leftPadding = isPaddingAllSidesEqually ? options : options.left; // Create a new matrix with left and right padding. | ||
function pad(matrix, options = {}) { | ||
const isPaddingAllSidesEqually = Number.isInteger(options.all); | ||
const topPadding = isPaddingAllSidesEqually ? options.all : options.top; | ||
const rightPadding = isPaddingAllSidesEqually ? options.all : options.right; | ||
const bottomPadding = isPaddingAllSidesEqually ? options.all : options.bottom; | ||
const leftPadding = isPaddingAllSidesEqually ? options.all : options.left; // Create a new matrix with left and right padding. | ||
@@ -25,0 +25,0 @@ let newMatrix = matrix.map(row => { |
export function marquee(newData, options = {}) { | ||
const { | ||
interval = 500, | ||
interval = 200, | ||
repeat = false, | ||
@@ -5,0 +5,0 @@ fillValue = 0, |
export function transitionWipe(newData, options = {}) { | ||
const { | ||
interval = 120, | ||
interval = 200, | ||
fillValue = 0, | ||
@@ -5,0 +5,0 @@ direction = 'ltr', |
@@ -8,3 +8,3 @@ export class Checkboxland { | ||
getCheckboxValue(x: any, y: any): any; | ||
setCheckboxValue(x: any, y: any, val: any): void; | ||
setCheckboxValue(x: any, y: any, value: any): void; | ||
getData(): any[][]; | ||
@@ -11,0 +11,0 @@ setData(data: any): void; |
@@ -14,18 +14,19 @@ class Checkboxland { | ||
getCheckboxValue(x, y) { | ||
// @todo: needs a isWithinDisplay check. | ||
return this._data[y][x]; | ||
} | ||
setCheckboxValue(x, y, val) { | ||
const isValueValid = val === 0 || val === 1; | ||
setCheckboxValue(x, y, value) { | ||
const isValueValid = value === 0 || value === 1; | ||
const isWithinDisplay = typeof this._data[y] !== 'undefined' && typeof this._data[y][x] !== 'undefined'; | ||
if (!isValueValid) { | ||
throw new Error(`${val} is not a valid checkbox value`); | ||
throw new Error(`${value} is not a valid checkbox value`); | ||
} | ||
if (!isWithinDisplay) return; | ||
this._data[y][x] = val; // We can assume the checkboxEl exists because it's within the display. | ||
this._data[y][x] = value; // We can assume the checkboxEl exists because it's within the display. | ||
const checkboxEl = this.displayEl.children[y].children[x]; | ||
const isCellChecked = Boolean(val); | ||
const isCellChecked = Boolean(value); | ||
if (checkboxEl.checked === isCellChecked) return; | ||
@@ -91,2 +92,3 @@ checkboxEl.checked = isCellChecked; | ||
displayEl.style.overflowX = 'auto'; | ||
displayEl.setAttribute('aria-hidden', true); | ||
data.forEach(rowData => { | ||
@@ -101,2 +103,3 @@ const rowEl = document.createElement('div'); | ||
checkboxEl.type = 'checkbox'; | ||
checkboxEl.tabIndex = '-1'; | ||
rowEl.appendChild(checkboxEl); | ||
@@ -234,3 +237,3 @@ }); | ||
const { | ||
interval = 500, | ||
interval = 200, | ||
repeat = false, | ||
@@ -280,3 +283,3 @@ fillValue = 0, | ||
const { | ||
interval = 120, | ||
interval = 200, | ||
fillValue = 0, | ||
@@ -345,8 +348,8 @@ direction = 'ltr', | ||
function pad(matrix, options = 1) { | ||
const isPaddingAllSidesEqually = Number.isInteger(options); | ||
const topPadding = isPaddingAllSidesEqually ? options : options.top; | ||
const rightPadding = isPaddingAllSidesEqually ? options : options.right; | ||
const bottomPadding = isPaddingAllSidesEqually ? options : options.bottom; | ||
const leftPadding = isPaddingAllSidesEqually ? options : options.left; // Create a new matrix with left and right padding. | ||
function pad(matrix, options = {}) { | ||
const isPaddingAllSidesEqually = Number.isInteger(options.all); | ||
const topPadding = isPaddingAllSidesEqually ? options.all : options.top; | ||
const rightPadding = isPaddingAllSidesEqually ? options.all : options.right; | ||
const bottomPadding = isPaddingAllSidesEqually ? options.all : options.bottom; | ||
const leftPadding = isPaddingAllSidesEqually ? options.all : options.left; // Create a new matrix with left and right padding. | ||
@@ -353,0 +356,0 @@ let newMatrix = matrix.map(row => { |
@@ -1,2 +0,2 @@ | ||
class Checkboxland{constructor(t={}){this.displayEl=document.querySelector(t.selector||"#checkboxland"),this.dimensions=_textDimensionsToArray(t.dimensions||"8x8"),this._data=_getEmptyMatrix(this.dimensions[0],this.dimensions[1]),_createInitialCheckboxDisplay(this.displayEl,this._data)}getCheckboxValue(t,e){return this._data[e][t]}setCheckboxValue(t,e,n){const i=0===n||1===n,a=void 0!==this._data[e]&&void 0!==this._data[e][t];if(!i)throw new Error(`${n} is not a valid checkbox value`);if(!a)return;this._data[e][t]=n;const r=this.displayEl.children[e].children[t],o=Boolean(n);r.checked!==o&&(r.checked=o)}getData(){return this._data.map(t=>t.slice())}setData(t){t.forEach((t,e)=>{t.forEach((t,n)=>{this.setCheckboxValue(n,e,t)})})}clearData(){const t=_getEmptyMatrix(this.dimensions[0],this.dimensions[1]);this.setData(t)}static extend(t){if(!t.name)throw new Error('Your plugin must be a function with a "name" property.');this.prototype[t.name]=t}}function _getEmptyMatrix(t,e){const n=[];for(let i=0;i<e;i++){n[i]=[];for(let e=0;e<t;e++)n[i][e]=0}return n}function _textDimensionsToArray(t){const e="The dimensions you provided are invalid.";if("string"!=typeof t)throw new Error(e);const n=t.split("x").map(t=>Number(t));if(!(2===n.length&&!isNaN(n[0])&&!isNaN(n[0])))throw new Error(e);return t.split("x").map(t=>Number(t))}function _createInitialCheckboxDisplay(t,e){t.innerHTML="",t.style.overflowX="auto",e.forEach(e=>{const n=document.createElement("div");n.style.lineHeight=.75,n.style.whiteSpace="nowrap",e.forEach(t=>{const e=document.createElement("input");e.style.margin=0,e.style.verticalAlign="top",e.type="checkbox",n.appendChild(e)}),t.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,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]],v:[[0,0,0,0,0],[0,0,0,0,0],[1,0,0,0,1],[1,0,0,0,1],[1,0,0,0,1],[0,1,0,1,0],[0,0,1,0,0]],w:[[0,0,0,0,0],[0,0,0,0,0],[1,0,0,0,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,1,0,1],[0,1,0,1,0]],x:[[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,1,0,1,0],[1,0,0,0,1]],y:[[0,0,0,0,0],[0,0,0,0,0],[1,0,0,0,1],[1,0,0,0,1],[0,1,1,1,1],[0,0,0,0,1],[0,1,1,1,0]],z:[[0,0,0,0,0],[0,0,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(t,e={}){const n=t.split(""),i=e.font||fiveBySeven,a=n.reduce((t,e)=>{return _matrixConcat(t,i[e])},[]);if(e.dataOnly)return a;this.setData(a)}function _matrixConcat(t,e){if(0===t.length)return e;const n=[];return t.forEach((t,i)=>{n.push(t.concat([0]).concat(e[i]))}),n}function marquee(t,e={}){const{interval:n=500,repeat:i=!1,fillValue:a=0,callback:r=(()=>{})}=e,o=this.dimensions[1],s=this.dimensions[0],l=s+t[0].length;let c=1;const h=setInterval(()=>{const e=this.getData();for(let n=0;n<o;n++)for(let i=0;i<s;i++){if(i+1===s){const e=c-(s-i),r=t[n]?void 0===t[n][e]?a:t[n][e]:a;this.setCheckboxValue(i,n,r)}else this.setCheckboxValue(i,n,e[n][i+1])}c===l?i?c=1:(clearInterval(h),r()):c++},n)}function transitionWipe(t,e={}){const{interval:n=120,fillValue:i=0,direction:a="ltr",callback:r=(()=>{})}=e,o=this.dimensions[1],s=this.dimensions[0],l=s+1;let c=1;const h=setInterval(()=>{let e,n;switch(a){case"ltr":n=(e=c-1)-1;break;case"rtl":n=(e=s-c)+1}for(let a=0;a<o;a++)for(let r=0;r<s;r++)if(r===e)this.setCheckboxValue(r,a,1);else if(r===n){let e=t[a]?void 0===t[a][r]?i:t[a][r]:i;this.setCheckboxValue(r,a,e)}c===l?(clearInterval(h),r()):c++},n)}function dataUtils(t,e,n){return{invert:invert,pad:pad}[t](e,n)}function invert(t){return t.map(t=>t.map(t=>t?0:1))}function pad(t,e=1){const n=Number.isInteger(e),i=n?e:e.top,a=n?e:e.right,r=n?e:e.bottom,o=n?e:e.left;let s=t.map(t=>{let e=t;return o&&(e=[...Array(o).fill(0),...e]),a&&(e=[...e,...Array(a).fill(0)]),e});const l=s[0].length,c=(t,e)=>{const n=[];for(let i=0;i<t;i++)n.push(Array(e).fill(0));return n};return i&&(s=[...c(i,l),...s]),r&&(s=[...s,...c(r,l)]),s}Checkboxland.extend(print),Checkboxland.extend(marquee),Checkboxland.extend(transitionWipe),Checkboxland.extend(dataUtils);export{Checkboxland}; | ||
class Checkboxland{constructor(t={}){this.displayEl=document.querySelector(t.selector||"#checkboxland"),this.dimensions=_textDimensionsToArray(t.dimensions||"8x8"),this._data=_getEmptyMatrix(this.dimensions[0],this.dimensions[1]),_createInitialCheckboxDisplay(this.displayEl,this._data)}getCheckboxValue(t,e){return this._data[e][t]}setCheckboxValue(t,e,n){const i=0===n||1===n,a=void 0!==this._data[e]&&void 0!==this._data[e][t];if(!i)throw new Error(`${n} is not a valid checkbox value`);if(!a)return;this._data[e][t]=n;const r=this.displayEl.children[e].children[t],o=Boolean(n);r.checked!==o&&(r.checked=o)}getData(){return this._data.map(t=>t.slice())}setData(t){t.forEach((t,e)=>{t.forEach((t,n)=>{this.setCheckboxValue(n,e,t)})})}clearData(){const t=_getEmptyMatrix(this.dimensions[0],this.dimensions[1]);this.setData(t)}static extend(t){if(!t.name)throw new Error('Your plugin must be a function with a "name" property.');this.prototype[t.name]=t}}function _getEmptyMatrix(t,e){const n=[];for(let i=0;i<e;i++){n[i]=[];for(let e=0;e<t;e++)n[i][e]=0}return n}function _textDimensionsToArray(t){const e="The dimensions you provided are invalid.";if("string"!=typeof t)throw new Error(e);const n=t.split("x").map(t=>Number(t));if(!(2===n.length&&!isNaN(n[0])&&!isNaN(n[0])))throw new Error(e);return t.split("x").map(t=>Number(t))}function _createInitialCheckboxDisplay(t,e){t.innerHTML="",t.style.overflowX="auto",t.setAttribute("aria-hidden",!0),e.forEach(e=>{const n=document.createElement("div");n.style.lineHeight=.75,n.style.whiteSpace="nowrap",e.forEach(t=>{const e=document.createElement("input");e.style.margin=0,e.style.verticalAlign="top",e.type="checkbox",e.tabIndex="-1",n.appendChild(e)}),t.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],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],A:[[0,1,1,1,0],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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(t,e={}){const n=t.split(""),i=e.font||fiveBySeven,a=n.reduce((t,e)=>{return _matrixConcat(t,i[e])},[]);if(e.dataOnly)return a;this.setData(a)}function _matrixConcat(t,e){if(0===t.length)return e;const n=[];return t.forEach((t,i)=>{n.push(t.concat([0]).concat(e[i]))}),n}function marquee(t,e={}){const{interval:n=200,repeat:i=!1,fillValue:a=0,callback:r=(()=>{})}=e,o=this.dimensions[1],s=this.dimensions[0],l=s+t[0].length;let c=1;const h=setInterval(()=>{const e=this.getData();for(let n=0;n<o;n++)for(let i=0;i<s;i++){if(i+1===s){const e=c-(s-i),r=t[n]?void 0===t[n][e]?a:t[n][e]:a;this.setCheckboxValue(i,n,r)}else this.setCheckboxValue(i,n,e[n][i+1])}c===l?i?c=1:(clearInterval(h),r()):c++},n)}function transitionWipe(t,e={}){const{interval:n=200,fillValue:i=0,direction:a="ltr",callback:r=(()=>{})}=e,o=this.dimensions[1],s=this.dimensions[0],l=s+1;let c=1;const h=setInterval(()=>{let e,n;switch(a){case"ltr":n=(e=c-1)-1;break;case"rtl":n=(e=s-c)+1}for(let a=0;a<o;a++)for(let r=0;r<s;r++)if(r===e)this.setCheckboxValue(r,a,1);else if(r===n){let e=t[a]?void 0===t[a][r]?i:t[a][r]:i;this.setCheckboxValue(r,a,e)}c===l?(clearInterval(h),r()):c++},n)}function dataUtils(t,e,n){return{invert:invert,pad:pad}[t](e,n)}function invert(t){return t.map(t=>t.map(t=>t?0:1))}function pad(t,e={}){const n=Number.isInteger(e.all),i=n?e.all:e.top,a=n?e.all:e.right,r=n?e.all:e.bottom,o=n?e.all:e.left;let s=t.map(t=>{let e=t;return o&&(e=[...Array(o).fill(0),...e]),a&&(e=[...e,...Array(a).fill(0)]),e});const l=s[0].length,c=(t,e)=>{const n=[];for(let i=0;i<t;i++)n.push(Array(e).fill(0));return n};return i&&(s=[...c(i,l),...s]),r&&(s=[...s,...c(r,l)]),s}Checkboxland.extend(print),Checkboxland.extend(marquee),Checkboxland.extend(transitionWipe),Checkboxland.extend(dataUtils);export{Checkboxland}; | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "checkboxland", | ||
"description": "Render anything as HTML checkboxes", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
@@ -5,1 +5,46 @@ # Checkboxland | ||
Checkboxland is a JavaScript library for rendering things as HTML checkboxes, and embedding them in a webpage. | ||
You can use it to display animations, text, and arbitrary data. It also supports plugins, so you can build more powerful APIs on top of it. | ||
Checkboxland is dependency-free, framework-agnostic, and fun! 🙃 | ||
**[For more details see the docs.](https://bryanbraun.com/checkboxland)** | ||
## Setup | ||
Install this package via npm: | ||
``` | ||
npm install checkboxland | ||
``` | ||
## Example | ||
Import it into your application, and create a checkbox grid: | ||
``` | ||
import { Checkboxland } from 'checkboxland'; | ||
const cbl = new Checkboxland({ dimensions: '8x7', selector: '#my-container' }); | ||
// Create a data representation of the heart. | ||
const heart = [ | ||
[0,1,1,0,0,1,1,0], | ||
[1,0,0,1,1,0,0,1], | ||
[1,0,0,0,0,0,0,1], | ||
[1,0,0,0,0,0,0,1], | ||
[0,1,0,0,0,0,1,0], | ||
[0,0,1,0,0,1,0,0], | ||
[0,0,0,1,1,0,0,0], | ||
]; | ||
// This updates the grid with the data we provided. | ||
cbl.setData(heart); | ||
``` | ||
<img src="docs/img/checkbox-heart.png" style="width:115px; height:102px" alt="a grid of checkboxes displaying the shape of a heart" /> | ||
## License | ||
MIT |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
153180
942
50