Last active
November 14, 2023 01:27
-
-
Save souri-t/0edcf6b042c04090cd8fa479de0ada6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Select, SelectChangeEvent, TableCell } from "@mui/material"; | |
/** | |
* 選択可能なテーブルセルのプロパティ | |
* @param param0 | |
* @returns | |
*/ | |
type Props = { | |
onchange?: (e: SelectChangeEvent<unknown>, child: React.ReactNode) => void; | |
children?: React.ReactNode; | |
sx?: React.CSSProperties; | |
defaultValue?: string; | |
size?: "small" | "medium"; | |
fontSize?: string; | |
}; | |
/** | |
* 選択可能なテーブルセル | |
* @param param0 | |
* @returns | |
*/ | |
export const SelectableTableCell = ({ onchange, children, sx, defaultValue, size, fontSize }: Props) => { | |
const handleSelectChange = (e: SelectChangeEvent<unknown>, child: React.ReactNode) => { | |
onchange?.(e, child); | |
}; | |
return ( | |
<TableCell contentEditable={true} sx={sx}> | |
<Select onChange={handleSelectChange} defaultValue={defaultValue} displayEmpty size={size} sx={{fontSize:{fontSize} }}> | |
{children} | |
</Select> | |
</TableCell> | |
); | |
} |
Author
souri-t
commented
Nov 14, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment