@xyo-network/react-module 2.38.17
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/LICENSE +165 -0
- package/README.md +70 -0
- package/dist/cjs/ModuleRenderProps.d.ts +5 -0
- package/dist/cjs/ModuleRenderProps.d.ts.map +1 -0
- package/dist/cjs/ModuleRenderProps.js +3 -0
- package/dist/cjs/ModuleRenderProps.js.map +1 -0
- package/dist/cjs/components/ArchivistCard.d.ts +6 -0
- package/dist/cjs/components/ArchivistCard.d.ts.map +1 -0
- package/dist/cjs/components/ArchivistCard.js +15 -0
- package/dist/cjs/components/ArchivistCard.js.map +1 -0
- package/dist/cjs/components/ArchivistCardHeader.d.ts +6 -0
- package/dist/cjs/components/ArchivistCardHeader.d.ts.map +1 -0
- package/dist/cjs/components/ArchivistCardHeader.js +12 -0
- package/dist/cjs/components/ArchivistCardHeader.js.map +1 -0
- package/dist/cjs/components/ArchivistContent.d.ts +6 -0
- package/dist/cjs/components/ArchivistContent.d.ts.map +1 -0
- package/dist/cjs/components/ArchivistContent.js +32 -0
- package/dist/cjs/components/ArchivistContent.js.map +1 -0
- package/dist/cjs/components/Card.d.ts +5 -0
- package/dist/cjs/components/Card.d.ts.map +1 -0
- package/dist/cjs/components/Card.js +15 -0
- package/dist/cjs/components/Card.js.map +1 -0
- package/dist/cjs/components/CardActions.d.ts +5 -0
- package/dist/cjs/components/CardActions.d.ts.map +1 -0
- package/dist/cjs/components/CardActions.js +15 -0
- package/dist/cjs/components/CardActions.js.map +1 -0
- package/dist/cjs/components/CardContent.d.ts +5 -0
- package/dist/cjs/components/CardContent.d.ts.map +1 -0
- package/dist/cjs/components/CardContent.js +29 -0
- package/dist/cjs/components/CardContent.js.map +1 -0
- package/dist/cjs/components/CardHeader.d.ts +5 -0
- package/dist/cjs/components/CardHeader.d.ts.map +1 -0
- package/dist/cjs/components/CardHeader.js +15 -0
- package/dist/cjs/components/CardHeader.js.map +1 -0
- package/dist/cjs/components/DetailsBox.d.ts +5 -0
- package/dist/cjs/components/DetailsBox.d.ts.map +1 -0
- package/dist/cjs/components/DetailsBox.js +16 -0
- package/dist/cjs/components/DetailsBox.js.map +1 -0
- package/dist/cjs/components/TableCell.d.ts +5 -0
- package/dist/cjs/components/TableCell.d.ts.map +1 -0
- package/dist/cjs/components/TableCell.js +16 -0
- package/dist/cjs/components/TableCell.js.map +1 -0
- package/dist/cjs/components/index.d.ts +6 -0
- package/dist/cjs/components/index.d.ts.map +1 -0
- package/dist/cjs/components/index.js +9 -0
- package/dist/cjs/components/index.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/docs.json +869 -0
- package/dist/esm/ModuleRenderProps.d.ts +5 -0
- package/dist/esm/ModuleRenderProps.d.ts.map +1 -0
- package/dist/esm/ModuleRenderProps.js +2 -0
- package/dist/esm/ModuleRenderProps.js.map +1 -0
- package/dist/esm/components/ArchivistCard.d.ts +6 -0
- package/dist/esm/components/ArchivistCard.d.ts.map +1 -0
- package/dist/esm/components/ArchivistCard.js +9 -0
- package/dist/esm/components/ArchivistCard.js.map +1 -0
- package/dist/esm/components/ArchivistCardHeader.d.ts +6 -0
- package/dist/esm/components/ArchivistCardHeader.d.ts.map +1 -0
- package/dist/esm/components/ArchivistCardHeader.js +6 -0
- package/dist/esm/components/ArchivistCardHeader.js.map +1 -0
- package/dist/esm/components/ArchivistContent.d.ts +6 -0
- package/dist/esm/components/ArchivistContent.d.ts.map +1 -0
- package/dist/esm/components/ArchivistContent.js +25 -0
- package/dist/esm/components/ArchivistContent.js.map +1 -0
- package/dist/esm/components/Card.d.ts +5 -0
- package/dist/esm/components/Card.d.ts.map +1 -0
- package/dist/esm/components/Card.js +9 -0
- package/dist/esm/components/Card.js.map +1 -0
- package/dist/esm/components/CardActions.d.ts +5 -0
- package/dist/esm/components/CardActions.d.ts.map +1 -0
- package/dist/esm/components/CardActions.js +9 -0
- package/dist/esm/components/CardActions.js.map +1 -0
- package/dist/esm/components/CardContent.d.ts +5 -0
- package/dist/esm/components/CardContent.d.ts.map +1 -0
- package/dist/esm/components/CardContent.js +23 -0
- package/dist/esm/components/CardContent.js.map +1 -0
- package/dist/esm/components/CardHeader.d.ts +5 -0
- package/dist/esm/components/CardHeader.d.ts.map +1 -0
- package/dist/esm/components/CardHeader.js +9 -0
- package/dist/esm/components/CardHeader.js.map +1 -0
- package/dist/esm/components/DetailsBox.d.ts +5 -0
- package/dist/esm/components/DetailsBox.d.ts.map +1 -0
- package/dist/esm/components/DetailsBox.js +10 -0
- package/dist/esm/components/DetailsBox.js.map +1 -0
- package/dist/esm/components/TableCell.d.ts +5 -0
- package/dist/esm/components/TableCell.d.ts.map +1 -0
- package/dist/esm/components/TableCell.js +10 -0
- package/dist/esm/components/TableCell.js.map +1 -0
- package/dist/esm/components/index.d.ts +6 -0
- package/dist/esm/components/index.d.ts.map +1 -0
- package/dist/esm/components/index.js +6 -0
- package/dist/esm/components/index.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +83 -0
- package/src/ModuleRenderProps.tsx +5 -0
- package/src/components/ArchivistCard.stories.tsx +54 -0
- package/src/components/ArchivistCard.tsx +17 -0
- package/src/components/ArchivistCardHeader.tsx +9 -0
- package/src/components/ArchivistContent.tsx +37 -0
- package/src/components/Card.stories.tsx +49 -0
- package/src/components/Card.tsx +16 -0
- package/src/components/CardActions.tsx +15 -0
- package/src/components/CardContent.tsx +35 -0
- package/src/components/CardHeader.tsx +17 -0
- package/src/components/DetailsBox.tsx +15 -0
- package/src/components/TableCell.tsx +15 -0
- package/src/components/index.ts +5 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CardActions, CardActionsProps } from '@mui/material'
|
|
2
|
+
import { ButtonEx } from '@xylabs/react-button'
|
|
3
|
+
import { XyoModuleWrapper } from '@xyo-network/module'
|
|
4
|
+
|
|
5
|
+
import { ModuleRenderProps } from '../ModuleRenderProps'
|
|
6
|
+
|
|
7
|
+
export const ModuleCardActions: React.FC<CardActionsProps & ModuleRenderProps> = ({ children, module, ...props }) => {
|
|
8
|
+
const wrapper = module ? new XyoModuleWrapper(module) : undefined
|
|
9
|
+
return (
|
|
10
|
+
<CardActions {...props}>
|
|
11
|
+
<ButtonEx onClick={() => wrapper?.discover()}>Discover</ButtonEx>
|
|
12
|
+
{children}
|
|
13
|
+
</CardActions>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CardContent, CardContentProps, Typography } from '@mui/material'
|
|
2
|
+
import { useAsyncEffect } from '@xylabs/react-shared'
|
|
3
|
+
import { EthAddress } from '@xylabs/sdk-js'
|
|
4
|
+
import { EthAccountBox } from '@xylabs/sdk-react'
|
|
5
|
+
import { XyoModuleConfig, XyoModuleWrapper } from '@xyo-network/module'
|
|
6
|
+
import { useState } from 'react'
|
|
7
|
+
|
|
8
|
+
import { ModuleRenderProps } from '../ModuleRenderProps'
|
|
9
|
+
|
|
10
|
+
export const ModuleCardContent: React.FC<ModuleRenderProps & CardContentProps> = ({ children, module, ...props }) => {
|
|
11
|
+
const [config, setConfig] = useState<XyoModuleConfig>()
|
|
12
|
+
|
|
13
|
+
const account = module?.address ? EthAddress.fromString(module?.address) : undefined
|
|
14
|
+
|
|
15
|
+
useAsyncEffect(
|
|
16
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
|
+
async (mounted) => {
|
|
18
|
+
const wrapper = module ? new XyoModuleWrapper(module) : undefined
|
|
19
|
+
const payloads = await wrapper?.discover()
|
|
20
|
+
console.log(`Payloads: ${JSON.stringify(payloads, null, 2)}`)
|
|
21
|
+
if (mounted()) {
|
|
22
|
+
setConfig(payloads?.[0])
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
[module],
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<CardContent {...props}>
|
|
30
|
+
<EthAccountBox address={account} />
|
|
31
|
+
{children}
|
|
32
|
+
<Typography variant="subtitle2">{config?.schema}</Typography>
|
|
33
|
+
</CardContent>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CardHeader, CardHeaderProps } from '@mui/material'
|
|
2
|
+
import { Identicon } from '@xylabs/react-identicon'
|
|
3
|
+
import { XyoModuleWrapper } from '@xyo-network/module'
|
|
4
|
+
|
|
5
|
+
import { ModuleRenderProps } from '../ModuleRenderProps'
|
|
6
|
+
|
|
7
|
+
export const ModuleCardHeader: React.FC<ModuleRenderProps & CardHeaderProps> = ({ subheader, avatar, title, module, ...props }) => {
|
|
8
|
+
const wrapper = module ? new XyoModuleWrapper(module) : undefined
|
|
9
|
+
return (
|
|
10
|
+
<CardHeader
|
|
11
|
+
title={title ?? 'Module'}
|
|
12
|
+
subheader={subheader ?? wrapper?.address}
|
|
13
|
+
avatar={avatar ?? <Identicon size={24} value={wrapper?.address} />}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FlexBoxProps, FlexCol } from '@xylabs/react-flexbox'
|
|
2
|
+
import { EthAddress } from '@xylabs/sdk-js'
|
|
3
|
+
import { EthAccountBox } from '@xylabs/sdk-react'
|
|
4
|
+
import { XyoModuleWrapper } from '@xyo-network/module'
|
|
5
|
+
|
|
6
|
+
import { ModuleRenderProps } from '../ModuleRenderProps'
|
|
7
|
+
|
|
8
|
+
export const ModuleDetailsBox: React.FC<ModuleRenderProps & FlexBoxProps> = ({ module, ...props }) => {
|
|
9
|
+
const wrapper = module ? new XyoModuleWrapper(module) : undefined
|
|
10
|
+
return (
|
|
11
|
+
<FlexCol {...props}>
|
|
12
|
+
<EthAccountBox address={EthAddress.fromString(wrapper?.address)} />
|
|
13
|
+
</FlexCol>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TableCell, TableCellProps } from '@mui/material'
|
|
2
|
+
import { EthAddress } from '@xylabs/sdk-js'
|
|
3
|
+
import { EthAccountBox } from '@xylabs/sdk-react'
|
|
4
|
+
import { XyoModuleWrapper } from '@xyo-network/module'
|
|
5
|
+
|
|
6
|
+
import { ModuleRenderProps } from '../ModuleRenderProps'
|
|
7
|
+
|
|
8
|
+
export const ModuleTableCell: React.FC<ModuleRenderProps & TableCellProps> = ({ module, ...props }) => {
|
|
9
|
+
const wrapper = module ? new XyoModuleWrapper(module) : undefined
|
|
10
|
+
return (
|
|
11
|
+
<TableCell {...props}>
|
|
12
|
+
<EthAccountBox address={EthAddress.fromString(wrapper?.address)} />
|
|
13
|
+
</TableCell>
|
|
14
|
+
)
|
|
15
|
+
}
|
package/src/index.ts
ADDED