@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration
Version:
An optional Pragmatic drag and drop package that enables rapid migration from react-beautiful-dnd to Pragmatic drag and drop
31 lines (28 loc) • 1.01 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import { useMemo } from 'react';
/**
* Private symbol that is intentionally not exported from this file.
*/
var privateKey = Symbol('DroppableData');
/**
* Data that is attached to drags.
*/
/**
* Checks if the passed data satisfies `DroppableData` using the private symbol.
*/
export function isDroppableData(data) {
return data[privateKey] === true;
}
/**
* Adds the private symbol to the passed data.
*
* The symbol allows us to quickly check if an object satisfies `DroppableData`.
*/
export function useDroppableData(_ref) {
var contextId = _ref.contextId,
droppableId = _ref.droppableId,
getIsDropDisabled = _ref.getIsDropDisabled;
return useMemo(function () {
return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, privateKey, true), "contextId", contextId), "droppableId", droppableId), "getIsDropDisabled", getIsDropDisabled);
}, [contextId, droppableId, getIsDropDisabled]);
}