Socket
Socket
Sign inDemoInstall

@reactflow/node-toolbar

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reactflow/node-toolbar - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

25

dist/esm/index.js

@@ -23,2 +23,5 @@ import { jsx } from 'react/jsx-runtime';

a?.[internalsSymbol]?.z === b?.[internalsSymbol]?.z;
const nodesEqualityFn = (a, b) => {
return a.length === b.length && a.every((node, i) => nodeEqualityFn(node, b[i]));
};
const storeSelector = (state) => ({

@@ -56,14 +59,24 @@ transform: state.transform,

function NodeToolbar({ nodeId, children, className, style, isVisible, position = Position.Top, offset = 10, ...rest }) {
const nodeSelector = useCallback((state) => state.nodeInternals.get(nodeId), [nodeId]);
const node = useStore(nodeSelector, nodeEqualityFn);
const nodesSelector = useCallback((state) => {
const nodeIds = typeof nodeId === 'string' ? [nodeId] : nodeId;
return nodeIds.reduce((acc, id) => {
const node = state.nodeInternals.get(id);
if (node) {
acc.push(node);
}
return acc;
}, []);
}, [nodeId]);
const nodes = useStore(nodesSelector, nodesEqualityFn);
const { transform, nodeOrigin, selectedNodesCount } = useStore(storeSelector, shallow);
const isActive = typeof isVisible === 'boolean' ? isVisible : node?.selected && selectedNodesCount === 1;
if (!isActive || !node) {
const isActive = typeof isVisible === 'boolean' ? isVisible : nodes.length === 1 && nodes[0].selected && selectedNodesCount === 1;
if (!isActive || !nodes.length) {
return null;
}
const nodeRect = getRectOfNodes([node], nodeOrigin);
const nodeRect = getRectOfNodes(nodes, nodeOrigin);
const zIndex = Math.max(...nodes.map((node) => (node[internalsSymbol]?.z || 1) + 1));
const wrapperStyle = {
position: 'absolute',
transform: getTransform(nodeRect, transform, position, offset),
zIndex: (node[internalsSymbol]?.z || 1) + 1,
zIndex,
...style,

@@ -70,0 +83,0 @@ };

import { Position } from '@reactflow/core';
import type { HTMLAttributes } from 'react';
export declare type NodeToolbarProps = HTMLAttributes<HTMLDivElement> & {
nodeId: string;
nodeId: string | string[];
isVisible?: boolean;

@@ -6,0 +6,0 @@ position?: Position;

import { Position } from '@reactflow/core';
import type { HTMLAttributes } from 'react';
export declare type NodeToolbarProps = HTMLAttributes<HTMLDivElement> & {
nodeId: string;
nodeId: string | string[];
isVisible?: boolean;

@@ -6,0 +6,0 @@ position?: Position;

{
"name": "@reactflow/node-toolbar",
"version": "1.0.0",
"version": "1.0.1",
"description": "A toolbar component for React Flow that can be attached to a node.",

@@ -34,3 +34,3 @@ "keywords": [

"@babel/runtime": "^7.18.9",
"@reactflow/core": "11.3.0",
"@reactflow/core": "11.3.1",
"classcat": "^5.0.3",

@@ -37,0 +37,0 @@ "zustand": "^4.1.1"

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 too big to display

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