Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-stately/dnd

Package Overview
Dependencies
Maintainers
2
Versions
739
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-stately/dnd - npm Package Compare versions

Comparing version 3.0.0-nightly-25f304dea-241008 to 3.0.0-nightly-262cc758b-241114

2

dist/types.d.ts

@@ -68,3 +68,3 @@ import { Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node, RefObject, DragTypes, DroppableCollectionProps, DropTarget } from "@react-types/shared";

/** Sets the current drop target. */
setTarget(target: DropTarget): void;
setTarget(target: DropTarget | null): void;
/** Returns whether the given target is equivalent to the current drop target. */

@@ -71,0 +71,0 @@ isDropTarget(target: DropTarget): boolean;

@@ -40,6 +40,7 @@ var $ax21c$react = require("react");

}
return null;
};
let defaultGetDropOperation = (0, $ax21c$react.useCallback)((e)=>{
if (isDisabled) return 'cancel';
let { target: target, types: types, allowedOperations: allowedOperations, isInternal: isInternal, draggingKeys: draggingKeys } = e;
if (isDisabled || !target) return 'cancel';
if (acceptedDragTypes === 'all' || acceptedDragTypes.some((type)=>types.has(type))) {

@@ -51,3 +52,3 @@ let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');

// Automatically prevent items (i.e. folders) from being dropped on themselves.
let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && target.key != null && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
if (onDrop || isValidInsert || isValidReorder || isValidRootDrop || isValidOnItemDrop) {

@@ -90,7 +91,8 @@ if (getDropOperation) return getDropOperation(target, types, allowedOperations);

});
targetRef.current = newTarget;
setTarget(newTarget);
targetRef.current = newTarget !== null && newTarget !== void 0 ? newTarget : null;
setTarget(newTarget !== null && newTarget !== void 0 ? newTarget : null);
},
isDropTarget (dropTarget) {
let target = targetRef.current;
if (!target || !dropTarget) return false;
if ($6ce4cbfbe5e354f1$var$isEqualDropTarget(dropTarget, target)) return true;

@@ -97,0 +99,0 @@ // Check if the targets point at the same point between two items, one referring before, and the other after.

@@ -34,6 +34,7 @@ import {useState as $lyPoT$useState, useRef as $lyPoT$useRef, useCallback as $lyPoT$useCallback} from "react";

}
return null;
};
let defaultGetDropOperation = (0, $lyPoT$useCallback)((e)=>{
if (isDisabled) return 'cancel';
let { target: target, types: types, allowedOperations: allowedOperations, isInternal: isInternal, draggingKeys: draggingKeys } = e;
if (isDisabled || !target) return 'cancel';
if (acceptedDragTypes === 'all' || acceptedDragTypes.some((type)=>types.has(type))) {

@@ -45,3 +46,3 @@ let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');

// Automatically prevent items (i.e. folders) from being dropped on themselves.
let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && target.key != null && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
if (onDrop || isValidInsert || isValidReorder || isValidRootDrop || isValidOnItemDrop) {

@@ -84,7 +85,8 @@ if (getDropOperation) return getDropOperation(target, types, allowedOperations);

});
targetRef.current = newTarget;
setTarget(newTarget);
targetRef.current = newTarget !== null && newTarget !== void 0 ? newTarget : null;
setTarget(newTarget !== null && newTarget !== void 0 ? newTarget : null);
},
isDropTarget (dropTarget) {
let target = targetRef.current;
if (!target || !dropTarget) return false;
if ($e672e8bc247525d1$var$isEqualDropTarget(dropTarget, target)) return true;

@@ -91,0 +93,0 @@ // Check if the targets point at the same point between two items, one referring before, and the other after.

{
"name": "@react-stately/dnd",
"version": "3.0.0-nightly-25f304dea-241008",
"version": "3.0.0-nightly-262cc758b-241114",
"description": "Spectrum UI components in React",

@@ -25,4 +25,4 @@ "license": "Apache-2.0",

"dependencies": {
"@react-stately/selection": "^3.0.0-nightly-25f304dea-241008",
"@react-types/shared": "^3.0.0-nightly-25f304dea-241008",
"@react-stately/selection": "^3.0.0-nightly-262cc758b-241114",
"@react-types/shared": "^3.0.0-nightly-262cc758b-241114",
"@swc/helpers": "^0.5.0"

@@ -29,0 +29,0 @@ },

@@ -44,3 +44,3 @@ /*

/** Sets the current drop target. */
setTarget(target: DropTarget): void,
setTarget(target: DropTarget | null): void,
/** Returns whether the given target is equivalent to the current drop target. */

@@ -70,6 +70,6 @@ isDropTarget(target: DropTarget): boolean,

} = props;
let [target, setTarget] = useState<DropTarget>(null);
let targetRef = useRef<DropTarget>(null);
let [target, setTarget] = useState<DropTarget | null>(null);
let targetRef = useRef<DropTarget | null>(null);
let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget => {
let getOppositeTarget = (target: ItemDropTarget): ItemDropTarget | null => {
if (target.dropPosition === 'before') {

@@ -82,9 +82,6 @@ let key = collection.getKeyBefore(target.key);

}
return null;
};
let defaultGetDropOperation = useCallback((e: DropOperationEvent) => {
if (isDisabled) {
return 'cancel';
}
let {

@@ -98,2 +95,6 @@ target,

if (isDisabled || !target) {
return 'cancel';
}
if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => types.has(type))) {

@@ -105,3 +106,3 @@ let isValidInsert = onInsert && target.type === 'item' && !isInternal && (target.dropPosition === 'before' || target.dropPosition === 'after');

// Automatically prevent items (i.e. folders) from being dropped on themselves.
let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));
let isValidOnItemDrop = onItemDrop && target.type === 'item' && target.dropPosition === 'on' && !(isInternal && target.key != null && draggingKeys.has(target.key)) && (!shouldAcceptItemDrop || shouldAcceptItemDrop(target, types));

@@ -149,7 +150,10 @@ if (onDrop || isValidInsert || isValidReorder || isValidRootDrop || isValidOnItemDrop) {

targetRef.current = newTarget;
setTarget(newTarget);
targetRef.current = newTarget ?? null;
setTarget(newTarget ?? null);
},
isDropTarget(dropTarget) {
let target = targetRef.current;
if (!target || !dropTarget) {
return false;
}
if (isEqualDropTarget(dropTarget, target)) {

@@ -180,3 +184,3 @@ return true;

function isEqualDropTarget(a: DropTarget, b: DropTarget) {
function isEqualDropTarget(a?: DropTarget | null, b?: DropTarget | null) {
if (!a) {

@@ -183,0 +187,0 @@ return !b;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc