'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _extends = require('@babel/runtime/helpers/extends');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var React = require('react');
var reactTransitionGroup = require('react-transition-group');
var classNames = require('clsx');
var Spinner = require('@prom-ui/core/Spinner');
var useForwardRef = require('@prom-ui/core/useForwardRef');

function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }

function _interopNamespaceCompat(e) {
  if (e && typeof e === 'object' && 'default' in e) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var _extends__default = /*#__PURE__*/_interopDefaultCompat(_extends);
var _defineProperty__default = /*#__PURE__*/_interopDefaultCompat(_defineProperty);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultCompat(_objectWithoutProperties);
var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);

var css = {"root":"Checkbox__root___t16TL","view":"Checkbox__view___vqHSH","input":"Checkbox__input___IYq4y","inputIndeterminate":"Checkbox__inputIndeterminate___W0nyo","inputLoading":"Checkbox__inputLoading___HmXKw","spinner":"Checkbox__spinner___YR6PM","spinnerEnterActive":"Checkbox__spinnerEnterActive___Q7DFi","spinnerEnterDone":"Checkbox__spinnerEnterDone___h1wA-","spinnerExitActive":"Checkbox__spinnerExitActive___qjqOb","spinnerExitDone":"Checkbox__spinnerExitDone___t3mB8"};

var _excluded = ["className", "type", "loading", "indeterminate"];
var Checkbox = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
  var className = _ref.className,
    _ref$type = _ref.type,
    type = _ref$type === void 0 ? 'checkbox' : _ref$type,
    _ref$loading = _ref.loading,
    loading = _ref$loading === void 0 ? false : _ref$loading,
    _ref$indeterminate = _ref.indeterminate,
    indeterminate = _ref$indeterminate === void 0 ? false : _ref$indeterminate,
    props = _objectWithoutProperties__default.default(_ref, _excluded);
  var inputRef = useForwardRef.useForwardRef(ref, null);
  var spinnerRef = React__namespace.useRef(null);
  return /*#__PURE__*/React__namespace.createElement("div", {
    className: classNames__default.default(css.root, className)
  }, /*#__PURE__*/React__namespace.createElement("input", _extends__default.default({
    className: classNames__default.default(css.input, _defineProperty__default.default(_defineProperty__default.default({}, css.inputLoading, loading), css.inputIndeterminate, indeterminate)),
    ref: inputRef,
    disabled: loading,
    type: type
  }, props)), /*#__PURE__*/React__namespace.createElement("div", {
    className: css.view
  }, /*#__PURE__*/React__namespace.createElement(reactTransitionGroup.CSSTransition, {
    nodeRef: spinnerRef,
    "in": loading,
    timeout: 100,
    classNames: {
      enterActive: css.spinnerEnterActive,
      enterDone: css.spinnerEnterDone,
      exitActive: css.spinnerExitActive,
      exitDone: css.spinnerExitDone
    },
    unmountOnExit: true
  }, /*#__PURE__*/React__namespace.createElement(Spinner.Spinner, {
    ref: spinnerRef,
    className: css.spinner,
    width: "100%",
    height: "100%"
  }))));
});
Checkbox.displayName = 'Checkbox';

exports.Checkbox = Checkbox;

require('./style.development.v2.css');
