Skip to content

Commit 42bc364

Browse files
authored
fix: avoid rc package deep imports (#603)
1 parent 6a52ca1 commit 42bc364

10 files changed

Lines changed: 12 additions & 29 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
"dependencies": {
4646
"@rc-component/motion": "^1.1.4",
4747
"@rc-component/portal": "^2.1.3",
48-
"@rc-component/util": "^1.9.0",
48+
"@rc-component/util": "^1.11.1",
4949
"clsx": "^2.1.1"
5050
},
5151
"devDependencies": {
5252
"@ant-design/icons": "^5.3.0",
53-
"@rc-component/father-plugin": "^2.0.2",
53+
"@rc-component/father-plugin": "^2.2.0",
5454
"@rc-component/np": "^1.0.0",
5555
"@testing-library/jest-dom": "^6.2.0",
5656
"@testing-library/react": "^16.3.0",

src/Drawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { PortalProps } from '@rc-component/portal';
22
import Portal from '@rc-component/portal';
3-
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
3+
import { useLayoutEffect } from '@rc-component/util';
44
import * as React from 'react';
55
import { RefContext } from './context';
66
import type {

src/DrawerPanel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { clsx } from 'clsx';
22
import * as React from 'react';
33
import { RefContext } from './context';
4-
import pickAttrs from '@rc-component/util/lib/pickAttrs';
5-
import { useComposeRef } from '@rc-component/util/lib/ref';
4+
import { pickAttrs, useComposeRef } from '@rc-component/util';
65

76
export interface DrawerPanelRef {
87
focus: VoidFunction;

src/DrawerPopup.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { clsx } from 'clsx';
22
import type { CSSMotionProps } from '@rc-component/motion';
33
import CSSMotion from '@rc-component/motion';
4-
import pickAttrs from '@rc-component/util/lib/pickAttrs';
4+
import { pickAttrs, useEvent } from '@rc-component/util';
55
import * as React from 'react';
66
import type { DrawerContextProps } from './context';
77
import DrawerContext from './context';
@@ -13,7 +13,6 @@ import DrawerPanel from './DrawerPanel';
1313
import useDrag from './hooks/useDrag';
1414
import { parseWidthHeight } from './util';
1515
import type { DrawerClassNames, DrawerStyles } from './inter';
16-
import { useEvent } from '@rc-component/util';
1716
import useFocusable from './hooks/useFocusable';
1817

1918
export type Placement = 'left' | 'right' | 'top' | 'bottom';

src/hooks/useFocusable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { useLockFocus } from '@rc-component/util/lib/Dom/focus';
2+
import { useLockFocus } from '@rc-component/util';
33

44
export default function useFocusable(
55
getContainer: () => HTMLElement,

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// export this package's api
22
import Drawer from './Drawer';
33
import type { DrawerProps, Placement } from './Drawer';
4+
import type { DrawerPopupProps } from './DrawerPopup';
45

5-
export type { DrawerProps, Placement };
6+
export type { DrawerProps, DrawerPopupProps, Placement };
67

78
export default Drawer;

src/util.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import warning from '@rc-component/util/lib/warning';
2-
import canUseDom from '@rc-component/util/lib/Dom/canUseDom';
1+
import { canUseDom, warning } from '@rc-component/util';
32
import type { DrawerProps } from './Drawer';
43

54
export function parseWidthHeight(value?: number | string) {

tests/focus.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import ReactDOM from 'react-dom';
44
import Drawer from '../src';
55

66
// Mock useLockFocus to track calls
7-
jest.mock('@rc-component/util/lib/Dom/focus', () => {
8-
const actual = jest.requireActual('@rc-component/util/lib/Dom/focus');
7+
jest.mock('@rc-component/util', () => {
8+
const actual = jest.requireActual('@rc-component/util');
99

1010
const useLockFocus = (visible: boolean, ...rest: any[]) => {
1111
(globalThis as any).__useLockFocusVisible = visible;

tests/index.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cleanup, fireEvent, render, act } from '@testing-library/react';
2-
import { resetWarned } from '@rc-component/util/lib/warning';
2+
import { resetWarned } from '@rc-component/util';
33
import React from 'react';
44
import type { DrawerProps } from '../src';
55
import Drawer from '../src';

typings/custom.d.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1 @@
1-
declare module '@rc-component/util/lib/KeyCode' {
2-
const Ret: { ESC: any; TAB: any };
3-
export default Ret;
4-
}
5-
6-
declare module '@rc-component/util/lib/getScrollBarSize' {
7-
const Ret: (b: boolean) => number;
8-
export default Ret;
9-
}
10-
11-
declare module '@rc-component/util/lib/*' {
12-
const Ret: any;
13-
export default Ret;
14-
}
15-
161
declare module 'raf';

0 commit comments

Comments
 (0)