mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 05:58:56 +08:00
@@ -7,19 +7,20 @@ import { useMenuItem } from '../use-menu-item';
|
||||
import { MobileMenuContext } from './context';
|
||||
|
||||
export const MobileMenuSub = ({
|
||||
title,
|
||||
children: propsChildren,
|
||||
items,
|
||||
triggerOptions,
|
||||
subContentOptions: contentOptions = {},
|
||||
}: MenuSubProps) => {
|
||||
}: MenuSubProps & { title?: string }) => {
|
||||
const {
|
||||
className,
|
||||
children,
|
||||
otherProps: { onClick, ...otherTriggerOptions },
|
||||
} = useMenuItem({
|
||||
...triggerOptions,
|
||||
children: propsChildren,
|
||||
suffixIcon: <ArrowRightSmallPlusIcon />,
|
||||
...triggerOptions,
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -27,6 +28,7 @@ export const MobileMenuSub = ({
|
||||
onClick={onClick}
|
||||
items={items}
|
||||
subContentOptions={contentOptions}
|
||||
title={title}
|
||||
>
|
||||
<div className={className} {...otherTriggerOptions}>
|
||||
{children}
|
||||
@@ -36,19 +38,23 @@ export const MobileMenuSub = ({
|
||||
};
|
||||
|
||||
export const MobileMenuSubRaw = ({
|
||||
title,
|
||||
onClick,
|
||||
children,
|
||||
items,
|
||||
subContentOptions: contentOptions = {},
|
||||
}: MenuSubProps & { onClick?: (e: MouseEvent<HTMLDivElement>) => void }) => {
|
||||
}: MenuSubProps & {
|
||||
onClick?: (e: MouseEvent<HTMLDivElement>) => void;
|
||||
title?: string;
|
||||
}) => {
|
||||
const { setSubMenus } = useContext(MobileMenuContext);
|
||||
|
||||
const onItemClick = useCallback(
|
||||
(e: MouseEvent<HTMLDivElement>) => {
|
||||
onClick?.(e);
|
||||
setSubMenus(prev => [...prev, { items, contentOptions }]);
|
||||
setSubMenus(prev => [...prev, { items, contentOptions, title }]);
|
||||
},
|
||||
[contentOptions, items, onClick, setSubMenus]
|
||||
[contentOptions, items, onClick, setSubMenus, title]
|
||||
);
|
||||
|
||||
return <Slot onClick={onItemClick}>{children}</Slot>;
|
||||
|
||||
Reference in New Issue
Block a user