"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 _select = _interopRequireDefault(require("@alifd/next/lib/select"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
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 GroupParamSetter = /*#__PURE__*/function (_PureComponent) {
  (0, _inheritsLoose2["default"])(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["default"], {
        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["default"], {
          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;
}(React.PureComponent);
exports["default"] = GroupParamSetter;
GroupParamSetter.displayName = 'GroupParamSetter';