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

var _button = _interopRequireDefault(require("../../button"));

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

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

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

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var dataSource = [{
  price: 'US $1',
  status: 1,
  parent: 'root',
  id: 1,
  product: [{
    title: "2014 New Fashion Novelty Tank Slim Women's Fashion Dresses With Lace",
    avatar: 'https://sc01.alicdn.com/kf/HTB1ravHKXXXXXccXVXXq6xXFXXXJ/Chinese-Style-Fashion-Custom-Digital-Print-Silk.jpg_220x220.jpg'
  }],
  children: [{
    price: 'US $1-1',
    status: 11,
    id: 2,
    parent: 0,
    index: 0,
    product: [{
      title: 'Free shipping women Casual dresses lady dress plus size 2014',
      avatar: 'https://sc02.alicdn.com/kf/HTB1efnNLVXXXXbtXpXXq6xXFXXXN/Light-100-acrylic-fashionabe-snood-shawl-weight.jpg_220x220.jpg'
    }]
  }, {
    price: 'US $1-2',
    status: 12,
    id: 3,
    parent: 0,
    product: [{
      title: 'Free shipping women Casual dresses lady dress plus size 2014',
      avatar: 'https://sc02.alicdn.com/kf/HTB1efnNLVXXXXbtXpXXq6xXFXXXN/Light-100-acrylic-fashionabe-snood-shawl-weight.jpg_220x220.jpg'
    }]
  }, {
    price: 'US $1-3',
    status: 13,
    id: 7,
    parent: 0,
    product: [{
      title: 'Free shipping women Casual dresses lady dress plus size 2014',
      avatar: 'https://sc02.alicdn.com/kf/HTB1efnNLVXXXXbtXpXXq6xXFXXXN/Light-100-acrylic-fashionabe-snood-shawl-weight.jpg_220x220.jpg'
    }]
  }]
}, {
  price: 'US $3',
  status: 3,
  parent: 'root',
  id: 3,
  product: [{
    title: "2014 New Fashion Novelty Tank Slim Women's Fashion Dresses With Lace",
    avatar: 'https://sc01.alicdn.com/kf/HTB1ravHKXXXXXccXVXXq6xXFXXXJ/Chinese-Style-Fashion-Custom-Digital-Print-Silk.jpg_220x220.jpg'
  }],
  children: [{
    price: 'US $3-1',
    status: 31,
    id: 31,
    parent: 1,
    index: 0,
    product: [{
      title: 'Free shipping women Casual dresses lady dress plus size 2014',
      avatar: 'https://sc02.alicdn.com/kf/HTB1efnNLVXXXXbtXpXXq6xXFXXXN/Light-100-acrylic-fashionabe-snood-shawl-weight.jpg_220x220.jpg'
    }]
  }, {
    price: 'US $3-2',
    status: 32,
    id: 32,
    parent: 1,
    product: [{
      title: 'Free shipping women Casual dresses lady dress plus size 2014',
      avatar: 'https://sc02.alicdn.com/kf/HTB1efnNLVXXXXbtXpXXq6xXFXXXN/Light-100-acrylic-fashionabe-snood-shawl-weight.jpg_220x220.jpg'
    }]
  }, {
    price: 'US $3-3',
    status: 33,
    id: 33,
    parent: 1,
    product: [{
      title: 'Free shipping women Casual dresses lady dress plus size 2014',
      avatar: 'https://sc02.alicdn.com/kf/HTB1efnNLVXXXXbtXpXXq6xXFXXXN/Light-100-acrylic-fashionabe-snood-shawl-weight.jpg_220x220.jpg'
    }]
  }, {
    price: 'US $3-4',
    status: 34,
    id: 34,
    parent: 1,
    product: [{
      title: 'Free shipping women Casual dresses lady dress plus size 2014',
      avatar: 'https://sc02.alicdn.com/kf/HTB1efnNLVXXXXbtXpXXq6xXFXXXN/Light-100-acrylic-fashionabe-snood-shawl-weight.jpg_220x220.jpg'
    }]
  }]
}, {
  price: 'US $4',
  status: 4,
  parent: 'root',
  id: 4,
  product: [{
    title: "2014 New Fashion Novelty Tank Slim Women's Fashion Dresses With Lace",
    avatar: 'https://sc01.alicdn.com/kf/HTB1ravHKXXXXXccXVXXq6xXFXXXJ/Chinese-Style-Fashion-Custom-Digital-Print-Silk.jpg_220x220.jpg'
  }],
  children: [{
    price: 'US $4-1',
    status: 31,
    id: 31,
    parent: 2,
    index: 0,
    product: [{
      title: 'Free shipping women Casual dresses lady dress plus size 2014',
      avatar: 'https://sc02.alicdn.com/kf/HTB1efnNLVXXXXbtXpXXq6xXFXXXN/Light-100-acrylic-fashionabe-snood-shawl-weight.jpg_220x220.jpg'
    }]
  }, {
    price: 'US $4-2',
    status: 32,
    id: 32,
    parent: 2,
    product: [{
      title: 'Free shipping women Casual dresses lady dress plus size 2014',
      avatar: 'https://sc02.alicdn.com/kf/HTB1efnNLVXXXXbtXpXXq6xXFXXXN/Light-100-acrylic-fashionabe-snood-shawl-weight.jpg_220x220.jpg'
    }]
  }, {
    price: 'US $4-3',
    status: 33,
    id: 33,
    parent: 2,
    product: [{
      title: 'Free shipping women Casual dresses lady dress plus size 2014',
      avatar: 'https://sc02.alicdn.com/kf/HTB1efnNLVXXXXbtXpXXq6xXFXXXN/Light-100-acrylic-fashionabe-snood-shawl-weight.jpg_220x220.jpg'
    }]
  }]
}],
    productRender = function productRender(product) {
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "media"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: product[0].avatar,
    className: "media-side"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "media-content"
  }, product[0].title));
},
    priceRender = function priceRender(price) {
  return /*#__PURE__*/_react["default"].createElement("b", null, price);
},
    statusRender = function statusRender(status) {
  if (status) {
    return 'Already Priced';
  }

  return 'No Priced';
},
    operRender = function operRender() {
  return /*#__PURE__*/_react["default"].createElement("a", {
    href: "javascript:;"
  }, "View"); // eslint-disable-line
},
    groupHeaderRender = function groupHeaderRender(record) {
  return /*#__PURE__*/_react["default"].createElement("div", null, record.product[0].title);
},
    rowSelection = {
  onChange: function onChange(selectedKeys) {
    console.log(selectedKeys);
  }
};

