refactor(boolean-props): omit is prefix
This commit is contained in:
+9
-9
@@ -32,10 +32,10 @@ import { createNodeInternals } from './utils';
|
||||
|
||||
const { Provider, useStore, useStoreApi } = createContext<ReactFlowState>();
|
||||
|
||||
const createNodeOrEdgeSelectionChange = (isSelected: boolean) => (item: Node | Edge) => ({
|
||||
const createNodeOrEdgeSelectionChange = (selected: boolean) => (item: Node | Edge) => ({
|
||||
id: item.id,
|
||||
type: 'select',
|
||||
isSelected,
|
||||
selected,
|
||||
});
|
||||
|
||||
const createStore = () =>
|
||||
@@ -141,11 +141,11 @@ const createStore = () =>
|
||||
|
||||
onNodesChange?.(nodesToChange);
|
||||
},
|
||||
updateNodePosition: ({ id, diff, isDragging }: NodeDiffUpdate) => {
|
||||
updateNodePosition: ({ id, diff, dragging }: NodeDiffUpdate) => {
|
||||
const { onNodesChange, nodes, nodeExtent, nodeInternals } = get();
|
||||
|
||||
if (onNodesChange) {
|
||||
const matchingNodes = nodes.filter((n) => !!(n.isSelected || n.id === id));
|
||||
const matchingNodes = nodes.filter((n) => !!(n.selected || n.id === id));
|
||||
|
||||
if (matchingNodes?.length) {
|
||||
onNodesChange(
|
||||
@@ -153,7 +153,7 @@ const createStore = () =>
|
||||
const change: NodeDimensionChange = {
|
||||
id: node.id,
|
||||
type: 'dimensions',
|
||||
isDragging: !!isDragging,
|
||||
dragging: !!dragging,
|
||||
};
|
||||
|
||||
if (diff) {
|
||||
@@ -231,7 +231,7 @@ const createStore = () =>
|
||||
},
|
||||
unsetUserSelection: () => {
|
||||
const { userSelectionRect, nodes } = get();
|
||||
const selectedNodes = nodes.filter((node) => node.isSelected);
|
||||
const selectedNodes = nodes.filter((node) => node.selected);
|
||||
|
||||
const stateUpdate = {
|
||||
selectionActive: false,
|
||||
@@ -281,7 +281,7 @@ const createStore = () =>
|
||||
const { nodes, edges, onNodesChange, onEdgesChange } = get();
|
||||
|
||||
const nodesToUnselect = nodes.map((n) => {
|
||||
n.isSelected = false;
|
||||
n.selected = false;
|
||||
return createNodeOrEdgeSelectionChange(false)(n);
|
||||
}) as NodeChange[];
|
||||
const edgesToUnselect = edges.map(createNodeOrEdgeSelectionChange(false)) as EdgeChange[];
|
||||
@@ -322,8 +322,8 @@ const createStore = () =>
|
||||
resetSelectedElements: () => {
|
||||
const { nodes, edges, onNodesChange, onEdgesChange } = get();
|
||||
|
||||
const nodesToUnselect = nodes.filter((e) => e.isSelected).map(createNodeOrEdgeSelectionChange(false));
|
||||
const edgesToUnselect = edges.filter((e) => e.isSelected).map(createNodeOrEdgeSelectionChange(false));
|
||||
const nodesToUnselect = nodes.filter((e) => e.selected).map(createNodeOrEdgeSelectionChange(false));
|
||||
const edgesToUnselect = edges.filter((e) => e.selected).map(createNodeOrEdgeSelectionChange(false));
|
||||
|
||||
if (nodesToUnselect.length) {
|
||||
onNodesChange?.(nodesToUnselect as NodeChange[]);
|
||||
|
||||
+3
-3
@@ -44,7 +44,7 @@ export function createNodeInternals(nodes: Node[], nodeInternals: NodeInternals)
|
||||
height: node.height || null,
|
||||
position: node.position,
|
||||
positionAbsolute: node.position,
|
||||
z: node.isDragging || node.isSelected ? 1000 : node.zIndex || 0,
|
||||
z: node.dragging || node.selected ? 1000 : node.zIndex || 0,
|
||||
};
|
||||
if (node.parentNode) {
|
||||
internals.parentNode = node.parentNode;
|
||||
@@ -57,7 +57,7 @@ export function createNodeInternals(nodes: Node[], nodeInternals: NodeInternals)
|
||||
const updatedInternals: NodeInternalsItem = nextNodeInternals.get(node.id)!;
|
||||
|
||||
if (node.parentNode || parentNodes[node.id]) {
|
||||
let startingZ = updatedInternals.z;
|
||||
let startingZ = updatedInternals.z || 0;
|
||||
|
||||
if (!startingZ) {
|
||||
if (parentNodes[node.id] && node.parentNode) {
|
||||
@@ -69,7 +69,7 @@ export function createNodeInternals(nodes: Node[], nodeInternals: NodeInternals)
|
||||
|
||||
const { x, y, z } = calculateXYZPosition(node, nextNodeInternals, parentNodes, {
|
||||
...node.position,
|
||||
z: startingZ as number,
|
||||
z: startingZ,
|
||||
});
|
||||
|
||||
updatedInternals.positionAbsolute = {
|
||||
|
||||
Reference in New Issue
Block a user