import { alpha, Box, ListItemText, ListItemButton, Typography, styled, } from "@mui/material"; import { ExpandLessRounded, ExpandMoreRounded, InboxRounded, } from "@mui/icons-material"; import { HeadState } from "./use-head-state"; import { ProxyHead } from "./proxy-head"; import { ProxyItem } from "./proxy-item"; import { ProxyItemMini } from "./proxy-item-mini"; import type { IRenderItem } from "./use-render-list"; interface RenderProps { item: IRenderItem; indent: boolean; onLocation: (group: IProxyGroupItem) => void; onCheckAll: (groupName: string) => void; onHeadState: (groupName: string, patch: Partial) => void; onChangeProxy: (group: IProxyGroupItem, proxy: IProxyItem) => void; } export const ProxyRender = (props: RenderProps) => { const { indent, item, onLocation, onCheckAll, onHeadState, onChangeProxy } = props; const { type, group, headState, proxy, proxyCol } = item; if (type === 0) { return ( onHeadState(group.name, { open: !headState?.open })} > {group.type} {group.now} } secondaryTypographyProps={{ sx: { display: "flex", alignItems: "center" }, }} /> {headState?.open ? : } ); } if (type === 1) { return ( onLocation(group)} onCheckDelay={() => onCheckAll(group.name)} onHeadState={(p) => onHeadState(group.name, p)} /> ); } if (type === 2) { return ( onChangeProxy(group, proxy!)} /> ); } if (type === 3) { return ( No Proxies ); } if (type === 4) { return ( {proxyCol?.map((proxy) => ( onChangeProxy(group, proxy!)} /> ))} ); } return null; }; const StyledSubtitle = styled("span")` font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; `; const StyledTypeBox = styled(Box)(({ theme }) => ({ display: "inline-block", border: "1px solid #ccc", borderColor: alpha(theme.palette.primary.main, 0.5), color: alpha(theme.palette.primary.main, 0.8), borderRadius: 4, fontSize: 10, padding: "0 2px", lineHeight: 1.25, marginRight: "4px", }));