"use strict";

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

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

require("./index.less");

var _ColorPicker = _interopRequireDefault(require("../ColorPicker"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var __extends = void 0 && (void 0).__extends || function () {
  var _extendStatics = function extendStatics(d, b) {
    _extendStatics = Object.setPrototypeOf || {
      __proto__: []
    } instanceof Array && function (d, b) {
      d.__proto__ = b;
    } || function (d, b) {
      for (var p in b) {
        if (b.hasOwnProperty(p)) d[p] = b[p];
      }
    };

    return _extendStatics(d, b);
  };

  return function (d, b) {
    _extendStatics(d, b);

    function __() {
      this.constructor = d;
    }

    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
}();

var ColorPickerInput =
/** @class */
function (_super) {
  __extends(ColorPickerInput, _super);

  function ColorPickerInput() {
    var _this = _super !== null && _super.apply(this, arguments) || this;

    _this.state = {
      visibility: false
    };
    return _this;
  }

  ColorPickerInput.prototype.render = function () {
    var _a;

    var _this = this;

    var _b = this.props,
        placement = _b.placement,
        type = _b.type,
        colorType = _b.colorType,
        value = _b.value,
        onChange = _b.onChange;
    var visibility = this.state.visibility;
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _classnames["default"])('m-color-picker-input', (_a = {}, _a[type] = true, _a))
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "input-color",
      onClick: function onClick() {
        return _this.setState({
          visibility: true
        });
      }
    }, /*#__PURE__*/_react["default"].createElement("span", {
      className: (0, _classnames["default"])('color-icon', {
        transparent: value === ''
      }),
      style: {
        background: value
      }
    }), /*#__PURE__*/_react["default"].createElement("span", {
      className: "color-value"
    }, value || 'Transparent')), /*#__PURE__*/_react["default"].createElement(_ColorPicker["default"], {
      color: value,
      onChangeColor: function onChangeColor(color) {
        return onChange(color);
      },
      onClose: function onClose() {
        return _this.setState({
          visibility: false
        });
      },
      placement: placement,
      type: colorType,
      visibility: visibility
    }));
  };

  ColorPickerInput.defaultProps = {
    value: '#2F54EB',
    onChange: function onChange() {},
    colorType: 'hex',
    type: 'default'
  };
  return ColorPickerInput;
}(_react["default"].Component);

var _default = ColorPickerInput;
exports["default"] = _default;