"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _select = _interopRequireDefault(require("@alifd/next/lib/select"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _collapse = _interopRequireDefault(require("@alifd/next/lib/collapse"));
var React = _interopRequireWildcard(require("react"));
var _colorInput = _interopRequireDefault(require("../../components/color-input"));
var _locale = require("./locale");
var _utils = require("../../utils");
require("./index.less");
var _styleItemSetter = _interopRequireDefault(require("../../components/style-item-setter"));
var _radioGroup = _interopRequireDefault(require("../../components/radio-group"));
var _styleSizeSetter = _interopRequireDefault(require("../../components/style-size-setter"));
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 fontConfig = (0, _locale.intlLocal)();
var _default = exports["default"] = function _default(props) {
  var styleData = props.styleData,
    onStyleChange = props.onStyleChange,
    fontPropsConfig = props.fontPropsConfig;
  var defaultFontPropsConfig = {
    // display 展示列表
    fontFamilyList: [{
      value: 'Helvetica',
      label: 'Helvetica'
    }, {
      value: 'Arial',
      label: 'Arial'
    }, {
      value: 'serif',
      label: 'serif'
    }]
  };

  // 配置合并
  var propsConfig = (0, _extends2["default"])({}, defaultFontPropsConfig, fontPropsConfig);
  var fontWeight = fontConfig.fontWeight,
    textAlign = fontConfig.textAlign;
  var onNumberChange = function onNumberChange(styleKey, value, unit) {
    onStyleChange === null || onStyleChange === void 0 ? void 0 : onStyleChange([{
      styleKey: styleKey,
      value: unit ? (0, _utils.addUnit)(value, unit) : value
    }]);
  };
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
    className: "lc-field lc-block-field",
    style: {
      background: "white"
    }
  }, /*#__PURE__*/React.createElement("div", {
    className: "lc-field-head"
  }, "\u5B57\u4F53"), /*#__PURE__*/React.createElement("div", {
    className: "lc-field-body"
  }, /*#__PURE__*/React.createElement(_styleItemSetter["default"].TowColumnLayout, null, /*#__PURE__*/React.createElement(_styleItemSetter["default"], {
    label: fontConfig.fontSize,
    dataInput: /*#__PURE__*/React.createElement(_styleSizeSetter["default"], {
      styleData: styleData,
      styleKey: "fontSize",
      onStyleChange: onStyleChange
    })
  }), /*#__PURE__*/React.createElement(_styleItemSetter["default"], {
    label: fontConfig.lineHeight,
    dataInput: /*#__PURE__*/React.createElement(_styleSizeSetter["default"], {
      styleData: styleData,
      styleKey: "lineHeight",
      onStyleChange: onStyleChange
    })
  }), /*#__PURE__*/React.createElement(_styleItemSetter["default"], {
    label: fontConfig.fontWeight.title,
    dataInput: /*#__PURE__*/React.createElement(_select["default"], {
      dataSource: fontWeight.dataList,
      style: {
        width: '100%'
      },
      value: styleData.fontWeight,
      hasClear: true,
      onChange: function onChange(val) {
        return onStyleChange === null || onStyleChange === void 0 ? void 0 : onStyleChange([{
          styleKey: 'fontWeight',
          value: val
        }]);
      }
    })
  }), /*#__PURE__*/React.createElement(_styleItemSetter["default"], {
    label: "字体",
    dataInput: /*#__PURE__*/React.createElement(_select["default"], {
      dataSource: propsConfig.fontFamilyList,
      style: {
        width: '100%'
      },
      value: styleData.fontFamily,
      hasClear: true,
      onChange: function onChange(val) {
        return onStyleChange === null || onStyleChange === void 0 ? void 0 : onStyleChange([{
          styleKey: 'fontFamily',
          value: val
        }]);
      }
    })
  }), /*#__PURE__*/React.createElement(_styleItemSetter["default"], {
    label: "颜色",
    dataInput: /*#__PURE__*/React.createElement(_colorInput["default"], (0, _extends2["default"])({
      styleKey: 'color'
    }, props, {
      inputWidth: "100%"
    }))
  }), /*#__PURE__*/React.createElement(_styleItemSetter["default"], {
    label: "对齐",
    dataInput: /*#__PURE__*/React.createElement(_radioGroup["default"], (0, _extends2["default"])({
      styleKey: 'textAlign',
      dataList: textAlign.dataList
    }, props))
  })))));
};