merge main
This commit is contained in:
@@ -1,5 +1,21 @@
|
||||
# @xyflow/system
|
||||
|
||||
## 0.0.49
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4949](https://github.com/xyflow/xyflow/pull/4949) [`592c7eaf`](https://github.com/xyflow/xyflow/commit/592c7eaf9574fc69df3123837da95f85877b23e8) Thanks [@peterkogo](https://github.com/peterkogo)! - Fix useNodeConnection hook not returning all connected edges.
|
||||
|
||||
## 0.0.48
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4880](https://github.com/xyflow/xyflow/pull/4880) [`e2d849dc`](https://github.com/xyflow/xyflow/commit/e2d849dca63aee5952f676aef1c675c6232bb69a) Thanks [@crimx](https://github.com/crimx)! - Add type check for all event targets
|
||||
|
||||
- [#4725](https://github.com/xyflow/xyflow/pull/4725) [`e10f53cf`](https://github.com/xyflow/xyflow/commit/e10f53cf898a56f954783d6efcf6977a0d88f4a9) Thanks [@peterkogo](https://github.com/peterkogo)! - Add useNodeConnections hook to track all connections to a node. Can be filtered by handleType and handleId.
|
||||
|
||||
- [#4929](https://github.com/xyflow/xyflow/pull/4929) [`4947f683`](https://github.com/xyflow/xyflow/commit/4947f683b7530f8e6684865ab53ea38633de0f4d) Thanks [@peterkogo](https://github.com/peterkogo)! - Optimize selections and take into account if edges connected to selected nodes are actually selectable.
|
||||
|
||||
## 0.0.47
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@xyflow/system",
|
||||
"version": "0.0.47",
|
||||
"version": "0.0.49",
|
||||
"description": "xyflow core system that powers React Flow and Svelte Flow.",
|
||||
"keywords": [
|
||||
"node-based UI",
|
||||
|
||||
@@ -32,18 +32,20 @@ export const getDimensions = (node: HTMLDivElement): Dimensions => ({
|
||||
height: node.offsetHeight,
|
||||
});
|
||||
|
||||
export const getHostForElement = (element: HTMLElement): Document | ShadowRoot =>
|
||||
(element.getRootNode?.() as Document | ShadowRoot) || window?.document;
|
||||
export const getHostForElement = (element: HTMLElement | EventTarget | null): Document | ShadowRoot =>
|
||||
((element as Partial<HTMLElement> | null)?.getRootNode?.() as Document | ShadowRoot) || window?.document;
|
||||
|
||||
const inputTags = ['INPUT', 'SELECT', 'TEXTAREA'];
|
||||
|
||||
export function isInputDOMNode(event: KeyboardEvent): boolean {
|
||||
// using composed path for handling shadow dom
|
||||
const target = (event.composedPath?.()?.[0] || event.target) as HTMLElement;
|
||||
const isInput = inputTags.includes(target?.nodeName) || target?.hasAttribute?.('contenteditable');
|
||||
const target = (event.composedPath?.()?.[0] || event.target) as Element | null;
|
||||
if (target?.nodeType !== 1 /* Node.ELEMENT_NODE */) return false;
|
||||
|
||||
const isInput = inputTags.includes(target.nodeName) || target.hasAttribute('contenteditable');
|
||||
|
||||
// when an input field is focused we don't want to trigger deletion or movement of nodes
|
||||
return isInput || !!target?.closest('.nokey');
|
||||
return isInput || !!target.closest('.nokey');
|
||||
}
|
||||
|
||||
export const isMouseEvent = (event: MouseEvent | TouchEvent): event is MouseEvent => 'clientX' in event;
|
||||
|
||||
@@ -498,8 +498,8 @@ export function updateConnectionLookup(connectionLookup: ConnectionLookup, edgeL
|
||||
const { source: sourceNode, target: targetNode, sourceHandle = null, targetHandle = null } = edge;
|
||||
|
||||
const connection = { edgeId: edge.id, source: sourceNode, target: targetNode, sourceHandle, targetHandle };
|
||||
const sourceKey = `${sourceNode}-${sourceHandle}`;
|
||||
const targetKey = `${targetNode}-${targetHandle}`;
|
||||
const sourceKey = `${sourceNode}-${sourceHandle}--${targetNode}-${targetHandle}`;
|
||||
const targetKey = `${targetNode}-${targetHandle}--${sourceNode}-${sourceHandle}`;
|
||||
|
||||
addConnectionToLookup('source', connection, targetKey, connectionLookup, sourceNode, sourceHandle);
|
||||
addConnectionToLookup('target', connection, sourceKey, connectionLookup, targetNode, targetHandle);
|
||||
|
||||
@@ -364,7 +364,7 @@ export function XYDrag<OnNodeDrag extends (e: any, nodes: any, node: any) => voi
|
||||
}
|
||||
})
|
||||
.filter((event: MouseEvent) => {
|
||||
const target = event.target as HTMLDivElement;
|
||||
const target = event.target;
|
||||
const isDraggable =
|
||||
!event.button &&
|
||||
(!noDragClassName || !hasSelector(target, `.${noDragClassName}`, domNode)) &&
|
||||
|
||||
@@ -18,13 +18,13 @@ export function isParentSelected<NodeType extends NodeBase>(node: NodeType, node
|
||||
return isParentSelected(parentNode, nodeLookup);
|
||||
}
|
||||
|
||||
export function hasSelector(target: Element, selector: string, domNode: Element): boolean {
|
||||
let current = target;
|
||||
export function hasSelector(target: Element | EventTarget | null, selector: string, domNode: Element): boolean {
|
||||
let current = target as Partial<Element> | null | undefined;
|
||||
|
||||
do {
|
||||
if (current?.matches(selector)) return true;
|
||||
if (current?.matches?.(selector)) return true;
|
||||
if (current === domNode) return false;
|
||||
current = current.parentElement as Element;
|
||||
current = current?.parentElement;
|
||||
} while (current);
|
||||
|
||||
return false;
|
||||
|
||||
@@ -48,7 +48,7 @@ function onPointerDown(
|
||||
}: OnPointerDownParams
|
||||
) {
|
||||
// when xyflow is used inside a shadow root we can't use document
|
||||
const doc = getHostForElement(event.target as HTMLElement);
|
||||
const doc = getHostForElement(event.target);
|
||||
let autoPanId = 0;
|
||||
let closestHandle: Handle | null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user