refactor(utils): put in folder
This commit is contained in:
@@ -3,7 +3,7 @@ import { useStoreState } from 'easy-peasy';
|
|||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
import { isFunction } from '../../utils'
|
import { isFunction } from '../../utils'
|
||||||
import { getNodesInside } from '../../graph-utils';
|
import { getNodesInside } from '../../utils/graph';
|
||||||
|
|
||||||
const baseStyle = {
|
const baseStyle = {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import { action } from 'easy-peasy';
|
import { action } from 'easy-peasy';
|
||||||
import isEqual from 'fast-deep-equal';
|
import isEqual from 'fast-deep-equal';
|
||||||
|
|
||||||
import { getBoundingBox, getNodesInside, getConnectedEdges } from './graph-utils';
|
import { getBoundingBox, getNodesInside, getConnectedEdges } from './utils/graph';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setOnConnect: action((state, onConnect) => {
|
setOnConnect: action((state, onConnect) => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useState, memo } from 'react';
|
|||||||
import ReactDraggable from 'react-draggable';
|
import ReactDraggable from 'react-draggable';
|
||||||
import { useStoreState, useStoreActions } from 'easy-peasy';
|
import { useStoreState, useStoreActions } from 'easy-peasy';
|
||||||
|
|
||||||
import { isNode } from '../../graph-utils';
|
import { isNode } from '../../utils/graph';
|
||||||
|
|
||||||
function getStartPositions(elements) {
|
function getStartPositions(elements) {
|
||||||
return elements
|
return elements
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { memo } from 'react';
|
|||||||
import { useStoreState } from 'easy-peasy';
|
import { useStoreState } from 'easy-peasy';
|
||||||
|
|
||||||
import ConnectionLine from '../../components/ConnectionLine';
|
import ConnectionLine from '../../components/ConnectionLine';
|
||||||
import { isEdge } from '../../graph-utils';
|
import { isEdge } from '../../utils/graph';
|
||||||
|
|
||||||
function getHandlePosition(position, node, handle = null) {
|
function getHandlePosition(position, node, handle = null) {
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import useD3Zoom from '../../hooks/useD3Zoom';
|
|||||||
import useGlobalKeyHandler from '../../hooks/useGlobalKeyHandler';
|
import useGlobalKeyHandler from '../../hooks/useGlobalKeyHandler';
|
||||||
import useElementUpdater from '../../hooks/useElementUpdater'
|
import useElementUpdater from '../../hooks/useElementUpdater'
|
||||||
import { getDimensions } from '../../utils';
|
import { getDimensions } from '../../utils';
|
||||||
import { fitView, zoomIn, zoomOut } from '../../graph-utils';
|
import { fitView, zoomIn, zoomOut } from '../../utils/graph';
|
||||||
|
|
||||||
const GraphView = memo(({
|
const GraphView = memo(({
|
||||||
nodeTypes, edgeTypes, onMove, onLoad,
|
nodeTypes, edgeTypes, onMove, onLoad,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { memo } from 'react';
|
import React, { memo } from 'react';
|
||||||
import { useStoreState } from 'easy-peasy';
|
import { useStoreState } from 'easy-peasy';
|
||||||
|
|
||||||
import { isNode } from '../../graph-utils';
|
import { isNode } from '../../utils/graph';
|
||||||
|
|
||||||
function renderNode(d, props, state) {
|
function renderNode(d, props, state) {
|
||||||
const nodeType = d.type || 'default';
|
const nodeType = d.type || 'default';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useEffect } from 'react';
|
|||||||
import { useStoreState, useStoreActions } from 'easy-peasy';
|
import { useStoreState, useStoreActions } from 'easy-peasy';
|
||||||
import isEqual from 'fast-deep-equal';
|
import isEqual from 'fast-deep-equal';
|
||||||
|
|
||||||
import { parseElement, isNode, isEdge } from '../graph-utils';
|
import { parseElement, isNode, isEdge } from '../utils/graph';
|
||||||
|
|
||||||
const useElementUpdater = ({ elements }) => {
|
const useElementUpdater = ({ elements }) => {
|
||||||
const state = useStoreState(s => ({
|
const state = useStoreState(s => ({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useEffect } from 'react';
|
|||||||
import { useStoreState, useStoreActions } from 'easy-peasy';
|
import { useStoreState, useStoreActions } from 'easy-peasy';
|
||||||
|
|
||||||
import useKeyPress from './useKeyPress';
|
import useKeyPress from './useKeyPress';
|
||||||
import { isEdge, getConnectedEdges } from '../graph-utils';
|
import { isEdge, getConnectedEdges } from '../utils/graph';
|
||||||
|
|
||||||
export default ({ deleteKeyCode, onElementsRemove }) => {
|
export default ({ deleteKeyCode, onElementsRemove }) => {
|
||||||
const state = useStoreState(s => ({ selectedElements: s.selectedElements, edges: s.edges }))
|
const state = useStoreState(s => ({ selectedElements: s.selectedElements, edges: s.edges }))
|
||||||
|
|||||||
+1
-1
@@ -10,4 +10,4 @@ export {
|
|||||||
isEdge,
|
isEdge,
|
||||||
removeElements,
|
removeElements,
|
||||||
getOutgoers
|
getOutgoers
|
||||||
} from './graph-utils';
|
} from './utils/graph';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { zoomIdentity } from 'd3-zoom';
|
import { zoomIdentity } from 'd3-zoom';
|
||||||
import store from './store';
|
import store from '../store';
|
||||||
|
|
||||||
export const isEdge = element => element.source && element.target;
|
export const isEdge = element => element.source && element.target;
|
||||||
|
|
||||||
Reference in New Issue
Block a user