function dashboard(view) {
const regions = new Map(Array.from(view.querySelectorAll('[data-region]'), n => [n.dataset.region, {
node: n,
template: n.dataset.template || '<div>',
}]));
view.oninput = view.onchange = view.onclick = e => e.stopImmediatePropagation();
view.value = function(region, content, invalidate) {
const {node, template} = regions.get(region);
const item = html`${template}${content}`;
node.appendChild(item);
const remove = () => { if(item.parentNode === node) node.removeChild(item) };
if(invalidate) invalidate.then(remove);
return remove;
};
return view;
}