From 6506c0767cc886ee6bdc99e6f462c80c208f10ce Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 15:54:07 +0800 Subject: [PATCH 01/33] chore: standardize repository config --- .dumirc.ts | 6 + .github/FUNDING.yml | 2 + .github/dependabot.yml | 36 ++-- .github/workflows/codeql.yml | 22 +-- .github/workflows/react-component-ci.yml | 6 +- .github/workflows/react-doctor.yml | 27 +++ .github/workflows/surge-preview.yml | 39 +++++ .gitignore | 2 + README.md | 204 ++++++++++++----------- docs/index.md | 2 +- package.json | 11 +- tsconfig.json | 3 +- vercel.json | 6 + 13 files changed, 232 insertions(+), 134 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/react-doctor.yml create mode 100644 .github/workflows/surge-preview.yml create mode 100644 vercel.json diff --git a/.dumirc.ts b/.dumirc.ts index 7a89997..0966ae2 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,6 +1,9 @@ import { defineConfig } from 'dumi'; import path from 'path'; +const basePath = process.env.GH_PAGES ? '/rate/' : '/'; +const publicPath = process.env.GH_PAGES ? '/rate/' : '/'; + export default defineConfig({ alias: { '@rc-component/rate$': path.resolve('src'), @@ -11,4 +14,7 @@ export default defineConfig({ name: 'Rate', logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', }, + outputPath: 'docs-dist', + base: basePath, + publicPath, }); diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..758659a --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: ant-design +open_collective: ant-design diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d151590..99e6fa7 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,20 +1,20 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "21:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: "@types/react" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - 17.0.3 - - dependency-name: "@types/react-dom" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 + - package-ecosystem: npm + directory: '/' + schedule: + interval: daily + time: '21:00' + open-pull-requests-limit: 10 + ignore: + - dependency-name: '@types/react' + versions: + - 17.0.0 + - 17.0.1 + - 17.0.2 + - 17.0.3 + - dependency-name: '@types/react-dom' + versions: + - 17.0.0 + - 17.0.1 + - 17.0.2 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4204398..4e2c36c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,12 +1,12 @@ -name: "CodeQL" +name: 'CodeQL' on: push: - branches: [ "master" ] + branches: ['master'] pull_request: - branches: [ "master" ] + branches: ['master'] schedule: - - cron: "7 4 * * 2" + - cron: '7 4 * * 2' jobs: analyze: @@ -20,22 +20,24 @@ jobs: strategy: fail-fast: false matrix: - language: [ javascript ] + language: [javascript] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: - category: "/language:${{ matrix.language }}" + category: '/language:${{ matrix.language }}' diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 5735e2d..9503b96 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -1,6 +1,8 @@ name: ✅ test on: [push, pull_request] +permissions: + contents: read jobs: test: - uses: react-component/rc-test/.github/workflows/test.yml@main - secrets: inherit \ No newline at end of file + uses: react-component/rc-test/.github/workflows/test-utoo.yml@main + secrets: inherit diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml new file mode 100644 index 0000000..f68281c --- /dev/null +++ b/.github/workflows/react-doctor.yml @@ -0,0 +1,27 @@ +name: React Doctor + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + push: + branches: [master] + +permissions: + contents: read + pull-requests: write + issues: write + statuses: write + +concurrency: + group: react-doctor-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + react-doctor: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + fetch-depth: 0 + persist-credentials: false + - uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3 diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml new file mode 100644 index 0000000..1b29a17 --- /dev/null +++ b/.github/workflows/surge-preview.yml @@ -0,0 +1,39 @@ +name: Surge Preview + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + checks: write + statuses: write + +jobs: + preview: + runs-on: ubuntu-latest + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + PREVIEW: true + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false + - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec + if: ${{ env.SURGE_TOKEN != '' }} + with: + surge_token: ${{ env.SURGE_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} + dist: docs-dist + failOnError: true + setCommitStatus: true + build: | + npm install + npm run build + - name: Skip Surge preview + if: ${{ env.SURGE_TOKEN == '' }} + run: echo "SURGE_TOKEN is not configured; skip Surge preview." diff --git a/.gitignore b/.gitignore index 2bbb726..b3750a5 100755 --- a/.gitignore +++ b/.gitignore @@ -29,10 +29,12 @@ package-lock.json pnpm-lock.yaml .doc/ dist +docs-dist .doc # dumi .dumi/tmp .dumi/tmp-test .dumi/tmp-production +.vercel bun.lockb diff --git a/README.md b/README.md index 1dbe6e9..1018e97 100644 --- a/README.md +++ b/README.md @@ -1,121 +1,131 @@ -# rc-rate - -React Rate Component - -[![NPM version][npm-image]][npm-url] -[![npm download][download-image]][download-url] -[![build status][github-actions-image]][github-actions-url] -[![Codecov][codecov-image]][codecov-url] -[![bundle size][bundlephobia-image]][bundlephobia-url] -[![dumi][dumi-image]][dumi-url] - -[npm-image]: http://img.shields.io/npm/v/rc-rate.svg?style=flat-square -[npm-url]: http://npmjs.org/package/rc-rate -[github-actions-image]: https://github.com/react-component/rate/workflows/CI/badge.svg -[github-actions-url]: https://github.com/react-component/rate/actions -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/rate/master.svg?style=flat-square -[codecov-url]: https://codecov.io/gh/react-component/rate/branch/master -[david-url]: https://david-dm.org/react-component/rate -[david-image]: https://david-dm.org/react-component/rate/status.svg?style=flat-square -[david-dev-url]: https://david-dm.org/react-component/rate?type=dev -[david-dev-image]: https://david-dm.org/react-component/rate/dev-status.svg?style=flat-square -[download-image]: https://img.shields.io/npm/dm/rc-rate.svg?style=flat-square -[download-url]: https://npmjs.org/package/rc-rate -[bundlephobia-url]: https://bundlephobia.com/result?p=rc-rate -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-rate -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square - -## Screenshots - - - -## Changelog - -- [CHANGELOG](./CHANGELOG.md) - -## Development - -``` -npm install -npm start +
+

@rc-component/rate

+

⭐ Accessible React rating component with half-star and keyboard support.

+ +

+ + Ant Design + +

+

+ Part of the Ant Design ecosystem +

+ +

+ npm version + npm downloads + CI + Codecov + Bundle size + dumi +

+
+ +## Highlights + +- Controlled and uncontrolled rating values. +- Half-star selection, custom characters, and custom character rendering. +- Keyboard interaction, focus/blur methods, disabled state, and RTL support. +- TypeScript definitions for props and imperative refs. + +## Install + +```bash +npm install @rc-component/rate ``` -## Example - -- Local: http://localhost:9001/ - -- Online: http://react-component.github.io/rate/ - -## install - -[![rc-rate](https://nodei.co/npm/rc-rate.png)](https://npmjs.org/package/rc-rate) - ## Usage -```js -import React from 'react'; -import ReactDOM from 'react-dom'; +```tsx | pure import Rate from '@rc-component/rate'; +import React from 'react'; -ReactDOM.render( - , - document.getElementById('root') -) +export default () => ; ``` -### with [styled-components](https://github.com/styled-components/styled-components) -```js -import React from 'react'; -import ReactDOM from 'react-dom'; +```tsx | pure import Rate from '@rc-component/rate'; -import styled from 'styled-components'; - -const StyledRate = styled(Rate)` - &.rc-rate { - font-size: ${({ size }) => size}px; - } -` - -ReactDOM.render( - , - document.getElementById('root') -) +import React from 'react'; + +export default () => ( + index + 1} + onChange={(value) => { + console.log('selected', value); + }} + /> +); ``` -## API +## Examples -### props +Run the examples locally: -| name | type | default | description | -| ------------- | --------------------------------- | ------------- | ----------------------------------------------------- | -| count | number | 5 | Star numbers | -| value | number | - | Controlled value | -| defaultValue | number | 0 | Initial value | -| allowHalf | boolean | false | Support half star | -| allowClear | boolean | true | Reset when click again | -| style | object | {} | | -| onChange | function | (value) => {} | `onChange` will be triggered when click | -| onHoverChange | function | (value) => {} | `onHoverChange` will be triggered when hover on stars | -| character | ReactNode \| (props) => ReactNode | ★ | The each character of rate | -| disabled | boolean | false | | -| direction | string | `ltr` | The direction of rate | +```bash +npm install +npm start +``` -## Test Case +## API -``` +### Rate + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| `allowClear` | boolean | true | Clear the value when clicking the selected item again. | +| `allowHalf` | boolean | false | Enable half item selection. | +| `autoFocus` | boolean | false | Focus the rating on mount. | +| `character` | ReactNode \| (props: StarProps) => ReactNode | `'★'` | Custom character for each item. | +| `characterRender` | (origin: ReactElement, props: StarProps) => ReactNode | - | Custom renderer for each item. | +| `className` | string | - | Additional class name. | +| `count` | number | 5 | Number of rating items. | +| `defaultValue` | number | 0 | Initial uncontrolled value. | +| `direction` | string | `'ltr'` | Layout direction. Use `'rtl'` for right-to-left display. | +| `disabled` | boolean | false | Disable interaction. | +| `id` | string | - | Root element id. | +| `keyboard` | boolean | true | Enable keyboard control. | +| `prefixCls` | string | `'rc-rate'` | Prefix class name. | +| `style` | React.CSSProperties | - | Root style. | +| `tabIndex` | number | 0 | Root tab index. | +| `value` | number | - | Controlled value. | +| `onBlur` | () => void | - | Blur callback. | +| `onChange` | (value: number) => void | - | Value change callback. | +| `onFocus` | () => void | - | Focus callback. | +| `onHoverChange` | (value: number) => void | - | Hover value callback. | +| `onKeyDown` | React.KeyboardEventHandler | - | Keydown callback. | +| `onMouseEnter` | React.MouseEventHandler | - | Mouse enter callback. | +| `onMouseLeave` | React.MouseEventHandler | - | Mouse leave callback. | + +### Ref + +| Name | Type | Description | +| ------- | ---------- | ----------------------------- | +| `blur` | () => void | Remove focus from the rating. | +| `focus` | () => void | Focus the rating. | + +## Development + +```bash +npm install +npm start npm test -npm run chrome-test +npm run tsc +npm run compile +npm run build ``` -## Coverage +## Release -``` -npm run coverage +Package artifacts are built with Father: + +```bash +npm run compile ``` -open coverage/ dir +Publishing is handled by `rc-np` through the `prepublishOnly` script. ## License -rc-rate is released under the MIT license. +`@rc-component/rate` is released under the MIT license. diff --git a/docs/index.md b/docs/index.md index aed1d13..a6cb69e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,6 @@ --- hero: - title: rc-rate + title: '@rc-component/rate' description: React Rate Component --- diff --git a/package.json b/package.json index 5f9926b..db5cd5f 100644 --- a/package.json +++ b/package.json @@ -25,19 +25,20 @@ "assets/*.css" ], "scripts": { + "build": "npm run docs:build", "compile": "father build && lessc assets/index.less assets/index.css", "coverage": "rc-test --coverage", "docs:build": "dumi build", - "docs:deploy": "gh-pages -d dist", + "docs:deploy": "gh-pages -d docs-dist", + "gh-pages": "GH_PAGES=1 npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", - "now-build": "npm run docs:build", "prepare": "dumi setup", "prepublishOnly": "npm run compile && rc-np", - "prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"", - "postpublish": "npm run docs:build && npm run docs:deploy", + "prettier": "prettier --write --ignore-unknown .", + "postpublish": "npm run gh-pages", "start": "dumi dev", "test": "rc-test", - "tsc": "bunx tsc --noEmit" + "tsc": "tsc --noEmit" }, "dependencies": { "@rc-component/util": "^1.11.1", diff --git a/tsconfig.json b/tsconfig.json index 6820619..021cd92 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,5 +13,6 @@ "@rc-component/rate": ["src/index.tsx"] } }, - "include": [".dumirc.ts", "./src/**/*.ts", "./src/**/*.tsx", "./docs/**/*.tsx"] + "include": [".dumirc.ts", "src", "docs", "tests"], + "exclude": ["node_modules", "lib", "es", "dist", "docs-dist", ".dumi"] } diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..5f9139e --- /dev/null +++ b/vercel.json @@ -0,0 +1,6 @@ +{ + "framework": "umijs", + "installCommand": "npm install", + "buildCommand": "npm run build", + "outputDirectory": "docs-dist" +} From d128ac970d0abfb9896cfb49efa0a293b79b7778 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:27:31 +0800 Subject: [PATCH 02/33] chore: address AI review feedback --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index db5cd5f..fafdf95 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "coverage": "rc-test --coverage", "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", - "gh-pages": "GH_PAGES=1 npm run docs:build && npm run docs:deploy", + "gh-pages": "cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", "prepare": "dumi setup", "prepublishOnly": "npm run compile && rc-np", From 03f028bfd1aa9d4ac1103fa07104ae974101415f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:56:49 +0800 Subject: [PATCH 03/33] docs: standardize README release details --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1018e97..eab1b90 100644 --- a/README.md +++ b/README.md @@ -118,14 +118,12 @@ npm run build ## Release -Package artifacts are built with Father: - ```bash -npm run compile +npm run prepublishOnly ``` -Publishing is handled by `rc-np` through the `prepublishOnly` script. +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. ## License -`@rc-component/rate` is released under the MIT license. +@rc-component/rate is released under the [MIT](./LICENSE.md) license. From 09bf22fdd9becd6d457726b097562cff47e91cb5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:13:58 +0800 Subject: [PATCH 04/33] ci: make surge preview non-blocking --- .github/workflows/surge-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 1b29a17..ad8683d 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -29,7 +29,7 @@ jobs: surge_token: ${{ env.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist - failOnError: true + failOnError: false setCommitStatus: true build: | npm install From 9a0527777f6fec6f4196f7d64d2717ed1a804924 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:17:45 +0800 Subject: [PATCH 05/33] docs: clarify Ant Design ecosystem note --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index eab1b90..77f779a 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,15 @@

+

+ + + Ant Design + + Part of the Ant Design ecosystem. + +

+ ## Highlights - Controlled and uncontrolled rating values. From a31c8fc1996de0f8c8fdb68899fac446cf0f97a4 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:25:42 +0800 Subject: [PATCH 06/33] ci: keep surge preview as fallback --- .github/workflows/surge-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index ad8683d..70768bf 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -30,7 +30,7 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist failOnError: false - setCommitStatus: true + setCommitStatus: false build: | npm install npm run build From 7f61b6d17e8c9e2b8edbe41125cb215aaa25ea6f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:04:02 +0800 Subject: [PATCH 07/33] docs: refine README usage and ecosystem note --- README.md | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/README.md b/README.md index 77f779a..a2f24a9 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,7 @@

@rc-component/rate

+

Part of the Ant Design ecosystem.

⭐ Accessible React rating component with half-star and keyboard support.

- -

- - Ant Design - -

Part of the Ant Design ecosystem

@@ -21,14 +16,6 @@

-

- - - Ant Design - - Part of the Ant Design ecosystem. - -

## Highlights @@ -47,15 +34,11 @@ npm install @rc-component/rate ```tsx | pure import Rate from '@rc-component/rate'; -import React from 'react'; - export default () => ; ``` ```tsx | pure import Rate from '@rc-component/rate'; -import React from 'react'; - export default () => ( Date: Sat, 27 Jun 2026 13:22:17 +0800 Subject: [PATCH 08/33] ci: isolate surge preview token --- .github/workflows/surge-preview.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 70768bf..faf6b8b 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -17,23 +17,26 @@ jobs: preview: runs-on: ubuntu-latest env: - SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} PREVIEW: true steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false + - name: Build preview + if: ${{ secrets.SURGE_TOKEN != '' }} + run: | + npm install + npm run build - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec - if: ${{ env.SURGE_TOKEN != '' }} + if: ${{ secrets.SURGE_TOKEN != '' }} + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} with: surge_token: ${{ env.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist failOnError: false setCommitStatus: false - build: | - npm install - npm run build - name: Skip Surge preview - if: ${{ env.SURGE_TOKEN == '' }} + if: ${{ secrets.SURGE_TOKEN == '' }} run: echo "SURGE_TOKEN is not configured; skip Surge preview." From 088b48d24fdabf61119cad210305a87ce82e2d7e Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:51:14 +0800 Subject: [PATCH 09/33] chore: address review comments --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index a2f24a9..7c0d7c4 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,6 @@

@rc-component/rate

Part of the Ant Design ecosystem.

⭐ Accessible React rating component with half-star and keyboard support.

-

- Part of the Ant Design ecosystem -

npm version From f72ac00b0f70c2ba7bd5ea9cb14336173e4319ba Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:19:59 +0800 Subject: [PATCH 10/33] docs: add Chinese README --- README.md | 2 + README.zh-CN.md | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 README.zh-CN.md diff --git a/README.md b/README.md index 7c0d7c4..40698dc 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@

+

English | 简体中文

+ ## Highlights diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 0000000..1b1590b --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,120 @@ +
+

@rc-component/rate

+

Ant Design 生态的一部分。

+

⭐ React 评分组件,支持半星、自定义字符、清除和键盘交互。

+ +

+ npm version + npm downloads + CI + Codecov + Bundle size + dumi +

+
+ +

English | 简体中文

+ + +## 特性 + +- Controlled and uncontrolled rating values. +- Half-star selection, custom characters, and custom character rendering. +- Keyboard interaction, focus/blur methods, disabled state, and RTL support. +- TypeScript definitions for props and imperative refs. + +## 安装 + +```bash +npm install @rc-component/rate +``` + +## 使用 + +```tsx | pure +import Rate from '@rc-component/rate'; +export default () => ; +``` + +```tsx | pure +import Rate from '@rc-component/rate'; +export default () => ( + index + 1} + onChange={(value) => { + console.log('selected', value); + }} + /> +); +``` + +## 示例 + +本地运行示例: + +```bash +npm install +npm start +``` + +## API + +### Rate + +| 名称 | 类型 | 默认值 | 说明 | +| --- | --- | --- | --- | +| `allowClear` | boolean | true | Clear the value when clicking the selected item again. | +| `allowHalf` | boolean | false | Enable half item selection. | +| `autoFocus` | boolean | false | Focus the rating on mount. | +| `character` | ReactNode \| (props: StarProps) => ReactNode | `'★'` | Custom character for each item. | +| `characterRender` | (origin: ReactElement, props: StarProps) => ReactNode | - | Custom renderer for each item. | +| `className` | string | - | Additional class name. | +| `count` | number | 5 | Number of rating items. | +| `defaultValue` | number | 0 | Initial uncontrolled value. | +| `direction` | string | `'ltr'` | Layout direction. Use `'rtl'` for right-to-left display. | +| `disabled` | boolean | false | Disable interaction. | +| `id` | string | - | Root element id. | +| `keyboard` | boolean | true | Enable keyboard control. | +| `prefixCls` | string | `'rc-rate'` | Prefix class name. | +| `style` | React.CSSProperties | - | Root style. | +| `tabIndex` | number | 0 | Root tab index. | +| `value` | number | - | Controlled value. | +| `onBlur` | () => void | - | Blur callback. | +| `onChange` | (value: number) => void | - | Value change callback. | +| `onFocus` | () => void | - | Focus callback. | +| `onHoverChange` | (value: number) => void | - | Hover value callback. | +| `onKeyDown` | React.KeyboardEventHandler | - | Keydown callback. | +| `onMouseEnter` | React.MouseEventHandler | - | Mouse enter callback. | +| `onMouseLeave` | React.MouseEventHandler | - | Mouse leave callback. | + +### Ref + +| 名称 | 类型 | 说明 | +| ------- | ---------- | ----------------------------- | +| `blur` | () => void | Remove focus from the rating. | +| `focus` | () => void | Focus the rating. | + +## 本地开发 + +```bash +npm install +npm start +npm test +npm run tsc +npm run compile +npm run build +``` + +## 发布 + +```bash +npm run prepublishOnly +``` + +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. + +## 许可证 + +@rc-component/rate is released under the [MIT](./LICENSE.md) license. From 4106b11ae57ec5cc73b34b2e6513ea776c1b6c08 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:34:47 +0800 Subject: [PATCH 11/33] docs: add Ant Design logo to README --- README.md | 1 + README.zh-CN.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 40698dc..d5217f1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@

@rc-component/rate

Part of the Ant Design ecosystem.

+ Ant Design

⭐ Accessible React rating component with half-star and keyboard support.

diff --git a/README.zh-CN.md b/README.zh-CN.md index 1b1590b..b7e7469 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,6 +1,7 @@

@rc-component/rate

Ant Design 生态的一部分。

+ Ant Design

⭐ React 评分组件,支持半星、自定义字符、清除和键盘交互。

From 985a9286d28e0183d5d55341945f8f5809f77fe2 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 23:03:38 +0800 Subject: [PATCH 12/33] docs: refine bilingual README branding --- README.md | 5 ++-- README.zh-CN.md | 67 ++++++++++++++++++++++++------------------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index d5217f1..53fd550 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@

@rc-component/rate

-

Part of the Ant Design ecosystem.

- Ant Design -

⭐ Accessible React rating component with half-star and keyboard support.

+

Ant Design Part of the Ant Design ecosystem.

+

📦 ⭐ Accessible React rating component with half-star and keyboard support.

npm version diff --git a/README.zh-CN.md b/README.zh-CN.md index b7e7469..ee2b9f6 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,8 +1,7 @@

@rc-component/rate

-

Ant Design 生态的一部分。

- Ant Design -

⭐ React 评分组件,支持半星、自定义字符、清除和键盘交互。

+

Ant Design Ant Design 生态的一部分。

+

📦 ⭐ React 评分组件,支持半星、自定义字符、清除和键盘交互。

npm version @@ -19,10 +18,10 @@ ## 特性 -- Controlled and uncontrolled rating values. -- Half-star selection, custom characters, and custom character rendering. -- Keyboard interaction, focus/blur methods, disabled state, and RTL support. -- TypeScript definitions for props and imperative refs. +- 受控和非受控额定值。 +- 半星选择、自定义角色和自定义角色渲染。 +- 支持键盘交互、焦点/模糊方法、取消状态和RTL。 +- props 和命令式引用的 TypeScript 定义。 ## 安装 @@ -66,36 +65,36 @@ npm start | 名称 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | -| `allowClear` | boolean | true | Clear the value when clicking the selected item again. | -| `allowHalf` | boolean | false | Enable half item selection. | -| `autoFocus` | boolean | false | Focus the rating on mount. | -| `character` | ReactNode \| (props: StarProps) => ReactNode | `'★'` | Custom character for each item. | -| `characterRender` | (origin: ReactElement, props: StarProps) => ReactNode | - | Custom renderer for each item. | -| `className` | string | - | Additional class name. | -| `count` | number | 5 | Number of rating items. | -| `defaultValue` | number | 0 | Initial uncontrolled value. | -| `direction` | string | `'ltr'` | Layout direction. Use `'rtl'` for right-to-left display. | -| `disabled` | boolean | false | Disable interaction. | -| `id` | string | - | Root element id. | -| `keyboard` | boolean | true | Enable keyboard control. | -| `prefixCls` | string | `'rc-rate'` | Prefix class name. | -| `style` | React.CSSProperties | - | Root style. | -| `tabIndex` | number | 0 | Root tab index. | -| `value` | number | - | Controlled value. | -| `onBlur` | () => void | - | Blur callback. | -| `onChange` | (value: number) => void | - | Value change callback. | -| `onFocus` | () => void | - | Focus callback. | -| `onHoverChange` | (value: number) => void | - | Hover value callback. | -| `onKeyDown` | React.KeyboardEventHandler | - | Keydown callback. | -| `onMouseEnter` | React.MouseEventHandler | - | Mouse enter callback. | -| `onMouseLeave` | React.MouseEventHandler | - | Mouse leave callback. | +| `allowClear` | boolean | true | 再次单击所选项目时清除该值。 | +| `allowHalf` | boolean | false | 启用一半项目选择。 | +| `autoFocus` | boolean | false | 将评级重点放在安装上。 | +| `character` | ReactNode \| (props: StarProps) => ReactNode | `'★'` | 每项的自定义字符。 | +| `characterRender` | (origin: ReactElement, props: StarProps) => ReactNode | - | 每项的自定义渲染函数。 | +| `className` | string | - | 附加className。 | +| `count` | number | 5 | 评级项目的数量。 | +| `defaultValue` | number | 0 | 初始不受控值。 | +| `direction` | string | `'ltr'` | 布局方向。使用 `'rtl'` 从右到左显示。 | +| `disabled` | boolean | false | 禁用交互。 | +| `id` | string | - | 根元素 ID。 | +| `keyboard` | boolean | true | 启用键盘控制。 | +| `prefixCls` | string | `'rc-rate'` | 前缀className。 | +| `style` | React.CSSProperties | - | 根样式。 | +| `tabIndex` | number | 0 | 根选项卡索引。 | +| `value` | number | - | 受控值。 | +| `onBlur` | () => void | - | 失焦回调。 | +| `onChange` | (值:数字)=> 无效 | - | 值变化回调。 | +| `onFocus` | () => void | - | 聚焦回调。 | +| `onHoverChange` | (值:数字)=> 无效 | - | 悬浮值回调。 | +| `onKeyDown` | React.KeyboardEventHandler | - | 按键回调。 | +| `onMouseEnter` | React.MouseEventHandler | - | 鼠标进入回调。 | +| `onMouseLeave` | React.MouseEventHandler | - | 鼠标离开回调。 | ### Ref | 名称 | 类型 | 说明 | | ------- | ---------- | ----------------------------- | -| `blur` | () => void | Remove focus from the rating. | -| `focus` | () => void | Focus the rating. | +| `blur` | () => void | 移除评分组件焦点。 | +| `focus` | () => void | 聚焦评分组件。 | ## 本地开发 @@ -114,8 +113,8 @@ npm run build npm run prepublishOnly ``` -The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. +包构建完成后,发布流程由 `@rc-component/np` 通过 `rc-np` 命令处理。 ## 许可证 -@rc-component/rate is released under the [MIT](./LICENSE.md) license. +@rc-component/rate 基于 [MIT](./LICENSE.md) 许可证发布。 From 10d85ce211b2f3ce6e084eb8a92e42b71c836798 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 01:28:42 +0800 Subject: [PATCH 13/33] chore: standardize rc tooling and docs --- .dumirc.ts | 2 +- README.md | 4 +++- README.zh-CN.md | 4 +++- package.json | 34 +++++++++++++++++----------------- tsconfig.json | 31 +++++++++++++++++++++++++------ 5 files changed, 49 insertions(+), 26 deletions(-) diff --git a/.dumirc.ts b/.dumirc.ts index 0966ae2..0f1beb4 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -2,7 +2,7 @@ import { defineConfig } from 'dumi'; import path from 'path'; const basePath = process.env.GH_PAGES ? '/rate/' : '/'; -const publicPath = process.env.GH_PAGES ? '/rate/' : '/'; +const publicPath = basePath; export default defineConfig({ alias: { diff --git a/README.md b/README.md index 53fd550..cf4c9eb 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,15 @@ export default () => ( ## Examples -Run the examples locally: +Run the local dumi site: ```bash npm install npm start ``` +Then open `http://localhost:8000`. + ## API ### Rate diff --git a/README.zh-CN.md b/README.zh-CN.md index ee2b9f6..a9c398f 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -52,13 +52,15 @@ export default () => ( ## 示例 -本地运行示例: +运行本地 dumi 站点: ```bash npm install npm start ``` +然后打开 `http://localhost:8000`。 + ## API ### Rate diff --git a/package.json b/package.json index fafdf95..73557d7 100644 --- a/package.json +++ b/package.json @@ -46,24 +46,24 @@ }, "devDependencies": { "@rc-component/father-plugin": "^2.2.0", - "@rc-component/np": "^1.0.0", + "@rc-component/np": "^1.0.4", "@rc-component/tooltip": "^1.2.1", - "@testing-library/react": "^16.0.1", - "@types/jest": "^29.5.1", - "@types/node": "^24.5.2", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", - "@umijs/fabric": "^3.0.0", - "cross-env": "^7.0.0", - "dumi": "^2.1.2", - "eslint": "^7.1.0", - "father": "^4.0.0", - "gh-pages": "^3.1.0", - "less": "^3.0.0", - "rc-test": "^7.0.15", - "react": "^18.0.0", - "react-dom": "^18.0.0", - "typescript": "^5.0.4" + "@testing-library/react": "^15.0.7", + "@types/jest": "^29.5.14", + "@types/node": "^26.0.1", + "@types/react": "^18.3.31", + "@types/react-dom": "^18.3.7", + "@umijs/fabric": "^4.0.1", + "cross-env": "^10.1.0", + "dumi": "^2.4.35", + "eslint": "^8.57.1", + "father": "^4.6.23", + "gh-pages": "^6.3.0", + "less": "^4.6.7", + "rc-test": "^7.1.3", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "typescript": "^5.9.3" }, "peerDependencies": { "react": ">=16.9.0", diff --git a/tsconfig.json b/tsconfig.json index 021cd92..65d646b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,11 +8,30 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": ["src/*"], - "@@/*": [".dumi/tmp/*"], - "@rc-component/rate": ["src/index.tsx"] - } + "@/*": [ + "src/*" + ], + "@@/*": [ + ".dumi/tmp/*" + ], + "@rc-component/rate": [ + "src/index.tsx" + ] + }, + "ignoreDeprecations": "5.0" }, - "include": [".dumirc.ts", "src", "docs", "tests"], - "exclude": ["node_modules", "lib", "es", "dist", "docs-dist", ".dumi"] + "include": [ + ".dumirc.ts", + "src", + "docs", + "tests" + ], + "exclude": [ + "node_modules", + "lib", + "es", + "dist", + "docs-dist", + ".dumi" + ] } From a5b9ef224d68d3c6058ecae20dcc35d46f6c338e Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 02:01:07 +0800 Subject: [PATCH 14/33] chore: address standardization review comments --- .github/workflows/surge-preview.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index faf6b8b..cb6c8c4 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -22,13 +22,23 @@ jobs: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false + - name: Check Surge token + id: surge-token + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + run: | + if [ -n "$SURGE_TOKEN" ]; then + echo "enabled=true" >> "$GITHUB_OUTPUT" + else + echo "enabled=false" >> "$GITHUB_OUTPUT" + fi - name: Build preview - if: ${{ secrets.SURGE_TOKEN != '' }} + if: ${{ steps.surge-token.outputs.enabled == 'true' }} run: | npm install npm run build - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec - if: ${{ secrets.SURGE_TOKEN != '' }} + if: ${{ steps.surge-token.outputs.enabled == 'true' }} env: SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} with: @@ -38,5 +48,5 @@ jobs: failOnError: false setCommitStatus: false - name: Skip Surge preview - if: ${{ secrets.SURGE_TOKEN == '' }} + if: ${{ steps.surge-token.outputs.enabled != 'true' }} run: echo "SURGE_TOKEN is not configured; skip Surge preview." From a520524e72eed93406b4103f15a2d40b3802e615 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 02:10:34 +0800 Subject: [PATCH 15/33] chore: include father config in type checks --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index 65d646b..f0380c4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,7 @@ "ignoreDeprecations": "5.0" }, "include": [ + ".fatherrc.ts", ".dumirc.ts", "src", "docs", From 692ab077018b3f18d90ba891173ed57ddac46482 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:24:27 +0800 Subject: [PATCH 16/33] ci: update GitHub Actions versions --- .github/workflows/codeql.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4e2c36c..25021e7 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,15 +29,15 @@ jobs: persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/init@a0853c24544627f65ddf259abe73b1d18a591444 with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/autobuild@a0853c24544627f65ddf259abe73b1d18a591444 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/analyze@a0853c24544627f65ddf259abe73b1d18a591444 with: category: '/language:${{ matrix.language }}' From 1f981e01af4625b9958d1d02073aa0d45158b28b Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:30:01 +0800 Subject: [PATCH 17/33] ci: use resolvable CodeQL action ref --- .github/workflows/codeql.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 25021e7..4e2c36c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,15 +29,15 @@ jobs: persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: category: '/language:${{ matrix.language }}' From e0a4c5edbea6cd45d773972ce879f623c7fa47b5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 13:27:49 +0800 Subject: [PATCH 18/33] docs: add license file --- LICENSE | 21 +++++++++++++++++++++ README.md | 2 +- README.zh-CN.md | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bd0a1f7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019-present react-component + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index cf4c9eb..4370172 100644 --- a/README.md +++ b/README.md @@ -119,4 +119,4 @@ The release flow is handled by `@rc-component/np` through the `rc-np` command af ## License -@rc-component/rate is released under the [MIT](./LICENSE.md) license. +@rc-component/rate is released under the [MIT](./LICENSE) license. diff --git a/README.zh-CN.md b/README.zh-CN.md index a9c398f..41abe05 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -119,4 +119,4 @@ npm run prepublishOnly ## 许可证 -@rc-component/rate 基于 [MIT](./LICENSE.md) 许可证发布。 +@rc-component/rate 基于 [MIT](./LICENSE) 许可证发布。 From 0e985b1ee15a36a23221e56bed0801c7e8dc5510 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:00:58 +0800 Subject: [PATCH 19/33] ci: use actions checkout v7 --- .github/workflows/codeql.yml | 2 +- .github/workflows/react-doctor.yml | 2 +- .github/workflows/surge-preview.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4e2c36c..be9c576 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + uses: actions/checkout@v7 with: persist-credentials: false diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml index f68281c..097eb88 100644 --- a/.github/workflows/react-doctor.yml +++ b/.github/workflows/react-doctor.yml @@ -20,7 +20,7 @@ jobs: react-doctor: runs-on: ubuntu-latest steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + - uses: actions/checkout@v7 with: fetch-depth: 0 persist-credentials: false diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index cb6c8c4..ebfecd5 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -19,7 +19,7 @@ jobs: env: PREVIEW: true steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + - uses: actions/checkout@v7 with: persist-credentials: false - name: Check Surge token From 9bb34bceaca9d1a999df99deb2b2ae8d0d9b929a Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:31:53 +0800 Subject: [PATCH 20/33] chore: standardize package metadata --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 73557d7..61fb927 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "react-rate", "rate" ], - "homepage": "https://github.com/react-component/rate", + "homepage": "https://react-component.github.io/rate", "bugs": { "url": "https://github.com/react-component/rate/issues" }, @@ -71,5 +71,8 @@ }, "engines": { "node": ">=8.x" + }, + "publishConfig": { + "access": "public" } } From 6cd9644c93c1a0c4ec1bd18cbed38bff003056ec Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:38:07 +0800 Subject: [PATCH 21/33] ci: standardize dependabot updates --- .github/dependabot.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 99e6fa7..3b730ef 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,18 +3,17 @@ updates: - package-ecosystem: npm directory: '/' schedule: - interval: daily + interval: weekly + day: monday time: '21:00' + timezone: Asia/Shanghai + open-pull-requests-limit: 10 + + - package-ecosystem: github-actions + directory: '/' + schedule: + interval: weekly + day: monday + time: '21:00' + timezone: Asia/Shanghai open-pull-requests-limit: 10 - ignore: - - dependency-name: '@types/react' - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - 17.0.3 - - dependency-name: '@types/react-dom' - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 From 5300715d72201a1436c0b0b88a85ea233c09c9e1 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 16:27:31 +0800 Subject: [PATCH 22/33] docs: fix Chinese README API names --- README.zh-CN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index 41abe05..c16dac1 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -84,9 +84,9 @@ npm start | `tabIndex` | number | 0 | 根选项卡索引。 | | `value` | number | - | 受控值。 | | `onBlur` | () => void | - | 失焦回调。 | -| `onChange` | (值:数字)=> 无效 | - | 值变化回调。 | +| `onChange` | (value: number) => void | - | 值变化回调。 | | `onFocus` | () => void | - | 聚焦回调。 | -| `onHoverChange` | (值:数字)=> 无效 | - | 悬浮值回调。 | +| `onHoverChange` | (value: number) => void | - | 悬浮值回调。 | | `onKeyDown` | React.KeyboardEventHandler | - | 按键回调。 | | `onMouseEnter` | React.MouseEventHandler | - | 鼠标进入回调。 | | `onMouseLeave` | React.MouseEventHandler | - | 鼠标离开回调。 | From 1961f3ad09538c3e95eb9cc03881845f188cb68e Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:15:47 +0800 Subject: [PATCH 23/33] chore: refine preview workflow ignores --- .github/workflows/surge-preview.yml | 3 +++ .prettierignore | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .prettierignore diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index ebfecd5..eaff160 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -16,6 +16,9 @@ permissions: jobs: preview: runs-on: ubuntu-latest + concurrency: + group: surge-preview-${{ github.event.pull_request.number }} + cancel-in-progress: true env: PREVIEW: true steps: diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..c466d87 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,14 @@ +node_modules +coverage +docs-dist +dist +es +lib +.dumi/tmp +.dumi/tmp-production +.vercel +package-lock.json +pnpm-lock.yaml +yarn.lock +bun.lockb +*.log From c05106ddbb3f2f88223fa0deae9aaf5963d957ff Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:36:30 +0800 Subject: [PATCH 24/33] docs: polish Chinese README wording --- README.zh-CN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index c16dac1..a1595e2 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -72,14 +72,14 @@ npm start | `autoFocus` | boolean | false | 将评级重点放在安装上。 | | `character` | ReactNode \| (props: StarProps) => ReactNode | `'★'` | 每项的自定义字符。 | | `characterRender` | (origin: ReactElement, props: StarProps) => ReactNode | - | 每项的自定义渲染函数。 | -| `className` | string | - | 附加className。 | +| `className` | string | - | 附加 className。 | | `count` | number | 5 | 评级项目的数量。 | | `defaultValue` | number | 0 | 初始不受控值。 | | `direction` | string | `'ltr'` | 布局方向。使用 `'rtl'` 从右到左显示。 | | `disabled` | boolean | false | 禁用交互。 | | `id` | string | - | 根元素 ID。 | | `keyboard` | boolean | true | 启用键盘控制。 | -| `prefixCls` | string | `'rc-rate'` | 前缀className。 | +| `prefixCls` | string | `'rc-rate'` | className 前缀。 | | `style` | React.CSSProperties | - | 根样式。 | | `tabIndex` | number | 0 | 根选项卡索引。 | | `value` | number | - | 受控值。 | From 364a12c727e47215f5e1b0fc731ade72ece919a1 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 18:19:27 +0800 Subject: [PATCH 25/33] chore: add missing prettier dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 61fb927..297a5e0 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ }, "devDependencies": { "@rc-component/father-plugin": "^2.2.0", + "prettier": "^3.9.0", "@rc-component/np": "^1.0.4", "@rc-component/tooltip": "^1.2.1", "@testing-library/react": "^15.0.7", From fd3bb8191d04f10b402995da92dd4704fb1549dc Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:39:02 +0800 Subject: [PATCH 26/33] docs: document dumi dev server port --- README.md | 2 ++ README.zh-CN.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 4370172..5033ae1 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,8 @@ npm run compile npm run build ``` +The dumi site runs at `http://localhost:8000` by default. + ## Release ```bash diff --git a/README.zh-CN.md b/README.zh-CN.md index a1595e2..1bf0c0b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -109,6 +109,8 @@ npm run compile npm run build ``` +dumi 站点默认运行在 `http://localhost:8000`。 + ## 发布 ```bash From 87030fdc758bce405097f1432877897165face12 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:58:21 +0800 Subject: [PATCH 27/33] chore: standardize husky configuration --- .husky/pre-commit | 1 + package.json | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..2312dc5 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npx lint-staged diff --git a/package.json b/package.json index 297a5e0..a2f54b5 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "docs:deploy": "gh-pages -d docs-dist", "gh-pages": "cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", - "prepare": "dumi setup", + "prepare": "husky && dumi setup", "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write --ignore-unknown .", "postpublish": "npm run gh-pages", @@ -64,7 +64,9 @@ "rc-test": "^7.1.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "typescript": "^5.9.3" + "typescript": "^5.9.3", + "husky": "^9.1.7", + "lint-staged": "^16.4.0" }, "peerDependencies": { "react": ">=16.9.0", @@ -75,5 +77,8 @@ }, "publishConfig": { "access": "public" + }, + "lint-staged": { + "*": "prettier --write --ignore-unknown" } } From 72bfe70de0189ce5c3aec2f59c9e289af43cda40 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 20:32:50 +0800 Subject: [PATCH 28/33] chore: standardize package type entry --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a2f54b5..2b20f2f 100644 --- a/package.json +++ b/package.json @@ -80,5 +80,6 @@ }, "lint-staged": { "*": "prettier --write --ignore-unknown" - } + }, + "types": "./es/index.d.ts" } From 8d51c08aa8edbc1259f43a51ed8816b56b43deb6 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:01:02 +0800 Subject: [PATCH 29/33] docs: normalize readme badges --- README.md | 12 ++++++------ README.zh-CN.md | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5033ae1..c1caeb6 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,12 @@

📦 ⭐ Accessible React rating component with half-star and keyboard support.

- npm version - npm downloads - CI - Codecov - Bundle size - dumi + NPM version + npm downloads + build status + Codecov + bundle size + dumi

diff --git a/README.zh-CN.md b/README.zh-CN.md index 1bf0c0b..001637b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -4,12 +4,12 @@

📦 ⭐ React 评分组件,支持半星、自定义字符、清除和键盘交互。

- npm version - npm downloads - CI - Codecov - Bundle size - dumi + NPM version + npm downloads + build status + Codecov + bundle size + dumi

From d2cff4f8f34850d84b8e24feee3a1645d32110fd Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:20:48 +0800 Subject: [PATCH 30/33] ci: limit reusable workflow secrets --- .github/workflows/react-component-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 9503b96..75e7054 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -5,4 +5,6 @@ permissions: jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: inherit + secrets: + + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 5835d0c3945a23b3c62f2c5044b55dc1c225990e Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:29:51 +0800 Subject: [PATCH 31/33] ci: restore reusable workflow compatibility --- .github/workflows/react-component-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 75e7054..9503b96 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -5,6 +5,4 @@ permissions: jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: - - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + secrets: inherit From 90d4158caca56361b1c58f568f4d82643a0ff921 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 01:00:23 +0800 Subject: [PATCH 32/33] ci: narrow surge preview permissions --- .github/workflows/surge-preview.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index eaff160..4c2f17e 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -11,7 +11,6 @@ permissions: contents: read pull-requests: write checks: write - statuses: write jobs: preview: From 81fc86e8a5adb04fe2c00fb5080868b7d0cbc7b8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 14:26:06 +0800 Subject: [PATCH 33/33] chore: limit reusable workflow secrets --- .github/workflows/react-component-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 9503b96..8d135ed 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -5,4 +5,5 @@ permissions: jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: inherit + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file