From 0a06399f5f547287c910c8a5f8d20b7d79e214c4 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 12:38:05 +0800 Subject: [PATCH 01/34] chore: standardize repository setup --- .github/FUNDING.yml | 2 + .../workflows/cloudflare-pages-preview.yml | 38 ++++ .github/workflows/codeql.yml | 22 +-- .github/workflows/main.yml | 4 +- .github/workflows/react-doctor.yml | 27 +++ .github/workflows/surge-preview.yml | 34 ++++ README.md | 168 ++++++++++-------- package.json | 9 +- vercel.json | 6 + 9 files changed, 218 insertions(+), 92 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/cloudflare-pages-preview.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/.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/workflows/cloudflare-pages-preview.yml b/.github/workflows/cloudflare-pages-preview.yml new file mode 100644 index 0000000..c1738df --- /dev/null +++ b/.github/workflows/cloudflare-pages-preview.yml @@ -0,0 +1,38 @@ +name: Cloudflare Pages Preview + +on: + pull_request: + +permissions: + contents: read + deployments: write + +jobs: + preview: + runs-on: ubuntu-latest + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_PAGES_PROJECT: ${{ vars.CLOUDFLARE_PAGES_PROJECT }} + PREVIEW: true + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false + - name: Skip Cloudflare Pages preview + if: ${{ env.CLOUDFLARE_API_TOKEN == '' || env.CLOUDFLARE_ACCOUNT_ID == '' || env.CLOUDFLARE_PAGES_PROJECT == '' }} + run: echo "Cloudflare Pages preview is not configured; skip deployment." + - name: Install dependencies + if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} + run: npm install + - name: Build site + if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} + run: npm run build + - name: Deploy preview + if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} + uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 + with: + apiToken: ${{ env.CLOUDFLARE_API_TOKEN }} + accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy dist --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT }} --branch=${{ github.head_ref }} + gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1bc4e70..85ac177 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: "8 20 * * 1" + - cron: '8 20 * * 1' 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/main.yml b/.github/workflows/main.yml index 5735e2d..f8482b6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,5 +2,5 @@ name: ✅ test on: [push, pull_request] 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..b7986b6 --- /dev/null +++ b/.github/workflows/surge-preview.yml @@ -0,0 +1,34 @@ +name: Surge Preview + +on: + pull_request: + +permissions: + contents: read + pull-requests: write + checks: 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: 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/README.md b/README.md index 0a64f69..5969a5f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ -# rc-checkbox +
+

@rc-component/checkbox

+

☑️ A small, accessible checkbox primitive for React.

---- + + Ant Design + -Checkbox ui component for react. +

Part of the Ant Design ecosystem.

