@xyo-network/react-node-renderer 7.5.8 → 7.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/Cytoscape/CytoscapeElements.d.ts +2 -6
- package/dist/browser/Cytoscape/CytoscapeElements.d.ts.map +1 -1
- package/dist/browser/components/module/graph/Popper.d.ts +3 -2
- package/dist/browser/components/module/graph/Popper.d.ts.map +1 -1
- package/dist/browser/components/module/graph/node/hooks/useNodeElement.d.ts +8 -5
- package/dist/browser/components/module/graph/node/hooks/useNodeElement.d.ts.map +1 -1
- package/dist/browser/components/relational/graph/Graph.d.ts.map +1 -1
- package/dist/browser/hooks/cytoscape/elements/useRenderNewElements.d.ts +1 -1
- package/dist/browser/hooks/cytoscape/elements/useRenderNewElements.d.ts.map +1 -1
- package/dist/browser/index.mjs +362 -423
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +188 -59
- package/src/Cytoscape/CytoscapeElements.ts +0 -96
- package/src/Cytoscape/CytoscapeIcons.tsx +0 -23
- package/src/Cytoscape/CytoscapeStyles.ts +0 -46
- package/src/Cytoscape/index.ts +0 -4
- package/src/Cytoscape/lib/CyNodeModuleTypes.ts +0 -1
- package/src/Cytoscape/lib/encodeSvg.ts +0 -19
- package/src/Cytoscape/lib/iconMap.ts +0 -12
- package/src/Cytoscape/lib/index.ts +0 -5
- package/src/Cytoscape/lib/layout/ColaLayout.ts +0 -5
- package/src/Cytoscape/lib/layout/ConcentricLayout.ts +0 -12
- package/src/Cytoscape/lib/layout/index.ts +0 -2
- package/src/Cytoscape/lib/parseModuleType.ts +0 -29
- package/src/components/cytoscape-extensions/WithExtensions.tsx +0 -16
- package/src/components/cytoscape-extensions/index.ts +0 -1
- package/src/components/index.ts +0 -3
- package/src/components/lib/RelationalGraphProps.ts +0 -16
- package/src/components/lib/index.ts +0 -1
- package/src/components/module/CardParser.stories.tsx +0 -36
- package/src/components/module/CardParser.tsx +0 -24
- package/src/components/module/graph/DetailsFlexbox.tsx +0 -22
- package/src/components/module/graph/GraphFlexBox.stories.tsx +0 -118
- package/src/components/module/graph/GraphFlexBox.tsx +0 -84
- package/src/components/module/graph/Popper.tsx +0 -77
- package/src/components/module/graph/index.ts +0 -1
- package/src/components/module/graph/node/Hover.tsx +0 -38
- package/src/components/module/graph/node/hooks/index.ts +0 -1
- package/src/components/module/graph/node/hooks/useNodeElement.tsx +0 -41
- package/src/components/module/graph/node/index.ts +0 -1
- package/src/components/module/index.ts +0 -2
- package/src/components/relational/graph/Graph.stories.tsx +0 -201
- package/src/components/relational/graph/Graph.tsx +0 -200
- package/src/components/relational/graph/GraphCola.stories.tsx +0 -187
- package/src/components/relational/graph/GraphCoseBilkent.stories.tsx +0 -186
- package/src/components/relational/graph/GraphDagre.stories.tsx +0 -186
- package/src/components/relational/graph/GraphEuler.stories.tsx +0 -187
- package/src/components/relational/graph/GraphEvents.stories.tsx +0 -82
- package/src/components/relational/graph/ProvidedNodeRenderer.tsx +0 -23
- package/src/components/relational/graph/index.ts +0 -2
- package/src/components/relational/graph/story/TestData.tsx +0 -51
- package/src/components/relational/graph/story/index.ts +0 -1
- package/src/components/relational/index.ts +0 -1
- package/src/contexts/CytoscapeInstance/Context.ts +0 -5
- package/src/contexts/CytoscapeInstance/Provider.tsx +0 -24
- package/src/contexts/CytoscapeInstance/State.ts +0 -8
- package/src/contexts/CytoscapeInstance/index.ts +0 -4
- package/src/contexts/CytoscapeInstance/use.ts +0 -5
- package/src/contexts/index.ts +0 -1
- package/src/hooks/cytoscape/elements/index.ts +0 -2
- package/src/hooks/cytoscape/elements/useCytoscapeElements.ts +0 -47
- package/src/hooks/cytoscape/elements/useElements.tsx +0 -15
- package/src/hooks/cytoscape/elements/useHoveredNode.tsx +0 -34
- package/src/hooks/cytoscape/elements/useNewElements.tsx +0 -17
- package/src/hooks/cytoscape/elements/useRenderNewElements.tsx +0 -17
- package/src/hooks/cytoscape/elements/useSelectedElement.tsx +0 -25
- package/src/hooks/cytoscape/index.ts +0 -4
- package/src/hooks/cytoscape/useCytoscapeOptions.ts +0 -29
- package/src/hooks/cytoscape/useCytoscapeStyle.tsx +0 -34
- package/src/hooks/cytoscape/useIcons.tsx +0 -22
- package/src/hooks/cytoscape/useModuleDetails.tsx +0 -83
- package/src/hooks/cytoscape/useRelationalGraphOptions.tsx +0 -23
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +0 -4
- package/src/types/global.d.ts +0 -19
- package/src/types/images.d.ts +0 -5
- package/src/types/theme.d.ts +0 -1
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { usePromise } from '@xylabs/react-promise'
|
|
2
|
-
import {
|
|
3
|
-
isDefined, isDefinedNotNull, isTruthy,
|
|
4
|
-
} from '@xylabs/sdk-js'
|
|
5
|
-
import type { ModuleInstance } from '@xyo-network/module-model'
|
|
6
|
-
import {
|
|
7
|
-
useCallback, useEffect, useState,
|
|
8
|
-
} from 'react'
|
|
9
|
-
|
|
10
|
-
import { useCytoscapeInstance } from '../../contexts/index.ts'
|
|
11
|
-
|
|
12
|
-
export const useModuleDetails = (rootModule?: WeakRef<ModuleInstance> | null, onFoundModule?: () => void) => {
|
|
13
|
-
const { cy } = useCytoscapeInstance()
|
|
14
|
-
const [moduleAddress, setModuleAddress] = useState<string | null>()
|
|
15
|
-
|
|
16
|
-
const [foundModule] = usePromise(async () => {
|
|
17
|
-
if (moduleAddress === null) return null
|
|
18
|
-
const rootModuleInstance = rootModule?.deref()
|
|
19
|
-
if (isDefined(moduleAddress) && isDefined(rootModuleInstance)) {
|
|
20
|
-
const foundModule = await rootModuleInstance.resolve(moduleAddress)
|
|
21
|
-
return foundModule ?? null
|
|
22
|
-
}
|
|
23
|
-
}, [moduleAddress, rootModule])
|
|
24
|
-
|
|
25
|
-
const createObserver = useCallback(() => {
|
|
26
|
-
return new ResizeObserver(() => {
|
|
27
|
-
if (moduleAddress === null) {
|
|
28
|
-
// cytoscape tries to center prematurely without it :(
|
|
29
|
-
setTimeout(() => {
|
|
30
|
-
cy?.deref()?.center()
|
|
31
|
-
}, 100)
|
|
32
|
-
} else if (foundModule && cy) {
|
|
33
|
-
const node = cy?.deref()?.nodes(`[id="${moduleAddress}"]`)?.[0]
|
|
34
|
-
// cy.pan(newPan)
|
|
35
|
-
// cytoscape tries to center prematurely without it :(
|
|
36
|
-
setTimeout(() => {
|
|
37
|
-
cy?.deref()?.center(node)
|
|
38
|
-
}, 100)
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
}, [cy, moduleAddress, foundModule])
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
const resizeObserver = createObserver()
|
|
45
|
-
|
|
46
|
-
const container = cy?.deref()?.container()
|
|
47
|
-
if (container) {
|
|
48
|
-
resizeObserver.observe(container)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return () => {
|
|
52
|
-
if (container) resizeObserver.unobserve(container)
|
|
53
|
-
}
|
|
54
|
-
}, [cy, moduleAddress, foundModule, rootModule])
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
if (foundModule) {
|
|
58
|
-
onFoundModule?.()
|
|
59
|
-
}
|
|
60
|
-
}, [cy, moduleAddress, foundModule, onFoundModule, createObserver])
|
|
61
|
-
|
|
62
|
-
// eslint-disable-next-line complexity
|
|
63
|
-
const onModuleDetails = (address?: string | null) => {
|
|
64
|
-
const moduleNode = cy?.deref()?.nodes(`[id="${address}"]`)
|
|
65
|
-
const rootModuleNode = cy?.deref()?.nodes(`[id="${rootModule?.deref()?.address}"]`)
|
|
66
|
-
const foundModuleNode = cy?.deref()?.nodes(`[id="${foundModule?.address}"]`)
|
|
67
|
-
const notModuleNode = cy?.deref()?.nodes(`[id != "${address}"]`)
|
|
68
|
-
|
|
69
|
-
if (isTruthy(address)) {
|
|
70
|
-
// address was passed so we set the node to active styles
|
|
71
|
-
moduleNode?.toggleClass('activeNode', true)
|
|
72
|
-
notModuleNode?.toggleClass('activeNode', false)
|
|
73
|
-
} else {
|
|
74
|
-
// no address was passes so we reset the state
|
|
75
|
-
notModuleNode?.toggleClass('activeNode', false)
|
|
76
|
-
const activeNode = isDefinedNotNull(foundModuleNode) && foundModuleNode.length > 0 ? foundModuleNode : rootModuleNode
|
|
77
|
-
activeNode?.toggleClass('activeNode', true)
|
|
78
|
-
}
|
|
79
|
-
setModuleAddress(address)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return { mod: foundModule, onModuleDetails }
|
|
83
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ModuleInstance } from '@xyo-network/module-model'
|
|
2
|
-
import { useState } from 'react'
|
|
3
|
-
|
|
4
|
-
import { ConcentricLayout } from '../../Cytoscape/index.ts'
|
|
5
|
-
import { useCytoscapeElements } from './elements/index.ts'
|
|
6
|
-
import { useCytoscapeOptions } from './useCytoscapeOptions.ts'
|
|
7
|
-
import { useCytoscapeStyle } from './useCytoscapeStyle.tsx'
|
|
8
|
-
|
|
9
|
-
export const useRelationalGraphOptions = (mod?: WeakRef<ModuleInstance>) => {
|
|
10
|
-
const [hideLabels, setHideLabels] = useState(true)
|
|
11
|
-
|
|
12
|
-
const handleToggleLabels = () => {
|
|
13
|
-
setHideLabels(oldValue => !oldValue)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const elements = useCytoscapeElements(mod)
|
|
17
|
-
const style = useCytoscapeStyle(hideLabels)
|
|
18
|
-
const options = useCytoscapeOptions(elements, style, ConcentricLayout)
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
handleToggleLabels, hideLabels, options,
|
|
22
|
-
}
|
|
23
|
-
}
|
package/src/hooks/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './cytoscape/index.ts'
|
package/src/index.ts
DELETED
package/src/types/global.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare module 'cytoscape-cola' {
|
|
2
|
-
const ext: cytoscape.Ext
|
|
3
|
-
export = ext
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
declare module 'cytoscape-cose-bilkent' {
|
|
7
|
-
const ext: cytoscape.Ext
|
|
8
|
-
export = ext
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare module 'cytoscape-euler' {
|
|
12
|
-
const ext: cytoscape.Ext
|
|
13
|
-
export = ext
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare module 'cytoscape-dagre' {
|
|
17
|
-
const ext: cytoscape.Ext
|
|
18
|
-
export = ext
|
|
19
|
-
}
|
package/src/types/images.d.ts
DELETED
package/src/types/theme.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@mui/material/themeCssVarsAugmentation'
|