"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = LayoutMarginSetter;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _select = _interopRequireDefault(require("@alifd/next/lib/select"));
var _styleItemSetter = _interopRequireDefault(require("../../components/style-item-setter"));
var _react = _interopRequireWildcard(require("react"));
var React = _react;
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
var Option = _select["default"].Option;
var options = [{
  value: "24px",
  label: "超大"
}, {
  value: "20px",
  label: "大"
}, {
  value: "16px",
  label: "中"
}, {
  value: "12px",
  label: "小"
}, {
  value: "8px",
  label: "超小"
}, {
  value: "0",
  label: "无"
}];
function LayoutMarginSetter(props) {
  return /*#__PURE__*/React.createElement(_styleItemSetter["default"].TowColumnLayout, null, /*#__PURE__*/React.createElement(_styleItemSetter["default"], {
    label: "外边距",
    dataInput: /*#__PURE__*/React.createElement(MarginSelect, (0, _extends2["default"])({}, props, {
      styleKey: "margin"
    }))
  }), /*#__PURE__*/React.createElement(_styleItemSetter["default"], {
    label: "内边距",
    dataInput: /*#__PURE__*/React.createElement(MarginSelect, (0, _extends2["default"])({}, props, {
      styleKey: "padding"
    }))
  }));
}
function MarginSelect(props) {
  var styleKey = props.styleKey,
    onStyleChange = props.onStyleChange,
    styleData = props.styleData;
  var value = (0, _react.useMemo)(function () {
    return styleData[styleKey];
  }, [styleData]);
  var displayValue = (0, _react.useMemo)(function () {
    if (value == null) return null;
    var findOption = options.find(function (op) {
      return op.value == value;
    });
    if (findOption) {
      return value;
    } else {
      return "\u81EA\u5B9A\u4E49(" + value + ")";
    }
  }, [value]);
  return /*#__PURE__*/React.createElement(_select["default"], {
    style: {
      width: "100%"
    },
    hasClear: true,
    value: displayValue,
    onChange: function onChange(value) {
      onStyleChange([{
        styleKey: styleKey,
        value: value
      }]);
    }
  }, options.map(function (op) {
    return /*#__PURE__*/React.createElement(Option, {
      value: op.value
    }, op.label, "(", op.value, ")");
  }));
}