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

react-complex-tree

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-complex-tree - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

30

lib/cjs/controlledEnvironment/useOnDragOverTreeHandler.js

@@ -15,5 +15,4 @@ "use strict";

linearIndex: treeLinearItems.length - 1,
targetItem: treeLinearItems[treeLinearItems.length - 1].item,
offset: 'bottom',
targetLinearItem: treeLinearItems[treeLinearItems.length - 1],
veryBottom: true,
};

@@ -35,3 +34,3 @@ }

}
return { linearIndex: linearIndex, offset: offset, targetItem: targetItem, targetLinearItem: targetLinearItem };
return { linearIndex: linearIndex, offset: offset };
};

@@ -57,3 +56,3 @@ var useIsDescendant = function () {

return (0, use_stable_handler_1.useStableHandler)(function (e, treeId, containerRef) {
var _a, _b;
var _a, _b, _c, _d;
if (!draggingItems) {

@@ -84,6 +83,7 @@ return;

}
var _c = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems), linearIndex = _c.linearIndex, offset = _c.offset;
// eslint-disable-next-line prefer-const
var _e = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems), linearIndex = _e.linearIndex, offset = _e.offset, veryBottom = _e.veryBottom;
var nextDragCode = outsideContainer
? 'outside'
: "".concat(treeId).concat(linearIndex).concat(offset !== null && offset !== void 0 ? offset : '');
: "".concat(treeId).concat(linearIndex).concat(offset !== null && offset !== void 0 ? offset : '').concat(veryBottom && 'vb');
if (lastDragCode === nextDragCode) {

@@ -106,3 +106,3 @@ return;

if (redirectTargetToParent) {
var _d = getParentOfLinearItem(linearIndex, treeId), parentLinearIndex = _d.parentLinearIndex, parent_1 = _d.parent;
var _f = getParentOfLinearItem(linearIndex, treeId), parentLinearIndex = _f.parentLinearIndex, parent_1 = _f.parent;
targetItem = parent_1;

@@ -152,11 +152,21 @@ linearIndex = parentLinearIndex;

var draggingPosition;
if (offset) {
if (veryBottom) {
var rootItem = trees[treeId].rootItem;
draggingPosition = {
targetType: 'between-items',
treeId: treeId,
parentItem: rootItem,
depth: 0,
linearIndex: linearIndex + 1,
childIndex: (_d = (_c = items[rootItem].children) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
linePosition: 'bottom',
};
}
else if (offset) {
draggingPosition = {
targetType: 'between-items',
treeId: treeId,
parentItem: parent.item,
depth: targetItem.depth,
linearIndex: linearIndex + (offset === 'top' ? 0 : 1),
// childIndex: linearIndex - parentLinearIndex - 1 + (offset === 'top' ? 0 : 1),
// childIndex: environment.items[parent.item].children!.indexOf(targetItem.item) + (offset === 'top' ? 0 : 1),
childIndex: newChildIndex,

@@ -163,0 +173,0 @@ linePosition: offset,

@@ -12,5 +12,4 @@ import { useTreeEnvironment } from './ControlledTreeEnvironment';

linearIndex: treeLinearItems.length - 1,
targetItem: treeLinearItems[treeLinearItems.length - 1].item,
offset: 'bottom',
targetLinearItem: treeLinearItems[treeLinearItems.length - 1],
veryBottom: true,
};

@@ -32,3 +31,3 @@ }

}
return { linearIndex: linearIndex, offset: offset, targetItem: targetItem, targetLinearItem: targetLinearItem };
return { linearIndex: linearIndex, offset: offset };
};

@@ -54,3 +53,3 @@ var useIsDescendant = function () {

return useStableHandler(function (e, treeId, containerRef) {
var _a, _b;
var _a, _b, _c, _d;
if (!draggingItems) {

@@ -81,6 +80,7 @@ return;

}
var _c = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems), linearIndex = _c.linearIndex, offset = _c.offset;
// eslint-disable-next-line prefer-const
var _e = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems), linearIndex = _e.linearIndex, offset = _e.offset, veryBottom = _e.veryBottom;
var nextDragCode = outsideContainer
? 'outside'
: "".concat(treeId).concat(linearIndex).concat(offset !== null && offset !== void 0 ? offset : '');
: "".concat(treeId).concat(linearIndex).concat(offset !== null && offset !== void 0 ? offset : '').concat(veryBottom && 'vb');
if (lastDragCode === nextDragCode) {

@@ -103,3 +103,3 @@ return;

if (redirectTargetToParent) {
var _d = getParentOfLinearItem(linearIndex, treeId), parentLinearIndex = _d.parentLinearIndex, parent_1 = _d.parent;
var _f = getParentOfLinearItem(linearIndex, treeId), parentLinearIndex = _f.parentLinearIndex, parent_1 = _f.parent;
targetItem = parent_1;

@@ -149,11 +149,21 @@ linearIndex = parentLinearIndex;

var draggingPosition;
if (offset) {
if (veryBottom) {
var rootItem = trees[treeId].rootItem;
draggingPosition = {
targetType: 'between-items',
treeId: treeId,
parentItem: rootItem,
depth: 0,
linearIndex: linearIndex + 1,
childIndex: (_d = (_c = items[rootItem].children) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
linePosition: 'bottom',
};
}
else if (offset) {
draggingPosition = {
targetType: 'between-items',
treeId: treeId,
parentItem: parent.item,
depth: targetItem.depth,
linearIndex: linearIndex + (offset === 'top' ? 0 : 1),
// childIndex: linearIndex - parentLinearIndex - 1 + (offset === 'top' ? 0 : 1),
// childIndex: environment.items[parent.item].children!.indexOf(targetItem.item) + (offset === 'top' ? 0 : 1),
childIndex: newChildIndex,

@@ -160,0 +170,0 @@ linePosition: offset,

@@ -12,5 +12,4 @@ import { useTreeEnvironment } from './ControlledTreeEnvironment';

linearIndex: treeLinearItems.length - 1,
targetItem: treeLinearItems[treeLinearItems.length - 1].item,
offset: 'bottom',
targetLinearItem: treeLinearItems[treeLinearItems.length - 1],
veryBottom: true,
};

@@ -32,3 +31,3 @@ }

}
return { linearIndex: linearIndex, offset: offset, targetItem: targetItem, targetLinearItem: targetLinearItem };
return { linearIndex: linearIndex, offset: offset };
};

@@ -54,3 +53,3 @@ var useIsDescendant = function () {

return useStableHandler(function (e, treeId, containerRef) {
var _a, _b;
var _a, _b, _c, _d;
if (!draggingItems) {

@@ -81,6 +80,7 @@ return;

}
var _c = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems), linearIndex = _c.linearIndex, offset = _c.offset;
// eslint-disable-next-line prefer-const
var _e = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems), linearIndex = _e.linearIndex, offset = _e.offset, veryBottom = _e.veryBottom;
var nextDragCode = outsideContainer
? 'outside'
: "".concat(treeId).concat(linearIndex).concat(offset !== null && offset !== void 0 ? offset : '');
: "".concat(treeId).concat(linearIndex).concat(offset !== null && offset !== void 0 ? offset : '').concat(veryBottom && 'vb');
if (lastDragCode === nextDragCode) {

@@ -103,3 +103,3 @@ return;

if (redirectTargetToParent) {
var _d = getParentOfLinearItem(linearIndex, treeId), parentLinearIndex = _d.parentLinearIndex, parent_1 = _d.parent;
var _f = getParentOfLinearItem(linearIndex, treeId), parentLinearIndex = _f.parentLinearIndex, parent_1 = _f.parent;
targetItem = parent_1;

@@ -149,11 +149,21 @@ linearIndex = parentLinearIndex;

var draggingPosition;
if (offset) {
if (veryBottom) {
var rootItem = trees[treeId].rootItem;
draggingPosition = {
targetType: 'between-items',
treeId: treeId,
parentItem: rootItem,
depth: 0,
linearIndex: linearIndex + 1,
childIndex: (_d = (_c = items[rootItem].children) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
linePosition: 'bottom',
};
}
else if (offset) {
draggingPosition = {
targetType: 'between-items',
treeId: treeId,
parentItem: parent.item,
depth: targetItem.depth,
linearIndex: linearIndex + (offset === 'top' ? 0 : 1),
// childIndex: linearIndex - parentLinearIndex - 1 + (offset === 'top' ? 0 : 1),
// childIndex: environment.items[parent.item].children!.indexOf(targetItem.item) + (offset === 'top' ? 0 : 1),
childIndex: newChildIndex,

@@ -160,0 +170,0 @@ linePosition: offset,

{
"name": "react-complex-tree",
"version": "2.3.0",
"version": "2.3.1",
"main": "lib/cjs/index.js",

@@ -37,3 +37,3 @@ "module": "lib/esm/index.js",

"cpy-cli": "^3.1.1",
"demodata": "^2.3.0",
"demodata": "^2.3.1",
"jest": "^29.2.2",

@@ -70,3 +70,3 @@ "jest-dom": "^4.0.0",

},
"gitHead": "7e2a22922e8b91eef046d13a0454738616d865bb"
"gitHead": "ec3eec734973fb48762b6b3b2a291a96e82c282d"
}

@@ -32,5 +32,4 @@ import * as React from 'react';

linearIndex: treeLinearItems.length - 1,
targetItem: treeLinearItems[treeLinearItems.length - 1].item,
offset: 'bottom',
targetLinearItem: treeLinearItems[treeLinearItems.length - 1],
veryBottom: true,
} as const;

@@ -55,3 +54,3 @@ }

return { linearIndex, offset, targetItem, targetLinearItem };
return { linearIndex, offset };
};

@@ -142,3 +141,4 @@

let { linearIndex, offset } = getHoveringPosition(
// eslint-disable-next-line prefer-const
let { linearIndex, offset, veryBottom } = getHoveringPosition(
e.clientY,

@@ -157,3 +157,3 @@ treeBb.top,

? 'outside'
: `${treeId}${linearIndex}${offset ?? ''}`;
: `${treeId}${linearIndex}${offset ?? ''}${veryBottom && 'vb'}`;

@@ -251,11 +251,20 @@ if (lastDragCode === nextDragCode) {

if (offset) {
if (veryBottom) {
const { rootItem } = trees[treeId];
draggingPosition = {
targetType: 'between-items',
treeId,
parentItem: rootItem,
depth: 0,
linearIndex: linearIndex + 1,
childIndex: items[rootItem].children?.length ?? 0,
linePosition: 'bottom',
};
} else if (offset) {
draggingPosition = {
targetType: 'between-items',
treeId,
parentItem: parent.item,
depth: targetItem.depth,
linearIndex: linearIndex + (offset === 'top' ? 0 : 1),
// childIndex: linearIndex - parentLinearIndex - 1 + (offset === 'top' ? 0 : 1),
// childIndex: environment.items[parent.item].children!.indexOf(targetItem.item) + (offset === 'top' ? 0 : 1),
childIndex: newChildIndex,

@@ -262,0 +271,0 @@ linePosition: offset,

Sorry, the diff of this file is too big to display

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