Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: components.js
dragComponent = _ref.__experimentalDragComponent;
[30000] Fix | Delete
var dragComponentRef = Object(external_wp_element_["useRef"])();
[30001] Fix | Delete
var cleanup = Object(external_wp_element_["useRef"])(function () {});
[30002] Fix | Delete
/**
[30003] Fix | Delete
* Removes the element clone, resets cursor, and removes drag listener.
[30004] Fix | Delete
*
[30005] Fix | Delete
* @param {Object} event The non-custom DragEvent.
[30006] Fix | Delete
*/
[30007] Fix | Delete
[30008] Fix | Delete
function end(event) {
[30009] Fix | Delete
event.preventDefault();
[30010] Fix | Delete
cleanup.current();
[30011] Fix | Delete
[30012] Fix | Delete
if (onDragOver) {
[30013] Fix | Delete
onDragEnd(event);
[30014] Fix | Delete
}
[30015] Fix | Delete
}
[30016] Fix | Delete
/**
[30017] Fix | Delete
* This method does a couple of things:
[30018] Fix | Delete
*
[30019] Fix | Delete
* - Clones the current element and spawns clone over original element.
[30020] Fix | Delete
* - Adds a fake temporary drag image to avoid browser defaults.
[30021] Fix | Delete
* - Sets transfer data.
[30022] Fix | Delete
* - Adds dragover listener.
[30023] Fix | Delete
*
[30024] Fix | Delete
* @param {Object} event The non-custom DragEvent.
[30025] Fix | Delete
*/
[30026] Fix | Delete
[30027] Fix | Delete
[30028] Fix | Delete
function start(event) {
[30029] Fix | Delete
var ownerDocument = event.target.ownerDocument;
[30030] Fix | Delete
event.dataTransfer.setData('text', JSON.stringify(transferData));
[30031] Fix | Delete
var cloneWrapper = ownerDocument.createElement('div');
[30032] Fix | Delete
var dragImage = ownerDocument.createElement('div'); // Set a fake drag image to avoid browser defaults. Remove from DOM
[30033] Fix | Delete
// right after. event.dataTransfer.setDragImage is not supported yet in
[30034] Fix | Delete
// IE, we need to check for its existence first.
[30035] Fix | Delete
[30036] Fix | Delete
if ('function' === typeof event.dataTransfer.setDragImage) {
[30037] Fix | Delete
dragImage.classList.add(dragImageClass);
[30038] Fix | Delete
ownerDocument.body.appendChild(dragImage);
[30039] Fix | Delete
event.dataTransfer.setDragImage(dragImage, 0, 0);
[30040] Fix | Delete
}
[30041] Fix | Delete
[30042] Fix | Delete
cloneWrapper.classList.add(cloneWrapperClass);
[30043] Fix | Delete
[30044] Fix | Delete
if (cloneClassname) {
[30045] Fix | Delete
cloneWrapper.classList.add(cloneClassname);
[30046] Fix | Delete
} // If a dragComponent is defined, the following logic will clone the
[30047] Fix | Delete
// HTML node and inject it into the cloneWrapper.
[30048] Fix | Delete
[30049] Fix | Delete
[30050] Fix | Delete
if (dragComponentRef.current) {
[30051] Fix | Delete
// Position dragComponent at the same position as the cursor.
[30052] Fix | Delete
cloneWrapper.style.top = "".concat(event.clientY, "px");
[30053] Fix | Delete
cloneWrapper.style.left = "".concat(event.clientX, "px");
[30054] Fix | Delete
var clonedDragComponent = ownerDocument.createElement('div');
[30055] Fix | Delete
clonedDragComponent.innerHTML = dragComponentRef.current.innerHTML;
[30056] Fix | Delete
cloneWrapper.appendChild(clonedDragComponent); // Inject the cloneWrapper into the DOM.
[30057] Fix | Delete
[30058] Fix | Delete
ownerDocument.body.appendChild(cloneWrapper);
[30059] Fix | Delete
} else {
[30060] Fix | Delete
var element = ownerDocument.getElementById(elementId); // Prepare element clone and append to element wrapper.
[30061] Fix | Delete
[30062] Fix | Delete
var elementRect = element.getBoundingClientRect();
[30063] Fix | Delete
var elementWrapper = element.parentNode;
[30064] Fix | Delete
var elementTopOffset = parseInt(elementRect.top, 10);
[30065] Fix | Delete
var elementLeftOffset = parseInt(elementRect.left, 10);
[30066] Fix | Delete
cloneWrapper.style.width = "".concat(elementRect.width + clonePadding * 2, "px");
[30067] Fix | Delete
var clone = element.cloneNode(true);
[30068] Fix | Delete
clone.id = "clone-".concat(elementId);
[30069] Fix | Delete
[30070] Fix | Delete
if (elementRect.height > cloneHeightTransformationBreakpoint) {
[30071] Fix | Delete
// Scale down clone if original element is larger than 700px.
[30072] Fix | Delete
cloneWrapper.style.transform = 'scale(0.5)';
[30073] Fix | Delete
cloneWrapper.style.transformOrigin = 'top left'; // Position clone near the cursor.
[30074] Fix | Delete
[30075] Fix | Delete
cloneWrapper.style.top = "".concat(event.clientY - 100, "px");
[30076] Fix | Delete
cloneWrapper.style.left = "".concat(event.clientX, "px");
[30077] Fix | Delete
} else {
[30078] Fix | Delete
// Position clone right over the original element (20px padding).
[30079] Fix | Delete
cloneWrapper.style.top = "".concat(elementTopOffset - clonePadding, "px");
[30080] Fix | Delete
cloneWrapper.style.left = "".concat(elementLeftOffset - clonePadding, "px");
[30081] Fix | Delete
} // Hack: Remove iFrames as it's causing the embeds drag clone to freeze
[30082] Fix | Delete
[30083] Fix | Delete
[30084] Fix | Delete
Array.from(clone.querySelectorAll('iframe')).forEach(function (child) {
[30085] Fix | Delete
return child.parentNode.removeChild(child);
[30086] Fix | Delete
});
[30087] Fix | Delete
cloneWrapper.appendChild(clone); // Inject the cloneWrapper into the DOM.
[30088] Fix | Delete
[30089] Fix | Delete
elementWrapper.appendChild(cloneWrapper);
[30090] Fix | Delete
} // Mark the current cursor coordinates.
[30091] Fix | Delete
[30092] Fix | Delete
[30093] Fix | Delete
var cursorLeft = event.clientX;
[30094] Fix | Delete
var cursorTop = event.clientY;
[30095] Fix | Delete
[30096] Fix | Delete
function over(e) {
[30097] Fix | Delete
cloneWrapper.style.top = "".concat(parseInt(cloneWrapper.style.top, 10) + e.clientY - cursorTop, "px");
[30098] Fix | Delete
cloneWrapper.style.left = "".concat(parseInt(cloneWrapper.style.left, 10) + e.clientX - cursorLeft, "px"); // Update cursor coordinates.
[30099] Fix | Delete
[30100] Fix | Delete
cursorLeft = e.clientX;
[30101] Fix | Delete
cursorTop = e.clientY;
[30102] Fix | Delete
[30103] Fix | Delete
if (onDragOver) {
[30104] Fix | Delete
onDragOver(e);
[30105] Fix | Delete
}
[30106] Fix | Delete
}
[30107] Fix | Delete
[30108] Fix | Delete
ownerDocument.addEventListener('dragover', over); // Update cursor to 'grabbing', document wide.
[30109] Fix | Delete
[30110] Fix | Delete
ownerDocument.body.classList.add(bodyClass); // Allow the Synthetic Event to be accessed from asynchronous code.
[30111] Fix | Delete
// https://reactjs.org/docs/events.html#event-pooling
[30112] Fix | Delete
[30113] Fix | Delete
event.persist();
[30114] Fix | Delete
var timerId;
[30115] Fix | Delete
[30116] Fix | Delete
if (onDragStart) {
[30117] Fix | Delete
timerId = setTimeout(function () {
[30118] Fix | Delete
return onDragStart(event);
[30119] Fix | Delete
});
[30120] Fix | Delete
}
[30121] Fix | Delete
[30122] Fix | Delete
cleanup.current = function () {
[30123] Fix | Delete
// Remove drag clone
[30124] Fix | Delete
if (cloneWrapper && cloneWrapper.parentNode) {
[30125] Fix | Delete
cloneWrapper.parentNode.removeChild(cloneWrapper);
[30126] Fix | Delete
}
[30127] Fix | Delete
[30128] Fix | Delete
if (dragImage && dragImage.parentNode) {
[30129] Fix | Delete
dragImage.parentNode.removeChild(dragImage);
[30130] Fix | Delete
} // Reset cursor.
[30131] Fix | Delete
[30132] Fix | Delete
[30133] Fix | Delete
ownerDocument.body.classList.remove(bodyClass);
[30134] Fix | Delete
ownerDocument.removeEventListener('dragover', over);
[30135] Fix | Delete
clearTimeout(timerId);
[30136] Fix | Delete
};
[30137] Fix | Delete
}
[30138] Fix | Delete
[30139] Fix | Delete
Object(external_wp_element_["useEffect"])(function () {
[30140] Fix | Delete
return function () {
[30141] Fix | Delete
cleanup.current();
[30142] Fix | Delete
};
[30143] Fix | Delete
}, []);
[30144] Fix | Delete
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, children({
[30145] Fix | Delete
onDraggableStart: start,
[30146] Fix | Delete
onDraggableEnd: end
[30147] Fix | Delete
}), dragComponent && Object(external_wp_element_["createElement"])("div", {
[30148] Fix | Delete
className: "components-draggable-drag-component-root",
[30149] Fix | Delete
style: {
[30150] Fix | Delete
display: 'none'
[30151] Fix | Delete
},
[30152] Fix | Delete
ref: dragComponentRef
[30153] Fix | Delete
}, dragComponent));
[30154] Fix | Delete
}
[30155] Fix | Delete
[30156] Fix | Delete
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/upload.js
[30157] Fix | Delete
var upload = __webpack_require__("NTP4");
[30158] Fix | Delete
[30159] Fix | Delete
// EXTERNAL MODULE: external ["wp","isShallowEqual"]
[30160] Fix | Delete
var external_wp_isShallowEqual_ = __webpack_require__("rl8x");
[30161] Fix | Delete
var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_);
[30162] Fix | Delete
[30163] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/drop-zone/provider.js
[30164] Fix | Delete
[30165] Fix | Delete
[30166] Fix | Delete
[30167] Fix | Delete
/**
[30168] Fix | Delete
* External dependencies
[30169] Fix | Delete
*/
[30170] Fix | Delete
[30171] Fix | Delete
/**
[30172] Fix | Delete
* WordPress dependencies
[30173] Fix | Delete
*/
[30174] Fix | Delete
[30175] Fix | Delete
[30176] Fix | Delete
[30177] Fix | Delete
[30178] Fix | Delete
[30179] Fix | Delete
var Context = Object(external_wp_element_["createContext"])();
[30180] Fix | Delete
var provider_Provider = Context.Provider;
[30181] Fix | Delete
[30182] Fix | Delete
function getDragEventType(_ref) {
[30183] Fix | Delete
var dataTransfer = _ref.dataTransfer;
[30184] Fix | Delete
[30185] Fix | Delete
if (dataTransfer) {
[30186] Fix | Delete
// Use lodash `includes` here as in the Edge browser `types` is implemented
[30187] Fix | Delete
// as a DomStringList, whereas in other browsers it's an array. `includes`
[30188] Fix | Delete
// happily works with both types.
[30189] Fix | Delete
if (Object(external_lodash_["includes"])(dataTransfer.types, 'Files') || Object(external_wp_dom_["getFilesFromDataTransfer"])(dataTransfer).length > 0) {
[30190] Fix | Delete
return 'file';
[30191] Fix | Delete
}
[30192] Fix | Delete
[30193] Fix | Delete
if (Object(external_lodash_["includes"])(dataTransfer.types, 'text/html')) {
[30194] Fix | Delete
return 'html';
[30195] Fix | Delete
}
[30196] Fix | Delete
}
[30197] Fix | Delete
[30198] Fix | Delete
return 'default';
[30199] Fix | Delete
}
[30200] Fix | Delete
[30201] Fix | Delete
function isTypeSupportedByDropZone(type, dropZone) {
[30202] Fix | Delete
return Boolean(type === 'file' && dropZone.onFilesDrop || type === 'html' && dropZone.onHTMLDrop || type === 'default' && dropZone.onDrop);
[30203] Fix | Delete
}
[30204] Fix | Delete
[30205] Fix | Delete
function isWithinElementBounds(element, x, y) {
[30206] Fix | Delete
var rect = element.getBoundingClientRect(); /// make sure the rect is a valid rect
[30207] Fix | Delete
[30208] Fix | Delete
if (rect.bottom === rect.top || rect.left === rect.right) {
[30209] Fix | Delete
return false;
[30210] Fix | Delete
}
[30211] Fix | Delete
[30212] Fix | Delete
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
[30213] Fix | Delete
}
[30214] Fix | Delete
[30215] Fix | Delete
function getPosition(event) {
[30216] Fix | Delete
// In some contexts, it may be necessary to capture and redirect the
[30217] Fix | Delete
// drag event (e.g. atop an `iframe`). To accommodate this, you can
[30218] Fix | Delete
// create an instance of CustomEvent with the original event specified
[30219] Fix | Delete
// as the `detail` property.
[30220] Fix | Delete
//
[30221] Fix | Delete
// See: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events
[30222] Fix | Delete
var detail = window.CustomEvent && event instanceof window.CustomEvent ? event.detail : event;
[30223] Fix | Delete
return {
[30224] Fix | Delete
x: detail.clientX,
[30225] Fix | Delete
y: detail.clientY
[30226] Fix | Delete
};
[30227] Fix | Delete
}
[30228] Fix | Delete
[30229] Fix | Delete
function getHoveredDropZone(dropZones, position, dragEventType) {
[30230] Fix | Delete
var hoveredDropZones = Object(external_lodash_["filter"])(Array.from(dropZones), function (dropZone) {
[30231] Fix | Delete
return isTypeSupportedByDropZone(dragEventType, dropZone) && isWithinElementBounds(dropZone.element.current, position.x, position.y);
[30232] Fix | Delete
}); // Find the leaf dropzone not containing another dropzone
[30233] Fix | Delete
[30234] Fix | Delete
return Object(external_lodash_["find"])(hoveredDropZones, function (zone) {
[30235] Fix | Delete
var container = zone.isRelative ? zone.element.current.parentElement : zone.element.current;
[30236] Fix | Delete
return !Object(external_lodash_["some"])(hoveredDropZones, function (subZone) {
[30237] Fix | Delete
return subZone !== zone && container.contains(subZone.element.current);
[30238] Fix | Delete
});
[30239] Fix | Delete
});
[30240] Fix | Delete
}
[30241] Fix | Delete
[30242] Fix | Delete
var INITIAL_DROP_ZONE_STATE = {
[30243] Fix | Delete
isDraggingOverDocument: false,
[30244] Fix | Delete
isDraggingOverElement: false,
[30245] Fix | Delete
x: null,
[30246] Fix | Delete
y: null,
[30247] Fix | Delete
type: null
[30248] Fix | Delete
};
[30249] Fix | Delete
function useDrop() {
[30250] Fix | Delete
var dropZones = Object(external_wp_element_["useContext"])(Context);
[30251] Fix | Delete
return Object(external_wp_compose_["useRefEffect"])(function (node) {
[30252] Fix | Delete
var ownerDocument = node.ownerDocument;
[30253] Fix | Delete
var defaultView = ownerDocument.defaultView;
[30254] Fix | Delete
var lastRelative;
[30255] Fix | Delete
[30256] Fix | Delete
function updateDragZones(event) {
[30257] Fix | Delete
if (lastRelative && lastRelative.contains(event.target)) {
[30258] Fix | Delete
return;
[30259] Fix | Delete
}
[30260] Fix | Delete
[30261] Fix | Delete
var dragEventType = getDragEventType(event);
[30262] Fix | Delete
var position = getPosition(event);
[30263] Fix | Delete
var hoveredDropZone = getHoveredDropZone(dropZones, position, dragEventType);
[30264] Fix | Delete
[30265] Fix | Delete
if (hoveredDropZone && hoveredDropZone.isRelative) {
[30266] Fix | Delete
lastRelative = hoveredDropZone.element.current.offsetParent;
[30267] Fix | Delete
} else {
[30268] Fix | Delete
lastRelative = null;
[30269] Fix | Delete
} // Notifying the dropzones
[30270] Fix | Delete
[30271] Fix | Delete
[30272] Fix | Delete
dropZones.forEach(function (dropZone) {
[30273] Fix | Delete
var isDraggingOverDropZone = dropZone === hoveredDropZone;
[30274] Fix | Delete
var newState = {
[30275] Fix | Delete
isDraggingOverDocument: isTypeSupportedByDropZone(dragEventType, dropZone),
[30276] Fix | Delete
isDraggingOverElement: isDraggingOverDropZone,
[30277] Fix | Delete
x: isDraggingOverDropZone && dropZone.withPosition ? position.x : null,
[30278] Fix | Delete
y: isDraggingOverDropZone && dropZone.withPosition ? position.y : null,
[30279] Fix | Delete
type: isDraggingOverDropZone ? dragEventType : null
[30280] Fix | Delete
};
[30281] Fix | Delete
dropZone.setState(function (state) {
[30282] Fix | Delete
if (external_wp_isShallowEqual_default()(state, newState)) {
[30283] Fix | Delete
return state;
[30284] Fix | Delete
}
[30285] Fix | Delete
[30286] Fix | Delete
return newState;
[30287] Fix | Delete
});
[30288] Fix | Delete
});
[30289] Fix | Delete
event.preventDefault();
[30290] Fix | Delete
}
[30291] Fix | Delete
[30292] Fix | Delete
var throttledUpdateDragZones = Object(external_lodash_["throttle"])(updateDragZones, 200);
[30293] Fix | Delete
[30294] Fix | Delete
function onDragOver(event) {
[30295] Fix | Delete
throttledUpdateDragZones(event);
[30296] Fix | Delete
event.preventDefault();
[30297] Fix | Delete
}
[30298] Fix | Delete
[30299] Fix | Delete
function resetDragState() {
[30300] Fix | Delete
// Avoid throttled drag over handler calls
[30301] Fix | Delete
throttledUpdateDragZones.cancel();
[30302] Fix | Delete
dropZones.forEach(function (dropZone) {
[30303] Fix | Delete
return dropZone.setState(INITIAL_DROP_ZONE_STATE);
[30304] Fix | Delete
});
[30305] Fix | Delete
}
[30306] Fix | Delete
[30307] Fix | Delete
function onDrop(event) {
[30308] Fix | Delete
// This seemingly useless line has been shown to resolve a Safari issue
[30309] Fix | Delete
// where files dragged directly from the dock are not recognized
[30310] Fix | Delete
event.dataTransfer && event.dataTransfer.files.length; // eslint-disable-line no-unused-expressions
[30311] Fix | Delete
[30312] Fix | Delete
var dragEventType = getDragEventType(event);
[30313] Fix | Delete
var position = getPosition(event);
[30314] Fix | Delete
var hoveredDropZone = getHoveredDropZone(dropZones, position, dragEventType);
[30315] Fix | Delete
resetDragState();
[30316] Fix | Delete
[30317] Fix | Delete
if (hoveredDropZone) {
[30318] Fix | Delete
switch (dragEventType) {
[30319] Fix | Delete
case 'file':
[30320] Fix | Delete
hoveredDropZone.onFilesDrop(Object(external_wp_dom_["getFilesFromDataTransfer"])(event.dataTransfer), position);
[30321] Fix | Delete
break;
[30322] Fix | Delete
[30323] Fix | Delete
case 'html':
[30324] Fix | Delete
hoveredDropZone.onHTMLDrop(event.dataTransfer.getData('text/html'), position);
[30325] Fix | Delete
break;
[30326] Fix | Delete
[30327] Fix | Delete
case 'default':
[30328] Fix | Delete
hoveredDropZone.onDrop(event, position);
[30329] Fix | Delete
}
[30330] Fix | Delete
}
[30331] Fix | Delete
[30332] Fix | Delete
event.stopPropagation();
[30333] Fix | Delete
event.preventDefault();
[30334] Fix | Delete
}
[30335] Fix | Delete
[30336] Fix | Delete
node.addEventListener('drop', onDrop);
[30337] Fix | Delete
defaultView.addEventListener('dragover', onDragOver);
[30338] Fix | Delete
defaultView.addEventListener('mouseup', resetDragState); // Note that `dragend` doesn't fire consistently for file and HTML drag
[30339] Fix | Delete
// events where the drag origin is outside the browser window.
[30340] Fix | Delete
// In Firefox it may also not fire if the originating node is removed.
[30341] Fix | Delete
[30342] Fix | Delete
defaultView.addEventListener('dragend', resetDragState);
[30343] Fix | Delete
return function () {
[30344] Fix | Delete
node.removeEventListener('drop', onDrop);
[30345] Fix | Delete
defaultView.removeEventListener('dragover', onDragOver);
[30346] Fix | Delete
defaultView.removeEventListener('mouseup', resetDragState);
[30347] Fix | Delete
defaultView.removeEventListener('dragend', resetDragState);
[30348] Fix | Delete
};
[30349] Fix | Delete
}, [dropZones]);
[30350] Fix | Delete
}
[30351] Fix | Delete
function DropZoneContextProvider(props) {
[30352] Fix | Delete
var ref = Object(external_wp_element_["useRef"])(new Set([]));
[30353] Fix | Delete
return Object(external_wp_element_["createElement"])(provider_Provider, Object(esm_extends["a" /* default */])({}, props, {
[30354] Fix | Delete
value: ref.current
[30355] Fix | Delete
}));
[30356] Fix | Delete
}
[30357] Fix | Delete
[30358] Fix | Delete
function DropContainer(_ref2) {
[30359] Fix | Delete
var children = _ref2.children;
[30360] Fix | Delete
var ref = useDrop();
[30361] Fix | Delete
return Object(external_wp_element_["createElement"])("div", {
[30362] Fix | Delete
ref: ref,
[30363] Fix | Delete
className: "components-drop-zone__provider"
[30364] Fix | Delete
}, children);
[30365] Fix | Delete
}
[30366] Fix | Delete
[30367] Fix | Delete
function DropZoneProvider(_ref3) {
[30368] Fix | Delete
var children = _ref3.children;
[30369] Fix | Delete
return Object(external_wp_element_["createElement"])(DropZoneContextProvider, null, Object(external_wp_element_["createElement"])(DropContainer, null, children));
[30370] Fix | Delete
}
[30371] Fix | Delete
[30372] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/drop-zone/index.js
[30373] Fix | Delete
[30374] Fix | Delete
[30375] Fix | Delete
[30376] Fix | Delete
[30377] Fix | Delete
[30378] Fix | Delete
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; }
[30379] Fix | Delete
[30380] Fix | Delete
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; }
[30381] Fix | Delete
[30382] Fix | Delete
/**
[30383] Fix | Delete
* External dependencies
[30384] Fix | Delete
*/
[30385] Fix | Delete
[30386] Fix | Delete
/**
[30387] Fix | Delete
* WordPress dependencies
[30388] Fix | Delete
*/
[30389] Fix | Delete
[30390] Fix | Delete
[30391] Fix | Delete
[30392] Fix | Delete
[30393] Fix | Delete
/**
[30394] Fix | Delete
* Internal dependencies
[30395] Fix | Delete
*/
[30396] Fix | Delete
[30397] Fix | Delete
[30398] Fix | Delete
function useDropZone(_ref) {
[30399] Fix | Delete
var element = _ref.element,
[30400] Fix | Delete
onFilesDrop = _ref.onFilesDrop,
[30401] Fix | Delete
onHTMLDrop = _ref.onHTMLDrop,
[30402] Fix | Delete
onDrop = _ref.onDrop,
[30403] Fix | Delete
isDisabled = _ref.isDisabled,
[30404] Fix | Delete
withPosition = _ref.withPosition,
[30405] Fix | Delete
_ref$__unstableIsRela = _ref.__unstableIsRelative,
[30406] Fix | Delete
isRelative = _ref$__unstableIsRela === void 0 ? false : _ref$__unstableIsRela;
[30407] Fix | Delete
var dropZones = Object(external_wp_element_["useContext"])(Context);
[30408] Fix | Delete
[30409] Fix | Delete
var _useState = Object(external_wp_element_["useState"])(INITIAL_DROP_ZONE_STATE),
[30410] Fix | Delete
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
[30411] Fix | Delete
state = _useState2[0],
[30412] Fix | Delete
setState = _useState2[1];
[30413] Fix | Delete
[30414] Fix | Delete
Object(external_wp_element_["useEffect"])(function () {
[30415] Fix | Delete
if (!isDisabled) {
[30416] Fix | Delete
var dropZone = {
[30417] Fix | Delete
element: element,
[30418] Fix | Delete
onDrop: onDrop,
[30419] Fix | Delete
onFilesDrop: onFilesDrop,
[30420] Fix | Delete
onHTMLDrop: onHTMLDrop,
[30421] Fix | Delete
setState: setState,
[30422] Fix | Delete
withPosition: withPosition,
[30423] Fix | Delete
isRelative: isRelative
[30424] Fix | Delete
};
[30425] Fix | Delete
dropZones.add(dropZone);
[30426] Fix | Delete
return function () {
[30427] Fix | Delete
dropZones.delete(dropZone);
[30428] Fix | Delete
};
[30429] Fix | Delete
}
[30430] Fix | Delete
}, [isDisabled, onDrop, onFilesDrop, onHTMLDrop, withPosition, isRelative]);
[30431] Fix | Delete
[30432] Fix | Delete
var x = state.x,
[30433] Fix | Delete
y = state.y,
[30434] Fix | Delete
remainingState = Object(objectWithoutProperties["a" /* default */])(state, ["x", "y"]);
[30435] Fix | Delete
[30436] Fix | Delete
var position = null;
[30437] Fix | Delete
[30438] Fix | Delete
if (x !== null && y !== null) {
[30439] Fix | Delete
position = {
[30440] Fix | Delete
x: x,
[30441] Fix | Delete
y: y
[30442] Fix | Delete
};
[30443] Fix | Delete
}
[30444] Fix | Delete
[30445] Fix | Delete
return drop_zone_objectSpread(drop_zone_objectSpread({}, remainingState), {}, {
[30446] Fix | Delete
position: position
[30447] Fix | Delete
});
[30448] Fix | Delete
}
[30449] Fix | Delete
function DropZoneComponent(_ref2) {
[30450] Fix | Delete
var className = _ref2.className,
[30451] Fix | Delete
label = _ref2.label,
[30452] Fix | Delete
onFilesDrop = _ref2.onFilesDrop,
[30453] Fix | Delete
onHTMLDrop = _ref2.onHTMLDrop,
[30454] Fix | Delete
onDrop = _ref2.onDrop;
[30455] Fix | Delete
var element = Object(external_wp_element_["useRef"])();
[30456] Fix | Delete
[30457] Fix | Delete
var _useDropZone = useDropZone({
[30458] Fix | Delete
element: element,
[30459] Fix | Delete
onFilesDrop: onFilesDrop,
[30460] Fix | Delete
onHTMLDrop: onHTMLDrop,
[30461] Fix | Delete
onDrop: onDrop,
[30462] Fix | Delete
__unstableIsRelative: true
[30463] Fix | Delete
}),
[30464] Fix | Delete
isDraggingOverDocument = _useDropZone.isDraggingOverDocument,
[30465] Fix | Delete
isDraggingOverElement = _useDropZone.isDraggingOverElement,
[30466] Fix | Delete
type = _useDropZone.type;
[30467] Fix | Delete
[30468] Fix | Delete
var children;
[30469] Fix | Delete
[30470] Fix | Delete
if (isDraggingOverElement) {
[30471] Fix | Delete
children = Object(external_wp_element_["createElement"])("div", {
[30472] Fix | Delete
className: "components-drop-zone__content"
[30473] Fix | Delete
}, Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
[30474] Fix | Delete
icon: upload["a" /* default */],
[30475] Fix | Delete
className: "components-drop-zone__content-icon"
[30476] Fix | Delete
}), Object(external_wp_element_["createElement"])("span", {
[30477] Fix | Delete
className: "components-drop-zone__content-text"
[30478] Fix | Delete
}, label ? label : Object(external_wp_i18n_["__"])('Drop files to upload')));
[30479] Fix | Delete
}
[30480] Fix | Delete
[30481] Fix | Delete
var classes = classnames_default()('components-drop-zone', className, Object(esm_defineProperty["a" /* default */])({
[30482] Fix | Delete
'is-active': (isDraggingOverDocument || isDraggingOverElement) && (type === 'file' && onFilesDrop || type === 'html' && onHTMLDrop || type === 'default' && onDrop),
[30483] Fix | Delete
'is-dragging-over-document': isDraggingOverDocument,
[30484] Fix | Delete
'is-dragging-over-element': isDraggingOverElement
[30485] Fix | Delete
}, "is-dragging-".concat(type), !!type));
[30486] Fix | Delete
return Object(external_wp_element_["createElement"])("div", {
[30487] Fix | Delete
ref: element,
[30488] Fix | Delete
className: classes
[30489] Fix | Delete
}, children);
[30490] Fix | Delete
}
[30491] Fix | Delete
[30492] Fix | Delete
// EXTERNAL MODULE: external ["wp","deprecated"]
[30493] Fix | Delete
var external_wp_deprecated_ = __webpack_require__("NMb1");
[30494] Fix | Delete
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_);
[30495] Fix | Delete
[30496] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/menu.js
[30497] Fix | Delete
[30498] Fix | Delete
[30499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function