@xyo-network/react-node-renderer 2.71.11 → 2.72.0

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 (68) hide show
  1. package/dist/browser/components/cytoscape-extensions/WithExtensions.d.cts.map +1 -1
  2. package/dist/browser/components/cytoscape-extensions/WithExtensions.d.mts.map +1 -1
  3. package/dist/browser/components/cytoscape-extensions/WithExtensions.d.ts.map +1 -1
  4. package/dist/browser/components/lib/RelationalGraphProps.d.cts +2 -2
  5. package/dist/browser/components/lib/RelationalGraphProps.d.cts.map +1 -1
  6. package/dist/browser/components/lib/RelationalGraphProps.d.mts +2 -2
  7. package/dist/browser/components/lib/RelationalGraphProps.d.mts.map +1 -1
  8. package/dist/browser/components/lib/RelationalGraphProps.d.ts +2 -2
  9. package/dist/browser/components/lib/RelationalGraphProps.d.ts.map +1 -1
  10. package/dist/browser/components/module/graph/GraphFlexBox.d.cts +2 -2
  11. package/dist/browser/components/module/graph/GraphFlexBox.d.cts.map +1 -1
  12. package/dist/browser/components/module/graph/GraphFlexBox.d.mts +2 -2
  13. package/dist/browser/components/module/graph/GraphFlexBox.d.mts.map +1 -1
  14. package/dist/browser/components/module/graph/GraphFlexBox.d.ts +2 -2
  15. package/dist/browser/components/module/graph/GraphFlexBox.d.ts.map +1 -1
  16. package/dist/browser/components/relational/graph/Graph.d.cts.map +1 -1
  17. package/dist/browser/components/relational/graph/Graph.d.mts.map +1 -1
  18. package/dist/browser/components/relational/graph/Graph.d.ts.map +1 -1
  19. package/dist/browser/components/relational/graph/ProvidedNodeRenderer.d.cts +2 -2
  20. package/dist/browser/components/relational/graph/ProvidedNodeRenderer.d.cts.map +1 -1
  21. package/dist/browser/components/relational/graph/ProvidedNodeRenderer.d.mts +2 -2
  22. package/dist/browser/components/relational/graph/ProvidedNodeRenderer.d.mts.map +1 -1
  23. package/dist/browser/components/relational/graph/ProvidedNodeRenderer.d.ts +2 -2
  24. package/dist/browser/components/relational/graph/ProvidedNodeRenderer.d.ts.map +1 -1
  25. package/dist/browser/index.cjs +42 -21
  26. package/dist/browser/index.cjs.map +1 -1
  27. package/dist/browser/index.js +42 -21
  28. package/dist/browser/index.js.map +1 -1
  29. package/dist/node/components/cytoscape-extensions/WithExtensions.d.cts.map +1 -1
  30. package/dist/node/components/cytoscape-extensions/WithExtensions.d.mts.map +1 -1
  31. package/dist/node/components/cytoscape-extensions/WithExtensions.d.ts.map +1 -1
  32. package/dist/node/components/lib/RelationalGraphProps.d.cts +2 -2
  33. package/dist/node/components/lib/RelationalGraphProps.d.cts.map +1 -1
  34. package/dist/node/components/lib/RelationalGraphProps.d.mts +2 -2
  35. package/dist/node/components/lib/RelationalGraphProps.d.mts.map +1 -1
  36. package/dist/node/components/lib/RelationalGraphProps.d.ts +2 -2
  37. package/dist/node/components/lib/RelationalGraphProps.d.ts.map +1 -1
  38. package/dist/node/components/module/graph/GraphFlexBox.d.cts +2 -2
  39. package/dist/node/components/module/graph/GraphFlexBox.d.cts.map +1 -1
  40. package/dist/node/components/module/graph/GraphFlexBox.d.mts +2 -2
  41. package/dist/node/components/module/graph/GraphFlexBox.d.mts.map +1 -1
  42. package/dist/node/components/module/graph/GraphFlexBox.d.ts +2 -2
  43. package/dist/node/components/module/graph/GraphFlexBox.d.ts.map +1 -1
  44. package/dist/node/components/relational/graph/Graph.d.cts.map +1 -1
  45. package/dist/node/components/relational/graph/Graph.d.mts.map +1 -1
  46. package/dist/node/components/relational/graph/Graph.d.ts.map +1 -1
  47. package/dist/node/components/relational/graph/ProvidedNodeRenderer.d.cts +2 -2
  48. package/dist/node/components/relational/graph/ProvidedNodeRenderer.d.cts.map +1 -1
  49. package/dist/node/components/relational/graph/ProvidedNodeRenderer.d.mts +2 -2
  50. package/dist/node/components/relational/graph/ProvidedNodeRenderer.d.mts.map +1 -1
  51. package/dist/node/components/relational/graph/ProvidedNodeRenderer.d.ts +2 -2
  52. package/dist/node/components/relational/graph/ProvidedNodeRenderer.d.ts.map +1 -1
  53. package/dist/node/index.cjs +42 -21
  54. package/dist/node/index.cjs.map +1 -1
  55. package/dist/node/index.js +42 -21
  56. package/dist/node/index.js.map +1 -1
  57. package/package.json +29 -24
  58. package/src/components/cytoscape-extensions/WithExtensions.tsx +6 -0
  59. package/src/components/lib/RelationalGraphProps.ts +2 -2
  60. package/src/components/module/graph/GraphFlexBox.tsx +2 -2
  61. package/src/components/relational/graph/Graph.tsx +37 -20
  62. package/src/components/relational/graph/{GraphDirected.stories.tsx → GraphCola.stories.tsx} +6 -6
  63. package/src/components/relational/graph/GraphCoseBilkent.stories.tsx +173 -0
  64. package/src/components/relational/graph/{GraphSpread.stories.tsx → GraphDagre.stories.tsx} +6 -6
  65. package/src/components/relational/graph/{GraphDirectedSpread.stories.tsx → GraphEuler.stories.tsx} +7 -7
  66. package/src/components/relational/graph/GraphFCose.stories.tsx +173 -0
  67. package/src/components/relational/graph/ProvidedNodeRenderer.tsx +2 -2
  68. package/src/types/global.d.ts +1 -6
