import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField, styled, } from "@mui/material"; import Menu from "@mui/material/Menu"; import MenuItem from "@mui/material/MenuItem"; import { Check } from "lucide-react"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import type { SheetOptions } from "./types"; function isWhiteColor(color: string): boolean { return ["#FFF", "#FFFFFF"].includes(color); } interface SheetRenameDialogProps { isOpen: boolean; close: () => void; onNameChanged: (name: string) => void; defaultName: string; } export const SheetRenameDialog = (properties: SheetRenameDialogProps) => { const { t } = useTranslation(); const [name, setName] = useState(properties.defaultName); return ( {t("sheet_rename.title")} event.stopPropagation()} onKeyDown={(event) => { event.stopPropagation(); }} onChange={(event) => { setName(event.target.value); }} spellCheck="false" onPaste={(event) => event.stopPropagation()} /> ); }; interface SheetListMenuProps { isOpen: boolean; close: () => void; anchorEl: HTMLButtonElement | null; onSheetSelected: (index: number) => void; sheetOptionsList: SheetOptions[]; selectedIndex: number; } const SheetListMenu = (properties: SheetListMenuProps) => { const { isOpen, close, anchorEl, onSheetSelected, sheetOptionsList, selectedIndex, } = properties; const hasColors = sheetOptionsList.some((tab) => !isWhiteColor(tab.color)); return ( {sheetOptionsList.map((tab, index) => ( onSheetSelected(index)} > {index === selectedIndex ? ( ) : (
)} {hasColors && } {tab.name} ))} ); }; const StyledMenu = styled(Menu)({ "& .MuiPaper-root": { borderRadius: 8, padding: 4, }, "& .MuiList-padding": { padding: 0, }, }); const StyledMenuItem = styled(MenuItem)({ padding: 8, borderRadius: 4, }); const ItemColor = styled("div")` width: 12px; height: 12px; border-radius: 4px; margin-right: 8px; `; const ItemName = styled("div")` font-size: 12px; color: #333; `; export default SheetListMenu;