2024-04-20 01:40:41 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
2024-04-20 14:45:24 +02:00
|
|
|
* src: https://github.com/webzep/mui-nested-menu/blob/main/packages/mui-nested-menu/src/components/IconMenuItem.tsx (2024-04-20 01:42)
|
2024-04-20 01:40:41 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
2026-03-11 00:11:29 +01:00
|
|
|
import type { MenuItemProps as MuiMenuItemProps } from '@mui/material/MenuItem';
|
|
|
|
|
import MenuItem from '@mui/material/MenuItem';
|
|
|
|
|
import type { SxProps, Theme } from '@mui/material/styles';
|
|
|
|
|
import type { Ref } from 'react';
|
|
|
|
|
import React from 'react';
|
2024-04-20 01:40:41 +02:00
|
|
|
|
2026-03-11 00:11:29 +01:00
|
|
|
import type { OverridableComponent } from '@mui/material/OverridableComponent';
|
|
|
|
|
import type { SvgIconTypeMap } from '@mui/material/SvgIcon';
|
2024-04-20 01:40:41 +02:00
|
|
|
import ListItemText from '@mui/material/ListItemText';
|
|
|
|
|
|
|
|
|
|
type IconMenuItemProps = {
|
|
|
|
|
MenuItemProps?: MuiMenuItemProps;
|
|
|
|
|
className?: string;
|
|
|
|
|
disabled?: boolean;
|
|
|
|
|
label?: string;
|
|
|
|
|
renderLabel?: () => React.ReactNode;
|
|
|
|
|
LeftIcon?: OverridableComponent<SvgIconTypeMap> & { muiName: string };
|
|
|
|
|
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
2025-09-24 00:51:13 +02:00
|
|
|
ref?: Ref<HTMLLIElement | null>;
|
2024-04-20 01:40:41 +02:00
|
|
|
RightIcon?: OverridableComponent<SvgIconTypeMap> & { muiName: string };
|
|
|
|
|
sx?: SxProps<Theme>;
|
|
|
|
|
};
|
|
|
|
|
|
2025-09-24 00:51:13 +02:00
|
|
|
export const IconMenuItem = ({
|
|
|
|
|
MenuItemProps,
|
|
|
|
|
className,
|
|
|
|
|
label,
|
|
|
|
|
LeftIcon,
|
|
|
|
|
renderLabel,
|
|
|
|
|
RightIcon,
|
|
|
|
|
...props
|
|
|
|
|
}: IconMenuItemProps) => (
|
|
|
|
|
<MenuItem {...MenuItemProps} className={className} {...props}>
|
|
|
|
|
{LeftIcon && (
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<LeftIcon fontSize="small" />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
)}
|
|
|
|
|
<ListItemText>{label}</ListItemText>
|
|
|
|
|
{RightIcon && (
|
|
|
|
|
<ListItemIcon style={{ minWidth: 0 }}>
|
|
|
|
|
<RightIcon fontSize="small" />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
)}
|
|
|
|
|
</MenuItem>
|
2024-04-20 01:40:41 +02:00
|
|
|
);
|