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.0.4 to 2.1.0

5

lib/cjs/controlledEnvironment/useGetParentOfLinearItem.d.ts

@@ -1,1 +0,4 @@

export declare const useGetGetParentOfLinearItem: () => (itemLinearIndex: number, treeId: string) => import("..").LinearItem;
export declare const useGetGetParentOfLinearItem: () => (itemLinearIndex: number, treeId: string) => {
parent: import("..").LinearItem;
parentLinearIndex: number;
};

2

lib/cjs/controlledEnvironment/useGetParentOfLinearItem.js

@@ -20,5 +20,5 @@ "use strict";

}
return parent;
return { parent: parent, parentLinearIndex: parentLinearIndex };
}, [environment.linearItems, environment.trees]);
};
exports.useGetGetParentOfLinearItem = useGetGetParentOfLinearItem;

@@ -27,3 +27,3 @@ "use strict";

var item = _a.item, depth = _a.depth;
var parent = getParentOfLinearItem(linearIndex, treeId);
var parent = getParentOfLinearItem(linearIndex, treeId).parent;
var childIndex = environment.items[parent.item].children.indexOf(item);

@@ -30,0 +30,0 @@ var itemPosition = {

@@ -8,3 +8,3 @@ "use strict";

var use_stable_handler_1 = require("../use-stable-handler");
var getHoveringPosition = function (clientY, treeTop, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder) {
var getHoveringPosition = function (clientY, treeTop, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems) {
var hoveringPosition = (clientY - treeTop) / itemHeight;

@@ -24,3 +24,7 @@ var treeLinearItems = linearItems[treeId];

var offset;
var lineThreshold = ((targetItem === null || targetItem === void 0 ? void 0 : targetItem.isFolder) && canDropOnFolder) || canDropOnNonFolder ? 0.2 : 0.5;
var lineThreshold = !canReorderItems
? 0
: ((targetItem === null || targetItem === void 0 ? void 0 : targetItem.isFolder) && canDropOnFolder) || canDropOnNonFolder
? 0.2
: 0.5;
if (hoveringPosition % 1 < lineThreshold) {

@@ -64,3 +68,3 @@ offset = 'top';

}
var _c = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder), linearIndex = _c.linearIndex, offset = _c.offset;
var _c = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems), linearIndex = _c.linearIndex, offset = _c.offset;
var nextDragCode = outsideContainer

@@ -82,2 +86,10 @@ ? 'outside'

var targetItem = linearItems[treeId][linearIndex];
var redirectTargetToParent = !canReorderItems &&
!canDropOnNonFolder &&
!items[targetItem.item].isFolder;
if (redirectTargetToParent) {
var _d = getParentOfLinearItem(linearIndex, treeId), parentLinearIndex = _d.parentLinearIndex, parent_1 = _d.parent;
targetItem = parent_1;
linearIndex = parentLinearIndex;
}
var depth = targetItem.depth;

@@ -97,3 +109,3 @@ var targetItemData = items[targetItem.item];

}
var parent = getParentOfLinearItem(linearIndex, treeId);
var parent = getParentOfLinearItem(linearIndex, treeId).parent;
if (draggingItems.some(function (draggingItem) { return draggingItem.index === targetItem.item; })) {

@@ -100,0 +112,0 @@ return;

@@ -0,1 +1,2 @@

/// <reference types="react" />
export declare const TreeManager: () => JSX.Element;

@@ -0,1 +1,2 @@

/// <reference types="react" />
import { TreeItemIndex } from '../types';

@@ -2,0 +3,0 @@ export declare const TreeItem: (props: {

@@ -0,1 +1,2 @@

/// <reference types="react" />
import { TreeItemIndex } from '../types';

@@ -2,0 +3,0 @@ export declare const TreeItemChildren: (props: {

@@ -1,1 +0,4 @@

export declare const useGetGetParentOfLinearItem: () => (itemLinearIndex: number, treeId: string) => import("..").LinearItem;
export declare const useGetGetParentOfLinearItem: () => (itemLinearIndex: number, treeId: string) => {
parent: import("..").LinearItem;
parentLinearIndex: number;
};

@@ -17,4 +17,4 @@ import { useCallback } from 'react';

}
return parent;
return { parent: parent, parentLinearIndex: parentLinearIndex };
}, [environment.linearItems, environment.trees]);
};

@@ -24,3 +24,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {

var item = _a.item, depth = _a.depth;
var parent = getParentOfLinearItem(linearIndex, treeId);
var parent = getParentOfLinearItem(linearIndex, treeId).parent;
var childIndex = environment.items[parent.item].children.indexOf(item);

@@ -27,0 +27,0 @@ var itemPosition = {

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

import { useStableHandler } from '../use-stable-handler';
var getHoveringPosition = function (clientY, treeTop, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder) {
var getHoveringPosition = function (clientY, treeTop, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems) {
var hoveringPosition = (clientY - treeTop) / itemHeight;

@@ -21,3 +21,7 @@ var treeLinearItems = linearItems[treeId];

var offset;
var lineThreshold = ((targetItem === null || targetItem === void 0 ? void 0 : targetItem.isFolder) && canDropOnFolder) || canDropOnNonFolder ? 0.2 : 0.5;
var lineThreshold = !canReorderItems
? 0
: ((targetItem === null || targetItem === void 0 ? void 0 : targetItem.isFolder) && canDropOnFolder) || canDropOnNonFolder
? 0.2
: 0.5;
if (hoveringPosition % 1 < lineThreshold) {

@@ -61,3 +65,3 @@ offset = 'top';

}
var _c = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder), linearIndex = _c.linearIndex, offset = _c.offset;
var _c = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems), linearIndex = _c.linearIndex, offset = _c.offset;
var nextDragCode = outsideContainer

@@ -79,2 +83,10 @@ ? 'outside'

var targetItem = linearItems[treeId][linearIndex];
var redirectTargetToParent = !canReorderItems &&
!canDropOnNonFolder &&
!items[targetItem.item].isFolder;
if (redirectTargetToParent) {
var _d = getParentOfLinearItem(linearIndex, treeId), parentLinearIndex = _d.parentLinearIndex, parent_1 = _d.parent;
targetItem = parent_1;
linearIndex = parentLinearIndex;
}
var depth = targetItem.depth;

@@ -94,3 +106,3 @@ var targetItemData = items[targetItem.item];

}
var parent = getParentOfLinearItem(linearIndex, treeId);
var parent = getParentOfLinearItem(linearIndex, treeId).parent;
if (draggingItems.some(function (draggingItem) { return draggingItem.index === targetItem.item; })) {

@@ -97,0 +109,0 @@ return;

@@ -1,1 +0,4 @@

export declare const useGetGetParentOfLinearItem: () => (itemLinearIndex: number, treeId: string) => import("..").LinearItem;
export declare const useGetGetParentOfLinearItem: () => (itemLinearIndex: number, treeId: string) => {
parent: import("..").LinearItem;
parentLinearIndex: number;
};

@@ -17,4 +17,4 @@ import { useCallback } from 'react';

}
return parent;
return { parent: parent, parentLinearIndex: parentLinearIndex };
}, [environment.linearItems, environment.trees]);
};

