From 4460652be0d034eabc7f38cb735198f582a8df14 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Mon, 17 Feb 2025 10:52:44 +0800 Subject: [PATCH 1/3] chore: migrate to @rc-component namespace --- package.json | 8 ++++---- tsconfig.json | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 12db8d0..0b9d3de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "rc-switch", - "version": "4.1.0", + "name": "@rc-component/switch", + "version": "1.0.0", "description": "switch ui component for react", "keywords": [ "react", @@ -32,7 +32,7 @@ "lint": "eslint .", "lint-staged": "lint-staged", "prepare": "husky install && dumi setup", - "prepublishOnly": "npm run compile && np --yolo --no-publish", + "prepublishOnly": "npm run compile && rc-np", "postpublish": "npm run gh-pages", "start": "dumi dev", "test": "umi-test" @@ -48,7 +48,7 @@ "rc-util": "^5.30.0" }, "devDependencies": { - "@rc-component/father-plugin": "^1.0.0", + "@rc-component/father-plugin": "^2.0.0", "@types/classnames": "^2.2.10", "@types/jest": "^29.4.0", "@umijs/fabric": "^3.0.0", diff --git a/tsconfig.json b/tsconfig.json index eea6766..fd0af5a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,10 @@ "declaration": true, "paths": { "rc-switch": ["src/index.tsx"], - "@@/*": [".dumi/tmp/*"] + "@@/*": [".dumi/tmp/*"], + "@rc-component/switch": [ + "src/" + ] } } } From f0ff02e17bf3255779ec8e40362c17d13b51fdef Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Mon, 17 Feb 2025 11:17:13 +0800 Subject: [PATCH 2/3] fix --- docs/examples/simple.tsx | 19 +++++++------------ package.json | 5 ++--- tsconfig.json | 7 ++----- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/docs/examples/simple.tsx b/docs/examples/simple.tsx index b0088be..3677dab 100644 --- a/docs/examples/simple.tsx +++ b/docs/examples/simple.tsx @@ -1,33 +1,28 @@ import '../../assets/index.less'; import React, { useState } from 'react'; -import type { SwitchChangeEventHandler } from 'rc-switch'; -import Switch from 'rc-switch'; +import type { SwitchChangeEventHandler } from '@rc-component/switch'; +import Switch from '@rc-component/switch'; const onChange: SwitchChangeEventHandler = (value, event) => { // eslint-disable-next-line no-console console.log(`switch checked: ${value}`, event); -} +}; export default () => { const [disabled, setDisabled] = useState(false); const toggle = () => { setDisabled((prev) => !prev); - } + }; return (
- +
- ) -} + ); +}; diff --git a/package.json b/package.json index 0b9d3de..6349924 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,8 @@ ] }, "dependencies": { - "@babel/runtime": "^7.21.0", "classnames": "^2.2.1", - "rc-util": "^5.30.0" + "@rc-component/util": "^1.2.0" }, "devDependencies": { "@rc-component/father-plugin": "^2.0.0", @@ -65,7 +64,7 @@ "husky": "^8.0.1", "less": "^4.1.3", "lint-staged": "^15.1.0", - "np": "^9.0.0", + "@rc-component/np": "^1.0.3", "prettier": "^3.1.0", "react": "^16.0.0", "react-dom": "^16.0.0", diff --git a/tsconfig.json b/tsconfig.json index fd0af5a..f110b99 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,11 +13,8 @@ "skipLibCheck": true, "declaration": true, "paths": { - "rc-switch": ["src/index.tsx"], - "@@/*": [".dumi/tmp/*"], - "@rc-component/switch": [ - "src/" - ] + "@rc-component/switch": ["src/"], + "@@/*": [".dumi/tmp/*"] } } } From b8ec113c421d281e866f6ae05c38a178bada7254 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Mon, 17 Feb 2025 11:42:03 +0800 Subject: [PATCH 3/3] fix --- src/index.tsx | 4 ++-- tests/index.spec.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 887c25d..b4ce9b6 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import classNames from 'classnames'; -import useMergedState from 'rc-util/lib/hooks/useMergedState'; -import KeyCode from 'rc-util/lib/KeyCode'; +import useMergedState from '@rc-component/util/lib/hooks/useMergedState'; +import KeyCode from '@rc-component/util/lib/KeyCode'; export type SwitchChangeEventHandler = ( checked: boolean, diff --git a/tests/index.spec.js b/tests/index.spec.js index eef4e03..4863932 100644 --- a/tests/index.spec.js +++ b/tests/index.spec.js @@ -1,5 +1,5 @@ import React from 'react'; -import KeyCode from 'rc-util/lib/KeyCode'; +import KeyCode from '@rc-component/util/lib/KeyCode'; import { mount } from 'enzyme'; import Switch from '..';