"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = _interopRequireDefault(require("react"));
var _ = _interopRequireDefault(require(".."));
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/Table/DataTable/docs/ExampleCallingServer.jsx";
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var style = {
  width: '966px'
};
var baseData = [{
  firstName: 'Meghan',
  lastName: 'Bishop'
}, {
  firstName: 'Sara',
  lastName: 'Porter'
}, {
  firstName: 'Deborah',
  lastName: 'Rhodes'
}, {
  firstName: 'Walter',
  lastName: 'Jenning'
}];
var generateData = function generateData(count) {
  var data = [];
  for (var i = 0; i < count; i++) {
    data = data.concat(baseData);
  }
  return data;
};
var DataTableExample = /*#__PURE__*/function (_React$Component) {
  function DataTableExample(props) {
    var _this;
    (0, _classCallCheck2["default"])(this, DataTableExample);
    _this = _callSuper(this, DataTableExample, [props]);
    _this.state = {
      hasMore: true,
      count: 5
    };
    _this.loadMore = _this.loadMore.bind(_this);
    return _this;
  }
  (0, _inherits2["default"])(DataTableExample, _React$Component);
  return (0, _createClass2["default"])(DataTableExample, [{
    key: "loadMore",
    value: function loadMore() {
      var _this2 = this;
      var loadMoreData = function loadMoreData() {
        _this2.setState({
          count: _this2.state.count + 5
        });
        if (_this2.state.count > 20) {
          _this2.setState({
            hasMore: false
          });
        }
      };
      setTimeout(loadMoreData, 3000);
    }
  }, {
    key: "render",
    value: function render() {
      var _this3 = this;
      return /*#__PURE__*/_react["default"].createElement("div", {
        style: style,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 42,
          columnNumber: 7
        }
      }, /*#__PURE__*/_react["default"].createElement(_["default"], {
        dataHook: "story-data-table-infinite-scroll",
        data: generateData(this.state.count),
        onRowClick: function onRowClick(row, rowNum) {
          window.alert("You clicked \"".concat(row.firstName, " ").concat(row.lastName, "\", row number ").concat(rowNum + 1));
        },
        infiniteScroll: true,
        itemsPerPage: 20,
        columns: [{
          title: 'Row Number',
          render: function render(row, rowNum) {
            return '#' + (rowNum + 1);
          },
          width: '20%',
          important: true
        }, {
          title: 'First Name',
          render: function render(row) {
            return /*#__PURE__*/_react["default"].createElement("span", {
              __self: _this3,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 64,
                columnNumber: 30
              }
            }, row.firstName);
          },
          width: '40%'
        }, {
          title: 'Last Name',
          render: function render(row) {
            return /*#__PURE__*/_react["default"].createElement("span", {
              __self: _this3,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 69,
                columnNumber: 30
              }
            }, row.lastName);
          },
          width: '40%'
        }],
        hasMore: this.state.hasMore,
        loadMore: this.loadMore,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 43,
          columnNumber: 9
        }
      }));
    }
  }]);
}(_react["default"].Component);
var _default = exports["default"] = DataTableExample;