react-aria-components
Version:
A library of styleable components built using React Aria
88 lines (79 loc) • 4.43 kB
JavaScript
var $9XrRC$reactaria = require("react-aria");
var $9XrRC$reactstately = require("react-stately");
var $9XrRC$react = require("react");
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "useDragAndDrop", () => $368d79437ab76c11$export$2cfc5be7a55829f6);
$parcel$export(module.exports, "DropIndicatorContext", () => $368d79437ab76c11$export$f55761759794cf55);
$parcel$export(module.exports, "DropIndicator", () => $368d79437ab76c11$export$62ed72bc21f6b8a6);
$parcel$export(module.exports, "DragAndDropContext", () => $368d79437ab76c11$export$d188a835a7bc5783);
/*
* Copyright 2022 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $368d79437ab76c11$export$2cfc5be7a55829f6(options) {
let dragAndDropHooks = (0, $9XrRC$react.useMemo)(()=>{
let { onDrop: onDrop, onInsert: onInsert, onItemDrop: onItemDrop, onReorder: onReorder, onRootDrop: onRootDrop, getItems: getItems, renderDragPreview: renderDragPreview, renderDropIndicator: renderDropIndicator, dropTargetDelegate: dropTargetDelegate } = options;
let isDraggable = !!getItems;
let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);
let hooks = {};
if (isDraggable) {
hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props) {
return (0, $9XrRC$reactstately.useDraggableCollectionState)({
...props,
...options
});
};
hooks.useDraggableCollection = (0, $9XrRC$reactaria.useDraggableCollection);
hooks.useDraggableItem = (0, $9XrRC$reactaria.useDraggableItem);
hooks.DragPreview = (0, $9XrRC$reactaria.DragPreview);
hooks.renderDragPreview = renderDragPreview;
}
if (isDroppable) {
hooks.useDroppableCollectionState = function useDroppableCollectionStateOverride(props) {
return (0, $9XrRC$reactstately.useDroppableCollectionState)({
...props,
...options
});
};
hooks.useDroppableItem = (0, $9XrRC$reactaria.useDroppableItem);
hooks.useDroppableCollection = function useDroppableCollectionOverride(props, state, ref) {
return (0, $9XrRC$reactaria.useDroppableCollection)({
...props,
...options
}, state, ref);
};
hooks.useDropIndicator = (0, $9XrRC$reactaria.useDropIndicator);
hooks.renderDropIndicator = renderDropIndicator;
hooks.dropTargetDelegate = dropTargetDelegate;
hooks.ListDropTargetDelegate = (0, $9XrRC$reactaria.ListDropTargetDelegate);
}
return hooks;
}, [
options
]);
return {
dragAndDropHooks: dragAndDropHooks
};
}
const $368d79437ab76c11$export$f55761759794cf55 = /*#__PURE__*/ (0, $9XrRC$react.createContext)(null);
function $368d79437ab76c11$var$DropIndicator(props, ref) {
let { render: render } = (0, $9XrRC$react.useContext)($368d79437ab76c11$export$f55761759794cf55);
return /*#__PURE__*/ (0, ($parcel$interopDefault($9XrRC$react))).createElement((0, ($parcel$interopDefault($9XrRC$react))).Fragment, null, render(props, ref));
}
/**
* A DropIndicator is rendered between items in a collection to indicate where dropped data will be inserted.
*/ const $368d79437ab76c11$export$62ed72bc21f6b8a6 = /*#__PURE__*/ (0, $9XrRC$react.forwardRef)($368d79437ab76c11$var$DropIndicator);
const $368d79437ab76c11$export$d188a835a7bc5783 = /*#__PURE__*/ (0, $9XrRC$react.createContext)({});
//# sourceMappingURL=useDragAndDrop.main.js.map