15 lines
729 B
JavaScript
15 lines
729 B
JavaScript
import { h } from '/static/admin2/vendor/preact.module.js';
|
|
import htm from '/static/admin2/vendor/htm.module.js';
|
|
const html = htm.bind(h);
|
|
|
|
export const Table = ({ columns, rows, empty = 'Никого не нашлось' }) => html`
|
|
<div class="table-wrap">
|
|
<table>
|
|
<thead><tr>${columns.map((c) => html`<th key=${c.key} class=${c.num ? 'num' : ''}>${c.label}</th>`)}</tr></thead>
|
|
<tbody>${rows.length ? rows.map((row) => html`
|
|
<tr key=${row.key}>${columns.map((c) => html`
|
|
<td key=${c.key} class=${c.num ? 'num' : ''}>${c.render ? c.render(row) : row[c.key]}</td>`)}</tr>`)
|
|
: html`<tr><td colSpan=${columns.length} class="empty">${empty}</td></tr>`}</tbody>
|
|
</table>
|
|
</div>`;
|