@@ -0,0 +1,173 @@
1
+ import { Button, ButtonGroup } from '@mui/material'
2
+ import { Decorator, Meta, StoryFn } from '@storybook/react'
3
+ import { useAsyncEffect } from '@xylabs/react-async-effect'
4
+ import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist'
5
+ import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/http-bridge'
6
+ import { IdWitness, IdWitnessConfigSchema } from '@xyo-network/id-plugin'
7
+ import { MemoryNode } from '@xyo-network/node-memory'
8
+ import { NodeConfigSchema } from '@xyo-network/node-model'
9
+ import { NodeProvider, useNodeFromNode, useProvidedNode } from '@xyo-network/react-node'
10
+ import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
11
+ import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
12
+ import { MemorySentinel, SentinelConfigSchema } from '@xyo-network/sentinel'
13
+ import { useState } from 'react'
14
+
15
+ import { CytoscapeInstanceProvider } from '../../../contexts'
16
+ import { useCytoscapeElements, useCytoscapeOptions } from '../../../hooks'
17
+ import { NodeRelationalGraphFlexBox } from './Graph'
18
+ import { ProvidedNodeRenderer } from './ProvidedNodeRenderer'
19
+ import { options } from './story'
20
+ import { WithExtensions } from '../../cytoscape-extensions'
21
+
22
+ const nodeUrl = 'http://localhost:8080/node'
23
+
24
+ const MemoryNodeDecorator: Decorator = (Story, args) => {
25
+ const [node, setNode] = useState<MemoryNode>()
26
+
27
+ useAsyncEffect(
28
+ // eslint-disable-next-line react-hooks/exhaustive-deps
29
+ async () => {
30
+ try {
31
+ const node = await MemoryNode.create({ config: { name: 'GlobalNode', schema: NodeConfigSchema } })
32
+ const node1 = await MemoryNode.create({ config: { name: 'ChildNode', schema: NodeConfigSchema } })
33
+ const bridge = await HttpBridge.create({
34
+ config: { name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true } },
35
+ })
36
+ await node.register(bridge)
37
+ await node.attach(bridge.address, true)
38
+
39
+ const archivist = await MemoryArchivist.create({ config: { name: 'RootStorageArchivist', schema: MemoryArchivistConfigSchema } })
40
+ await node.register(archivist)
41
+ await node.attach(archivist.address, true)
42
+
43
+ const sentinel = await MemorySentinel.create({
44
+ config: { name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [] },
45
+ })
46
+ await node.register(sentinel)
47
+ await node.attach(sentinel.address, true)
48
+
49
+ const archivist1 = await MemoryArchivist.create({ config: { name: 'RootStorageArchivist1', schema: MemoryArchivistConfigSchema } })
50
+ await node1.register(archivist1)
51
+ await node1.attach(archivist1.address, true)
52
+
53
+ await node.register(node1)
54
+ await node.attach(node1.address, true)
55
+
56
+ setNode(node)
57
+ } catch (e) {
58
+ console.error('Error Creating MemoryNode', e)
59
+ }
60
+ },
61
+ [],
62
+ )
63
+
64
+ const [wallet] = useWallet({ mnemonic: DefaultSeedPhrase })
65
+
66
+ return (
67
+ <WalletProvider rootWallet={wallet}>
68
+ <NodeProvider node={node}>
69
+ <CytoscapeInstanceProvider>
70
+ <Story {...args} />
71
+ </CytoscapeInstanceProvider>
72
+ </NodeProvider>
73
+ </WalletProvider>
74
+ )
75
+ }
76
+
77
+ // eslint-disable-next-line import/no-default-export
78
+ export default {
79
+ component: NodeRelationalGraphFlexBox,
80
+ title: 'node/renderer/coseBilkent/NodeRelationalGraph',
81
+ } as Meta
82
+
83
+ const Template: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => <NodeRelationalGraphFlexBox layout="cose-bilkent" {...props} />
84
+
85
+ const TemplateDescribe: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
86
+ const [node] = useProvidedNode()
87
+ const elements = useCytoscapeElements(node)
88
+ const options = useCytoscapeOptions(elements)
89
+ return <NodeRelationalGraphFlexBox layout="cose-bilkent" options={options} {...props} />
90
+ }
91
+
92
+ const TemplateCustomAddress: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
93
+ const [node] = useNodeFromNode('ChildNode')
94
+ const elements = useCytoscapeElements(node)
95
+ const options = useCytoscapeOptions(elements)
96
+ return <NodeRelationalGraphFlexBox layout="cose-bilkent" options={options} {...props} />
97
+ }
98
+
99
+ const TemplateProvidedNodeRenderer: StoryFn<typeof ProvidedNodeRenderer> = (props) => <ProvidedNodeRenderer layout="cose-bilkent" {...props} />
100
+
101
+ const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
102
+ const [node] = useNodeFromNode('ChildNode')
103
+ const elements = useCytoscapeElements(node)
104
+ const options = useCytoscapeOptions(elements)
105
+ const [idWitness, setIdWitness] = useState<IdWitness>()
106
+
107
+ useAsyncEffect(
108
+ // eslint-disable-next-line react-hooks/exhaustive-deps
109
+ async () => {
110
+ const witnessModule = await IdWitness.create({ config: { name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema } })
111
+ setIdWitness(witnessModule)
112
+ },
113
+ [],
114
+ )
115
+
116
+ const handleAddWitness = async () => {
117
+ if (node && idWitness) {
118
+ const memoryNode = node as MemoryNode
119
+ await memoryNode.register(idWitness)
120
+ await memoryNode.attach(idWitness.address, true)
121
+ }
122
+ }
123
+
124
+ const handleRemoveWitness = async () => {
125
+ if (node && idWitness) {
126
+ const memoryNode = node as MemoryNode
127
+ if (memoryNode.registered().includes(idWitness.address)) {
128
+ await memoryNode.unregister(idWitness)
129
+ }
130
+ }
131
+ }
132
+
133
+ return (
134
+ <>
135
+ <ButtonGroup>
136
+ <Button onClick={handleAddWitness}>Add Witness</Button>
137
+ <Button onClick={handleRemoveWitness}>Remove Witness</Button>
138
+ </ButtonGroup>
139
+ <WithExtensions>
140
+ <NodeRelationalGraphFlexBox layout="cose-bilkent" options={options} {...props} />
141
+ </WithExtensions>
142
+ </>
143
+ )
144
+ }
145
+
146
+ const defaultProps = {
147
+ height: 'calc(100vh - 20px)',
148
+ width: '100%',
149
+ }
150
+
151
+ const Default = Template.bind({})
152
+ Default.args = {}
153
+
154
+ const WithData = Template.bind({})
155
+ WithData.args = { options, ...defaultProps }
156
+
157
+ const WithDescribe = TemplateDescribe.bind({})
158
+ WithDescribe.args = { ...defaultProps }
159
+ WithDescribe.decorators = [MemoryNodeDecorator]
160
+
161
+ const WithCustomAddress = TemplateCustomAddress.bind({})
162
+ WithCustomAddress.args = { ...defaultProps }
163
+ WithCustomAddress.decorators = [MemoryNodeDecorator]
164
+
165
+ const WithAttachDetach = TemplateAttachDetach.bind({})
166
+ WithAttachDetach.args = { ...defaultProps }
167
+ WithAttachDetach.decorators = [MemoryNodeDecorator]
168
+
169
+ const WithProvidedNodeRenderer = TemplateProvidedNodeRenderer.bind({})
170
+ WithProvidedNodeRenderer.args = { ...defaultProps }
171
+ WithProvidedNodeRenderer.decorators = [MemoryNodeDecorator]
172
+
173
+ export { Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer }
@@ -77,26 +77,26 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
77
77
  // eslint-disable-next-line import/no-default-export
