@xyo-network/react-chain-boundwitness 1.0.1
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 +13 -0
- package/dist/browser/index.mjs +1246 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/types/Plugin.d.ts +3 -0
- package/dist/types/Plugin.d.ts.map +1 -0
- package/dist/types/components/Card/Card.d.ts +9 -0
- package/dist/types/components/Card/Card.d.ts.map +1 -0
- package/dist/types/components/Card/CardContent/AddressAvatarGroup.d.ts +8 -0
- package/dist/types/components/Card/CardContent/AddressAvatarGroup.d.ts.map +1 -0
- package/dist/types/components/Card/CardContent/CardContent.d.ts +9 -0
- package/dist/types/components/Card/CardContent/CardContent.d.ts.map +1 -0
- package/dist/types/components/Card/CardContent/SchemaAvatarGroup.d.ts +9 -0
- package/dist/types/components/Card/CardContent/SchemaAvatarGroup.d.ts.map +1 -0
- package/dist/types/components/Card/CardContent/index.d.ts +3 -0
- package/dist/types/components/Card/CardContent/index.d.ts.map +1 -0
- package/dist/types/components/Card/CardContent/layout/CardColumnTitle.d.ts +5 -0
- package/dist/types/components/Card/CardContent/layout/CardColumnTitle.d.ts.map +1 -0
- package/dist/types/components/Card/CardContent/layout/CardColumnsFlex.d.ts +2 -0
- package/dist/types/components/Card/CardContent/layout/CardColumnsFlex.d.ts.map +1 -0
- package/dist/types/components/Card/CardContent/layout/CardContentFlex.d.ts +5 -0
- package/dist/types/components/Card/CardContent/layout/CardContentFlex.d.ts.map +1 -0
- package/dist/types/components/Card/CardContent/layout/index.d.ts +4 -0
- package/dist/types/components/Card/CardContent/layout/index.d.ts.map +1 -0
- package/dist/types/components/Card/CardHeader/CardHeader.d.ts +14 -0
- package/dist/types/components/Card/CardHeader/CardHeader.d.ts.map +1 -0
- package/dist/types/components/Card/CardHeader/index.d.ts +2 -0
- package/dist/types/components/Card/CardHeader/index.d.ts.map +1 -0
- package/dist/types/components/Card/index.d.ts +4 -0
- package/dist/types/components/Card/index.d.ts.map +1 -0
- package/dist/types/components/Details/BoundWitnessLinksDetails.d.ts +8 -0
- package/dist/types/components/Details/BoundWitnessLinksDetails.d.ts.map +1 -0
- package/dist/types/components/Details/Box/DetailsBox.d.ts +6 -0
- package/dist/types/components/Details/Box/DetailsBox.d.ts.map +1 -0
- package/dist/types/components/Details/Box/index.d.ts +2 -0
- package/dist/types/components/Details/Box/index.d.ts.map +1 -0
- package/dist/types/components/Details/Card/DetailsCard.d.ts +7 -0
- package/dist/types/components/Details/Card/DetailsCard.d.ts.map +1 -0
- package/dist/types/components/Details/Card/DetailsCardContent.d.ts +10 -0
- package/dist/types/components/Details/Card/DetailsCardContent.d.ts.map +1 -0
- package/dist/types/components/Details/Card/DetailsCardInner.d.ts +7 -0
- package/dist/types/components/Details/Card/DetailsCardInner.d.ts.map +1 -0
- package/dist/types/components/Details/Card/Navigation/BottomNavigation.d.ts +11 -0
- package/dist/types/components/Details/Card/Navigation/BottomNavigation.d.ts.map +1 -0
- package/dist/types/components/Details/Card/Navigation/NavigationTabs.d.ts +10 -0
- package/dist/types/components/Details/Card/Navigation/NavigationTabs.d.ts.map +1 -0
- package/dist/types/components/Details/Card/Navigation/index.d.ts +3 -0
- package/dist/types/components/Details/Card/Navigation/index.d.ts.map +1 -0
- package/dist/types/components/Details/Card/index.d.ts +2 -0
- package/dist/types/components/Details/Card/index.d.ts.map +1 -0
- package/dist/types/components/Details/Details.d.ts +11 -0
- package/dist/types/components/Details/Details.d.ts.map +1 -0
- package/dist/types/components/Details/ValidationDetails.d.ts +8 -0
- package/dist/types/components/Details/ValidationDetails.d.ts.map +1 -0
- package/dist/types/components/Details/index.d.ts +5 -0
- package/dist/types/components/Details/index.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/BWActions.d.ts +14 -0
- package/dist/types/components/_shared/Actions/BWActions.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/Verification.d.ts +9 -0
- package/dist/types/components/_shared/Actions/Verification.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/_shared/ActionMenuItemProps.d.ts +7 -0
- package/dist/types/components/_shared/Actions/_shared/ActionMenuItemProps.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/_shared/MenuItemDialog.d.ts +7 -0
- package/dist/types/components/_shared/Actions/_shared/MenuItemDialog.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/_shared/index.d.ts +3 -0
- package/dist/types/components/_shared/Actions/_shared/index.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/index.d.ts +5 -0
- package/dist/types/components/_shared/Actions/index.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/json/MenuItem.d.ts +6 -0
- package/dist/types/components/_shared/Actions/json/MenuItem.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/json/index.d.ts +2 -0
- package/dist/types/components/_shared/Actions/json/index.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/previous-hash/DialogContent.d.ts +8 -0
- package/dist/types/components/_shared/Actions/previous-hash/DialogContent.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/previous-hash/MenuItem.d.ts +6 -0
- package/dist/types/components/_shared/Actions/previous-hash/MenuItem.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/previous-hash/QuickTipButton.d.ts +8 -0
- package/dist/types/components/_shared/Actions/previous-hash/QuickTipButton.d.ts.map +1 -0
- package/dist/types/components/_shared/Actions/previous-hash/index.d.ts +4 -0
- package/dist/types/components/_shared/Actions/previous-hash/index.d.ts.map +1 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/Adornment/BackPaperAdornment.d.ts +6 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/Adornment/BackPaperAdornment.d.ts.map +1 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/Adornment/PaperAdornment.d.ts +6 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/Adornment/PaperAdornment.d.ts.map +1 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/Adornment/PaperAdornmentIconButton.d.ts +6 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/Adornment/PaperAdornmentIconButton.d.ts.map +1 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/Adornment/index.d.ts +4 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/Adornment/index.d.ts.map +1 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/HashHeadingPaper.d.ts +10 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/HashHeadingPaper.d.ts.map +1 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/index.d.ts +2 -0
- package/dist/types/components/_shared/Heading/HashHeadingPaper/index.d.ts.map +1 -0
- package/dist/types/components/_shared/Heading/Heading.d.ts +4 -0
- package/dist/types/components/_shared/Heading/Heading.d.ts.map +1 -0
- package/dist/types/components/_shared/Heading/HeadingPaper/HeadingPaper.d.ts +9 -0
- package/dist/types/components/_shared/Heading/HeadingPaper/HeadingPaper.d.ts.map +1 -0
- package/dist/types/components/_shared/Heading/HeadingPaper/index.d.ts +2 -0
- package/dist/types/components/_shared/Heading/HeadingPaper/index.d.ts.map +1 -0
- package/dist/types/components/_shared/Heading/HeadingProps.d.ts +14 -0
- package/dist/types/components/_shared/Heading/HeadingProps.d.ts.map +1 -0
- package/dist/types/components/_shared/Heading/index.d.ts +5 -0
- package/dist/types/components/_shared/Heading/index.d.ts.map +1 -0
- package/dist/types/components/_shared/Payloads/PayloadsPropertyGroup.d.ts +10 -0
- package/dist/types/components/_shared/Payloads/PayloadsPropertyGroup.d.ts.map +1 -0
- package/dist/types/components/_shared/Payloads/PayloadsTable.d.ts +10 -0
- package/dist/types/components/_shared/Payloads/PayloadsTable.d.ts.map +1 -0
- package/dist/types/components/_shared/Payloads/index.d.ts +3 -0
- package/dist/types/components/_shared/Payloads/index.d.ts.map +1 -0
- package/dist/types/components/_shared/Payloads/payloads-table/TableBody.d.ts +11 -0
- package/dist/types/components/_shared/Payloads/payloads-table/TableBody.d.ts.map +1 -0
- package/dist/types/components/_shared/Payloads/payloads-table/TableBodyFiltered.d.ts +8 -0
- package/dist/types/components/_shared/Payloads/payloads-table/TableBodyFiltered.d.ts.map +1 -0
- package/dist/types/components/_shared/Payloads/payloads-table/TableHead.d.ts +4 -0
- package/dist/types/components/_shared/Payloads/payloads-table/TableHead.d.ts.map +1 -0
- package/dist/types/components/_shared/Payloads/payloads-table/index.d.ts +4 -0
- package/dist/types/components/_shared/Payloads/payloads-table/index.d.ts.map +1 -0
- package/dist/types/components/_shared/Signatures/SignatureDetails.d.ts +8 -0
- package/dist/types/components/_shared/Signatures/SignatureDetails.d.ts.map +1 -0
- package/dist/types/components/_shared/Signatures/SignatureTable.d.ts +8 -0
- package/dist/types/components/_shared/Signatures/SignatureTable.d.ts.map +1 -0
- package/dist/types/components/_shared/Signatures/SignatureTableRow.d.ts +14 -0
- package/dist/types/components/_shared/Signatures/SignatureTableRow.d.ts.map +1 -0
- package/dist/types/components/_shared/Signatures/index.d.ts +3 -0
- package/dist/types/components/_shared/Signatures/index.d.ts.map +1 -0
- package/dist/types/components/_shared/index.d.ts +5 -0
- package/dist/types/components/_shared/index.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +4 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +92 -0
- package/src/Plugin.ts +20 -0
- package/src/components/Card/Card.stories.tsx +22 -0
- package/src/components/Card/Card.tsx +24 -0
- package/src/components/Card/CardContent/AddressAvatarGroup.tsx +28 -0
- package/src/components/Card/CardContent/CardContent.tsx +36 -0
- package/src/components/Card/CardContent/SchemaAvatarGroup.tsx +45 -0
- package/src/components/Card/CardContent/index.ts +2 -0
- package/src/components/Card/CardContent/layout/CardColumnTitle.tsx +11 -0
- package/src/components/Card/CardContent/layout/CardColumnsFlex.tsx +8 -0
- package/src/components/Card/CardContent/layout/CardContentFlex.tsx +19 -0
- package/src/components/Card/CardContent/layout/index.ts +3 -0
- package/src/components/Card/CardHeader/CardHeader.tsx +97 -0
- package/src/components/Card/CardHeader/index.ts +1 -0
- package/src/components/Card/index.ts +3 -0
- package/src/components/Details/BoundWitnessLinksDetails.tsx +39 -0
- package/src/components/Details/Box/DetailsBox.stories.tsx +65 -0
- package/src/components/Details/Box/DetailsBox.tsx +70 -0
- package/src/components/Details/Box/index.ts +1 -0
- package/src/components/Details/Card/DetailsCard.stories.tsx +37 -0
- package/src/components/Details/Card/DetailsCard.tsx +18 -0
- package/src/components/Details/Card/DetailsCardContent.tsx +63 -0
- package/src/components/Details/Card/DetailsCardInner.tsx +55 -0
- package/src/components/Details/Card/Navigation/BottomNavigation.stories.tsx +24 -0
- package/src/components/Details/Card/Navigation/BottomNavigation.tsx +50 -0
- package/src/components/Details/Card/Navigation/NavigationTabs.stories.tsx +26 -0
- package/src/components/Details/Card/Navigation/NavigationTabs.tsx +52 -0
- package/src/components/Details/Card/Navigation/index.ts +2 -0
- package/src/components/Details/Card/index.ts +1 -0
- package/src/components/Details/Details.stories.tsx +77 -0
- package/src/components/Details/Details.tsx +34 -0
- package/src/components/Details/ValidationDetails.tsx +44 -0
- package/src/components/Details/index.ts +4 -0
- package/src/components/_shared/Actions/BWActions.tsx +53 -0
- package/src/components/_shared/Actions/Verification.tsx +43 -0
- package/src/components/_shared/Actions/_shared/ActionMenuItemProps.ts +7 -0
- package/src/components/_shared/Actions/_shared/MenuItemDialog.tsx +27 -0
- package/src/components/_shared/Actions/_shared/index.ts +2 -0
- package/src/components/_shared/Actions/index.ts +4 -0
- package/src/components/_shared/Actions/json/MenuItem.tsx +41 -0
- package/src/components/_shared/Actions/json/index.ts +1 -0
- package/src/components/_shared/Actions/previous-hash/DialogContent.tsx +43 -0
- package/src/components/_shared/Actions/previous-hash/MenuItem.tsx +35 -0
- package/src/components/_shared/Actions/previous-hash/QuickTipButton.tsx +31 -0
- package/src/components/_shared/Actions/previous-hash/index.ts +3 -0
- package/src/components/_shared/Heading/HashHeadingPaper/Adornment/BackPaperAdornment.tsx +13 -0
- package/src/components/_shared/Heading/HashHeadingPaper/Adornment/PaperAdornment.tsx +14 -0
- package/src/components/_shared/Heading/HashHeadingPaper/Adornment/PaperAdornmentIconButton.tsx +14 -0
- package/src/components/_shared/Heading/HashHeadingPaper/Adornment/index.ts +3 -0
- package/src/components/_shared/Heading/HashHeadingPaper/HashHeadingPaper.stories.tsx +33 -0
- package/src/components/_shared/Heading/HashHeadingPaper/HashHeadingPaper.tsx +43 -0
- package/src/components/_shared/Heading/HashHeadingPaper/index.ts +1 -0
- package/src/components/_shared/Heading/Heading.tsx +49 -0
- package/src/components/_shared/Heading/HeadingPaper/HeadingPaper.tsx +52 -0
- package/src/components/_shared/Heading/HeadingPaper/index.ts +1 -0
- package/src/components/_shared/Heading/HeadingProps.tsx +15 -0
- package/src/components/_shared/Heading/index.ts +4 -0
- package/src/components/_shared/Payloads/PayloadsPropertyGroup.tsx +25 -0
- package/src/components/_shared/Payloads/PayloadsTable.tsx +51 -0
- package/src/components/_shared/Payloads/index.ts +2 -0
- package/src/components/_shared/Payloads/payloads-table/TableBody.tsx +67 -0
- package/src/components/_shared/Payloads/payloads-table/TableBodyFiltered.tsx +51 -0
- package/src/components/_shared/Payloads/payloads-table/TableHead.tsx +27 -0
- package/src/components/_shared/Payloads/payloads-table/index.ts +3 -0
- package/src/components/_shared/Signatures/SignatureDetails.tsx +21 -0
- package/src/components/_shared/Signatures/SignatureTable.stories.tsx +29 -0
- package/src/components/_shared/Signatures/SignatureTable.tsx +93 -0
- package/src/components/_shared/Signatures/SignatureTableRow.tsx +88 -0
- package/src/components/_shared/Signatures/index.ts +2 -0
- package/src/components/_shared/index.ts +4 -0
- package/src/components/index.ts +3 -0
- package/src/index.ts +2 -0
- package/typedoc.json +5 -0
- package/xy.config.ts +10 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Collapse } from '@mui/material'
|
|
2
|
+
import { FlexGrowCol, FlexRow } from '@xylabs/react-flexbox'
|
|
3
|
+
import { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
4
|
+
import { CardContentEx, CardContentExProps } from '@xyo-network/react-card'
|
|
5
|
+
import { useTableHeight } from '@xyo-network/react-table'
|
|
6
|
+
import React, {
|
|
7
|
+
Dispatch, forwardRef, SetStateAction, useState,
|
|
8
|
+
} from 'react'
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
BoundWitnessPayloadsTable, BoundWitnessPayloadsTableForBWs, BoundWitnessSignatureTable,
|
|
12
|
+
} from '../../_shared/index.ts'
|
|
13
|
+
import { BoundWitnessBottomNavigation, BWNavigationTabs } from './Navigation/index.ts'
|
|
14
|
+
|
|
15
|
+
export interface DetailsCardContentProps extends CardContentExProps {
|
|
16
|
+
boundwitness?: BoundWitness
|
|
17
|
+
collapsed?: boolean
|
|
18
|
+
setCollapsed?: Dispatch<SetStateAction<boolean>>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const DetailsCardContent = forwardRef<HTMLDivElement, DetailsCardContentProps>(({
|
|
22
|
+
collapsed, boundwitness, setCollapsed, ...props
|
|
23
|
+
}, ref) => {
|
|
24
|
+
const { height } = useTableHeight()
|
|
25
|
+
const [activeTab, setActiveTab] = useState(0)
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<CardContentEx removePadding>
|
|
29
|
+
<FlexGrowCol alignItems="stretch" height={height !== undefined && collapsed ? height : 'auto'} justifyContent="start" ref={ref}>
|
|
30
|
+
<Collapse in={collapsed}>
|
|
31
|
+
<FlexRow alignItems="stretch" height={height !== undefined && collapsed ? height : 'auto'} {...props}>
|
|
32
|
+
<BWNavigationTabs value={activeTab} setValue={setActiveTab} boundWitness={boundwitness} />
|
|
33
|
+
<FlexGrowCol
|
|
34
|
+
justifyContent="start"
|
|
35
|
+
overflow="scroll"
|
|
36
|
+
sx={{ borderLeft: '1px solid', borderLeftColor: 'divider' }}
|
|
37
|
+
>
|
|
38
|
+
{activeTab === 0
|
|
39
|
+
? <BoundWitnessPayloadsTable boundwitness={boundwitness} variant="scrollable" />
|
|
40
|
+
: null}
|
|
41
|
+
{activeTab === 1
|
|
42
|
+
? <BoundWitnessPayloadsTableForBWs boundwitness={boundwitness} variant="scrollable" />
|
|
43
|
+
: null}
|
|
44
|
+
{activeTab === 2
|
|
45
|
+
? <BoundWitnessSignatureTable block={boundwitness} variant="scrollable" />
|
|
46
|
+
: null}
|
|
47
|
+
</FlexGrowCol>
|
|
48
|
+
</FlexRow>
|
|
49
|
+
</Collapse>
|
|
50
|
+
</FlexGrowCol>
|
|
51
|
+
<Collapse in={!collapsed} unmountOnExit>
|
|
52
|
+
<BoundWitnessBottomNavigation
|
|
53
|
+
onClick={() => setCollapsed?.(true)}
|
|
54
|
+
activeTab={activeTab}
|
|
55
|
+
setActiveTab={setActiveTab}
|
|
56
|
+
boundWitness={boundwitness}
|
|
57
|
+
/>
|
|
58
|
+
</Collapse>
|
|
59
|
+
</CardContentEx>
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
DetailsCardContent.displayName = 'DetailsCardContent'
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ExpandLessRounded as ExpandLessRoundedIcon, ExpandMoreRounded as ExpandMoreRoundedIcon } from '@mui/icons-material'
|
|
2
|
+
import {
|
|
3
|
+
Card, CardProps,
|
|
4
|
+
Divider, IconButton,
|
|
5
|
+
} from '@mui/material'
|
|
6
|
+
import { useResetState } from '@xylabs/react-hooks'
|
|
7
|
+
import { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
8
|
+
import { PayloadDetailsRenderProps } from '@xyo-network/react-payload-plugin'
|
|
9
|
+
import React, { forwardRef } from 'react'
|
|
10
|
+
|
|
11
|
+
import { BoundWitnessCardHeader } from '../../Card/index.ts'
|
|
12
|
+
import { DetailsCardContent } from './DetailsCardContent.tsx'
|
|
13
|
+
|
|
14
|
+
const BoundWitnessDetailsCardInner = forwardRef<HTMLDivElement, PayloadDetailsRenderProps & CardProps>(
|
|
15
|
+
|
|
16
|
+
({
|
|
17
|
+
payload, active, ...props
|
|
18
|
+
}, ref) => {
|
|
19
|
+
const boundwitness = payload as BoundWitness
|
|
20
|
+
const [collapsed, setCollapsed] = useResetState<boolean>(!active)
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Card ref={ref} {...props}>
|
|
24
|
+
<BoundWitnessCardHeader
|
|
25
|
+
payload={payload}
|
|
26
|
+
active={active}
|
|
27
|
+
activeBgColor={false}
|
|
28
|
+
hideJSONButton={false}
|
|
29
|
+
hideValidation={false}
|
|
30
|
+
hidePreviousHash={false}
|
|
31
|
+
additionalActions={(
|
|
32
|
+
<>
|
|
33
|
+
<Divider
|
|
34
|
+
flexItem
|
|
35
|
+
orientation="vertical"
|
|
36
|
+
sx={{ ml: 2, mr: 1 }}
|
|
37
|
+
/>
|
|
38
|
+
<IconButton onClick={() => setCollapsed(!collapsed)}>
|
|
39
|
+
{collapsed
|
|
40
|
+
? <ExpandMoreRoundedIcon />
|
|
41
|
+
: <ExpandLessRoundedIcon />}
|
|
42
|
+
</IconButton>
|
|
43
|
+
</>
|
|
44
|
+
)}
|
|
45
|
+
sx={{ columnGap: 2 }}
|
|
46
|
+
/>
|
|
47
|
+
<DetailsCardContent boundwitness={boundwitness} collapsed={collapsed} setCollapsed={setCollapsed} ref={ref} />
|
|
48
|
+
</Card>
|
|
49
|
+
)
|
|
50
|
+
},
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
BoundWitnessDetailsCardInner.displayName = 'BoundWitnessDetailsCardInner'
|
|
54
|
+
|
|
55
|
+
export { BoundWitnessDetailsCardInner }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/react'
|
|
2
|
+
import { FlexGrowRow } from '@xylabs/react-flexbox'
|
|
3
|
+
import { sampleBlock } from '@xyo-network/react-storybook'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
|
|
6
|
+
import { BoundWitnessBottomNavigation } from './BottomNavigation.tsx'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
component: BoundWitnessBottomNavigation,
|
|
10
|
+
title: 'plugin/boundwitness/BottomNavigation',
|
|
11
|
+
} as Meta
|
|
12
|
+
|
|
13
|
+
const Template: StoryFn<typeof BoundWitnessBottomNavigation> = (props) => {
|
|
14
|
+
return (
|
|
15
|
+
<FlexGrowRow height="calc(100vh - 20px)">
|
|
16
|
+
<BoundWitnessBottomNavigation {...props} />
|
|
17
|
+
</FlexGrowRow>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const Default = Template.bind({})
|
|
22
|
+
Default.args = { boundWitness: sampleBlock }
|
|
23
|
+
|
|
24
|
+
export { Default }
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BottomNavigation, BottomNavigationAction, BottomNavigationProps,
|
|
3
|
+
styled,
|
|
4
|
+
} from '@mui/material'
|
|
5
|
+
import { BoundWitness, BoundWitnessSchema } from '@xyo-network/boundwitness-model'
|
|
6
|
+
import React, {
|
|
7
|
+
Dispatch, forwardRef, SetStateAction,
|
|
8
|
+
} from 'react'
|
|
9
|
+
// eslint-disable-next-line import-x/no-internal-modules
|
|
10
|
+
import { FaSignature } from 'react-icons/fa'
|
|
11
|
+
// eslint-disable-next-line import-x/no-internal-modules
|
|
12
|
+
import { VscSymbolMethod, VscSymbolNamespace } from 'react-icons/vsc'
|
|
13
|
+
|
|
14
|
+
export interface BoundWitnessBottomNavigationProps extends BottomNavigationProps {
|
|
15
|
+
activeTab?: number
|
|
16
|
+
boundWitness?: BoundWitness
|
|
17
|
+
setActiveTab?: Dispatch<SetStateAction<number>>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const BoundWitnessBottomNavigation = forwardRef<HTMLDivElement, BoundWitnessBottomNavigationProps>(
|
|
21
|
+
({
|
|
22
|
+
activeTab = 0, setActiveTab, boundWitness, ...props
|
|
23
|
+
}, ref) => {
|
|
24
|
+
const payloadCount = boundWitness?.payload_schemas.filter(schema => schema !== BoundWitnessSchema).length ?? 0
|
|
25
|
+
const boundWitnessCount = boundWitness?.payload_schemas.filter(schema => schema === BoundWitnessSchema).length ?? 0
|
|
26
|
+
const signers = boundWitness?.addresses.length ?? 0
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<StyledBottomNavigation
|
|
30
|
+
showLabels
|
|
31
|
+
value={activeTab}
|
|
32
|
+
|
|
33
|
+
onChange={(_event, newValue) => {
|
|
34
|
+
setActiveTab?.(newValue)
|
|
35
|
+
}}
|
|
36
|
+
ref={ref}
|
|
37
|
+
{...props}
|
|
38
|
+
>
|
|
39
|
+
<BottomNavigationAction label={`Payloads - ${payloadCount}`} icon={<VscSymbolNamespace />} />
|
|
40
|
+
<BottomNavigationAction label={`Bound Witnesses - ${boundWitnessCount}`} icon={<VscSymbolMethod />} />
|
|
41
|
+
<BottomNavigationAction label={`Signatures - ${signers}`} icon={<FaSignature />} />
|
|
42
|
+
</StyledBottomNavigation>
|
|
43
|
+
)
|
|
44
|
+
},
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
BoundWitnessBottomNavigation.displayName = 'BoundWitnessBottomNavigation'
|
|
48
|
+
export { BoundWitnessBottomNavigation }
|
|
49
|
+
|
|
50
|
+
const StyledBottomNavigation = styled(BottomNavigation, { name: 'StyledBottomNavigation' })(() => ({ background: 'inherit' }))
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/react'
|
|
2
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
+
import React, { useState } from 'react'
|
|
4
|
+
|
|
5
|
+
import { BWNavigationTabs } from './NavigationTabs.tsx'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
component: BWNavigationTabs,
|
|
9
|
+
parameters: { actions: { argTypesRegex: '(?!^onChange)^on[A-Z].*' } },
|
|
10
|
+
title: 'plugin/boundwitness/BWNavigationTabs',
|
|
11
|
+
} as Meta
|
|
12
|
+
|
|
13
|
+
const Template: StoryFn<typeof BWNavigationTabs> = (props) => {
|
|
14
|
+
const [value, setValue] = useState(0)
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<FlexCol alignItems="start">
|
|
18
|
+
<BWNavigationTabs value={value} setValue={setValue} {...props} />
|
|
19
|
+
</FlexCol>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const Default = Template.bind({})
|
|
24
|
+
Default.args = {}
|
|
25
|
+
|
|
26
|
+
export { Default }
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Paper, Tab, TabProps, Tabs, TabsProps,
|
|
3
|
+
useTheme,
|
|
4
|
+
} from '@mui/material'
|
|
5
|
+
import { BoundWitness, BoundWitnessSchema } from '@xyo-network/boundwitness-model'
|
|
6
|
+
import React, {
|
|
7
|
+
Dispatch, SetStateAction, SyntheticEvent,
|
|
8
|
+
} from 'react'
|
|
9
|
+
// eslint-disable-next-line import-x/no-internal-modules
|
|
10
|
+
import { FaSignature } from 'react-icons/fa'
|
|
11
|
+
// eslint-disable-next-line import-x/no-internal-modules
|
|
12
|
+
import { VscSymbolMethod, VscSymbolNamespace } from 'react-icons/vsc'
|
|
13
|
+
|
|
14
|
+
export interface BWNavigationTabs extends TabsProps {
|
|
15
|
+
boundWitness?: BoundWitness
|
|
16
|
+
setValue?: Dispatch<SetStateAction<number>>
|
|
17
|
+
value?: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const BWNavigationTabs: React.FC<BWNavigationTabs> = ({
|
|
21
|
+
setValue, value, boundWitness, ...props
|
|
22
|
+
}) => {
|
|
23
|
+
const payloadCount = boundWitness?.payload_schemas.filter(schema => schema !== BoundWitnessSchema).length ?? 0
|
|
24
|
+
const boundWitnessCount = boundWitness?.payload_schemas.filter(schema => schema === BoundWitnessSchema).length ?? 0
|
|
25
|
+
const signers = boundWitness?.addresses.length ?? 0
|
|
26
|
+
const theme = useTheme()
|
|
27
|
+
|
|
28
|
+
const handleChange = (_event: SyntheticEvent, newValue: number) => {
|
|
29
|
+
setValue?.(newValue)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const tabProps: TabProps = {
|
|
33
|
+
iconPosition: 'start',
|
|
34
|
+
sx: {
|
|
35
|
+
boxShadow: 'none', fontSize: theme.spacing(1.75), justifyContent: 'start', lineHeight: 3, minHeight: 0, overflow: 'hidden',
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Tabs orientation="vertical" value={value} onChange={handleChange} aria-label="BW Vertical tabs" {...props}>
|
|
41
|
+
<Tab component={Paper} elevation={value === 0 ? 3 : 0} {...tabProps} label={`Payloads - ${payloadCount}`} icon={<VscSymbolNamespace />} />
|
|
42
|
+
<Tab
|
|
43
|
+
component={Paper}
|
|
44
|
+
elevation={value === 1 ? 3 : 0}
|
|
45
|
+
{...tabProps}
|
|
46
|
+
label={`Bound Witnesses - ${boundWitnessCount}`}
|
|
47
|
+
icon={<VscSymbolMethod />}
|
|
48
|
+
/>
|
|
49
|
+
<Tab component={Paper} elevation={value === 2 ? 3 : 0} {...tabProps} label={`Signatures - ${signers}`} icon={<FaSignature />} />
|
|
50
|
+
</Tabs>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DetailsCard.tsx'
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/react'
|
|
2
|
+
import { Hash } from '@xylabs/hex'
|
|
3
|
+
import { Payload } from '@xyo-network/payload-model'
|
|
4
|
+
import { useEvent } from '@xyo-network/react-event'
|
|
5
|
+
import { sampleBlock } from '@xyo-network/react-storybook'
|
|
6
|
+
import React, { useRef } from 'react'
|
|
7
|
+
import {
|
|
8
|
+
BrowserRouter, Route, Routes,
|
|
9
|
+
} from 'react-router-dom'
|
|
10
|
+
|
|
11
|
+
import { BoundWitnessLinksDetails } from './BoundWitnessLinksDetails.tsx'
|
|
12
|
+
import { BoundWitnessDetails } from './Details.tsx'
|
|
13
|
+
|
|
14
|
+
const StorybookEntry = {
|
|
15
|
+
argTypes: {},
|
|
16
|
+
component: BoundWitnessDetails,
|
|
17
|
+
parameters: { docs: { page: null } },
|
|
18
|
+
title: 'plugin/boundwitness/Details',
|
|
19
|
+
} as Meta<typeof BoundWitnessDetails>
|
|
20
|
+
|
|
21
|
+
const Template: StoryFn<typeof BoundWitnessDetails> = (args) => {
|
|
22
|
+
const sharedRef = useRef<HTMLDivElement>(null)
|
|
23
|
+
useEvent<HTMLDivElement>((noun, verb, data) => console.log(`[${noun}|${verb}|${data}]`), sharedRef)
|
|
24
|
+
useEvent<HTMLDivElement>(() => console.log('2nd Listener'), sharedRef)
|
|
25
|
+
useEvent<HTMLDivElement>(() => console.log('3rd Listener'), sharedRef)
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<BrowserRouter>
|
|
29
|
+
<Routes>
|
|
30
|
+
<Route path="temp" element={<h1>Successfully navigated to archivePath</h1>} />
|
|
31
|
+
<Route path="*" element={<BoundWitnessDetails ref={sharedRef} {...args} />} />
|
|
32
|
+
</Routes>
|
|
33
|
+
</BrowserRouter>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const Default = Template.bind({})
|
|
38
|
+
Default.args = {}
|
|
39
|
+
|
|
40
|
+
const WithNoData = Template.bind({})
|
|
41
|
+
WithNoData.args = {
|
|
42
|
+
payload: {
|
|
43
|
+
_signatures: [],
|
|
44
|
+
addresses: [],
|
|
45
|
+
payload_hashes: [],
|
|
46
|
+
payload_schemas: [],
|
|
47
|
+
previous_hashes: [],
|
|
48
|
+
schema: 'network.xyo.boundwitness',
|
|
49
|
+
} as Payload,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const WithData = Template.bind({})
|
|
53
|
+
WithData.args = { payload: sampleBlock }
|
|
54
|
+
|
|
55
|
+
const WithArchiveLink = Template.bind({})
|
|
56
|
+
WithArchiveLink.args = { payload: sampleBlock }
|
|
57
|
+
|
|
58
|
+
const WithPreviousHash = Template.bind({})
|
|
59
|
+
const payload = { ...sampleBlock, previous_hashes: ['ebeb156c9aa0db6e5bf9fe3bfcab5e7f2765235587667adc34c1e8966f899349'] as Hash[] }
|
|
60
|
+
WithPreviousHash.args = {
|
|
61
|
+
children: (
|
|
62
|
+
<>
|
|
63
|
+
<h2>For Testing events only</h2>
|
|
64
|
+
<BoundWitnessLinksDetails value={payload} />
|
|
65
|
+
</>
|
|
66
|
+
),
|
|
67
|
+
payload,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const WithArchiveLinkPaper = Template.bind({})
|
|
71
|
+
WithArchiveLinkPaper.args = { paper: true, payload: sampleBlock }
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
Default, WithArchiveLink, WithArchiveLinkPaper, WithData, WithNoData, WithPreviousHash,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default StorybookEntry
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FlexBoxProps, FlexCol } from '@xylabs/react-flexbox'
|
|
2
|
+
import { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
3
|
+
import { Payload } from '@xyo-network/payload-model'
|
|
4
|
+
import { PayloadDataDetails, PayloadJsonDetails } from '@xyo-network/react-payload-details'
|
|
5
|
+
import React, { forwardRef } from 'react'
|
|
6
|
+
|
|
7
|
+
import { BoundWitnessPayloads, BoundWitnessSignatureDetails } from '../_shared/index.ts'
|
|
8
|
+
import { BoundWitnessValidationDetails } from './ValidationDetails.tsx'
|
|
9
|
+
|
|
10
|
+
export interface BoundWitnessDetailsProps extends FlexBoxProps {
|
|
11
|
+
payload?: Payload
|
|
12
|
+
/** @field Fetched Payloads for the Bound Witness */
|
|
13
|
+
payloads?: Payload[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const BoundWitnessDetails = forwardRef<unknown, BoundWitnessDetailsProps>(({
|
|
17
|
+
paper, payload, children, ...props
|
|
18
|
+
}, ref) => {
|
|
19
|
+
const boundwitness = payload as BoundWitness | undefined
|
|
20
|
+
return (
|
|
21
|
+
<FlexCol justifyContent="flex-start" alignItems="stretch" gap={1} ref={ref} {...props}>
|
|
22
|
+
<PayloadDataDetails paper={paper} payload={boundwitness} size="large" badge />
|
|
23
|
+
<BoundWitnessPayloads paper={paper} payload={boundwitness} />
|
|
24
|
+
<BoundWitnessSignatureDetails paper={paper} block={boundwitness} />
|
|
25
|
+
<BoundWitnessValidationDetails paper={paper} value={boundwitness} />
|
|
26
|
+
<PayloadJsonDetails paper={paper} payload={boundwitness} />
|
|
27
|
+
{children}
|
|
28
|
+
</FlexCol>
|
|
29
|
+
)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
BoundWitnessDetails.displayName = 'BoundWitnessDetails [XYO]'
|
|
33
|
+
|
|
34
|
+
export { BoundWitnessDetails }
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Typography } from '@mui/material'
|
|
2
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
+
import { usePromise } from '@xylabs/react-promise'
|
|
4
|
+
import { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
5
|
+
import { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'
|
|
6
|
+
import {
|
|
7
|
+
Property, PropertyGroup, PropertyGroupProps,
|
|
8
|
+
} from '@xyo-network/react-property'
|
|
9
|
+
import React from 'react'
|
|
10
|
+
|
|
11
|
+
export type BoundWitnessValidationDetailsProps = PropertyGroupProps & {
|
|
12
|
+
value?: BoundWitness
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const BoundWitnessValidationDetails: React.FC<BoundWitnessValidationDetailsProps> = ({ value, ...props }) => {
|
|
16
|
+
const [errors = []] = usePromise(async () => await (value ? new BoundWitnessValidator(value).validate() : undefined), [value])
|
|
17
|
+
|
|
18
|
+
let elevation = 2
|
|
19
|
+
if (props.paper) {
|
|
20
|
+
elevation += props.elevation ?? 0
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<PropertyGroup titleProps={{ elevation }} title="Validation" tip="The results from validating the block" {...props}>
|
|
25
|
+
<Property
|
|
26
|
+
titleProps={{ elevation }}
|
|
27
|
+
flexGrow={1}
|
|
28
|
+
title="Valid"
|
|
29
|
+
value={errors.length === 0 ? 'True' : 'False'}
|
|
30
|
+
tip={
|
|
31
|
+
errors.length > 0
|
|
32
|
+
? (
|
|
33
|
+
<FlexCol flexWrap="wrap">
|
|
34
|
+
{errors.map((error, index) => {
|
|
35
|
+
return <Typography key={index}>{error.toString()}</Typography>
|
|
36
|
+
})}
|
|
37
|
+
</FlexCol>
|
|
38
|
+
)
|
|
39
|
+
: <Typography>No Errors</Typography>
|
|
40
|
+
}
|
|
41
|
+
/>
|
|
42
|
+
</PropertyGroup>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { DataObject as DataObjectIcon } from '@mui/icons-material'
|
|
2
|
+
import { ellipsize } from '@xylabs/eth-address'
|
|
3
|
+
import { FlexBoxProps, FlexRow } from '@xylabs/react-flexbox'
|
|
4
|
+
import { QuickTipButton } from '@xylabs/react-quick-tip-button'
|
|
5
|
+
import { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
6
|
+
import { usePayloadHash } from '@xyo-network/react-shared'
|
|
7
|
+
import React, { ReactNode } from 'react'
|
|
8
|
+
|
|
9
|
+
import { BWPreviousHashQuickTipButton } from './previous-hash/index.ts'
|
|
10
|
+
import { BWVerification } from './Verification.tsx'
|
|
11
|
+
|
|
12
|
+
export interface BWActionsProps extends FlexBoxProps {
|
|
13
|
+
additionalActions?: ReactNode
|
|
14
|
+
boundwitness?: BoundWitness
|
|
15
|
+
hideJSONButton?: boolean
|
|
16
|
+
hidePreviousHash?: boolean
|
|
17
|
+
hideValidation?: boolean
|
|
18
|
+
priorActions?: ReactNode
|
|
19
|
+
validationIconColors?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const BWActions: React.FC<BWActionsProps> = ({
|
|
23
|
+
additionalActions,
|
|
24
|
+
boundwitness,
|
|
25
|
+
hideJSONButton,
|
|
26
|
+
hideValidation,
|
|
27
|
+
hidePreviousHash,
|
|
28
|
+
priorActions,
|
|
29
|
+
validationIconColors,
|
|
30
|
+
...props
|
|
31
|
+
}) => {
|
|
32
|
+
const hash = usePayloadHash(boundwitness)
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<FlexRow {...props}>
|
|
36
|
+
{priorActions}
|
|
37
|
+
{hidePreviousHash || boundwitness?.previous_hashes.length === 0 ? null : <BWPreviousHashQuickTipButton boundwitness={boundwitness} />}
|
|
38
|
+
{hideValidation ? null : <BWVerification iconColors={validationIconColors} boundwitness={boundwitness} />}
|
|
39
|
+
{hideJSONButton
|
|
40
|
+
? null
|
|
41
|
+
: (
|
|
42
|
+
<QuickTipButton
|
|
43
|
+
Icon={DataObjectIcon}
|
|
44
|
+
title={`JSON for ${ellipsize(hash ?? '', 8)}`}
|
|
45
|
+
dialogProps={{ fullWidth: true, maxWidth: 'md' }}
|
|
46
|
+
>
|
|
47
|
+
<pre style={{ wordBreak: 'break-all' }}>{boundwitness ? JSON.stringify(boundwitness, null, 2) : null}</pre>
|
|
48
|
+
</QuickTipButton>
|
|
49
|
+
)}
|
|
50
|
+
{additionalActions}
|
|
51
|
+
</FlexRow>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CancelRounded as CancelRoundedIcon, CheckCircleOutlineRounded as CheckCircleOutlineRoundedIcon } from '@mui/icons-material'
|
|
2
|
+
import { SvgIconProps, Typography } from '@mui/material'
|
|
3
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
4
|
+
import { usePromise } from '@xylabs/react-promise'
|
|
5
|
+
import { QuickTipButton, QuickTipButtonProps } from '@xylabs/react-quick-tip-button'
|
|
6
|
+
import { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
7
|
+
import { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'
|
|
8
|
+
import React, { forwardRef } from 'react'
|
|
9
|
+
|
|
10
|
+
const InvalidIcon = forwardRef<SVGSVGElement, SvgIconProps>((props, ref) => <CancelRoundedIcon color="error" ref={ref} {...props} />)
|
|
11
|
+
InvalidIcon.displayName = 'InvalidIcon'
|
|
12
|
+
|
|
13
|
+
export interface BWVerification extends QuickTipButtonProps {
|
|
14
|
+
boundwitness?: BoundWitness
|
|
15
|
+
iconColors?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const BWVerification: React.FC<BWVerification> = ({ boundwitness, iconColors }) => {
|
|
19
|
+
const [errors = []] = usePromise(async () => await (boundwitness ? new BoundWitnessValidator(boundwitness) : undefined)?.validate(), [boundwitness])
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<QuickTipButton
|
|
23
|
+
Icon={errors.length > 0
|
|
24
|
+
? forwardRef((props, ref) => {
|
|
25
|
+
return <InvalidIcon color={iconColors ? 'error' : undefined} ref={ref} {...props} />
|
|
26
|
+
})
|
|
27
|
+
: forwardRef((props, ref) => {
|
|
28
|
+
return <CheckCircleOutlineRoundedIcon color={iconColors ? 'success' : undefined} ref={ref} {...props} />
|
|
29
|
+
})}
|
|
30
|
+
hoverText={errors.length > 0 ? 'Invalid Bound Witness' : 'Valid'}
|
|
31
|
+
>
|
|
32
|
+
{errors.length > 0
|
|
33
|
+
? (
|
|
34
|
+
<FlexCol flexWrap="wrap" alignItems="start">
|
|
35
|
+
{errors.map((error, index) => {
|
|
36
|
+
return <Typography key={index}>{error.toString()}</Typography>
|
|
37
|
+
})}
|
|
38
|
+
</FlexCol>
|
|
39
|
+
)
|
|
40
|
+
: <Typography>No Errors</Typography>}
|
|
41
|
+
</QuickTipButton>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button, Dialog, DialogActions, DialogContent, DialogProps, DialogTitle,
|
|
3
|
+
} from '@mui/material'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
|
|
6
|
+
export interface MenuItemDialogProps extends DialogProps {
|
|
7
|
+
dialogTitle?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const MenuItemDialog: React.FC<MenuItemDialogProps> = ({
|
|
11
|
+
children, dialogTitle, open, onClose, ...props
|
|
12
|
+
}) => {
|
|
13
|
+
return (
|
|
14
|
+
<Dialog open={open} onClose={onClose} sx={{ '& .MuiPaper-root': { minWidth: '75%' } }} {...props}>
|
|
15
|
+
<DialogTitle>{dialogTitle}</DialogTitle>
|
|
16
|
+
<DialogContent>
|
|
17
|
+
{children}
|
|
18
|
+
</DialogContent>
|
|
19
|
+
<DialogActions sx={{
|
|
20
|
+
display: 'flex', flexDirection: 'row', justifyContent: 'end',
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<Button variant="contained" onClick={e => onClose?.(e, 'escapeKeyDown')}>Close</Button>
|
|
24
|
+
</DialogActions>
|
|
25
|
+
</Dialog>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Code } from '@mui/icons-material'
|
|
2
|
+
import { ListItemIcon, MenuItem } from '@mui/material'
|
|
3
|
+
import { ellipsize } from '@xylabs/eth-address'
|
|
4
|
+
import { JsonViewerEx } from '@xyo-network/react-payload-raw-info'
|
|
5
|
+
import { usePayloadHash } from '@xyo-network/react-shared'
|
|
6
|
+
import React, { MouseEventHandler, useState } from 'react'
|
|
7
|
+
|
|
8
|
+
import { ActionMenuItemProps, MenuItemDialog } from '../_shared/index.ts'
|
|
9
|
+
|
|
10
|
+
export interface BWJsonMenuItemProps extends ActionMenuItemProps {}
|
|
11
|
+
|
|
12
|
+
export const BWJsonMenuItem: React.FC<BWJsonMenuItemProps> = ({
|
|
13
|
+
boundwitness, onClick, onDialogClose, ...props
|
|
14
|
+
}) => {
|
|
15
|
+
const hash = usePayloadHash(boundwitness)
|
|
16
|
+
|
|
17
|
+
const [open, setOpen] = useState(false)
|
|
18
|
+
const onClose = () => {
|
|
19
|
+
onDialogClose?.()
|
|
20
|
+
setOpen(false)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const handleMenuClick: MouseEventHandler<HTMLLIElement> = (e) => {
|
|
24
|
+
onClick?.(e)
|
|
25
|
+
setOpen(true)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const title = hash ? `JSON for ${ellipsize(hash, 5)}` : 'JSON'
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<MenuItem onClick={handleMenuClick} {...props}>
|
|
33
|
+
<ListItemIcon><Code /></ListItemIcon>
|
|
34
|
+
JSON
|
|
35
|
+
</MenuItem>
|
|
36
|
+
<MenuItemDialog open={open} onClose={onClose} dialogTitle={title}>
|
|
37
|
+
<JsonViewerEx value={boundwitness} />
|
|
38
|
+
</MenuItemDialog>
|
|
39
|
+
</>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MenuItem.tsx'
|