Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Checkbox ui component for react.
## Usage

```js
import checkbox from 'rc-checkbox';
import checkbox from '@rc-component/checkbox';

export default () => <checkbox />;
```
Comment on lines 39 to 43
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

README 用法示例中的组件名大小写错误,当前会被当作原生标签渲染

应使用大写组件名并与默认导出同名,避免 <checkbox /> 被识别为自定义元素而非 React 组件。

建议改成:

-import checkbox from '@rc-component/checkbox';
+import Checkbox from '@rc-component/checkbox';

-export default () => <checkbox />;
+export default () => <Checkbox />;
🤖 Prompt for AI Agents
In README.md around lines 39 to 43 the example imports and uses a lowercase
component name causing React to treat it as a native DOM tag; change the import
to a PascalCase name that matches the default export and use that PascalCase in
JSX (e.g., import Checkbox from '...'; export default () => <Checkbox />) so the
element is recognized as a React component.

Expand Down
4 changes: 2 additions & 2 deletions docs/demo/focus.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
4 changes: 2 additions & 2 deletions docs/demo/simple.tsx
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
10 changes: 5 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
---
hero:
title: rc-checkbox
title: @rc-component/checkbox
description: checkbox ui component for react
---

## 📦 Install

```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 <Checkbox />;
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "rc-checkbox",
"version": "3.5.0",
"name": "@rc-component/checkbox",
"version": "1.0.0",
"description": "checkbox ui component for react",
Comment on lines +2 to 4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

首次发布 scoped 包建议显式声明为 public

NPM 对作用域包默认私有。为避免首发失败或误发私有,建议添加 publishConfig.access: public

可在根级添加:

"publishConfig": {
  "access": "public"
}

需要我顺手补上并校验发布流程脚本吗?

🤖 Prompt for AI Agents
In package.json around lines 2 to 4, this scoped package lacks an explicit
publishConfig and NPM defaults scoped packages to private; add a root-level
"publishConfig": { "access": "public" } entry to ensure the first publish is
public, and verify any publish scripts or CI use the package.json root so the
new field is picked up.

"keywords": [
"react",
"react-component",
"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"
},
Expand All @@ -29,12 +29,13 @@
"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 && 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}": [
Expand All @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 2 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -44,9 +44,7 @@ export const Checkbox = forwardRef<CheckboxRef, CheckboxProps>((props, ref) => {
const inputRef = useRef<HTMLInputElement>(null);
const holderRef = useRef<HTMLElement>(null);

const [rawValue, setRawValue] = useMergedState(defaultChecked, {
value: checked,
});
const [rawValue, setRawValue] = useControlledState(defaultChecked, checked);

useImperativeHandle(ref, () => ({
focus: (options) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/index.test.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"paths": {
"@/*": ["src/*"],
"@@/*": [".dumi/tmp/*"],
"rc-checkbox": ["src/index.tsx"]
"@rc-component/checkbox": ["src/index.tsx"]
}
},
"include": [".dumirc.ts", "**/*.ts", "**/*.tsx"]
Expand Down