mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
feat: ✨ 💥 Conversione a Typescript
- Rimossi Babel e Flow, sostituito con Typescript - Qualche piccolo fix qua e là - Aggiornate dipendenze
This commit is contained in:
45
resources/js/Components/DataTable/TableRow.tsx
Normal file
45
resources/js/Components/DataTable/TableRow.tsx
Normal file
@ -0,0 +1,45 @@
|
||||
import '@material/mwc-checkbox';
|
||||
|
||||
import {collect} from 'collect.js';
|
||||
import type {Children, Vnode} from 'mithril';
|
||||
|
||||
import Component from '../Component';
|
||||
import TableCell from './TableCell';
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
'TableRow': TableRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type TableRowAttributes = {checkable?: boolean};
|
||||
|
||||
export default class TableRow extends Component<TableRowAttributes> {
|
||||
view(vnode: Vnode<TableRowAttributes>) {
|
||||
this.attrs.addClassNames('mdc-data-table__row');
|
||||
return (
|
||||
<tr {...this.attrs.all()}>
|
||||
{this.checkbox(vnode.children as Children[])}
|
||||
{vnode.children}
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
checkbox(children: Children[]): Children {
|
||||
if (!this.attrs.has('checkable')) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
for (const child of children) {
|
||||
const attributes = collect((child as Vnode).attrs);
|
||||
|
||||
if (attributes.get('type') === 'checkbox') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return <TableCell type="checkbox" />;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user