|
@@ -0,0 +1,192 @@
|
|
|
+import * as React from "react";
|
|
|
+import {
|
|
|
+ FolderRegular,
|
|
|
+ EditRegular,
|
|
|
+ OpenRegular,
|
|
|
+ DocumentRegular,
|
|
|
+ PeopleRegular,
|
|
|
+ DocumentPdfRegular,
|
|
|
+ VideoRegular,
|
|
|
+ ChevronDown16Filled,
|
|
|
+} from "@fluentui/react-icons";
|
|
|
+import {
|
|
|
+ PresenceBadgeStatus,
|
|
|
+ Avatar,
|
|
|
+ DataGridBody,
|
|
|
+ DataGridRow,
|
|
|
+ DataGrid,
|
|
|
+ DataGridHeader,
|
|
|
+ DataGridHeaderCell,
|
|
|
+ DataGridCell,
|
|
|
+ TableCellLayout,
|
|
|
+ TableColumnDefinition,
|
|
|
+ createTableColumn,
|
|
|
+ Button,
|
|
|
+ Menu,
|
|
|
+ MenuTrigger,
|
|
|
+ MenuList,
|
|
|
+ MenuItem,
|
|
|
+ MenuPopover,
|
|
|
+ Text
|
|
|
+} from "@fluentui/react-components";
|
|
|
+
|
|
|
+
|
|
|
+const items = [
|
|
|
+ {
|
|
|
+ 姓名: { label: "张三", icon: <DocumentRegular /> },
|
|
|
+ 性别: { label: "男", status: "available" },
|
|
|
+ 年龄: { label: "30岁", timestamp: 1 },
|
|
|
+ 最后在线时间: { label: "2024/11/6 13:50" },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 姓名: { label: "李四", icon: <FolderRegular /> },
|
|
|
+ 性别: { label: "女", status: "busy" },
|
|
|
+ 年龄: { label: "20", timestamp: 2 },
|
|
|
+ 最后在线时间: { label: "2024/11/6 13:50" },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 姓名: { label: "王五", icon: <VideoRegular /> },
|
|
|
+ 性别: { label: "男", status: "away" },
|
|
|
+ 年龄: { label: "25", timestamp: 2 },
|
|
|
+ 最后在线时间: { label: "2024/11/6 13:50" },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 姓名: { label: "田六", icon: <DocumentPdfRegular /> },
|
|
|
+ 性别: { label: "男", status: "offline" },
|
|
|
+ 年龄: { label: "33", timestamp: 3 },
|
|
|
+ 最后在线时间: { label: "2024/11/6 13:50" },
|
|
|
+ },
|
|
|
+];
|
|
|
+
|
|
|
+const columns = [
|
|
|
+ createTableColumn({
|
|
|
+ columnId: "姓名",
|
|
|
+ compare: (a, b) => {
|
|
|
+ return a.姓名.label.localeCompare(b.姓名.label);
|
|
|
+ },
|
|
|
+ renderHeaderCell: () => {
|
|
|
+ return ("姓名");
|
|
|
+ },
|
|
|
+ renderCell: (item) => {
|
|
|
+ return (
|
|
|
+ <TableCellLayout media={item.姓名.icon}>
|
|
|
+ {item.姓名.label}
|
|
|
+ </TableCellLayout>
|
|
|
+ );
|
|
|
+ },
|
|
|
+ }),
|
|
|
+ createTableColumn({
|
|
|
+ columnId: "性别",
|
|
|
+ compare: (a, b) => {
|
|
|
+ return a.性别.label.localeCompare(b.性别.label);
|
|
|
+ },
|
|
|
+ renderHeaderCell: () => {
|
|
|
+ return (
|
|
|
+ <TableCellLayout
|
|
|
+ media={<VideoRegular />}
|
|
|
+ >
|
|
|
+ 性别
|
|
|
+ <Menu>
|
|
|
+ <MenuTrigger disableButtonEnhancement>
|
|
|
+ <Button appearance="subtle" icon={<ChevronDown16Filled />}></Button>
|
|
|
+ </MenuTrigger>
|
|
|
+
|
|
|
+ <MenuPopover>
|
|
|
+ <MenuList>
|
|
|
+ <MenuItem>New </MenuItem>
|
|
|
+ <MenuItem>New Window</MenuItem>
|
|
|
+ <MenuItem disabled>Open File</MenuItem>
|
|
|
+ <MenuItem>Open Folder</MenuItem>
|
|
|
+ </MenuList>
|
|
|
+ </MenuPopover>
|
|
|
+ </Menu>
|
|
|
+ {/* <Button appearance="subtle" icon={<VideoRegular />}></Button> */}
|
|
|
+ </TableCellLayout>
|
|
|
+ );
|
|
|
+ },
|
|
|
+ renderCell: (item) => {
|
|
|
+ return item.性别.label;
|
|
|
+ // return (
|
|
|
+ // <TableCellLayout
|
|
|
+ // media={
|
|
|
+ // <Avatar
|
|
|
+ // aria-label={item.性别.label}
|
|
|
+ // name={item.性别.label}
|
|
|
+ // badge={{ status: item.性别.status }}
|
|
|
+ // />
|
|
|
+ // }
|
|
|
+ // >
|
|
|
+ // {item.性别.label}
|
|
|
+ // </TableCellLayout>
|
|
|
+ // );
|
|
|
+ },
|
|
|
+ }),
|
|
|
+ createTableColumn({
|
|
|
+ columnId: "年龄",
|
|
|
+ compare: (a, b) => {
|
|
|
+ return a.年龄.timestamp - b.年龄.timestamp;
|
|
|
+ },
|
|
|
+ renderHeaderCell: () => {
|
|
|
+ return "年龄";
|
|
|
+ },
|
|
|
+
|
|
|
+ renderCell: (item) => {
|
|
|
+ return item.年龄.label;
|
|
|
+ },
|
|
|
+ }),
|
|
|
+ createTableColumn({
|
|
|
+ columnId: "最后在线时间",
|
|
|
+ compare: (a, b) => {
|
|
|
+ return a.最后在线时间.label.localeCompare(b.最后在线时间.label);
|
|
|
+ },
|
|
|
+ renderHeaderCell: () => {
|
|
|
+ return "最后在线时间";
|
|
|
+ },
|
|
|
+ renderCell: (item) => {
|
|
|
+ return (
|
|
|
+ <TableCellLayout media={item.最后在线时间.icon}>
|
|
|
+ {item.最后在线时间.label}
|
|
|
+ </TableCellLayout>
|
|
|
+ );
|
|
|
+ },
|
|
|
+ }),
|
|
|
+];
|
|
|
+
|
|
|
+const List = () => {
|
|
|
+ const defaultSelectedItems = React.useMemo(() => new Set([1]), []);
|
|
|
+
|
|
|
+ return (
|
|
|
+ <DataGrid
|
|
|
+ items={items}
|
|
|
+ columns={columns}
|
|
|
+ selectionMode="single"
|
|
|
+ // sortable
|
|
|
+ subtleSelection
|
|
|
+ resizableColumns
|
|
|
+ defaultSelectedItems={defaultSelectedItems}
|
|
|
+ style={{ minWidth: "550px" }}
|
|
|
+ >
|
|
|
+ <DataGridHeader>
|
|
|
+ <DataGridRow>
|
|
|
+ {({ renderHeaderCell }) => (
|
|
|
+ <DataGridHeaderCell>{renderHeaderCell()}</DataGridHeaderCell>
|
|
|
+ )}
|
|
|
+ </DataGridRow>
|
|
|
+ </DataGridHeader>
|
|
|
+ <DataGridBody>
|
|
|
+ {({ item, rowId }) => (
|
|
|
+ <DataGridRow
|
|
|
+ key={rowId}
|
|
|
+ selectionCell={{ radioIndicator: { "aria-label": "Select row" } }}
|
|
|
+ >
|
|
|
+ {({ renderCell }) => (
|
|
|
+ <DataGridCell>{renderCell(item)}</DataGridCell>
|
|
|
+ )}
|
|
|
+ </DataGridRow>
|
|
|
+ )}
|
|
|
+ </DataGridBody>
|
|
|
+ </DataGrid>
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+export default List;
|