"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 _left = _interopRequireDefault(require("./imgs/left.png"));

var _center = _interopRequireDefault(require("./imgs/center.png"));

var _right = _interopRequireDefault(require("./imgs/right.png"));

var _Iconfont = _interopRequireDefault(require("../Iconfont"));

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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
      }
    };

    return _extendStatics(d, b);
  };

  return function (d, b) {
    if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");

    _extendStatics(d, b);

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

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

var defaultSource = [{
  id: 'layout1',
  name: 'left',
  image: _left["default"]
}, {
  id: 'layout2',
  name: 'center',
  image: _center["default"]
}, {
  id: 'layout3',
  name: 'right',
  image: _right["default"]
}];

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

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

    _this.state = {};
    return _this;
  }

  LayoutSelector.prototype.render = function () {
    var _a = this.props,
        source = _a.source,
        onChange = _a.onChange,
        value = _a.value;
    var sourceList = source || defaultSource;
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "m-layout-selector"
    }, sourceList.map(function (item) {
      return /*#__PURE__*/_react["default"].createElement("div", {
        key: item.name,
        className: (0, _classnames["default"])('item-wrap', {
          active: value === item.name
        }),
        onClick: function onClick() {
          onChange(item.name);
        }
      }, item.image ? /*#__PURE__*/_react["default"].createElement("img", {
        alt: item.name,
        src: item.image
      }) : /*#__PURE__*/_react["default"].createElement(_Iconfont["default"], {
        size: 32,
        type: item.icon
      }));
    }));
  };

  LayoutSelector.defaultProps = {
    value: 'left',
    onChange: function onChange() {}
  };
  return LayoutSelector;
}(_react["default"].Component);

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