'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');

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":"Tumbler__root___17yYC","view":"Tumbler__view___w66K2","viewCircle":"Tumbler__viewCircle___xvJqd","input":"Tumbler__input___Kg91O","inputLoading":"Tumbler__inputLoading___y1iJD","spinner":"Tumbler__spinner___CNMl7","spinnerEnterActive":"Tumbler__spinnerEnterActive___C2P5b","spinnerEnterDone":"Tumbler__spinnerEnterDone___cgEXP","spinnerExitActive":"Tumbler__spinnerExitActive___k-mzv","spinnerExitDone":"Tumbler__spinnerExitDone___XD0-8"};

var _excluded = ["className", "loading", "type"];
var Tumbler = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
  var className = _ref.className,
    _ref$loading = _ref.loading,
    loading = _ref$loading === void 0 ? false : _ref$loading,
    _ref$type = _ref.type,
    type = _ref$type === void 0 ? 'checkbox' : _ref$type,
    props = _objectWithoutProperties__default.default(_ref, _excluded);
  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({
    ref: ref,
    className: classNames__default.default(css.input, _defineProperty__default.default({}, css.inputLoading, loading)),
    type: type
  }, props)), /*#__PURE__*/React__namespace.createElement("div", {
    className: css.view
  }, /*#__PURE__*/React__namespace.createElement("div", {
    className: css.viewCircle
  }, /*#__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
  })))));
});
Tumbler.displayName = 'Tumbler';

exports.Tumbler = Tumbler;

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