const preact = require('preact'); // const key = require('keymaster'); function convertVar(v) { return v || ''; } function Vbox(args) { const { instance, combiner, setCombiner, sendVboxAccept, sendVboxDiscard, sendVboxReclaim, sendVboxCombine, } = args; const { vbox } = instance; if (!instance.vbox) return false; // lots of rubbish to make it flow nice function combinerAdd(i) { if (combiner.indexOf(i) === -1) { const insert = combiner.findIndex(j => j === null); combiner[insert] = i; return setCombiner(combiner); } return setCombiner([i, null, null]); } function combinerRmv(i) { combiner[i] = null; return setCombiner(combiner); } const free = []; for (let i = 0 ; i < 6; i++) { free.push([vbox.free[0][i], vbox.free[1][i], vbox.free[2][i]]); } const freeRows = free.map((row, i) => { const cells = row.map((c, j) => (
| combinerRmv(0)}>{convertVar(vbox.bound[combiner[0]])} | combinerRmv(1)}>{convertVar(vbox.bound[combiner[1]])} | combinerRmv(2)}>{convertVar(vbox.bound[combiner[2]])} |