@xyo-network/react-node-renderer 3.0.2 → 3.0.4

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.
Files changed (134) hide show
  1. package/dist/browser/Cytoscape/CytoscapeElements.d.ts +29 -0
  2. package/dist/browser/Cytoscape/CytoscapeElements.d.ts.map +1 -0
  3. package/dist/browser/Cytoscape/CytoscapeIcons.d.ts +5 -0
  4. package/dist/browser/Cytoscape/CytoscapeIcons.d.ts.map +1 -0
  5. package/dist/browser/Cytoscape/CytoscapeStyles.d.ts +22 -0
  6. package/dist/browser/Cytoscape/CytoscapeStyles.d.ts.map +1 -0
  7. package/dist/browser/Cytoscape/index.d.ts +5 -0
  8. package/dist/browser/Cytoscape/index.d.ts.map +1 -0
  9. package/dist/browser/Cytoscape/lib/CyNodeModuleTypes.d.ts +2 -0
  10. package/dist/browser/Cytoscape/lib/CyNodeModuleTypes.d.ts.map +1 -0
  11. package/dist/browser/Cytoscape/lib/encodeSvg.d.ts +3 -0
  12. package/dist/browser/Cytoscape/lib/encodeSvg.d.ts.map +1 -0
  13. package/dist/browser/Cytoscape/lib/iconMap.d.ts +3 -0
  14. package/dist/browser/Cytoscape/lib/iconMap.d.ts.map +1 -0
  15. package/dist/browser/Cytoscape/lib/index.d.ts +6 -0
  16. package/dist/browser/Cytoscape/lib/index.d.ts.map +1 -0
  17. package/dist/browser/Cytoscape/lib/layout/ColaLayout.d.ts +6 -0
  18. package/dist/browser/Cytoscape/lib/layout/ColaLayout.d.ts.map +1 -0
  19. package/dist/browser/Cytoscape/lib/layout/ConcentricLayout.d.ts +3 -0
  20. package/dist/browser/Cytoscape/lib/layout/ConcentricLayout.d.ts.map +1 -0
  21. package/dist/browser/Cytoscape/lib/layout/index.d.ts +3 -0
  22. package/dist/browser/Cytoscape/lib/layout/index.d.ts.map +1 -0
  23. package/dist/browser/Cytoscape/lib/parseModuleType.d.ts +4 -0
  24. package/dist/browser/Cytoscape/lib/parseModuleType.d.ts.map +1 -0
  25. package/dist/browser/components/cytoscape-extensions/WithExtensions.d.ts +4 -0
  26. package/dist/browser/components/cytoscape-extensions/WithExtensions.d.ts.map +1 -0
  27. package/dist/browser/components/cytoscape-extensions/index.d.ts +2 -0
  28. package/dist/browser/components/cytoscape-extensions/index.d.ts.map +1 -0
  29. package/dist/browser/components/index.d.ts +4 -0
  30. package/dist/browser/components/index.d.ts.map +1 -0
  31. package/dist/browser/components/lib/RelationalGraphProps.d.ts +16 -0
  32. package/dist/browser/components/lib/RelationalGraphProps.d.ts.map +1 -0
  33. package/dist/browser/components/lib/index.d.ts +2 -0
  34. package/dist/browser/components/lib/index.d.ts.map +1 -0
  35. package/dist/browser/components/module/CardParser.d.ts +7 -0
  36. package/dist/browser/components/module/CardParser.d.ts.map +1 -0
  37. package/dist/browser/components/module/graph/DetailsFlexbox.d.ts +7 -0
  38. package/dist/browser/components/module/graph/DetailsFlexbox.d.ts.map +1 -0
  39. package/dist/browser/components/module/graph/GraphFlexBox.d.ts +13 -0
  40. package/dist/browser/components/module/graph/GraphFlexBox.d.ts.map +1 -0
  41. package/dist/browser/components/module/graph/Popper.d.ts +13 -0
  42. package/dist/browser/components/module/graph/Popper.d.ts.map +1 -0
  43. package/dist/browser/components/module/graph/index.d.ts +2 -0
  44. package/dist/browser/components/module/graph/index.d.ts.map +1 -0
  45. package/dist/browser/components/module/graph/node/Hover.d.ts +10 -0
  46. package/dist/browser/components/module/graph/node/Hover.d.ts.map +1 -0
  47. package/dist/browser/components/module/graph/node/hooks/index.d.ts +2 -0
  48. package/dist/browser/components/module/graph/node/hooks/index.d.ts.map +1 -0
  49. package/dist/browser/components/module/graph/node/hooks/useNodeElement.d.ts +7 -0
  50. package/dist/browser/components/module/graph/node/hooks/useNodeElement.d.ts.map +1 -0
  51. package/dist/browser/components/module/graph/node/index.d.ts +2 -0
  52. package/dist/browser/components/module/graph/node/index.d.ts.map +1 -0
  53. package/dist/browser/components/module/index.d.ts +3 -0
  54. package/dist/browser/components/module/index.d.ts.map +1 -0
  55. package/dist/browser/components/relational/graph/Graph.d.ts +5 -0
  56. package/dist/browser/components/relational/graph/Graph.d.ts.map +1 -0
  57. package/dist/browser/components/relational/graph/ProvidedNodeRenderer.d.ts +12 -0
  58. package/dist/browser/components/relational/graph/ProvidedNodeRenderer.d.ts.map +1 -0
  59. package/dist/browser/components/relational/graph/index.d.ts +3 -0
  60. package/dist/browser/components/relational/graph/index.d.ts.map +1 -0
  61. package/dist/browser/components/relational/graph/story/TestData.d.ts +3 -0
  62. package/dist/browser/components/relational/graph/story/TestData.d.ts.map +1 -0
  63. package/dist/browser/components/relational/graph/story/index.d.ts +2 -0
  64. package/dist/browser/components/relational/graph/story/index.d.ts.map +1 -0
  65. package/dist/browser/components/relational/index.d.ts +2 -0
  66. package/dist/browser/components/relational/index.d.ts.map +1 -0
  67. package/dist/browser/contexts/CytoscapeInstance/Context.d.ts +3 -0
  68. package/dist/browser/contexts/CytoscapeInstance/Context.d.ts.map +1 -0
  69. package/dist/browser/contexts/CytoscapeInstance/Provider.d.ts +8 -0
  70. package/dist/browser/contexts/CytoscapeInstance/Provider.d.ts.map +1 -0
  71. package/dist/browser/contexts/CytoscapeInstance/State.d.ts +8 -0
  72. package/dist/browser/contexts/CytoscapeInstance/State.d.ts.map +1 -0
  73. package/dist/browser/contexts/CytoscapeInstance/index.d.ts +5 -0
  74. package/dist/browser/contexts/CytoscapeInstance/index.d.ts.map +1 -0
  75. package/dist/browser/contexts/CytoscapeInstance/use.d.ts +2 -0
  76. package/dist/browser/contexts/CytoscapeInstance/use.d.ts.map +1 -0
  77. package/dist/browser/contexts/index.d.ts +2 -0
  78. package/dist/browser/contexts/index.d.ts.map +1 -0
  79. package/dist/browser/hooks/cytoscape/elements/index.d.ts +3 -0
  80. package/dist/browser/hooks/cytoscape/elements/index.d.ts.map +1 -0
  81. package/dist/browser/hooks/cytoscape/elements/useCytoscapeElements.d.ts +4 -0
  82. package/dist/browser/hooks/cytoscape/elements/useCytoscapeElements.d.ts.map +1 -0
  83. package/dist/browser/hooks/cytoscape/elements/useElements.d.ts +6 -0
  84. package/dist/browser/hooks/cytoscape/elements/useElements.d.ts.map +1 -0
  85. package/dist/browser/hooks/cytoscape/elements/useHoveredNode.d.ts +4 -0
  86. package/dist/browser/hooks/cytoscape/elements/useHoveredNode.d.ts.map +1 -0
  87. package/dist/browser/hooks/cytoscape/elements/useNewElements.d.ts +3 -0
  88. package/dist/browser/hooks/cytoscape/elements/useNewElements.d.ts.map +1 -0
  89. package/dist/browser/hooks/cytoscape/elements/useRenderNewElements.d.ts +3 -0
  90. package/dist/browser/hooks/cytoscape/elements/useRenderNewElements.d.ts.map +1 -0
  91. package/dist/browser/hooks/cytoscape/elements/useSelectedElement.d.ts +6 -0
  92. package/dist/browser/hooks/cytoscape/elements/useSelectedElement.d.ts.map +1 -0
  93. package/dist/browser/hooks/cytoscape/index.d.ts +5 -0
  94. package/dist/browser/hooks/cytoscape/index.d.ts.map +1 -0
  95. package/dist/browser/hooks/cytoscape/useCytoscapeOptions.d.ts +3 -0
  96. package/dist/browser/hooks/cytoscape/useCytoscapeOptions.d.ts.map +1 -0
  97. package/dist/browser/hooks/cytoscape/useCytoscapeStyle.d.ts +2 -0
  98. package/dist/browser/hooks/cytoscape/useCytoscapeStyle.d.ts.map +1 -0
  99. package/dist/browser/hooks/cytoscape/useIcons.d.ts +3 -0
  100. package/dist/browser/hooks/cytoscape/useIcons.d.ts.map +1 -0
  101. package/dist/browser/hooks/cytoscape/useModuleDetails.d.ts +18 -0
  102. package/dist/browser/hooks/cytoscape/useModuleDetails.d.ts.map +1 -0
  103. package/dist/browser/hooks/cytoscape/useRelationalGraphOptions.d.ts +7 -0
  104. package/dist/browser/hooks/cytoscape/useRelationalGraphOptions.d.ts.map +1 -0
  105. package/dist/browser/hooks/index.d.ts +2 -0
  106. package/dist/browser/hooks/index.d.ts.map +1 -0
  107. package/dist/browser/index.d.ts +5 -168
  108. package/dist/browser/index.d.ts.map +1 -0
  109. package/dist/browser/index.mjs +38 -39
  110. package/dist/browser/index.mjs.map +1 -1
  111. package/package.json +76 -70
  112. package/src/Cytoscape/CytoscapeElements.ts +6 -2
  113. package/src/Cytoscape/CytoscapeStyles.ts +1 -3
  114. package/src/components/module/CardParser.stories.tsx +4 -4
  115. package/src/components/module/graph/GraphFlexBox.stories.tsx +12 -4
  116. package/src/components/module/graph/GraphFlexBox.tsx +12 -4
  117. package/src/components/module/graph/Popper.tsx +11 -6
  118. package/src/components/module/graph/node/Hover.tsx +3 -1
  119. package/src/components/module/graph/node/hooks/useNodeElement.tsx +6 -2
  120. package/src/components/relational/graph/Graph.stories.tsx +20 -6
  121. package/src/components/relational/graph/Graph.tsx +19 -6
  122. package/src/components/relational/graph/GraphCola.stories.tsx +20 -6
  123. package/src/components/relational/graph/GraphCoseBilkent.stories.tsx +20 -6
  124. package/src/components/relational/graph/GraphDagre.stories.tsx +20 -6
  125. package/src/components/relational/graph/GraphEuler.stories.tsx +20 -6
  126. package/src/components/relational/graph/GraphEvents.stories.tsx +3 -1
  127. package/src/components/relational/graph/story/TestData.tsx +7 -5
  128. package/src/contexts/CytoscapeInstance/Provider.tsx +11 -7
  129. package/src/hooks/cytoscape/elements/useElements.tsx +3 -1
  130. package/src/hooks/cytoscape/elements/useHoveredNode.tsx +3 -1
  131. package/src/hooks/cytoscape/useCytoscapeStyle.tsx +3 -1
  132. package/src/hooks/cytoscape/useIcons.tsx +3 -1
  133. package/src/hooks/cytoscape/useRelationalGraphOptions.tsx +3 -1
  134. package/xy.config.ts +1 -3
