Comparing version 4.0.0 to 4.1.0
@@ -1,5 +0,5 @@ | ||
import _extends from "@babel/runtime/helpers/extends"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; | ||
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; | ||
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; | ||
var _excluded = ["prefixCls", "className", "checked", "defaultChecked", "disabled", "loadingIcon", "checkedChildren", "unCheckedChildren", "onClick", "onChange", "onKeyDown"]; | ||
@@ -12,28 +12,24 @@ import * as React from 'react'; | ||
var _classNames; | ||
var _ref$prefixCls = _ref.prefixCls, | ||
prefixCls = _ref$prefixCls === void 0 ? 'rc-switch' : _ref$prefixCls, | ||
className = _ref.className, | ||
checked = _ref.checked, | ||
defaultChecked = _ref.defaultChecked, | ||
disabled = _ref.disabled, | ||
loadingIcon = _ref.loadingIcon, | ||
checkedChildren = _ref.checkedChildren, | ||
unCheckedChildren = _ref.unCheckedChildren, | ||
onClick = _ref.onClick, | ||
onChange = _ref.onChange, | ||
onKeyDown = _ref.onKeyDown, | ||
restProps = _objectWithoutProperties(_ref, _excluded); | ||
prefixCls = _ref$prefixCls === void 0 ? 'rc-switch' : _ref$prefixCls, | ||
className = _ref.className, | ||
checked = _ref.checked, | ||
defaultChecked = _ref.defaultChecked, | ||
disabled = _ref.disabled, | ||
loadingIcon = _ref.loadingIcon, | ||
checkedChildren = _ref.checkedChildren, | ||
unCheckedChildren = _ref.unCheckedChildren, | ||
onClick = _ref.onClick, | ||
onChange = _ref.onChange, | ||
onKeyDown = _ref.onKeyDown, | ||
restProps = _objectWithoutProperties(_ref, _excluded); | ||
var _useMergedState = useMergedState(false, { | ||
value: checked, | ||
defaultValue: defaultChecked | ||
}), | ||
_useMergedState2 = _slicedToArray(_useMergedState, 2), | ||
innerChecked = _useMergedState2[0], | ||
setInnerChecked = _useMergedState2[1]; | ||
value: checked, | ||
defaultValue: defaultChecked | ||
}), | ||
_useMergedState2 = _slicedToArray(_useMergedState, 2), | ||
innerChecked = _useMergedState2[0], | ||
setInnerChecked = _useMergedState2[1]; | ||
function triggerChange(newChecked, event) { | ||
var mergedChecked = innerChecked; | ||
if (!disabled) { | ||
@@ -44,6 +40,4 @@ mergedChecked = newChecked; | ||
} | ||
return mergedChecked; | ||
} | ||
function onInternalKeyDown(e) { | ||
@@ -55,12 +49,9 @@ if (e.which === KeyCode.LEFT) { | ||
} | ||
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e); | ||
} | ||
function onInternalClick(e) { | ||
var ret = triggerChange(!innerChecked, e); // [Legacy] trigger onClick with value | ||
var ret = triggerChange(!innerChecked, e); | ||
// [Legacy] trigger onClick with value | ||
onClick === null || onClick === void 0 ? void 0 : onClick(ret, e); | ||
} | ||
var switchClassName = classNames(prefixCls, className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-checked"), innerChecked), _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), disabled), _classNames)); | ||
@@ -67,0 +58,0 @@ return /*#__PURE__*/React.createElement("button", _extends({}, restProps, { |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -11,53 +9,35 @@ value: true | ||
exports.default = void 0; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var React = _interopRequireWildcard(require("react")); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _useMergedState3 = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState")); | ||
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode")); | ||
var _excluded = ["prefixCls", "className", "checked", "defaultChecked", "disabled", "loadingIcon", "checkedChildren", "unCheckedChildren", "onClick", "onChange", "onKeyDown"]; | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var Switch = /*#__PURE__*/React.forwardRef(function (_ref, ref) { | ||
var _classNames; | ||
var _ref$prefixCls = _ref.prefixCls, | ||
prefixCls = _ref$prefixCls === void 0 ? 'rc-switch' : _ref$prefixCls, | ||
className = _ref.className, | ||
checked = _ref.checked, | ||
defaultChecked = _ref.defaultChecked, | ||
disabled = _ref.disabled, | ||
loadingIcon = _ref.loadingIcon, | ||
checkedChildren = _ref.checkedChildren, | ||
unCheckedChildren = _ref.unCheckedChildren, | ||
onClick = _ref.onClick, | ||
onChange = _ref.onChange, | ||
onKeyDown = _ref.onKeyDown, | ||
restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded); | ||
prefixCls = _ref$prefixCls === void 0 ? 'rc-switch' : _ref$prefixCls, | ||
className = _ref.className, | ||
checked = _ref.checked, | ||
defaultChecked = _ref.defaultChecked, | ||
disabled = _ref.disabled, | ||
loadingIcon = _ref.loadingIcon, | ||
checkedChildren = _ref.checkedChildren, | ||
unCheckedChildren = _ref.unCheckedChildren, | ||
onClick = _ref.onClick, | ||
onChange = _ref.onChange, | ||
onKeyDown = _ref.onKeyDown, | ||
restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded); | ||
var _useMergedState = (0, _useMergedState3.default)(false, { | ||
value: checked, | ||
defaultValue: defaultChecked | ||
}), | ||
_useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2), | ||
innerChecked = _useMergedState2[0], | ||
setInnerChecked = _useMergedState2[1]; | ||
value: checked, | ||
defaultValue: defaultChecked | ||
}), | ||
_useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2), | ||
innerChecked = _useMergedState2[0], | ||
setInnerChecked = _useMergedState2[1]; | ||
function triggerChange(newChecked, event) { | ||
var mergedChecked = innerChecked; | ||
if (!disabled) { | ||
@@ -68,6 +48,4 @@ mergedChecked = newChecked; | ||
} | ||
return mergedChecked; | ||
} | ||
function onInternalKeyDown(e) { | ||
@@ -79,12 +57,9 @@ if (e.which === _KeyCode.default.LEFT) { | ||
} | ||
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e); | ||
} | ||
function onInternalClick(e) { | ||
var ret = triggerChange(!innerChecked, e); // [Legacy] trigger onClick with value | ||
var ret = triggerChange(!innerChecked, e); | ||
// [Legacy] trigger onClick with value | ||
onClick === null || onClick === void 0 ? void 0 : onClick(ret, e); | ||
} | ||
var switchClassName = (0, _classnames.default)(prefixCls, className, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-checked"), innerChecked), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-disabled"), disabled), _classNames)); | ||
@@ -91,0 +66,0 @@ return /*#__PURE__*/React.createElement("button", (0, _extends2.default)({}, restProps, { |
{ | ||
"name": "rc-switch", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "switch ui component for react", | ||
@@ -11,2 +11,11 @@ "keywords": [ | ||
], | ||
"homepage": "http://github.com/react-component/switch", | ||
"bugs": { | ||
"url": "http://github.com/react-component/switch/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:react-component/switch.git" | ||
}, | ||
"license": "MIT", | ||
"main": "lib/index", | ||
@@ -19,36 +28,30 @@ "module": "./es/index", | ||
], | ||
"homepage": "http://github.com/react-component/switch", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:react-component/switch.git" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/react-component/switch/issues" | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"start": "dumi dev", | ||
"compile": "father build && lessc assets/index.less assets/index.css", | ||
"docs:build": "dumi build", | ||
"docs:deploy": "gh-pages -d .doc", | ||
"compile": "father build && lessc assets/index.less assets/index.css", | ||
"gh-pages": "npm run docs:build && npm run docs:deploy", | ||
"lint": "eslint .", | ||
"lint-staged": "lint-staged", | ||
"prepare": "husky install", | ||
"prepublishOnly": "npm run compile && np --yolo --no-publish", | ||
"postpublish": "npm run gh-pages", | ||
"lint": "eslint .", | ||
"lint-staged": "lint-staged", | ||
"test": "umi-test", | ||
"coverage": "father test --coverage", | ||
"prepare": "husky install" | ||
"start": "dumi dev", | ||
"test": "umi-test" | ||
}, | ||
"lint-staged": { | ||
"**/*.{js,jsx,tsx,ts,md,json}": [ | ||
"prettier --write", | ||
"git add" | ||
"prettier --write" | ||
] | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.21.0", | ||
"classnames": "^2.2.1", | ||
"rc-util": "^5.30.0" | ||
}, | ||
"devDependencies": { | ||
"@rc-component/father-plugin": "^1.0.0", | ||
"@types/classnames": "^2.2.10", | ||
"@types/jest": "^26.0.4", | ||
"@umijs/fabric": "^3.0.0", | ||
"coveralls": "^3.0.6", | ||
"dumi": "^1.1.0", | ||
@@ -63,4 +66,5 @@ "enzyme": "^3.0.0", | ||
"less": "^3.11.1", | ||
"lint-staged": "^13.0.3", | ||
"lint-staged": "^13.2.1", | ||
"np": "^7.1.0", | ||
"prettier": "^2.8.8", | ||
"react": "^16.0.0", | ||
@@ -74,8 +78,3 @@ "react-dom": "^16.0.0", | ||
"react-dom": ">=16.9.0" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.10.1", | ||
"classnames": "^2.2.1", | ||
"rc-util": "^5.0.1" | ||
} | ||
} |
@@ -8,7 +8,5 @@ # rc-switch | ||
[![NPM version][npm-image]][npm-url] | ||
[![build status][travis-image]][travis-url] | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![Dependencies][david-image]][david-url] | ||
[![DevDependencies][david-dev-image]][david-dev-url] | ||
[![npm download][download-image]][download-url] | ||
[![build status][github-actions-image]][github-actions-url] | ||
[![Test coverage][codecov-image]][codecov-url] | ||
[![bundle size][bundlephobia-image]][bundlephobia-url] | ||
@@ -19,7 +17,7 @@ | ||
[travis-image]: https://img.shields.io/travis/react-component/switch/master?style=flat-square | ||
[travis-url]: https://travis-ci.org/react-component/switch | ||
[circleci-image]: https://img.shields.io/circleci/react-component/switch/master?style=flat-square | ||
[circleci-url]: https://circleci.com/gh/react-component/switch | ||
[coveralls-image]: https://img.shields.io/coveralls/react-component/switch.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/r/react-component/switch?branch=master | ||
[travis-url]: https://travis-ci.com/react-component/switch | ||
[github-actions-image]: https://github.com/react-component/switch/workflows/CI/badge.svg | ||
[github-actions-url]: https://github.com/react-component/switch/actions | ||
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/switch/master.svg?style=flat-square | ||
[codecov-url]: https://app.codecov.io/gh/react-component/switch | ||
[david-url]: https://david-dm.org/react-component/switch | ||
@@ -31,3 +29,3 @@ [david-image]: https://david-dm.org/react-component/switch/status.svg?style=flat-square | ||
[download-url]: https://npmjs.org/package/rc-switch | ||
[bundlephobia-url]: https://bundlephobia.com/result?p=rc-switch | ||
[bundlephobia-url]: https://bundlephobia.com/package/rc-switch | ||
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-switch | ||
@@ -50,4 +48,4 @@ | ||
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Electron | | ||
| --- | --- | --- | --- | --- | | ||
| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | | ||
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | | ||
@@ -76,3 +74,3 @@ ## API | ||
Online demo: http://react-component.github.io/switch/examples/ | ||
Online demo: http://react-component.github.io/switch/ | ||
@@ -79,0 +77,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20546
20
306
75
Updated@babel/runtime@^7.21.0
Updatedrc-util@^5.30.0