// Copyright (c) Meta Platforms, Inc. and affiliates. 'use client'; import {useState} from 'react'; import { Table, useTableSelection, useTableSelectionState, proportional, } from '@astryxdesign/core/Table'; import type {TableColumn} from '@astryxdesign/core/Table'; interface User extends Record { id: string; name: string; email: string; role: string; } const users: User[] = [ {id: '1', name: 'Alice', email: 'alice@example.com', role: 'Engineer'}, {id: '2', name: 'Bob', email: 'bob@example.com', role: 'Designer'}, {id: '3', name: 'Charlie', email: 'charlie@example.com', role: 'Manager'}, {id: '4', name: 'Diana', email: 'diana@example.com', role: 'Engineer'}, {id: '5', name: 'Eve', email: 'eve@example.com', role: 'Admin'}, ]; const columns: TableColumn[] = [ {key: 'name', header: 'Name', width: proportional(1)}, {key: 'email', header: 'Email', width: proportional(2)}, {key: 'role', header: 'Role', width: proportional(1)}, ]; export default function TableSelectableTable() { const [selectedKeys, setSelectedKeys] = useState>(new Set()); const {selectionConfig} = useTableSelectionState({ data: users, idKey: 'id', selectedKeys, setSelectedKeys, }); const selectionPlugin = useTableSelection(selectionConfig); return ( ); }