78
78
  export default {
79
79
  component: NodeRelationalGraphFlexBox,
80
- title: 'node/renderer/spread/NodeRelationalGraph',
80
+ title: 'node/renderer/dagre/NodeRelationalGraph',
81
81
  } as Meta
82
82
 
83
- const Template: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => <NodeRelationalGraphFlexBox spread {...props} />
83
+ const Template: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => <NodeRelationalGraphFlexBox layout="dagre" {...props} />
84
84
 
85
85
  const TemplateDescribe: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
86
86
  const [node] = useProvidedNode()
87
87
  const elements = useCytoscapeElements(node)
88
88
  const options = useCytoscapeOptions(elements)
89
- return <NodeRelationalGraphFlexBox spread options={options} {...props} />
89
+ return <NodeRelationalGraphFlexBox layout="dagre" options={options} {...props} />
90
90
  }
91
91
 
92
92
  const TemplateCustomAddress: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
93
93
  const [node] = useNodeFromNode('ChildNode')
94
94
  const elements = useCytoscapeElements(node)
95
95
  const options = useCytoscapeOptions(elements)
96
- return <NodeRelationalGraphFlexBox spread options={options} {...props} />
96
+ return <NodeRelationalGraphFlexBox layout="dagre" options={options} {...props} />
97
97
  }
