UNPKG

2.59 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5exports.__esModule = true;
6exports["default"] = void 0;
7
8var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
10var _colorsUtils = require("../theme/colors-utils");
11
12function 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; }
13
14function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15
16var baseProps = {
17 userSelect: "none",
18 border: "2px",
19 rounded: "md",
20 borderColor: "inherit",
21 transition: "background-color 120ms, box-shadow 250ms"
22};
23
24var interactionProps = function interactionProps(_ref) {
25 var color = _ref.color,
26 colorMode = _ref.colorMode;
27 var isDarkMode = colorMode === "dark";
28
29 var _color = isDarkMode ? 200 : 500;
30
31 return {
32 color: "white",
33 _checked: {
34 bg: (0, _colorsUtils.get)(color, _color),
35 borderColor: (0, _colorsUtils.get)(color, _color),
36 color: isDarkMode ? "gray.900" : undefined
37 },
38 _checkedAndDisabled: {
39 borderColor: isDarkMode ? "transparent" : "gray.200",
40 bg: isDarkMode ? "whiteAlpha.300" : "gray.200",
41 color: isDarkMode ? "whiteAlpha.500" : "gray.500"
42 },
43 _disabled: {
44 bg: isDarkMode ? "whiteAlpha.100" : "gray.100",
45 borderColor: isDarkMode ? "transparent" : "gray.100"
46 },
47 _focus: {
48 boxShadow: "outline"
49 },
50 _invalid: {
51 borderColor: isDarkMode ? "red.300" : "red.500"
52 }
53 };
54};
55
56var useCheckboxStyle = function useCheckboxStyle(props) {
57 var sizes = {
58 lg: 5,
59 md: 4,
60 sm: props.type === "radio" ? 3 : "auto"
61 };
62 return _objectSpread({}, baseProps, {}, props.size && {
63 rounded: "sm"
64 }, {}, interactionProps(props), {
65 size: sizes[props.size]
66 });
67};
68
69var _default = useCheckboxStyle;
70exports["default"] = _default;
\No newline at end of file