2021-11-22 19:22:54 +01:00
|
|
|
import '@material/mwc-checkbox';
|
|
|
|
|
|
|
|
import {
|
|
|
|
type Children,
|
|
|
|
type Vnode
|
|
|
|
} from 'mithril';
|
|
|
|
|
2021-09-29 15:32:31 +02:00
|
|
|
import Component from '../Component.jsx';
|
2021-11-22 19:22:54 +01:00
|
|
|
import TableCell from './TableCell.jsx';
|
2021-09-07 13:28:20 +02:00
|
|
|
|
|
|
|
export default class TableRow extends Component {
|
|
|
|
view(vnode) {
|
|
|
|
this.attrs.addClassNames('mdc-data-table__row');
|
2021-11-22 19:22:54 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<tr {...this.attrs.all()}>
|
|
|
|
{this.checkbox(vnode.children)}
|
|
|
|
{vnode.children}
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-11-30 14:47:35 +01:00
|
|
|
checkbox(children: Children[]): Children {
|
2021-11-22 19:22:54 +01:00
|
|
|
if (!this.attrs.has('checkable')) {
|
|
|
|
return <></>;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const child: Vnode of children) {
|
|
|
|
if (child.attrs.type === 'checkbox') {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return <TableCell type="checkbox"/>;
|
2021-09-07 13:28:20 +02:00
|
|
|
}
|
|
|
|
}
|