/* eslint-disable react/no-array-index-key */ import * as React from 'react'; import { Table, Space, TableProps, ConfigProvider, Select, Row, Col, Alert } from 'antd'; import { statistic } from '../../../../../components/_util/theme'; const columns: TableProps<{ name: string; value: any }>['columns'] = [ { dataIndex: 'name', title: 'Name', width: 1, }, { dataIndex: 'value', title: 'Value', render: (value: string) => { let content: React.ReactNode = value; switch (typeof value) { case 'object': { if (Array.isArray(value)) { content = ( ); break; } } // eslint-disable-next-line no-fallthrough default: content = String(value); } return {content}; }, }, ]; export interface TokenProps { tokenList: string[]; } export default () => { const [selectedComponent, setSelectedComponent] = React.useState(); const [componentNames, setComponentNames] = React.useState<{ value: string; label: string }[]>( [], ); // Full token const [, token] = ConfigProvider.useToken(); const tokenList = React.useMemo( () => Object.keys(token) .filter(name => !name.startsWith('_')) .map((name: keyof typeof token) => ({ name, value: token[name], })), [token], ); React.useEffect(() => { function update() { setComponentNames(Object.keys(statistic).map(key => ({ value: key, label: key }))); } const observer = new MutationObserver(update); observer.observe(document.head, { childList: true }); update(); return () => { observer.disconnect(); }; }, []); const filteredTokenList = React.useMemo(() => { const tokenKeys = statistic[selectedComponent!] || []; if (!tokenKeys.length) { return tokenList; } return tokenList.filter(({ name }) => tokenKeys.includes(name)); }, [tokenList, selectedComponent]); return (