import _NumberPicker from "@alifd/next/es/number-picker";
import _Select from "@alifd/next/es/select";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import * as React from 'react';
import { PureComponent } from 'react';
import "./index.scss";
var GroupParamSetter = /*#__PURE__*/function (_PureComponent) {
  _inheritsLoose(GroupParamSetter, _PureComponent);
  function GroupParamSetter() {
    return _PureComponent.apply(this, arguments) || this;
  }
  var _proto = GroupParamSetter.prototype;
  _proto.render = function render() {
    var _this$props = this.props,
      value = _this$props.value,
      _this$props$step = _this$props.step,
      step = _this$props$step === void 0 ? 2 : _this$props$step,
      _onChange = _this$props.onChange;
    var _dataSource = [{
      label: '绝对单位',
      children: [{
        label: 'px',
        value: 'px'
      }, {
        label: 'in',
        value: 'in'
      }, {
        label: 'cm',
        value: 'cm'
      }, {
        label: 'mm',
        value: 'mm'
      }]
    }, {
      label: '相对单位',
      children: [{
        label: '%',
        value: '%'
      }, {
        label: 'em',
        value: 'em'
      }, {
        label: 'rem',
        value: 'rem'
      }, {
        label: 'vw',
        value: 'vw'
      }, {
        label: 'vh',
        value: 'vh'
      }]
    }];
    return /*#__PURE__*/React.createElement("div", {
      className: "group-param-setter"
    }, Object.entries(value).map(function (_ref, idx) {
      var key = _ref[0],
        val = _ref[1];
      return idx < 2 ? /*#__PURE__*/React.createElement(_NumberPicker, {
        onChange: function onChange(_val) {
          var _value = JSON.parse(JSON.stringify(value));
          _value[key].value = _val;
          _onChange(_value);
        },
        key: val.value + key,
        value: val.value,
        size: "small",
        step: step,
        hasTrigger: false,
        innerAfter: /*#__PURE__*/React.createElement(_Select, {
          defaultValue: val.unit || 'px',
          className: "unitSel",
          size: "small",
          dataSource: _dataSource,
          onChange: function onChange(_val) {
            var _value = JSON.parse(JSON.stringify(value));
            _value[key].unit = _val;
            _onChange(_value);
          },
          popupClassName: "sel-popup-gp-param-setter"
        }),
        label: val.label,
        className: "group-param-setter-item"
      }) : /*#__PURE__*/React.createElement("div", null);
    }));
  };
  return GroupParamSetter;
}(PureComponent);
GroupParamSetter.displayName = 'GroupParamSetter';
export { GroupParamSetter as default };