changed to new functions
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 3s
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 3s
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
// components/Table.js
|
||||
import { Tag, For } from "sigpro";
|
||||
import { h, each } from "sigpro";
|
||||
|
||||
export const Table = (props, children) => {
|
||||
children === undefined && (children = props, props = {});
|
||||
return Tag("table", { ...props, class: `table ${props.class ?? ''}` }, children);
|
||||
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) ?
|
||||
Tag("thead", {},
|
||||
Tag("tr", {},
|
||||
props.columns.map(col => Tag("th", { class: col.class }, col.label))
|
||||
h("thead", {},
|
||||
h("tr", {},
|
||||
props.columns.map(col => h("th", { class: col.class }, col.label))
|
||||
)
|
||||
) : null;
|
||||
|
||||
const tbody = Tag("tbody", {}, [
|
||||
For(itemArray, (item, idx) =>
|
||||
Tag("tr", {},
|
||||
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 Tag("td", { class: col.class }, content);
|
||||
return h("td", { class: col.class }, content);
|
||||
})
|
||||
)
|
||||
, props.keyFn || ((item, idx) => item.id ?? idx))
|
||||
|
||||
Reference in New Issue
Block a user