[![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] @@ -11,102 +15,114 @@ Checkbox ui component for react. [![bundle size][bundlephobia-image]][bundlephobia-url] [![dumi][dumi-image]][dumi-url] -[npm-image]: http://img.shields.io/npm/v/rc-checkbox.svg?style=flat-square -[npm-url]: http://npmjs.org/package/rc-checkbox -[travis-image]: https://img.shields.io/travis/react-component/checkbox/master?style=flat-square -[travis-url]: https://travis-ci.com/react-component/checkbox -[github-actions-image]: https://github.com/react-component/checkbox/workflows/CI/badge.svg -[github-actions-url]: https://github.com/react-component/checkbox/actions +
+ +[npm-image]: https://img.shields.io/npm/v/@rc-component/checkbox.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@rc-component/checkbox +[github-actions-image]: https://github.com/react-component/checkbox/actions/workflows/main.yml/badge.svg +[github-actions-url]: https://github.com/react-component/checkbox/actions/workflows/main.yml [codecov-image]: https://img.shields.io/codecov/c/github/react-component/checkbox/master.svg?style=flat-square [codecov-url]: https://app.codecov.io/gh/react-component/checkbox -[david-url]: https://david-dm.org/react-component/checkbox -[david-image]: https://david-dm.org/react-component/checkbox/status.svg?style=flat-square -[david-dev-url]: https://david-dm.org/react-component/checkbox?type=dev -[david-dev-image]: https://david-dm.org/react-component/checkbox/dev-status.svg?style=flat-square -[download-image]: https://img.shields.io/npm/dm/rc-checkbox.svg?style=flat-square -[download-url]: https://npmjs.org/package/rc-checkbox -[bundlephobia-url]: https://bundlephobia.com/package/rc-checkbox -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-checkbox -[dumi-url]: https://github.com/umijs/dumi +[download-image]: https://img.shields.io/npm/dm/@rc-component/checkbox.svg?style=flat-square +[download-url]: https://npmjs.org/package/@rc-component/checkbox +[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/%40rc-component%2Fcheckbox?style=flat-square +[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/checkbox [dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square +[dumi-url]: https://github.com/umijs/dumi + +## Highlights + +- Works as a controlled or uncontrolled checkbox. +- Exposes an imperative ref for focus, blur, and DOM access. +- Keeps native input attributes available while normalizing the change event. +- Ships compiled JavaScript, TypeScript definitions, and a standalone CSS asset. ## Install -[![rc-checkbox](https://nodei.co/npm/rc-checkbox.png)](https://npmjs.org/package/rc-checkbox) +```bash +npm install @rc-component/checkbox +``` ## Usage -```js -import checkbox from '@rc-component/checkbox'; +```tsx +import Checkbox from '@rc-component/checkbox'; +import '@rc-component/checkbox/assets/index.css'; + +export default function App() { + return ( + { + console.log(event.target.checked); + }} + /> + ); +} +``` + +## Examples -export default () => ; +```bash +npm install +npm start ``` -## Compatibility +Then open `http://localhost:8000`. -| [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | [Electron](http://godban.github.io/browsers-support-badges/)
Electron | -| --- | --- | --- | --- | --- | -| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | +Online demo: https://react-component.github.io/checkbox/ ## API - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
nametypedefaultdescription
prefixClsStringrc-checkbox
classNameString''additional class name of root node
nameStringsame with native input checkbox
checkedenum: 0,1,2
defaultCheckedenum: 0,1,20same with native input checkbox
onChangeFunction(e:Event, checked:Number)called when checkbox is changed. e is native event, checked is original checked state.
+### Checkbox + +| Property | Description | Type | Default | +| -------------- | ------------------------------------------ | -------------------------------------- | ------------- | +| checked | Whether the checkbox is checked | boolean | - | +| className | Additional class name | string | - | +| defaultChecked | Whether the checkbox is checked by default | boolean | false | +| disabled | Whether the checkbox is disabled | boolean | false | +| name | Same as native checkbox input `name` | string | - | +| prefixCls | Component class name prefix | string | `rc-checkbox` | +| style | Inline style for the wrapper | `React.CSSProperties` | - | +| type | Native input type | string | `checkbox` | +| value | Same as native checkbox input `value` | string \| number \| readonly string[] | - | +| onChange | Callback when checked state changes | `(event: CheckboxChangeEvent) => void` | - | + +Other native input attributes are also supported. + +### Ref + +| Property | Description | Type | +| ------------- | ------------------------------ | ---------------------------------- | +| blur | Remove focus from the checkbox | `() => void` | +| focus | Focus the checkbox | `(options?: FocusOptions) => void` | +| input | Native input element | `HTMLInputElement \| null` | +| nativeElement | Wrapper element | `HTMLElement \| null` | ## Development -``` +```bash npm install npm start ``` -Online demo: http://react-component.github.io/checkbox/ +```bash +npm test +npm run tsc +npm run lint +npm run compile +npm run build +``` + +## Release + +```bash +npm run prepublishOnly +``` + +The release script compiles the package and runs `rc-np`. ## License -rc-checkbox is released under the MIT license. +`@rc-component/checkbox` is released under the MIT license. diff --git a/package.json b/package.json index 038b9fb..4dfe5af 100644 --- a/package.json +++ b/package.json @@ -31,18 +31,19 @@ "coverage": "jest --coverage", "gh-pages": "npm run build && father doc deploy -d dist", "lint": "eslint src/ --ext .tsx,.ts", - "prepare": "husky install && dumi setup", + "prepare": "husky && dumi setup", "prepublishOnly": "npm run compile && rc-np", + "prettier": "prettier --write --ignore-unknown .", "start": "dumi dev", "test": "jest", - "tsc": "bunx tsc --noEmit" + "tsc": "tsc --noEmit" }, "lint-staged": { "*.{js,jsx,less,md,json}": [ - "prettier --write" + "prettier --write --ignore-unknown" ], "*.ts?(x)": [ - "prettier --parser=typescript --write" + "prettier --parser=typescript --write --ignore-unknown" ] }, "dependencies": { diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..e884e1b --- /dev/null +++ b/vercel.json @@ -0,0 +1,6 @@ +{ + "framework": "umijs", + "installCommand": "npm install", + "buildCommand": "npm run build", + "outputDirectory": "dist" +} From 748e5c95b45bfd1de4050af9a3120f6250e4d390 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 12:40:40 +0800 Subject: [PATCH 02/34] chore: simplify lint-staged prettier command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4dfe5af..ac73e21 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "prettier --write --ignore-unknown" ], "*.ts?(x)": [ - "prettier --parser=typescript --write --ignore-unknown" + "prettier --write --ignore-unknown" ] }, "dependencies": { From 344d6faf625ee058fe4a893c086ca829ba389343 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 12:41:29 +0800 Subject: [PATCH 03/34] ci: allow surge preview status updates --- .github/workflows/surge-preview.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index b7986b6..1b7fc7e 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -7,6 +7,7 @@ permissions: contents: read pull-requests: write checks: write + statuses: write jobs: preview: From bf5628a49f06e18f8c871fc02cc962db6ad94305 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 15:03:18 +0800 Subject: [PATCH 04/34] chore: remove cloudflare preview and now-build --- .../workflows/cloudflare-pages-preview.yml | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 .github/workflows/cloudflare-pages-preview.yml diff --git a/.github/workflows/cloudflare-pages-preview.yml b/.github/workflows/cloudflare-pages-preview.yml deleted file mode 100644 index c1738df..0000000 --- a/.github/workflows/cloudflare-pages-preview.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Cloudflare Pages Preview - -on: - pull_request: - -permissions: - contents: read - deployments: write - -jobs: - preview: - runs-on: ubuntu-latest - env: - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - CLOUDFLARE_PAGES_PROJECT: ${{ vars.CLOUDFLARE_PAGES_PROJECT }} - PREVIEW: true - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - with: - persist-credentials: false - - name: Skip Cloudflare Pages preview - if: ${{ env.CLOUDFLARE_API_TOKEN == '' || env.CLOUDFLARE_ACCOUNT_ID == '' || env.CLOUDFLARE_PAGES_PROJECT == '' }} - run: echo "Cloudflare Pages preview is not configured; skip deployment." - - name: Install dependencies - if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} - run: npm install - - name: Build site - if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} - run: npm run build - - name: Deploy preview - if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} - uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 - with: - apiToken: ${{ env.CLOUDFLARE_API_TOKEN }} - accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy dist --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT }} --branch=${{ github.head_ref }} - gitHubToken: ${{ secrets.GITHUB_TOKEN }} From 3b8e33ba91058b5ec19f1b96e4842ecbb3d9c6a9 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:56:45 +0800 Subject: [PATCH 05/34] docs: standardize README release details --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5969a5f..4f6fab6 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@

Part of the Ant Design ecosystem.

+ + +
[![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] @@ -121,8 +124,8 @@ npm run build npm run prepublishOnly ``` -The release script compiles the package and runs `rc-np`. +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. ## License -`@rc-component/checkbox` is released under the MIT license. +@rc-component/checkbox is released under the [MIT](./LICENSE.md) license. From 2a1c02ee2164e15f5706f93d7b77277e354c3666 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:13:36 +0800 Subject: [PATCH 06/34] 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 1b7fc7e..c1e7176 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -25,7 +25,7 @@ jobs: surge_token: ${{ env.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} dist: dist - failOnError: true + failOnError: false setCommitStatus: true build: | npm install From b0fc36bd4fd1c60632587c1668fa2e484e4203ba Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:25:40 +0800 Subject: [PATCH 07/34] 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 c1e7176..d4a0c7a 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -26,7 +26,7 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} dist: dist failOnError: false - setCommitStatus: true + setCommitStatus: false build: | npm install npm run build From 67028d62772ca8f74353270602c346d4e8c2f578 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:03:57 +0800 Subject: [PATCH 08/34] docs: refine README usage and ecosystem note --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4f6fab6..88961c7 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,10 @@

@rc-component/checkbox

+

Part of the Ant Design ecosystem.

☑️ A small, accessible checkbox primitive for React.

- - - Ant Design - - -

Part of the Ant Design ecosystem.

+
[![NPM version][npm-image]][npm-url] From 51519b8012d96be7721f08ae78b0891e22729259 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:22:13 +0800 Subject: [PATCH 09/34] 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 d4a0c7a..230f8c6 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -13,23 +13,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: 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 8a14a22a7a02fe67f0a4f115a81d86a413d24626 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:19:06 +0800 Subject: [PATCH 10/34] docs: add Chinese README --- README.md | 2 + README.zh-CN.md | 129 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 README.zh-CN.md diff --git a/README.md b/README.md index 88961c7..1e39fbf 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@

☑️ A small, accessible checkbox primitive for React.

+

English | 简体中文

+
diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 0000000..9dc5eea --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,129 @@ +
+

@rc-component/checkbox

+

Ant Design 生态的一部分。

+

☑️ 轻量、可访问的 React 复选框基础组件。

+
+ +

English | 简体中文

+ + +
+ +[![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]: https://img.shields.io/npm/v/@rc-component/checkbox.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@rc-component/checkbox +[github-actions-image]: https://github.com/react-component/checkbox/actions/workflows/main.yml/badge.svg +[github-actions-url]: https://github.com/react-component/checkbox/actions/workflows/main.yml +[codecov-image]: https://img.shields.io/codecov/c/github/react-component/checkbox/master.svg?style=flat-square +[codecov-url]: https://app.codecov.io/gh/react-component/checkbox +[download-image]: https://img.shields.io/npm/dm/@rc-component/checkbox.svg?style=flat-square +[download-url]: https://npmjs.org/package/@rc-component/checkbox +[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/%40rc-component%2Fcheckbox?style=flat-square +[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/checkbox +[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square +[dumi-url]: https://github.com/umijs/dumi + +## 特性 + +- 可 as a controlled or uncontrolled checkbox. +- 暴露 an imperative ref for focus, blur, and DOM access. +- 保留 native input attributes available while normalizing the change event. +- 提供编译后的 JavaScript、TypeScript 类型定义和独立 CSS 资源。 + +## 安装 + +```bash +npm install @rc-component/checkbox +``` + +## 使用 + +```tsx +import Checkbox from '@rc-component/checkbox'; +import '@rc-component/checkbox/assets/index.css'; + +export default function App() { + return ( + { + console.log(event.target.checked); + }} + /> + ); +} +``` + +## 示例 + +```bash +npm install +npm start +``` + +然后打开 `http://localhost:8000`。 + +在线演示: https://react-component.github.io/checkbox/ + +## API + +### Checkbox + +| 参数 | 说明 | 类型 | 默认值 | +| -------------- | ------------------------------------------ | -------------------------------------- | ------------- | +| checked | Whether the checkbox is checked | boolean | - | +| className | Additional class name | string | - | +| defaultChecked | Whether the checkbox is checked by default | boolean | false | +| disabled | Whether the checkbox is disabled | boolean | false | +| name | Same as native checkbox input `name` | string | - | +| prefixCls | Component class name prefix | string | `rc-checkbox` | +| style | Inline style for the wrapper | `React.CSSProperties` | - | +| type | Native input type | string | `checkbox` | +| value | Same as native checkbox input `value` | string \| number \| readonly string[] | - | +| onChange | Callback when checked state changes | `(event: CheckboxChangeEvent) => void` | - | + +Other native input attributes are also supported. + +### Ref + +| 参数 | 说明 | 类型 | +| ------------- | ------------------------------ | ---------------------------------- | +| blur | Remove focus from the checkbox | `() => void` | +| focus | Focus the checkbox | `(options?: FocusOptions) => void` | +| input | Native input element | `HTMLInputElement \| null` | +| nativeElement | Wrapper element | `HTMLElement \| null` | + +## 本地开发 + +```bash +npm install +npm start +``` + +```bash +npm test +npm run tsc +npm run lint +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/checkbox is released under the [MIT](./LICENSE.md) license. From b518d1bd25d201c56395a6577d63384c911697d7 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:34:25 +0800 Subject: [PATCH 11/34] 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 1e39fbf..2222e82 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@

@rc-component/checkbox

Part of the Ant Design ecosystem.

+ Ant Design

☑️ A small, accessible checkbox primitive for React.

diff --git a/README.zh-CN.md b/README.zh-CN.md index 9dc5eea..8472ef6 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,6 +1,7 @@

@rc-component/checkbox

Ant Design 生态的一部分。

+ Ant Design

☑️ 轻量、可访问的 React 复选框基础组件。

From c1df5f8b56edc7f05062c1de0622d178ba91ed3a Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 23:02:39 +0800 Subject: [PATCH 12/34] docs: refine bilingual README branding --- README.md | 3 +-- README.zh-CN.md | 45 ++++++++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 2222e82..15e96c2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@

@rc-component/checkbox

-

Part of the Ant Design ecosystem.

- Ant Design +

Ant Design Part of the Ant Design ecosystem.

☑️ A small, accessible checkbox primitive for React.

diff --git a/README.zh-CN.md b/README.zh-CN.md index 8472ef6..4389661 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,7 +1,6 @@

@rc-component/checkbox

-

Ant Design 生态的一部分。

- Ant Design +

Ant Design Ant Design 生态的一部分。

☑️ 轻量、可访问的 React 复选框基础组件。

@@ -34,9 +33,9 @@ ## 特性 -- 可 as a controlled or uncontrolled checkbox. -- 暴露 an imperative ref for focus, blur, and DOM access. -- 保留 native input attributes available while normalizing the change event. +- 可作为受控或非受控复选框。 +- 引入用于焦点、模糊和 DOM 访问的命令式引用。 +- 在规范化更改事件时保留可用的本机输入属性。 - 提供编译后的 JavaScript、TypeScript 类型定义和独立 CSS 资源。 ## 安装 @@ -80,27 +79,27 @@ npm start | 参数 | 说明 | 类型 | 默认值 | | -------------- | ------------------------------------------ | -------------------------------------- | ------------- | -| checked | Whether the checkbox is checked | boolean | - | -| className | Additional class name | string | - | -| defaultChecked | Whether the checkbox is checked by default | boolean | false | -| disabled | Whether the checkbox is disabled | boolean | false | -| name | Same as native checkbox input `name` | string | - | -| prefixCls | Component class name prefix | string | `rc-checkbox` | -| style | Inline style for the wrapper | `React.CSSProperties` | - | -| type | Native input type | string | `checkbox` | -| value | Same as native checkbox input `value` | string \| number \| readonly string[] | - | -| onChange | Callback when checked state changes | `(event: CheckboxChangeEvent) => void` | - | - -Other native input attributes are also supported. +| checked | 复选框是否被选中 | boolean | - | +| className | 附加className | string | - | +| defaultChecked | 复选框是否默认选中 | boolean | false | +| disabled | 复选框是否禁用 | boolean | false | +| name | 与原生 checkbox input 一致 `name` | string | - | +| prefixCls | 组件className前缀 | string | `rc-checkbox` | +| 风格 | 包装器的内联样式 | `React.CSSProperties` | - | +| type | 原生输入类型 | string | `checkbox` | +| 价值 | 与原生 checkbox input 一致 `value` | 字符串\|数字\|只读字符串[] | - | +| onChange | 勾选状态改变时回调 | `(event: CheckboxChangeEvent) => void` | - | + +还支持其他本机输入属性。 ### Ref | 参数 | 说明 | 类型 | | ------------- | ------------------------------ | ---------------------------------- | -| blur | Remove focus from the checkbox | `() => void` | -| focus | Focus the checkbox | `(options?: FocusOptions) => void` | -| input | Native input element | `HTMLInputElement \| null` | -| nativeElement | Wrapper element | `HTMLElement \| null` | +| 模糊 | 从复选框中移除焦点 | `() => void` | +| 重点 | 聚焦复选框 | `(options?: FocusOptions) => void` | +| input | 原生输入元素 | `HTMLInputElement \| null` | +| nativeElement | 包装元素 | `HTMLElement \| null` | ## 本地开发 @@ -123,8 +122,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/checkbox is released under the [MIT](./LICENSE.md) license. +@rc-component/checkbox 基于 [MIT](./LICENSE.md) 许可证发布。 From c092a171bbb2ece5afe3556c3b12de88fc25167b Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 01:28:37 +0800 Subject: [PATCH 13/34] chore: standardize rc tooling and docs --- .dumirc.ts | 6 +++++ .github/workflows/surge-preview.yml | 2 +- README.md | 4 +-- README.zh-CN.md | 4 +-- package.json | 42 ++++++++++++++--------------- tsconfig.json | 21 +++++++++++---- vercel.json | 2 +- 7 files changed, 49 insertions(+), 32 deletions(-) diff --git a/.dumirc.ts b/.dumirc.ts index 01854c1..7d2614c 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,6 +1,12 @@ import { defineConfig } from 'dumi'; +const basePath = process.env.GH_PAGES ? '/checkbox/' : '/'; +const publicPath = basePath; + export default defineConfig({ + outputPath: 'docs-dist', + base: basePath, + publicPath, themeConfig: { name: 'Checkbox', }, diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 230f8c6..5e2be72 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -30,7 +30,7 @@ jobs: with: surge_token: ${{ env.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} - dist: dist + dist: docs-dist failOnError: false setCommitStatus: false - name: Skip Surge preview diff --git a/README.md b/README.md index 15e96c2..7d31401 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ export default function App() { ## Examples +Run the local dumi site: + ```bash npm install npm start @@ -71,8 +73,6 @@ npm start Then open `http://localhost:8000`. -Online demo: https://react-component.github.io/checkbox/ - ## API ### Checkbox diff --git a/README.zh-CN.md b/README.zh-CN.md index 4389661..845adc4 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -64,6 +64,8 @@ export default function App() { ## 示例 +运行本地 dumi 站点: + ```bash npm install npm start @@ -71,8 +73,6 @@ npm start 然后打开 `http://localhost:8000`。 -在线演示: https://react-component.github.io/checkbox/ - ## API ### Checkbox diff --git a/package.json b/package.json index ac73e21..963ce38 100644 --- a/package.json +++ b/package.json @@ -52,29 +52,29 @@ }, "devDependencies": { "@rc-component/father-plugin": "^2.2.0", - "@rc-component/np": "^1.0.0", - "@testing-library/jest-dom": "^6.1.5", - "@testing-library/react": "^14.1.2", - "@types/jest": "^29.2.4", - "@types/node": "^24.5.2", - "@types/react": "^18.0.26", - "@types/react-dom": "^18.0.9", + "@rc-component/np": "^1.0.4", + "@testing-library/jest-dom": "^6.9.1", + "@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", - "@umijs/test": "^4.0.34", - "dumi": "^2.0.12", - "eslint": "^8.55.0", - "eslint-plugin-jest": "^27.6.0", - "eslint-plugin-unicorn": "^50.0.1", - "father": "^4.1.1", - "husky": "9.0.5", - "jest": "^29.3.1", - "jest-environment-jsdom": "^29.3.1", - "less": "^4.2.0", - "lint-staged": "^15.1.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", + "@umijs/test": "^4.6.68", + "dumi": "^2.4.35", + "eslint": "^8.57.1", + "eslint-plugin-jest": "^27.9.0", + "eslint-plugin-unicorn": "^56.0.1", + "father": "^4.6.23", + "husky": "^9.1.7", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", + "less": "^4.6.7", + "lint-staged": "^16.4.0", + "react": "^18.3.1", + "react-dom": "^18.3.1", "ts-node": "^10.9.1", - "typescript": "^5.2.2" + "typescript": "^5.9.3" }, "peerDependencies": { "react": ">=16.9.0", diff --git a/tsconfig.json b/tsconfig.json index 206c1bb..e564d60 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,10 +9,21 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": ["src/*"], - "@@/*": [".dumi/tmp/*"], - "@rc-component/checkbox": ["src/index.tsx"] - } + "@/*": [ + "src/*" + ], + "@@/*": [ + ".dumi/tmp/*" + ], + "@rc-component/checkbox": [ + "src/index.tsx" + ] + }, + "ignoreDeprecations": "5.0" }, - "include": [".dumirc.ts", "**/*.ts", "**/*.tsx"] + "include": [ + ".dumirc.ts", + "**/*.ts", + "**/*.tsx" + ] } diff --git a/vercel.json b/vercel.json index e884e1b..5f9139e 100644 --- a/vercel.json +++ b/vercel.json @@ -2,5 +2,5 @@ "framework": "umijs", "installCommand": "npm install", "buildCommand": "npm run build", - "outputDirectory": "dist" + "outputDirectory": "docs-dist" } From e16b82efbf450d9fc95d190ff53a6b044b2062a1 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 02:01:03 +0800 Subject: [PATCH 14/34] chore: address standardization review comments --- .github/workflows/surge-preview.yml | 16 +++++++++++++--- README.zh-CN.md | 12 ++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 5e2be72..0f193f1 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -18,13 +18,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: @@ -34,5 +44,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." diff --git a/README.zh-CN.md b/README.zh-CN.md index 845adc4..589541e 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -80,14 +80,14 @@ npm start | 参数 | 说明 | 类型 | 默认值 | | -------------- | ------------------------------------------ | -------------------------------------- | ------------- | | checked | 复选框是否被选中 | boolean | - | -| className | 附加className | string | - | +| className | 附加 className | string | - | | defaultChecked | 复选框是否默认选中 | boolean | false | | disabled | 复选框是否禁用 | boolean | false | | name | 与原生 checkbox input 一致 `name` | string | - | -| prefixCls | 组件className前缀 | string | `rc-checkbox` | -| 风格 | 包装器的内联样式 | `React.CSSProperties` | - | +| prefixCls | 组件 className 前缀 | string | `rc-checkbox` | +| style | 包装器的内联样式 | `React.CSSProperties` | - | | type | 原生输入类型 | string | `checkbox` | -| 价值 | 与原生 checkbox input 一致 `value` | 字符串\|数字\|只读字符串[] | - | +| value | 与原生 checkbox input 一致 `value` | string \| number \| readonly string[] | - | | onChange | 勾选状态改变时回调 | `(event: CheckboxChangeEvent) => void` | - | 还支持其他本机输入属性。 @@ -96,8 +96,8 @@ npm start | 参数 | 说明 | 类型 | | ------------- | ------------------------------ | ---------------------------------- | -| 模糊 | 从复选框中移除焦点 | `() => void` | -| 重点 | 聚焦复选框 | `(options?: FocusOptions) => void` | +| blur | 从复选框中移除焦点 | `() => void` | +| focus | 聚焦复选框 | `(options?: FocusOptions) => void` | | input | 原生输入元素 | `HTMLInputElement \| null` | | nativeElement | 包装元素 | `HTMLElement \| null` | From 044ae19aad2a83dda7a992bea5b47fee9e54e660 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 02:10:32 +0800 Subject: [PATCH 15/34] chore: include father config in type checks --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index e564d60..3e28a3f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,6 +22,7 @@ "ignoreDeprecations": "5.0" }, "include": [ + ".fatherrc.ts", ".dumirc.ts", "**/*.ts", "**/*.tsx" From 183257a2b4ef6ff42c20f0b265630358e7d83890 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:23:36 +0800 Subject: [PATCH 16/34] 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 85ac177..60ef96d 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 0b9b79f603bf709b2bced1e2ee802c4ccfbf7d5f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:27:25 +0800 Subject: [PATCH 17/34] 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 60ef96d..85ac177 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 0292874b1bed107485d0bb1c00d71631f572cd7d Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 13:14:22 +0800 Subject: [PATCH 18/34] chore: ignore dumi build output --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index be4e312..16145ad 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,8 @@ package-lock.json .umi-production .umi-test .docs +docs-dist pnpm-lock.yaml -bun.lockb \ No newline at end of file +bun.lockb From 6f4e4798a3e782db1902383396fba6804c2442d2 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 13:26:52 +0800 Subject: [PATCH 19/34] 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 7d31401..81fe2c0 100644 --- a/README.md +++ b/README.md @@ -126,4 +126,4 @@ The release flow is handled by `@rc-component/np` through the `rc-np` command af ## License -@rc-component/checkbox is released under the [MIT](./LICENSE.md) license. +@rc-component/checkbox is released under the [MIT](./LICENSE) license. diff --git a/README.zh-CN.md b/README.zh-CN.md index 589541e..b0f387f 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -126,4 +126,4 @@ npm run prepublishOnly ## 许可证 -@rc-component/checkbox 基于 [MIT](./LICENSE.md) 许可证发布。 +@rc-component/checkbox 基于 [MIT](./LICENSE) 许可证发布。 From fc978803e702a2e070f48cf5c6d7b71cc370b805 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 13:59:30 +0800 Subject: [PATCH 20/34] 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 85ac177..e9fe2fd 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 0f193f1..16eaf48 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -15,7 +15,7 @@ jobs: env: PREVIEW: true steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + - uses: actions/checkout@v7 with: persist-credentials: false - name: Check Surge token From 6e65c71f0ad8746f000ab73b4eb147625b6c3ffb Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:29:50 +0800 Subject: [PATCH 21/34] chore: standardize package metadata --- package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 963ce38..2adb363 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,11 @@ ], "homepage": "https://react-component.github.io/checkbox", "bugs": { - "url": "http://github.com/react-component/checkbox/issues" + "url": "https://github.com/react-component/checkbox/issues" }, "repository": { "type": "git", - "url": "git@github.com:react-component/checkbox.git" + "url": "https://github.com/react-component/checkbox.git" }, "license": "MIT", "main": "lib/index.js", @@ -79,5 +79,8 @@ "peerDependencies": { "react": ">=16.9.0", "react-dom": ">=16.9.0" + }, + "publishConfig": { + "access": "public" } } From c304c42ac6c017fff3e99d5b2c7c9ae1a154b2c6 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:36:13 +0800 Subject: [PATCH 22/34] ci: standardize dependabot updates --- .github/dependabot.yml | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1372add..3b730ef 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,20 +1,19 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "21:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: react-dom - versions: - - 17.0.1 - - dependency-name: np - versions: - - 7.2.0 - - 7.3.0 - - 7.4.0 - - dependency-name: less - versions: - - 4.1.0 + - package-ecosystem: npm + directory: '/' + schedule: + 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 From 487d5c8b66777d6def972e40fbbcc25494cbdb00 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:14:18 +0800 Subject: [PATCH 23/34] 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 16eaf48..456b911 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -12,6 +12,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 4cc7b6200670eab06b45a11d80e82c85d2b5be46 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 18:19:16 +0800 Subject: [PATCH 24/34] chore: add missing prettier dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 2adb363..7eee56d 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "jest-environment-jsdom": "^29.7.0", "less": "^4.6.7", "lint-staged": "^16.4.0", + "prettier": "^3.9.0", "react": "^18.3.1", "react-dom": "^18.3.1", "ts-node": "^10.9.1", From 695fb13cda01db77407714cd7d9ce3bb06ca30c0 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:37:40 +0800 Subject: [PATCH 25/34] docs: document dumi dev server port --- README.md | 3 ++- README.zh-CN.md | 35 ++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 81fe2c0..582fc45 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@

English | 简体中文

-
[![NPM version][npm-image]][npm-url] @@ -108,6 +107,8 @@ npm install npm start ``` +The dumi site runs at `http://localhost:8000` by default. + ```bash npm test npm run tsc diff --git a/README.zh-CN.md b/README.zh-CN.md index b0f387f..99f7200 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -6,7 +6,6 @@

English | 简体中文

-
[![NPM version][npm-image]][npm-url] @@ -77,29 +76,29 @@ npm start ### Checkbox -| 参数 | 说明 | 类型 | 默认值 | -| -------------- | ------------------------------------------ | -------------------------------------- | ------------- | -| checked | 复选框是否被选中 | boolean | - | -| className | 附加 className | string | - | -| defaultChecked | 复选框是否默认选中 | boolean | false | -| disabled | 复选框是否禁用 | boolean | false | -| name | 与原生 checkbox input 一致 `name` | string | - | +| 参数 | 说明 | 类型 | 默认值 | +| -------------- | ---------------------------------- | -------------------------------------- | ------------- | +| checked | 复选框是否被选中 | boolean | - | +| className | 附加 className | string | - | +| defaultChecked | 复选框是否默认选中 | boolean | false | +| disabled | 复选框是否禁用 | boolean | false | +| name | 与原生 checkbox input 一致 `name` | string | - | | prefixCls | 组件 className 前缀 | string | `rc-checkbox` | -| style | 包装器的内联样式 | `React.CSSProperties` | - | -| type | 原生输入类型 | string | `checkbox` | -| value | 与原生 checkbox input 一致 `value` | string \| number \| readonly string[] | - | -| onChange | 勾选状态改变时回调 | `(event: CheckboxChangeEvent) => void` | - | +| style | 包装器的内联样式 | `React.CSSProperties` | - | +| type | 原生输入类型 | string | `checkbox` | +| value | 与原生 checkbox input 一致 `value` | string \| number \| readonly string[] | - | +| onChange | 勾选状态改变时回调 | `(event: CheckboxChangeEvent) => void` | - | 还支持其他本机输入属性。 ### Ref -| 参数 | 说明 | 类型 | -| ------------- | ------------------------------ | ---------------------------------- | +| 参数 | 说明 | 类型 | +| ------------- | ------------------ | ---------------------------------- | | blur | 从复选框中移除焦点 | `() => void` | -| focus | 聚焦复选框 | `(options?: FocusOptions) => void` | -| input | 原生输入元素 | `HTMLInputElement \| null` | -| nativeElement | 包装元素 | `HTMLElement \| null` | +| focus | 聚焦复选框 | `(options?: FocusOptions) => void` | +| input | 原生输入元素 | `HTMLInputElement \| null` | +| nativeElement | 包装元素 | `HTMLElement \| null` | ## 本地开发 @@ -108,6 +107,8 @@ npm install npm start ``` +dumi 站点默认运行在 `http://localhost:8000`。 + ```bash npm test npm run tsc From efca12e624006e2b84e32c8e79047a5faf77f1ee Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:56:42 +0800 Subject: [PATCH 26/34] chore: standardize husky configuration --- .husky/pre-commit | 5 +---- package.json | 7 +------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 759436f..2312dc5 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx --no-install lint-staged --quiet +npx lint-staged diff --git a/package.json b/package.json index 7eee56d..57eb6eb 100644 --- a/package.json +++ b/package.json @@ -39,12 +39,7 @@ "tsc": "tsc --noEmit" }, "lint-staged": { - "*.{js,jsx,less,md,json}": [ - "prettier --write --ignore-unknown" - ], - "*.ts?(x)": [ - "prettier --write --ignore-unknown" - ] + "*": "prettier --write --ignore-unknown" }, "dependencies": { "@rc-component/util": "^1.11.1", From ae19686e178d9eab60b53c912153f2277dd33b1c Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 20:05:24 +0800 Subject: [PATCH 27/34] docs: align readme badge layout --- README.md | 34 +++++++++------------------------- README.zh-CN.md | 34 +++++++++------------------------- 2 files changed, 18 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 582fc45..f7c148b 100644 --- a/README.md +++ b/README.md @@ -2,34 +2,18 @@

@rc-component/checkbox

Ant Design Part of the Ant Design ecosystem.

☑️ A small, accessible checkbox primitive for React.

-
- -

English | 简体中文

- -
- -[![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 version + npm downloads + build status + Codecov + bundle size + dumi +

-[npm-image]: https://img.shields.io/npm/v/@rc-component/checkbox.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/checkbox -[github-actions-image]: https://github.com/react-component/checkbox/actions/workflows/main.yml/badge.svg -[github-actions-url]: https://github.com/react-component/checkbox/actions/workflows/main.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/checkbox/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/checkbox -[download-image]: https://img.shields.io/npm/dm/@rc-component/checkbox.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/checkbox -[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/%40rc-component%2Fcheckbox?style=flat-square -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/checkbox -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square -[dumi-url]: https://github.com/umijs/dumi - +

English | 简体中文

## Highlights - Works as a controlled or uncontrolled checkbox. diff --git a/README.zh-CN.md b/README.zh-CN.md index 99f7200..6687e7e 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -2,34 +2,18 @@

@rc-component/checkbox

Ant Design Ant Design 生态的一部分。

☑️ 轻量、可访问的 React 复选框基础组件。

-
- -

English | 简体中文

- -
- -[![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 version + npm downloads + build status + Codecov + bundle size + dumi +

-[npm-image]: https://img.shields.io/npm/v/@rc-component/checkbox.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/checkbox -[github-actions-image]: https://github.com/react-component/checkbox/actions/workflows/main.yml/badge.svg -[github-actions-url]: https://github.com/react-component/checkbox/actions/workflows/main.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/checkbox/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/checkbox -[download-image]: https://img.shields.io/npm/dm/@rc-component/checkbox.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/checkbox -[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/%40rc-component%2Fcheckbox?style=flat-square -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/checkbox -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square -[dumi-url]: https://github.com/umijs/dumi - +

English | 简体中文

## 特性 - 可作为受控或非受控复选框。 From d1fcbd6c293dfdec2e082d0f0bddba1400ef0b7c Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 20:31:20 +0800 Subject: [PATCH 28/34] chore: standardize package type entry --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 57eb6eb..453532a 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "MIT", "main": "lib/index.js", "module": "es/index.js", - "typings": "es/index.d.ts", + "types": "./es/index.d.ts", "files": [ "assets/*.css", "es", From 72dbb61a2fe88a884b36505ed270432fd1289c29 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 20:59:32 +0800 Subject: [PATCH 29/34] docs: normalize readme badges --- README.md | 1 + README.zh-CN.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index f7c148b..ed95df8 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@

English | 简体中文

+ ## Highlights - Works as a controlled or uncontrolled checkbox. diff --git a/README.zh-CN.md b/README.zh-CN.md index 6687e7e..b86c75f 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -14,6 +14,7 @@

English | 简体中文

+ ## 特性 - 可作为受控或非受控复选框。 From afa42f5d47e5eb33862238875bff8af5f2587df5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:19:00 +0800 Subject: [PATCH 30/34] ci: limit reusable workflow secrets --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f8482b6..36dacae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,9 @@ name: ✅ test on: [push, pull_request] +permissions: + contents: read jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: inherit + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 771540162a7b094037bba586b7e8088f5b15da2f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:31:47 +0800 Subject: [PATCH 31/34] ci: restore reusable workflow compatibility --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 36dacae..9503b96 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,5 +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 4195fb34ec6874c8817a2b271d53c74185351880 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:52:26 +0800 Subject: [PATCH 32/34] docs: polish zh-CN 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 b86c75f..c4ff67f 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -19,7 +19,7 @@ - 可作为受控或非受控复选框。 - 引入用于焦点、模糊和 DOM 访问的命令式引用。 -- 在规范化更改事件时保留可用的本机输入属性。 +- 在规范化变更事件时保留可用的原生 input 属性。 - 提供编译后的 JavaScript、TypeScript 类型定义和独立 CSS 资源。 ## 安装 @@ -74,7 +74,7 @@ npm start | value | 与原生 checkbox input 一致 `value` | string \| number \| readonly string[] | - | | onChange | 勾选状态改变时回调 | `(event: CheckboxChangeEvent) => void` | - | -还支持其他本机输入属性。 +还支持其他原生 input 属性。 ### Ref From 56b189dde5c25b6b48b957beb87c9075c294ca6b Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 00:33:52 +0800 Subject: [PATCH 33/34] 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 456b911..cffac6c 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -7,7 +7,6 @@ permissions: contents: read pull-requests: write checks: write - statuses: write jobs: preview: From 049909e7259164c0e6a3f7f0346ae1eb7cc7135b Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 14:24:17 +0800 Subject: [PATCH 34/34] chore: limit reusable workflow secrets --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9503b96..36dacae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.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 }}