chore(app): cleanup
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
|
|
||||||
import { useStore } from '../../hooks/useStore';
|
import { useStore } from '../../hooks/useStore';
|
||||||
import { ReactFlowState } from '../../types';
|
import { ReactFlowState } from '../../types';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import EdgeText from './EdgeText';
|
import EdgeText from './EdgeText';
|
||||||
import type { BaseEdgeProps } from '../../types';
|
|
||||||
import { isNumeric } from '../../utils';
|
import { isNumeric } from '../../utils';
|
||||||
|
import type { BaseEdgeProps } from '../../types';
|
||||||
|
|
||||||
const BaseEdge = ({
|
const BaseEdge = ({
|
||||||
path,
|
path,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { EdgeAnchor } from './EdgeAnchor';
|
|||||||
import { getMarkerId } from '../../utils/graph';
|
import { getMarkerId } from '../../utils/graph';
|
||||||
import { getMouseHandler } from './utils';
|
import { getMouseHandler } from './utils';
|
||||||
import { elementSelectionKeys } from '../../utils';
|
import { elementSelectionKeys } from '../../utils';
|
||||||
import type { EdgeProps, WrapEdgeProps, Connection, HandleType } from '../../types';
|
import type { EdgeProps, WrapEdgeProps, Connection } from '../../types';
|
||||||
|
|
||||||
export default (EdgeComponent: ComponentType<EdgeProps>) => {
|
export default (EdgeComponent: ComponentType<EdgeProps>) => {
|
||||||
const EdgeWrapper = ({
|
const EdgeWrapper = ({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ConnectionMode } from '../../types';
|
import { ConnectionMode } from '../../types';
|
||||||
import type { Connection, HandleType, XYPosition, Node, NodeHandleBounds } from '../../types';
|
|
||||||
import { internalsSymbol } from '../../utils';
|
import { internalsSymbol } from '../../utils';
|
||||||
|
import type { Connection, HandleType, XYPosition, Node, NodeHandleBounds } from '../../types';
|
||||||
|
|
||||||
export type ConnectionHandle = {
|
export type ConnectionHandle = {
|
||||||
id: string | null;
|
id: string | null;
|
||||||
|
|||||||
@@ -21,20 +21,18 @@ export interface NodesSelectionProps {
|
|||||||
disableKeyboardA11y: boolean;
|
disableKeyboardA11y: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const selector = (s: ReactFlowState) => ({
|
const selector = (s: ReactFlowState) => {
|
||||||
transformString: `translate(${s.transform[0]}px,${s.transform[1]}px) scale(${s.transform[2]})`,
|
|
||||||
userSelectionActive: s.userSelectionActive,
|
|
||||||
});
|
|
||||||
|
|
||||||
const bboxSelector = (s: ReactFlowState) => {
|
|
||||||
const selectedNodes = s.getNodes().filter((n) => n.selected);
|
const selectedNodes = s.getNodes().filter((n) => n.selected);
|
||||||
return getRectOfNodes(selectedNodes, s.nodeOrigin);
|
return {
|
||||||
|
...getRectOfNodes(selectedNodes, s.nodeOrigin),
|
||||||
|
transformString: `translate(${s.transform[0]}px,${s.transform[1]}px) scale(${s.transform[2]})`,
|
||||||
|
userSelectionActive: s.userSelectionActive,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
function NodesSelection({ onSelectionContextMenu, noPanClassName, disableKeyboardA11y }: NodesSelectionProps) {
|
function NodesSelection({ onSelectionContextMenu, noPanClassName, disableKeyboardA11y }: NodesSelectionProps) {
|
||||||
const store = useStoreApi();
|
const store = useStoreApi();
|
||||||
const { transformString, userSelectionActive } = useStore(selector, shallow);
|
const { width, height, x: left, y: top, transformString, userSelectionActive } = useStore(selector, shallow);
|
||||||
const { width, height, x: left, y: top } = useStore(bboxSelector, shallow);
|
|
||||||
const updatePositions = useUpdateNodePositions();
|
const updatePositions = useUpdateNodePositions();
|
||||||
|
|
||||||
const nodeRef = useRef<HTMLDivElement>(null);
|
const nodeRef = useRef<HTMLDivElement>(null);
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ const selector = (s: ReactFlowState) => ({
|
|||||||
|
|
||||||
function UserSelection() {
|
function UserSelection() {
|
||||||
const { userSelectionActive, userSelectionRect } = useStore(selector, shallow);
|
const { userSelectionActive, userSelectionRect } = useStore(selector, shallow);
|
||||||
const showSelectionBox = userSelectionActive && userSelectionRect;
|
const isActive = userSelectionActive && userSelectionRect;
|
||||||
|
|
||||||
if (!showSelectionBox) {
|
if (!isActive) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export const MarkerSymbols = {
|
|||||||
|
|
||||||
export function useMarkerSymbol(type: MarkerType) {
|
export function useMarkerSymbol(type: MarkerType) {
|
||||||
const store = useStoreApi();
|
const store = useStoreApi();
|
||||||
|
|
||||||
const symbol = useMemo(() => {
|
const symbol = useMemo(() => {
|
||||||
const symbolExists = Object.prototype.hasOwnProperty.call(MarkerSymbols, type);
|
const symbolExists = Object.prototype.hasOwnProperty.call(MarkerSymbols, type);
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ export function useMarkerSymbol(type: MarkerType) {
|
|||||||
|
|
||||||
return MarkerSymbols[type];
|
return MarkerSymbols[type];
|
||||||
}, [type]);
|
}, [type]);
|
||||||
|
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import NodeRenderer from '../NodeRenderer';
|
|||||||
import EdgeRenderer from '../EdgeRenderer';
|
import EdgeRenderer from '../EdgeRenderer';
|
||||||
import ViewportWrapper from '../Viewport';
|
import ViewportWrapper from '../Viewport';
|
||||||
import useOnInitHandler from '../../hooks/useOnInitHandler';
|
import useOnInitHandler from '../../hooks/useOnInitHandler';
|
||||||
import type { EdgeTypesWrapped, NodeTypesWrapped, ReactFlowProps } from '../../types';
|
|
||||||
import ConnectionLine from '../../components/ConnectionLine';
|
import ConnectionLine from '../../components/ConnectionLine';
|
||||||
|
import type { EdgeTypesWrapped, NodeTypesWrapped, ReactFlowProps } from '../../types';
|
||||||
|
|
||||||
export type GraphViewProps = Omit<ReactFlowProps, 'onSelectionChange' | 'nodes' | 'edges' | 'nodeTypes' | 'edgeTypes'> &
|
export type GraphViewProps = Omit<ReactFlowProps, 'onSelectionChange' | 'nodes' | 'edges' | 'nodeTypes' | 'edgeTypes'> &
|
||||||
Required<
|
Required<
|
||||||
|
|||||||
Reference in New Issue
Block a user