dragComponent = _ref.__experimentalDragComponent;
var dragComponentRef = Object(external_wp_element_["useRef"])();
var cleanup = Object(external_wp_element_["useRef"])(function () {});
* Removes the element clone, resets cursor, and removes drag listener.
* @param {Object} event The non-custom DragEvent.
* This method does a couple of things:
* - Clones the current element and spawns clone over original element.
* - Adds a fake temporary drag image to avoid browser defaults.
* - Adds dragover listener.
* @param {Object} event The non-custom DragEvent.
var ownerDocument = event.target.ownerDocument;
event.dataTransfer.setData('text', JSON.stringify(transferData));
var cloneWrapper = ownerDocument.createElement('div');
var dragImage = ownerDocument.createElement('div'); // Set a fake drag image to avoid browser defaults. Remove from DOM
// right after. event.dataTransfer.setDragImage is not supported yet in
// IE, we need to check for its existence first.
if ('function' === typeof event.dataTransfer.setDragImage) {
dragImage.classList.add(dragImageClass);
ownerDocument.body.appendChild(dragImage);
event.dataTransfer.setDragImage(dragImage, 0, 0);
cloneWrapper.classList.add(cloneWrapperClass);
cloneWrapper.classList.add(cloneClassname);
} // If a dragComponent is defined, the following logic will clone the
// HTML node and inject it into the cloneWrapper.
if (dragComponentRef.current) {
// Position dragComponent at the same position as the cursor.
cloneWrapper.style.top = "".concat(event.clientY, "px");
cloneWrapper.style.left = "".concat(event.clientX, "px");
var clonedDragComponent = ownerDocument.createElement('div');
clonedDragComponent.innerHTML = dragComponentRef.current.innerHTML;
cloneWrapper.appendChild(clonedDragComponent); // Inject the cloneWrapper into the DOM.
ownerDocument.body.appendChild(cloneWrapper);
var element = ownerDocument.getElementById(elementId); // Prepare element clone and append to element wrapper.
var elementRect = element.getBoundingClientRect();
var elementWrapper = element.parentNode;
var elementTopOffset = parseInt(elementRect.top, 10);
var elementLeftOffset = parseInt(elementRect.left, 10);
cloneWrapper.style.width = "".concat(elementRect.width + clonePadding * 2, "px");
var clone = element.cloneNode(true);
clone.id = "clone-".concat(elementId);
if (elementRect.height > cloneHeightTransformationBreakpoint) {
// Scale down clone if original element is larger than 700px.
cloneWrapper.style.transform = 'scale(0.5)';
cloneWrapper.style.transformOrigin = 'top left'; // Position clone near the cursor.
cloneWrapper.style.top = "".concat(event.clientY - 100, "px");
cloneWrapper.style.left = "".concat(event.clientX, "px");
// Position clone right over the original element (20px padding).
cloneWrapper.style.top = "".concat(elementTopOffset - clonePadding, "px");
cloneWrapper.style.left = "".concat(elementLeftOffset - clonePadding, "px");
} // Hack: Remove iFrames as it's causing the embeds drag clone to freeze
Array.from(clone.querySelectorAll('iframe')).forEach(function (child) {
return child.parentNode.removeChild(child);
cloneWrapper.appendChild(clone); // Inject the cloneWrapper into the DOM.
elementWrapper.appendChild(cloneWrapper);
} // Mark the current cursor coordinates.
var cursorLeft = event.clientX;
var cursorTop = event.clientY;
cloneWrapper.style.top = "".concat(parseInt(cloneWrapper.style.top, 10) + e.clientY - cursorTop, "px");
cloneWrapper.style.left = "".concat(parseInt(cloneWrapper.style.left, 10) + e.clientX - cursorLeft, "px"); // Update cursor coordinates.
ownerDocument.addEventListener('dragover', over); // Update cursor to 'grabbing', document wide.
ownerDocument.body.classList.add(bodyClass); // Allow the Synthetic Event to be accessed from asynchronous code.
// https://reactjs.org/docs/events.html#event-pooling
timerId = setTimeout(function () {
return onDragStart(event);
cleanup.current = function () {
if (cloneWrapper && cloneWrapper.parentNode) {
cloneWrapper.parentNode.removeChild(cloneWrapper);
if (dragImage && dragImage.parentNode) {
dragImage.parentNode.removeChild(dragImage);
ownerDocument.body.classList.remove(bodyClass);
ownerDocument.removeEventListener('dragover', over);
Object(external_wp_element_["useEffect"])(function () {
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, children({
}), dragComponent && Object(external_wp_element_["createElement"])("div", {
className: "components-draggable-drag-component-root",
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/upload.js
var upload = __webpack_require__("NTP4");
// EXTERNAL MODULE: external ["wp","isShallowEqual"]
var external_wp_isShallowEqual_ = __webpack_require__("rl8x");
var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_);
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/drop-zone/provider.js
var Context = Object(external_wp_element_["createContext"])();
var provider_Provider = Context.Provider;
function getDragEventType(_ref) {
var dataTransfer = _ref.dataTransfer;
// Use lodash `includes` here as in the Edge browser `types` is implemented
// as a DomStringList, whereas in other browsers it's an array. `includes`
// happily works with both types.
if (Object(external_lodash_["includes"])(dataTransfer.types, 'Files') || Object(external_wp_dom_["getFilesFromDataTransfer"])(dataTransfer).length > 0) {
if (Object(external_lodash_["includes"])(dataTransfer.types, 'text/html')) {
function isTypeSupportedByDropZone(type, dropZone) {
return Boolean(type === 'file' && dropZone.onFilesDrop || type === 'html' && dropZone.onHTMLDrop || type === 'default' && dropZone.onDrop);
function isWithinElementBounds(element, x, y) {
var rect = element.getBoundingClientRect(); /// make sure the rect is a valid rect
if (rect.bottom === rect.top || rect.left === rect.right) {
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
function getPosition(event) {
// In some contexts, it may be necessary to capture and redirect the
// drag event (e.g. atop an `iframe`). To accommodate this, you can
// create an instance of CustomEvent with the original event specified
// as the `detail` property.
// See: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events
var detail = window.CustomEvent && event instanceof window.CustomEvent ? event.detail : event;
function getHoveredDropZone(dropZones, position, dragEventType) {
var hoveredDropZones = Object(external_lodash_["filter"])(Array.from(dropZones), function (dropZone) {
return isTypeSupportedByDropZone(dragEventType, dropZone) && isWithinElementBounds(dropZone.element.current, position.x, position.y);
}); // Find the leaf dropzone not containing another dropzone
return Object(external_lodash_["find"])(hoveredDropZones, function (zone) {
var container = zone.isRelative ? zone.element.current.parentElement : zone.element.current;
return !Object(external_lodash_["some"])(hoveredDropZones, function (subZone) {
return subZone !== zone && container.contains(subZone.element.current);
var INITIAL_DROP_ZONE_STATE = {
isDraggingOverDocument: false,
isDraggingOverElement: false,
var dropZones = Object(external_wp_element_["useContext"])(Context);
return Object(external_wp_compose_["useRefEffect"])(function (node) {
var ownerDocument = node.ownerDocument;
var defaultView = ownerDocument.defaultView;
function updateDragZones(event) {
if (lastRelative && lastRelative.contains(event.target)) {
var dragEventType = getDragEventType(event);
var position = getPosition(event);
var hoveredDropZone = getHoveredDropZone(dropZones, position, dragEventType);
if (hoveredDropZone && hoveredDropZone.isRelative) {
lastRelative = hoveredDropZone.element.current.offsetParent;
} // Notifying the dropzones
dropZones.forEach(function (dropZone) {
var isDraggingOverDropZone = dropZone === hoveredDropZone;
isDraggingOverDocument: isTypeSupportedByDropZone(dragEventType, dropZone),
isDraggingOverElement: isDraggingOverDropZone,
x: isDraggingOverDropZone && dropZone.withPosition ? position.x : null,
y: isDraggingOverDropZone && dropZone.withPosition ? position.y : null,
type: isDraggingOverDropZone ? dragEventType : null
dropZone.setState(function (state) {
if (external_wp_isShallowEqual_default()(state, newState)) {
var throttledUpdateDragZones = Object(external_lodash_["throttle"])(updateDragZones, 200);
function onDragOver(event) {
throttledUpdateDragZones(event);
function resetDragState() {
// Avoid throttled drag over handler calls
throttledUpdateDragZones.cancel();
dropZones.forEach(function (dropZone) {
return dropZone.setState(INITIAL_DROP_ZONE_STATE);
// This seemingly useless line has been shown to resolve a Safari issue
// where files dragged directly from the dock are not recognized
event.dataTransfer && event.dataTransfer.files.length; // eslint-disable-line no-unused-expressions
var dragEventType = getDragEventType(event);
var position = getPosition(event);
var hoveredDropZone = getHoveredDropZone(dropZones, position, dragEventType);
hoveredDropZone.onFilesDrop(Object(external_wp_dom_["getFilesFromDataTransfer"])(event.dataTransfer), position);
hoveredDropZone.onHTMLDrop(event.dataTransfer.getData('text/html'), position);
hoveredDropZone.onDrop(event, position);
node.addEventListener('drop', onDrop);
defaultView.addEventListener('dragover', onDragOver);
defaultView.addEventListener('mouseup', resetDragState); // Note that `dragend` doesn't fire consistently for file and HTML drag
// events where the drag origin is outside the browser window.
// In Firefox it may also not fire if the originating node is removed.
defaultView.addEventListener('dragend', resetDragState);
node.removeEventListener('drop', onDrop);
defaultView.removeEventListener('dragover', onDragOver);
defaultView.removeEventListener('mouseup', resetDragState);
defaultView.removeEventListener('dragend', resetDragState);
function DropZoneContextProvider(props) {
var ref = Object(external_wp_element_["useRef"])(new Set([]));
return Object(external_wp_element_["createElement"])(provider_Provider, Object(esm_extends["a" /* default */])({}, props, {
function DropContainer(_ref2) {
var children = _ref2.children;
return Object(external_wp_element_["createElement"])("div", {
className: "components-drop-zone__provider"
function DropZoneProvider(_ref3) {
var children = _ref3.children;
return Object(external_wp_element_["createElement"])(DropZoneContextProvider, null, Object(external_wp_element_["createElement"])(DropContainer, null, children));
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/drop-zone/index.js
function drop_zone_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function drop_zone_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { drop_zone_ownKeys(Object(source), true).forEach(function (key) { Object(esm_defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { drop_zone_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function useDropZone(_ref) {
var element = _ref.element,
onFilesDrop = _ref.onFilesDrop,
onHTMLDrop = _ref.onHTMLDrop,
isDisabled = _ref.isDisabled,
withPosition = _ref.withPosition,
_ref$__unstableIsRela = _ref.__unstableIsRelative,
isRelative = _ref$__unstableIsRela === void 0 ? false : _ref$__unstableIsRela;
var dropZones = Object(external_wp_element_["useContext"])(Context);
var _useState = Object(external_wp_element_["useState"])(INITIAL_DROP_ZONE_STATE),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
setState = _useState2[1];
Object(external_wp_element_["useEffect"])(function () {
onFilesDrop: onFilesDrop,
withPosition: withPosition,
dropZones.delete(dropZone);
}, [isDisabled, onDrop, onFilesDrop, onHTMLDrop, withPosition, isRelative]);
remainingState = Object(objectWithoutProperties["a" /* default */])(state, ["x", "y"]);
if (x !== null && y !== null) {
return drop_zone_objectSpread(drop_zone_objectSpread({}, remainingState), {}, {
function DropZoneComponent(_ref2) {
var className = _ref2.className,
onFilesDrop = _ref2.onFilesDrop,
onHTMLDrop = _ref2.onHTMLDrop,
var element = Object(external_wp_element_["useRef"])();
var _useDropZone = useDropZone({
onFilesDrop: onFilesDrop,
__unstableIsRelative: true
isDraggingOverDocument = _useDropZone.isDraggingOverDocument,
isDraggingOverElement = _useDropZone.isDraggingOverElement,
type = _useDropZone.type;
if (isDraggingOverElement) {
children = Object(external_wp_element_["createElement"])("div", {
className: "components-drop-zone__content"
}, Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
icon: upload["a" /* default */],
className: "components-drop-zone__content-icon"
}), Object(external_wp_element_["createElement"])("span", {
className: "components-drop-zone__content-text"
}, label ? label : Object(external_wp_i18n_["__"])('Drop files to upload')));
var classes = classnames_default()('components-drop-zone', className, Object(esm_defineProperty["a" /* default */])({
'is-active': (isDraggingOverDocument || isDraggingOverElement) && (type === 'file' && onFilesDrop || type === 'html' && onHTMLDrop || type === 'default' && onDrop),
'is-dragging-over-document': isDraggingOverDocument,
'is-dragging-over-element': isDraggingOverElement
}, "is-dragging-".concat(type), !!type));
return Object(external_wp_element_["createElement"])("div", {
// EXTERNAL MODULE: external ["wp","deprecated"]
var external_wp_deprecated_ = __webpack_require__("NMb1");
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/menu.js