98
98
 
99
- const TemplateProvidedNodeRenderer: StoryFn<typeof ProvidedNodeRenderer> = (props) => <ProvidedNodeRenderer spread {...props} />
99
+ const TemplateProvidedNodeRenderer: StoryFn<typeof ProvidedNodeRenderer> = (props) => <ProvidedNodeRenderer layout="dagre" {...props} />
100
100
 
101
101
  const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
102
102
  const [node] = useNodeFromNode('ChildNode')
@@ -137,7 +137,7 @@ const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props)
137
137
  <Button onClick={handleRemoveWitness}>Remove Witness</Button>
138
138
  </ButtonGroup>
139
139
  <WithExtensions>
140
- <NodeRelationalGraphFlexBox spread options={options} {...props} />
140
+ <NodeRelationalGraphFlexBox layout="dagre" options={options} {...props} />
141
141
  </WithExtensions>
142
142
  </>
143
143
  )
@@ -14,10 +14,10 @@ import { useState } from 'react'
14
14
 
15
15
  import { CytoscapeInstanceProvider } from '../../../contexts'
16
16
  import { useCytoscapeElements, useCytoscapeOptions } from '../../../hooks'
17
- import { WithExtensions } from '../../cytoscape-extensions'
18
17
  import { NodeRelationalGraphFlexBox } from './Graph'
