import _extends from "@babel/runtime/helpers/extends";
import _Select from "@alifd/next/es/select";
import StyleItemSetter from "../../components/style-item-setter";
import * as React from "react";
import { useMemo } from "react";
var Option = _Select.Option;
var options = [{
  value: "24px",
  label: "超大"
}, {
  value: "20px",
  label: "大"
}, {
  value: "16px",
  label: "中"
}, {
  value: "12px",
  label: "小"
}, {
  value: "8px",
  label: "超小"
}, {
  value: "0",
  label: "无"
}];
export default function LayoutMarginSetter(props) {
  return /*#__PURE__*/React.createElement(StyleItemSetter.TowColumnLayout, null, /*#__PURE__*/React.createElement(StyleItemSetter, {
    label: "外边距",
    dataInput: /*#__PURE__*/React.createElement(MarginSelect, _extends({}, props, {
      styleKey: "margin"
    }))
  }), /*#__PURE__*/React.createElement(StyleItemSetter, {
    label: "内边距",
    dataInput: /*#__PURE__*/React.createElement(MarginSelect, _extends({}, props, {
      styleKey: "padding"
    }))
  }));
}
function MarginSelect(props) {
  var styleKey = props.styleKey,
    onStyleChange = props.onStyleChange,
    styleData = props.styleData;
  var value = useMemo(function () {
    return styleData[styleKey];
  }, [styleData]);
  var displayValue = 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, {
    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, ")");
  }));
}