Skip to content

Commit eeb39e5

Browse files
authored
perf: uninstall classnames, install clsx (#624)
1 parent b9b4a9c commit eeb39e5

File tree

6 files changed

+15
-20
lines changed

6 files changed

+15
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ lib
2626
es
2727
yarn.lock
2828
package-lock.json
29+
pnpm-lock.yaml
2930
coverage
3031
# umi
3132
.umi

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@
4646
"@rc-component/select": "~1.1.0",
4747
"@rc-component/tree": "~1.0.0",
4848
"@rc-component/util": "^1.3.0",
49-
"classnames": "^2.3.1"
49+
"clsx": "^2.1.1"
5050
},
5151
"devDependencies": {
5252
"@rc-component/father-plugin": "^2.0.2",
5353
"@rc-component/np": "^1.0.3",
5454
"@rc-component/trigger": "^3.0.0",
5555
"@testing-library/react": "^12.1.5",
56-
"@types/classnames": "^2.2.6",
5756
"@types/enzyme": "^3.1.15",
5857
"@types/jest": "^29.4.0",
58+
"@types/node": "^24.5.2",
5959
"@types/react": "^19.0.0",
6060
"@types/react-dom": "^19.0.0",
6161
"@types/warning": "^3.0.0",

src/OptionList/Checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import classNames from 'classnames';
2+
import { clsx } from 'clsx';
33
import CascaderContext from '../context';
44

55
export interface CheckboxProps {
@@ -25,7 +25,7 @@ export default function Checkbox({
2525

2626
return (
2727
<span
28-
className={classNames(`${prefixCls}`, {
28+
className={clsx(`${prefixCls}`, {
2929
[`${prefixCls}-checked`]: checked,
3030
[`${prefixCls}-indeterminate`]: !checked && halfChecked,
3131
[`${prefixCls}-disabled`]: disabled || disableCheckbox,

src/OptionList/Column.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import cls from 'classnames';
1+
import { clsx } from 'clsx';
22
import * as React from 'react';
3-
import pickAttrs from 'rc-util/lib/pickAttrs';
3+
import pickAttrs from '@rc-component/util/lib/pickAttrs';
44
import type { DefaultOptionType, SingleValueType } from '../Cascader';
55
import CascaderContext from '../context';
66
import { SEARCH_MARK } from '../hooks/useSearchOptions';
@@ -121,7 +121,7 @@ export default function Column<OptionType extends DefaultOptionType = DefaultOpt
121121
// ============================ Render ============================
122122
return (
123123
<ul
124-
className={cls(menuPrefixCls, classNames?.popup?.list)}
124+
className={clsx(menuPrefixCls, classNames?.popup?.list)}
125125
style={styles?.popup?.list}
126126
ref={menuRef}
127127
role="menu"
@@ -140,10 +140,7 @@ export default function Column<OptionType extends DefaultOptionType = DefaultOpt
140140
fullPathKey,
141141
disableCheckbox,
142142
}) => {
143-
const ariaProps = pickAttrs(option, {
144-
aria: true,
145-
data: true
146-
});
143+
const ariaProps = pickAttrs(option, { aria: true, data: true });
147144
// >>>>> Open
148145
const triggerOpenPath = () => {
149146
if (isOptionDisabled(disabled)) {
@@ -176,7 +173,7 @@ export default function Column<OptionType extends DefaultOptionType = DefaultOpt
176173
<li
177174
key={fullPathKey}
178175
{...ariaProps}
179-
className={cls(menuItemPrefixCls, classNames?.popup?.listItem, {
176+
className={clsx(menuItemPrefixCls, classNames?.popup?.listItem, {
180177
[`${menuItemPrefixCls}-expand`]: !isMergedLeaf,
181178
[`${menuItemPrefixCls}-active`]:
182179
activeValue === value || activeValue === fullPathKey,

src/OptionList/List.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable default-case */
2-
import classNames from 'classnames';
2+
import { clsx } from 'clsx';
33
import type { useBaseProps } from '@rc-component/select';
44
import type { RefOptionListProps } from '@rc-component/select/lib/OptionList';
55
import * as React from 'react';
@@ -248,7 +248,7 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
248248
return (
249249
<CacheContent open={open}>
250250
<div
251-
className={classNames(`${mergedPrefixCls}-menus`, {
251+
className={clsx(`${mergedPrefixCls}-menus`, {
252252
[`${mergedPrefixCls}-menu-empty`]: isEmpty,
253253
[`${mergedPrefixCls}-rtl`]: rtl,
254254
})}

src/Panel.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import classNames from 'classnames';
1+
import { clsx } from 'clsx';
22
import { useEvent, useControlledState } from '@rc-component/util';
33
import * as React from 'react';
44
import type {
@@ -184,12 +184,9 @@ export default function Panel<
184184
return (
185185
<CascaderContext.Provider value={cascaderContext}>
186186
<div
187-
className={classNames(
187+
className={clsx(
188188
panelPrefixCls,
189-
{
190-
[`${panelPrefixCls}-rtl`]: direction === 'rtl',
191-
[`${panelPrefixCls}-empty`]: isEmpty,
192-
},
189+
{ [`${panelPrefixCls}-rtl`]: direction === 'rtl', [`${panelPrefixCls}-empty`]: isEmpty },
193190
className,
194191
)}
195192
style={style}

0 commit comments

Comments
 (0)