19
18
  import { ProvidedNodeRenderer } from './ProvidedNodeRenderer'
20
19
  import { options } from './story'
20
+ import { WithExtensions } from '../../cytoscape-extensions'
21
21
 
22
22
  const nodeUrl = 'http://localhost:8080/node'
23
23
 
@@ -77,26 +77,26 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
77
77
  // eslint-disable-next-line import/no-default-export
78
78
  export default {
79
79
  component: NodeRelationalGraphFlexBox,
80
- title: 'node/renderer/directed/spread/NodeRelationalGraph',
80
+ title: 'node/renderer/euler/NodeRelationalGraph',
81
81
  } as Meta
82
82
 
83
- const Template: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => <NodeRelationalGraphFlexBox directed spread {...props} />
83
+ const Template: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => <NodeRelationalGraphFlexBox layout="euler" {...props} />
84
84
 
85
85
  const TemplateDescribe: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
86
86
  const [node] = useProvidedNode()
87
87
  const elements = useCytoscapeElements(node)
88
88
  const options = useCytoscapeOptions(elements)
89
- return <NodeRelationalGraphFlexBox directed spread options={options} {...props} />
89
+ return <NodeRelationalGraphFlexBox layout="euler" options={options} {...props} />
90
90
  }
91
91
 
92
92
  const TemplateCustomAddress: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
93
93
  const [node] = useNodeFromNode('ChildNode')
94
94
  const elements = useCytoscapeElements(node)
95
95
  const options = useCytoscapeOptions(elements)
96
- return <NodeRelationalGraphFlexBox directed spread options={options} {...props} />
96
+ return <NodeRelationalGraphFlexBox layout="euler" options={options} {...props} />
97
97
  }
98
98
 
99
- const TemplateProvidedNodeRenderer: StoryFn<typeof ProvidedNodeRenderer> = (props) => <ProvidedNodeRenderer directed spread {...props} />
99
+ const TemplateProvidedNodeRenderer: StoryFn<typeof ProvidedNodeRenderer> = (props) => <ProvidedNodeRenderer layout="euler" {...props} />
100
100
 
101
101
  const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
102
102
  const [node] = useNodeFromNode('ChildNode')
@@ -137,7 +137,7 @@ const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props)
137
137
  <Button onClick={handleRemoveWitness}>Remove Witness</Button>
138
138
  </ButtonGroup>
139
139
  <WithExtensions>
140
- <NodeRelationalGraphFlexBox directed options={options} {...props} />
140
+ <NodeRelationalGraphFlexBox layout="euler" options={options} {...props} />
141
141
  </WithExtensions>
142
142
  </>
143
143
  )