@@ -24,3 +24,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {

var item = _a.item, depth = _a.depth;
var parent = getParentOfLinearItem(linearIndex, treeId);
var parent = getParentOfLinearItem(linearIndex, treeId).parent;
var childIndex = environment.items[parent.item].children.indexOf(item);

@@ -27,0 +27,0 @@ var itemPosition = {

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

import { useStableHandler } from '../use-stable-handler';
var getHoveringPosition = function (clientY, treeTop, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder) {
var getHoveringPosition = function (clientY, treeTop, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems) {
var hoveringPosition = (clientY - treeTop) / itemHeight;

@@ -21,3 +21,7 @@ var treeLinearItems = linearItems[treeId];

var offset;
var lineThreshold = ((targetItem === null || targetItem === void 0 ? void 0 : targetItem.isFolder) && canDropOnFolder) || canDropOnNonFolder ? 0.2 : 0.5;
var lineThreshold = !canReorderItems
? 0
: ((targetItem === null || targetItem === void 0 ? void 0 : targetItem.isFolder) && canDropOnFolder) || canDropOnNonFolder
? 0.2
: 0.5;
if (hoveringPosition % 1 < lineThreshold) {

@@ -61,3 +65,3 @@ offset = 'top';

}
var _c = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder), linearIndex = _c.linearIndex, offset = _c.offset;
var _c = getHoveringPosition(e.clientY, treeBb.top, itemHeight, linearItems, treeId, items, canDropOnFolder, canDropOnNonFolder, canReorderItems), linearIndex = _c.linearIndex, offset = _c.offset;
var nextDragCode = outsideContainer

@@ -79,2 +83,10 @@ ? 'outside'

var targetItem = linearItems[treeId][linearIndex];
var redirectTargetToParent = !canReorderItems &&
!canDropOnNonFolder &&
!items[targetItem.item].isFolder;
if (redirectTargetToParent) {
var _d = getParentOfLinearItem(linearIndex, treeId), parentLinearIndex = _d.parentLinearIndex, parent_1 = _d.parent;
targetItem = parent_1;
linearIndex = parentLinearIndex;
}
var depth = targetItem.depth;

@@ -94,3 +106,3 @@ var targetItemData = items[targetItem.item];

}
var parent = getParentOfLinearItem(linearIndex, treeId);
var parent = getParentOfLinearItem(linearIndex, treeId).parent;
if (draggingItems.some(function (draggingItem) { return draggingItem.index === targetItem.item; })) {

@@ -97,0 +109,0 @@ return;

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

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

"cpy-cli": "^3.1.1",
"demodata": "^2.0.4",
"demodata": "^2.1.0",
"jest": "^29.2.2",

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

},
"gitHead": "c0d35bcbc108ac10030cc568a3bc316cdbe4b312"
"gitHead": "40c728bed52c80e8bd00d57658edb38c252f08a5"
}

@@ -25,3 +25,3 @@ import { useCallback } from 'react';

return parent;
return { parent, parentLinearIndex };
},

