"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.sizeTypeList = exports["default"] = void 0;

var _react = _interopRequireWildcard(require("react"));

var _antd = require("antd");

require("./index.less");

var _mobx = require("../../../mobx");

var _common = require("../../../common");

var _BaseConfig = _interopRequireDefault(require("../BaseConfig"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

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; }

function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

var __extends = void 0 && (void 0).__extends || function () {
  var _extendStatics = function extendStatics(d, b) {
    _extendStatics = Object.setPrototypeOf || {
      __proto__: []
    } instanceof Array && function (d, b) {
      d.__proto__ = b;
    } || function (d, b) {
      for (var p in b) {
        if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
      }
    };

    return _extendStatics(d, b);
  };

  return function (d, b) {
    if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");

    _extendStatics(d, b);

    function __() {
      this.constructor = d;
    }

    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
}();

var __assign = void 0 && (void 0).__assign || function () {
  __assign = Object.assign || function (t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];

      for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
      }
    }

    return t;
  };

  return __assign.apply(this, arguments);
};

/** 预设字体样式 */
var sizeTypeList = [{
  key: 'Headline 1',
  fontFamily: 'Montserrat',
  fontSize: 68,
  fontWeight: 600
}, {
  key: 'Headline 2',
  fontFamily: 'Montserrat',
  fontSize: 42,
  fontWeight: 600
}, {
  key: 'Headline 3',
  fontFamily: 'Montserrat',
  fontSize: 38,
  fontWeight: 600
}, {
  key: 'Title 1',
  fontFamily: 'Montserrat',
  fontSize: 32,
  fontWeight: 400
}, {
  key: 'Title 2',
  fontFamily: 'Montserrat',
  fontSize: 24,
  fontWeight: 400
}, {
  key: 'Title 3',
  fontFamily: 'Montserrat',
  fontSize: 20,
  fontWeight: 400
}, {
  key: 'Body 1',
  fontFamily: 'Open Sans',
  fontSize: 18,
  fontWeight: 400
}, {
  key: 'Body 2',
  fontFamily: 'Open Sans',
  fontSize: 16,
  fontWeight: 400
}, {
  key: 'Body 3',
  fontFamily: 'Open Sans',
  fontSize: 14,
  fontWeight: 400
}];
exports.sizeTypeList = sizeTypeList;

var TextConfig =
/** @class */
function (_super) {
  __extends(TextConfig, _super);

  function TextConfig() {
    var _this = _super !== null && _super.apply(this, arguments) || this;

    _this.state = {};

    _this.onSizeTypeChange = function (v, obj) {
      _extends(obj, sizeTypeMap[v]);
    };

    return _this;
  }

  TextConfig.prototype.componentDidMount = function () {
    window.document.addEventListener('text-render', this.selfRender);
  };

  TextConfig.prototype.componentWillUnmount = function () {
    window.document.removeEventListener('text-render', this.selfRender);
  };

  TextConfig.prototype.render = function () {
    var _this = this;

    var data = this.props.data;
    var textData = _mobx.store.textSelection ? _mobx.store.textSelection : data.content; // const textData = data.content;

    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "m-text-config"
    }, /*#__PURE__*/_react["default"].createElement(_common.Collapse, {
      divider: "dashed",
      headerSize: "small",
      onRefresh: this.selfRender,
      source: [{
        key: '1',
        name: 'Content',
        value: /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement(_common.Field, {
          title: "Font Style"
        }, /*#__PURE__*/_react["default"].createElement(_antd.Select, {
          onChange: function onChange(v) {
            var findOne = sizeTypeList.find(function (t) {
              return t.key == v;
            });

            _extends(textData, __assign(__assign({}, findOne), {
              sizeType: findOne === null || findOne === void 0 ? void 0 : findOne.key
            }));

            _this.selfRender();
          },
          value: textData.sizeType
        }, sizeTypeList.map(function (sizeType) {
          return /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
            key: sizeType.key,
            value: sizeType.key
          }, sizeType.key);
        }))), /*#__PURE__*/_react["default"].createElement(_common.Field, {
          title: "font Family"
        }, /*#__PURE__*/_react["default"].createElement(_antd.Select, {
          onChange: function onChange(v) {
            textData.fontFamily = v;

            _this.selfRender();
          },
          value: textData.fontFamily
        }, /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
          value: "Montserrat"
        }, "Montserrat"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
          value: "Open Sans"
        }, "Open Sans"))), /*#__PURE__*/_react["default"].createElement(_common.Field, {
          title: "font Weight"
        }, /*#__PURE__*/_react["default"].createElement(_antd.Select, {
          onChange: function onChange(v) {
            textData.fontWeight = v;

            _this.selfRender();
          },
          value: textData.fontWeight
        }, /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
          value: 400
        }, "Regular"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
          value: 600
        }, "Medium"))), /*#__PURE__*/_react["default"].createElement(_common.Field, {
          title: "Font Size"
        }, /*#__PURE__*/_react["default"].createElement(_common.Slider, {
          onChange: function onChange(_a) {
            var count = _a.count;
            textData.fontSize = count;

            _this.selfRender();
          },
          unit: "px",
          value: {
            count: textData.fontSize
          }
        })), /*#__PURE__*/_react["default"].createElement(_common.Field, {
          title: ""
        }, /*#__PURE__*/_react["default"].createElement(_common.FontStyles, {
          onChange: function onChange(value) {
            _extends(textData, value);

            _this.selfRender();
          },
          showTextAlign: true,
          value: textData
        })), /*#__PURE__*/_react["default"].createElement(_common.Field, {
          split: true,
          title: "URL"
        }, /*#__PURE__*/_react["default"].createElement(_common.UrlPicker, {
          onChange: function onChange(v) {
            textData.clickUrl = v;

            _this.selfRender();
          },
          value: data.content.clickUrl
        })), /*#__PURE__*/_react["default"].createElement(_common.Field, {
          title: "Content Width"
        }, /*#__PURE__*/_react["default"].createElement(_common.Slider, {
          maxVal: 1760,
          minVal: 0,
          onChange: function onChange(_a) {
            var count = _a.count;
            textData.width = count;

            _this.selfRender();
          },
          unit: "px",
          value: {
            count: textData.width
          }
        })))
      }, {
        key: '2',
        name: 'Underline Setting',
        value: /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement(_common.Field, {
          split: true,
          title: "Underline Color"
        }, /*#__PURE__*/_react["default"].createElement(_common.ColorPickerInput, {
          onChange: function onChange(v) {
            data.underline.textDecorationColor = v;

            _this.selfRender();
          },
          value: data.underline.textDecorationColor
        })), /*#__PURE__*/_react["default"].createElement(_common.Field, {
          title: "Underline Style"
        }, /*#__PURE__*/_react["default"].createElement(_antd.Select, {
          onChange: function onChange(v) {
            data.underline.textDecorationStyle = v;

            _this.selfRender();
          },
          value: data.underline.textDecorationStyle
        }, /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
          value: "solid"
        }, "\u5B9E\u7EBF"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
          value: "dashed"
        }, "\u865A\u7EBF"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
          value: "double"
        }, "\u53CC\u5B9E\u7EBF"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
          value: "wavy"
        }, "\u6CE2\u6D6A\u7EBF")))),
        metaOption: data.underline,
        toggleType: 'checkbox'
      }],
      type: "arrow"
    }));
  };

  TextConfig.defaultProps = {
    data: null
  };
  return TextConfig;
}(_BaseConfig["default"]);

var _default = TextConfig;
exports["default"] = _default;