"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
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 _IntroductionExampleSt = require("./IntroductionExample.st.css");
var _ = require("../../..");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/DragAndDrop/docs/Introduction/IntroductionExample.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; })(); }
/**
 * An example for a simple drag and drop list component.
 */
var IntroductionExample = exports["default"] = /*#__PURE__*/function (_React$Component) {
  function IntroductionExample() {
    var _this;
    (0, _classCallCheck2["default"])(this, IntroductionExample);
    _this = _callSuper(this, IntroductionExample);
    _this.handleDrop = function (_ref) {
      var removedIndex = _ref.removedIndex,
        addedIndex = _ref.addedIndex;
      var nextItems = (0, _toConsumableArray2["default"])(_this.state.items);
      nextItems.splice.apply(nextItems, [addedIndex, 0].concat((0, _toConsumableArray2["default"])(nextItems.splice(removedIndex, 1))));
      _this.setState({
        items: nextItems
      });
    };
    _this.renderItem = function (_ref2) {
      var isPlaceholder = _ref2.isPlaceholder,
        isPreview = _ref2.isPreview,
        id = _ref2.id,
        previewStyles = _ref2.previewStyles,
        item = _ref2.item;
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: (0, _IntroductionExampleSt.st)(_IntroductionExampleSt.classes.root, {
          placeholder: isPlaceholder,
          preview: isPreview
        }),
        style: previewStyles,
        "data-hook": "item-".concat(id),
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 59,
          columnNumber: 7
        }
      }, item.text);
    };
    _this.state = {
      items: [{
        id: 'a',
        text: 'Item 1'
      }, {
        id: 'b',
        text: 'Item 2'
      }, {
        id: 'c',
        text: 'Item 3'
      }, {
        id: 'd',
        text: 'Item 4'
      }, {
        id: 'e',
        text: 'Item 5'
      }, {
        id: 'f',
        text: 'Item 6'
      }, {
        id: 'g',
        text: 'Item 7'
      }, {
        id: 'h',
        text: 'Item 8'
      }]
    };
    return _this;
  }
  (0, _inherits2["default"])(IntroductionExample, _React$Component);
  return (0, _createClass2["default"])(IntroductionExample, [{
    key: "render",
    value: function render() {
      return /*#__PURE__*/_react["default"].createElement(_.SortableListBase, {
        containerId: "single-area-1",
        dataHook: "list-single-area",
        items: this.state.items,
        renderItem: this.renderItem,
        onDrop: this.handleDrop,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 74,
          columnNumber: 7
        }
      });
    }
  }]);
}(_react["default"].Component);