Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: retire deprecated api #745

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/demo/fragment.md

This file was deleted.

201 changes: 135 additions & 66 deletions docs/examples/antd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import React from 'react';
import type { CSSMotionProps } from 'rc-motion';
import Menu, { SubMenu, Item as MenuItem, Divider, MenuProps } from '../../src';
import Menu from 'rc-menu';
import type { ItemType } from '@/interface';
import type { MenuProps } from 'rc-menu';
import '../../assets/index.less';

function handleClick(info) {
Expand Down Expand Up @@ -48,75 +50,142 @@ const motionMap: Record<MenuProps['mode'], CSSMotionProps> = {
vertical: verticalMotion,
};

const nestSubMenu = (
<SubMenu
title={<span className="submenu-title-wrapper">offset sub menu 2</span>}
key="4"
popupOffset={[10, 15]}
>
<MenuItem key="4-1">inner inner</MenuItem>
<Divider />
<SubMenu
key="4-2"
title={<span className="submenu-title-wrapper">sub menu 1</span>}
>
<SubMenu
title={<span className="submenu-title-wrapper">sub 4-2-0</span>}
key="4-2-0"
>
<MenuItem key="4-2-0-1">inner inner</MenuItem>
<MenuItem key="4-2-0-2">inner inner2</MenuItem>
</SubMenu>
<MenuItem key="4-2-1">inn</MenuItem>
<SubMenu
title={<span className="submenu-title-wrapper">sub menu 4</span>}
key="4-2-2"
>
<MenuItem key="4-2-2-1">inner inner</MenuItem>
<MenuItem key="4-2-2-2">inner inner2</MenuItem>
</SubMenu>
<SubMenu
title={<span className="submenu-title-wrapper">sub menu 3</span>}
key="4-2-3"
>
<MenuItem key="4-2-3-1">inner inner</MenuItem>
<MenuItem key="4-2-3-2">inner inner2</MenuItem>
</SubMenu>
</SubMenu>
</SubMenu>
);
const nestSubMenu: ItemType = {
key: '4',
type: 'submenu',
label: <span className="submenu-title-wrapper">offset sub menu 2</span>,
popupOffset: [10, 15],
children: [
{
key: '4-1',
label: 'inner inner',
},
{
type: 'divider',
},
{
key: '4-2',
type: 'submenu',
label: <span className="submenu-title-wrapper">sub menu 1</span>,
children: [
{
key: '4-2-0',
type: 'submenu',
label: <span className="submenu-title-wrapper">sub 4-2-0</span>,
children: [
{
key: '4-2-0-1',
label: 'inner inner',
},
{
key: '4-2-0-2',
label: 'inner inner2',
},
],
},
{
key: '4-2-1',
label: 'inn',
},
{
key: '4-2-2',
type: 'submenu',
label: <span className="submenu-title-wrapper">sub menu 4</span>,
children: [
{
key: '4-2-2-1',
label: 'inner inner',
},
{
key: '4-2-2-2',
label: 'inner inner2',
},
],
},
{
key: '4-2-3',
type: 'submenu',
label: <span className="submenu-title-wrapper">sub menu 3</span>,
children: [
{
key: '4-2-3-1',
label: 'inner inner',
},
{
key: '4-2-3-2',
label: 'inner inner2',
},
],
},
],
},
],
};

function onOpenChange(value) {
console.log('onOpenChange', value);
}

const children1 = [
<SubMenu
title={<span className="submenu-title-wrapper">sub menu</span>}
key="1"
>
<MenuItem key="1-1">0-1</MenuItem>
<MenuItem key="1-2">0-2</MenuItem>
</SubMenu>,
const children1: ItemType[] = [
{
type: 'submenu',
key: '1',
label: <span className="submenu-title-wrapper">sub menu</span>,
children: [
{
key: '1-1',
label: '0-1',
},
{
key: '1-2',
label: '0-2',
},
],
},
nestSubMenu,
<MenuItem key="2">1</MenuItem>,
<MenuItem key="3">outer</MenuItem>,
<MenuItem key="5" disabled>
disabled
</MenuItem>,
<MenuItem key="6">outer3</MenuItem>,
{
key: '2',
label: '1',
},
{
key: '3',
label: 'outer',
},
{
key: '5',
label: 'disabled',
disabled: true,
},
{
key: '6',
label: 'outer3',
},
];

const children2 = [
<SubMenu
title={<span className="submenu-title-wrapper">sub menu</span>}
key="1"
>
<MenuItem key="1-1">0-1</MenuItem>
<MenuItem key="1-2">0-2</MenuItem>
</SubMenu>,
<MenuItem key="2">1</MenuItem>,
<MenuItem key="3">outer</MenuItem>,
{
type: 'submenu',
key: '1',
label: <span className="submenu-title-wrapper">sub menu</span>,
children: [
{
key: '1-1',
label: '0-1',
},
{
key: '1-2',
label: '0-2',
},
],
},
{
key: '2',
label: '1',
},
{
key: '3',
label: 'outer',
},
];

const customizeIndicator = <span>Add More Items</span>;
Expand All @@ -127,7 +196,7 @@ interface CommonMenuProps extends MenuProps {
}

interface CommonMenuState {
children: React.ReactNode;
children: ItemType[];
overflowedIndicator: React.ReactNode;
}

Expand All @@ -136,11 +205,12 @@ export class CommonMenu extends React.Component<
CommonMenuState
> {
state: CommonMenuState = {
children: children1,
children: children1 as ItemType[],
overflowedIndicator: undefined,
};

toggleChildren = () => {
// @ts-ignore
this.setState(({ children }) => ({
children: children === children1 ? children2 : children1,
}));
Expand Down Expand Up @@ -175,9 +245,8 @@ export class CommonMenu extends React.Component<
selectedKeys={['3']}
overflowedIndicator={overflowedIndicator}
{...this.props}
>
{children}
</Menu>
items={children}
/>
</div>
);
}
Expand Down
Loading