Skip to content

Commit ab8980d

Browse files
committed
feat: clsx update
1 parent 4c51c46 commit ab8980d

File tree

12 files changed

+35
-40
lines changed

12 files changed

+35
-40
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ lib/
77
~*
88
yarn.lock
99
package-lock.json
10+
pnpm-lock.yaml
1011
!tests/__mocks__/rc-util/lib
12+
!tests/__mocks__/@rc-component/util/lib
1113
bun.lockb
1214

1315
# umi

examples/animate.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import * as React from 'react';
44
// @ts-ignore
55
import CSSMotion from 'rc-animate/lib/CSSMotion';
6-
import classNames from 'classnames';
6+
import { clsx } from 'clsx';
77
import List, { ListRef } from '../src/List';
8-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
8+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
99
import './animate.less';
1010

1111
let uuid = 0;
@@ -74,7 +74,7 @@ const MyItem: React.ForwardRefRenderFunction<any, MyItemProps> = (
7474
motionName="motion"
7575
motionAppear={motionAppear}
7676
onAppearStart={getCollapsedHeight}
77-
onAppearActive={node => {
77+
onAppearActive={(node) => {
7878
motionRef.current = true;
7979
return getMaxHeight(node);
8080
}}
@@ -87,12 +87,7 @@ const MyItem: React.ForwardRefRenderFunction<any, MyItemProps> = (
8787
>
8888
{({ className, style }, passedMotionRef) => {
8989
return (
90-
<div
91-
ref={passedMotionRef}
92-
className={classNames('item', className)}
93-
style={style}
94-
data-id={id}
95-
>
90+
<div ref={passedMotionRef} className={clsx('item', className)} style={style} data-id={id}>
9691
<div style={{ height: itemUuid % 2 ? 100 : undefined }}>
9792
<button
9893
type="button"
@@ -145,7 +140,7 @@ const Demo = () => {
145140
};
146141

147142
const onLeave = (id: string) => {
148-
const newData = data.filter(item => item.id !== id);
143+
const newData = data.filter((item) => item.id !== id);
149144
setData(newData);
150145
};
151146

@@ -159,14 +154,14 @@ const Demo = () => {
159154
}
160155

161156
const onInsertBefore = (id: string) => {
162-
const index = data.findIndex(item => item.id === id);
157+
const index = data.findIndex((item) => item.id === id);
163158
const newData = [...data.slice(0, index), genItem(), ...data.slice(index)];
164159
setInsertIndex(index);
165160
setData(newData);
166161
lockForAnimation();
167162
};
168163
const onInsertAfter = (id: string) => {
169-
const index = data.findIndex(item => item.id === id) + 1;
164+
const index = data.findIndex((item) => item.id === id) + 1;
170165
const newData = [...data.slice(0, index), genItem(), ...data.slice(index)];
171166
setInsertIndex(index);
172167
setData(newData);

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
"@rc-component/father-plugin": "^1.0.2",
4545
"@testing-library/jest-dom": "^5.17.0",
4646
"@testing-library/react": "^12.1.5",
47-
"@types/classnames": "^2.2.10",
4847
"@types/enzyme": "^3.10.5",
4948
"@types/jest": "^30.0.0",
49+
"@types/node": "^24.10.1",
5050
"@types/react": "^18.0.8",
5151
"@types/react-dom": "^18.0.3",
5252
"@types/warning": "^3.0.0",
@@ -67,8 +67,8 @@
6767
},
6868
"dependencies": {
6969
"@babel/runtime": "^7.20.0",
70-
"classnames": "^2.2.6",
71-
"rc-resize-observer": "^1.0.0",
72-
"rc-util": "^5.36.0"
70+
"@rc-component/util": "^1.4.0",
71+
"clsx": "^2.1.1",
72+
"rc-resize-observer": "^1.0.0"
7373
}
7474
}

src/Filler.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import ResizeObserver from 'rc-resize-observer';
3-
import classNames from 'classnames';
3+
import { clsx } from 'clsx';
44

55
export type InnerProps = Pick<React.HTMLAttributes<HTMLDivElement>, 'role' | 'id'>;
66

@@ -80,9 +80,7 @@ const Filler = React.forwardRef(
8080
>
8181
<div
8282
style={innerStyle}
83-
className={classNames({
84-
[`${prefixCls}-holder-inner`]: prefixCls,
85-
})}
83+
className={clsx({ [`${prefixCls}-holder-inner`]: prefixCls })}
8684
ref={ref}
8785
{...innerProps}
8886
>

src/List.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import classNames from 'classnames';
1+
import { clsx } from 'clsx';
22
import type { ResizeObserverProps } from 'rc-resize-observer';
33
import ResizeObserver from 'rc-resize-observer';
4-
import { useEvent } from 'rc-util';
5-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
4+
import { useEvent } from '@rc-component/util';
5+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
66
import * as React from 'react';
77
import { useRef, useState } from 'react';
88
import { flushSync } from 'react-dom';
@@ -146,7 +146,7 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
146146
(Math.max(itemHeight * data.length, containerHeight) > height || !!scrollWidth);
147147
const isRTL = direction === 'rtl';
148148

149-
const mergedClassName = classNames(prefixCls, { [`${prefixCls}-rtl`]: isRTL }, className);
149+
const mergedClassName = clsx(prefixCls, { [`${prefixCls}-rtl`]: isRTL }, className);
150150
const mergedData = data || EMPTY_DATA;
151151
const componentRef = useRef<HTMLDivElement>();
152152
const fillerInnerRef = useRef<HTMLDivElement>();

src/ScrollBar.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import classNames from 'classnames';
2-
import raf from 'rc-util/lib/raf';
1+
import { clsx } from 'clsx';
2+
import raf from '@rc-component/util/lib/raf';
33
import * as React from 'react';
44
import { getPageXY } from './hooks/useScrollDrag';
55

@@ -222,7 +222,7 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>
222222
right: 0,
223223
bottom: 0,
224224
});
225-
225+
226226
Object.assign(thumbStyle, {
227227
height: '100%',
228228
width: spinSize,
@@ -235,7 +235,7 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>
235235
bottom: 0,
236236
[isLTR ? 'right' : 'left']: 0,
237237
});
238-
238+
239239
Object.assign(thumbStyle, {
240240
width: '100%',
241241
height: spinSize,
@@ -246,7 +246,7 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>
246246
return (
247247
<div
248248
ref={scrollbarRef}
249-
className={classNames(scrollbarPrefixCls, {
249+
className={clsx(scrollbarPrefixCls, {
250250
[`${scrollbarPrefixCls}-horizontal`]: horizontal,
251251
[`${scrollbarPrefixCls}-vertical`]: !horizontal,
252252
[`${scrollbarPrefixCls}-visible`]: visible,
@@ -257,7 +257,7 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>
257257
>
258258
<div
259259
ref={thumbRef}
260-
className={classNames(`${scrollbarPrefixCls}-thumb`, {
260+
className={clsx(`${scrollbarPrefixCls}-thumb`, {
261261
[`${scrollbarPrefixCls}-thumb-moving`]: dragging,
262262
})}
263263
style={{ ...thumbStyle, ...propsThumbStyle }}

src/hooks/useFrameWheel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import raf from 'rc-util/lib/raf';
1+
import raf from '@rc-component/util/lib/raf';
22
import { useRef } from 'react';
33
import isFF from '../utils/isFirefox';
44
import useOriginScroll from './useOriginScroll';

src/hooks/useMobileTouchMove.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
1+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
22
import type * as React from 'react';
33
import { useRef } from 'react';
44

src/hooks/useScrollDrag.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import raf from 'rc-util/lib/raf';
1+
import raf from '@rc-component/util/lib/raf';
22
import * as React from 'react';
33

44
function smoothScrollOffset(offset: number) {

src/hooks/useScrollTo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable no-param-reassign */
22
import * as React from 'react';
3-
import raf from 'rc-util/lib/raf';
3+
import raf from '@rc-component/util/lib/raf';
44
import type { GetKey } from '../interface';
55
import type CacheMap from '../utils/CacheMap';
6-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
7-
import { warning } from 'rc-util';
6+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
7+
import { warning } from '@rc-component/util';
88

99
const MAX_TIMES = 10;
1010

0 commit comments

Comments
 (0)