// Copyright (c) Meta Platforms, Inc. and affiliates. 'use client'; import {useState} from 'react'; import {Button} from '@astryxdesign/core/Button'; import {CheckboxInput} from '@astryxdesign/core/CheckboxInput'; import {HStack, VStack} from '@astryxdesign/core/Layout'; import {Popover} from '@astryxdesign/core/Popover'; import { Table, useTableColumnSettings, useTableColumnSettingsState, } from '@astryxdesign/core/Table'; import type {TableColumn} from '@astryxdesign/core/Table'; interface Member extends Record { id: string; name: string; email: string; role: string; } const members: Member[] = [ {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'}, ]; const allColumns: TableColumn[] = [ {key: 'name', header: 'Name'}, {key: 'email', header: 'Email'}, {key: 'role', header: 'Role'}, ]; const columnOptions = [ {key: 'name' as const, label: 'Name', isAlwaysVisible: true}, {key: 'email' as const, label: 'Email'}, {key: 'role' as const, label: 'Role'}, ]; const defaultKeys = ['name', 'email', 'role']; export default function UseTableColumnSettingsStateHookUsage() { const [activeKeys, setActiveKeys] = useState>(defaultKeys); const state = useTableColumnSettingsState({ columns: columnOptions, activeColumnKeys: activeKeys, onChangeActiveColumnKeys: setActiveKeys, defaultColumnKeys: defaultKeys, }); const plugin = useTableColumnSettings(state.columnSettingsConfig); return ( {columnOptions.map(col => ( state.toggleColumn(col.key)} /> ))} }> ); }