function ImageLoader({ width = 50, files = [] } = {}) {
const filesIn = Inputs.file({
multiple: true,
accept: ".jpg, .png,.tiff,.png"
});
const thumbsHolder = htl.html`<output></output>`;
const target = htl.html`<div>
${filesIn}
<div>
<style>
img {
max-width: 50px;
max-height: 50px;
}
</style>
${thumbsHolder}
</div>
</div>`;
async function showValue() {
const thumbs = htl.html`${await Promise.all(widget.value.map((i) => i.image()))}`;
thumbsHolder.innerHTML = "";
thumbsHolder.appendChild(thumbs);
}
const widget = ReactiveWidget(target, {
value: files,
showValue
});
filesIn.oninput = (evt) => {
evt.stopPropagation();
evt.preventDefault();
widget.setValue(filesIn.value);
};
return widget;
}