From ae9231400aefe722b17ac5c65e2190078cc9d799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=89=B3=E5=85=B5?= Date: Tue, 19 May 2026 10:33:51 +0800 Subject: [PATCH 1/2] chore: avoid util deep imports --- package.json | 4 +-- src/Options.tsx | 4 +-- src/Pagination.tsx | 10 ++++--- src/index.ts | 1 + src/locale/index.ts | 67 ++++++++++++++++++++++++++++++++++++++++++++ tests/index.test.tsx | 2 +- 6 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 src/locale/index.ts diff --git a/package.json b/package.json index 025f0858..f3044f05 100644 --- a/package.json +++ b/package.json @@ -42,11 +42,11 @@ "prepare": "husky" }, "dependencies": { - "@rc-component/util": "^1.3.0", + "@rc-component/util": "^1.11.1", "clsx": "^2.1.1" }, "devDependencies": { - "@rc-component/father-plugin": "^2.0.2", + "@rc-component/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.3", "@testing-library/jest-dom": "^6.1.5", "@testing-library/react": "^16.0.1", diff --git a/src/Options.tsx b/src/Options.tsx index 8e7b1118..aa570dc0 100644 --- a/src/Options.tsx +++ b/src/Options.tsx @@ -1,4 +1,4 @@ -import KEYCODE from '@rc-component/util/lib/KeyCode'; +import { KeyCode } from '@rc-component/util'; import React from 'react'; import type { PaginationLocale } from './interface'; @@ -85,7 +85,7 @@ const Options: React.FC = (props) => { if (goInputText === '') { return; } - if (e.keyCode === KEYCODE.ENTER || e.type === 'click') { + if (e.keyCode === KeyCode.ENTER || e.type === 'click') { setGoInputText(''); quickGo?.(getValidValue); } diff --git a/src/Pagination.tsx b/src/Pagination.tsx index b285eb06..452203d4 100644 --- a/src/Pagination.tsx +++ b/src/Pagination.tsx @@ -1,8 +1,10 @@ import { clsx } from 'clsx'; -import useControlledState from '@rc-component/util/lib/hooks/useControlledState'; -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 { + KeyCode, + pickAttrs, + useControlledState, + warning, +} from '@rc-component/util'; import React, { useEffect } from 'react'; import type { PaginationProps } from './interface'; import zhCN from './locale/zh_CN'; diff --git a/src/index.ts b/src/index.ts index ac30e303..b605b477 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,3 @@ export { default } from './Pagination'; export type { PaginationLocale, PaginationProps } from './interface'; +export * from './locale'; diff --git a/src/locale/index.ts b/src/locale/index.ts new file mode 100644 index 00000000..8773a270 --- /dev/null +++ b/src/locale/index.ts @@ -0,0 +1,67 @@ +export { default as ar_EG } from './ar_EG'; +export { default as az_AZ } from './az_AZ'; +export { default as bg_BG } from './bg_BG'; +export { default as bn_BD } from './bn_BD'; +export { default as by_BY } from './by_BY'; +export { default as ca_ES } from './ca_ES'; +export { default as cs_CZ } from './cs_CZ'; +export { default as da_DK } from './da_DK'; +export { default as de_DE } from './de_DE'; +export { default as el_GR } from './el_GR'; +export { default as en_GB } from './en_GB'; +export { default as en_US } from './en_US'; +export { default as es_ES } from './es_ES'; +export { default as et_EE } from './et_EE'; +export { default as eu_ES } from './eu_ES'; +export { default as fa_IR } from './fa_IR'; +export { default as fi_FI } from './fi_FI'; +export { default as fr_BE } from './fr_BE'; +export { default as fr_CA } from './fr_CA'; +export { default as fr_FR } from './fr_FR'; +export { default as ga_IE } from './ga_IE'; +export { default as gl_ES } from './gl_ES'; +export { default as he_IL } from './he_IL'; +export { default as hi_IN } from './hi_IN'; +export { default as hr_HR } from './hr_HR'; +export { default as hu_HU } from './hu_HU'; +export { default as id_ID } from './id_ID'; +export { default as is_IS } from './is_IS'; +export { default as it_IT } from './it_IT'; +export { default as ja_JP } from './ja_JP'; +export { default as ka_GE } from './ka_GE'; +export { default as kk_KZ } from './kk_KZ'; +export { default as km_KH } from './km_KH'; +export { default as kmr_IQ } from './kmr_IQ'; +export { default as kn_IN } from './kn_IN'; +export { default as ko_KR } from './ko_KR'; +export { default as lt_LT } from './lt_LT'; +export { default as lv_LV } from './lv_LV'; +export { default as mk_MK } from './mk_MK'; +export { default as ml_IN } from './ml_IN'; +export { default as mn_MN } from './mn_MN'; +export { default as mr_IN } from './mr_IN'; +export { default as ms_MY } from './ms_MY'; +export { default as my_MM } from './my_MM'; +export { default as nb_NO } from './nb_NO'; +export { default as nl_BE } from './nl_BE'; +export { default as nl_NL } from './nl_NL'; +export { default as pl_PL } from './pl_PL'; +export { default as pt_BR } from './pt_BR'; +export { default as pt_PT } from './pt_PT'; +export { default as ro_RO } from './ro_RO'; +export { default as ru_RU } from './ru_RU'; +export { default as si_LK } from './si_LK'; +export { default as sk_SK } from './sk_SK'; +export { default as sl_SI } from './sl_SI'; +export { default as sr_RS } from './sr_RS'; +export { default as sv_SE } from './sv_SE'; +export { default as ta_IN } from './ta_IN'; +export { default as th_TH } from './th_TH'; +export { default as tk_TK } from './tk_TK'; +export { default as tr_TR } from './tr_TR'; +export { default as uk_UA } from './uk_UA'; +export { default as ur_PK } from './ur_PK'; +export { default as uz_UZ } from './uz_UZ'; +export { default as vi_VN } from './vi_VN'; +export { default as zh_CN } from './zh_CN'; +export { default as zh_TW } from './zh_TW'; diff --git a/tests/index.test.tsx b/tests/index.test.tsx index 4e616e2c..08242676 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -2,7 +2,7 @@ import type { RenderResult } from '@testing-library/react'; import { render, fireEvent } from '@testing-library/react'; import React from 'react'; import Pagination from '../src'; -import { resetWarned } from '@rc-component/util/lib/warning'; +import { resetWarned } from '@rc-component/util'; import { sizeChangerRender } from './commonUtil'; describe('Default Pagination', () => { From eb5b36029c74a3037f58a05ceaa0746c9583ba02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=89=B3=E5=85=B5?= Date: Wed, 27 May 2026 12:21:46 +0800 Subject: [PATCH 2/2] Expose locale subpath exports --- package.json | 24 ++++++++++++++++ src/index.ts | 1 - src/locale/index.ts | 67 --------------------------------------------- 3 files changed, 24 insertions(+), 68 deletions(-) delete mode 100644 src/locale/index.ts diff --git a/package.json b/package.json index f3044f05..ac8fcb76 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,30 @@ ], "main": "./lib/index", "module": "./es/index", + "types": "./es/index.d.ts", + "exports": { + ".": { + "types": "./es/index.d.ts", + "import": "./es/index.js", + "require": "./lib/index.js" + }, + "./assets/*": "./assets/*", + "./locale/*": { + "types": "./es/locale/*.d.ts", + "import": "./es/locale/*.js", + "require": "./lib/locale/*.js" + }, + "./lib/locale/*": { + "types": "./es/locale/*.d.ts", + "import": "./es/locale/*.js", + "require": "./lib/locale/*.js" + }, + "./es/locale/*": { + "types": "./es/locale/*.d.ts", + "import": "./es/locale/*.js", + "require": "./lib/locale/*.js" + } + }, "files": [ "assets/*.css", "assets/*.less", diff --git a/src/index.ts b/src/index.ts index b605b477..ac30e303 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,2 @@ export { default } from './Pagination'; export type { PaginationLocale, PaginationProps } from './interface'; -export * from './locale'; diff --git a/src/locale/index.ts b/src/locale/index.ts deleted file mode 100644 index 8773a270..00000000 --- a/src/locale/index.ts +++ /dev/null @@ -1,67 +0,0 @@ -export { default as ar_EG } from './ar_EG'; -export { default as az_AZ } from './az_AZ'; -export { default as bg_BG } from './bg_BG'; -export { default as bn_BD } from './bn_BD'; -export { default as by_BY } from './by_BY'; -export { default as ca_ES } from './ca_ES'; -export { default as cs_CZ } from './cs_CZ'; -export { default as da_DK } from './da_DK'; -export { default as de_DE } from './de_DE'; -export { default as el_GR } from './el_GR'; -export { default as en_GB } from './en_GB'; -export { default as en_US } from './en_US'; -export { default as es_ES } from './es_ES'; -export { default as et_EE } from './et_EE'; -export { default as eu_ES } from './eu_ES'; -export { default as fa_IR } from './fa_IR'; -export { default as fi_FI } from './fi_FI'; -export { default as fr_BE } from './fr_BE'; -export { default as fr_CA } from './fr_CA'; -export { default as fr_FR } from './fr_FR'; -export { default as ga_IE } from './ga_IE'; -export { default as gl_ES } from './gl_ES'; -export { default as he_IL } from './he_IL'; -export { default as hi_IN } from './hi_IN'; -export { default as hr_HR } from './hr_HR'; -export { default as hu_HU } from './hu_HU'; -export { default as id_ID } from './id_ID'; -export { default as is_IS } from './is_IS'; -export { default as it_IT } from './it_IT'; -export { default as ja_JP } from './ja_JP'; -export { default as ka_GE } from './ka_GE'; -export { default as kk_KZ } from './kk_KZ'; -export { default as km_KH } from './km_KH'; -export { default as kmr_IQ } from './kmr_IQ'; -export { default as kn_IN } from './kn_IN'; -export { default as ko_KR } from './ko_KR'; -export { default as lt_LT } from './lt_LT'; -export { default as lv_LV } from './lv_LV'; -export { default as mk_MK } from './mk_MK'; -export { default as ml_IN } from './ml_IN'; -export { default as mn_MN } from './mn_MN'; -export { default as mr_IN } from './mr_IN'; -export { default as ms_MY } from './ms_MY'; -export { default as my_MM } from './my_MM'; -export { default as nb_NO } from './nb_NO'; -export { default as nl_BE } from './nl_BE'; -export { default as nl_NL } from './nl_NL'; -export { default as pl_PL } from './pl_PL'; -export { default as pt_BR } from './pt_BR'; -export { default as pt_PT } from './pt_PT'; -export { default as ro_RO } from './ro_RO'; -export { default as ru_RU } from './ru_RU'; -export { default as si_LK } from './si_LK'; -export { default as sk_SK } from './sk_SK'; -export { default as sl_SI } from './sl_SI'; -export { default as sr_RS } from './sr_RS'; -export { default as sv_SE } from './sv_SE'; -export { default as ta_IN } from './ta_IN'; -export { default as th_TH } from './th_TH'; -export { default as tk_TK } from './tk_TK'; -export { default as tr_TR } from './tr_TR'; -export { default as uk_UA } from './uk_UA'; -export { default as ur_PK } from './ur_PK'; -export { default as uz_UZ } from './uz_UZ'; -export { default as vi_VN } from './vi_VN'; -export { default as zh_CN } from './zh_CN'; -export { default as zh_TW } from './zh_TW';