rc-checkbox
Advanced tools
Comparing version 2.2.0 to 2.3.0
154
es/index.js
@@ -1,17 +0,33 @@ | ||
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; | ||
import _inherits from 'babel-runtime/helpers/inherits'; | ||
/* eslint-disable react/prop-types */ | ||
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import _inherits from "@babel/runtime/helpers/esm/inherits"; | ||
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn"; | ||
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import React, { Component } from 'react'; | ||
import classNames from 'classnames'; | ||
var Checkbox = function (_Component) { | ||
var Checkbox = /*#__PURE__*/function (_Component) { | ||
_inherits(Checkbox, _Component); | ||
var _super = _createSuper(Checkbox); | ||
function Checkbox(props) { | ||
var _this; | ||
_classCallCheck(this, Checkbox); | ||
var _this = _possibleConstructorReturn(this, _Component.call(this, props)); | ||
_this = _super.call(this, props); | ||
@@ -26,2 +42,3 @@ _this.handleChange = function (e) { | ||
} | ||
if (!('checked' in _this.props)) { | ||
@@ -32,5 +49,6 @@ _this.setState({ | ||
} | ||
if (onChange) { | ||
onChange({ | ||
target: _extends({}, _this.props, { | ||
target: _objectSpread(_objectSpread({}, _this.props), {}, { | ||
checked: e.target.checked | ||
@@ -44,3 +62,2 @@ }), | ||
}, | ||
nativeEvent: e.nativeEvent | ||
@@ -56,3 +73,2 @@ }); | ||
var checked = 'checked' in props ? props.checked : props.defaultChecked; | ||
_this.state = { | ||
@@ -64,55 +80,49 @@ checked: checked | ||
Checkbox.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) { | ||
if ('checked' in props) { | ||
return _extends({}, state, { | ||
checked: props.checked | ||
}); | ||
_createClass(Checkbox, [{ | ||
key: "focus", | ||
value: function focus() { | ||
this.input.focus(); | ||
} | ||
return null; | ||
}; | ||
}, { | ||
key: "blur", | ||
value: function blur() { | ||
this.input.blur(); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _classNames; | ||
Checkbox.prototype.focus = function focus() { | ||
this.input.focus(); | ||
}; | ||
var _this$props2 = this.props, | ||
prefixCls = _this$props2.prefixCls, | ||
className = _this$props2.className, | ||
style = _this$props2.style, | ||
name = _this$props2.name, | ||
id = _this$props2.id, | ||
type = _this$props2.type, | ||
disabled = _this$props2.disabled, | ||
readOnly = _this$props2.readOnly, | ||
tabIndex = _this$props2.tabIndex, | ||
onClick = _this$props2.onClick, | ||
onFocus = _this$props2.onFocus, | ||
onBlur = _this$props2.onBlur, | ||
autoFocus = _this$props2.autoFocus, | ||
value = _this$props2.value, | ||
required = _this$props2.required, | ||
others = _objectWithoutProperties(_this$props2, ["prefixCls", "className", "style", "name", "id", "type", "disabled", "readOnly", "tabIndex", "onClick", "onFocus", "onBlur", "autoFocus", "value", "required"]); | ||
Checkbox.prototype.blur = function blur() { | ||
this.input.blur(); | ||
}; | ||
var globalProps = Object.keys(others).reduce(function (prev, key) { | ||
if (key.substr(0, 5) === 'aria-' || key.substr(0, 5) === 'data-' || key === 'role') { | ||
// eslint-disable-next-line no-param-reassign | ||
prev[key] = others[key]; | ||
} | ||
Checkbox.prototype.render = function render() { | ||
var _classNames; | ||
var _props = this.props, | ||
prefixCls = _props.prefixCls, | ||
className = _props.className, | ||
style = _props.style, | ||
name = _props.name, | ||
id = _props.id, | ||
type = _props.type, | ||
disabled = _props.disabled, | ||
readOnly = _props.readOnly, | ||
tabIndex = _props.tabIndex, | ||
onClick = _props.onClick, | ||
onFocus = _props.onFocus, | ||
onBlur = _props.onBlur, | ||
autoFocus = _props.autoFocus, | ||
value = _props.value, | ||
required = _props.required, | ||
others = _objectWithoutProperties(_props, ['prefixCls', 'className', 'style', 'name', 'id', 'type', 'disabled', 'readOnly', 'tabIndex', 'onClick', 'onFocus', 'onBlur', 'autoFocus', 'value', 'required']); | ||
var globalProps = Object.keys(others).reduce(function (prev, key) { | ||
if (key.substr(0, 5) === 'aria-' || key.substr(0, 5) === 'data-' || key === 'role') { | ||
prev[key] = others[key]; | ||
} | ||
return prev; | ||
}, {}); | ||
var checked = this.state.checked; | ||
var classString = classNames(prefixCls, className, (_classNames = {}, _classNames[prefixCls + '-checked'] = checked, _classNames[prefixCls + '-disabled'] = disabled, _classNames)); | ||
return React.createElement( | ||
'span', | ||
{ className: classString, style: style }, | ||
React.createElement('input', _extends({ | ||
return prev; | ||
}, {}); | ||
var checked = this.state.checked; | ||
var classString = classNames(prefixCls, className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-checked"), checked), _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), disabled), _classNames)); | ||
return /*#__PURE__*/React.createElement("span", { | ||
className: classString, | ||
style: style | ||
}, /*#__PURE__*/React.createElement("input", _extends({ | ||
name: name, | ||
@@ -125,3 +135,3 @@ id: id, | ||
tabIndex: tabIndex, | ||
className: prefixCls + '-input', | ||
className: "".concat(prefixCls, "-input"), | ||
checked: !!checked, | ||
@@ -135,7 +145,19 @@ onClick: onClick, | ||
value: value | ||
}, globalProps)), | ||
React.createElement('span', { className: prefixCls + '-inner' }) | ||
); | ||
}; | ||
}, globalProps)), /*#__PURE__*/React.createElement("span", { | ||
className: "".concat(prefixCls, "-inner") | ||
})); | ||
} | ||
}], [{ | ||
key: "getDerivedStateFromProps", | ||
value: function getDerivedStateFromProps(props, state) { | ||
if ('checked' in props) { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
checked: props.checked | ||
}); | ||
} | ||
return null; | ||
} | ||
}]); | ||
return Checkbox; | ||
@@ -154,4 +176,2 @@ }(Component); | ||
}; | ||
export default Checkbox; |
176
lib/index.js
@@ -1,43 +0,50 @@ | ||
'use strict'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties'); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _react = require('react'); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _classnames = require('classnames'); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
var _classnames2 = _interopRequireDefault(_classnames); | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; } | ||
/* eslint-disable react/prop-types */ | ||
var Checkbox = function (_Component) { | ||
(0, _inherits3['default'])(Checkbox, _Component); | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
var Checkbox = /*#__PURE__*/function (_Component) { | ||
(0, _inherits2.default)(Checkbox, _Component); | ||
var _super = _createSuper(Checkbox); | ||
function Checkbox(props) { | ||
(0, _classCallCheck3['default'])(this, Checkbox); | ||
var _this; | ||
var _this = (0, _possibleConstructorReturn3['default'])(this, _Component.call(this, props)); | ||
(0, _classCallCheck2.default)(this, Checkbox); | ||
_this = _super.call(this, props); | ||
@@ -52,2 +59,3 @@ _this.handleChange = function (e) { | ||
} | ||
if (!('checked' in _this.props)) { | ||
@@ -58,5 +66,6 @@ _this.setState({ | ||
} | ||
if (onChange) { | ||
onChange({ | ||
target: (0, _extends3['default'])({}, _this.props, { | ||
target: _objectSpread(_objectSpread({}, _this.props), {}, { | ||
checked: e.target.checked | ||
@@ -70,3 +79,2 @@ }), | ||
}, | ||
nativeEvent: e.nativeEvent | ||
@@ -82,3 +90,2 @@ }); | ||
var checked = 'checked' in props ? props.checked : props.defaultChecked; | ||
_this.state = { | ||
@@ -90,56 +97,48 @@ checked: checked | ||
Checkbox.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) { | ||
if ('checked' in props) { | ||
return (0, _extends3['default'])({}, state, { | ||
checked: props.checked | ||
}); | ||
(0, _createClass2.default)(Checkbox, [{ | ||
key: "focus", | ||
value: function focus() { | ||
this.input.focus(); | ||
} | ||
return null; | ||
}; | ||
}, { | ||
key: "blur", | ||
value: function blur() { | ||
this.input.blur(); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _classNames; | ||
Checkbox.prototype.focus = function focus() { | ||
this.input.focus(); | ||
}; | ||
var _this$props2 = this.props, | ||
prefixCls = _this$props2.prefixCls, | ||
className = _this$props2.className, | ||
style = _this$props2.style, | ||
name = _this$props2.name, | ||
id = _this$props2.id, | ||
type = _this$props2.type, | ||
disabled = _this$props2.disabled, | ||
readOnly = _this$props2.readOnly, | ||
tabIndex = _this$props2.tabIndex, | ||
onClick = _this$props2.onClick, | ||
onFocus = _this$props2.onFocus, | ||
onBlur = _this$props2.onBlur, | ||
autoFocus = _this$props2.autoFocus, | ||
value = _this$props2.value, | ||
required = _this$props2.required, | ||
others = (0, _objectWithoutProperties2.default)(_this$props2, ["prefixCls", "className", "style", "name", "id", "type", "disabled", "readOnly", "tabIndex", "onClick", "onFocus", "onBlur", "autoFocus", "value", "required"]); | ||
var globalProps = Object.keys(others).reduce(function (prev, key) { | ||
if (key.substr(0, 5) === 'aria-' || key.substr(0, 5) === 'data-' || key === 'role') { | ||
// eslint-disable-next-line no-param-reassign | ||
prev[key] = others[key]; | ||
} | ||
Checkbox.prototype.blur = function blur() { | ||
this.input.blur(); | ||
}; | ||
Checkbox.prototype.render = function render() { | ||
var _classNames; | ||
var _props = this.props, | ||
prefixCls = _props.prefixCls, | ||
className = _props.className, | ||
style = _props.style, | ||
name = _props.name, | ||
id = _props.id, | ||
type = _props.type, | ||
disabled = _props.disabled, | ||
readOnly = _props.readOnly, | ||
tabIndex = _props.tabIndex, | ||
onClick = _props.onClick, | ||
onFocus = _props.onFocus, | ||
onBlur = _props.onBlur, | ||
autoFocus = _props.autoFocus, | ||
value = _props.value, | ||
required = _props.required, | ||
others = (0, _objectWithoutProperties3['default'])(_props, ['prefixCls', 'className', 'style', 'name', 'id', 'type', 'disabled', 'readOnly', 'tabIndex', 'onClick', 'onFocus', 'onBlur', 'autoFocus', 'value', 'required']); | ||
var globalProps = Object.keys(others).reduce(function (prev, key) { | ||
if (key.substr(0, 5) === 'aria-' || key.substr(0, 5) === 'data-' || key === 'role') { | ||
prev[key] = others[key]; | ||
} | ||
return prev; | ||
}, {}); | ||
var checked = this.state.checked; | ||
var classString = (0, _classnames2['default'])(prefixCls, className, (_classNames = {}, _classNames[prefixCls + '-checked'] = checked, _classNames[prefixCls + '-disabled'] = disabled, _classNames)); | ||
return _react2['default'].createElement( | ||
'span', | ||
{ className: classString, style: style }, | ||
_react2['default'].createElement('input', (0, _extends3['default'])({ | ||
return prev; | ||
}, {}); | ||
var checked = this.state.checked; | ||
var classString = (0, _classnames.default)(prefixCls, className, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-checked"), checked), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-disabled"), disabled), _classNames)); | ||
return /*#__PURE__*/_react.default.createElement("span", { | ||
className: classString, | ||
style: style | ||
}, /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({ | ||
name: name, | ||
@@ -152,3 +151,3 @@ id: id, | ||
tabIndex: tabIndex, | ||
className: prefixCls + '-input', | ||
className: "".concat(prefixCls, "-input"), | ||
checked: !!checked, | ||
@@ -162,7 +161,18 @@ onClick: onClick, | ||
value: value | ||
}, globalProps)), | ||
_react2['default'].createElement('span', { className: prefixCls + '-inner' }) | ||
); | ||
}; | ||
}, globalProps)), /*#__PURE__*/_react.default.createElement("span", { | ||
className: "".concat(prefixCls, "-inner") | ||
})); | ||
} | ||
}], [{ | ||
key: "getDerivedStateFromProps", | ||
value: function getDerivedStateFromProps(props, state) { | ||
if ('checked' in props) { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
checked: props.checked | ||
}); | ||
} | ||
return null; | ||
} | ||
}]); | ||
return Checkbox; | ||
@@ -181,3 +191,3 @@ }(_react.Component); | ||
}; | ||
exports['default'] = Checkbox; | ||
module.exports = exports['default']; | ||
var _default = Checkbox; | ||
exports.default = _default; |
{ | ||
"name": "rc-checkbox", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "checkbox ui component for react", | ||
@@ -11,11 +11,9 @@ "keywords": [ | ||
], | ||
"main": "lib/index", | ||
"module": "es/index", | ||
"main": "./lib/index", | ||
"module": "./es/index", | ||
"files": [ | ||
"lib", | ||
"assets/*.css", | ||
"es", | ||
"assets/*.css", | ||
"index.d.ts" | ||
"lib" | ||
], | ||
"types": "index.d.ts", | ||
"homepage": "http://github.com/react-component/checkbox", | ||
@@ -29,48 +27,33 @@ "repository": { | ||
}, | ||
"licenses": "MIT", | ||
"config": { | ||
"port": 8001 | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "rc-tools run build", | ||
"gh-pages": "rc-tools run gh-pages", | ||
"start": "rc-tools run server", | ||
"compile": "rc-tools run compile --babel-runtime", | ||
"pub": "rc-tools run pub --babel-runtime", | ||
"lint": "rc-tools run lint", | ||
"test": "jest", | ||
"coverage": "jest --coverage && cat ./coverage/lcov.info | coveralls", | ||
"prepublish": "rc-tools run guard" | ||
"start": "father doc dev --storybook", | ||
"build": "father doc build --storybook", | ||
"compile": "father build && lessc assets/index.less assets/index.css", | ||
"gh-pages": "father doc deploy", | ||
"prepublishOnly": "npm run compile && np --yolo --no-publish", | ||
"lint": "eslint . --ext='jsx'", | ||
"test": "father test", | ||
"coverage": "father test --coverage" | ||
}, | ||
"jest": { | ||
"setupFiles": [ | ||
"./tests/setup.js" | ||
], | ||
"collectCoverageFrom": [ | ||
"src/*" | ||
], | ||
"transform": { | ||
"\\.tsx?$": "./node_modules/rc-tools/scripts/jestPreprocessor.js", | ||
"\\.jsx?$": "./node_modules/rc-tools/scripts/jestPreprocessor.js" | ||
} | ||
}, | ||
"dependencies": { | ||
"babel-runtime": "^6.23.0", | ||
"classnames": "2.x" | ||
"@babel/runtime": "^7.10.1", | ||
"classnames": "^2.2.1" | ||
}, | ||
"devDependencies": { | ||
"core-js": "^2.5.1", | ||
"coveralls": "^3.0.0", | ||
"enzyme": "^3.1.0", | ||
"@types/classnames": "^2.2.10", | ||
"@types/jest": "^25.2.2", | ||
"@umijs/fabric": "^2.2.2", | ||
"coveralls": "^3.0.6", | ||
"enzyme": "^3.0.0", | ||
"enzyme-adapter-react-16": "^1.0.1", | ||
"jest": "^21.2.1", | ||
"pre-commit": "1.x", | ||
"rc-tools": "^7.0.3", | ||
"enzyme-to-json": "^3.0.0", | ||
"eslint": "^7.0.0", | ||
"father": "^2.13.4", | ||
"less": "^3.11.1", | ||
"np": "^6.2.3", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0", | ||
"react-test-renderer": "^16.0.0" | ||
}, | ||
"pre-commit": [ | ||
"lint" | ||
] | ||
} | ||
} |
144
README.md
# rc-checkbox | ||
--- | ||
React Checkbox | ||
Checkbox ui component for react. | ||
@@ -9,16 +10,25 @@ [![NPM version][npm-image]][npm-url] | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![Dependencies](https://img.shields.io/david/react-component/checkbox.svg?style=flat-square)](https://david-dm.org/react-component/checkbox) | ||
[![DevDependencies](https://img.shields.io/david/dev/react-component/checkbox.svg?style=flat-square)](https://david-dm.org/react-component/checkbox?type=dev) | ||
[![Dependencies][david-image]][david-url] | ||
[![DevDependencies][david-dev-image]][david-dev-url] | ||
[![npm download][download-image]][download-url] | ||
[![bundle size][bundlephobia-image]][bundlephobia-url] | ||
[npm-image]: http://img.shields.io/npm/v/rc-checkbox.svg?style=flat-square | ||
[npm-url]: http://npmjs.org/package/rc-checkbox | ||
[travis-image]: https://img.shields.io/travis/react-component/checkbox.svg?style=flat-square | ||
[travis-image]: https://img.shields.io/travis/react-component/checkbox/master?style=flat-square | ||
[travis-url]: https://travis-ci.org/react-component/checkbox | ||
[circleci-image]: https://img.shields.io/circleci/react-component/checkbox/master?style=flat-square | ||
[circleci-url]: https://circleci.com/gh/react-component/checkbox | ||
[coveralls-image]: https://img.shields.io/coveralls/react-component/checkbox.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/r/react-component/checkbox?branch=master | ||
[david-url]: https://david-dm.org/react-component/checkbox | ||
[david-image]: https://david-dm.org/react-component/checkbox/status.svg?style=flat-square | ||
[david-dev-url]: https://david-dm.org/react-component/checkbox?type=dev | ||
[david-dev-image]: https://david-dm.org/react-component/checkbox/dev-status.svg?style=flat-square | ||
[download-image]: https://img.shields.io/npm/dm/rc-checkbox.svg?style=flat-square | ||
[download-url]: https://npmjs.org/package/rc-checkbox | ||
[bundlephobia-url]: https://bundlephobia.com/result?p=rc-checkbox | ||
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-checkbox | ||
## install | ||
## Install | ||
@@ -30,59 +40,61 @@ [![rc-checkbox](https://nodei.co/npm/rc-checkbox.png)](https://npmjs.org/package/rc-checkbox) | ||
```js | ||
require('rc-checkbox/assets/index.css'); | ||
const Checkbox = require('rc-checkbox'); | ||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
ReactDOM.render(<Checkbox />, container); | ||
import checkbox from 'rc-checkbox'; | ||
export default () => <checkbox />; | ||
``` | ||
## Compatibility | ||
| [<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 | | ||
## API | ||
### props | ||
<table class="table table-bordered table-striped"> | ||
<thead> | ||
<thead> | ||
<tr> | ||
<th style="width: 100px;">name</th> | ||
<th style="width: 50px;">type</th> | ||
<th style="width: 50px;">default</th> | ||
<th>description</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<th style="width: 100px;">name</th> | ||
<th style="width: 50px;">type</th> | ||
<th style="width: 50px;">default</th> | ||
<th>description</th> | ||
<td>prefixCls</td> | ||
<td>String</td> | ||
<td>rc-checkbox</td> | ||
<td></td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>prefixCls</td> | ||
<td>String</td> | ||
<td>rc-checkbox</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>className</td> | ||
<td>String</td> | ||
<td>''</td> | ||
<td>additional class name of root node</td> | ||
</tr> | ||
<tr> | ||
<td>name</td> | ||
<td>String</td> | ||
<td></td> | ||
<td>same with native input checkbox</td> | ||
</tr> | ||
<tr> | ||
<td>checked</td> | ||
<td>enum: 0,1,2</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>defaultChecked</td> | ||
<td>enum: 0,1,2</td> | ||
<td>0</td> | ||
<td>same with native input checkbox</td> | ||
<tr> | ||
<td>onChange</td> | ||
<td>Function(e:Event, checked:Number)</td> | ||
<td></td> | ||
<td>called when checkbox is changed. e is native event, checked is original checked state.</td> | ||
</tr> | ||
</tbody> | ||
<tr> | ||
<td>className</td> | ||
<td>String</td> | ||
<td>''</td> | ||
<td>additional class name of root node</td> | ||
</tr> | ||
<tr> | ||
<td>name</td> | ||
<td>String</td> | ||
<td></td> | ||
<td>same with native input checkbox</td> | ||
</tr> | ||
<tr> | ||
<td>checked</td> | ||
<td>enum: 0,1,2</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>defaultChecked</td> | ||
<td>enum: 0,1,2</td> | ||
<td>0</td> | ||
<td>same with native input checkbox</td> | ||
<tr> | ||
<td>onChange</td> | ||
<td>Function(e:Event, checked:Number)</td> | ||
<td></td> | ||
<td>called when checkbox is changed. e is native event, checked is original checked state.</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
@@ -97,26 +109,6 @@ | ||
## Example | ||
Online demo: http://react-component.github.io/checkbox/ | ||
http://localhost:8001/examples/ | ||
online example: http://react-component.github.io/checkbox/examples/simple.html | ||
## Test Case | ||
``` | ||
npm test | ||
npm run chrome-test | ||
``` | ||
## Coverage | ||
``` | ||
npm run coverage | ||
``` | ||
open coverage/ dir | ||
## License | ||
rc-checkbox is released under the MIT 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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
23918
0
439
0
14
7
112
+ Added@babel/runtime@^7.10.1
+ Added@babel/runtime@7.26.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
- Removedbabel-runtime@^6.23.0
- Removedbabel-runtime@6.26.0(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
Updatedclassnames@^2.2.1