@uiw/react-checkbox
Advanced tools
Comparing version 5.0.0-bate-5 to 5.0.0-bate-6
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"]; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,32 +8,23 @@ value: true | ||
exports["default"] = void 0; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _reactRadio = require("@uiw/react-radio"); | ||
var _Group = require("./Group"); | ||
var _style = require("./style"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var _excluded = ["className", "prefixCls", "type", "indeterminate", "disabled", "value"]; | ||
function InternalCheckbox(props, ref) { | ||
var className = props.className, | ||
_props$prefixCls = props.prefixCls, | ||
prefixCls = _props$prefixCls === void 0 ? 'w-checkbox' : _props$prefixCls, | ||
_props$type = props.type, | ||
type = _props$type === void 0 ? 'checkbox' : _props$type, | ||
_props$indeterminate = props.indeterminate, | ||
indeterminate = _props$indeterminate === void 0 ? false : _props$indeterminate, | ||
_props$disabled = props.disabled, | ||
disabled = _props$disabled === void 0 ? false : _props$disabled, | ||
_props$value = props.value, | ||
value = _props$value === void 0 ? '' : _props$value, | ||
other = (0, _objectWithoutProperties2["default"])(props, _excluded); | ||
_props$prefixCls = props.prefixCls, | ||
prefixCls = _props$prefixCls === void 0 ? 'w-checkbox' : _props$prefixCls, | ||
_props$type = props.type, | ||
type = _props$type === void 0 ? 'checkbox' : _props$type, | ||
_props$indeterminate = props.indeterminate, | ||
indeterminate = _props$indeterminate === void 0 ? false : _props$indeterminate, | ||
_props$disabled = props.disabled, | ||
disabled = _props$disabled === void 0 ? false : _props$disabled, | ||
_props$value = props.value, | ||
value = _props$value === void 0 ? '' : _props$value, | ||
other = (0, _objectWithoutProperties2["default"])(props, _excluded); | ||
var cls = [className, indeterminate && 'indeterminate'].filter(Boolean).join(' ').trim(); | ||
@@ -52,5 +42,3 @@ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_style.CheckboxStyleBase, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({ | ||
} | ||
var Checkbox = /*#__PURE__*/_react["default"].forwardRef(InternalCheckbox); | ||
Checkbox.Group = _Group.CheckboxGroup; | ||
@@ -57,0 +45,0 @@ var _default = Checkbox; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"]; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"]; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -11,28 +9,19 @@ value: true | ||
exports.CheckboxGroup = void 0; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _style = require("./style"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var _excluded = ["prefixCls", "className", "name", "value", "onChange"]; | ||
var CheckboxGroup = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) { | ||
var _props$prefixCls = props.prefixCls, | ||
prefixCls = _props$prefixCls === void 0 ? 'w-checkbox-group' : _props$prefixCls, | ||
className = props.className, | ||
name = props.name, | ||
value = props.value, | ||
_onChange = props.onChange, | ||
other = (0, _objectWithoutProperties2["default"])(props, _excluded); | ||
prefixCls = _props$prefixCls === void 0 ? 'w-checkbox-group' : _props$prefixCls, | ||
className = props.className, | ||
name = props.name, | ||
value = props.value, | ||
_onChange = props.onChange, | ||
other = (0, _objectWithoutProperties2["default"])(props, _excluded); | ||
var valueRef = (0, _react.useRef)([]); | ||
var cls = [prefixCls, className].filter(Boolean).join(' ').trim(); | ||
var childs = _react["default"].Children.toArray(props.children); | ||
(0, _react.useMemo)(function () { | ||
@@ -46,3 +35,2 @@ return valueRef.current = value || []; | ||
if (! /*#__PURE__*/_react["default"].isValidElement(element)) return; | ||
if (Array.isArray(value) && element && element.props && element.props.value && value.includes(element.props.value)) { | ||
@@ -53,3 +41,2 @@ if (!valueRef.current.includes(element.props.value)) { | ||
} | ||
return /*#__PURE__*/_react["default"].cloneElement(element, Object.assign({}, element.props, { | ||
@@ -62,3 +49,2 @@ name: name, | ||
var include = valueRef.current.includes(element.props.value); | ||
if (!include && checked) { | ||
@@ -71,3 +57,2 @@ valueRef.current.push(element.props.value); | ||
} | ||
_onChange && _onChange(e, valueRef.current); | ||
@@ -79,4 +64,3 @@ } | ||
}); | ||
exports.CheckboxGroup = CheckboxGroup; | ||
//# sourceMappingURL=Group.js.map |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"]; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -10,5 +9,3 @@ value: true | ||
exports["default"] = void 0; | ||
var _Checkbox = _interopRequireWildcard(require("./Checkbox")); | ||
Object.keys(_Checkbox).forEach(function (key) { | ||
@@ -25,5 +22,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _Group = require("./Group"); | ||
Object.keys(_Group).forEach(function (key) { | ||
@@ -40,5 +35,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _style = require("./style"); | ||
Object.keys(_style).forEach(function (key) { | ||
@@ -45,0 +38,0 @@ if (key === "default" || key === "__esModule") return; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"]; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"]; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -11,19 +9,11 @@ value: true | ||
exports.CheckboxStyleTheme = exports.CheckboxStyleBase = exports.CheckGroupStyleBase = void 0; | ||
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral")); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _styledComponents = _interopRequireWildcard(require("styled-components")); | ||
var _reactRadio = require("@uiw/react-radio"); | ||
var _utils = require("@uiw/utils"); | ||
var _templateObject, _templateObject2, _templateObject3, _templateObject4; | ||
var _excluded = ["disabled"], | ||
_excluded2 = ["indeterminate"]; | ||
_excluded2 = ["indeterminate"]; | ||
var CheckboxStyleTheme = { | ||
@@ -41,6 +31,5 @@ boxShadowCheckboxChecked: 'inset 0 0 0 1px rgb(0, 142, 240)', | ||
}; | ||
var disabledCss = function disabledCss(_ref) { | ||
var disabled = _ref.disabled, | ||
rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded); | ||
rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded); | ||
return disabled && (0, _styledComponents.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n input[type='checkbox'] {\n cursor: not-allowed;\n opacity: 0.5;\n }\n ", " {\n color: ", ";\n }\n "])), _reactRadio.RadioText, function () { | ||
@@ -50,6 +39,5 @@ return (0, _utils.getThemeVariantValue)((0, _objectSpread2["default"])({}, rest), 'colorCheckboxDisabled'); | ||
}; | ||
var indeterminateCss = function indeterminateCss(_ref2) { | ||
var indeterminate = _ref2.indeterminate, | ||
rest = (0, _objectWithoutProperties2["default"])(_ref2, _excluded2); | ||
rest = (0, _objectWithoutProperties2["default"])(_ref2, _excluded2); | ||
return indeterminate && (0, _styledComponents.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n input[type='checkbox']:checked {\n background-color: transparent;\n box-shadow: ", ";\n &:after {\n display: inline-block;\n background-color: ", ";\n box-sizing: inherit;\n transform: rotate(0);\n position: relative;\n top: -1px;\n right: -3px;\n border-width: 0;\n border-radius: 2px;\n height: 8px;\n width: 8px;\n }\n }\n "])), function () { | ||
@@ -61,7 +49,4 @@ return (0, _utils.getThemeVariantValue)((0, _objectSpread2["default"])({}, rest), 'boxShadowCheckboxChecked'); | ||
}; | ||
var CheckGroupStyleBase = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n vertical-align: middle;\n font-size: 0;\n cursor: pointer;\n white-space: nowrap;\n"]))); | ||
exports.CheckGroupStyleBase = CheckGroupStyleBase; | ||
var CheckboxStyleBase = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-block;\n input[type='checkbox'] {\n vertical-align: middle;\n outline: none;\n width: 14px;\n height: 14px;\n font-size: 14px;\n line-height: 14px;\n border-radius: 2px;\n background-clip: border-box;\n appearance: none;\n margin: 0 !important;\n background-color: ", ";\n transition: background-color 0.3s, box-shadow 0.3s;\n &:after {\n content: '';\n box-sizing: inherit;\n }\n &:not(:checked):not(:disabled):not(.disabled) {\n &:focus,\n &:hover {\n box-shadow: ", ";\n }\n }\n }\n ", "\n ", "\n input[type='checkbox']:checked {\n background-color: ", ";\n &:after {\n transition: background-color 0.2s ease-in;\n display: inline-block;\n border: solid ", ";\n border-width: 0 2px 2px 0;\n transform: rotate(33deg);\n position: relative;\n top: -1px;\n right: -4px;\n height: 10px;\n width: 6px;\n }\n }\n ", " {\n display: inline-block;\n padding-left: 4px;\n margin-right: 5px;\n font-size: 14px;\n }\n"])), function (props) { | ||
@@ -76,4 +61,3 @@ return (0, _utils.getThemeVariantValue)((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), propsTheme), 'backgroundColorCheckboxBase'); | ||
}, _reactRadio.RadioText); | ||
exports.CheckboxStyleBase = CheckboxStyleBase; | ||
//# sourceMappingURL=index.js.map |
@@ -9,14 +9,12 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
function InternalCheckbox(props, ref) { | ||
var { | ||
className, | ||
prefixCls = 'w-checkbox', | ||
type = 'checkbox', | ||
indeterminate = false, | ||
disabled = false, | ||
value = '' | ||
} = props, | ||
other = _objectWithoutPropertiesLoose(props, _excluded); | ||
className, | ||
prefixCls = 'w-checkbox', | ||
type = 'checkbox', | ||
indeterminate = false, | ||
disabled = false, | ||
value = '' | ||
} = props, | ||
other = _objectWithoutPropertiesLoose(props, _excluded); | ||
var cls = [className, indeterminate && 'indeterminate'].filter(Boolean).join(' ').trim(); | ||
@@ -34,3 +32,2 @@ return /*#__PURE__*/_jsx(CheckboxStyleBase, _extends({ | ||
} | ||
var Checkbox = /*#__PURE__*/React.forwardRef(InternalCheckbox); | ||
@@ -37,0 +34,0 @@ Checkbox.Group = CheckboxGroup; |
@@ -9,10 +9,9 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
var { | ||
prefixCls = 'w-checkbox-group', | ||
className, | ||
name, | ||
value, | ||
onChange: _onChange | ||
} = props, | ||
other = _objectWithoutPropertiesLoose(props, _excluded); | ||
prefixCls = 'w-checkbox-group', | ||
className, | ||
name, | ||
value, | ||
onChange: _onChange | ||
} = props, | ||
other = _objectWithoutPropertiesLoose(props, _excluded); | ||
var valueRef = useRef([]); | ||
@@ -27,3 +26,2 @@ var cls = [prefixCls, className].filter(Boolean).join(' ').trim(); | ||
if (! /*#__PURE__*/React.isValidElement(element)) return; | ||
if (Array.isArray(value) && element && element.props && element.props.value && value.includes(element.props.value)) { | ||
@@ -34,3 +32,2 @@ if (!valueRef.current.includes(element.props.value)) { | ||
} | ||
return /*#__PURE__*/React.cloneElement(element, Object.assign({}, element.props, { | ||
@@ -43,3 +40,2 @@ name, | ||
var include = valueRef.current.includes(element.props.value); | ||
if (!include && checked) { | ||
@@ -50,3 +46,2 @@ valueRef.current.push(element.props.value); | ||
} | ||
_onChange && _onChange(e, valueRef.current); | ||
@@ -53,0 +48,0 @@ } |
import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/taggedTemplateLiteralLoose"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; | ||
import _extends from "@babel/runtime/helpers/extends"; | ||
var _templateObject, _templateObject2, _templateObject3, _templateObject4; | ||
var _excluded = ["disabled"], | ||
_excluded2 = ["indeterminate"]; | ||
_excluded2 = ["indeterminate"]; | ||
import styled, { css } from 'styled-components'; | ||
@@ -23,21 +21,16 @@ import { RadioText } from '@uiw/react-radio'; | ||
}; | ||
var disabledCss = _ref => { | ||
var { | ||
disabled | ||
} = _ref, | ||
rest = _objectWithoutPropertiesLoose(_ref, _excluded); | ||
disabled | ||
} = _ref, | ||
rest = _objectWithoutPropertiesLoose(_ref, _excluded); | ||
return disabled && css(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n input[type='checkbox'] {\n cursor: not-allowed;\n opacity: 0.5;\n }\n ", " {\n color: ", ";\n }\n "])), RadioText, () => getThemeVariantValue(_extends({}, rest), 'colorCheckboxDisabled')); | ||
}; | ||
var indeterminateCss = _ref2 => { | ||
var { | ||
indeterminate | ||
} = _ref2, | ||
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2); | ||
indeterminate | ||
} = _ref2, | ||
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2); | ||
return indeterminate && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n input[type='checkbox']:checked {\n background-color: transparent;\n box-shadow: ", ";\n &:after {\n display: inline-block;\n background-color: ", ";\n box-sizing: inherit;\n transform: rotate(0);\n position: relative;\n top: -1px;\n right: -3px;\n border-width: 0;\n border-radius: 2px;\n height: 8px;\n width: 8px;\n }\n }\n "])), () => getThemeVariantValue(_extends({}, rest), 'boxShadowCheckboxChecked'), () => getThemeVariantValue(_extends({}, rest), 'backgroundColorCheckboxChecked')); | ||
}; | ||
var CheckGroupStyleBase = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n vertical-align: middle;\n font-size: 0;\n cursor: pointer;\n white-space: nowrap;\n"]))); | ||
@@ -44,0 +37,0 @@ var CheckboxStyleBase = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n display: inline-block;\n input[type='checkbox'] {\n vertical-align: middle;\n outline: none;\n width: 14px;\n height: 14px;\n font-size: 14px;\n line-height: 14px;\n border-radius: 2px;\n background-clip: border-box;\n appearance: none;\n margin: 0 !important;\n background-color: ", ";\n transition: background-color 0.3s, box-shadow 0.3s;\n &:after {\n content: '';\n box-sizing: inherit;\n }\n &:not(:checked):not(:disabled):not(.disabled) {\n &:focus,\n &:hover {\n box-shadow: ", ";\n }\n }\n }\n ", "\n ", "\n input[type='checkbox']:checked {\n background-color: ", ";\n &:after {\n transition: background-color 0.2s ease-in;\n display: inline-block;\n border: solid ", ";\n border-width: 0 2px 2px 0;\n transform: rotate(33deg);\n position: relative;\n top: -1px;\n right: -4px;\n height: 10px;\n width: 6px;\n }\n }\n ", " {\n display: inline-block;\n padding-left: 4px;\n margin-right: 5px;\n font-size: 14px;\n }\n"])), props => getThemeVariantValue(_extends({}, props, propsTheme), 'backgroundColorCheckboxBase'), props => getThemeVariantValue(_extends({}, props, propsTheme), 'boxShadowCheckboxHover'), disabledCss, indeterminateCss, props => getThemeVariantValue(_extends({}, props, propsTheme), 'backgroundColorCheckboxChecked'), props => getThemeVariantValue(_extends({}, props, propsTheme), 'borderColorCheckboxChecked'), RadioText); |
{ | ||
"name": "@uiw/react-checkbox", | ||
"version": "5.0.0-bate-5", | ||
"version": "5.0.0-bate-6", | ||
"description": "Checkbox component", | ||
@@ -48,5 +48,5 @@ "author": "Kenny Wong <wowohoo@qq.com>", | ||
"dependencies": { | ||
"@uiw/react-radio": "^5.0.0-bate-5", | ||
"@uiw/utils": "^5.0.0-bate-5" | ||
"@uiw/react-radio": "^5.0.0-bate-6", | ||
"@uiw/utils": "^5.0.0-bate-6" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
67044
Updated@uiw/utils@^5.0.0-bate-6