@@ -0,0 +1,173 @@
1
+ import { Button, ButtonGroup } from '@mui/material'
2
+ import { Decorator, Meta, StoryFn } from '@storybook/react'
3
+ import { useAsyncEffect } from '@xylabs/react-async-effect'
4
+ import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist'
5
+ import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/http-bridge'
6
+ import { IdWitness, IdWitnessConfigSchema } from '@xyo-network/id-plugin'
7
+ import { MemoryNode } from '@xyo-network/node-memory'
8
+ import { NodeConfigSchema } from '@xyo-network/node-model'
9
+ import { NodeProvider, useNodeFromNode, useProvidedNode } from '@xyo-network/react-node'
10
+ import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
11
+ import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
12
+ import { MemorySentinel, SentinelConfigSchema } from '@xyo-network/sentinel'
13
+ import { useState } from 'react'
14
+
15
+ import { CytoscapeInstanceProvider } from '../../../contexts'
16
+ import { useCytoscapeElements, useCytoscapeOptions } from '../../../hooks'
17
+ import { NodeRelationalGraphFlexBox } from './Graph'
18
+ import { ProvidedNodeRenderer } from './ProvidedNodeRenderer'
19
+ import { options } from './story'
20
+ import { WithExtensions } from '../../cytoscape-extensions'
21
+
22
+ const nodeUrl = 'http://localhost:8080/node'
23
+
24
+ const MemoryNodeDecorator: Decorator = (Story, args) => {
25
+ const [node, setNode] = useState<MemoryNode>()
26
+
27
+ useAsyncEffect(
28
+ // eslint-disable-next-line react-hooks/exhaustive-deps
29
+ async () => {
30
+ try {
31
+ const node = await MemoryNode.create({ config: { name: 'GlobalNode', schema: NodeConfigSchema } })
32
+ const node1 = await MemoryNode.create({ config: { name: 'ChildNode', schema: NodeConfigSchema } })
33
+ const bridge = await HttpBridge.create({
34
+ config: { name: 'Bridge', nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true } },
35
+ })
36
+ await node.register(bridge)
37
+ await node.attach(bridge.address, true)
38
+
39
+ const archivist = await MemoryArchivist.create({ config: { name: 'RootStorageArchivist', schema: MemoryArchivistConfigSchema } })
40
+ await node.register(archivist)
41
+ await node.attach(archivist.address, true)
42
+
43
+ const sentinel = await MemorySentinel.create({
44
+ config: { name: 'MemorySentinel', schema: SentinelConfigSchema, synchronous: true, tasks: [] },
45
+ })
46
+ await node.register(sentinel)
47
+ await node.attach(sentinel.address, true)
48
+
49
+ const archivist1 = await MemoryArchivist.create({ config: { name: 'RootStorageArchivist1', schema: MemoryArchivistConfigSchema } })
50
+ await node1.register(archivist1)
51
+ await node1.attach(archivist1.address, true)
52
+
53
+ await node.register(node1)
54
+ await node.attach(node1.address, true)
55
+
56
+ setNode(node)
57
+ } catch (e) {
58
+ console.error('Error Creating MemoryNode', e)
59
+ }
60
+ },
61
+ [],
62
+ )
63
+
64
+ const [wallet] = useWallet({ mnemonic: DefaultSeedPhrase })
65
+
66
+ return (
67
+ <WalletProvider rootWallet={wallet}>
68
+ <NodeProvider node={node}>
69
+ <CytoscapeInstanceProvider>
70
+ <Story {...args} />
71
+ </CytoscapeInstanceProvider>
72
+ </NodeProvider>
73
+ </WalletProvider>
74
+ )
75
+ }
76
+
77
+ // eslint-disable-next-line import/no-default-export
78
+ export default {
79
+ component: NodeRelationalGraphFlexBox,
80
+ title: 'node/renderer/fcose/NodeRelationalGraph',
81
+ } as Meta
82
+
83
+ const Template: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => <NodeRelationalGraphFlexBox layout="fcose" {...props} />
84
+
85
+ const TemplateDescribe: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
86
+ const [node] = useProvidedNode()
87
+ const elements = useCytoscapeElements(node)
88
+ const options = useCytoscapeOptions(elements)
89
+ return <NodeRelationalGraphFlexBox layout="fcose" options={options} {...props} />
90
+ }
91
+
92
+ const TemplateCustomAddress: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
93
+ const [node] = useNodeFromNode('ChildNode')
94
+ const elements = useCytoscapeElements(node)
95
+ const options = useCytoscapeOptions(elements)
96
+ return <NodeRelationalGraphFlexBox layout="fcose" options={options} {...props} />
97
+ }
98
+
99
+ const TemplateProvidedNodeRenderer: StoryFn<typeof ProvidedNodeRenderer> = (props) => <ProvidedNodeRenderer layout="fcose" {...props} />
100
+
101
+ const TemplateAttachDetach: StoryFn<typeof NodeRelationalGraphFlexBox> = (props) => {
102
+ const [node] = useNodeFromNode('ChildNode')
103
+ const elements = useCytoscapeElements(node)
104
+ const options = useCytoscapeOptions(elements)
105
+ const [idWitness, setIdWitness] = useState<IdWitness>()
106
+
107
+ useAsyncEffect(
108
+ // eslint-disable-next-line react-hooks/exhaustive-deps
109
+ async () => {
110
+ const witnessModule = await IdWitness.create({ config: { name: 'IdWitness', salt: 'test', schema: IdWitnessConfigSchema } })
111
+ setIdWitness(witnessModule)
112
+ },
113
+ [],
114
+ )
115
+
116
+ const handleAddWitness = async () => {
117
+ if (node && idWitness) {
118
+ const memoryNode = node as MemoryNode
119
+ await memoryNode.register(idWitness)
120
+ await memoryNode.attach(idWitness.address, true)
121
+ }
122
+ }
123
+
124
+ const handleRemoveWitness = async () => {
125
+ if (node && idWitness) {
126
+ const memoryNode = node as MemoryNode
127
+ if (memoryNode.registered().includes(idWitness.address)) {
128
+ await memoryNode.unregister(idWitness)
129
+ }
130
+ }
131
+ }
132
+
133
+ return (
134
+ <>
135
+ <ButtonGroup>
136
+ <Button onClick={handleAddWitness}>Add Witness</Button>
137
+ <Button onClick={handleRemoveWitness}>Remove Witness</Button>
138
+ </ButtonGroup>
139
+ <WithExtensions>
140
+ <NodeRelationalGraphFlexBox layout="fcose" options={options} {...props} />
141
+ </WithExtensions>
142
+ </>
143
+ )
144
+ }
145
+
146
+ const defaultProps = {
147
+ height: 'calc(100vh - 20px)',
148
+ width: '100%',
149
+ }
150
+
151
+ const Default = Template.bind({})
152
+ Default.args = {}
153
+
154
+ const WithData = Template.bind({})
155
+ WithData.args = { options, ...defaultProps }
156
+
157
+ const WithDescribe = TemplateDescribe.bind({})
158
+ WithDescribe.args = { ...defaultProps }
159
+ WithDescribe.decorators = [MemoryNodeDecorator]
160
+
161
+ const WithCustomAddress = TemplateCustomAddress.bind({})
162
+ WithCustomAddress.args = { ...defaultProps }
163
+ WithCustomAddress.decorators = [MemoryNodeDecorator]
164
+
165
+ const WithAttachDetach = TemplateAttachDetach.bind({})
166
+ WithAttachDetach.args = { ...defaultProps }
167
+ WithAttachDetach.decorators = [MemoryNodeDecorator]
168
+
169
+ const WithProvidedNodeRenderer = TemplateProvidedNodeRenderer.bind({})
170
+ WithProvidedNodeRenderer.args = { ...defaultProps }
171
+ WithProvidedNodeRenderer.decorators = [MemoryNodeDecorator]
172
+
173
+ export { Default, WithAttachDetach, WithCustomAddress, WithData, WithDescribe, WithProvidedNodeRenderer }
@@ -8,9 +8,9 @@ import { NodeRelationalGraphFlexBox } from './Graph'
8
8
 
9
9
  export interface ProvidedNodeRendererProps extends NodeRelationalGraphProps {
10
10
  account?: AccountInstance
11
- directed?: boolean | object
11
+ layout?: 'dagre' | 'euler' | 'fcose' | 'cose-bilkent' | 'cola'
12
+ layoutOptions?: object
12
13
  node?: NodeInstance
13
- spread?: boolean | object
14
14
  }
15
15
 
16
16
  export const ProvidedNodeRenderer: React.FC<ProvidedNodeRendererProps> = ({ node, ...props }) => {
@@ -3,12 +3,7 @@ declare module 'cytoscape-cola' {
3
3
  export = ext
4
4
  }
5
5
 
6
- declare module 'cytoscape-fcose' {
7
- const ext: cytoscape.Ext
8
- export = ext
9
- }
10
-
11
- declare module 'cytoscape-dagre' {
6
+ declare module 'cytoscape-cose-bilkent' {
12
7
  const ext: cytoscape.Ext
13
8
  export = ext
14
9
  }