var __assign = this && this.__assign || function () {
  __assign = Object.assign || function (t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];

      for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
      }
    }

    return t;
  };

  return __assign.apply(this, arguments);
};

import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import * as React from 'react';
import classNames from 'classnames';
import { prefixCls, DEFAULT_IMAGE_SRC, BACKGROUND_SIZE_OPT } from "./constant";
import Button from "../../button";
import Select from "../../select";
import "../style/color-image.css";

var ColorImage = function ColorImage(_a) {
  var className = _a.className,
      showUpload = _a.showUpload,
      showMedia = _a.showMedia,
      onChange = _a.onChange,
      labelUpload = _a.labelUpload,
      getPopupContainer = _a.getPopupContainer,
      labelSelectMedia = _a.labelSelectMedia,
      bgSizeOptions = _a.bgSizeOptions,
      src = _a.src,
      size = _a.size;
  var style = {
    backgroundSize: size,
    backgroundImage: "url(" + src + ")",
    backgroundRepeat: src === DEFAULT_IMAGE_SRC ? 'repeat' : 'no-repeat'
  };
  return _jsxs(React.Fragment, {
    children: [_jsx("div", __assign({
      style: style,
      className: classNames(prefixCls + "-img", className)
    }, {
      children: _jsxs("div", __assign({
        className: prefixCls + "-img-btns"
      }, {
        children: [_jsx(Button, __assign({
          className: prefixCls + "-img-btn",
          onClick: showUpload
        }, {
          children: labelUpload
        }), void 0), !!showMedia && _jsx(Button, __assign({
          className: prefixCls + "-img-btn",
          onClick: showMedia
        }, {
          children: labelSelectMedia
        }), void 0)]
      }), void 0)
    }), void 0), _jsx("div", __assign({
      className: prefixCls + "-img-size-wrap"
    }, {
      children: _jsx(Select, {
        size: "compact",
        type: "menu-bg",
        value: size,
        options: bgSizeOptions,
        allowClear: false,
        onChange: onChange,
        getPopupContainer: getPopupContainer,
        className: prefixCls + "-img-size-select " + prefixCls + "-select"
      }, void 0)
    }), void 0)]
  }, void 0);
};

ColorImage.defaultProps = {
  labelUpload: '本地上传',
  labelSelectMedia: '从素材库选择',
  bgSizeOptions: BACKGROUND_SIZE_OPT,
  src: DEFAULT_IMAGE_SRC,
  size: BACKGROUND_SIZE_OPT[0].key
};
ColorImage.displayName = 'ColorImage';
export default ColorImage;
var ColorImageMemo = /*#__PURE__*/React.memo(ColorImage);
ColorImageMemo.displayName = 'ColorImageMemo';
export { ColorImageMemo };

