function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

import PropTypes from 'prop-types';
import React from 'react';
import { Draggable } from 'react-beautiful-dnd';

var DraggableItem = function DraggableItem(_ref) {
  var id = _ref.id,
      index = _ref.index,
      item = _ref.item,
      renderFunc = _ref.renderFunc,
      useCustomDragHandle = _ref.useCustomDragHandle;
  return React.createElement(Draggable, {
    key: item.id,
    draggableId: id.toString(),
    index: index
  }, function (provided, snapshot) {
    return React.createElement("li", _extends({
      className: "oui-sortable__item flex",
      ref: provided.innerRef
    }, provided.draggableProps, useCustomDragHandle ? {} : provided.dragHandleProps), renderFunc({
      item: item,
      index: index,
      snapshot: snapshot,
      dragHandleProps: provided.dragHandleProps
    }));
  });
};

DraggableItem.propTypes = {
  /**
   * Id for this particular Draggable Item
   */
  id: PropTypes.number.isRequired,

  /**
   * Current index for this particular Draggable Item
   */
  index: PropTypes.number.isRequired,

  /**
   * Item to render using render function pass as prop
   */
  item: PropTypes.shape({
    id: PropTypes.number
  }).isRequired,

  /**
   * Function used to render the contents of this Draggable Item
   */
  renderFunc: PropTypes.func.isRequired,

  /**
   * Whether or not the item itself will make use of the drag handle
   */
  useCustomDragHandle: PropTypes.bool
};
export default DraggableItem;