"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
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 _classnames = _interopRequireDefault(require("classnames"));
var _ = require("../../../..");
var _SingleAreaGridSt = require("./SingleAreaGrid.st.css");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/DragAndDrop/docs/SortableGridBase/SingleAreaGrid/SingleAreaGrid.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 generateId = function generateId() {
  return Math.floor(Math.random() * 100000);
};
var SingleAreaGrid = exports["default"] = /*#__PURE__*/function (_React$Component) {
  function SingleAreaGrid() {
    var _this;
    (0, _classCallCheck2["default"])(this, SingleAreaGrid);
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _callSuper(this, SingleAreaGrid, [].concat(args));
    _this.state = {
      items: [{
        id: generateId(),
        text: 'Item 1'
      }, {
        id: generateId(),
        text: 'Item 2'
      }, {
        id: generateId(),
        text: 'Item 3'
      }, {
        id: generateId(),
        text: 'Item 4'
      }, {
        id: generateId(),
        text: 'Item 5'
      }, {
        id: generateId(),
        text: 'Item 6'
      }, {
        id: generateId(),
        text: 'Item 7'
      }, {
        id: generateId(),
        text: 'Item 8'
      }, {
        id: generateId(),
        text: 'Item 9'
      }]
    };
    _this.handleDrop = function () {};
    _this.renderItem = function (_ref) {
      var isPlaceholder = _ref.isPlaceholder,
        isPreview = _ref.isPreview,
        id = _ref.id,
        connectHandle = _ref.connectHandle,
        item = _ref.item,
        withStrip = _ref.withStrip,
        isInitialPositionToDrop = _ref.isInitialPositionToDrop;
      var stripPositionClass = (0, _classnames["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, _.dndStyles.withGridItemStrip, withStrip), _.dndStyles.withGridItemStripRight, withStrip === 'right'));
      var _classes = (0, _classnames["default"])((0, _classnames["default"])(_.dndStyles.item, _SingleAreaGridSt.classes.item, stripPositionClass), (0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, (0, _classnames["default"])(_.dndStyles.gridItemPreview), isPreview), (0, _classnames["default"])(_.dndStyles.gridItemPlaceholder), isPlaceholder), (0, _classnames["default"])(_.dndStyles.isInitialPositionToDrop), isInitialPositionToDrop));
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: _classes,
        "data-hook": "item-".concat(id),
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 64,
          columnNumber: 7
        }
      }, item.text, _this.props.withHandle ? _this.renderHandle({
        connectHandle: connectHandle,
        id: id,
        isPlaceholder: isPlaceholder
      }) : null);
    };
    return _this;
  }
  (0, _inherits2["default"])(SingleAreaGrid, _React$Component);
  return (0, _createClass2["default"])(SingleAreaGrid, [{
    key: "renderHandle",
    value: function renderHandle(_ref2) {
      var connectHandle = _ref2.connectHandle,
        id = _ref2.id,
        isPlaceholder = _ref2.isPlaceholder;
      return connectHandle(/*#__PURE__*/_react["default"].createElement("div", {
        className: _SingleAreaGridSt.classes.handle,
        style: {
          opacity: isPlaceholder ? 0 : 1
        },
        "data-hook": "card-".concat(id, "-handle"),
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 29,
          columnNumber: 7
        }
      }, "Drag Handle"));
    }
  }, {
    key: "render",
    value: function render() {
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: _SingleAreaGridSt.classes.root,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 79,
          columnNumber: 7
        }
      }, /*#__PURE__*/_react["default"].createElement("h3", {
        className: _SingleAreaGridSt.classes.title,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 80,
          columnNumber: 9
        }
      }, "Draggable Area"), /*#__PURE__*/_react["default"].createElement(_.SortableGridBase, {
        withHandle: this.props.withHandle,
        className: _SingleAreaGridSt.classes.sortableGridBase,
        containerId: "single-area-1",
        dataHook: "grid-single-area",
        items: this.state.items,
        renderItem: this.renderItem,
        onDrop: this.handleDrop,
        startFixedElement: this.props.startFixedElement,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 81,
          columnNumber: 9
        }
      }));
    }
  }]);
}(_react["default"].Component);