Skip to content

Commit 4947f68

Browse files
committed
Move areSetsEqual to system
1 parent a893cdd commit 4947f68

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
'@xyflow/react': patch
3+
'@xyflow/system': patch
34
---
45

56
Optimize selections and take into account if edges connected to selected nodes are actually selectable.

packages/react/src/container/Pane/index.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ import {
1010
} from 'react';
1111
import { shallow } from 'zustand/shallow';
1212
import cc from 'classcat';
13-
import { getNodesInside, getEventPosition, SelectionMode, type NodeChange, type EdgeChange } from '@xyflow/system';
13+
import {
14+
getNodesInside,
15+
getEventPosition,
16+
SelectionMode,
17+
areSetsEqual,
18+
type NodeChange,
19+
type EdgeChange,
20+
} from '@xyflow/system';
1421

1522
import { UserSelection } from '../../components/UserSelection';
1623
import { containerStyle } from '../../styles/utils';
@@ -39,20 +46,6 @@ type PaneProps = {
3946
>
4047
>;
4148

42-
function areSetsEqual(a: Set<string>, b: Set<string>) {
43-
if (a.size !== b.size) {
44-
return false;
45-
}
46-
47-
for (const item of a) {
48-
if (!b.has(item)) {
49-
return false;
50-
}
51-
}
52-
53-
return true;
54-
}
55-
5649
const wrapHandler = (
5750
handler: React.MouseEventHandler | undefined,
5851
containerRef: React.MutableRefObject<HTMLDivElement | null>

packages/system/src/utils/general.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,17 @@ export function evaluateAbsolutePosition(
263263

264264
return positionAbsolute;
265265
}
266+
267+
export function areSetsEqual(a: Set<string>, b: Set<string>) {
268+
if (a.size !== b.size) {
269+
return false;
270+
}
271+
272+
for (const item of a) {
273+
if (!b.has(item)) {
274+
return false;
275+
}
276+
}
277+
278+
return true;
279+
}

0 commit comments

Comments
 (0)