From abeefe183b33b943f955e3ff9d5b2d1dc0427e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Tue, 18 Feb 2025 15:18:56 +0800 Subject: [PATCH 1/3] chore(deps): update RC component dependencies --- package.json | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 22006826..63f1fd44 100644 --- a/package.json +++ b/package.json @@ -64,15 +64,14 @@ "typescript": "^5.1.6" }, "dependencies": { - "@babel/runtime": "^7.23.2", + "@rc-component/motion": "^1.1.4", "@rc-component/portal": "^1.1.0", - "classnames": "^2.3.2", - "rc-motion": "^2.0.0", - "rc-resize-observer": "^1.3.1", - "rc-util": "^5.44.0" + "@rc-component/resize-observer": "^1.0.0", + "@rc-component/util": "^1.2.1", + "classnames": "^2.3.2" }, "peerDependencies": { "react": ">=16.9.0", "react-dom": ">=16.9.0" } -} +} \ No newline at end of file From f1730f9cbdeb243761512f66c15b5786fee51c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Tue, 18 Feb 2025 15:43:50 +0800 Subject: [PATCH 2/3] refactor: migrate from rc-* dependencies to @rc-component/* packages --- .gitignore | 1 + docs/examples/body-overflow.tsx | 2 +- docs/examples/case.tsx | 6 +++--- docs/examples/click-nested.tsx | 2 +- docs/examples/clip.tsx | 2 +- docs/examples/container.tsx | 2 +- docs/examples/large-popup.tsx | 2 +- docs/examples/nested.tsx | 2 +- docs/examples/point.tsx | 2 +- docs/examples/portal.tsx | 2 +- docs/examples/shadow.tsx | 2 +- docs/examples/simple.tsx | 2 +- docs/examples/static-scroll.tsx | 2 +- docs/examples/visible-fallback.tsx | 4 ++-- src/Popup/Mask.tsx | 4 ++-- src/Popup/index.tsx | 10 +++++----- src/TriggerWrapper.tsx | 2 +- src/hooks/useAlign.ts | 8 ++++---- src/hooks/useWatch.ts | 2 +- src/hooks/useWinClick.ts | 4 ++-- src/index.tsx | 16 ++++++++-------- src/interface.ts | 2 +- tests/align.test.tsx | 4 ++-- tests/arrow.test.jsx | 2 +- tests/basic.test.jsx | 2 +- tests/flip-visibleFirst.test.tsx | 2 +- tests/flip.test.tsx | 4 ++-- tests/flipShift.test.tsx | 2 +- tests/mask.test.jsx | 2 +- tests/mobile.test.tsx | 4 ++-- tests/portal.test.jsx | 2 +- tests/rect.test.tsx | 2 +- tests/ref.test.tsx | 2 +- tests/shadow.test.tsx | 2 +- tsconfig.json | 2 +- 35 files changed, 57 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index f44d17fe..02e6333b 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ coverage yarn.lock package-lock.json bun.lockb +.vscode # dumi .umi diff --git a/docs/examples/body-overflow.tsx b/docs/examples/body-overflow.tsx index d4b272ea..7183b019 100644 --- a/docs/examples/body-overflow.tsx +++ b/docs/examples/body-overflow.tsx @@ -1,5 +1,5 @@ /* eslint no-console:0 */ -import Trigger from 'rc-trigger'; +import Trigger from '@rc-component/trigger'; import React from 'react'; import { createPortal } from 'react-dom'; import '../../assets/index.less'; diff --git a/docs/examples/case.tsx b/docs/examples/case.tsx index c1b8ae9b..060a220b 100644 --- a/docs/examples/case.tsx +++ b/docs/examples/case.tsx @@ -1,9 +1,9 @@ /* eslint no-console:0 */ import React from 'react'; -import type { CSSMotionProps } from 'rc-motion'; -import type { ActionType, BuildInPlacements } from 'rc-trigger'; -import Trigger from 'rc-trigger'; +import type { CSSMotionProps } from '@rc-component/motion'; +import type { ActionType, BuildInPlacements } from '@rc-component/trigger'; +import Trigger from '@rc-component/trigger'; import './case.less'; const builtinPlacements: BuildInPlacements = { diff --git a/docs/examples/click-nested.tsx b/docs/examples/click-nested.tsx index 11c7e430..0509d07e 100644 --- a/docs/examples/click-nested.tsx +++ b/docs/examples/click-nested.tsx @@ -1,6 +1,6 @@ /* eslint no-console:0 */ -import Trigger from 'rc-trigger'; +import Trigger from '@rc-component/trigger'; import React from 'react'; import '../../assets/index.less'; diff --git a/docs/examples/clip.tsx b/docs/examples/clip.tsx index 5f096b45..7ba1986e 100644 --- a/docs/examples/clip.tsx +++ b/docs/examples/clip.tsx @@ -1,5 +1,5 @@ /* eslint no-console:0 */ -import Trigger from 'rc-trigger'; +import Trigger from '@rc-component/trigger'; import React from 'react'; import '../../assets/index.less'; diff --git a/docs/examples/container.tsx b/docs/examples/container.tsx index 9ea1ff09..41d1e692 100644 --- a/docs/examples/container.tsx +++ b/docs/examples/container.tsx @@ -1,5 +1,5 @@ /* eslint no-console:0 */ -import Trigger from 'rc-trigger'; +import Trigger from '@rc-component/trigger'; import React from 'react'; import '../../assets/index.less'; diff --git a/docs/examples/large-popup.tsx b/docs/examples/large-popup.tsx index 8d402d32..e132cb0e 100644 --- a/docs/examples/large-popup.tsx +++ b/docs/examples/large-popup.tsx @@ -1,5 +1,5 @@ /* eslint no-console:0 */ -import Trigger from 'rc-trigger'; +import Trigger from '@rc-component/trigger'; import React from 'react'; import '../../assets/index.less'; diff --git a/docs/examples/nested.tsx b/docs/examples/nested.tsx index 12dffe09..fbd60f70 100644 --- a/docs/examples/nested.tsx +++ b/docs/examples/nested.tsx @@ -2,7 +2,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import Trigger from 'rc-trigger'; +import Trigger from '@rc-component/trigger'; import '../../assets/index.less'; const builtinPlacements = { diff --git a/docs/examples/point.tsx b/docs/examples/point.tsx index 1e1e16ef..839092de 100644 --- a/docs/examples/point.tsx +++ b/docs/examples/point.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import Trigger, { ActionType } from 'rc-trigger'; +import Trigger, { ActionType } from '@rc-component/trigger'; import '../../assets/index.less'; import './point.less'; diff --git a/docs/examples/portal.tsx b/docs/examples/portal.tsx index a1b66576..2b2c6fa4 100644 --- a/docs/examples/portal.tsx +++ b/docs/examples/portal.tsx @@ -1,6 +1,6 @@ /* eslint no-console:0 */ -import Trigger from 'rc-trigger'; +import Trigger from '@rc-component/trigger'; import React from 'react'; import { createPortal } from 'react-dom'; import '../../assets/index.less'; diff --git a/docs/examples/shadow.tsx b/docs/examples/shadow.tsx index 562f6d5b..1d4e969c 100644 --- a/docs/examples/shadow.tsx +++ b/docs/examples/shadow.tsx @@ -1,5 +1,5 @@ /* eslint no-console:0 */ -import Trigger from 'rc-trigger'; +import Trigger from '@rc-component/trigger'; import React from 'react'; import { createRoot } from 'react-dom/client'; import '../../assets/index.less'; diff --git a/docs/examples/simple.tsx b/docs/examples/simple.tsx index 5e85d544..37131216 100644 --- a/docs/examples/simple.tsx +++ b/docs/examples/simple.tsx @@ -1,6 +1,6 @@ /* eslint no-console:0 */ -import Trigger, { ActionType } from 'rc-trigger'; +import Trigger, { ActionType } from '@rc-component/trigger'; import React from 'react'; import '../../assets/index.less'; diff --git a/docs/examples/static-scroll.tsx b/docs/examples/static-scroll.tsx index 1f0e6e2b..79979f33 100644 --- a/docs/examples/static-scroll.tsx +++ b/docs/examples/static-scroll.tsx @@ -1,5 +1,5 @@ /* eslint no-console:0 */ -import Trigger from 'rc-trigger'; +import Trigger from '@rc-component/trigger'; import React from 'react'; import '../../assets/index.less'; import { builtinPlacements } from './inside'; diff --git a/docs/examples/visible-fallback.tsx b/docs/examples/visible-fallback.tsx index 3e0881f2..0c1e1ea0 100644 --- a/docs/examples/visible-fallback.tsx +++ b/docs/examples/visible-fallback.tsx @@ -1,6 +1,6 @@ /* eslint no-console:0 */ -import type { AlignType, TriggerRef } from 'rc-trigger'; -import Trigger from 'rc-trigger'; +import type { AlignType, TriggerRef } from '@rc-component/trigger'; +import Trigger from '@rc-component/trigger'; import React from 'react'; import '../../assets/index.less'; diff --git a/src/Popup/Mask.tsx b/src/Popup/Mask.tsx index 86429ee4..125fe458 100644 --- a/src/Popup/Mask.tsx +++ b/src/Popup/Mask.tsx @@ -1,6 +1,6 @@ import classNames from 'classnames'; -import type { CSSMotionProps } from 'rc-motion'; -import CSSMotion from 'rc-motion'; +import type { CSSMotionProps } from '@rc-component/motion'; +import CSSMotion from '@rc-component/motion'; import * as React from 'react'; export interface MaskProps { diff --git a/src/Popup/index.tsx b/src/Popup/index.tsx index 47666c19..167a4aa5 100644 --- a/src/Popup/index.tsx +++ b/src/Popup/index.tsx @@ -1,9 +1,9 @@ import classNames from 'classnames'; -import type { CSSMotionProps } from 'rc-motion'; -import CSSMotion from 'rc-motion'; -import ResizeObserver from 'rc-resize-observer'; -import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect'; -import { composeRef } from 'rc-util/lib/ref'; +import type { CSSMotionProps } from '@rc-component/motion'; +import CSSMotion from '@rc-component/motion'; +import ResizeObserver from '@rc-component/resize-observer'; +import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; +import { composeRef } from '@rc-component/util/lib/ref'; import * as React from 'react'; import type { TriggerProps } from '../'; import type { AlignType, ArrowPos, ArrowTypeOuter } from '../interface'; diff --git a/src/TriggerWrapper.tsx b/src/TriggerWrapper.tsx index 0facc9ad..f6c34610 100644 --- a/src/TriggerWrapper.tsx +++ b/src/TriggerWrapper.tsx @@ -3,7 +3,7 @@ import { getNodeRef, supportRef, useComposeRef, -} from 'rc-util/lib/ref'; +} from '@rc-component/util/lib/ref'; import * as React from 'react'; import type { TriggerProps } from '.'; diff --git a/src/hooks/useAlign.ts b/src/hooks/useAlign.ts index 8af82525..f352a33d 100644 --- a/src/hooks/useAlign.ts +++ b/src/hooks/useAlign.ts @@ -1,7 +1,7 @@ -import { isDOM } from 'rc-util/lib/Dom/findDOMNode'; -import isVisible from 'rc-util/lib/Dom/isVisible'; -import useEvent from 'rc-util/lib/hooks/useEvent'; -import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect'; +import { isDOM } from '@rc-component/util/lib/Dom/findDOMNode'; +import isVisible from '@rc-component/util/lib/Dom/isVisible'; +import useEvent from '@rc-component/util/lib/hooks/useEvent'; +import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; import * as React from 'react'; import type { TriggerProps } from '..'; import type { diff --git a/src/hooks/useWatch.ts b/src/hooks/useWatch.ts index eba0fd80..d5d3fd66 100644 --- a/src/hooks/useWatch.ts +++ b/src/hooks/useWatch.ts @@ -1,4 +1,4 @@ -import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect'; +import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; import { collectScroller, getWin } from '../util'; export default function useWatch( diff --git a/src/hooks/useWinClick.ts b/src/hooks/useWinClick.ts index 9e44fe2f..e14bb482 100644 --- a/src/hooks/useWinClick.ts +++ b/src/hooks/useWinClick.ts @@ -1,5 +1,5 @@ -import { getShadowRoot } from 'rc-util/lib/Dom/shadow'; -import { warning } from 'rc-util/lib/warning'; +import { getShadowRoot } from '@rc-component/util/lib/Dom/shadow'; +import { warning } from '@rc-component/util/lib/warning'; import * as React from 'react'; import { getWin } from '../util'; diff --git a/src/index.tsx b/src/index.tsx index 49e4cbfb..5bd2bf58 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,13 +1,13 @@ import Portal from '@rc-component/portal'; import classNames from 'classnames'; -import type { CSSMotionProps } from 'rc-motion'; -import ResizeObserver from 'rc-resize-observer'; -import { isDOM } from 'rc-util/lib/Dom/findDOMNode'; -import { getShadowRoot } from 'rc-util/lib/Dom/shadow'; -import useEvent from 'rc-util/lib/hooks/useEvent'; -import useId from 'rc-util/lib/hooks/useId'; -import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect'; -import isMobile from 'rc-util/lib/isMobile'; +import type { CSSMotionProps } from '@rc-component/motion'; +import ResizeObserver from '@rc-component/resize-observer'; +import { isDOM } from '@rc-component/util/lib/Dom/findDOMNode'; +import { getShadowRoot } from '@rc-component/util/lib/Dom/shadow'; +import useEvent from '@rc-component/util/lib/hooks/useEvent'; +import useId from '@rc-component/util/lib/hooks/useId'; +import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; +import isMobile from '@rc-component/util/lib/isMobile'; import * as React from 'react'; import Popup from './Popup'; import TriggerWrapper from './TriggerWrapper'; diff --git a/src/interface.ts b/src/interface.ts index ddb27eec..93fe2832 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -1,4 +1,4 @@ -import type { CSSMotionProps } from 'rc-motion'; +import type { CSSMotionProps } from '@rc-component/motion'; export type Placement = | 'top' diff --git a/tests/align.test.tsx b/tests/align.test.tsx index 945b132e..1ef62f02 100644 --- a/tests/align.test.tsx +++ b/tests/align.test.tsx @@ -1,11 +1,11 @@ import { act, cleanup, 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 type { TriggerProps, TriggerRef } from '../src'; import Trigger from '../src'; import { awaitFakeTimer } from './util'; -import { _rs } from 'rc-resize-observer'; +import { _rs } from '@rc-component/resize-observer'; export const triggerResize = (target: Element) => { act(() => { diff --git a/tests/arrow.test.jsx b/tests/arrow.test.jsx index 24df7055..19c53b9f 100644 --- a/tests/arrow.test.jsx +++ b/tests/arrow.test.jsx @@ -4,7 +4,7 @@ import { act, cleanup, render } from '@testing-library/react'; import { spyElementPrototype, spyElementPrototypes, -} from 'rc-util/lib/test/domHook'; +} from '@rc-component/util/lib/test/domHook'; import Trigger from '../src'; describe('Trigger.Arrow', () => { diff --git a/tests/basic.test.jsx b/tests/basic.test.jsx index 58b912b8..10312488 100644 --- a/tests/basic.test.jsx +++ b/tests/basic.test.jsx @@ -1,7 +1,7 @@ /* eslint-disable max-classes-per-file */ import { act, cleanup, 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, { StrictMode, createRef } from 'react'; import ReactDOM, { createPortal } from 'react-dom'; import Trigger from '../src'; diff --git a/tests/flip-visibleFirst.test.tsx b/tests/flip-visibleFirst.test.tsx index f44c530f..83194a5e 100644 --- a/tests/flip-visibleFirst.test.tsx +++ b/tests/flip-visibleFirst.test.tsx @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-invalid-this */ import { act, cleanup, render } from '@testing-library/react'; -import { spyElementPrototypes } from 'rc-util/lib/test/domHook'; +import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook'; import * as React from 'react'; import type { AlignType, TriggerProps, TriggerRef } from '../src'; import Trigger from '../src'; diff --git a/tests/flip.test.tsx b/tests/flip.test.tsx index 853ec980..bc1efec6 100644 --- a/tests/flip.test.tsx +++ b/tests/flip.test.tsx @@ -1,6 +1,6 @@ import { act, cleanup, render } from '@testing-library/react'; -import { _rs } from 'rc-resize-observer'; -import { spyElementPrototypes } from 'rc-util/lib/test/domHook'; +import { _rs } from '@rc-component/resize-observer'; +import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook'; import * as React from 'react'; import type { AlignType, TriggerProps } from '../src'; import Trigger from '../src'; diff --git a/tests/flipShift.test.tsx b/tests/flipShift.test.tsx index d9e02a03..57e88e77 100644 --- a/tests/flipShift.test.tsx +++ b/tests/flipShift.test.tsx @@ -1,5 +1,5 @@ import { act, cleanup, 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 Trigger from '../src'; diff --git a/tests/mask.test.jsx b/tests/mask.test.jsx index f27d239d..34760e00 100644 --- a/tests/mask.test.jsx +++ b/tests/mask.test.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { fireEvent, render } from '@testing-library/react'; import Trigger from '../src'; -import CSSMotion from 'rc-motion'; +import CSSMotion from '@rc-component/motion'; import { placementAlignMap } from './util'; describe('Trigger.Mask', () => { diff --git a/tests/mobile.test.tsx b/tests/mobile.test.tsx index b7abaed3..a3269c2b 100644 --- a/tests/mobile.test.tsx +++ b/tests/mobile.test.tsx @@ -1,10 +1,10 @@ import { act, fireEvent, render } from '@testing-library/react'; -import isMobile from 'rc-util/lib/isMobile'; +import isMobile from '@rc-component/util/lib/isMobile'; import React from 'react'; import Trigger from '../src'; import { placementAlignMap } from './util'; -jest.mock('rc-util/lib/isMobile'); +jest.mock('@rc-component/util/lib/isMobile'); describe('Trigger.Mobile', () => { beforeAll(() => { diff --git a/tests/portal.test.jsx b/tests/portal.test.jsx index 699dc06a..79b37351 100644 --- a/tests/portal.test.jsx +++ b/tests/portal.test.jsx @@ -1,7 +1,7 @@ /* eslint-disable max-classes-per-file */ import { act, cleanup, 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 ReactDOM from 'react-dom'; import Trigger from '../src'; diff --git a/tests/rect.test.tsx b/tests/rect.test.tsx index 596689f0..ae26a5b8 100644 --- a/tests/rect.test.tsx +++ b/tests/rect.test.tsx @@ -1,5 +1,5 @@ import { cleanup, 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 Trigger from '../src'; import { awaitFakeTimer } from './util'; diff --git a/tests/ref.test.tsx b/tests/ref.test.tsx index 2d0179e6..bdea4570 100644 --- a/tests/ref.test.tsx +++ b/tests/ref.test.tsx @@ -1,7 +1,7 @@ /* eslint-disable max-classes-per-file */ import { cleanup, 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 Trigger, { type TriggerRef } from '../src'; diff --git a/tests/shadow.test.tsx b/tests/shadow.test.tsx index b7e05802..ac4109f6 100644 --- a/tests/shadow.test.tsx +++ b/tests/shadow.test.tsx @@ -1,5 +1,5 @@ import { act, fireEvent } from '@testing-library/react'; -import { resetWarned } from 'rc-util/lib/warning'; +import { resetWarned } from '@rc-component/util/lib/warning'; import React from 'react'; import { createRoot } from 'react-dom/client'; import Trigger from '../src'; diff --git a/tsconfig.json b/tsconfig.json index 74b428a6..6db6d940 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "paths": { "@/*": ["src/*"], "@@/*": [".dumi/tmp/*"], - "rc-trigger": ["src/index.tsx"] + "@rc-component/trigger": ["src/index.tsx"] } } } From 52a1c1e9c51114c7d88bfffcd545a9095df67209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Tue, 18 Feb 2025 16:29:44 +0800 Subject: [PATCH 3/3] test: mock ResizeObserver for Jest testing environment --- tests/setup.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/setup.js b/tests/setup.js index a78e9dc9..cd00d9c4 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -1,3 +1,10 @@ // jsdom add motion events to test CSSMotion window.AnimationEvent = window.AnimationEvent || (() => {}); window.TransitionEvent = window.TransitionEvent || (() => {}); +global.ResizeObserver = jest.fn(() => { + return { + observe() { }, + unobserve() { }, + disconnect() { }, + }; +}); \ No newline at end of file