handsontable = (options = {}, update) => {
const height = Math.min(options.data.length * 22 + 42, 600);
const element = html`<div style="padding-bottom: 15px; ${
options.style || ""
};" />`;
const hot = Handsontable(element, {
width: "100%",
height,
licenseKey: "non-commercial-and-evaluation",
data: options.data,
outsideClickDeselects: false,
...options
});
const updateElement = () => {
element.value = hot.getSourceData() || [];
element.dispatchEvent(new CustomEvent("input"));
};
hot.updateSettings({
afterRender: () => {
hot.view.activeWt.wtOverlays?.updateMainScrollableElements();
},
afterChange: (changes, source) => {
updateElement(changes, source);
}
});
element.hot = hot;
element.value = hot.getSourceData() || [];
invalidation.then(() => element.hot.destroy());
setTimeout(() => {
element.hot.refreshDimensions();
}, 30);
return element;
}