From 6a44b4e01bc0882b71de930b6add3055c964af31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com> Date: Mon, 27 Jan 2025 17:05:50 +0800 Subject: [PATCH 1/7] chore: use rc-component/util --- package.json | 4 ++-- src/Options.tsx | 2 +- src/Pagination.tsx | 8 ++++---- tests/index.test.tsx | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 00c5c889..d8fcb560 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,8 @@ }, "dependencies": { "@babel/runtime": "^7.10.1", - "classnames": "^2.3.2", - "rc-util": "^5.38.0" + "@rc-component/util": "^1.2.0", + "classnames": "^2.3.2" }, "devDependencies": { "@rc-component/father-plugin": "^1.0.0", diff --git a/src/Options.tsx b/src/Options.tsx index 8efd5dd6..541ecb8f 100644 --- a/src/Options.tsx +++ b/src/Options.tsx @@ -1,4 +1,4 @@ -import KEYCODE from 'rc-util/lib/KeyCode'; +import KEYCODE from '@rc-component/util/lib/KeyCode'; import React from 'react'; import type { PaginationLocale } from './interface'; diff --git a/src/Pagination.tsx b/src/Pagination.tsx index 04b18118..7486a403 100644 --- a/src/Pagination.tsx +++ b/src/Pagination.tsx @@ -1,8 +1,8 @@ import classNames from 'classnames'; -import useMergedState from 'rc-util/lib/hooks/useMergedState'; -import KeyCode from 'rc-util/lib/KeyCode'; -import pickAttrs from 'rc-util/lib/pickAttrs'; -import warning from 'rc-util/lib/warning'; +import useMergedState from '@rc-component/util/lib/hooks/useMergedState'; +import KeyCode from '@rc-component/util/lib/KeyCode'; +import pickAttrs from '@rc-component/util/lib/pickAttrs'; +import warning from '@rc-component/util/lib/warning'; import React, { useEffect } from 'react'; import type { PaginationProps } from './interface'; import zhCN from './locale/zh_CN'; diff --git a/tests/index.test.tsx b/tests/index.test.tsx index 7f5c8e12..7efb5407 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -1,9 +1,8 @@ import type { RenderResult } from '@testing-library/react'; import { render, fireEvent } from '@testing-library/react'; -import Select from 'rc-select'; import React from 'react'; import Pagination from '../src'; -import { resetWarned } from 'rc-util/lib/warning'; +import { resetWarned } from '@rc-component/util/lib/warning'; import { sizeChangerRender } from './commonUtil'; describe('Default Pagination', () => { From 7522fb22b41516c8a42b4dcf62617dcd3a03d20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com> Date: Mon, 27 Jan 2025 17:09:31 +0800 Subject: [PATCH 2/7] fix: fix --- package.json | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index d8fcb560..530581b2 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "@testing-library/react": "^16.0.1", "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.2.2", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", + "@types/react": "^19.0.8", + "@types/react-dom": "^19.0.3", "@umijs/fabric": "^4.0.1", "coveralls": "^3.0.6", "cross-env": "^7.0.0", @@ -72,12 +72,8 @@ "prettier": "^3.1.0", "rc-select": "^14.16.4", "rc-test": "^7.0.15", - "react": "^18.2.0", - "react-dom": "^18.2.0" - }, - "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" + "react": "^19.0.0", + "react-dom": "^19.0.0" }, "cnpm": { "mode": "npm" From 5b28c84a1cf106f97fd9382d1b979212879161f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com> Date: Mon, 27 Jan 2025 17:10:10 +0800 Subject: [PATCH 3/7] fix: fix --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 530581b2..5b9967e8 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,10 @@ "react": "^19.0.0", "react-dom": "^19.0.0" }, + "peerDependencies": { + "react": ">=16.9.0", + "react-dom": ">=16.9.0" + }, "cnpm": { "mode": "npm" }, From e8e53039964c4b9e78a083e4663b4c6fcfe7bce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com> Date: Mon, 27 Jan 2025 17:13:04 +0800 Subject: [PATCH 4/7] fix: fix --- src/Pagination.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pagination.tsx b/src/Pagination.tsx index 7486a403..37355da2 100644 --- a/src/Pagination.tsx +++ b/src/Pagination.tsx @@ -326,7 +326,7 @@ const Pagination: React.FC = (props) => { return null; } - const pagerList: React.ReactElement[] = []; + const pagerList: React.ReactElement[] = []; const pagerProps: PagerProps = { rootPrefixCls: prefixCls, From e9a19421660a409fffd538b29a9f105460079c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com> Date: Wed, 29 Jan 2025 11:04:05 +0800 Subject: [PATCH 5/7] fix: fix --- src/Pagination.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pagination.tsx b/src/Pagination.tsx index 37355da2..ffea0d83 100644 --- a/src/Pagination.tsx +++ b/src/Pagination.tsx @@ -300,7 +300,7 @@ const Pagination: React.FC = (props) => { } } - let jumpPrev: React.ReactElement = null; + let jumpPrev: React.ReactElement = null; const dataOrAriaAttributeProps = pickAttrs(props, { aria: true, @@ -316,7 +316,7 @@ const Pagination: React.FC = (props) => { ); - let jumpNext: React.ReactElement = null; + let jumpNext: React.ReactElement = null; const allPages = calculatePage(undefined, pageSize, total); @@ -326,7 +326,7 @@ const Pagination: React.FC = (props) => { return null; } - const pagerList: React.ReactElement[] = []; + const pagerList: React.ReactElement[] = []; const pagerProps: PagerProps = { rootPrefixCls: prefixCls, From 489efd81c558ab261ec30c3118e37bd437b1d03f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com> Date: Wed, 29 Jan 2025 11:21:25 +0800 Subject: [PATCH 6/7] fix: fix --- src/Options.tsx | 12 ++++++------ src/Pagination.tsx | 11 ++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/Options.tsx b/src/Options.tsx index 541ecb8f..9608697c 100644 --- a/src/Options.tsx +++ b/src/Options.tsx @@ -48,11 +48,11 @@ const Options: React.FC = (props) => { const [goInputText, setGoInputText] = React.useState(''); - const getValidValue = () => { + const getValidValue = React.useMemo(() => { return !goInputText || Number.isNaN(goInputText) ? undefined : Number(goInputText); - }; + }, [goInputText]); const mergeBuildOptionText = typeof buildOptionText === 'function' @@ -70,12 +70,12 @@ const Options: React.FC = (props) => { setGoInputText(''); if ( e.relatedTarget && - (e.relatedTarget.className.indexOf(`${rootPrefixCls}-item-link`) >= 0 || - e.relatedTarget.className.indexOf(`${rootPrefixCls}-item`) >= 0) + (e.relatedTarget.className.includes(`${rootPrefixCls}-item-link`) || + e.relatedTarget.className.includes(`${rootPrefixCls}-item`)) ) { return; } - quickGo?.(getValidValue()); + quickGo?.(getValidValue); }; const go = (e: any) => { @@ -84,7 +84,7 @@ const Options: React.FC = (props) => { } if (e.keyCode === KEYCODE.ENTER || e.type === 'click') { setGoInputText(''); - quickGo?.(getValidValue()); + quickGo?.(getValidValue); } }; diff --git a/src/Pagination.tsx b/src/Pagination.tsx index ffea0d83..ff4ac02e 100644 --- a/src/Pagination.tsx +++ b/src/Pagination.tsx @@ -10,11 +10,8 @@ import Options from './Options'; import type { PagerProps } from './Pager'; import Pager from './Pager'; -const defaultItemRender: PaginationProps['itemRender'] = ( - page, - type, - element, -) => element; +const defaultItemRender: PaginationProps['itemRender'] = (_, __, element) => + element; function noop() {} @@ -244,8 +241,8 @@ const Pagination: React.FC = (props) => { function runIfEnter( event: React.KeyboardEvent, - callback, - ...restParams + callback: (...args: any[]) => void, + ...restParams: any[] ) { if ( event.key === 'Enter' || From 4ada5b512de68cfb94b9521ef8bcaa7afc7996dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com> Date: Wed, 29 Jan 2025 11:22:49 +0800 Subject: [PATCH 7/7] fix: fix --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5b9967e8..df119bb2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "rc-pagination", - "version": "5.1.0", + "name": "@rc-component/pagination", + "version": "1.0.0", "description": "pagination ui component for react", "keywords": [ "react",