From 0a06399f5f547287c910c8a5f8d20b7d79e214c4 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 12:38:05 +0800 Subject: [PATCH 01/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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"