@xyo-network/react-embed 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/components/EmbedPlugin.d.ts +5 -0
- package/dist/browser/components/EmbedPlugin.d.ts.map +1 -0
- package/dist/browser/components/EmbedResolver.d.ts +4 -0
- package/dist/browser/components/EmbedResolver.d.ts.map +1 -0
- package/dist/browser/components/controls/EmbedFormControl.d.ts +10 -0
- package/dist/browser/components/controls/EmbedFormControl.d.ts.map +1 -0
- package/dist/browser/components/controls/ListModeSelect.d.ts +6 -0
- package/dist/browser/components/controls/ListModeSelect.d.ts.map +1 -0
- package/dist/browser/components/controls/RenderSelect.d.ts +4 -0
- package/dist/browser/components/controls/RenderSelect.d.ts.map +1 -0
- package/dist/browser/components/controls/index.d.ts +4 -0
- package/dist/browser/components/controls/index.d.ts.map +1 -0
- package/dist/browser/components/embed-card/EmbedCardResolver.d.ts +5 -0
- package/dist/browser/components/embed-card/EmbedCardResolver.d.ts.map +1 -0
- package/dist/browser/components/embed-card/EmbedPluginCard.d.ts +10 -0
- package/dist/browser/components/embed-card/EmbedPluginCard.d.ts.map +1 -0
- package/dist/browser/components/embed-card/card/BusyCard.d.ts +11 -0
- package/dist/browser/components/embed-card/card/BusyCard.d.ts.map +1 -0
- package/dist/browser/components/embed-card/card/EmbedCardHeader.d.ts +4 -0
- package/dist/browser/components/embed-card/card/EmbedCardHeader.d.ts.map +1 -0
- package/dist/browser/components/embed-card/card/EmbedPluginCard.d.ts +4 -0
- package/dist/browser/components/embed-card/card/EmbedPluginCard.d.ts.map +1 -0
- package/dist/browser/components/embed-card/card/index.d.ts +4 -0
- package/dist/browser/components/embed-card/card/index.d.ts.map +1 -0
- package/dist/browser/components/embed-card/error-handling/EmbedCardApiErrorRenderer.d.ts +10 -0
- package/dist/browser/components/embed-card/error-handling/EmbedCardApiErrorRenderer.d.ts.map +1 -0
- package/dist/browser/components/embed-card/error-handling/EmbedErrorCard.d.ts +14 -0
- package/dist/browser/components/embed-card/error-handling/EmbedErrorCard.d.ts.map +1 -0
- package/dist/browser/components/embed-card/error-handling/index.d.ts +3 -0
- package/dist/browser/components/embed-card/error-handling/index.d.ts.map +1 -0
- package/dist/browser/components/embed-card/index.d.ts +3 -0
- package/dist/browser/components/embed-card/index.d.ts.map +1 -0
- package/dist/browser/components/embed-card/menu/EmbedMenu.d.ts +4 -0
- package/dist/browser/components/embed-card/menu/EmbedMenu.d.ts.map +1 -0
- package/dist/browser/components/embed-card/menu/JsonMenuItem.d.ts +4 -0
- package/dist/browser/components/embed-card/menu/JsonMenuItem.d.ts.map +1 -0
- package/dist/browser/components/embed-card/menu/index.d.ts +2 -0
- package/dist/browser/components/embed-card/menu/index.d.ts.map +1 -0
- package/dist/browser/components/index.d.ts +3 -0
- package/dist/browser/components/index.d.ts.map +1 -0
- package/dist/browser/components/stories/storyPayload.d.ts +126 -0
- package/dist/browser/components/stories/storyPayload.d.ts.map +1 -0
- package/dist/browser/components/stories/storyShared.d.ts +4 -0
- package/dist/browser/components/stories/storyShared.d.ts.map +1 -0
- package/dist/browser/components/stories/xyoEmbedStoryBase.d.ts +3 -0
- package/dist/browser/components/stories/xyoEmbedStoryBase.d.ts.map +1 -0
- package/dist/browser/components/validation-alerts/ValidatePayload.d.ts +5 -0
- package/dist/browser/components/validation-alerts/ValidatePayload.d.ts.map +1 -0
- package/dist/browser/components/validation-alerts/ValidatePlugins.d.ts +5 -0
- package/dist/browser/components/validation-alerts/ValidatePlugins.d.ts.map +1 -0
- package/dist/browser/components/validation-alerts/index.d.ts +3 -0
- package/dist/browser/components/validation-alerts/index.d.ts.map +1 -0
- package/dist/browser/contexts/EmbedPluginContext/Context.d.ts +3 -0
- package/dist/browser/contexts/EmbedPluginContext/Context.d.ts.map +1 -0
- package/dist/browser/contexts/EmbedPluginContext/Provider.d.ts +6 -0
- package/dist/browser/contexts/EmbedPluginContext/Provider.d.ts.map +1 -0
- package/dist/browser/contexts/EmbedPluginContext/State.d.ts +28 -0
- package/dist/browser/contexts/EmbedPluginContext/State.d.ts.map +1 -0
- package/dist/browser/contexts/EmbedPluginContext/index.d.ts +5 -0
- package/dist/browser/contexts/EmbedPluginContext/index.d.ts.map +1 -0
- package/dist/browser/contexts/EmbedPluginContext/use.d.ts +2 -0
- package/dist/browser/contexts/EmbedPluginContext/use.d.ts.map +1 -0
- package/dist/browser/contexts/RefreshPayloadContext/Context.d.ts +3 -0
- package/dist/browser/contexts/RefreshPayloadContext/Context.d.ts.map +1 -0
- package/dist/browser/contexts/RefreshPayloadContext/Provider.d.ts +8 -0
- package/dist/browser/contexts/RefreshPayloadContext/Provider.d.ts.map +1 -0
- package/dist/browser/contexts/RefreshPayloadContext/State.d.ts +8 -0
- package/dist/browser/contexts/RefreshPayloadContext/State.d.ts.map +1 -0
- package/dist/browser/contexts/RefreshPayloadContext/index.d.ts +4 -0
- package/dist/browser/contexts/RefreshPayloadContext/index.d.ts.map +1 -0
- package/dist/browser/contexts/RefreshPayloadContext/use.d.ts +2 -0
- package/dist/browser/contexts/RefreshPayloadContext/use.d.ts.map +1 -0
- package/dist/browser/contexts/ResolvePayloadContext/Context.d.ts +3 -0
- package/dist/browser/contexts/ResolvePayloadContext/Context.d.ts.map +1 -0
- package/dist/browser/contexts/ResolvePayloadContext/Provider.d.ts +6 -0
- package/dist/browser/contexts/ResolvePayloadContext/Provider.d.ts.map +1 -0
- package/dist/browser/contexts/ResolvePayloadContext/State.d.ts +13 -0
- package/dist/browser/contexts/ResolvePayloadContext/State.d.ts.map +1 -0
- package/dist/browser/contexts/ResolvePayloadContext/index.d.ts +5 -0
- package/dist/browser/contexts/ResolvePayloadContext/index.d.ts.map +1 -0
- package/dist/browser/contexts/ResolvePayloadContext/use.d.ts +2 -0
- package/dist/browser/contexts/ResolvePayloadContext/use.d.ts.map +1 -0
- package/dist/browser/contexts/ValidatePayloadContext/Context.d.ts +3 -0
- package/dist/browser/contexts/ValidatePayloadContext/Context.d.ts.map +1 -0
- package/dist/browser/contexts/ValidatePayloadContext/Provider.d.ts +7 -0
- package/dist/browser/contexts/ValidatePayloadContext/Provider.d.ts.map +1 -0
- package/dist/browser/contexts/ValidatePayloadContext/State.d.ts +7 -0
- package/dist/browser/contexts/ValidatePayloadContext/State.d.ts.map +1 -0
- package/dist/browser/contexts/ValidatePayloadContext/index.d.ts +4 -0
- package/dist/browser/contexts/ValidatePayloadContext/index.d.ts.map +1 -0
- package/dist/browser/contexts/ValidatePayloadContext/use.d.ts +2 -0
- package/dist/browser/contexts/ValidatePayloadContext/use.d.ts.map +1 -0
- package/dist/browser/contexts/index.d.ts +5 -0
- package/dist/browser/contexts/index.d.ts.map +1 -0
- package/dist/browser/index.d.ts +4 -112
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/types/EmbedPluginProps.d.ts +9 -0
- package/dist/browser/types/EmbedPluginProps.d.ts.map +1 -0
- package/dist/browser/types/index.d.ts +2 -0
- package/dist/browser/types/index.d.ts.map +1 -0
- package/package.json +52 -49
- package/src/components/EmbedPlugin.tsx +6 -2
- package/src/components/EmbedResolver.tsx +3 -1
- package/src/components/controls/EmbedFormControl.tsx +3 -1
- package/src/components/controls/RenderSelect.tsx +3 -1
- package/src/components/embed-card/EmbedCardResolver.tsx +8 -2
- package/src/components/embed-card/EmbedPluginCard.tsx +5 -1
- package/src/components/embed-card/card/BusyCard.tsx +2 -1
- package/src/components/embed-card/card/EmbedCardHeader.tsx +9 -3
- package/src/components/embed-card/card/EmbedPluginCard.tsx +3 -1
- package/src/components/embed-card/error-handling/EmbedCardApiErrorRenderer.tsx +3 -1
- package/src/components/embed-card/error-handling/EmbedErrorCard.tsx +12 -4
- package/src/components/embed-card/menu/JsonMenuItem.tsx +3 -1
- package/src/components/stories/XyoEmbedPlugin.states.stories.tsx +3 -1
- package/src/components/stories/storyPayload.ts +60 -12
- package/src/components/stories/storyShared.tsx +1 -11
- package/src/components/stories/xyoEmbedStoryBase.ts +9 -0
- package/src/components/validation-alerts/ValidatePayload.tsx +3 -1
- package/src/contexts/RefreshPayloadContext/Provider.tsx +7 -2
- package/src/contexts/ResolvePayloadContext/Provider.tsx +10 -3
- package/src/contexts/ValidatePayloadContext/Provider.stories.tsx +9 -3
- package/src/contexts/ValidatePayloadContext/Provider.tsx +4 -1
- package/xy.config.ts +1 -3
@@ -3,7 +3,9 @@ import type { WithChildren } from '@xylabs/react-shared'
|
|
3
3
|
import { ErrorBoundary, ListModeProvider } from '@xyo-network/react-shared'
|
4
4
|
import React from 'react'
|
5
5
|
|
6
|
-
import {
|
6
|
+
import {
|
7
|
+
EmbedPluginProvider, RefreshPayloadProvider, ResolvePayloadProvider, ValidatePayloadProvider,
|
8
|
+
} from '../contexts/index.ts'
|
7
9
|
import type { EmbedPluginProps } from '../types/index.ts'
|
8
10
|
import { EmbedResolver } from './EmbedResolver.tsx'
|
9
11
|
import { ValidatePayloadAlert, ValidatePluginsAlert } from './validation-alerts/index.ts'
|
@@ -40,7 +42,9 @@ export const EmbedPluginInner: React.FC<WithChildren<EmbedPluginProps>> = ({
|
|
40
42
|
|
41
43
|
interface WithResolversProps extends Pick<EmbedPluginProps, 'onRefresh' | 'huriPayload'>, FlexBoxProps {}
|
42
44
|
|
43
|
-
const WithResolvers: React.FC<WithChildren<WithResolversProps>> = ({
|
45
|
+
const WithResolvers: React.FC<WithChildren<WithResolversProps>> = ({
|
46
|
+
children, onRefresh, huriPayload,
|
47
|
+
}) => {
|
44
48
|
return (
|
45
49
|
<RefreshPayloadProvider onRefresh={onRefresh}>
|
46
50
|
<ResolvePayloadProvider huriPayload={huriPayload}>
|
@@ -5,7 +5,9 @@ import React from 'react'
|
|
5
5
|
import { useResolvePayload } from '../contexts/index.ts'
|
6
6
|
|
7
7
|
export const EmbedResolver: React.FC<WithChildren> = ({ children }) => {
|
8
|
-
const {
|
8
|
+
const {
|
9
|
+
payload, notFound, huriError,
|
10
|
+
} = useResolvePayload()
|
9
11
|
|
10
12
|
return (
|
11
13
|
<LoadResult searchResult={payload} notFound={!!notFound} error={!!huriError}>
|
@@ -8,7 +8,9 @@ interface EmbedFormControlProps extends FormControlProps {
|
|
8
8
|
formLabel?: string
|
9
9
|
}
|
10
10
|
|
11
|
-
export const EmbedFormControl: React.FC<WithChildren<EmbedFormControlProps>> = ({
|
11
|
+
export const EmbedFormControl: React.FC<WithChildren<EmbedFormControlProps>> = ({
|
12
|
+
formId, formLabel, children, ...props
|
13
|
+
}) => {
|
12
14
|
return (
|
13
15
|
<FormControl {...props}>
|
14
16
|
<InputLabel id={formId}>{formLabel}</InputLabel>
|
@@ -10,7 +10,9 @@ const renderSelectId = 'render-select-id'
|
|
10
10
|
const renderSelectLabel = 'Renderer'
|
11
11
|
|
12
12
|
export const EmbedRenderSelect: React.FC<SelectExProps<string>> = (props) => {
|
13
|
-
const {
|
13
|
+
const {
|
14
|
+
activePlugin, setActivePlugin, plugins,
|
15
|
+
} = useEmbedPluginState()
|
14
16
|
return (
|
15
17
|
<EmbedFormControl formId={renderSelectId} formLabel={renderSelectLabel}>
|
16
18
|
<SelectEx size="small" value={activePlugin?.name} {...props}>
|
@@ -9,7 +9,9 @@ import { useRefreshPayload, useResolvePayload } from '../../contexts/index.ts'
|
|
9
9
|
import { EmbedCardApiErrorRenderer } from './error-handling/index.ts'
|
10
10
|
|
11
11
|
export const EmbedCardResolverFlexBox: React.FC<WithChildren<FlexBoxProps>> = ({ children, ...props }) => {
|
12
|
-
const {
|
12
|
+
const {
|
13
|
+
payload, notFound, huriError,
|
14
|
+
} = useResolvePayload()
|
13
15
|
const { refreshPayload } = useRefreshPayload()
|
14
16
|
const theme = useTheme()
|
15
17
|
|
@@ -21,7 +23,11 @@ export const EmbedCardResolverFlexBox: React.FC<WithChildren<FlexBoxProps>> = ({
|
|
21
23
|
alignItems="stretch"
|
22
24
|
justifyContent="start"
|
23
25
|
busy={Boolean(!refreshPayload && payload)}
|
24
|
-
busyCircularProps={{
|
26
|
+
busyCircularProps={{
|
27
|
+
style: {
|
28
|
+
alignItems: 'start', paddingTop: theme.spacing(2), zIndex: 2,
|
29
|
+
},
|
30
|
+
}}
|
25
31
|
{...props}
|
26
32
|
>
|
27
33
|
{children}
|
@@ -54,7 +54,11 @@ export const EmbedPluginCardInner: React.FC<BusyCardProps> = (props) => {
|
|
54
54
|
elevation={3}
|
55
55
|
variant="elevation"
|
56
56
|
busy={Boolean(!refreshPayload && payload)}
|
57
|
-
busyVariantProps={{
|
57
|
+
busyVariantProps={{
|
58
|
+
style: {
|
59
|
+
alignItems: 'start', paddingTop: theme.spacing(2), zIndex: 2,
|
60
|
+
},
|
61
|
+
}}
|
58
62
|
sx={{ position: 'relative' }}
|
59
63
|
{...props}
|
60
64
|
/>
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { Refresh as RefreshIcon } from '@mui/icons-material'
|
2
2
|
import type { CardHeaderProps, Theme } from '@mui/material'
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
Avatar, CardHeader, Chip,
|
5
|
+
} from '@mui/material'
|
4
6
|
import { FlexRow } from '@xylabs/react-flexbox'
|
5
7
|
import React from 'react'
|
6
8
|
|
@@ -9,8 +11,12 @@ import { EmbedMenu } from '../menu/index.ts'
|
|
9
11
|
|
10
12
|
export const EmbedCardHeader: React.FC<CardHeaderProps> = () => {
|
11
13
|
const { refreshHuri, huri } = useResolvePayload()
|
12
|
-
const {
|
13
|
-
|
14
|
+
const {
|
15
|
+
activePlugin, timestampLabel, hideElementsConfig,
|
16
|
+
} = useEmbedPluginState()
|
17
|
+
const {
|
18
|
+
hideAvatar, hideTitle, hideRefreshButton, hideTimestamp, hideCardActions,
|
19
|
+
} = hideElementsConfig ?? {}
|
14
20
|
// this is temporary so that we can add the ability to get a timestamp via diviner later
|
15
21
|
const timestamp = Date.now()
|
16
22
|
return (
|
@@ -11,7 +11,9 @@ import { EmbedCardHeader } from './EmbedCardHeader.tsx'
|
|
11
11
|
|
12
12
|
export const EmbedPluginCard: React.FC<BusyCardProps> = ({ ...props }) => {
|
13
13
|
const { payload } = useResolvePayload()
|
14
|
-
const {
|
14
|
+
const {
|
15
|
+
activePlugin: ActivePlugin, plugins, hideElementsConfig,
|
16
|
+
} = useEmbedPluginState()
|
15
17
|
const { listMode } = useListMode()
|
16
18
|
const supportsListMode = ActivePlugin?.components?.box?.listModes?.length ?? 0 > 1
|
17
19
|
|
@@ -10,7 +10,9 @@ interface EmbedCardApiErrorRendererProps extends CardProps {
|
|
10
10
|
xyoError?: ModuleError
|
11
11
|
}
|
12
12
|
|
13
|
-
export const EmbedCardApiErrorRenderer: React.FC<WithChildren<EmbedCardApiErrorRendererProps>> = ({
|
13
|
+
export const EmbedCardApiErrorRenderer: React.FC<WithChildren<EmbedCardApiErrorRendererProps>> = ({
|
14
|
+
xyoError, children, ...props
|
15
|
+
}) => {
|
14
16
|
return (
|
15
17
|
<ErrorRender error={xyoError} noReAuth noErrorDisplay customError={<CustomApiErrorCard xyoError={xyoError} {...props} />}>
|
16
18
|
{children}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import type { AlertProps, CardProps } from '@mui/material'
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
Alert, AlertTitle, Card, CardContent, Typography,
|
4
|
+
} from '@mui/material'
|
3
5
|
import type { WithChildren } from '@xylabs/react-shared'
|
4
6
|
import React from 'react'
|
5
7
|
|
@@ -13,8 +15,12 @@ interface EmbedErrorCardBaseProps {
|
|
13
15
|
interface EmbedErrorCardProps extends EmbedErrorCardBaseProps, CardProps {}
|
14
16
|
|
15
17
|
export const EmbedErrorCard: React.FC<WithChildren<EmbedErrorCardProps>> = (props) => {
|
16
|
-
const {
|
17
|
-
|
18
|
+
const {
|
19
|
+
alertProps, error, scope, hideErrorDetails = true, children, ...cardProps
|
20
|
+
} = props
|
21
|
+
const errorProps = {
|
22
|
+
alertProps, error, hideErrorDetails, scope,
|
23
|
+
}
|
18
24
|
return (
|
19
25
|
<Card {...cardProps}>
|
20
26
|
<CardContent>{children ?? <DefaultErrorAlert {...errorProps} />}</CardContent>
|
@@ -22,7 +28,9 @@ export const EmbedErrorCard: React.FC<WithChildren<EmbedErrorCardProps>> = (prop
|
|
22
28
|
)
|
23
29
|
}
|
24
30
|
|
25
|
-
const DefaultErrorAlert: React.FC<EmbedErrorCardBaseProps> = ({
|
31
|
+
const DefaultErrorAlert: React.FC<EmbedErrorCardBaseProps> = ({
|
32
|
+
alertProps, scope, hideErrorDetails, error,
|
33
|
+
}) => {
|
26
34
|
return (
|
27
35
|
<Alert severity="error" {...alertProps}>
|
28
36
|
<AlertTitle>Whoops! Something went wrong</AlertTitle>
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { OpenInNew as OpenInNewIcon } from '@mui/icons-material'
|
2
2
|
import type { MenuItemProps } from '@mui/material'
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
ListItemIcon, ListItemText, MenuItem,
|
5
|
+
} from '@mui/material'
|
4
6
|
import React from 'react'
|
5
7
|
|
6
8
|
import { useResolvePayload } from '../../../contexts/index.ts'
|
@@ -87,4 +87,6 @@ WithOnRefresh.args = {
|
|
87
87
|
plugins: [CryptoAssetRenderPlugin],
|
88
88
|
}
|
89
89
|
|
90
|
-
export {
|
90
|
+
export {
|
91
|
+
ApiError, Default, HiddenElements, ThrownError, WithOnRefresh, WithPassedPayload, WithSetBusyExternally,
|
92
|
+
}
|
@@ -1,20 +1,68 @@
|
|
1
1
|
export const payloadData = {
|
2
2
|
assets: {
|
3
|
-
ada: {
|
4
|
-
|
5
|
-
|
3
|
+
ada: {
|
4
|
+
value: {
|
5
|
+
btc: '0.00002192', eth: '0.00031141', eur: '0.491867', usd: '0.502045',
|
6
|
+
},
|
7
|
+
},
|
8
|
+
btc: {
|
9
|
+
value: {
|
10
|
+
btc: '1', eth: '14.213346', eur: '22450', usd: '22914',
|
11
|
+
},
|
12
|
+
},
|
13
|
+
busd: {
|
14
|
+
value: {
|
15
|
+
btc: '0.00004369', eth: '0.00062074', eur: '0.980451', usd: '1.001',
|
16
|
+
},
|
17
|
+
},
|
6
18
|
dai: { value: { usdc: '1.00004', xyo: '114.394' } },
|
7
|
-
doge: {
|
8
|
-
|
9
|
-
|
19
|
+
doge: {
|
20
|
+
value: {
|
21
|
+
btc: '0.00000293', eth: '0.00004157', eur: '0.065655', usd: '0.067013',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
dot: {
|
25
|
+
value: {
|
26
|
+
btc: '0.00035508', eth: '0.00504454', eur: '7.97', usd: '8.13',
|
27
|
+
},
|
28
|
+
},
|
29
|
+
eth: {
|
30
|
+
value: {
|
31
|
+
btc: '0.0703878', eth: '1', eur: '1579.47', usd: '1612.16',
|
32
|
+
},
|
33
|
+
},
|
10
34
|
frax: { value: { usdc: '0.999738' } },
|
11
35
|
link: { value: { xyo: '837.731' } },
|
12
|
-
sol: {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
36
|
+
sol: {
|
37
|
+
value: {
|
38
|
+
btc: '0.00169369', eth: '0.02406215', eur: '38.01', usd: '38.79',
|
39
|
+
},
|
40
|
+
},
|
41
|
+
usdc: {
|
42
|
+
value: {
|
43
|
+
btc: '0.0000436965', dai: '0.999963', eth: '0.0006204464999999999', eur: '0.979419', frax: '1.00026', usd: '0.999732',
|
44
|
+
},
|
45
|
+
},
|
46
|
+
usdt: {
|
47
|
+
value: {
|
48
|
+
btc: '0.00004367', eth: '0.0006204', eur: '0.979881', usd: '1.001', usdc: '1.00022', xyo: '113.28',
|
49
|
+
},
|
50
|
+
},
|
51
|
+
wbtc: {
|
52
|
+
value: {
|
53
|
+
btc: '0.99903669', eth: '14.2015745', eur: '22418', usd: '22882', usdc: '22860.8', xyo: '2617950',
|
54
|
+
},
|
55
|
+
},
|
56
|
+
weth: {
|
57
|
+
value: {
|
58
|
+
btc: '0.0703735', usdc: '1610.82', xyo: '186652',
|
59
|
+
},
|
60
|
+
},
|
61
|
+
xyo: {
|
62
|
+
value: {
|
63
|
+
btc: '3.79226e-7', dai: '0.00874169', eth: '0.000005353785', eur: '0.00844792', link: '0.0011937', usd: '0.00872519',
|
64
|
+
},
|
65
|
+
},
|
18
66
|
},
|
19
67
|
schema: 'network.xyo.crypto.asset',
|
20
68
|
timestamp: 1_659_625_815_232,
|
@@ -1,19 +1,9 @@
|
|
1
|
-
import type {
|
1
|
+
import type { StoryFn } from '@storybook/react'
|
2
2
|
import React from 'react'
|
3
3
|
import { BrowserRouter } from 'react-router-dom'
|
4
4
|
|
5
5
|
import { ApiEmbedPluginCard } from '../embed-card/index.ts'
|
6
6
|
|
7
|
-
export const xyoEmbedStoryBase: Meta = {
|
8
|
-
argTypes: {},
|
9
|
-
component: ApiEmbedPluginCard,
|
10
|
-
parameters: {
|
11
|
-
docs: {
|
12
|
-
page: null,
|
13
|
-
},
|
14
|
-
},
|
15
|
-
}
|
16
|
-
|
17
7
|
export const Template: StoryFn<typeof ApiEmbedPluginCard> = (args) => {
|
18
8
|
return (
|
19
9
|
<BrowserRouter>
|
@@ -6,7 +6,9 @@ import React from 'react'
|
|
6
6
|
import { useValidatePayload } from '../../contexts/index.ts'
|
7
7
|
|
8
8
|
export const ValidatePayloadAlert: React.FC<WithChildren<AlertProps>> = ({ children, ...props }) => {
|
9
|
-
const {
|
9
|
+
const {
|
10
|
+
validPayload, enabled, schema,
|
11
|
+
} = useValidatePayload()
|
10
12
|
|
11
13
|
if (enabled && validPayload === false) {
|
12
14
|
return (
|
@@ -8,12 +8,17 @@ export interface RefreshPayloadProps {
|
|
8
8
|
refreshPayload?: boolean
|
9
9
|
}
|
10
10
|
|
11
|
-
export const RefreshPayloadProvider: React.FC<WithChildren<RefreshPayloadProps>> = ({
|
11
|
+
export const RefreshPayloadProvider: React.FC<WithChildren<RefreshPayloadProps>> = ({
|
12
|
+
children, onRefresh, refreshPayload,
|
13
|
+
}) => {
|
12
14
|
const [localRefreshPayload, setRefreshPayload] = useState(refreshPayload)
|
13
15
|
|
14
16
|
return (
|
15
17
|
// eslint-disable-next-line @eslint-react/no-unstable-context-value
|
16
|
-
<RefreshPayloadContext.Provider value={{
|
18
|
+
<RefreshPayloadContext.Provider value={{
|
19
|
+
onRefresh, provided: true, refreshPayload: localRefreshPayload, setRefreshPayload,
|
20
|
+
}}
|
21
|
+
>
|
17
22
|
{children}
|
18
23
|
</RefreshPayloadContext.Provider>
|
19
24
|
)
|
@@ -15,7 +15,9 @@ export type ResolvePayloadProviderProps = Omit<ResolvePayloadState, 'provided'>
|
|
15
15
|
export const ResolvePayloadProvider: React.FC<WithChildren<ResolvePayloadProviderProps>> = ({ children, huriPayload }) => {
|
16
16
|
const [payload, setPayload] = useState<Payload>()
|
17
17
|
const [huri, setHuri] = useState<string>()
|
18
|
-
const {
|
18
|
+
const {
|
19
|
+
refreshPayload, setRefreshPayload, onRefresh,
|
20
|
+
} = useRefreshPayload()
|
19
21
|
|
20
22
|
useEffect(() => {
|
21
23
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
@@ -45,7 +47,9 @@ export const ResolvePayloadProvider: React.FC<WithChildren<ResolvePayloadProvide
|
|
45
47
|
}
|
46
48
|
} catch (e) {
|
47
49
|
const error = e as Error
|
48
|
-
setHuriError({
|
50
|
+
setHuriError({
|
51
|
+
message: error.message, schema: ModuleErrorSchema, sources: [],
|
52
|
+
})
|
49
53
|
}
|
50
54
|
}
|
51
55
|
},
|
@@ -61,7 +65,10 @@ export const ResolvePayloadProvider: React.FC<WithChildren<ResolvePayloadProvide
|
|
61
65
|
|
62
66
|
return (
|
63
67
|
// eslint-disable-next-line @eslint-react/no-unstable-context-value
|
64
|
-
<ResolvePayloadContext.Provider value={{
|
68
|
+
<ResolvePayloadContext.Provider value={{
|
69
|
+
huri, huriError, notFound, payload, provided: true, refreshHuri, setPayload,
|
70
|
+
}}
|
71
|
+
>
|
65
72
|
{children}
|
66
73
|
</ResolvePayloadContext.Provider>
|
67
74
|
)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import { Typography } from '@mui/material'
|
2
|
-
import type {
|
2
|
+
import type {
|
3
|
+
Decorator, Meta, StoryFn,
|
4
|
+
} from '@storybook/react'
|
3
5
|
import React from 'react'
|
4
6
|
|
5
7
|
import type { EmbedPluginState } from '../EmbedPluginContext/index.ts'
|
@@ -12,7 +14,9 @@ import { ValidatePayloadProvider } from './Provider.tsx'
|
|
12
14
|
import { useValidatePayload } from './use.ts'
|
13
15
|
|
14
16
|
const EmbedDecorator: Decorator<ValidatePayloadProviderPropsEx> = (Story, { args }) => {
|
15
|
-
const {
|
17
|
+
const {
|
18
|
+
xyoEmbedPluginContext, resolvePayloadContext, ...props
|
19
|
+
} = args
|
16
20
|
console.log(resolvePayloadContext)
|
17
21
|
return (
|
18
22
|
<RefreshPayloadProvider>
|
@@ -72,6 +76,8 @@ ValidationFailed.args = {
|
|
72
76
|
xyoEmbedPluginContext: stubProviderDefaultValue,
|
73
77
|
}
|
74
78
|
|
75
|
-
export {
|
79
|
+
export {
|
80
|
+
Default, ValidationFailed, ValidationSucceeded,
|
81
|
+
}
|
76
82
|
|
77
83
|
export default StorybookEntry
|
@@ -37,7 +37,10 @@ export const ValidatePayloadProvider: React.FC<WithChildren<ValidatePayloadProvi
|
|
37
37
|
|
38
38
|
return (
|
39
39
|
// eslint-disable-next-line @eslint-react/no-unstable-context-value
|
40
|
-
<ValidatePayloadContext.Provider value={{
|
40
|
+
<ValidatePayloadContext.Provider value={{
|
41
|
+
enabled, provided: true, schema: payload?.schema, validPayload: valid,
|
42
|
+
}}
|
43
|
+
>
|
41
44
|
{enabled
|
42
45
|
? <>{initialized ? children : <Chip label="Validating Payload..." />}</>
|
43
46
|
: children}
|