From a1c8b836f0e10373d293e30dc5fc5f8d4c4b0b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=AC=A2?= Date: Fri, 12 Sep 2025 10:43:59 +0800 Subject: [PATCH 1/3] chore: migrate to @rc-component namespace and update --- README.md | 2 +- docs/demo/focus.tsx | 4 ++-- docs/demo/simple.tsx | 4 ++-- docs/index.md | 10 +++++----- package.json | 22 +++++++++++----------- src/index.tsx | 6 ++---- tests/index.test.tsx | 2 +- tsconfig.json | 2 +- 8 files changed, 25 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 4a9b961..0a64f69 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Checkbox ui component for react. ## Usage ```js -import checkbox from 'rc-checkbox'; +import checkbox from '@rc-component/checkbox'; export default () => ; ``` diff --git a/docs/demo/focus.tsx b/docs/demo/focus.tsx index cec0ee3..41ea12a 100644 --- a/docs/demo/focus.tsx +++ b/docs/demo/focus.tsx @@ -1,5 +1,5 @@ -import type { CheckboxRef } from 'rc-checkbox'; -import Checkbox from 'rc-checkbox'; +import type { CheckboxRef } from '@rc-component/checkbox'; +import Checkbox from '@rc-component/checkbox'; import { useLayoutEffect, useRef, useState } from 'react'; import '../../assets/index.less'; diff --git a/docs/demo/simple.tsx b/docs/demo/simple.tsx index 336ef62..eac6e2d 100644 --- a/docs/demo/simple.tsx +++ b/docs/demo/simple.tsx @@ -1,9 +1,9 @@ /* eslint no-console:0, jsx-a11y/label-has-for: 0, jsx-a11y/label-has-associated-control: 0 */ +import Checkbox from '@rc-component/checkbox'; import React from 'react'; -import Checkbox from 'rc-checkbox'; import '../../assets/index.less'; -import type { CheckboxProps } from 'rc-checkbox'; +import type { CheckboxProps } from '@rc-component/checkbox'; const onChange = (e: any) => { console.log('Checkbox checked:', e.target.checked); diff --git a/docs/index.md b/docs/index.md index 63ea97f..ac60dd5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,6 @@ --- hero: - title: rc-checkbox + title: @rc-component/checkbox description: checkbox ui component for react --- @@ -8,19 +8,19 @@ hero: ```bash # npm install -npm install rc-checkbox --save +npm install @rc-component/checkbox --save # yarn install -yarn add rc-checkbox +yarn add @rc-component/checkbox # pnpm install -pnpm i rc-checkbox +pnpm i @rc-component/checkbox ``` ## 🔨 Usage ```ts -import Checkbox from 'rc-checkbox'; +import Checkbox from '@rc-component/checkbox'; export default () => { return ; diff --git a/package.json b/package.json index 7d4ed98..99d8d53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "rc-checkbox", - "version": "3.5.0", + "name": "@rc-component/checkbox", + "version": "1.0.0", "description": "checkbox ui component for react", "keywords": [ "react", @@ -8,7 +8,7 @@ "react-checkbox", "checkbox" ], - "homepage": "http://github.com/react-component/checkbox", + "homepage": "https://react-component.github.io/checkbox", "bugs": { "url": "http://github.com/react-component/checkbox/issues" }, @@ -32,9 +32,10 @@ "gh-pages": "npm run build && father doc deploy -d .docs", "lint": "eslint src/ --ext .tsx,.ts", "prepare": "husky install && dumi setup", - "prepublishOnly": "npm run compile && np --yolo --no-publish", + "prepublishOnly": "npm run compile && rc-np", "start": "dumi dev", - "test": "jest" + "test": "jest", + "tsc": "bunx tsc --noEmit" }, "lint-staged": { "*.{js,jsx,less,md,json}": [ @@ -45,14 +46,14 @@ ] }, "dependencies": { - "@babel/runtime": "^7.10.1", - "classnames": "^2.3.2", - "rc-util": "^5.25.2" + "@rc-component/util": "^1.3.0", + "classnames": "^2.3.2" }, "devDependencies": { - "@rc-component/father-plugin": "^1.0.1", - "@testing-library/react": "^14.1.2 ", + "@rc-component/father-plugin": "^2.1.3", + "@rc-component/np": "^1.0.0", "@testing-library/jest-dom": "^6.1.5", + "@testing-library/react": "^14.1.2 ", "@testing-library/user-event": "^14.4.3", "@types/classnames": "^2.3.1", "@types/jest": "^29.2.4", @@ -71,7 +72,6 @@ "jest-environment-jsdom": "^29.3.1", "less": "^4.2.0", "lint-staged": "^15.1.0", - "np": "^9.0.0", "react": "^18.2.0", "react-dom": "^18.2.0", "ts-node": "^10.9.1", diff --git a/src/index.tsx b/src/index.tsx index aac4eee..0c2afb7 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,5 +1,5 @@ +import useControlledState from '@rc-component/util/lib/hooks/useControlledState'; import classNames from 'classnames'; -import useMergedState from 'rc-util/lib/hooks/useMergedState'; import * as React from 'react'; import { forwardRef, useImperativeHandle, useRef } from 'react'; @@ -44,9 +44,7 @@ export const Checkbox = forwardRef((props, ref) => { const inputRef = useRef(null); const holderRef = useRef(null); - const [rawValue, setRawValue] = useMergedState(defaultChecked, { - value: checked, - }); + const [rawValue, setRawValue] = useControlledState(defaultChecked, checked); useImperativeHandle(ref, () => ({ focus: (options) => { diff --git a/tests/index.test.tsx b/tests/index.test.tsx index fbb3390..c672a93 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -1,5 +1,5 @@ +import KeyCode from '@rc-component/util/lib/KeyCode'; import { fireEvent, render } from '@testing-library/react'; -import KeyCode from 'rc-util/lib/KeyCode'; import * as React from 'react'; import Checkbox from '../src'; diff --git a/tsconfig.json b/tsconfig.json index 08cc8d8..206c1bb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "paths": { "@/*": ["src/*"], "@@/*": [".dumi/tmp/*"], - "rc-checkbox": ["src/index.tsx"] + "@rc-component/checkbox": ["src/index.tsx"] } }, "include": [".dumirc.ts", "**/*.ts", "**/*.tsx"] From d4b709e79ce56a381a2a7ca78bac69b11ff62daf Mon Sep 17 00:00:00 2001 From: EmilyyyLiu <100924403+EmilyyyLiu@users.noreply.github.com> Date: Fri, 12 Sep 2025 10:51:33 +0800 Subject: [PATCH 2/3] Update package.json Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 99d8d53..5c7fefb 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@rc-component/father-plugin": "^2.1.3", "@rc-component/np": "^1.0.0", "@testing-library/jest-dom": "^6.1.5", - "@testing-library/react": "^14.1.2 ", + "@testing-library/react": "^14.1.2", "@testing-library/user-event": "^14.4.3", "@types/classnames": "^2.3.1", "@types/jest": "^29.2.4", From 319ebda1ce70cd7c5c43d5e44fcb673284b8844f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=AC=A2?= Date: Tue, 16 Sep 2025 15:32:52 +0800 Subject: [PATCH 3/3] chore: modify deploy path --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5c7fefb..eeb4782 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "build": "dumi build", "compile": "father build && lessc assets/index.less assets/index.css", "coverage": "jest --coverage", - "gh-pages": "npm run build && father doc deploy -d .docs", + "gh-pages": "npm run build && father doc deploy -d dist", "lint": "eslint src/ --ext .tsx,.ts", "prepare": "husky install && dumi setup", "prepublishOnly": "npm run compile && rc-np",