refactor: Menu migrate to @rc-component/trigger (#42554)

* refactor: Menu migrate to @rc-component/trigger

* chore: remove rc-trigger

* chore: bump version

* chore: bump version

* chore: update size limit

* chore: update snapshot
This commit is contained in:
MadCcc 2023-05-26 11:04:02 +08:00 committed by GitHub
parent 2777f26909
commit f09e9cb0c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 4216 additions and 4349 deletions

View File

@ -1,9 +1,9 @@
import type { TriggerProps } from '@rc-component/trigger';
import dayjs from 'dayjs';
import 'dayjs/locale/mk'; // to test local in 'prop locale should works' test case
import customParseFormat from 'dayjs/plugin/customParseFormat';
import MockDate from 'mockdate';
import dayJsGenerateConfig from 'rc-picker/lib/generate/dayjs';
import type { TriggerProps } from 'rc-trigger';
import React from 'react';
import DatePicker from '..';
import focusTest from '../../../tests/shared/focusTest';

View File

@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { MailOutlined } from '@ant-design/icons';
import type { MenuProps, MenuTheme } from 'antd';
import { Menu, Switch } from 'antd';
import React, { useState } from 'react';
type MenuItem = Required<MenuProps>['items'][number];
@ -63,7 +63,9 @@ const App: React.FC = () => {
mode="vertical"
theme="dark"
items={items}
getPopupContainer={(node) => node.parentNode as HTMLElement}
getPopupContainer={function test(node) {
return node.parentNode as HTMLElement;
}}
/>
</>
);

View File

@ -13348,111 +13348,109 @@ exports[`renders components/table/demo/head.tsx extend context correctly 1`] = `
</span>
</span>
</div>
<div>
<div
class="ant-dropdown-menu-submenu ant-dropdown-menu-submenu-popup ant-dropdown-menu ant-table-filter-dropdown-submenu ant-dropdown-menu-light ant-zoom-big-appear ant-zoom-big-appear-prepare ant-zoom-big"
style="opacity: 0;"
<div
class="ant-dropdown-menu-submenu ant-zoom-big-appear ant-zoom-big-appear-prepare ant-zoom-big ant-dropdown-menu-submenu-popup ant-dropdown-menu ant-table-filter-dropdown-submenu ant-dropdown-menu-light ant-dropdown-menu-submenu-placement-rightTop"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-sub ant-dropdown-menu-vertical"
data-menu-list="true"
id="rc-menu-uuid-test-Submenu-popup"
role="menu"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-sub ant-dropdown-menu-vertical"
data-menu-list="true"
id="rc-menu-uuid-test-Submenu-popup"
role="menu"
<li
class="ant-dropdown-menu-item"
data-menu-id="rc-menu-uuid-test-Green"
role="menuitem"
tabindex="-1"
>
<li
class="ant-dropdown-menu-item"
data-menu-id="rc-menu-uuid-test-Green"
role="menuitem"
tabindex="-1"
<span
class="ant-dropdown-menu-title-content"
>
<span
class="ant-dropdown-menu-title-content"
<label
class="ant-checkbox-wrapper"
>
<label
class="ant-checkbox-wrapper"
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
<span>
Green
class="ant-checkbox-inner"
/>
</span>
</label>
<span>
Green
</span>
</li>
</span>
</li>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-dropdown-menu-inline-collapsed-tooltip ant-tooltip-placement-right"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-dropdown-menu-inline-collapsed-tooltip ant-tooltip-placement-right"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
class="ant-tooltip-arrow"
style="position: absolute; top: 0px; left: 0px;"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-arrow"
style="position: absolute; top: 0px; left: 0px;"
class="ant-tooltip-inner"
role="tooltip"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
<li
class="ant-dropdown-menu-item"
data-menu-id="rc-menu-uuid-test-Black"
role="menuitem"
tabindex="-1"
</div>
<li
class="ant-dropdown-menu-item"
data-menu-id="rc-menu-uuid-test-Black"
role="menuitem"
tabindex="-1"
>
<span
class="ant-dropdown-menu-title-content"
>
<span
class="ant-dropdown-menu-title-content"
<label
class="ant-checkbox-wrapper"
>
<label
class="ant-checkbox-wrapper"
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
<span>
Black
class="ant-checkbox-inner"
/>
</span>
</label>
<span>
Black
</span>
</li>
</span>
</li>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-dropdown-menu-inline-collapsed-tooltip ant-tooltip-placement-right"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-dropdown-menu-inline-collapsed-tooltip ant-tooltip-placement-right"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
class="ant-tooltip-arrow"
style="position: absolute; top: 0px; left: 0px;"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-arrow"
style="position: absolute; top: 0px; left: 0px;"
class="ant-tooltip-inner"
role="tooltip"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
</ul>
</div>
</div>
</ul>
</div>
</li>
</ul>

View File

@ -131,8 +131,8 @@
"rc-image": "~5.16.0",
"rc-input": "~1.0.4",
"rc-input-number": "~7.4.0",
"rc-mentions": "~2.2.0",
"rc-menu": "~9.8.3",
"rc-mentions": "~2.3.0",
"rc-menu": "~9.9.1",
"rc-motion": "^2.7.3",
"rc-notification": "~5.0.4",
"rc-pagination": "~3.4.2",
@ -146,7 +146,7 @@
"rc-steps": "~6.0.0",
"rc-switch": "~4.1.0",
"rc-table": "~7.32.1",
"rc-tabs": "~12.6.0",
"rc-tabs": "~12.7.0",
"rc-textarea": "~1.2.2",
"rc-tooltip": "~6.0.0",
"rc-tree": "~5.7.4",
@ -262,7 +262,6 @@
"progress": "^2.0.3",
"qs": "^6.10.1",
"rc-footer": "^0.6.8",
"rc-trigger": "^5.3.4",
"rc-tween-one": "^3.0.3",
"rc-virtual-list": "^3.4.11",
"react": "^18.0.0",
@ -309,11 +308,11 @@
"size-limit": [
{
"path": "./dist/antd.min.js",
"limit": "385 KiB"
"limit": "380 KiB"
},
{
"path": "./dist/antd-with-locales.min.js",
"limit": "500 KiB"
"limit": "440 KiB"
}
],
"tnpm": {

View File

@ -1,27 +0,0 @@
import type { TriggerProps } from 'rc-trigger';
import MockTrigger from 'rc-trigger/lib/mock';
import * as React from 'react';
import { TriggerMockContext } from '../shared/demoTestContext';
let OriginTrigger = jest.requireActual('rc-trigger');
OriginTrigger = OriginTrigger.default ?? OriginTrigger;
const ForwardTrigger = React.forwardRef<any, TriggerProps>((props, ref) => {
const context = React.useContext(TriggerMockContext);
const mergedPopupVisible = context?.popupVisible ?? props.popupVisible;
(global as any).triggerProps = props;
const mergedProps = {
...props,
ref,
popupVisible: mergedPopupVisible as boolean,
};
if (context?.mock === false) {
return <OriginTrigger {...mergedProps} />;
}
return <MockTrigger {...mergedProps} />;
});
export default ForwardTrigger;

View File

@ -1,5 +1,5 @@
/* eslint-disable import/prefer-default-export */
import type { TriggerProps } from 'rc-trigger';
import type { TriggerProps } from '@rc-component/trigger';
import * as React from 'react';
// We export context here is to avoid testing-lib inject `afterEach` in `tests/index.test.js`