var cellProps = function cellProps(rowIndex, colIndex, dataIndex, record) {
  if (colIndex === 3 && record.index === 0) {
    return {
      rowSpan: dataSource[record.parent].children.length
    };
  }

  if (colIndex === 4 && record.index === 0) {
    return {
      rowSpan: dataSource[record.parent].children.length
    };
  }
};

var App = /*#__PURE__*/function (_React$Component) {
  _inherits(App, _React$Component);

  var _super = _createSuper(App);

  function App() {
    var _this;

    _classCallCheck(this, App);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));

    _defineProperty(_assertThisInitialized(_this), "state", {
      hasSelection: false
    });

    _defineProperty(_assertThisInitialized(_this), "toggleGroupSelection", function () {
      _this.setState({
        hasSelection: !_this.state.hasSelection
      });
    });

    return _this;
  }

  _createClass(App, [{
    key: "render",
    value: function render() {
      return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("p", null, /*#__PURE__*/_react["default"].createElement(_button["default"], {
        onClick: this.toggleGroupSelection
      }, "Toggle GroupHeader Selection")), /*#__PURE__*/_react["default"].createElement(_["default"], {
        dataSource: dataSource,
        rowSelection: rowSelection,
        cellProps: cellProps
      }, /*#__PURE__*/_react["default"].createElement(_["default"].GroupHeader, {
        cell: groupHeaderRender,
        hasChildrenSelection: this.state.hasSelection
      }), /*#__PURE__*/_react["default"].createElement(_["default"].GroupFooter, {
        cell: groupHeaderRender
      }), /*#__PURE__*/_react["default"].createElement(_["default"].Column, {
        cell: productRender,
        title: "Product Details",
        dataIndex: "product"
      }), /*#__PURE__*/_react["default"].createElement(_["default"].Column, {
        cell: priceRender,
        title: "Price",
        dataIndex: "price",
        width: 120
      }), /*#__PURE__*/_react["default"].createElement(_["default"].Column, {
        cell: statusRender,
        title: "Status",
        dataIndex: "status",
        width: 100
      }), /*#__PURE__*/_react["default"].createElement(_["default"].Column, {
        cell: operRender,
        title: "Operation",
        width: 100
      })));
    }
  }]);

  return App;
}(_react["default"].Component);

_reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(App, null), document.getElementById('table-demo-13'));