chore: lint files
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -25,8 +25,11 @@ function handleParentExpand(updateItem: GraphNode, parent: GraphNode) {
|
||||
if (extendWidth > 0 || extendHeight > 0 || updateItem.position.x < 0 || updateItem.position.y < 0) {
|
||||
let parentStyles: Styles = {}
|
||||
|
||||
if (isFunction(parent.style)) parentStyles = { ...parent.style(parent) }
|
||||
else if (parent.style) parentStyles = { ...parent.style }
|
||||
if (isFunction(parent.style)) {
|
||||
parentStyles = { ...parent.style(parent) }
|
||||
} else if (parent.style) {
|
||||
parentStyles = { ...parent.style }
|
||||
}
|
||||
|
||||
parentStyles.width = parentStyles.width ?? `${parent.dimensions.width}px`
|
||||
parentStyles.height = parentStyles.height ?? `${parent.dimensions.height}px`
|
||||
@@ -114,11 +117,15 @@ export function applyChanges<
|
||||
if (change.type === 'add') {
|
||||
const index = elements.findIndex((el) => el.id === change.item.id)
|
||||
|
||||
if (index === -1) elements.push(<T>change.item)
|
||||
if (index === -1) {
|
||||
elements.push(<T>change.item)
|
||||
}
|
||||
} else if (change.type === 'remove') {
|
||||
const index = elements.findIndex((el) => el.id === change.id)
|
||||
|
||||
if (index !== -1) elements.splice(index, 1)
|
||||
if (index !== -1) {
|
||||
elements.splice(index, 1)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -134,9 +141,13 @@ export function applyChanges<
|
||||
break
|
||||
case 'position':
|
||||
if (isGraphNode(element)) {
|
||||
if (typeof currentChange.position !== 'undefined') element.position = currentChange.position
|
||||
if (typeof currentChange.position !== 'undefined') {
|
||||
element.position = currentChange.position
|
||||
}
|
||||
|
||||
if (typeof currentChange.dragging !== 'undefined') element.dragging = currentChange.dragging
|
||||
if (typeof currentChange.dragging !== 'undefined') {
|
||||
element.dragging = currentChange.dragging
|
||||
}
|
||||
|
||||
if (element.expandParent && element.parentNode) {
|
||||
const parent = elements[elementIds.indexOf(element.parentNode)]
|
||||
@@ -149,7 +160,9 @@ export function applyChanges<
|
||||
break
|
||||
case 'dimensions':
|
||||
if (isGraphNode(element)) {
|
||||
if (typeof currentChange.dimensions !== 'undefined') element.dimensions = currentChange.dimensions
|
||||
if (typeof currentChange.dimensions !== 'undefined') {
|
||||
element.dimensions = currentChange.dimensions
|
||||
}
|
||||
|
||||
if (typeof currentChange.updateStyle !== 'undefined') {
|
||||
element.style = {
|
||||
@@ -159,7 +172,9 @@ export function applyChanges<
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof currentChange.resizing !== 'undefined') element.resizing = currentChange.resizing
|
||||
if (typeof currentChange.resizing !== 'undefined') {
|
||||
element.resizing = currentChange.resizing
|
||||
}
|
||||
|
||||
if (element.expandParent && element.parentNode) {
|
||||
const parent = elements[elementIds.indexOf(element.parentNode)]
|
||||
@@ -175,7 +190,9 @@ export function applyChanges<
|
||||
}
|
||||
}
|
||||
|
||||
if (!element.initialized) element.initialized = true
|
||||
if (!element.initialized) {
|
||||
element.initialized = true
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
@@ -5,8 +5,11 @@ export function hasSelector(target: Element, selector: string, node: Element): b
|
||||
let current = target
|
||||
|
||||
do {
|
||||
if (current && current.matches(selector)) return true
|
||||
else if (current === node) return false
|
||||
if (current && current.matches(selector)) {
|
||||
return true
|
||||
} else if (current === node) {
|
||||
return false
|
||||
}
|
||||
|
||||
current = current.parentElement as Element
|
||||
} while (current)
|
||||
|
||||
@@ -141,7 +141,9 @@ export function groupEdgesByZLevel(edges: GraphEdge[], findNode: Actions['findNo
|
||||
const source = findNode(edge.source)
|
||||
const target = findNode(edge.target)
|
||||
|
||||
if (!source || !target) return tree
|
||||
if (!source || !target) {
|
||||
return tree
|
||||
}
|
||||
|
||||
if (elevateEdgesOnSelect) {
|
||||
z = hasZIndex ? edge.zIndex! : Math.max(source.computedPosition.z || 0, target.computedPosition.z || 0)
|
||||
|
||||
@@ -58,8 +58,11 @@ export function getHostForElement(element: HTMLElement): Document {
|
||||
const doc = element.getRootNode() as Document
|
||||
const window = useWindow()
|
||||
|
||||
if ('elementFromPoint' in doc) return doc
|
||||
else return window.document
|
||||
if ('elementFromPoint' in doc) {
|
||||
return doc
|
||||
} else {
|
||||
return window.document
|
||||
}
|
||||
}
|
||||
|
||||
export function isEdge<Data = ElementData>(element: MaybeElement): element is Edge<Data> {
|
||||
@@ -147,7 +150,9 @@ function getConnectedElements<T extends Elements = FlowElements>(
|
||||
elements: T,
|
||||
dir: 'source' | 'target',
|
||||
): T extends FlowElements ? GraphNode[] : Node[] {
|
||||
if (!isNode(node)) return []
|
||||
if (!isNode(node)) {
|
||||
return []
|
||||
}
|
||||
const origin = dir === 'source' ? 'target' : 'source'
|
||||
const ids = elements.filter((e) => isEdge(e) && e[origin] === node.id).map((e) => isEdge(e) && e[dir])
|
||||
return elements.filter((e) => ids.includes(e.id)) as T extends FlowElements ? GraphNode[] : Node[]
|
||||
@@ -200,7 +205,9 @@ export function addEdge(edgeParams: Edge | Connection, elements: Elements, defau
|
||||
|
||||
edge = parseEdge(edge, defaults)
|
||||
|
||||
if (connectionExists(edge, elements)) return elements
|
||||
if (connectionExists(edge, elements)) {
|
||||
return elements
|
||||
}
|
||||
|
||||
elements.push(edge)
|
||||
|
||||
@@ -363,6 +370,21 @@ export function getConnectedEdges(nodes: (Node | GraphNode | { id: string })[],
|
||||
return edges.filter((edge) => nodeIds.includes(edge.source) || nodeIds.includes(edge.target))
|
||||
}
|
||||
|
||||
export function getConnectedNodes(nodes: (Node | GraphNode | { id: string })[], edges: GraphEdge[]) {
|
||||
const nodeIds = nodes.map((node) => node.id)
|
||||
const connectedNodeIds = edges.reduce((acc, edge) => {
|
||||
if (nodeIds.includes(edge.source)) {
|
||||
acc.add(edge.target)
|
||||
}
|
||||
if (nodeIds.includes(edge.target)) {
|
||||
acc.add(edge.source)
|
||||
}
|
||||
return acc
|
||||
}, new Set<string>())
|
||||
|
||||
return nodes.filter((node) => connectedNodeIds.has(node.id))
|
||||
}
|
||||
|
||||
export function getTransformForBounds(
|
||||
bounds: Rect,
|
||||
width: number,
|
||||
@@ -396,20 +418,30 @@ export function getXYZPos(parentPos: XYZPosition, computedPosition: XYZPosition)
|
||||
}
|
||||
|
||||
export function isParentSelected(node: GraphNode, findNode: Actions['findNode']): boolean {
|
||||
if (!node.parentNode) return false
|
||||
if (!node.parentNode) {
|
||||
return false
|
||||
}
|
||||
|
||||
const parent = findNode(node.parentNode)
|
||||
if (!parent) return false
|
||||
if (!parent) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (parent.selected) return true
|
||||
if (parent.selected) {
|
||||
return true
|
||||
}
|
||||
|
||||
return isParentSelected(parent, findNode)
|
||||
}
|
||||
|
||||
export function getMarkerId(marker: EdgeMarkerType | undefined, vueFlowId?: string) {
|
||||
if (typeof marker === 'undefined') return ''
|
||||
if (typeof marker === 'undefined') {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (typeof marker === 'string') return marker
|
||||
if (typeof marker === 'string') {
|
||||
return marker
|
||||
}
|
||||
|
||||
const idPrefix = vueFlowId ? `${vueFlowId}__` : ''
|
||||
|
||||
|
||||
@@ -26,7 +26,9 @@ export function addEdgeToStore(edgeParams: Edge | Connection, edges: Edge[], onE
|
||||
|
||||
edge = parseEdge(edge)
|
||||
|
||||
if (connectionExists(edge, edges)) return false
|
||||
if (connectionExists(edge, edges)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return edge
|
||||
}
|
||||
@@ -102,7 +104,9 @@ export function createGraphNodes(
|
||||
node.isParent = true
|
||||
}
|
||||
|
||||
if (parentNode) parentNode.isParent = true
|
||||
if (parentNode) {
|
||||
parentNode.isParent = true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -26,8 +26,11 @@ export function useWatch(
|
||||
store.setElements(elements)
|
||||
|
||||
// only trigger store watcher immediately if we actually set any elements to the store
|
||||
if (!pauseStore && !immediateStore && elements.length) immediateStore = true
|
||||
else pauseStore?.resume()
|
||||
if (!pauseStore && !immediateStore && elements.length) {
|
||||
immediateStore = true
|
||||
} else {
|
||||
pauseStore?.resume()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -69,8 +72,11 @@ export function useWatch(
|
||||
store.setNodes(nodes)
|
||||
|
||||
// only trigger store watcher immediately if we actually set any elements to the store
|
||||
if (!pauseStore && !immediateStore && nodes.length) immediateStore = true
|
||||
else pauseStore?.resume()
|
||||
if (!pauseStore && !immediateStore && nodes.length) {
|
||||
immediateStore = true
|
||||
} else {
|
||||
pauseStore?.resume()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -112,8 +118,11 @@ export function useWatch(
|
||||
store.setEdges(edges)
|
||||
|
||||
// only trigger store watcher immediately if we actually set any elements to the store
|
||||
if (!pauseStore && !immediateStore && edges.length) immediateStore = true
|
||||
else pauseStore?.resume()
|
||||
if (!pauseStore && !immediateStore && edges.length) {
|
||||
immediateStore = true
|
||||
} else {
|
||||
pauseStore?.resume()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user