function formatTable(
data,
props,
opts = {}
) {
const options = Object.assign(
{
dateFormat: (datum, path) => isoformat.format(datum),
format: (datum, path) => datum,
height: 274,
width: null
},
opts
);
const minHeight = 33;
let { height, width } = options;
const copy = cleanseData(data, options);
height = height > minHeight ? height : null;
const generateHTMLTableoptions = {
attributes: {
table: {
style: `
max-width: initial;
${minHeight != null ? `min-height: ${length(minHeight)};` : ""}
margin: 0;
border-spacing: 0;
font-variant-numeric: tabular-nums;`
},
th: {
style: `padding: 3px 6.5px; position: sticky; top: 0; background: #fff;`
},
td: {
style: `padding: 3px 6.5px`
}
}
};
return html`<div style="overflow-x: auto;${
height ? `max-height: ${height}px;` : ""
}${width != null ? `width: ${length(width)};` : ""}">
${json2table.generateHTMLTable(copy, props, generateHTMLTableoptions)}
</div>`;
}