ffr-components
Version:
Fiori styled UI components
74 lines (62 loc) • 2.24 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";
// Import React Framework
import React, { Component } from 'react';
var Droppable =
/*#__PURE__*/
function (_Component) {
_inherits(Droppable, _Component);
function Droppable() {
var _getPrototypeOf2;
var _this;
_classCallCheck(this, Droppable);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Droppable)).call.apply(_getPrototypeOf2, [this].concat(args)));
_this.handleDragOver = function (e) {
var _this$props = _this.props,
dragOver = _this$props.dragOver,
droppableId = _this$props.droppableId;
dragOver && dragOver(e, droppableId);
};
return _this;
}
_createClass(Droppable, [{
key: "render",
value: function render() {
var _this2 = this;
var _this$props2 = this.props,
children = _this$props2.children,
dropClass = _this$props2.dropClass,
dragStart = _this$props2.dragStart,
dragEnd = _this$props2.dragEnd,
droppableId = _this$props2.droppableId;
return React.Children.map(children, function (child) {
var itemChild = child.props.children;
itemChild = React.Children.map(itemChild, function (innerChild) {
return React.cloneElement(innerChild, {
dragStart: dragStart,
droppableId: droppableId,
dragEnd: dragEnd
});
});
var _props = {
className: dropClass,
children: itemChild,
onDragOver: _this2.handleDragOver
};
return React.cloneElement(child, _props);
});
}
}]);
return Droppable;
}(Component);
Droppable.defaultProps = {
dropClass: '',
droppableId: '-1'
};
export { Droppable as default };