"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.checkboxStyle = void 0;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _ThemeProvider = require("../ThemeProvider");

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) { (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; }

var checkboxStyle = function checkboxStyle(_ref, _ref2) {
  var color = _ref.color,
      type = _ref.type,
      isDisabled = _ref.isDisabled,
      isFullWidth = _ref.isFullWidth,
      isChild = _ref.isChild,
      size = _ref.size;
  var colors = _ref2.colors,
      shadows = _ref2.shadows;
  return {
    style: {
      userSelect: 'none',
      border: '2px',
      rounded: '2px',
      borderColor: 'track',
      transition: 'background-color 120ms, box-shadow 250ms',
      color: 'white',
      _checked: {
        bg: "".concat(color, ".500"),
        borderColor: "".concat(color, ".500")
      },
      _checkedAndDisabled: {
        borderColor: "".concat(color, ".500"),
        bg: "".concat(color, ".500"),
        color: 'disabled',
        opacity: 0.25
      },
      _disabled: {
        bg: 'border',
        borderColor: 'border'
      },
      _focus: {
        boxShadow: 'outline'
      },
      _invalid: {
        borderColor: 'error.500'
      }
    },
    sizes: {
      lg: 5,
      md: 4,
      sm: type === 'radio' ? 3 : 'auto'
    },
    label: {
      ml: 'spacing-sm',
      userSelect: 'none',
      color: isDisabled ? 'disabled' : 'bodyText',
      whiteSpace: 'nowrap'
    },
    container: {
      display: 'flex',
      verticalAlign: 'top',
      alignItems: 'center',
      width: isFullWidth ? 'full' : undefined,
      cursor: isDisabled ? 'not-allowed' : 'pointer',
      ml: isChild ? 'spacing-lg' : 0
    }
  };
};

exports.checkboxStyle = checkboxStyle;

var useCheckboxStyle = function useCheckboxStyle(props) {
  var theme = (0, _ThemeProvider.useTheme)();
  var styles = theme['styles'].checkbox ? theme['styles'].checkbox(props, theme) : checkboxStyle(props, theme);
  return {
    root: _objectSpread(_objectSpread({}, styles.style), {}, {
      size: styles.sizes[props.size]
    }),
    label: styles.label,
    container: styles.container
  };
};

var _default = useCheckboxStyle;
exports["default"] = _default;
//# sourceMappingURL=styles.js.map