@@ -1,5 +1,7 @@
1
1
  import { Button, ButtonGroup } from '@mui/material'
2
- import type { Decorator, Meta, StoryFn } from '@storybook/react'
2
+ import type {
3
+ Decorator, Meta, StoryFn,
4
+ } from '@storybook/react'
3
5
  import { useAsyncEffect } from '@xylabs/react-async-effect'
4
6
  import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist'
5
7
  import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge-http'
@@ -25,7 +27,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
25
27
  const node = await MemoryNode.create({ config: { name: 'GlobalNode', schema: NodeConfigSchema } })
26
28
  const node1 = await MemoryNode.create({ config: { name: 'ChildNode', schema: NodeConfigSchema } })
27
29
  const bridge = await HttpBridge.create({
28
- config: { name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true } },
30
+ config: {
31
+ name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true },
32
+ },
29
33
  })
30
34
  await node.register(bridge)
31
35
  await node.attach(bridge.address, true)
@@ -35,7 +39,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
35
39
  await node.attach(archivist.address, true)
36
40
 
37
41
  const sentinel = await MemorySentinel.create({
38
- config: { name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [] },
42
+ config: {
43
+ name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [],
44
+ },
39
45
  })
40
46
  await node.register(sentinel)
41
47
  await node.attach(sentinel.address, true)
