From 28fbc299d34d31be3dd412cca5671c4b5dd6ac26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=89=B3=E5=85=B5?= Date: Thu, 21 May 2026 14:22:15 +0800 Subject: [PATCH 1/2] fix: avoid rc package deep imports --- package.json | 4 ++-- src/Dialog/Content/Panel.tsx | 4 +--- src/Dialog/Content/index.tsx | 3 +-- src/Dialog/index.tsx | 5 +---- src/IDialogPropTypes.ts | 2 +- src/index.ts | 3 ++- tests/focus.spec.tsx | 6 +++--- 7 files changed, 11 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 8b76e000..f15edb2c 100644 --- a/package.json +++ b/package.json @@ -51,12 +51,12 @@ "dependencies": { "@rc-component/motion": "^1.1.3", "@rc-component/portal": "^2.1.0", - "@rc-component/util": "^1.9.0", + "@rc-component/util": "^1.11.1", "clsx": "^2.1.1" }, "devDependencies": { "@rc-component/drawer": "^1.0.0", - "@rc-component/father-plugin": "^2.0.2", + "@rc-component/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.3", "@rc-component/select": "^1.0.0", "@testing-library/jest-dom": "^6.1.6", diff --git a/src/Dialog/Content/Panel.tsx b/src/Dialog/Content/Panel.tsx index fb53ace7..f3fd1cf0 100644 --- a/src/Dialog/Content/Panel.tsx +++ b/src/Dialog/Content/Panel.tsx @@ -1,11 +1,9 @@ import { clsx } from 'clsx'; -import { useComposeRef } from '@rc-component/util/lib/ref'; -import { useLockFocus } from '@rc-component/util/lib/Dom/focus'; +import { pickAttrs, useComposeRef, useLockFocus } from '@rc-component/util'; import React, { useMemo, useRef } from 'react'; import { RefContext } from '../../context'; import type { IDialogPropTypes } from '../../IDialogPropTypes'; import MemoChildren from './MemoChildren'; -import pickAttrs from '@rc-component/util/lib/pickAttrs'; export interface PanelProps extends Omit { prefixCls: string; diff --git a/src/Dialog/Content/index.tsx b/src/Dialog/Content/index.tsx index f3313d53..77539b2c 100644 --- a/src/Dialog/Content/index.tsx +++ b/src/Dialog/Content/index.tsx @@ -1,11 +1,10 @@ import * as React from 'react'; import { useRef } from 'react'; import { clsx } from 'clsx'; -import CSSMotion from '@rc-component/motion'; +import CSSMotion, { type CSSMotionRef } from '@rc-component/motion'; import { offset } from '../../util'; import type { PanelProps, PanelRef } from './Panel'; import Panel from './Panel'; -import type { CSSMotionRef } from '@rc-component/motion/es/CSSMotion'; export type CSSMotionStateRef = Pick; diff --git a/src/Dialog/index.tsx b/src/Dialog/index.tsx index d714eaeb..5d92fd97 100644 --- a/src/Dialog/index.tsx +++ b/src/Dialog/index.tsx @@ -1,14 +1,11 @@ import { clsx } from 'clsx'; -import contains from '@rc-component/util/lib/Dom/contains'; -import useId from '@rc-component/util/lib/hooks/useId'; -import pickAttrs from '@rc-component/util/lib/pickAttrs'; +import { contains, pickAttrs, useId, warning } from '@rc-component/util'; import * as React from 'react'; import { useEffect, useRef } from 'react'; import type { IDialogPropTypes } from '../IDialogPropTypes'; import { getMotionName } from '../util'; import Content, { type ContentRef } from './Content'; import Mask from './Mask'; -import { warning } from '@rc-component/util/lib/warning'; const Dialog: React.FC = (props) => { const { diff --git a/src/IDialogPropTypes.ts b/src/IDialogPropTypes.ts index e39b1616..4ab00b5b 100644 --- a/src/IDialogPropTypes.ts +++ b/src/IDialogPropTypes.ts @@ -1,4 +1,4 @@ -import type { GetContainer } from '@rc-component/util/lib/PortalWrapper'; +import type { GetContainer } from '@rc-component/util'; import type { CSSProperties, ReactNode, SyntheticEvent } from 'react'; export type SemanticName = 'header' | 'body' | 'footer' | 'container' | 'title' | 'wrapper' | 'mask' | 'close'; diff --git a/src/index.ts b/src/index.ts index a7b88678..cd58beab 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,9 @@ import DialogWrap from './DialogWrap'; import Panel from './Dialog/Content/Panel'; +import type { PanelProps } from './Dialog/Content/Panel'; import type { IDialogPropTypes as DialogProps } from './IDialogPropTypes'; -export type { DialogProps }; +export type { DialogProps, PanelProps }; export { Panel }; export default DialogWrap; diff --git a/tests/focus.spec.tsx b/tests/focus.spec.tsx index 9e2449de..ed8bde32 100644 --- a/tests/focus.spec.tsx +++ b/tests/focus.spec.tsx @@ -4,9 +4,9 @@ import ReactDOM from 'react-dom'; import { act, render } from '@testing-library/react'; import Dialog from '../src'; -// Mock: import { useLockFocus } from '@rc-component/util/lib/Dom/focus'; -jest.mock('@rc-component/util/lib/Dom/focus', () => { - const actual = jest.requireActual('@rc-component/util/lib/Dom/focus'); +// Mock: import { useLockFocus } from '@rc-component/util'; +jest.mock('@rc-component/util', () => { + const actual = jest.requireActual('@rc-component/util'); const useLockFocus = (visible: boolean, ...rest: any[]) => { globalThis.__useLockFocusVisible = visible; From 41fb96367a35d9fa63967463eae4b9a1dbfb56f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=89=B3=E5=85=B5?= Date: Mon, 25 May 2026 15:30:54 +0800 Subject: [PATCH 2/2] fix: trim public exports --- src/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index cd58beab..a7b88678 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,8 @@ import DialogWrap from './DialogWrap'; import Panel from './Dialog/Content/Panel'; -import type { PanelProps } from './Dialog/Content/Panel'; import type { IDialogPropTypes as DialogProps } from './IDialogPropTypes'; -export type { DialogProps, PanelProps }; +export type { DialogProps }; export { Panel }; export default DialogWrap;