Skip to content

Commit b392364

Browse files
authored
chore: use rc-component/util (#635)
* chore: use rc-component/util * fix: fix * fix: fix * fix: fix * fix: fix * fix: fix * fix: fix
1 parent 9f79748 commit b392364

File tree

4 files changed

+26
-30
lines changed

4 files changed

+26
-30
lines changed

Diff for: package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "rc-pagination",
3-
"version": "5.1.0",
2+
"name": "@rc-component/pagination",
3+
"version": "1.0.0",
44
"description": "pagination ui component for react",
55
"keywords": [
66
"react",
@@ -43,17 +43,17 @@
4343
},
4444
"dependencies": {
4545
"@babel/runtime": "^7.10.1",
46-
"classnames": "^2.3.2",
47-
"rc-util": "^5.38.0"
46+
"@rc-component/util": "^1.2.0",
47+
"classnames": "^2.3.2"
4848
},
4949
"devDependencies": {
5050
"@rc-component/father-plugin": "^1.0.0",
5151
"@testing-library/jest-dom": "^6.1.5",
5252
"@testing-library/react": "^16.0.1",
5353
"@testing-library/user-event": "^14.5.2",
5454
"@types/jest": "^29.2.2",
55-
"@types/react": "^18.0.0",
56-
"@types/react-dom": "^18.0.0",
55+
"@types/react": "^19.0.8",
56+
"@types/react-dom": "^19.0.3",
5757
"@umijs/fabric": "^4.0.1",
5858
"coveralls": "^3.0.6",
5959
"cross-env": "^7.0.0",
@@ -72,8 +72,8 @@
7272
"prettier": "^3.1.0",
7373
"rc-select": "^14.16.4",
7474
"rc-test": "^7.0.15",
75-
"react": "^18.2.0",
76-
"react-dom": "^18.2.0"
75+
"react": "^19.0.0",
76+
"react-dom": "^19.0.0"
7777
},
7878
"peerDependencies": {
7979
"react": ">=16.9.0",

Diff for: src/Options.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import KEYCODE from 'rc-util/lib/KeyCode';
1+
import KEYCODE from '@rc-component/util/lib/KeyCode';
22
import React from 'react';
33
import type { PaginationLocale } from './interface';
44

@@ -48,11 +48,11 @@ const Options: React.FC<OptionsProps> = (props) => {
4848

4949
const [goInputText, setGoInputText] = React.useState('');
5050

51-
const getValidValue = () => {
51+
const getValidValue = React.useMemo<number>(() => {
5252
return !goInputText || Number.isNaN(goInputText)
5353
? undefined
5454
: Number(goInputText);
55-
};
55+
}, [goInputText]);
5656

5757
const mergeBuildOptionText =
5858
typeof buildOptionText === 'function'
@@ -70,12 +70,12 @@ const Options: React.FC<OptionsProps> = (props) => {
7070
setGoInputText('');
7171
if (
7272
e.relatedTarget &&
73-
(e.relatedTarget.className.indexOf(`${rootPrefixCls}-item-link`) >= 0 ||
74-
e.relatedTarget.className.indexOf(`${rootPrefixCls}-item`) >= 0)
73+
(e.relatedTarget.className.includes(`${rootPrefixCls}-item-link`) ||
74+
e.relatedTarget.className.includes(`${rootPrefixCls}-item`))
7575
) {
7676
return;
7777
}
78-
quickGo?.(getValidValue());
78+
quickGo?.(getValidValue);
7979
};
8080

8181
const go = (e: any) => {
@@ -84,7 +84,7 @@ const Options: React.FC<OptionsProps> = (props) => {
8484
}
8585
if (e.keyCode === KEYCODE.ENTER || e.type === 'click') {
8686
setGoInputText('');
87-
quickGo?.(getValidValue());
87+
quickGo?.(getValidValue);
8888
}
8989
};
9090

Diff for: src/Pagination.tsx

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import classNames from 'classnames';
2-
import useMergedState from 'rc-util/lib/hooks/useMergedState';
3-
import KeyCode from 'rc-util/lib/KeyCode';
4-
import pickAttrs from 'rc-util/lib/pickAttrs';
5-
import warning from 'rc-util/lib/warning';
2+
import useMergedState from '@rc-component/util/lib/hooks/useMergedState';
3+
import KeyCode from '@rc-component/util/lib/KeyCode';
4+
import pickAttrs from '@rc-component/util/lib/pickAttrs';
5+
import warning from '@rc-component/util/lib/warning';
66
import React, { useEffect } from 'react';
77
import type { PaginationProps } from './interface';
88
import zhCN from './locale/zh_CN';
99
import Options from './Options';
1010
import type { PagerProps } from './Pager';
1111
import Pager from './Pager';
1212

13-
const defaultItemRender: PaginationProps['itemRender'] = (
14-
page,
15-
type,
16-
element,
17-
) => element;
13+
const defaultItemRender: PaginationProps['itemRender'] = (_, __, element) =>
14+
element;
1815

1916
function noop() {}
2017

@@ -244,8 +241,8 @@ const Pagination: React.FC<PaginationProps> = (props) => {
244241

245242
function runIfEnter(
246243
event: React.KeyboardEvent<HTMLLIElement>,
247-
callback,
248-
...restParams
244+
callback: (...args: any[]) => void,
245+
...restParams: any[]
249246
) {
250247
if (
251248
event.key === 'Enter' ||
@@ -300,7 +297,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
300297
}
301298
}
302299

303-
let jumpPrev: React.ReactElement = null;
300+
let jumpPrev: React.ReactElement<PagerProps> = null;
304301

305302
const dataOrAriaAttributeProps = pickAttrs(props, {
306303
aria: true,
@@ -316,7 +313,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
316313
</li>
317314
);
318315

319-
let jumpNext: React.ReactElement = null;
316+
let jumpNext: React.ReactElement<PagerProps> = null;
320317

321318
const allPages = calculatePage(undefined, pageSize, total);
322319

Diff for: tests/index.test.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import type { RenderResult } from '@testing-library/react';
22
import { render, fireEvent } from '@testing-library/react';
3-
import Select from 'rc-select';
43
import React from 'react';
54
import Pagination from '../src';
6-
import { resetWarned } from 'rc-util/lib/warning';
5+
import { resetWarned } from '@rc-component/util/lib/warning';
76
import { sizeChangerRender } from './commonUtil';
87

98
describe('Default Pagination', () => {

0 commit comments

Comments
 (0)