import React, { useState } from 'react' import { RadioGroup, Radio, TablePaginationAlign, Button, Table, ComponentSize, Select, SelectOption, Link, TableColumnSelectFilterValue } from 'react-icecream' import originalRecords from './shared-records' const nextSizeMap = { default: 'small', small: 'default', large: 'default' } as const const nextBorderMap = { full: 'none', none: 'row', row: 'full' } as const export default function Demo() { const [border, setBorder] = useState<'row' | 'full' | 'none'>('row') const [idVisible, setIdVisible] = useState(false) const [size, setSize] = useState('default') const [zebra, setZebra] = useState(false) const [noData, setNoData] = useState(false) const [fixdHead, setFixdHead] = useState(false) const [contentWidth, setContentWidth] = useState('') const { records, loading, currentPage, pageSize, total, setPageInfo, filterValue, setFilterValue } = useData() const [enableSelection, setEnableSelection] = useState(false) const [selectedIds, setSelectedIds] = useState(['1', '2']) const [enableRowSpan, setEnableRowSpan] = useState(false) const [align, setAlign] = useState('right') function handleSelect(nextSelectedIds: string[]) { setSelectedIds(nextSelectedIds) console.log(nextSelectedIds) } return ( <>
defaultValue={contentWidth} onChange={v => setContentWidth(v ?? '')} style={{ width: 150 }}> 不开启固定列 max-content 1500px 居中对齐 右侧对齐
{ idVisible && ( idx + 1} /> ) } ((idx + 1) % 2 === 1 ? 2 : 0) : undefined} /> ( 概览 文件 设置 域名 )} />
) } function useData() { const [{ currentPage, pageSize }, setPageInfo] = useState({ pageSize: 10, currentPage: 0 }) const [loading, setLoading] = useState(false) const [filterValue, setFilterValue] = useState([]) async function handleSetPageInfo(nextCurrentPage: number, nextPageSize: number) { setLoading(true) await new Promise(r => setTimeout(r, 1000)) setLoading(false) setPageInfo({ pageSize: nextPageSize, currentPage: nextCurrentPage }) } return { records: originalRecords .slice(currentPage * pageSize, (currentPage + 1) * pageSize) .filter(record => (filterValue.length > 0 ? filterValue.indexOf(record.type) > -1 : true)), currentPage, pageSize, setPageInfo: handleSetPageInfo, total: originalRecords.length, loading, setFilterValue, filterValue } }