<!-- INCORRECT --><mds-table> <thead> <tr><th>Nome</th><th>Email</th></tr> </thead> <tbody> <tr><td>Mario Rossi</td><td>mario.rossi@example.com</td></tr> </tbody></mds-table>
<!-- CORRECT --><mds-table> <mds-table-header> <mds-table-header-cell label="Nome"></mds-table-header-cell> <mds-table-header-cell label="Email"></mds-table-header-cell> </mds-table-header> <mds-table-body> <mds-table-row> <mds-table-cell><mds-text typography="detail">Mario Rossi</mds-text></mds-table-cell> <mds-table-cell><mds-text typography="detail">mario.rossi@example.com</mds-text></mds-table-cell> </mds-table-row> </mds-table-body></mds-table><!-- INCORRECT --><mds-table selectable> <mds-table-body> <mds-table-row>...</mds-table-row> <mds-button slot="batch-action" label="Elimina" variant="error" tone="text"></mds-button> </mds-table-body></mds-table>
<!-- CORRECT --><mds-table selectable> <mds-table-header>...</mds-table-header> <mds-table-body> <mds-table-row>...</mds-table-row> </mds-table-body> <mds-button slot="batch-action" label="Elimina" variant="error" tone="text"></mds-button></mds-table><!-- INCORRECT --><mds-table-row> <mds-table-cell><mds-text typography="detail">Contratto.pdf</mds-text></mds-table-cell> <mds-table-cell> <mds-button slot="action" icon="mi/baseline/delete" title="Elimina" variant="error" tone="text"></mds-button> </mds-table-cell></mds-table-row>
<!-- CORRECT --><mds-table-row> <mds-table-cell><mds-text typography="detail">Contratto.pdf</mds-text></mds-table-cell> <mds-button slot="action" icon="mi/baseline/delete" title="Elimina" variant="error" tone="text"></mds-button></mds-table-row><!-- INCORRECT --><mds-table> <mds-table-header>...</mds-table-header> <mds-table-body>...</mds-table-body> <mds-button slot="batch-action" label="Esporta" variant="primary"></mds-button></mds-table>
<!-- CORRECT --><mds-table selectable> <mds-table-header>...</mds-table-header> <mds-table-body>...</mds-table-body> <mds-button slot="batch-action" label="Esporta" variant="primary"></mds-button></mds-table><!-- INCORRECT --><mds-table> <mds-table-body> <mds-table-row interactive>...</mds-table-row> <mds-table-row>...</mds-table-row> </mds-table-body></mds-table>
<!-- CORRECT --><mds-table interactive> <mds-table-body> <mds-table-row>...</mds-table-row> <mds-table-row>...</mds-table-row> </mds-table-body></mds-table><!-- INCORRECT --><mds-table selectable id="tbl">...</mds-table><script> document.getElementById('tbl').addEventListener('change', (e) => { // unreliable - native events do not bubble from shadow DOM });</script>
<!-- CORRECT --><mds-table selectable id="tbl">...</mds-table><script> document.getElementById('tbl').addEventListener('mdsTableSelectionChange', (e) => { console.log('Righe selezionate:', e.detail.rows); });</script><!-- INCORRECT --><mds-table selectable selection> ...</mds-table>
<!-- CORRECT - read it back, do not set it --><mds-table selectable id="tbl"> ...</mds-table><script> document.getElementById('tbl').addEventListener('mdsTableSelectionChange', (e) => { const hasSelection = e.detail.rows.length > 0; document.getElementById('panel-azioni').hidden = !hasSelection; });</script>