@@ -28,0 +28,0 @@ [environment.linearItems, environment.trees]

@@ -17,3 +17,3 @@ import { useCallback } from 'react';

.map<DraggingPosition[]>(({ item, depth }, linearIndex) => {
const parent = getParentOfLinearItem(linearIndex, treeId);
const { parent } = getParentOfLinearItem(linearIndex, treeId);
const childIndex =

@@ -20,0 +20,0 @@ environment.items[parent.item].children!.indexOf(item);

@@ -21,3 +21,4 @@ import * as React from 'react';

canDropOnFolder?: boolean,
canDropOnNonFolder?: boolean
canDropOnNonFolder?: boolean,
canReorderItems?: boolean
) => {

@@ -42,4 +43,7 @@ const hoveringPosition = (clientY - treeTop) / itemHeight;

const lineThreshold =
(targetItem?.isFolder && canDropOnFolder) || canDropOnNonFolder ? 0.2 : 0.5;
const lineThreshold = !canReorderItems
? 0
: (targetItem?.isFolder && canDropOnFolder) || canDropOnNonFolder
? 0.2
: 0.5;

@@ -119,3 +123,4 @@ if (hoveringPosition % 1 < lineThreshold) {

canDropOnFolder,
canDropOnNonFolder
canDropOnNonFolder,
canReorderItems
);

@@ -143,3 +148,17 @@

const targetItem = linearItems[treeId][linearIndex];
let targetItem = linearItems[treeId][linearIndex];
const redirectTargetToParent =
!canReorderItems &&
!canDropOnNonFolder &&
!items[targetItem.item].isFolder;
if (redirectTargetToParent) {
const { parentLinearIndex, parent } = getParentOfLinearItem(
linearIndex,
treeId
);
targetItem = parent;
linearIndex = parentLinearIndex;
}
const { depth } = targetItem;

@@ -163,3 +182,3 @@ const targetItemData = items[targetItem.item];

const parent = getParentOfLinearItem(linearIndex, treeId);
const { parent } = getParentOfLinearItem(linearIndex, treeId);

@@ -166,0 +185,0 @@ if (

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