@atlaskit/pragmatic-drag-and-drop-hitbox
Version:
An optional package for Pragmatic drag and drop that enables the attaching of interaction information to a drop target
30 lines (29 loc) • 741 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.extractInstruction = extractInstruction;
var _listItem = require("./list-item");
/**
* Extract an instruction from the user data if it is available.
*
*
* @example
*
* ```ts
* monitorForElements({
* onDrop({location}) {
* const innerMost = location.current.dropTargets[0];
* if(!innerMost) {
* return;
* }
* const instruction: Instruction | null = extractInstruction(innerMost.data);
* }
* });
* ```
*/
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
function extractInstruction(userData) {
var _ref;
return (_ref = userData[_listItem.uniqueKey]) !== null && _ref !== void 0 ? _ref : null;
}