From deb5485c4752ef241a1508364853e67f7a8663d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Sun, 23 Feb 2025 17:41:14 +0800 Subject: [PATCH 1/6] chore: update dependencies and import paths to @rc-component packages dependencies --- README.md | 6 ++-- docs/examples/antd.tsx | 2 +- docs/examples/debug.tsx | 2 +- docs/examples/rtl-antd.tsx | 6 ++-- package.json | 13 ++++---- src/Menu.tsx | 8 ++--- src/MenuItem.tsx | 8 ++--- src/MenuItemGroup.tsx | 2 +- src/SubMenu/InlineSubMenuList.tsx | 11 ++----- src/SubMenu/PopupTrigger.tsx | 4 +-- src/SubMenu/index.tsx | 2 +- src/context/MenuContext.tsx | 6 ++-- src/hooks/useAccessibility.ts | 41 ++++++----------------- src/hooks/useKeyRecords.ts | 2 +- src/hooks/useUUID.ts | 6 ++-- src/utils/commonUtil.ts | 55 +++++++++++++++---------------- src/utils/motionUtil.ts | 2 +- src/utils/warnUtil.ts | 2 +- tests/Focus.spec.tsx | 2 +- tests/Keyboard.spec.tsx | 4 +-- tests/Menu.spec.tsx | 10 +++--- tests/MenuItem.spec.tsx | 2 +- tests/Responsive.spec.tsx | 4 +-- tests/SubMenu.spec.tsx | 2 +- 24 files changed, 85 insertions(+), 117 deletions(-) diff --git a/README.md b/README.md index e2f81ccf..a826091b 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ ReactDOM.render( ## Compatibility | [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | [Electron](http://godban.github.io/browsers-support-badges/)
Electron | -| --- | --- | --- | --- | --- | -| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | ## API @@ -172,7 +172,7 @@ ReactDOM.render( openAnimation {enter:function,leave:function}|String - animate when sub menu open or close. see rc-motion for object type. + animate when sub menu open or close. see @rc-component/motion for object type. openTransition diff --git a/docs/examples/antd.tsx b/docs/examples/antd.tsx index f5bd0bba..7dac7ffd 100644 --- a/docs/examples/antd.tsx +++ b/docs/examples/antd.tsx @@ -1,7 +1,7 @@ /* eslint-disable no-console, react/require-default-props, no-param-reassign */ import React from 'react'; -import type { CSSMotionProps } from 'rc-motion'; +import type { CSSMotionProps } from '@rc-component/motion'; import Menu, { SubMenu, Item as MenuItem, Divider, MenuProps } from '../../src'; import '../../assets/index.less'; diff --git a/docs/examples/debug.tsx b/docs/examples/debug.tsx index a9db1e87..0fca53ab 100644 --- a/docs/examples/debug.tsx +++ b/docs/examples/debug.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React, { useRef } from 'react'; -import type { CSSMotionProps } from 'rc-motion'; +import type { CSSMotionProps } from '@rc-component/motion'; import Menu, { ItemGroup as MenuItemGroup, MenuItem } from '../../src'; import type { MenuProps } from '../../src'; import '../../assets/index.less'; diff --git a/docs/examples/rtl-antd.tsx b/docs/examples/rtl-antd.tsx index 91984cf7..7ba5bdd1 100644 --- a/docs/examples/rtl-antd.tsx +++ b/docs/examples/rtl-antd.tsx @@ -1,7 +1,7 @@ /* eslint-disable no-console, react/require-default-props, no-param-reassign */ import React from 'react'; -import type { CSSMotionProps } from 'rc-motion'; +import type { CSSMotionProps } from '@rc-component/motion'; import Menu, { SubMenu, Item as MenuItem, Divider, MenuProps } from 'rc-menu'; import '../../assets/index.less'; @@ -122,8 +122,8 @@ const children2 = [ const customizeIndicator = Add More Items; interface CommonMenuState { - children: React.ReactNode; - overflowedIndicator?: React.ReactNode; + children: React.ReactNode; + overflowedIndicator?: React.ReactNode; } class CommonMenu extends React.Component { diff --git a/package.json b/package.json index 4301b3ba..c3d8103d 100644 --- a/package.json +++ b/package.json @@ -37,22 +37,22 @@ "docs:deploy": "gh-pages -d .doc", "lint": "eslint src/ --ext .tsx,.ts,.jsx,.js", "now-build": "npm run build", - "prepublishOnly": "npm run compile && np --yolo --no-publish", + "prepublishOnly": "npm run compile && rc-np", "postpublish": "tnpm sync rc-menu", "start": "dumi dev", "test": "rc-test", "prepare": "husky && dumi setup" }, "dependencies": { - "@babel/runtime": "^7.10.1", - "@rc-component/trigger": "^2.0.0", + "@rc-component/motion": "^1.1.4", + "@rc-component/trigger": "^3.0.0", + "@rc-component/util": "^1.0.0", "classnames": "2.x", - "rc-motion": "^2.4.3", - "rc-overflow": "^1.3.1", - "rc-util": "^5.27.0" + "rc-overflow": "^1.3.1" }, "devDependencies": { "@rc-component/father-plugin": "^1.0.0", + "@rc-component/np": "^1.0.3", "@testing-library/jest-dom": "^6.1.5", "@testing-library/react": "^16.0.0", "@types/jest": "^29.5.2", @@ -70,7 +70,6 @@ "husky": "^9.1.6", "less": "^4.1.3", "lint-staged": "^15.2.10", - "np": "^10.0.5", "prettier": "^3.3.3", "rc-test": "^7.0.14", "react": "^18.3.1", diff --git a/src/Menu.tsx b/src/Menu.tsx index edad0c5b..b5dfdaf9 100644 --- a/src/Menu.tsx +++ b/src/Menu.tsx @@ -1,9 +1,9 @@ import classNames from 'classnames'; -import type { CSSMotionProps } from 'rc-motion'; +import type { CSSMotionProps } from '@rc-component/motion'; import Overflow from 'rc-overflow'; -import useMergedState from 'rc-util/lib/hooks/useMergedState'; -import isEqual from 'rc-util/lib/isEqual'; -import warning from 'rc-util/lib/warning'; +import useMergedState from '@rc-component/util/lib/hooks/useMergedState'; +import isEqual from '@rc-component/util/lib/isEqual'; +import warning from '@rc-component/util/lib/warning'; import * as React from 'react'; import { useImperativeHandle } from 'react'; import { flushSync } from 'react-dom'; diff --git a/src/MenuItem.tsx b/src/MenuItem.tsx index fb83fece..a806bdea 100644 --- a/src/MenuItem.tsx +++ b/src/MenuItem.tsx @@ -1,9 +1,9 @@ import classNames from 'classnames'; import Overflow from 'rc-overflow'; -import KeyCode from 'rc-util/lib/KeyCode'; -import omit from 'rc-util/lib/omit'; -import { useComposeRef } from 'rc-util/lib/ref'; -import warning from 'rc-util/lib/warning'; +import KeyCode from '@rc-component/util/lib/KeyCode'; +import omit from '@rc-component/util/lib/omit'; +import { useComposeRef } from '@rc-component/util/lib/ref'; +import warning from '@rc-component/util/lib/warning'; import * as React from 'react'; import { useMenuId } from './context/IdContext'; import { MenuContext } from './context/MenuContext'; diff --git a/src/MenuItemGroup.tsx b/src/MenuItemGroup.tsx index c41bd7f3..dfe8b30f 100644 --- a/src/MenuItemGroup.tsx +++ b/src/MenuItemGroup.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import omit from 'rc-util/lib/omit'; +import omit from '@rc-component/util/lib/omit'; import * as React from 'react'; import { MenuContext } from './context/MenuContext'; import { useFullPath, useMeasure } from './context/PathContext'; diff --git a/src/SubMenu/InlineSubMenuList.tsx b/src/SubMenu/InlineSubMenuList.tsx index b5f48b8d..26de7633 100644 --- a/src/SubMenu/InlineSubMenuList.tsx +++ b/src/SubMenu/InlineSubMenuList.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import CSSMotion from 'rc-motion'; +import CSSMotion from '@rc-component/motion'; import { getMotion } from '../utils/motionUtil'; import MenuContextProvider, { MenuContext } from '../context/MenuContext'; import SubMenuList from './SubMenuList'; @@ -20,13 +20,8 @@ export default function InlineSubMenuList({ }: InlineSubMenuListProps) { const fixedMode: MenuMode = 'inline'; - const { - prefixCls, - forceSubMenuRender, - motion, - defaultMotions, - mode, - } = React.useContext(MenuContext); + const { prefixCls, forceSubMenuRender, motion, defaultMotions, mode } = + React.useContext(MenuContext); // Always use latest mode check const sameModeRef = React.useRef(false); diff --git a/src/SubMenu/PopupTrigger.tsx b/src/SubMenu/PopupTrigger.tsx index e915ad12..cd4f46bc 100644 --- a/src/SubMenu/PopupTrigger.tsx +++ b/src/SubMenu/PopupTrigger.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import Trigger from '@rc-component/trigger'; import classNames from 'classnames'; -import raf from 'rc-util/lib/raf'; -import type { CSSMotionProps } from 'rc-motion'; +import raf from '@rc-component/util/lib/raf'; +import type { CSSMotionProps } from '@rc-component/motion'; import { MenuContext } from '../context/MenuContext'; import { placements, placementsRtl } from '../placements'; import type { MenuMode } from '../interface'; diff --git a/src/SubMenu/index.tsx b/src/SubMenu/index.tsx index 3703918d..59ace838 100644 --- a/src/SubMenu/index.tsx +++ b/src/SubMenu/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import classNames from 'classnames'; import Overflow from 'rc-overflow'; -import warning from 'rc-util/lib/warning'; +import warning from '@rc-component/util/lib/warning'; import SubMenuList from './SubMenuList'; import { parseChildren } from '../utils/commonUtil'; import type { MenuInfo, SubMenuType } from '../interface'; diff --git a/src/context/MenuContext.tsx b/src/context/MenuContext.tsx index c34c4bdf..5327910d 100644 --- a/src/context/MenuContext.tsx +++ b/src/context/MenuContext.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; -import type { CSSMotionProps } from 'rc-motion'; -import useMemo from 'rc-util/lib/hooks/useMemo'; -import isEqual from 'rc-util/lib/isEqual'; +import type { CSSMotionProps } from '@rc-component/motion'; +import useMemo from '@rc-component/util/lib/hooks/useMemo'; +import isEqual from '@rc-component/util/lib/isEqual'; import type { BuiltinPlacements, MenuClickEventHandler, diff --git a/src/hooks/useAccessibility.ts b/src/hooks/useAccessibility.ts index 5cd58e20..d4c18658 100644 --- a/src/hooks/useAccessibility.ts +++ b/src/hooks/useAccessibility.ts @@ -1,6 +1,6 @@ -import { getFocusNodeList } from 'rc-util/lib/Dom/focus'; -import KeyCode from 'rc-util/lib/KeyCode'; -import raf from 'rc-util/lib/raf'; +import { getFocusNodeList } from '@rc-component/util/lib/Dom/focus'; +import KeyCode from '@rc-component/util/lib/KeyCode'; +import raf from '@rc-component/util/lib/raf'; import * as React from 'react'; import { getMenuId } from '../context/IdContext'; import type { MenuMode } from '../interface'; @@ -15,11 +15,7 @@ function getOffset( isRootLevel: boolean, isRtl: boolean, which: number, -): { - offset?: number; - sibling?: boolean; - inlineTrigger?: boolean; -} { +): { offset?: number; sibling?: boolean; inlineTrigger?: boolean } { const prev = 'prev' as const; const next = 'next' as const; const children = 'children' as const; @@ -27,16 +23,11 @@ function getOffset( // Inline enter is special that we use unique operation if (mode === 'inline' && which === ENTER) { - return { - inlineTrigger: true, - }; + return { inlineTrigger: true }; } type OffsetMap = Record; - const inline: OffsetMap = { - [UP]: prev, - [DOWN]: next, - }; + const inline: OffsetMap = { [UP]: prev, [DOWN]: next }; const horizontal: OffsetMap = { [LEFT]: isRtl ? next : prev, [RIGHT]: isRtl ? prev : next, @@ -68,28 +59,16 @@ function getOffset( switch (type) { case prev: - return { - offset: -1, - sibling: true, - }; + return { offset: -1, sibling: true }; case next: - return { - offset: 1, - sibling: true, - }; + return { offset: 1, sibling: true }; case parent: - return { - offset: -1, - sibling: false, - }; + return { offset: -1, sibling: false }; case children: - return { - offset: 1, - sibling: false, - }; + return { offset: 1, sibling: false }; default: return null; diff --git a/src/hooks/useKeyRecords.ts b/src/hooks/useKeyRecords.ts index c4c884e9..f9dda910 100644 --- a/src/hooks/useKeyRecords.ts +++ b/src/hooks/useKeyRecords.ts @@ -1,6 +1,6 @@ import * as React from 'react'; import { useRef, useCallback } from 'react'; -import warning from 'rc-util/lib/warning'; +import warning from '@rc-component/util/lib/warning'; import { nextSlice } from '../utils/timeUtil'; const PATH_SPLIT = '__RC_UTIL_PATH_SPLIT__'; diff --git a/src/hooks/useUUID.ts b/src/hooks/useUUID.ts index cce514ee..45c8a0cd 100644 --- a/src/hooks/useUUID.ts +++ b/src/hooks/useUUID.ts @@ -1,14 +1,12 @@ import * as React from 'react'; -import useMergedState from 'rc-util/lib/hooks/useMergedState'; +import useMergedState from '@rc-component/util/lib/hooks/useMergedState'; const uniquePrefix = Math.random().toFixed(5).toString().slice(2); let internalId = 0; export default function useUUID(id?: string) { - const [uuid, setUUID] = useMergedState(id, { - value: id, - }); + const [uuid, setUUID] = useMergedState(id, { value: id }); React.useEffect(() => { internalId += 1; diff --git a/src/utils/commonUtil.ts b/src/utils/commonUtil.ts index 116ffc79..99da70fa 100644 --- a/src/utils/commonUtil.ts +++ b/src/utils/commonUtil.ts @@ -1,33 +1,30 @@ -import toArray from "rc-util/lib/Children/toArray"; +import toArray from '@rc-component/util/lib/Children/toArray'; import * as React from 'react'; export function parseChildren( - children: React.ReactNode | undefined, - keyPath: string[], - ) { - return toArray(children).map((child, index) => { - if (React.isValidElement(child)) { - const { key } = child; - let eventKey = (child.props as any)?.eventKey ?? key; - - const emptyKey = eventKey === null || eventKey === undefined; - - if (emptyKey) { - eventKey = `tmp_key-${[...keyPath, index].join('-')}`; - } - - const cloneProps = { - key: eventKey, - eventKey, - } as any; - - if (process.env.NODE_ENV !== 'production' && emptyKey) { - cloneProps.warnKey = true; - } - - return React.cloneElement(child, cloneProps); + children: React.ReactNode | undefined, + keyPath: string[], +) { + return toArray(children).map((child, index) => { + if (React.isValidElement(child)) { + const { key } = child; + let eventKey = (child.props as any)?.eventKey ?? key; + + const emptyKey = eventKey === null || eventKey === undefined; + + if (emptyKey) { + eventKey = `tmp_key-${[...keyPath, index].join('-')}`; } - - return child; - }); - } \ No newline at end of file + + const cloneProps = { key: eventKey, eventKey } as any; + + if (process.env.NODE_ENV !== 'production' && emptyKey) { + cloneProps.warnKey = true; + } + + return React.cloneElement(child, cloneProps); + } + + return child; + }); +} diff --git a/src/utils/motionUtil.ts b/src/utils/motionUtil.ts index 09042d07..c09e8f34 100644 --- a/src/utils/motionUtil.ts +++ b/src/utils/motionUtil.ts @@ -1,4 +1,4 @@ -import type { CSSMotionProps } from 'rc-motion'; +import type { CSSMotionProps } from '@rc-component/motion'; export function getMotion( mode: string, diff --git a/src/utils/warnUtil.ts b/src/utils/warnUtil.ts index afd5c3cf..5cf99b36 100644 --- a/src/utils/warnUtil.ts +++ b/src/utils/warnUtil.ts @@ -1,4 +1,4 @@ -import warning from 'rc-util/lib/warning'; +import warning from '@rc-component/util/lib/warning'; /** * `onClick` event return `info.item` which point to react node directly. diff --git a/tests/Focus.spec.tsx b/tests/Focus.spec.tsx index 5457895f..0b299e75 100644 --- a/tests/Focus.spec.tsx +++ b/tests/Focus.spec.tsx @@ -1,6 +1,6 @@ /* eslint-disable no-undef */ import { act, fireEvent, render } from '@testing-library/react'; -import { spyElementPrototypes } from 'rc-util/lib/test/domHook'; +import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook'; import React from 'react'; import Menu, { MenuItem, MenuItemGroup, MenuRef, SubMenu } from '../src'; diff --git a/tests/Keyboard.spec.tsx b/tests/Keyboard.spec.tsx index 73544b0f..68a4a372 100644 --- a/tests/Keyboard.spec.tsx +++ b/tests/Keyboard.spec.tsx @@ -1,7 +1,7 @@ /* eslint-disable no-undef, react/no-multi-comp, react/jsx-curly-brace-presence, max-classes-per-file */ import { fireEvent, render } from '@testing-library/react'; -import KeyCode from 'rc-util/lib/KeyCode'; -import { spyElementPrototypes } from 'rc-util/lib/test/domHook'; +import KeyCode from '@rc-component/util/lib/KeyCode'; +import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook'; import React from 'react'; import { act } from 'react-dom/test-utils'; import Menu, { MenuItem, SubMenu } from '../src'; diff --git a/tests/Menu.spec.tsx b/tests/Menu.spec.tsx index fc7326ef..f0ee8c99 100644 --- a/tests/Menu.spec.tsx +++ b/tests/Menu.spec.tsx @@ -1,8 +1,8 @@ /* eslint-disable no-undef, react/no-multi-comp, react/jsx-curly-brace-presence, max-classes-per-file */ import type { MenuMode } from '@/interface'; import { fireEvent, render } from '@testing-library/react'; -import KeyCode from 'rc-util/lib/KeyCode'; -import { resetWarned } from 'rc-util/lib/warning'; +import KeyCode from '@rc-component/util/lib/KeyCode'; +import { resetWarned } from '@rc-component/util/lib/warning'; import React from 'react'; import { act } from 'react-dom/test-utils'; import type { MenuRef } from '../src'; @@ -20,9 +20,9 @@ jest.mock('@rc-component/trigger', () => { }); }); -jest.mock('rc-motion', () => { +jest.mock('@rc-component/motion', () => { const react = require('react'); - let Motion = jest.requireActual('rc-motion'); + let Motion = jest.requireActual('@rc-component/motion'); Motion = Motion.default || Motion; return react.forwardRef((props, ref) => { @@ -333,7 +333,7 @@ describe('Menu', () => { // don't use selectedKeys as string // it is a compatible feature for https://github.com/ant-design/ant-design/issues/29429 const { container } = render( - + 1 2 , diff --git a/tests/MenuItem.spec.tsx b/tests/MenuItem.spec.tsx index d5cc0d12..7e7e2177 100644 --- a/tests/MenuItem.spec.tsx +++ b/tests/MenuItem.spec.tsx @@ -1,6 +1,6 @@ /* eslint-disable no-undef */ import { fireEvent, render } from '@testing-library/react'; -import KeyCode from 'rc-util/lib/KeyCode'; +import KeyCode from '@rc-component/util/lib/KeyCode'; import React from 'react'; import Menu, { MenuItem, MenuItemGroup, SubMenu } from '../src'; diff --git a/tests/Responsive.spec.tsx b/tests/Responsive.spec.tsx index 9d1e6ff6..a59cfa4c 100644 --- a/tests/Responsive.spec.tsx +++ b/tests/Responsive.spec.tsx @@ -1,8 +1,8 @@ /* eslint-disable no-undef, react/no-multi-comp, react/jsx-curly-brace-presence, max-classes-per-file */ import { act, fireEvent, render } from '@testing-library/react'; import ResizeObserver from 'rc-resize-observer'; -import KeyCode from 'rc-util/lib/KeyCode'; -import { spyElementPrototype } from 'rc-util/lib/test/domHook'; +import KeyCode from '@rc-component/util/lib/KeyCode'; +import { spyElementPrototype } from '@rc-component/util/lib/test/domHook'; import React from 'react'; import Menu, { MenuItem, SubMenu } from '../src'; import { OVERFLOW_KEY } from '../src/hooks/useKeyRecords'; diff --git a/tests/SubMenu.spec.tsx b/tests/SubMenu.spec.tsx index f77e6d76..6fa748b4 100644 --- a/tests/SubMenu.spec.tsx +++ b/tests/SubMenu.spec.tsx @@ -1,6 +1,6 @@ /* eslint-disable no-undef */ import { act, fireEvent, render } from '@testing-library/react'; -import { resetWarned } from 'rc-util/lib/warning'; +import { resetWarned } from '@rc-component/util/lib/warning'; import React from 'react'; import Menu, { MenuItem, SubMenu } from '../src'; import { isActive, last } from './util'; From 515c03bee670f0b439b9ef250713829c55b2cae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Sun, 23 Feb 2025 18:13:56 +0800 Subject: [PATCH 2/6] chore: update package name to @rc-component/menu --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c3d8103d..da934397 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "rc-menu", + "name": "@rc-component/menu", "version": "9.16.1", "description": "menu ui component for react", "keywords": [ From 61a64675b746eac1a920e49b67c16970a784ed9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Sun, 23 Feb 2025 19:00:55 +0800 Subject: [PATCH 3/6] chore: update import paths to @rc-component/menu in example files --- docs/examples/fragment.tsx | 2 +- docs/examples/inlineCollapsed.tsx | 18 +++++++---- docs/examples/keyPath.tsx | 2 +- docs/examples/menuItemGroup.tsx | 10 +++++-- docs/examples/multiple.tsx | 2 +- docs/examples/openKeys.tsx | 2 +- docs/examples/rtl-antd.tsx | 7 ++++- docs/examples/scrollable.tsx | 2 +- docs/examples/selectedKeys.tsx | 10 +++---- docs/examples/single.tsx | 50 +++++++++++++++---------------- package.json | 2 +- tsconfig.json | 2 +- 12 files changed, 63 insertions(+), 46 deletions(-) diff --git a/docs/examples/fragment.tsx b/docs/examples/fragment.tsx index 8dc52457..825272dc 100644 --- a/docs/examples/fragment.tsx +++ b/docs/examples/fragment.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import Menu, { SubMenu, Item as MenuItem, Divider } from 'rc-menu'; +import Menu, { SubMenu, Item as MenuItem, Divider } from '@rc-component/menu'; import '../../assets/index.less'; export default () => ( diff --git a/docs/examples/inlineCollapsed.tsx b/docs/examples/inlineCollapsed.tsx index bc6cbef5..691f8f03 100644 --- a/docs/examples/inlineCollapsed.tsx +++ b/docs/examples/inlineCollapsed.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import Menu from 'rc-menu'; +import Menu from '@rc-component/menu'; import './inlineCollapsed.less'; const App = () => { @@ -7,7 +7,11 @@ const App = () => { return ( <> { { key: '3', label: 'item 2' }, { key: '4', label: 'item 3' }, { - key: '5', label: 'SubMenu', children: [ + key: '5', + label: 'SubMenu', + children: [ { key: '6', label: 'item 4' }, { key: '7', label: 'item 5' }, { key: '8', label: 'item 6' }, - ] - } + ], + }, ], }, ]} /> ); -} +}; export default App; diff --git a/docs/examples/keyPath.tsx b/docs/examples/keyPath.tsx index 30a5542e..0cf3e0c6 100644 --- a/docs/examples/keyPath.tsx +++ b/docs/examples/keyPath.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import Menu, { SubMenu, Item as MenuItem } from 'rc-menu'; +import Menu, { SubMenu, Item as MenuItem } from '@rc-component/menu'; import '../../assets/index.less'; diff --git a/docs/examples/menuItemGroup.tsx b/docs/examples/menuItemGroup.tsx index b598ddda..52fa5d8f 100644 --- a/docs/examples/menuItemGroup.tsx +++ b/docs/examples/menuItemGroup.tsx @@ -1,14 +1,20 @@ /* eslint no-console:0 */ import React from 'react'; -import Menu, { Item as MenuItem, ItemGroup as MenuItemGroup } from 'rc-menu'; +import Menu, { + Item as MenuItem, + ItemGroup as MenuItemGroup, +} from '@rc-component/menu'; import '../../assets/index.less'; export default () => (

menu item group

- console.log('click')}> + console.log('click')} + > 2 3 diff --git a/docs/examples/multiple.tsx b/docs/examples/multiple.tsx index 9b9f5057..ec6fa8bf 100644 --- a/docs/examples/multiple.tsx +++ b/docs/examples/multiple.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import Menu, { SubMenu, Item as MenuItem, Divider } from 'rc-menu'; +import Menu, { SubMenu, Item as MenuItem, Divider } from '@rc-component/menu'; import '../../assets/index.less'; diff --git a/docs/examples/openKeys.tsx b/docs/examples/openKeys.tsx index f83ec15d..daddc585 100644 --- a/docs/examples/openKeys.tsx +++ b/docs/examples/openKeys.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import Menu, { SubMenu, Item as MenuItem } from 'rc-menu'; +import Menu, { SubMenu, Item as MenuItem } from '@rc-component/menu'; import '../../assets/index.less'; diff --git a/docs/examples/rtl-antd.tsx b/docs/examples/rtl-antd.tsx index 7ba5bdd1..466936f4 100644 --- a/docs/examples/rtl-antd.tsx +++ b/docs/examples/rtl-antd.tsx @@ -2,7 +2,12 @@ import React from 'react'; import type { CSSMotionProps } from '@rc-component/motion'; -import Menu, { SubMenu, Item as MenuItem, Divider, MenuProps } from 'rc-menu'; +import Menu, { + SubMenu, + Item as MenuItem, + Divider, + MenuProps, +} from '@rc-component/menu'; import '../../assets/index.less'; function handleClick(info) { diff --git a/docs/examples/scrollable.tsx b/docs/examples/scrollable.tsx index a7ee7b67..a6ae9e1f 100644 --- a/docs/examples/scrollable.tsx +++ b/docs/examples/scrollable.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import Menu, { Item as MenuItem } from 'rc-menu'; +import Menu, { Item as MenuItem } from '@rc-component/menu'; import '../../assets/index.less'; diff --git a/docs/examples/selectedKeys.tsx b/docs/examples/selectedKeys.tsx index aa68aa97..545ace7a 100644 --- a/docs/examples/selectedKeys.tsx +++ b/docs/examples/selectedKeys.tsx @@ -1,15 +1,15 @@ /* eslint no-console:0 */ import React from 'react'; -import Menu, { SubMenu, Item as MenuItem } from 'rc-menu'; +import Menu, { SubMenu, Item as MenuItem } from '@rc-component/menu'; import '../../assets/index.less'; interface TestState { - destroyed: boolean; - selectedKeys: string[]; - openKeys: string[]; - } + destroyed: boolean; + selectedKeys: string[]; + openKeys: string[]; +} class Test extends React.Component { state = { diff --git a/docs/examples/single.tsx b/docs/examples/single.tsx index 0cee87b3..a6b80f2a 100644 --- a/docs/examples/single.tsx +++ b/docs/examples/single.tsx @@ -1,37 +1,37 @@ /* eslint no-console:0 */ import React from 'react'; -import Menu from 'rc-menu'; +import Menu from '@rc-component/menu'; import '../../assets/index.less'; const menu1List = [ { - titleLocalKey: "Properties", - key: "Properties" + titleLocalKey: 'Properties', + key: 'Properties', }, { - titleLocalKey: "Resources", - key: "Resources", + titleLocalKey: 'Resources', + key: 'Resources', children: [ { - titleLocalKey: "FAQ", - key: "Faq", - isSub: true + titleLocalKey: 'FAQ', + key: 'Faq', + isSub: true, }, { - titleLocalKey: "Learn", - key: "Learn", - isSub: true - } - ] + titleLocalKey: 'Learn', + key: 'Learn', + isSub: true, + }, + ], }, { - titleLocalKey: "About Us", - key: "AboutUs" - } + titleLocalKey: 'About Us', + key: 'AboutUs', + }, ]; -const menu1Items = (values) => { +const menu1Items = values => { if (!values) { return undefined; } @@ -39,7 +39,7 @@ const menu1Items = (values) => { return { label:
{item.titleLocalKey}
, key: item.key, - children: menu1Items(item.children) + children: menu1Items(item.children), }; }); }; @@ -48,10 +48,10 @@ console.log(menu1Items(menu1List)); export default () => ( -) + selectable={false} + mode="inline" + defaultOpenKeys={['Resources']} + style={{ width: '100%' }} + items={menu1Items(menu1List)} + /> +); diff --git a/package.json b/package.json index da934397..d8363336 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "lint": "eslint src/ --ext .tsx,.ts,.jsx,.js", "now-build": "npm run build", "prepublishOnly": "npm run compile && rc-np", - "postpublish": "tnpm sync rc-menu", + "postpublish": "tnpm sync @rc-component/menu", "start": "dumi dev", "test": "rc-test", "prepare": "husky && dumi setup" diff --git a/tsconfig.json b/tsconfig.json index 9d879602..0e7a3f4a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,7 @@ "paths": { "@/*": ["src/*"], "@@/*": [".dumi/tmp/*"], - "rc-menu": ["src/index.ts"] + "@rc-component/menu": ["src/index.ts"] } } } From e983bb06c7b0890f878741e2b6da31bac9e8b533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Tue, 25 Feb 2025 10:58:10 +0800 Subject: [PATCH 4/6] docs: format --- .prettierrc | 2 ++ README.md | 11 +++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.prettierrc b/.prettierrc index 73e9b594..c28db5cd 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,6 +3,8 @@ "semi": true, "singleQuote": true, "tabWidth": 2, + "printWidth": 100, + "proseWrap": "never", "trailingComma": "all", "arrowParens": "avoid" } diff --git a/README.md b/README.md index a826091b..1f21241e 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,7 @@ React Menu Component. port from https://github.com/kissyteam/menu -[![NPM version][npm-image]][npm-url] -[![npm download][download-image]][download-url] -[![build status][github-actions-image]][github-actions-url] -[![Codecov][codecov-image]][codecov-url] -[![bundle size][bundlephobia-image]][bundlephobia-url] -[![dumi][dumi-image]][dumi-url] +[![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![bundle size][bundlephobia-image]][bundlephobia-url] [![dumi][dumi-image]][dumi-url] [npm-image]: http://img.shields.io/npm/v/rc-menu.svg?style=flat-square [npm-url]: http://npmjs.org/package/rc-menu @@ -55,8 +50,8 @@ ReactDOM.render( ## Compatibility | [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | [Electron](http://godban.github.io/browsers-support-badges/)
Electron | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | +| --- | --- | --- | --- | --- | +| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | ## API From 03d7ec6ab8ce2d94e189b3be50eee2151047e391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Tue, 25 Feb 2025 10:59:35 +0800 Subject: [PATCH 5/6] chore: back of version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8363336..1fdbdc9a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rc-component/menu", - "version": "9.16.1", + "version": "1.0.0", "description": "menu ui component for react", "keywords": [ "react", From c1d76a0aa701b1a2318b0d71f8c60a2167e02e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Tue, 25 Feb 2025 11:00:14 +0800 Subject: [PATCH 6/6] chore: update deps --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1fdbdc9a..89971703 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "rc-overflow": "^1.3.1" }, "devDependencies": { - "@rc-component/father-plugin": "^1.0.0", + "@rc-component/father-plugin": "^2.0.2", "@rc-component/np": "^1.0.3", "@testing-library/jest-dom": "^6.1.5", "@testing-library/react": "^16.0.0",