"use strict";

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

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

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

var _antd = require("antd");

require("./index.less");

var _InputNumber = _interopRequireDefault(require("../InputNumber"));

var _ColorPickerInput = _interopRequireDefault(require("../ColorPickerInput"));

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 __assign = void 0 && (void 0).__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);
};

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

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

    _this.state = {};
    _this.colorRef = /*#__PURE__*/_react["default"].createRef();
    _this.colorPickerRef = /*#__PURE__*/_react["default"].createRef();
    return _this;
  }

  SliderInput.prototype.render = function () {
    var _a = this.props,
        value = _a.value,
        minVal = _a.minVal,
        _onChange = _a.onChange,
        maxVal = _a.maxVal,
        needColor = _a.needColor,
        inputType = _a.inputType,
        step = _a.step,
        unit = _a.unit; // 在step 未传的情况下： 若类型为 int or percent 则step默认为1； 类型为float，则step默认为0.1

    var _step = step || 1;

    if (inputType == 'float') {
      _step = step || 0.1;
    }

    var _unit = unit || (inputType === 'percent' ? '%' : '');

    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "m-slider-input"
    }, /*#__PURE__*/_react["default"].createElement(_antd.Slider, {
      className: (0, _classnames["default"])('slider', {
        colorAndSlider: needColor
      }),
      max: maxVal,
      min: minVal,
      onChange: function onChange(v) {
        return _onChange(__assign(__assign({}, value), {
          count: v
        }));
      },
      step: _step,
      value: value.count
    }), /*#__PURE__*/_react["default"].createElement(_InputNumber["default"], {
      max: maxVal,
      min: minVal,
      onChange: function onChange(v) {
        return _onChange(__assign(__assign({}, value), {
          count: v
        }));
      },
      step: _step,
      unit: _unit,
      value: value.count
    }), needColor && /*#__PURE__*/_react["default"].createElement(_ColorPickerInput["default"], {
      colorType: "rgba",
      onChange: function onChange(color) {
        _onChange(__assign(__assign({}, value), {
          color: color
        }));
      },
      placement: "bottomLeft",
      type: "dot",
      value: value.color
    }));
  };

  SliderInput.defaultProps = {
    value: {
      count: 1
    },
    onChange: function onChange() {},
    minVal: 1,
    maxVal: 100,
    needColor: false,
    inputType: 'int',
    unit: ''
  };
  return SliderInput;
}(_react["default"].Component);

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