Skip to content

Instantly share code, notes, and snippets.

@souri-t
Last active November 13, 2023 16:23
Show Gist options
  • Save souri-t/6094db026bbb1ed086ff4d0ea69ad391 to your computer and use it in GitHub Desktop.
Save souri-t/6094db026bbb1ed086ff4d0ea69ad391 to your computer and use it in GitHub Desktop.
import { TableCell } from "@mui/material";
/**
* 編集可能なテーブルセルのプロパティ
*/
type Props = {
onInput?: (e: React.FormEvent<HTMLTableCellElement>) => void;
children?: React.ReactNode;
sx?: React.CSSProperties;
size?: "small" | "medium";
};
/**
* 編集可能なテーブルセル
* @param param0
* @returns
*/
export const EditableTableCell = ({ onInput, children, sx, size }: Props) => {
const handleCellInput = (e: React.FormEvent<HTMLTableCellElement>) => {
onInput?.(e);
};
return (
<TableCell contentEditable={true} onInput={handleCellInput} sx={sx} size={size} >
{children}
</TableCell>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment