Skip to content

Commit 5245e8a

Browse files
committed
refactor: avoid deep imports
1 parent 0215da5 commit 5245e8a

8 files changed

Lines changed: 12 additions & 23 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
},
4646
"dependencies": {
4747
"@rc-component/resize-observer": "^1.1.1",
48-
"@rc-component/util": "^1.4.0",
48+
"@rc-component/util": "^1.11.1",
4949
"clsx": "^2.1.1"
5050
},
5151
"devDependencies": {
52-
"@rc-component/father-plugin": "^2.0.3",
52+
"@rc-component/father-plugin": "^2.2.0",
5353
"@rc-component/np": "^1.0.3",
5454
"@testing-library/jest-dom": "^6.6.3",
5555
"@testing-library/react": "^16.0.1",

src/Input.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { clsx } from 'clsx';
2-
import omit from '@rc-component/util/lib/omit';
2+
import { omit, triggerFocus, type InputFocusOptions } from '@rc-component/util';
33
import React, {
44
forwardRef,
55
useEffect,
@@ -15,10 +15,6 @@ import useCountExceed from './hooks/useCountExceed';
1515
import useMergedValue from './hooks/useMergedValue';
1616
import type { ChangeEventInfo, InputProps, InputRef } from './interface';
1717
import { resolveOnChange } from './utils/commonUtils';
18-
import {
19-
triggerFocus,
20-
type InputFocusOptions,
21-
} from '@rc-component/util/lib/Dom/focus';
2218

2319
const Input = forwardRef<InputRef, InputProps>((props, ref) => {
2420
const {

src/ResizableTextArea.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import ResizeObserver from '@rc-component/resize-observer';
2-
import useControlledState from '@rc-component/util/lib/hooks/useControlledState';
3-
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
4-
import raf from '@rc-component/util/lib/raf';
51
import { clsx } from 'clsx';
2+
import ResizeObserver from '@rc-component/resize-observer';
3+
import { raf, useControlledState, useLayoutEffect } from '@rc-component/util';
64
import * as React from 'react';
75
import type { ResizableTextAreaRef, TextAreaProps } from './interface';
86
import calculateAutoSizeStyle from './calculateNodeHeight';

src/hooks/useMergedValue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import useControlledState from '@rc-component/util/lib/hooks/useControlledState';
1+
import { useControlledState } from '@rc-component/util';
22

33
type MergedValue = string | number | readonly string[] | bigint | undefined;
44

src/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type {
77
ReactNode,
88
TextareaHTMLAttributes,
99
} from 'react';
10+
import type { InputFocusOptions } from '@rc-component/util';
1011
import type { LiteralUnion } from './utils/types';
11-
import type { InputFocusOptions } from '@rc-component/util/lib/Dom/focus';
1212

1313
export interface CommonInputProps {
1414
prefix?: ReactNode;

tests/focus.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { fireEvent, render } from '@testing-library/react';
12
import React from 'react';
2-
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
3+
import { spyElementPrototypes } from '@rc-component/util';
34
import Input from '../src';
4-
import { fireEvent, render } from '@testing-library/react';
55

66
const getInputRef = () => {
77
const ref = React.createRef<any>();

tests/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fireEvent, render } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
3-
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
43
import React, { ElementType } from 'react';
4+
import { spyElementPrototypes } from '@rc-component/util';
55
import Input from '../src';
66
import type { InputRef } from '../src/interface';
77
import { resolveOnChange } from '../src/utils/commonUtils';

tests/utils.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// @ts-nocheck
22
import { act } from '@testing-library/react';
3-
import {
4-
_rs as onEsResize,
5-
_rs as onLibResize,
6-
} from '@rc-component/resize-observer/lib/utils/observerUtil';
3+
import { _rs as onResize } from '@rc-component/resize-observer';
74

85
export function triggerResize(
96
target,
@@ -14,9 +11,7 @@ export function triggerResize(
1411

1512
target.getBoundingClientRect = () => ({ width, height });
1613
// @ts-ignore
17-
onLibResize([{ target }]);
18-
// @ts-ignore
19-
onEsResize([{ target }]);
14+
onResize([{ target }]);
2015

2116
target.style.height = `${height}px`;
2217
target.getBoundingClientRect = originGetBoundingClientRect;

0 commit comments

Comments
 (0)