"use strict";

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

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.inputStyle = 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 readOnly = {
  _readOnly: {
    bg: 'transparent',
    boxShadow: 'none',
    userSelect: 'all'
  }
};

var inputStyle = function inputStyle(_ref, theme) {
  var _ref$isFullWidth = _ref.isFullWidth,
      isFullWidth = _ref$isFullWidth === void 0 ? true : _ref$isFullWidth;
  return {
    style: {
      display: 'flex',
      alignItems: 'center',
      position: 'relative',
      transition: 'all 0.2s',
      outline: 'none',
      appearance: 'none',
      borderRadius: 'radius',
      boxSizing: 'border-box',
      px: 'spacing',
      width: isFullWidth ? 'full' : 'input.width'
    },
    sizes: {
      lg: {
        height: 'input.lg'
      },
      md: {
        height: 'input.md'
      },
      sm: {
        height: 'input.sm'
      }
    },
    variants: {
      flushed: _objectSpread({
        borderBottom: '1px',
        borderColor: 'border',
        rounded: 0,
        px: undefined,
        bg: 'transparent',
        _focus: {
          zIndex: 1,
          borderColor: 'inputFocus'
        },
        _invalid: {
          borderColor: 'error.500'
        }
      }, readOnly),
      filled: _objectSpread({
        border: '1px',
        borderColor: 'border',
        bg: 'inputBg',
        _hover: {
          bg: 'inputHover'
        },
        _disabled: {
          opacity: '0.4',
          cursor: 'not-allowed'
        },
        _focus: {
          zIndex: 1,
          bg: 'inputHover',
          borderColor: 'inputFocus'
        },
        _invalid: {
          borderColor: 'error.500'
        }
      }, readOnly),
      outline: _objectSpread({
        border: '1px',
        borderColor: 'border',
        bg: 'transparent',
        _hover: {
          borderColor: 'inputHover'
        },
        _disabled: {
          opacity: '0.4',
          cursor: 'not-allowed'
        },
        _focus: {
          zIndex: 1,
          borderColor: 'inputFocus',
          boxShadow: "0 0 0 1px ".concat(theme.colors.inputFocus)
        },
        _invalid: {
          borderColor: 'error.500',
          boxShadow: "0 0 0 1px ".concat(theme.colors.error[500])
        }
      }, readOnly),
      unstyled: {
        bg: 'transparent',
        px: undefined,
        height: undefined
      }
    }
  };
};

exports.inputStyle = inputStyle;

var useInputStyle = function useInputStyle(props) {
  var theme = (0, _ThemeProvider.useTheme)();
  var styles = theme['styles'].input ? theme['styles'].input(props, theme) : inputStyle(props, theme);
  return _objectSpread(_objectSpread(_objectSpread({}, styles.style), styles.variants[props.variant]), styles.sizes[props.size]);
};

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