wix-style-react
Version:
wix-style-react
66 lines (54 loc) • 3.3 kB
JavaScript
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
import React from 'react';
import PropTypes from 'prop-types';
import WixComponent from '../../BaseComponents/WixComponent';
import DraggableSource from './components/DraggableSource';
import DraggableTarget from './components/DraggableTarget';
export var Draggable = function (_WixComponent) {
_inherits(Draggable, _WixComponent);
function Draggable() {
_classCallCheck(this, Draggable);
return _possibleConstructorReturn(this, (Draggable.__proto__ || Object.getPrototypeOf(Draggable)).apply(this, arguments));
}
_createClass(Draggable, [{
key: 'render',
value: function render() {
return React.createElement(
DraggableTarget,
this.props,
React.createElement(DraggableSource, this.props)
);
}
}]);
return Draggable;
}(WixComponent);
Draggable.propTypes = {
/** decide whether to render a handle using `connectHandle` (see below) */
withHandle: PropTypes.bool,
/** uniq id of container that contain current draggable item */
containerId: PropTypes.string,
/* name of group between inside of each dnd is allowed */
groupName: PropTypes.string,
/* custom renderer for item */
renderItem: PropTypes.func,
/* position of item in container items array */
index: PropTypes.number,
/* uniq id of an item */
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
/* model that represent item */
item: PropTypes.object,
/** callback when item was moved out from current container to another container */
onMoveOut: PropTypes.func,
/** callback when item was dropped in a new location */
onDrop: PropTypes.func,
/** callback when item is hovered*/
onHover: PropTypes.func,
/** callback for drag start */
onDragStart: PropTypes.func,
/** callback for drag end */
onDragEnd: PropTypes.func
};
export default Draggable;