@@ -106,4 +112,6 @@ const WithDisabledDetails = TemplateWithProvidedModule.bind({})
106
112
  WithDisabledDetails.args = { ...defaultProps, disableModuleDetails: true }
107
113
  WithDisabledDetails.decorators = [MemoryNodeDecorator]
108
114
 
109
- export { Default, WithDisabledDetails, WithProvidedNode }
115
+ export {
116
+ Default, WithDisabledDetails, WithProvidedNode,
117
+ }
@@ -4,7 +4,9 @@ import type { ModuleInstance } from '@xyo-network/module-model'
4
4
  import React, { useRef } from 'react'
5
5
 
6
6
  import { CytoscapeInstanceProvider } from '../../../contexts/index.ts'
7
- import { useElements, useModuleDetails, useRelationalGraphOptions } from '../../../hooks/index.ts'
7
+ import {
8
+ useElements, useModuleDetails, useRelationalGraphOptions,
9
+ } from '../../../hooks/index.ts'
8
10
  import { WithExtensions } from '../../cytoscape-extensions/index.ts'
9
11
  import { NodeRelationalGraphFlexBox } from '../../relational/index.ts'
10
12
  import { DetailsFlexbox } from './DetailsFlexbox.tsx'
@@ -19,10 +21,16 @@ export interface ModuleGraphFlexBoxProps extends FlexBoxProps {
19
21
  rootModule?: WeakRef<ModuleInstance> | null
20
22
  }
21
23
 
