Skip to content

Commit 97bb0c7

Browse files
authored
Avoid rc package deep imports (#1071)
* fix: avoid rc package deep imports * chore: address eslint review comment
1 parent 0477cdb commit 97bb0c7

13 files changed

Lines changed: 24 additions & 37 deletions

File tree

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ module.exports = {
1717
'jsx-a11y/label-has-for': 0,
1818
'jsx-a11y/label-has-associated-control': 0,
1919
},
20-
};
20+
};

docs/examples/components/TooltipSlider.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import type { SliderProps } from '@rc-component/slider';
2-
import Slider from '@rc-component/slider';
3-
import type { TooltipRef } from '@rc-component/tooltip';
4-
import Tooltip from '@rc-component/tooltip';
1+
import Slider, { type SliderProps } from '@rc-component/slider';
2+
import Tooltip, { type TooltipRef } from '@rc-component/tooltip';
53
import '@rc-component/tooltip/assets/bootstrap.css';
6-
import raf from '@rc-component/util/lib/raf';
4+
import { raf } from '@rc-component/util';
75
import * as React from 'react';
86

97
interface HandleTooltipProps {

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,22 @@
4242
"tsc": "bunx tsc --noEmit"
4343
},
4444
"dependencies": {
45-
"@rc-component/util": "^1.3.0",
45+
"@rc-component/util": "^1.11.1",
4646
"clsx": "^2.1.1"
4747
},
4848
"devDependencies": {
49-
"@rc-component/father-plugin": "^2.1.3",
49+
"@rc-component/father-plugin": "^2.2.0",
5050
"@rc-component/np": "^1.0.0",
5151
"@rc-component/tooltip": "^1.2.1",
5252
"@rc-component/trigger": "^3.5.2",
5353
"@testing-library/jest-dom": "^6.1.5",
54-
"@testing-library/react": "^12.1.3",
54+
"@testing-library/react": "^16.0.0",
5555
"@types/jest": "^29.5.1",
5656
"@types/node": "^22.5.0",
5757
"@types/react": "^18.2.42",
5858
"@types/react-dom": "^18.0.11",
59+
"@typescript-eslint/eslint-plugin": "^5.62.0",
60+
"@typescript-eslint/parser": "^5.62.0",
5961
"@umijs/fabric": "^4.0.1",
6062
"cross-env": "^7.0.0",
6163
"dumi": "^2.2.10",
@@ -68,8 +70,8 @@
6870
"glob": "^7.1.6",
6971
"less": "^4.1.3",
7072
"rc-test": "^7.0.15",
71-
"react": "^16.0.0",
72-
"react-dom": "^16.0.0",
73+
"react": "^18.0.0",
74+
"react-dom": "^18.0.0",
7375
"regenerator-runtime": "^0.14.0",
7476
"typescript": "^5.1.6"
7577
},

src/Handles/Handle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { clsx } from 'clsx';
2-
import KeyCode from '@rc-component/util/lib/KeyCode';
2+
import { KeyCode } from '@rc-component/util';
33
import * as React from 'react';
44
import SliderContext from '../context';
55
import type { OnStartMove } from '../interface';

src/Handles/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import * as React from 'react';
22
import { flushSync } from 'react-dom';
33
import type { OnStartMove } from '../interface';
44
import { getIndex } from '../util';
5-
import type { HandleProps } from './Handle';
6-
import Handle from './Handle';
5+
import Handle, { type HandleProps } from './Handle';
76

87
export interface HandlesProps {
98
prefixCls: string;

src/Slider.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
import useControlledState from '@rc-component/util/lib/hooks/useControlledState';
2-
import useEvent from '@rc-component/util/lib/hooks/useEvent';
3-
import isEqual from '@rc-component/util/lib/isEqual';
4-
import warning from '@rc-component/util/lib/warning';
1+
import { isEqual, useControlledState, useEvent, warning } from '@rc-component/util';
52
import { clsx } from 'clsx';
63
import * as React from 'react';
7-
import type { HandlesProps, HandlesRef } from './Handles';
8-
import Handles from './Handles';
9-
import type { InternalMarkObj, MarkObj } from './Marks';
10-
import Marks from './Marks';
4+
import Handles, { type HandlesProps, type HandlesRef } from './Handles';
5+
import Marks, { type InternalMarkObj, type MarkObj } from './Marks';
116
import Steps from './Steps';
127
import Tracks from './Tracks';
13-
import type { SliderContextProps } from './context';
14-
import SliderContext from './context';
8+
import SliderContext, { type SliderContextProps } from './context';
159
import useDisabled from './hooks/useDisabled';
1610
import useDrag from './hooks/useDrag';
1711
import useOffset, { getClosestEnabledHandleIndex } from './hooks/useOffset';

src/hooks/useDrag.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from 'react';
2-
import useEvent from '@rc-component/util/lib/hooks/useEvent';
3-
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
2+
import { useEvent, useLayoutEffect } from '@rc-component/util';
43
import { UnstableContext } from '../context';
54
import type { Direction, OnStartMove } from '../interface';
65
import type { OffsetValues } from './useOffset';

src/hooks/useRange.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { warning } from '@rc-component/util/lib/warning';
1+
import { warning } from '@rc-component/util';
22
import { useMemo } from 'react';
33
import type { SliderProps } from '../Slider';
44

src/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { SliderProps, SliderRef } from './Slider';
2-
import Slider from './Slider';
1+
import Slider, { type SliderProps, type SliderRef } from './Slider';
32
export { UnstableContext } from './context';
43

54
export type { SliderProps, SliderRef };

tests/Range.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/* eslint-disable max-len, no-undef, react/no-string-refs, no-param-reassign, max-classes-per-file */
22
import '@testing-library/jest-dom';
33
import { createEvent, fireEvent, render } from '@testing-library/react';
4-
import keyCode from '@rc-component/util/lib/KeyCode';
5-
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
6-
import { resetWarned } from '@rc-component/util/lib/warning';
4+
import { KeyCode as keyCode, resetWarned, spyElementPrototypes } from '@rc-component/util';
75
import React from 'react';
86
import Slider from '../src';
97

0 commit comments

Comments
 (0)