Files
sigpro-ui/components/discarted/table.js
natxocc 2f877a9537
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 3s
update editor and components
2026-04-26 02:39:27 +02:00

30 lines
919 B
JavaScript

// components/Table.js
import { h, each } from "sigpro";
export const Table = (props, children) => {
children === undefined && (children = props, props = {});
return h("table", { ...props, class: `table ${props.class ?? ''}` }, children);
};
export const TableItems = (props) => {
const itemArray = typeof props.items === "function" ? props.items() : (props.items || []);
const thead = props.header !== false && props.columns?.some(col => col.label) ?
h("thead", {},
h("tr", {},
props.columns.map(col => h("th", { class: col.class }, col.label))
)
) : null;
const tbody = h("tbody", {}, [
each(itemArray, (item, idx) =>
h("tr", {},
props.columns.map(col => {
const content = col.render ? col.render(item, idx) : item[col.key];
return h("td", { class: col.class }, content);
})
))
]);
return [thead, tbody];
};