import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/esm/DragAndDrop/docs/SortableListBase/MultiAreaListPreventOfDropping/MultiAreaListPreventDropping.jsx";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(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; })(); }
import React from 'react';
import classNames from 'classnames';
import { dndStyles as defaultDndStyles, SortableListBase, DragDropContextProvider } from '../../../..';
import { classes } from './MultiAreaListPreventDropping.st.css';
var generateStateForContainer = function generateStateForContainer(length, startIndex) {
  var res = [];
  for (var i = 0; i < length; i++) {
    res.push({
      id: 'item' + (startIndex + i),
      text: "Drag object ".concat(startIndex + i)
    });
  }
  return res;
};
var copy = function copy(value) {
  return JSON.parse(JSON.stringify(value));
};

/**
 * An example multi list dnd.
 */
var MultiAreaListPreventDropping = /*#__PURE__*/function (_React$Component) {
  function MultiAreaListPreventDropping() {
    var _this;
    _classCallCheck(this, MultiAreaListPreventDropping);
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _callSuper(this, MultiAreaListPreventDropping, [].concat(args));
    _this.state = {
      multiArea1: generateStateForContainer(4, 1),
      multiArea2: generateStateForContainer(4, 5)
    };
    _this.handleDrop = function (_ref) {
      var removedIndex = _ref.removedIndex,
        addedIndex = _ref.addedIndex,
        removedFromContainerId = _ref.removedFromContainerId,
        addedToContainerId = _ref.addedToContainerId,
        payload = _ref.payload;
      var nextState = copy(_this.state);
      nextState[removedFromContainerId].splice(removedIndex, 1);
      nextState[addedToContainerId].splice(addedIndex, 0, payload);
      _this.setState(_objectSpread({}, nextState));
    };
    _this.renderItem = function (_ref2) {
      var isPlaceholder = _ref2.isPlaceholder,
        isPreview = _ref2.isPreview,
        id = _ref2.id,
        item = _ref2.item,
        previewStyles = _ref2.previewStyles;
      var _classes = classNames(_defineProperty(_defineProperty({}, classNames(defaultDndStyles.itemPlaceholder, classes.itemPlaceholder), isPlaceholder), classNames(defaultDndStyles.itemPreview, classes.itemPreview), isPreview), classNames(defaultDndStyles.item, classes.item));
      return /*#__PURE__*/React.createElement("div", {
        className: _classes,
        style: previewStyles,
        "data-hook": "item-".concat(id),
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 58,
          columnNumber: 7
        }
      }, item.text);
    };
    return _this;
  }
  _inherits(MultiAreaListPreventDropping, _React$Component);
  return _createClass(MultiAreaListPreventDropping, [{
    key: "render",
    value: function render() {
      return /*#__PURE__*/React.createElement(DragDropContextProvider, {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 66,
          columnNumber: 7
        }
      }, /*#__PURE__*/React.createElement("div", {
        className: classes.root,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 67,
          columnNumber: 9
        }
      }, /*#__PURE__*/React.createElement("div", {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 68,
          columnNumber: 11
        }
      }, /*#__PURE__*/React.createElement("h4", {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 69,
          columnNumber: 13
        }
      }, "Drop is not allowed here"), /*#__PURE__*/React.createElement(SortableListBase, {
        className: classNames(defaultDndStyles.list, classes.list),
        dataHook: "list-multi-area",
        groupName: "multi-area",
        containerId: "multiArea1",
        items: this.state.multiArea1,
        renderItem: this.renderItem,
        droppable: false,
        onDrop: this.handleDrop,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 70,
          columnNumber: 13
        }
      })), /*#__PURE__*/React.createElement("div", {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 81,
          columnNumber: 11
        }
      }, /*#__PURE__*/React.createElement("h4", {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 82,
          columnNumber: 13
        }
      }, "You can drop here"), /*#__PURE__*/React.createElement(SortableListBase, {
        className: classNames(defaultDndStyles.list, classes.list),
        dataHook: "list-multi-area",
        groupName: "multi-area",
        containerId: "multiArea2",
        items: this.state.multiArea2,
        renderItem: this.renderItem,
        onDrop: this.handleDrop,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 83,
          columnNumber: 13
        }
      }))));
    }
  }]);
}(React.Component);
export { MultiAreaListPreventDropping as default };