diff --git a/package.json b/package.json index 00c5c889..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", @@ -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", @@ -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,8 +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" + "react": "^19.0.0", + "react-dom": "^19.0.0" }, "peerDependencies": { "react": ">=16.9.0", diff --git a/src/Options.tsx b/src/Options.tsx index 8efd5dd6..9608697c 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'; @@ -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 04b18118..ff4ac02e 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'; @@ -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' || @@ -300,7 +297,7 @@ const Pagination: React.FC = (props) => { } } - let jumpPrev: React.ReactElement = null; + let jumpPrev: React.ReactElement = null; const dataOrAriaAttributeProps = pickAttrs(props, { aria: true, @@ -316,7 +313,7 @@ const Pagination: React.FC = (props) => { ); - let jumpNext: React.ReactElement = null; + let jumpNext: React.ReactElement = null; const allPages = calculatePage(undefined, pageSize, total); 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', () => {