@xyo-network/react-node-renderer 2.47.38 → 2.47.40

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.
@@ -1,12 +1,12 @@
1
- import CallMergeRoundedIcon from '@mui/icons-material/CallMergeRounded';
2
- import GridViewRoundedIcon from '@mui/icons-material/GridViewRounded';
1
+ import BubbleChartRoundedIcon from '@mui/icons-material/BubbleChartRounded';
3
2
  import HubIcon from '@mui/icons-material/Hub';
3
+ import Inventory2RoundedIcon from '@mui/icons-material/Inventory2Rounded';
4
4
  import QuestionMarkRoundedIcon from '@mui/icons-material/QuestionMarkRounded';
5
5
  import VisibilityRoundedIcon from '@mui/icons-material/VisibilityRounded';
6
6
  // eslint-disable-next-line @typescript-eslint/ban-types
7
7
  export const CyIconSet = {
8
- archivist: GridViewRoundedIcon,
9
- diviner: CallMergeRoundedIcon,
8
+ archivist: Inventory2RoundedIcon,
9
+ diviner: BubbleChartRoundedIcon,
10
10
  module: QuestionMarkRoundedIcon,
11
11
  node: HubIcon,
12
12
  witness: VisibilityRoundedIcon,
@@ -1 +1 @@
1
- {"version":3,"file":"CytoscapeIcons.js","sourceRoot":"","sources":["../../../src/Cytoscape/CytoscapeIcons.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,sCAAsC,CAAA;AACvE,OAAO,mBAAmB,MAAM,qCAAqC,CAAA;AACrE,OAAO,OAAO,MAAM,yBAAyB,CAAA;AAC7C,OAAO,uBAAuB,MAAM,yCAAyC,CAAA;AAC7E,OAAO,qBAAqB,MAAM,uCAAuC,CAAA;AAMzE,wDAAwD;AACxD,MAAM,CAAC,MAAM,SAAS,GAAyE;IAC7F,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE,oBAAoB;IAC7B,MAAM,EAAE,uBAAuB;IAC/B,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,qBAAqB;CAC/B,CAAA"}
1
+ {"version":3,"file":"CytoscapeIcons.js","sourceRoot":"","sources":["../../../src/Cytoscape/CytoscapeIcons.tsx"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,MAAM,wCAAwC,CAAA;AAC3E,OAAO,OAAO,MAAM,yBAAyB,CAAA;AAC7C,OAAO,qBAAqB,MAAM,uCAAuC,CAAA;AACzE,OAAO,uBAAuB,MAAM,yCAAyC,CAAA;AAC7E,OAAO,qBAAqB,MAAM,uCAAuC,CAAA;AAMzE,wDAAwD;AACxD,MAAM,CAAC,MAAM,SAAS,GAAyE;IAC7F,SAAS,EAAE,qBAAqB;IAChC,OAAO,EAAE,sBAAsB;IAC/B,MAAM,EAAE,uBAAuB;IAC/B,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,qBAAqB;CAC/B,CAAA"}
@@ -1,27 +1,37 @@
1
1
  import { useAsyncEffect } from '@xylabs/react-shared';
2
- import { useProvidedWrappedNode } from '@xyo-network/react-node';
2
+ import { NodeWrapper } from '@xyo-network/node';
3
+ import { useModule, useProvidedWrappedNode } from '@xyo-network/react-node';
3
4
  import { useEffect, useState } from 'react';
4
5
  import { CytoscapeElements } from '../../Cytoscape';
5
6
  /**
6
7
  * Note: Relies on describe but could eventually be converted to a discover call
7
8
  * Logic would be similar to what the bridge does
8
9
  */
9
- export const useCytoscapeElements = () => {
10
+ export const useCytoscapeElements = (nodeAddressOrName, onModuleError) => {
10
11
  const [node] = useProvidedWrappedNode();
12
+ const [module, moduleError] = useModule(nodeAddressOrName);
11
13
  const [elements, setElements] = useState([]);
12
14
  const [refresh, setRefresh] = useState(1);
15
+ useEffect(() => {
16
+ if (moduleError)
17
+ onModuleError?.(moduleError);
18
+ }, [moduleError, onModuleError]);
13
19
  useAsyncEffect(
14
20
  // eslint-disable-next-line react-hooks/exhaustive-deps
15
21
  async (mounted) => {
16
- if (node && refresh) {
22
+ if ((node || module) && refresh) {
23
+ const wrappedNode = nodeAddressOrName ? NodeWrapper.wrap(module) : node;
24
+ if (!wrappedNode) {
25
+ return;
26
+ }
17
27
  try {
18
- const [description, newRootNode] = await CytoscapeElements.buildRootNode(node);
28
+ const [description, newRootNode] = await CytoscapeElements.buildRootNode(wrappedNode);
19
29
  if (mounted())
20
30
  setElements(() => [newRootNode]);
21
31
  const children = description.children;
22
32
  await Promise.allSettled((children ?? [])?.map(async (address) => {
23
33
  try {
24
- const newNode = await CytoscapeElements.buildChild(node, address);
34
+ const newNode = await CytoscapeElements.buildChild(wrappedNode, address);
25
35
  if (mounted())
26
36
  setElements((previous) => [...previous, newNode]);
27
37
  const newEdge = CytoscapeElements.buildEdge(newRootNode, newNode);
@@ -37,7 +47,7 @@ export const useCytoscapeElements = () => {
37
47
  console.error('Error Getting initial description', e);
38
48
  }
39
49
  }
40
- }, [node, refresh]);
50
+ }, [module, node, nodeAddressOrName, refresh]);
41
51
  useEffect(() => {
42
52
  let listener;
43
53
  if (node) {
@@ -1 +1 @@
1
- {"version":3,"file":"useCytoscapeElements.js","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeElements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,MAAM,CAAC,IAAI,CAAC,GAAG,sBAAsB,EAAE,CAAA;IACvC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAsB,EAAE,CAAC,CAAA;IACjE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAEzC,cAAc;IACZ,uDAAuD;IACvD,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IAAI,IAAI,IAAI,OAAO,EAAE;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AC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,CAAC,CAAC,CAAA;aACtD;SACF;IACH,CAAC,EACD,CAAC,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAC3C,CAAA;IAED,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,QAAkC,CAAA;QACtC,IAAI,IAAI,EAAE;YACR,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE;gBAClC,IAAI,SAAS,KAAK,gBAAgB;oBAAE,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAA;YAC5E,CAAC,CAAC,CAAA;SACH;QACD,OAAO,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAA;IAC3B,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA"}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from './components';
2
+ export * from './Cytoscape';
2
3
  export * from './hooks';
4
+ export * from './lib';
3
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA"}
@@ -3,5 +3,5 @@ import { ElementDefinition } from 'cytoscape';
3
3
  * Note: Relies on describe but could eventually be converted to a discover call
4
4
  * Logic would be similar to what the bridge does
5
5
  */
6
- export declare const useCytoscapeElements: () => ElementDefinition[];
6
+ export declare const useCytoscapeElements: (nodeAddressOrName?: string, onModuleError?: ((error: Error) => void) | undefined) => ElementDefinition[];
7
7
  //# sourceMappingURL=useCytoscapeElements.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCytoscapeElements.d.ts","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeElements.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAK7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,2BA8ChC,CAAA"}
1
+ {"version":3,"file":"useCytoscapeElements.d.ts","sourceRoot":"","sources":["../../../../src/hooks/cytoscape/useCytoscapeElements.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAK7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,uBAAwB,MAAM,2BAA0B,KAAK,KAAK,IAAI,qCAuDtG,CAAA"}
@@ -1,3 +1,5 @@
1
1
  export * from './components';
2
+ export * from './Cytoscape';
2
3
  export * from './hooks';
4
+ export * from './lib';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA"}
package/package.json CHANGED
@@ -14,8 +14,8 @@
14
14
  "@xylabs/react-shared": "^2.16.14",
15
15
  "@xyo-network/module": "^2.53.36",
16
16
  "@xyo-network/node": "^2.53.36",
17
- "@xyo-network/react-node": "^2.47.38",
18
- "@xyo-network/react-shared": "^2.47.38",
17
+ "@xyo-network/react-node": "^2.47.40",
18
+ "@xyo-network/react-shared": "^2.47.40",
19
19
  "cytoscape": "^3.23.0"
20
20
  },
21
21
  "peerDependencies": {
@@ -39,9 +39,9 @@
39
39
  "@xyo-network/id-plugin": "^2.53.34",
40
40
  "@xyo-network/module": "^2.53.34",
41
41
  "@xyo-network/node": "^2.53.34",
42
- "@xyo-network/react-node": "^2.47.38",
43
- "@xyo-network/react-storybook": "^2.47.38",
44
- "@xyo-network/react-wallet": "^2.47.38",
42
+ "@xyo-network/react-node": "^2.47.40",
43
+ "@xyo-network/react-storybook": "^2.47.40",
44
+ "@xyo-network/react-wallet": "^2.47.40",
45
45
  "require-from-string": "^2.0.2",
46
46
  "typescript": "^4.9.5"
47
47
  },
@@ -88,5 +88,5 @@
88
88
  },
89
89
  "sideEffects": false,
90
90
  "types": "dist/types/index.d.ts",
91
- "version": "2.47.38"
91
+ "version": "2.47.40"
92
92
  }
@@ -1,6 +1,6 @@
1
- import CallMergeRoundedIcon from '@mui/icons-material/CallMergeRounded'
2
- import GridViewRoundedIcon from '@mui/icons-material/GridViewRounded'
1
+ import BubbleChartRoundedIcon from '@mui/icons-material/BubbleChartRounded'
3
2
  import HubIcon from '@mui/icons-material/Hub'
3
+ import Inventory2RoundedIcon from '@mui/icons-material/Inventory2Rounded'
4
4
  import QuestionMarkRoundedIcon from '@mui/icons-material/QuestionMarkRounded'
5
5
  import VisibilityRoundedIcon from '@mui/icons-material/VisibilityRounded'
6
6
  import { SvgIconTypeMap } from '@mui/material'
@@ -10,8 +10,8 @@ export type CyNodeIcons = 'archivist' | 'diviner' | 'module' | 'node' | 'witness
10
10
 
11
11
  // eslint-disable-next-line @typescript-eslint/ban-types
12
12
  export const CyIconSet: Record<CyNodeIcons, OverridableComponent<SvgIconTypeMap<{}, 'svg'>>> = {
13
- archivist: GridViewRoundedIcon,
14
- diviner: CallMergeRoundedIcon,
13
+ archivist: Inventory2RoundedIcon,
14
+ diviner: BubbleChartRoundedIcon,
15
15
  module: QuestionMarkRoundedIcon,
16
16
  node: HubIcon,
17
17
  witness: VisibilityRoundedIcon,
@@ -67,12 +67,19 @@ export default {
67
67
  } as Meta
68
68
 
69
69
  const Template: ComponentStory<typeof NodeRelationalGraph> = (props) => <NodeRelationalGraph {...props} />
70
+
70
71
  const TemplateDescribe: ComponentStory<typeof NodeRelationalGraph> = (props) => {
71
72
  const elements = useCytoscapeElements()
72
73
  const options = useCytoscapeOptions(elements)
73
74
  return <NodeRelationalGraph options={options} {...props} />
74
75
  }
75
76
 
77
+ const TemplateCustomAddress: ComponentStory<typeof NodeRelationalGraph> = (props) => {
78
+ const elements = useCytoscapeElements('ChildNode')
79
+ const options = useCytoscapeOptions(elements)
80
+ return <NodeRelationalGraph options={options} {...props} />
81
+ }
82
+
76
83
  const defaultProps = {
77
84
  height: 'calc(100vh - 20px)',
78
85
  width: '100%',
@@ -88,4 +95,8 @@ const WithDescribe = TemplateDescribe.bind({})
88
95
  WithDescribe.args = { ...defaultProps }
89
96
  WithDescribe.decorators = [MemoryNodeDecorator]
90
97
 
91
- export { Default, WithData, WithDescribe }
98
+ const WithCustomAddress = TemplateCustomAddress.bind({})
99
+ WithCustomAddress.args = { ...defaultProps }
100
+ WithCustomAddress.decorators = [MemoryNodeDecorator]
101
+
102
+ export { Default, WithCustomAddress, WithData, WithDescribe }
@@ -1,6 +1,7 @@
1
1
  import { useAsyncEffect } from '@xylabs/react-shared'
2
2
  import { EventUnsubscribeFunction } from '@xyo-network/module'
3
- import { useProvidedWrappedNode } from '@xyo-network/react-node'
3
+ import { NodeWrapper } from '@xyo-network/node'
4
+ import { useModule, useProvidedWrappedNode } from '@xyo-network/react-node'
4
5
  import { ElementDefinition } from 'cytoscape'
5
6
  import { useEffect, useState } from 'react'
6
7
 
@@ -10,24 +11,33 @@ import { CytoscapeElements } from '../../Cytoscape'
10
11
  * Note: Relies on describe but could eventually be converted to a discover call
11
12
  * Logic would be similar to what the bridge does
12
13
  */
13
- export const useCytoscapeElements = () => {
14
+ export const useCytoscapeElements = (nodeAddressOrName?: string, onModuleError?: (error: Error) => void) => {
14
15
  const [node] = useProvidedWrappedNode()
16
+ const [module, moduleError] = useModule(nodeAddressOrName)
15
17
  const [elements, setElements] = useState<ElementDefinition[]>([])
16
18
  const [refresh, setRefresh] = useState(1)
17
19
 
20
+ useEffect(() => {
21
+ if (moduleError) onModuleError?.(moduleError)
22
+ }, [moduleError, onModuleError])
23
+
18
24
  useAsyncEffect(
19
25
  // eslint-disable-next-line react-hooks/exhaustive-deps
20
26
  async (mounted) => {
21
- if (node && refresh) {
27
+ if ((node || module) && refresh) {
28
+ const wrappedNode = nodeAddressOrName ? NodeWrapper.wrap(module) : node
29
+ if (!wrappedNode) {
30
+ return
31
+ }
22
32
  try {
23
- const [description, newRootNode] = await CytoscapeElements.buildRootNode(node)
33
+ const [description, newRootNode] = await CytoscapeElements.buildRootNode(wrappedNode)
24
34
  if (mounted()) setElements(() => [newRootNode])
25
35
 
26
36
  const children = description.children
27
37
  await Promise.allSettled(
28
38
  (children ?? [])?.map(async (address) => {
29
39
  try {
30
- const newNode = await CytoscapeElements.buildChild(node, address)
40
+ const newNode = await CytoscapeElements.buildChild(wrappedNode, address)
31
41
  if (mounted()) setElements((previous) => [...previous, newNode])
32
42
 
33
43
  const newEdge = CytoscapeElements.buildEdge(newRootNode, newNode)
@@ -42,7 +52,7 @@ export const useCytoscapeElements = () => {
42
52
  }
43
53
  }
44
54
  },
45
- [node, refresh],
55
+ [module, node, nodeAddressOrName, refresh],
46
56
  )
47
57
 
48
58
  useEffect(() => {
package/src/index.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './components'
2
+ export * from './Cytoscape'
2
3
  export * from './hooks'
4
+ export * from './lib'