UNPKG

@chakra-xui/control-box

Version:
66 lines (61 loc) 2.66 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import { chakra } from "@chakra-xui/system"; import { __DEV__ } from "@chakra-xui/utils"; import * as React from "react"; export var ControlBox = props => { var { type = "checkbox", _hover, _invalid, _disabled, _focus, _checked, _child = { opacity: 0 }, _checkedAndChild = { opacity: 1 }, _checkedAndDisabled, _checkedAndFocus, _checkedAndHover, children } = props, rest = _objectWithoutPropertiesLoose(props, ["type", "_hover", "_invalid", "_disabled", "_focus", "_checked", "_child", "_checkedAndChild", "_checkedAndDisabled", "_checkedAndFocus", "_checkedAndHover", "children"]); var checkedAndDisabled = "input[type=" + type + "]:checked:disabled + &"; var checkedAndHover = "input[type=" + type + "]:checked:hover:not(:disabled) + &"; var checkedAndFocus = "input[type=" + type + "]:checked:focus + &"; var disabled = "input[type=" + type + "]:disabled + &"; var focus = "input[type=" + type + "]:focus + &"; var hover = "input[type=" + type + "]:hover:not(:disabled):not(:checked) + &"; var checked = "input[type=" + type + "]:checked + &, input[type=" + type + "][aria-checked=mixed] + &"; var invalid = "input[type=" + type + "][aria-invalid=true] + &"; var child = "& > *"; return /*#__PURE__*/React.createElement(chakra.div, _extends({}, rest, { "aria-hidden": true, __css: { display: "inline-flex", alignItems: "center", justifyContent: "center", transition: "all 120ms", flexShrink: 0, [focus]: _focus, [hover]: _hover, [disabled]: _disabled, [invalid]: _invalid, [checkedAndDisabled]: _checkedAndDisabled, [checkedAndFocus]: _checkedAndFocus, [checkedAndHover]: _checkedAndHover, [child]: _child, [checked]: _extends({}, _checked, { [child]: _checkedAndChild }) } }), children); }; if (__DEV__) { ControlBox.displayName = "ControlBox"; } export default ControlBox; //# sourceMappingURL=control-box.js.map