"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _numberPicker = _interopRequireDefault(require("@alifd/next/lib/number-picker"));
var _range = _interopRequireDefault(require("@alifd/next/lib/range"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _radio = _interopRequireDefault(require("@alifd/next/lib/radio"));
var React = _interopRequireWildcard(require("react"));
require("./index.scss");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var RadioGroup = _radio["default"].Group;
var ResizeSetter = /*#__PURE__*/function (_PureComponent) {
  (0, _inheritsLoose2["default"])(ResizeSetter, _PureComponent);
  function ResizeSetter() {
    return _PureComponent.apply(this, arguments) || this;
  }
  var _proto = ResizeSetter.prototype;
  _proto.render = function render() {
    var options = this.props.options;
    if (options) {
      var _this$props = this.props,
        value = _this$props.value,
        _onChange = _this$props.onChange,
        disabled = _this$props.disabled,
        _this$props$options = _this$props.options,
        size = _this$props$options.size,
        sizeList = _this$props$options.sizeList;
      var dataSource = sizeList.map(function (item) {
        if (typeof item === 'string') {
          return item;
        } else {
          return {
            label: item.title || item.label,
            value: item.value
          };
        }
      });
      var otherProps = {};
      var isRangeSelect = sizeList.find(function (res) {
        return res.value === value;
      });
      return /*#__PURE__*/React.createElement("div", {
        className: "resize-img-setter"
      }, /*#__PURE__*/React.createElement(RadioGroup, (0, _extends2["default"])({
        size: "small",
        dataSource: dataSource,
        shape: "button",
        value: value,
        disabled: disabled,
        onChange: function onChange(val) {
          return _onChange(val);
        }
      }, otherProps)), /*#__PURE__*/React.createElement("div", {
        style: {
          display: 'flex',
          marginTop: '4px'
        }
      }, /*#__PURE__*/React.createElement(_range["default"], {
        value: value,
        min: size.min || 0,
        max: size.max || 100,
        step: size.step || 1,
        onChange: function onChange(val) {
          return _onChange(val);
        },
        style: {
          marginRight: 15
        },
        className: isRangeSelect ? 'next-range-static' : ''
      }), !isRangeSelect ? /*#__PURE__*/React.createElement(_numberPicker["default"], {
        onChange: function onChange(val) {
          return _onChange(val);
        },
        value: value,
        size: "small",
        min: size.min || 0,
        max: size.max || 100,
        hasTrigger: false,
        innerAfter: "%"
      }) : ''));
    }
  };
  return ResizeSetter;
}(React.PureComponent);
exports["default"] = ResizeSetter;
ResizeSetter.displayName = 'ResizeSetter';