22
- export const ModuleGraphFlexBox: React.FC<ModuleGraphFlexBoxProps> = ({ hideActions, rootModule, disableModuleDetails, ...props }) => {
24
+ export const ModuleGraphFlexBox: React.FC<ModuleGraphFlexBoxProps> = ({
25
+ hideActions, rootModule, disableModuleDetails, ...props
26
+ }) => {
23
27
  const cytoscapeRef = useRef<HTMLDivElement>(null)
24
- const { handleToggleLabels, hideLabels, options } = useRelationalGraphOptions(rootModule ?? undefined)
25
- const { hoveredNode, setHoveredNode, toggleSelectedElement } = useElements(hideLabels)
28
+ const {
29
+ handleToggleLabels, hideLabels, options,
30
+ } = useRelationalGraphOptions(rootModule ?? undefined)
31
+ const {
32
+ hoveredNode, setHoveredNode, toggleSelectedElement,
33
+ } = useElements(hideLabels)
26
34
 
27
35
  const { mod, onModuleDetails } = useModuleDetails(rootModule, () => setHoveredNode(undefined))
28
36
 
@@ -1,6 +1,8 @@
1
1
  import { CancelRounded } from '@mui/icons-material'
2
2
  import type { PopperProps } from '@mui/material'
3
- import { Button, Card, CardActions, CardHeader, IconButton, Paper, Popper, styled } from '@mui/material'
3
+ import {
4
+ Button, Card, CardActions, CardHeader, IconButton, Paper, Popper, styled,
5
+ } from '@mui/material'
4
6
  import { Identicon } from '@xylabs/react-identicon'
5
7
  import type { NodeSingular } from 'cytoscape'
6
8
  import React from 'react'
@@ -12,7 +14,9 @@ export interface ModuleHoverPopperProps extends PopperProps {
12
14
  onModuleExplore?: (address?: string) => void
13
15
  }
14
16
 
15
- export const ModuleHoverPopper: React.FC<ModuleHoverPopperProps> = ({ anchorEl, onClose, onModuleDetails, onModuleExplore, node, ...props }) => {
17
+ export const ModuleHoverPopper: React.FC<ModuleHoverPopperProps> = ({
18
+ anchorEl, onClose, onModuleDetails, onModuleExplore, node, ...props
19
+ }) => {
16
20
  const { address, name } = node?.data() ?? {}
17
21
  return (
18
22
  <>
@@ -31,7 +35,10 @@ export const ModuleHoverPopper: React.FC<ModuleHoverPopperProps> = ({ anchorEl,
31
35
  : null
32
36
  }
33
37
  avatar={(
34
- <Paper elevation={6} sx={{ bgcolor: '#fff', p: 1 }}>
38
+ <Paper
39
+ elevation={6}
40
+ sx={{ bgcolor: '#fff', p: 1 }}
41
+ >
35
42
  <Identicon value={address} size={24} />
36
43
  </Paper>
37
44
  )}
@@ -62,9 +69,7 @@ export const ModuleHoverPopper: React.FC<ModuleHoverPopperProps> = ({ anchorEl,
62
69
  )
63
70
  }
64
71
 
65
- export const StyledModuleHoverPopper = styled(ModuleHoverPopper, { name: 'StyledComponents' })(() => ({
66
- zIndex: 2,
67
- }))
72
+ export const StyledModuleHoverPopper = styled(ModuleHoverPopper, { name: 'StyledComponents' })(() => ({ zIndex: 2 }))
68
73
 
69
74
  export const StyledCardActions = styled(CardActions, { name: 'StyledCardActions' })(() => ({
70
75
  display: 'flex',
@@ -13,7 +13,9 @@ export interface ModuleHoverProps {
13
13
  }
14
14
 
15
15
  export const ModuleGraphNodeHover: React.FC<ModuleHoverProps> = ({ children, node }) => {
16
- const { boundingBox, ref, currentElement } = useNodeElement(node)
16
+ const {
17
+ boundingBox, ref, currentElement,
18
+ } = useNodeElement(node)
17
19
 
18
20
  return (
19
21
  <>
@@ -1,6 +1,8 @@
1
1
  import type { PopperProps } from '@mui/material'
2
2
  import type { NodeSingular } from 'cytoscape'
3
- import { useEffect, useRef, useState } from 'react'
3
+ import {
4
+ useEffect, useRef, useState,
5
+ } from 'react'
4
6
 
5
7
  export const useNodeElement = (node?: NodeSingular) => {
6
8
  const ref = useRef<HTMLDivElement>(null)
@@ -33,5 +35,7 @@ export const useNodeElement = (node?: NodeSingular) => {
33
35
  setCurrentElement(ref.current)
34
36
  }, [boundingBox])
35
37
 
36
- return { boundingBox, currentElement, ref }
38
+ return {
39
+ boundingBox, currentElement, ref,
40
+ }
37
41
  }
@@ -1,12 +1,16 @@
1
1
  import { Button, ButtonGroup } from '@mui/material'
2
- import type { Decorator, Meta, StoryFn } from '@storybook/react'
2
+ import type {
3
+ Decorator, Meta, StoryFn,
4
+ } from '@storybook/react'
3
5
  import { useAsyncEffect } from '@xylabs/react-async-effect'
4
6
  import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist'
5
7
  import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge-http'
6
8
  import { IdWitness, IdWitnessConfigSchema } from '@xyo-network/id-plugin'
7
9
  import { MemoryNode } from '@xyo-network/node-memory'
8
10
  import { NodeConfigSchema } from '@xyo-network/node-model'
9
- import { NodeProvider, useWeakNodeFromNode, useWeakProvidedNode } from '@xyo-network/react-node'
11
+ import {
12
+ NodeProvider, useWeakNodeFromNode, useWeakProvidedNode,
13
+ } from '@xyo-network/react-node'
10
14
  import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
11
15
  import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
12
16
  import { MemorySentinel, SentinelConfigSchema } from '@xyo-network/sentinel'
@@ -29,7 +33,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
29
33
  const node = await MemoryNode.create({ config: { name: 'GlobalNode', schema: NodeConfigSchema } })
30
34
  const node1 = await MemoryNode.create({ config: { name: 'ChildNode', schema: NodeConfigSchema } })
31
35
  const bridge = await HttpBridge.create({
32
- config: { name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true } },
36
+ config: {
37
+ name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true },
38
+ },
33
39
  })
34
40
  await node.register(bridge)
35
41
  await node.attach(bridge.address, true)
@@ -39,7 +45,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
39
45
  await node.attach(archivist.address, true)
40
46
 
41
47
  const sentinel = await MemorySentinel.create({
42
- config: { name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [] },
48
+ config: {
49
+ name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [],
50
+ },
43
51
  })
44
52
  await node.register(sentinel)
45
53
  await node.attach(sentinel.address, true)
@@ -118,7 +126,11 @@ const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props)
118
126
 
119
127
  useAsyncEffect(
120
128
  async () => {
121
- const witnessModule = await IdWitness.create({ config: { name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema } })
129
+ const witnessModule = await IdWitness.create({
130
+ config: {
131
+ name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema,
132
+ },
133
+ })
122
134
  setIdWitness(witnessModule)
123
135
  },
124
136
  [],
@@ -183,4 +195,6 @@ const WithProvidedNodeRenderer = TemplateProvidedNodeRenderer.bind({})
183
195
  WithProvidedNodeRenderer.args = { ...defaultProps }
184
196
  WithProvidedNodeRenderer.decorators = [MemoryNodeDecorator]
185
197
 
186
- export { Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer }
198
+ export {
199
+ Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer,
200
+ }
@@ -1,8 +1,12 @@
1
1
  import type { CardProps } from '@mui/material'
2
- import { Box, Button, ButtonGroup, Card, CardHeader, Paper, useTheme } from '@mui/material'
2
+ import {
3
+ Box, Button, ButtonGroup, Card, CardHeader, Paper, useTheme,
4
+ } from '@mui/material'
3
5
  import type { Address } from '@xylabs/hex'
4
6
  import { asAddress } from '@xylabs/hex'
5
- import { FlexCol, FlexGrowRow, FlexRow } from '@xylabs/react-flexbox'
7
+ import {
8
+ FlexCol, FlexGrowRow, FlexRow,
9
+ } from '@xylabs/react-flexbox'
6
10
  import { Identicon } from '@xylabs/react-identicon'
7
11
  import { useWeakModuleFromNode } from '@xyo-network/react-node'
8
12
  import type { Core, NodeSingular } from 'cytoscape'
@@ -11,7 +15,9 @@ import cola from 'cytoscape-cola'
11
15
  import coseBilkentLayout from 'cytoscape-cose-bilkent'
12
16
  import dagre from 'cytoscape-dagre'
13
17
  import eulerLayout from 'cytoscape-euler'
14
- import React, { forwardRef, useEffect, useRef, useState } from 'react'
18
+ import React, {
19
+ forwardRef, useEffect, useRef, useState,
20
+ } from 'react'
15
21
 
16
22
  import type { NodeRelationalGraphProps } from '../../lib/index.ts'
17
23
 
@@ -45,12 +51,17 @@ type ModuleHoverDetailsProps = CardProps & {
45
51
  name: string
46
52
  }
47
53
 
48
- const ModuleHoverDetails: React.FC<ModuleHoverDetailsProps> = ({ name, address, ...props }) => {
54
+ const ModuleHoverDetails: React.FC<ModuleHoverDetailsProps> = ({
55
+ name, address, ...props
56
+ }) => {
49
57
  return (
50
58
  <Card elevation={3} {...props}>
51
59
  <CardHeader
52
60
  avatar={(
53
- <Paper elevation={6} sx={{ bgcolor: '#fff', p: 1 }}>
61
+ <Paper
62
+ elevation={6}
63
+ sx={{ bgcolor: '#fff', p: 1 }}
64
+ >
54
65
  <Identicon value={address} size={24} />
55
66
  </Paper>
56
67
  )}
@@ -62,7 +73,9 @@ const ModuleHoverDetails: React.FC<ModuleHoverDetailsProps> = ({ name, address,
62
73
  }
63
74
 
64
75
  export const NodeRelationalGraphFlexBox = forwardRef<HTMLDivElement, NodeRelationalGraphProps>(
65
- ({ actions, children, node, layout, layoutOptions, showDetails, detail, options, onHover, ...props }, ref) => {
76
+ ({
77
+ actions, children, node, layout, layoutOptions, showDetails, detail, options, onHover, ...props
78
+ }, ref) => {
66
79
  const theme = useTheme()
67
80
  const [cy, setCy] = useState<Core>()
68
81
  const cytoscapeRef = useRef<HTMLDivElement>()
@@ -1,12 +1,16 @@
1
1
  import { Button, ButtonGroup } from '@mui/material'
2
- import type { Decorator, Meta, StoryFn } from '@storybook/react'
2
+ import type {
3
+ Decorator, Meta, StoryFn,
4
+ } from '@storybook/react'
3
5
  import { useAsyncEffect } from '@xylabs/react-async-effect'
4
6
  import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist'
5
7
  import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge-http'
6
8
  import { IdWitness, IdWitnessConfigSchema } from '@xyo-network/id-plugin'
7
9
  import { MemoryNode } from '@xyo-network/node-memory'
8
10
  import { NodeConfigSchema } from '@xyo-network/node-model'
9
- import { NodeProvider, useWeakNodeFromNode, useWeakProvidedNode } from '@xyo-network/react-node'
11
+ import {
12
+ NodeProvider, useWeakNodeFromNode, useWeakProvidedNode,
13
+ } from '@xyo-network/react-node'
10
14
  import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
11
15
  import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
12
16
  import { MemorySentinel, SentinelConfigSchema } from '@xyo-network/sentinel'
@@ -30,7 +34,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
30
34
  const node = await MemoryNode.create({ config: { name: 'GlobalNode', schema: NodeConfigSchema } })
31
35
  const node1 = await MemoryNode.create({ config: { name: 'ChildNode', schema: NodeConfigSchema } })
32
36
  const bridge = await HttpBridge.create({
33
- config: { name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true } },
37
+ config: {
38
+ name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true },
39
+ },
34
40
  })
35
41
  await node.register(bridge)
36
42
  await node.attach(bridge.address, true)
@@ -40,7 +46,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
40
46
  await node.attach(archivist.address, true)
41
47
 
42
48
  const sentinel = await MemorySentinel.create({
43
- config: { name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [] },
49
+ config: {
50
+ name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [],
51
+ },
44
52
  })
45
53
  await node.register(sentinel)
46
54
  await node.attach(sentinel.address, true)
@@ -105,7 +113,11 @@ const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props)
105
113
  useAsyncEffect(
106
114
 
107
115
  async () => {
108
- const witnessModule = await IdWitness.create({ config: { name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema } })
116
+ const witnessModule = await IdWitness.create({
117
+ config: {
118
+ name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema,
119
+ },
120
+ })
109
121
  setIdWitness(witnessModule)
110
122
  },
111
123
  [],
@@ -168,4 +180,6 @@ const WithProvidedNodeRenderer = TemplateProvidedNodeRenderer.bind({})
168
180
  WithProvidedNodeRenderer.args = { ...defaultProps }
169
181
  WithProvidedNodeRenderer.decorators = [MemoryNodeDecorator]
170
182
 
171
- export { Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer }
183
+ export {
184
+ Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer,
185
+ }
@@ -1,12 +1,16 @@
1
1
  import { Button, ButtonGroup } from '@mui/material'
2
- import type { Decorator, Meta, StoryFn } from '@storybook/react'
2
+ import type {
3
+ Decorator, Meta, StoryFn,
4
+ } from '@storybook/react'
3
5
  import { useAsyncEffect } from '@xylabs/react-async-effect'
4
6
  import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist'
5
7
  import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge-http'
6
8
  import { IdWitness, IdWitnessConfigSchema } from '@xyo-network/id-plugin'
7
9
  import { MemoryNode } from '@xyo-network/node-memory'
8
10
  import { NodeConfigSchema } from '@xyo-network/node-model'
9
- import { NodeProvider, useWeakNodeFromNode, useWeakProvidedNode } from '@xyo-network/react-node'
11
+ import {
12
+ NodeProvider, useWeakNodeFromNode, useWeakProvidedNode,
13
+ } from '@xyo-network/react-node'
10
14
  import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
11
15
  import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
12
16
  import { MemorySentinel, SentinelConfigSchema } from '@xyo-network/sentinel'
@@ -30,7 +34,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
30
34
  const node = await MemoryNode.create({ config: { name: 'GlobalNode', schema: NodeConfigSchema } })
31
35
  const node1 = await MemoryNode.create({ config: { name: 'ChildNode', schema: NodeConfigSchema } })
32
36
  const bridge = await HttpBridge.create({
33
- config: { name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true } },
37
+ config: {
38
+ name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true },
39
+ },
34
40
  })
35
41
  await node.register(bridge)
36
42
  await node.attach(bridge.address, true)
@@ -40,7 +46,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
40
46
  await node.attach(archivist.address, true)
41
47
 
42
48
  const sentinel = await MemorySentinel.create({
43
- config: { name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [] },
49
+ config: {
50
+ name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [],
51
+ },
44
52
  })
45
53
  await node.register(sentinel)
46
54
  await node.attach(sentinel.address, true)
@@ -104,7 +112,11 @@ const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props)
104
112
 
105
113
  useAsyncEffect(
106
114
  async () => {
107
- const witnessModule = await IdWitness.create({ config: { name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema } })
115
+ const witnessModule = await IdWitness.create({
116
+ config: {
117
+ name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema,
118
+ },
119
+ })
108
120
  setIdWitness(witnessModule)
109
121
  },
110
122
  [],
@@ -167,4 +179,6 @@ const WithProvidedNodeRenderer = TemplateProvidedNodeRenderer.bind({})
167
179
  WithProvidedNodeRenderer.args = { ...defaultProps }
168
180
  WithProvidedNodeRenderer.decorators = [MemoryNodeDecorator]
169
181
 
170
- export { Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer }
182
+ export {
183
+ Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer,
184
+ }
@@ -1,12 +1,16 @@
1
1
  import { Button, ButtonGroup } from '@mui/material'
2
- import type { Decorator, Meta, StoryFn } from '@storybook/react'
2
+ import type {
3
+ Decorator, Meta, StoryFn,
4
+ } from '@storybook/react'
3
5
  import { useAsyncEffect } from '@xylabs/react-async-effect'
4
6
  import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist'
5
7
  import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge-http'
6
8
  import { IdWitness, IdWitnessConfigSchema } from '@xyo-network/id-plugin'
7
9
  import { MemoryNode } from '@xyo-network/node-memory'
8
10
  import { NodeConfigSchema } from '@xyo-network/node-model'
9
- import { NodeProvider, useWeakNodeFromNode, useWeakProvidedNode } from '@xyo-network/react-node'
11
+ import {
12
+ NodeProvider, useWeakNodeFromNode, useWeakProvidedNode,
13
+ } from '@xyo-network/react-node'
10
14
  import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
11
15
  import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
12
16
  import { MemorySentinel, SentinelConfigSchema } from '@xyo-network/sentinel'
@@ -30,7 +34,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
30
34
  const node = await MemoryNode.create({ config: { name: 'GlobalNode', schema: NodeConfigSchema } })
31
35
  const node1 = await MemoryNode.create({ config: { name: 'ChildNode', schema: NodeConfigSchema } })
32
36
  const bridge = await HttpBridge.create({
33
- config: { name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true } },
37
+ config: {
38
+ name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true },
39
+ },
34
40
  })
35
41
  await node.register(bridge)
36
42
  await node.attach(bridge.address, true)
@@ -40,7 +46,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
40
46
  await node.attach(archivist.address, true)
41
47
 
42
48
  const sentinel = await MemorySentinel.create({
43
- config: { name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [] },
49
+ config: {
50
+ name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [],
51
+ },
44
52
  })
45
53
  await node.register(sentinel)
46
54
  await node.attach(sentinel.address, true)
@@ -105,7 +113,11 @@ const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props)
105
113
  useAsyncEffect(
106
114
 
107
115
  async () => {
108
- const witnessModule = await IdWitness.create({ config: { name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema } })
116
+ const witnessModule = await IdWitness.create({
117
+ config: {
118
+ name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema,
119
+ },
120
+ })
109
121
  setIdWitness(witnessModule)
110
122
  },
111
123
  [],
@@ -168,4 +180,6 @@ const WithProvidedNodeRenderer = TemplateProvidedNodeRenderer.bind({})
168
180
  WithProvidedNodeRenderer.args = { ...defaultProps }
169
181
  WithProvidedNodeRenderer.decorators = [MemoryNodeDecorator]
170
182
 
171
- export { Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer }
183
+ export {
184
+ Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer,
185
+ }
@@ -1,12 +1,16 @@
1
1
  import { Button, ButtonGroup } from '@mui/material'
2
- import type { Decorator, Meta, StoryFn } from '@storybook/react'
2
+ import type {
3
+ Decorator, Meta, StoryFn,
4
+ } from '@storybook/react'
3
5
  import { useAsyncEffect } from '@xylabs/react-async-effect'
4
6
  import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist'
5
7
  import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge-http'
6
8
  import { IdWitness, IdWitnessConfigSchema } from '@xyo-network/id-plugin'
7
9
  import { MemoryNode } from '@xyo-network/node-memory'
8
10
  import { NodeConfigSchema } from '@xyo-network/node-model'
9
- import { NodeProvider, useWeakNodeFromNode, useWeakProvidedNode } from '@xyo-network/react-node'
11
+ import {
12
+ NodeProvider, useWeakNodeFromNode, useWeakProvidedNode,
13
+ } from '@xyo-network/react-node'
10
14
  import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
11
15
  import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
12
16
  import { MemorySentinel, SentinelConfigSchema } from '@xyo-network/sentinel'
@@ -31,7 +35,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
31
35
  const node = await MemoryNode.create({ config: { name: 'GlobalNode', schema: NodeConfigSchema } })
32
36
  const node1 = await MemoryNode.create({ config: { name: 'ChildNode', schema: NodeConfigSchema } })
33
37
  const bridge = await HttpBridge.create({
34
- config: { name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true } },
38
+ config: {
39
+ name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true },
40
+ },
35
41
  })
36
42
  await node.register(bridge)
37
43
  await node.attach(bridge.address, true)
@@ -41,7 +47,9 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
41
47
  await node.attach(archivist.address, true)
42
48
 
43
49
  const sentinel = await MemorySentinel.create({
44
- config: { name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [] },
50
+ config: {
51
+ name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [],
52
+ },
45
53
  })
46
54
  await node.register(sentinel)
47
55
  await node.attach(sentinel.address, true)
@@ -105,7 +113,11 @@ const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props)
105
113
 
106
114
  useAsyncEffect(
107
115
  async () => {
108
- const witnessModule = await IdWitness.create({ config: { name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema } })
116
+ const witnessModule = await IdWitness.create({
117
+ config: {
118
+ name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema,
119
+ },
120
+ })
109
121
  setIdWitness(witnessModule)
110
122
  },
111
123
  [],
@@ -168,4 +180,6 @@ const WithProvidedNodeRenderer = TemplateProvidedNodeRenderer.bind({})
168
180
  WithProvidedNodeRenderer.args = { ...defaultProps }
169
181
  WithProvidedNodeRenderer.decorators = [MemoryNodeDecorator]
170
182
 
171
- export { Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer }
183
+ export {
184
+ Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer,
185
+ }
@@ -1,4 +1,6 @@
1
- import type { Decorator, Meta, StoryFn } from '@storybook/react'
1
+ import type {
2
+ Decorator, Meta, StoryFn,
3
+ } from '@storybook/react'
2
4
  import { useAsyncEffect } from '@xylabs/react-async-effect'
3
5
  import { ArchivistConfigSchema, MemoryArchivist } from '@xyo-network/archivist'
4
6
  import { MemoryNode } from '@xyo-network/node-memory'
@@ -15,20 +15,22 @@ const elements: CytoscapeOptions['elements'] = [
15
15
  },
16
16
  {
17
17
  // edge ab
18
- data: { id: 'ab', source: 'a', target: 'b' },
18
+ data: {
19
+ id: 'ab', source: 'a', target: 'b',
20
+ },
19
21
  },
20
22
  {
21
23
  // edge ac
22
- data: { id: 'ac', source: 'a', target: 'c' },
24
+ data: {
25
+ id: 'ac', source: 'a', target: 'c',
26
+ },
23
27
  },
24
28
  ]
25
29
 
26
30
  const style: CytoscapeOptions['style'] = [
27
31
  {
28
32
  selector: 'node',
29
- style: {
30
- label: 'data(id)',
31
- },
33
+ style: { label: 'data(id)' },
32
34
  },
33
35
 
34
36
  {
@@ -1,6 +1,6 @@
1
1
  import type { WithChildren } from '@xylabs/react-shared'
2
2
  import type { Core } from 'cytoscape'
3
- import React, { useEffect, useState } from 'react'
3
+ import React, { useMemo, useState } from 'react'
4
4
 
5
5
  import { CytoscapeInstanceContext } from './Context.ts'
6
6
 
@@ -9,11 +9,15 @@ export interface CytoscapeInstanceProviderProps extends WithChildren {
9
9
  }
10
10
 
11
11
  export const CytoscapeInstanceProvider: React.FC<CytoscapeInstanceProviderProps> = ({ children, defaultInstance }) => {
12
- const [cy, setCy] = useState<WeakRef<Core> | undefined>(defaultInstance)
13
- useEffect(() => {
14
- setCy(defaultInstance)
15
- }, [defaultInstance])
12
+ const [cy, setCy] = useState<WeakRef<Core> | undefined>(() => defaultInstance)
16
13
 
17
- // eslint-disable-next-line @eslint-react/no-unstable-context-value
18
- return <CytoscapeInstanceContext.Provider value={{ cy, provided: true, setCy }}>{children}</CytoscapeInstanceContext.Provider>
14
+ const value = useMemo(() => ({
15
+ cy, provided: true, setCy,
16
+ }), [cy, setCy])
17
+
18
+ return (
19
+ <CytoscapeInstanceContext.Provider value={value}>
20
+ {children}
21
+ </CytoscapeInstanceContext.Provider>
22
+ )
19
23
  }
@@ -9,5 +9,7 @@ export const useElements = (hideLabels: boolean) => {
9
9
  const renderedElements = useRenderNewElements(newElements, hideLabels)
10
10
  const [hoveredNode, setHoveredNode] = useHoveredNode(renderedElements)
11
11
 
12
- return { hoveredNode, setHoveredNode, toggleSelectedElement }
12
+ return {
13
+ hoveredNode, setHoveredNode, toggleSelectedElement,
14
+ }
13
15
  }
@@ -1,6 +1,8 @@
1
1
  import type { NodeCollection, NodeSingular } from 'cytoscape'
2
2
  import type { Dispatch, SetStateAction } from 'react'
3
- import { useCallback, useEffect, useState } from 'react'
3
+ import {
4
+ useCallback, useEffect, useState,
5
+ } from 'react'
4
6
 
5
7
  import { useCytoscapeInstance } from '../../../contexts/index.ts'
6
8
 
@@ -2,7 +2,9 @@ import { useTheme } from '@mui/material'
2
2
  import type { CytoscapeOptions } from 'cytoscape'
3
3
  import { useMemo } from 'react'
4
4
 
5
- import { EdgeStyled, Node, NodeAsRoot, NodeWithName } from '../../Cytoscape/index.ts'
5
+ import {
6
+ EdgeStyled, Node, NodeAsRoot, NodeWithName,
7
+ } from '../../Cytoscape/index.ts'
6
8
  import { useIcons } from './useIcons.tsx'
7
9
 
8
10
  export const useCytoscapeStyle = (hideLabels = false) => {
@@ -2,7 +2,9 @@ import { useTheme } from '@mui/material'
2
2
  import React, { useMemo } from 'react'
3
3
 
4
4
  import type { CyNodeModuleTypes } from '../../Cytoscape/index.ts'
5
- import { CyIconSet, encodeSvg, generateIconMap } from '../../Cytoscape/index.ts'
5
+ import {
6
+ CyIconSet, encodeSvg, generateIconMap,
7
+ } from '../../Cytoscape/index.ts'
6
8
 
7
9
  export const useIcons = () => {
8
10
  const theme = useTheme()
@@ -17,5 +17,7 @@ export const useRelationalGraphOptions = (mod?: WeakRef<ModuleInstance>) => {
17
17
  const style = useCytoscapeStyle(hideLabels)
18
18
  const options = useCytoscapeOptions(elements, style, ConcentricLayout)
19
19
 
20
- return { handleToggleLabels, hideLabels, options }
20
+ return {
21
+ handleToggleLabels, hideLabels, options,
22
+ }
21
23
  }
package/xy.config.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
2
2
  const config: XyTsupConfig = {
3
3
  compile: {
4
- browser: {
5
- src: true,
6
- },
4
+ browser: { src: true },
7
5
  node: {},
8
6
  neutral: {},
9
7
  },