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
19 changes: 7 additions & 12 deletions docs/examples/simple.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div style={{ margin: 20 }}>
<Switch
onChange={onChange}
disabled={disabled}
checkedChildren="开"
unCheckedChildren="关"
/>
<Switch onChange={onChange} disabled={disabled} checkedChildren="开" unCheckedChildren="关" />
<div style={{ marginTop: 20 }}>
<button type="button" onClick={toggle}>
toggle disabled
</button>
</div>
</div>
)
}
);
};
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
Expand All @@ -43,12 +43,11 @@
]
},
"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": "^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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/index.spec.js
Original file line number Diff line number Diff line change
@@ -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 '..';

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"skipLibCheck": true,
"declaration": true,
"paths": {
"rc-switch": ["src/index.tsx"],
"@rc-component/switch": ["src/"],
"@@/*": [".dumi/tmp/*"]
}
}
Expand Down