"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _collapse = _interopRequireDefault(require("@alifd/next/lib/collapse"));
var React = _interopRequireWildcard(require("react"));
var _row = _interopRequireDefault(require("../../components/row"));
var _layoutBox = _interopRequireDefault(require("./layoutBox"));
var _number = _interopRequireDefault(require("../../components/number"));
var _locale = require("./locale");
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 Panel = _collapse["default"].Panel;
var layoutConfig = (0, _locale.intlLocal)();
var defaultLayoutPropsConfig = {
  // display 展示列表
  showDisPlayList: ['inline', 'flex', 'block', 'inline-block', 'none'],
  isShowPadding: true,
  isShowMargin: true,
  isShowWidthHeight: true
};
var _default = exports["default"] = function _default(props) {
  var onStyleChange = props.onStyleChange,
    styleData = props.styleData,
    layoutPropsConfig = props.layoutPropsConfig,
    unit = props.unit;

  // 配置合并
  var propsConfig = (0, _extends2["default"])({}, defaultLayoutPropsConfig, layoutPropsConfig);

  // 传入配置
  var showDisPlayList = propsConfig.showDisPlayList,
    isShowWidthHeight = propsConfig.isShowWidthHeight;
  // 静态配置
  var display = layoutConfig.display,
    flexDirection = layoutConfig.flexDirection,
    justifyContent = layoutConfig.justifyContent,
    alignItems = layoutConfig.alignItems,
    flexWrap = layoutConfig.flexWrap;
  var displayDataList = display.dataList.filter(function (item) {
    return showDisPlayList.indexOf(item.value) >= 0;
  });
  return /*#__PURE__*/React.createElement(_collapse["default"], {
    defaultExpandedKeys: ['0']
  }, /*#__PURE__*/React.createElement(Panel, {
    title: layoutConfig.title,
    className: "layout-style-container"
  }, /*#__PURE__*/React.createElement(_row["default"], (0, _extends2["default"])({
    title: display.title,
    dataList: displayDataList,
    styleKey: "display"
  }, props, {
    longTitle: true
  })), styleData['display'] === 'flex' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_row["default"], (0, _extends2["default"])({
    title: flexDirection.title,
    dataList: flexDirection.dataList,
    styleKey: "flexDirection",
    longTitle: true
  }, props)), /*#__PURE__*/React.createElement(_row["default"], (0, _extends2["default"])({
    title: justifyContent.title,
    dataList: justifyContent.dataList,
    styleKey: "justifyContent",
    longTitle: true
  }, props)), /*#__PURE__*/React.createElement(_row["default"], (0, _extends2["default"])({
    title: alignItems.title,
    dataList: alignItems.dataList,
    styleKey: "alignItems",
    longTitle: true
  }, props)), /*#__PURE__*/React.createElement(_row["default"], (0, _extends2["default"])({
    title: flexWrap.title,
    dataList: flexWrap.dataList,
    styleKey: "flexWrap",
    longTitle: true
  }, props))), /*#__PURE__*/React.createElement(_layoutBox["default"], {
    styleData: styleData,
    onStyleChange: onStyleChange,
    layoutPropsConfig: propsConfig,
    unit: unit
  }), isShowWidthHeight && /*#__PURE__*/React.createElement("div", {
    className: "inner-row-contaienr"
  }, /*#__PURE__*/React.createElement("div", {
    className: "row-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "row-item-title"
  }, layoutConfig.width), /*#__PURE__*/React.createElement(_number["default"], (0, _extends2["default"])({
    style: {
      marginRight: '10px',
      width: '100%'
    },
    min: 0,
    styleKey: "width"
  }, props, {
    unit: ['px', '%'],
    useComputedStyle: true
  }))), /*#__PURE__*/React.createElement("div", {
    className: "row-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "row-item-title"
  }, layoutConfig.height), /*#__PURE__*/React.createElement(_number["default"], (0, _extends2["default"])({
    styleKey: "height",
    min: 0
  }, props, {
    style: {
      width: '100%'
    },
    unit: ['px', '%'],
    useComputedStyle: true
  }))))));
};