"use strict";

require("./demo8.css");

var _box = _interopRequireDefault(require("../../box"));

var _ = _interopRequireDefault(require(".."));

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

var _reactDom = _interopRequireDefault(require("react-dom"));

var _excluded = ["dataSource"],
    _excluded2 = ["dataSource"];

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

function _extends() { _extends = Object.assign || 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); }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var PopupItem = _["default"].PopupItem,
    Divider = _["default"].Divider;
var popupProps = {
  align: 'tc bc',
  triggerType: 'click'
};
var ds = [{
  title: '库存管理',
  children: [{
    title: '部门库存管理',
    link: ''
  }, {
    title: '小二库存管理',
    link: ''
  }]
}, {
  title: '功能模块管理',
  children: [{
    title: '功能模块管理',
    link: ''
  }, {
    title: '卡片管理',
    link: ''
  }, {
    title: '首页布局',
    link: ''
  }, {
    title: '页面管理',
    link: ''
  }]
}, {
  title: '系统管理',
  children: [{
    title: '角色管理',
    link: ''
  }, {
    title: '标签管理',
    link: ''
  }, {
    title: '字典管理',
    link: ''
  }]
}];

var Panel = function Panel(props) {
  var dataSource = props.dataSource,
      others = _objectWithoutProperties(props, _excluded);

  return /*#__PURE__*/_react["default"].createElement("div", _extends({
    className: "my-custom-content3"
  }, others), /*#__PURE__*/_react["default"].createElement(_box["default"], {
    direction: "row"
  }, dataSource.map(function (item, i) {
    return /*#__PURE__*/_react["default"].createElement(_["default"], {
      embeddable: true,
      key: i
    }, /*#__PURE__*/_react["default"].createElement(_["default"].Item, null, /*#__PURE__*/_react["default"].createElement("div", {
      className: "title"
    }, item.title)), /*#__PURE__*/_react["default"].createElement(Divider, null), item.dataSource.map(function (child, g) {
      var a = child.children && child.children.map(function (c, j) {
        return /*#__PURE__*/_react["default"].createElement(_["default"].Item, {
          key: j
        }, /*#__PURE__*/_react["default"].createElement("a", {
          href: c.link
        }, c.title));
      });
      return [/*#__PURE__*/_react["default"].createElement("div", {
        className: "sub-title",
        key: "title-".concat(g)
      }, child.title)].concat(_toConsumableArray(a));
    }));
  })));
};

var SubPanel = function SubPanel(props) {
  var dataSource = props.dataSource,
      others = _objectWithoutProperties(props, _excluded2);

  return /*#__PURE__*/_react["default"].createElement("div", _extends({
    className: "my-custom-content2"
  }, others), /*#__PURE__*/_react["default"].createElement(_box["default"], {
    direction: "row"
  }, dataSource.map(function (item, i) {
    return /*#__PURE__*/_react["default"].createElement(_["default"], {
      embeddable: true,
      key: i
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "sub-title"
    }, item.title), item.children.map(function (child, j) {
      return /*#__PURE__*/_react["default"].createElement(_["default"].Item, {
        key: j
      }, /*#__PURE__*/_react["default"].createElement("a", {
        href: child.link
      }, child.title));
    }));
  })));
};

_reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(_["default"] // @ts-ignore
, {
  hozInLine: true,
  direction: "hoz",
  mode: "popup",
  className: "my-hoz-menu",
  popupClassName: "my-hoz-menu",
  popupProps: popupProps,
  renderMore: function renderMore(more) {
    var newDs = more.map(function (item) {
      var data = item.props.children.props;
      return {
        title: item.props.label,
        dataSource: data.dataSource
      };
    });
    return /*#__PURE__*/_react["default"].createElement(PopupItem // @ts-ignore
    , {
      noIcon: true,
      triggerType: "click",
      key: "0-more",
      label: "\u66F4\u591A"
    }, /*#__PURE__*/_react["default"].createElement(Panel, {
      dataSource: newDs
    }));
  }
}, /*#__PURE__*/_react["default"].createElement(PopupItem, {
  key: "0",
  label: "Popup item 1" // @ts-ignore
  ,
  noIcon: true
}, /*#__PURE__*/_react["default"].createElement(SubPanel, {
  dataSource: ds
})), /*#__PURE__*/_react["default"].createElement(PopupItem, {
  key: "1",
  label: "Popup item 2" // @ts-ignore
  ,
  noIcon: true
}, /*#__PURE__*/_react["default"].createElement(SubPanel, {
  dataSource: ds
})), /*#__PURE__*/_react["default"].createElement(PopupItem, {
  key: "2",
  label: "Popup item 3" // @ts-ignore
  ,
  noIcon: true
}, /*#__PURE__*/_react["default"].createElement(SubPanel, {
  dataSource: ds
})), /*#__PURE__*/_react["default"].createElement(PopupItem, {
  key: "3",
  label: "Popup item 4" // @ts-ignore
  ,
  noIcon: true
}, /*#__PURE__*/_react["default"].createElement(SubPanel, {
  dataSource: ds
})), /*#__PURE__*/_react["default"].createElement(PopupItem, {
  key: "4",
  label: "Popup item 5" // @ts-ignore
  ,
  noIcon: true
}, /*#__PURE__*/_react["default"].createElement(SubPanel, {
  dataSource: ds
})), /*#__PURE__*/_react["default"].createElement(PopupItem, {
  key: "5",
  label: "Popup item 6" // @ts-ignore
  ,
  noIcon: true
}, /*#__PURE__*/_react["default"].createElement(SubPanel, {
  dataSource: ds
})), /*#__PURE__*/_react["default"].createElement(PopupItem, {
  key: "6",
  label: "Popup item 7" // @ts-ignore
  ,
  noIcon: true
}, /*#__PURE__*/_react["default"].createElement(SubPanel, {
  dataSource: ds
})), /*#__PURE__*/_react["default"].createElement(PopupItem, {
  key: "7",
  label: "Popup item 8" // @ts-ignore
  ,
  noIcon: true
}, /*#__PURE__*/_react["default"].createElement(SubPanel, {
  dataSource: ds
})), /*#__PURE__*/_react["default"].createElement(PopupItem, {
  key: "8",
  label: "Popup item 9" // @ts-ignore
  ,
  noIcon: true
}, /*#__PURE__*/_react["default"].createElement(SubPanel, {
  dataSource: ds
}))), document.getElementById('menu-demo-8'));