@xyo-network/react-embed 7.5.7 → 7.5.11
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/dist/browser/components/embed-card/card/EmbedCardHeader.d.ts.map +1 -1
- package/dist/browser/contexts/EmbedPluginContext/Provider.d.ts.map +1 -1
- package/dist/browser/contexts/PluginPropsContext/Provider.d.ts.map +1 -1
- package/dist/browser/contexts/RefreshPayloadContext/Provider.d.ts.map +1 -1
- package/dist/browser/contexts/ResolvePayloadContext/Provider.d.ts.map +1 -1
- package/dist/browser/contexts/ValidatePayloadContext/Provider.d.ts.map +1 -1
- package/dist/browser/index.mjs +453 -391
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +176 -42
- package/src/components/EmbedPlugin.tsx +0 -66
- package/src/components/EmbedResolver.tsx +0 -17
- package/src/components/controls/EmbedFormControl.tsx +0 -20
- package/src/components/controls/ListModeSelect.tsx +0 -43
- package/src/components/controls/RenderSelect.tsx +0 -27
- package/src/components/controls/index.ts +0 -3
- package/src/components/embed-card/EmbedCardResolver.tsx +0 -38
- package/src/components/embed-card/EmbedPluginCard.tsx +0 -71
- package/src/components/embed-card/card/BusyCard.tsx +0 -43
- package/src/components/embed-card/card/EmbedCardHeader.tsx +0 -57
- package/src/components/embed-card/card/EmbedPluginCard.tsx +0 -47
- package/src/components/embed-card/card/index.ts +0 -3
- package/src/components/embed-card/error-handling/EmbedCardApiErrorRenderer.tsx +0 -29
- package/src/components/embed-card/error-handling/EmbedErrorCard.tsx +0 -60
- package/src/components/embed-card/error-handling/index.ts +0 -2
- package/src/components/embed-card/index.ts +0 -2
- package/src/components/embed-card/menu/EmbedMenu.tsx +0 -37
- package/src/components/embed-card/menu/JsonMenuItem.tsx +0 -28
- package/src/components/embed-card/menu/index.ts +0 -1
- package/src/components/index.ts +0 -2
- package/src/components/stories/XyoEmbedPlugin.examples.stories.tsx +0 -28
- package/src/components/stories/XyoEmbedPlugin.states.stories.tsx +0 -93
- package/src/components/stories/storyPayload.ts +0 -71
- package/src/components/stories/storyShared.tsx +0 -19
- package/src/components/stories/xyoEmbedStoryBase.ts +0 -9
- package/src/components/validation-alerts/ValidatePayload.tsx +0 -26
- package/src/components/validation-alerts/ValidatePlugins.tsx +0 -22
- package/src/components/validation-alerts/index.ts +0 -2
- package/src/contexts/EmbedPluginContext/Context.ts +0 -5
- package/src/contexts/EmbedPluginContext/Provider.tsx +0 -36
- package/src/contexts/EmbedPluginContext/State.ts +0 -37
- package/src/contexts/EmbedPluginContext/index.ts +0 -4
- package/src/contexts/EmbedPluginContext/use.ts +0 -5
- package/src/contexts/PluginPropsContext/Provider.tsx +0 -31
- package/src/contexts/PluginPropsContext/context.ts +0 -5
- package/src/contexts/PluginPropsContext/index.ts +0 -4
- package/src/contexts/PluginPropsContext/state.ts +0 -9
- package/src/contexts/PluginPropsContext/use.ts +0 -5
- package/src/contexts/RefreshPayloadContext/Context.ts +0 -5
- package/src/contexts/RefreshPayloadContext/Provider.tsx +0 -24
- package/src/contexts/RefreshPayloadContext/State.ts +0 -8
- package/src/contexts/RefreshPayloadContext/index.ts +0 -3
- package/src/contexts/RefreshPayloadContext/use.ts +0 -5
- package/src/contexts/ResolvePayloadContext/Context.ts +0 -5
- package/src/contexts/ResolvePayloadContext/Provider.tsx +0 -76
- package/src/contexts/ResolvePayloadContext/State.ts +0 -13
- package/src/contexts/ResolvePayloadContext/index.ts +0 -4
- package/src/contexts/ResolvePayloadContext/use.ts +0 -5
- package/src/contexts/ValidatePayloadContext/Context.ts +0 -5
- package/src/contexts/ValidatePayloadContext/Provider.stories.tsx +0 -87
- package/src/contexts/ValidatePayloadContext/Provider.tsx +0 -49
- package/src/contexts/ValidatePayloadContext/State.ts +0 -7
- package/src/contexts/ValidatePayloadContext/index.ts +0 -3
- package/src/contexts/ValidatePayloadContext/use.ts +0 -5
- package/src/contexts/index.ts +0 -5
- package/src/global.d.ts +0 -1
- package/src/index.ts +0 -3
- package/src/types/EmbedPluginProps.ts +0 -11
- package/src/types/index.ts +0 -1
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { MenuItem } from '@mui/material'
|
|
2
|
-
import type { SelectExProps } from '@xylabs/react-select'
|
|
3
|
-
import { SelectEx } from '@xylabs/react-select'
|
|
4
|
-
import type { ListMode } from '@xyo-network/react-shared'
|
|
5
|
-
import { useListMode } from '@xyo-network/react-shared'
|
|
6
|
-
import React from 'react'
|
|
7
|
-
|
|
8
|
-
import { EmbedFormControl } from './EmbedFormControl.tsx'
|
|
9
|
-
|
|
10
|
-
const listModeSelectId = 'listmode-select-id'
|
|
11
|
-
const listModeSelectLabel = 'List Mode'
|
|
12
|
-
|
|
13
|
-
export const ListModeSelect: React.FC<SelectExProps<ListMode>> = (props) => {
|
|
14
|
-
const { listMode, setListMode } = useListMode()
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<SelectEx<ListMode>
|
|
18
|
-
value={(listMode ?? 'default') as ListMode}
|
|
19
|
-
onChange={(event) => {
|
|
20
|
-
setListMode?.(event.target.value as ListMode)
|
|
21
|
-
}}
|
|
22
|
-
{...props}
|
|
23
|
-
>
|
|
24
|
-
<MenuItem key="default" value="default">
|
|
25
|
-
Default
|
|
26
|
-
</MenuItem>
|
|
27
|
-
<MenuItem key="table" value="table">
|
|
28
|
-
Table
|
|
29
|
-
</MenuItem>
|
|
30
|
-
<MenuItem key="grid" value="grid">
|
|
31
|
-
Grid
|
|
32
|
-
</MenuItem>
|
|
33
|
-
</SelectEx>
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const ListModeSelectFormControl: React.FC<SelectExProps<ListMode>> = (props) => {
|
|
38
|
-
return (
|
|
39
|
-
<EmbedFormControl formId={listModeSelectId} formLabel={listModeSelectLabel}>
|
|
40
|
-
<ListModeSelect size="small" label={listModeSelectLabel} labelId={listModeSelectId} {...props} />
|
|
41
|
-
</EmbedFormControl>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { MenuItem } from '@mui/material'
|
|
2
|
-
import type { SelectExProps } from '@xylabs/react-select'
|
|
3
|
-
import { SelectEx } from '@xylabs/react-select'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
import { useEmbedPluginState } from '../../contexts/index.ts'
|
|
7
|
-
import { EmbedFormControl } from './EmbedFormControl.tsx'
|
|
8
|
-
|
|
9
|
-
const renderSelectId = 'render-select-id'
|
|
10
|
-
const renderSelectLabel = 'Renderer'
|
|
11
|
-
|
|
12
|
-
export const EmbedRenderSelect: React.FC<SelectExProps<string>> = (props) => {
|
|
13
|
-
const {
|
|
14
|
-
activePlugin, setActivePlugin, plugins,
|
|
15
|
-
} = useEmbedPluginState()
|
|
16
|
-
return (
|
|
17
|
-
<EmbedFormControl formId={renderSelectId} formLabel={renderSelectLabel}>
|
|
18
|
-
<SelectEx size="small" value={activePlugin?.name} {...props}>
|
|
19
|
-
{plugins?.map(plugin => (
|
|
20
|
-
<MenuItem value={plugin.name} key={plugin.name} onClick={() => setActivePlugin?.(plugin)}>
|
|
21
|
-
{plugin.name}
|
|
22
|
-
</MenuItem>
|
|
23
|
-
))}
|
|
24
|
-
</SelectEx>
|
|
25
|
-
</EmbedFormControl>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useTheme } from '@mui/material'
|
|
2
|
-
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
3
|
-
import { FlexCol } from '@xylabs/react-flexbox'
|
|
4
|
-
import { LoadResult } from '@xyo-network/react-shared'
|
|
5
|
-
import type { PropsWithChildren } from 'react'
|
|
6
|
-
import React from 'react'
|
|
7
|
-
|
|
8
|
-
import { useRefreshPayload, useResolvePayload } from '../../contexts/index.ts'
|
|
9
|
-
import { EmbedCardApiErrorRenderer } from './error-handling/index.ts'
|
|
10
|
-
|
|
11
|
-
export const EmbedCardResolverFlexBox: React.FC<PropsWithChildren<FlexBoxProps>> = ({ children, ...props }) => {
|
|
12
|
-
const {
|
|
13
|
-
payload, notFound, huriError,
|
|
14
|
-
} = useResolvePayload()
|
|
15
|
-
const { refreshPayload } = useRefreshPayload()
|
|
16
|
-
const theme = useTheme()
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<LoadResult searchResult={payload} notFound={!!notFound} error={!!huriError}>
|
|
20
|
-
<EmbedCardApiErrorRenderer xyoError={huriError}>
|
|
21
|
-
<FlexCol
|
|
22
|
-
id="embed-outer-wrap"
|
|
23
|
-
alignItems="stretch"
|
|
24
|
-
justifyContent="start"
|
|
25
|
-
busy={Boolean(!refreshPayload && payload)}
|
|
26
|
-
busyCircularProps={{
|
|
27
|
-
style: {
|
|
28
|
-
alignItems: 'start', paddingTop: theme.spacing(2), zIndex: 2,
|
|
29
|
-
},
|
|
30
|
-
}}
|
|
31
|
-
{...props}
|
|
32
|
-
>
|
|
33
|
-
{children}
|
|
34
|
-
</FlexCol>
|
|
35
|
-
</EmbedCardApiErrorRenderer>
|
|
36
|
-
</LoadResult>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { useTheme } from '@mui/material'
|
|
2
|
-
import type { PropsWithChildren } from 'react'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import { useRefreshPayload, useResolvePayload } from '../../contexts/index.ts'
|
|
6
|
-
import type { EmbedPluginProps } from '../../types/index.ts'
|
|
7
|
-
import { EmbedPluginInner } from '../EmbedPlugin.tsx'
|
|
8
|
-
import type { BusyCardProps } from './card/index.ts'
|
|
9
|
-
import { EmbedPluginCard } from './card/index.ts'
|
|
10
|
-
import { EmbedCardApiErrorRenderer } from './error-handling/index.ts'
|
|
11
|
-
|
|
12
|
-
export interface EmbedPluginCardProps extends PropsWithChildren, EmbedPluginProps, BusyCardProps {}
|
|
13
|
-
|
|
14
|
-
export const ApiEmbedPluginCard: React.FC<EmbedPluginCardProps> = ({ children, ...props }) => {
|
|
15
|
-
const {
|
|
16
|
-
validateSchema,
|
|
17
|
-
plugins = [],
|
|
18
|
-
huriPayload,
|
|
19
|
-
refreshTitle = '',
|
|
20
|
-
timestampLabel = 'Data From',
|
|
21
|
-
hideElementsConfig,
|
|
22
|
-
embedPluginConfig,
|
|
23
|
-
onRefresh,
|
|
24
|
-
...busyCardProps
|
|
25
|
-
} = props
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<EmbedPluginInner
|
|
29
|
-
{...{
|
|
30
|
-
embedPluginConfig,
|
|
31
|
-
hideElementsConfig,
|
|
32
|
-
huriPayload,
|
|
33
|
-
onRefresh,
|
|
34
|
-
plugins,
|
|
35
|
-
refreshTitle,
|
|
36
|
-
timestampLabel,
|
|
37
|
-
validateSchema,
|
|
38
|
-
}}
|
|
39
|
-
>
|
|
40
|
-
<EmbedPluginCardInner {...busyCardProps} />
|
|
41
|
-
{children}
|
|
42
|
-
</EmbedPluginInner>
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const EmbedPluginCardInner: React.FC<BusyCardProps> = (props) => {
|
|
47
|
-
const { payload, huriError } = useResolvePayload()
|
|
48
|
-
const { refreshPayload } = useRefreshPayload()
|
|
49
|
-
const theme = useTheme()
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<EmbedCardApiErrorRenderer xyoError={huriError}>
|
|
53
|
-
<EmbedPluginCard
|
|
54
|
-
elevation={3}
|
|
55
|
-
variant="elevation"
|
|
56
|
-
busy={Boolean(!refreshPayload && payload)}
|
|
57
|
-
busyVariantProps={{
|
|
58
|
-
style: {
|
|
59
|
-
alignItems: 'start', paddingTop: theme.spacing(2), zIndex: 2,
|
|
60
|
-
},
|
|
61
|
-
}}
|
|
62
|
-
sx={{ position: 'relative' }}
|
|
63
|
-
{...props}
|
|
64
|
-
/>
|
|
65
|
-
</EmbedCardApiErrorRenderer>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** @deprecated - use EmbedPluginCard and use CardProps instead of FlexBoxProps */
|
|
70
|
-
|
|
71
|
-
export { EmbedPluginCard as EmbedPlugin } from './card/index.ts'
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { CardProps } from '@mui/material'
|
|
2
|
-
import { Card } from '@mui/material'
|
|
3
|
-
import { useBusyTiming } from '@xylabs/react-flexbox'
|
|
4
|
-
import type {
|
|
5
|
-
BusyCircularProgressProps,
|
|
6
|
-
BusyLinearProgressProps,
|
|
7
|
-
BusyVariant,
|
|
8
|
-
} from '@xylabs/react-shared'
|
|
9
|
-
import {
|
|
10
|
-
BusyCircularProgress,
|
|
11
|
-
BusyLinearProgress,
|
|
12
|
-
} from '@xylabs/react-shared'
|
|
13
|
-
import type { PropsWithChildren } from 'react'
|
|
14
|
-
import React from 'react'
|
|
15
|
-
|
|
16
|
-
export interface BusyCardProps extends CardProps {
|
|
17
|
-
busy?: boolean
|
|
18
|
-
busyMinimum?: number
|
|
19
|
-
busyVariant?: BusyVariant
|
|
20
|
-
busyVariantProps?: BusyCircularProgressProps | BusyLinearProgressProps
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const BusyCard: React.FC<PropsWithChildren<BusyCardProps>> = ({
|
|
24
|
-
busy,
|
|
25
|
-
busyMinimum = 500,
|
|
26
|
-
busyVariant = 'circular',
|
|
27
|
-
busyVariantProps,
|
|
28
|
-
children,
|
|
29
|
-
...props
|
|
30
|
-
}) => {
|
|
31
|
-
const internalBusy = useBusyTiming(busy, busyMinimum)
|
|
32
|
-
return (
|
|
33
|
-
<Card {...props}>
|
|
34
|
-
{children}
|
|
35
|
-
{busyVariant === 'circular' && internalBusy
|
|
36
|
-
? <BusyCircularProgress {...(busyVariantProps as BusyCircularProgressProps)} />
|
|
37
|
-
: null}
|
|
38
|
-
{busyVariant === 'linear' && internalBusy
|
|
39
|
-
? <BusyLinearProgress {...(busyVariantProps as BusyLinearProgressProps)} />
|
|
40
|
-
: null}
|
|
41
|
-
</Card>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Refresh as RefreshIcon } from '@mui/icons-material'
|
|
2
|
-
import type { CardHeaderProps, Theme } from '@mui/material'
|
|
3
|
-
import {
|
|
4
|
-
Avatar, CardHeader, Chip,
|
|
5
|
-
} from '@mui/material'
|
|
6
|
-
import { FlexRow } from '@xylabs/react-flexbox'
|
|
7
|
-
import { isDefined } from '@xylabs/sdk-js'
|
|
8
|
-
import React from 'react'
|
|
9
|
-
|
|
10
|
-
import { useEmbedPluginState, useResolvePayload } from '../../../contexts/index.ts'
|
|
11
|
-
import { EmbedMenu } from '../menu/index.ts'
|
|
12
|
-
|
|
13
|
-
export const EmbedCardHeader: React.FC<CardHeaderProps> = () => {
|
|
14
|
-
const { refreshHuri, huri } = useResolvePayload()
|
|
15
|
-
const {
|
|
16
|
-
activePlugin, timestampLabel, hideElementsConfig,
|
|
17
|
-
} = useEmbedPluginState()
|
|
18
|
-
const {
|
|
19
|
-
hideAvatar, hideTitle, hideRefreshButton, hideTimestamp, hideCardActions,
|
|
20
|
-
} = hideElementsConfig ?? {}
|
|
21
|
-
// this is temporary so that we can add the ability to get a timestamp via diviner later
|
|
22
|
-
const timestamp = Date.now()
|
|
23
|
-
return (
|
|
24
|
-
<CardHeader
|
|
25
|
-
sx={{ flexWrap: 'wrap', rowGap: 1 }}
|
|
26
|
-
avatar={
|
|
27
|
-
hideAvatar
|
|
28
|
-
? <></>
|
|
29
|
-
: (
|
|
30
|
-
<Avatar sx={{ bgcolor: (theme: Theme) => theme.vars.palette.primary.main }} aria-label={activePlugin?.name}>
|
|
31
|
-
{activePlugin?.name?.charAt(0)}
|
|
32
|
-
</Avatar>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
action={(
|
|
36
|
-
<FlexRow flexWrap="wrap" columnGap={0.5}>
|
|
37
|
-
{isDefined(timestamp) && !Number.isNaN(timestamp)
|
|
38
|
-
? hideTimestamp && hideRefreshButton
|
|
39
|
-
? ''
|
|
40
|
-
: (
|
|
41
|
-
<Chip
|
|
42
|
-
avatar={hideRefreshButton ? <></> : <RefreshIcon />}
|
|
43
|
-
clickable={hideRefreshButton ? false : true}
|
|
44
|
-
onClick={refreshHuri}
|
|
45
|
-
label={hideTimestamp ? '' : `${timestampLabel} ${new Date(timestamp).toLocaleString()}`}
|
|
46
|
-
/>
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
: null}
|
|
50
|
-
{/* Huri case is valid as long as the only menu item is JSON */}
|
|
51
|
-
{hideCardActions || huri === undefined ? null : <EmbedMenu />}
|
|
52
|
-
</FlexRow>
|
|
53
|
-
)}
|
|
54
|
-
title={hideTitle ? '' : activePlugin?.name}
|
|
55
|
-
/>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { CardContent } from '@mui/material'
|
|
2
|
-
import { FlexGrowRow } from '@xylabs/react-flexbox'
|
|
3
|
-
import { isTruthy } from '@xylabs/sdk-js'
|
|
4
|
-
import { useListMode } from '@xyo-network/react-shared'
|
|
5
|
-
import React from 'react'
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
useEmbedPluginState, usePluginProps, useResolvePayload,
|
|
9
|
-
} from '../../../contexts/index.ts'
|
|
10
|
-
import { EmbedRenderSelect, ListModeSelectFormControl } from '../../controls/index.ts'
|
|
11
|
-
import type { BusyCardProps } from './BusyCard.tsx'
|
|
12
|
-
import { BusyCard } from './BusyCard.tsx'
|
|
13
|
-
import { EmbedCardHeader } from './EmbedCardHeader.tsx'
|
|
14
|
-
|
|
15
|
-
export const EmbedPluginCard: React.FC<BusyCardProps> = ({ ...props }) => {
|
|
16
|
-
const { payload } = useResolvePayload()
|
|
17
|
-
const {
|
|
18
|
-
activePlugin: ActivePlugin, plugins, hideElementsConfig,
|
|
19
|
-
} = useEmbedPluginState()
|
|
20
|
-
const { listMode } = useListMode()
|
|
21
|
-
const { pluginProps } = usePluginProps()
|
|
22
|
-
const supportsListMode = isTruthy(ActivePlugin?.components?.box?.listModes?.length) ? true : false
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<BusyCard {...props}>
|
|
26
|
-
{hideElementsConfig?.hideCardHeader ? null : <EmbedCardHeader />}
|
|
27
|
-
{/* Only show the row if the children are present */}
|
|
28
|
-
{(plugins && plugins.length > 0) || supportsListMode
|
|
29
|
-
? (
|
|
30
|
-
<FlexGrowRow columnGap={2} rowGap={2} flexWrap="wrap" pb={1}>
|
|
31
|
-
{plugins && plugins.length > 1
|
|
32
|
-
? <EmbedRenderSelect />
|
|
33
|
-
: null}
|
|
34
|
-
{supportsListMode
|
|
35
|
-
? <ListModeSelectFormControl />
|
|
36
|
-
: null}
|
|
37
|
-
</FlexGrowRow>
|
|
38
|
-
)
|
|
39
|
-
: null}
|
|
40
|
-
<CardContent sx={{ height: '100%' }}>
|
|
41
|
-
{ActivePlugin
|
|
42
|
-
? <ActivePlugin.components.box.detailsBox payload={payload} {...pluginProps} {...(supportsListMode && { listMode })} />
|
|
43
|
-
: null}
|
|
44
|
-
</CardContent>
|
|
45
|
-
</BusyCard>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { CardProps } from '@mui/material'
|
|
2
|
-
import { ErrorAlert, ErrorRender } from '@xylabs/react-error'
|
|
3
|
-
import type { ModuleError } from '@xyo-network/payload-model'
|
|
4
|
-
import type { PropsWithChildren } from 'react'
|
|
5
|
-
import React from 'react'
|
|
6
|
-
|
|
7
|
-
import { EmbedErrorCard } from './EmbedErrorCard.tsx'
|
|
8
|
-
|
|
9
|
-
interface EmbedCardApiErrorRendererProps extends CardProps {
|
|
10
|
-
xyoError?: ModuleError
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const EmbedCardApiErrorRenderer: React.FC<PropsWithChildren<EmbedCardApiErrorRendererProps>> = ({
|
|
14
|
-
xyoError, children, ...props
|
|
15
|
-
}) => {
|
|
16
|
-
return (
|
|
17
|
-
<ErrorRender error={xyoError} noReAuth noErrorDisplay customError={<CustomApiErrorCard xyoError={xyoError} {...props} />}>
|
|
18
|
-
{children}
|
|
19
|
-
</ErrorRender>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const CustomApiErrorCard: React.FC<EmbedCardApiErrorRendererProps> = ({ xyoError, ...props }) => {
|
|
24
|
-
return (
|
|
25
|
-
<EmbedErrorCard {...props}>
|
|
26
|
-
<ErrorAlert error={xyoError} />
|
|
27
|
-
</EmbedErrorCard>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { AlertProps, CardProps } from '@mui/material'
|
|
2
|
-
import {
|
|
3
|
-
Alert, AlertTitle, Card, CardContent, Typography,
|
|
4
|
-
} from '@mui/material'
|
|
5
|
-
import { isDefined } from '@xylabs/sdk-js'
|
|
6
|
-
import type { PropsWithChildren } from 'react'
|
|
7
|
-
import React from 'react'
|
|
8
|
-
|
|
9
|
-
interface EmbedErrorCardBaseProps {
|
|
10
|
-
alertProps?: AlertProps
|
|
11
|
-
error?: Error
|
|
12
|
-
hideErrorDetails?: boolean
|
|
13
|
-
scope?: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface EmbedErrorCardProps extends EmbedErrorCardBaseProps, CardProps {}
|
|
17
|
-
|
|
18
|
-
export const EmbedErrorCard: React.FC<PropsWithChildren<EmbedErrorCardProps>> = (props) => {
|
|
19
|
-
const {
|
|
20
|
-
alertProps, error, scope, hideErrorDetails = true, children, ...cardProps
|
|
21
|
-
} = props
|
|
22
|
-
const errorProps = {
|
|
23
|
-
alertProps, error, hideErrorDetails, scope,
|
|
24
|
-
}
|
|
25
|
-
return (
|
|
26
|
-
<Card {...cardProps}>
|
|
27
|
-
<CardContent>{children ?? <DefaultErrorAlert {...errorProps} />}</CardContent>
|
|
28
|
-
</Card>
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const DefaultErrorAlert: React.FC<EmbedErrorCardBaseProps> = ({
|
|
33
|
-
alertProps, scope, hideErrorDetails, error,
|
|
34
|
-
}) => {
|
|
35
|
-
return (
|
|
36
|
-
<Alert severity="error" {...alertProps}>
|
|
37
|
-
<AlertTitle>Whoops! Something went wrong</AlertTitle>
|
|
38
|
-
{isDefined(scope)
|
|
39
|
-
? (
|
|
40
|
-
<Typography variant="caption">
|
|
41
|
-
Scope:
|
|
42
|
-
{scope}
|
|
43
|
-
</Typography>
|
|
44
|
-
)
|
|
45
|
-
: null}
|
|
46
|
-
{!hideErrorDetails && error
|
|
47
|
-
? (
|
|
48
|
-
<>
|
|
49
|
-
<Typography variant="caption">Error: </Typography>
|
|
50
|
-
<Typography variant="caption">{error?.message}</Typography>
|
|
51
|
-
</>
|
|
52
|
-
)
|
|
53
|
-
: (
|
|
54
|
-
<Typography variant="caption" fontSize="small">
|
|
55
|
-
Error Loading Plugin
|
|
56
|
-
</Typography>
|
|
57
|
-
)}
|
|
58
|
-
</Alert>
|
|
59
|
-
)
|
|
60
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { MoreVert as MoreVertIcon } from '@mui/icons-material'
|
|
2
|
-
import type { IconButtonProps } from '@mui/material'
|
|
3
|
-
import { IconButton, Menu } from '@mui/material'
|
|
4
|
-
import React, { useState } from 'react'
|
|
5
|
-
|
|
6
|
-
import { JsonMenuItem } from './JsonMenuItem.tsx'
|
|
7
|
-
|
|
8
|
-
export const EmbedMenu: React.FC<IconButtonProps> = (props) => {
|
|
9
|
-
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null)
|
|
10
|
-
const open = Boolean(anchorEl)
|
|
11
|
-
|
|
12
|
-
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
13
|
-
setAnchorEl(event.currentTarget)
|
|
14
|
-
}
|
|
15
|
-
const handleClose = () => {
|
|
16
|
-
setAnchorEl(null)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
<IconButton onClick={handleClick} {...props}>
|
|
22
|
-
<MoreVertIcon />
|
|
23
|
-
</IconButton>
|
|
24
|
-
<Menu
|
|
25
|
-
anchorEl={anchorEl}
|
|
26
|
-
open={open}
|
|
27
|
-
onClose={handleClose}
|
|
28
|
-
slotProps={{
|
|
29
|
-
paper: { variant: 'elevation' },
|
|
30
|
-
list: { dense: true },
|
|
31
|
-
}}
|
|
32
|
-
>
|
|
33
|
-
<JsonMenuItem />
|
|
34
|
-
</Menu>
|
|
35
|
-
</>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { OpenInNew as OpenInNewIcon } from '@mui/icons-material'
|
|
2
|
-
import type { MenuItemProps } from '@mui/material'
|
|
3
|
-
import {
|
|
4
|
-
ListItemIcon, ListItemText, MenuItem,
|
|
5
|
-
} from '@mui/material'
|
|
6
|
-
import { isDefined } from '@xylabs/sdk-js'
|
|
7
|
-
import React from 'react'
|
|
8
|
-
|
|
9
|
-
import { useResolvePayload } from '../../../contexts/index.ts'
|
|
10
|
-
|
|
11
|
-
export const JsonMenuItem: React.FC<MenuItemProps> = (props) => {
|
|
12
|
-
const { huri } = useResolvePayload()
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<>
|
|
16
|
-
{isDefined(huri)
|
|
17
|
-
? (
|
|
18
|
-
<MenuItem title="Source Payload JSON" onClick={() => window.open(huri, '_blank')} {...props}>
|
|
19
|
-
<ListItemText sx={{ mr: 1 }}>JSON</ListItemText>
|
|
20
|
-
<ListItemIcon sx={{ justifyContent: 'end' }}>
|
|
21
|
-
<OpenInNewIcon fontSize="small" />
|
|
22
|
-
</ListItemIcon>
|
|
23
|
-
</MenuItem>
|
|
24
|
-
)
|
|
25
|
-
: null}
|
|
26
|
-
</>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './EmbedMenu.tsx'
|
package/src/components/index.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Meta } from '@storybook/react-vite'
|
|
2
|
-
import { CryptoAssetRenderPlugin } from '@xyo-network/react-aggregate-price-plugin'
|
|
3
|
-
import { UniswapPairsRenderPlugin } from '@xyo-network/react-crypto-market-uniswap-plugin'
|
|
4
|
-
|
|
5
|
-
import { Template } from './storyShared.tsx'
|
|
6
|
-
import { xyoEmbedStoryBase } from './xyoEmbedStoryBase.ts'
|
|
7
|
-
|
|
8
|
-
const AggregatePricePointer = 'https://api.archivist.xyo.network/1948bf4eedf90ee2b8a1f63216b7c6b3b18d7bc2834330d85bcd6ab3d6428a20'
|
|
9
|
-
const UniswapPairPointer = 'https://beta.api.archivist.xyo.network/e36602006239d86b6e08412f7879372b2c622d74f4d6bc508a08a46fa8ad6523'
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
...xyoEmbedStoryBase,
|
|
13
|
-
title: 'embed/EmbedPlugin/examples',
|
|
14
|
-
} as Meta
|
|
15
|
-
|
|
16
|
-
const AggregatePriceExample = Template.bind({})
|
|
17
|
-
AggregatePriceExample.args = {
|
|
18
|
-
huriPayload: AggregatePricePointer,
|
|
19
|
-
plugins: [CryptoAssetRenderPlugin],
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const UniswapPairsExample = Template.bind({})
|
|
23
|
-
UniswapPairsExample.args = {
|
|
24
|
-
huriPayload: UniswapPairPointer,
|
|
25
|
-
plugins: [UniswapPairsRenderPlugin],
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { AggregatePriceExample, UniswapPairsExample }
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type { Meta } from '@storybook/react-vite'
|
|
2
|
-
import { CryptoAssetRenderPlugin } from '@xyo-network/react-aggregate-price-plugin'
|
|
3
|
-
import { UniswapPairsRenderPlugin } from '@xyo-network/react-crypto-market-uniswap-plugin'
|
|
4
|
-
import { createPayloadRenderPlugin } from '@xyo-network/react-payload-plugin'
|
|
5
|
-
|
|
6
|
-
import { payloadData } from './storyPayload.ts'
|
|
7
|
-
import { Template } from './storyShared.tsx'
|
|
8
|
-
import { xyoEmbedStoryBase } from './xyoEmbedStoryBase.ts'
|
|
9
|
-
|
|
10
|
-
const AggregatePricePointer = 'https://api.archivist.xyo.network/1948bf4eedf90ee2b8a1f63216b7c6b3b18d7bc2834330d85bcd6ab3d6428a20'
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
...xyoEmbedStoryBase,
|
|
14
|
-
title: 'embed/EmbedPlugin/states',
|
|
15
|
-
} as Meta
|
|
16
|
-
|
|
17
|
-
const testPlugin = createPayloadRenderPlugin({
|
|
18
|
-
canRender: () => true,
|
|
19
|
-
name: 'Test Plugin',
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const testPlugin1 = createPayloadRenderPlugin({
|
|
23
|
-
canRender: () => true,
|
|
24
|
-
name: 'Test1 Plugin',
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
const failingPlugin = createPayloadRenderPlugin({
|
|
28
|
-
canRender: () => true,
|
|
29
|
-
components: {
|
|
30
|
-
box: {
|
|
31
|
-
details: () => {
|
|
32
|
-
throw new Error('testing Error Boundary')
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
name: 'Failing Plugin',
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
const Default = Template.bind({})
|
|
40
|
-
Default.args = {
|
|
41
|
-
huri: AggregatePricePointer,
|
|
42
|
-
plugins: [testPlugin, testPlugin1],
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const ApiError = Template.bind({})
|
|
46
|
-
ApiError.args = {
|
|
47
|
-
huriPayload: 'https://api.archivist.xyo.network/9663b2f80395a9e7e95948fdd5988b778a4dcc047202bf67e855ff6cd459b8c',
|
|
48
|
-
plugins: [UniswapPairsRenderPlugin],
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const ThrownError = Template.bind({})
|
|
52
|
-
ThrownError.args = {
|
|
53
|
-
huriPayload: AggregatePricePointer,
|
|
54
|
-
plugins: [failingPlugin],
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const HiddenElements = Template.bind({})
|
|
58
|
-
HiddenElements.args = {
|
|
59
|
-
hideElementsConfig: {
|
|
60
|
-
hideAvatar: true,
|
|
61
|
-
hideCardActions: true,
|
|
62
|
-
hideCardHeader: true,
|
|
63
|
-
hideRefreshButton: true,
|
|
64
|
-
hideTimestamp: true,
|
|
65
|
-
hideTitle: true,
|
|
66
|
-
},
|
|
67
|
-
huriPayload: AggregatePricePointer,
|
|
68
|
-
plugins: [CryptoAssetRenderPlugin],
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const WithPassedPayload = Template.bind({})
|
|
72
|
-
WithPassedPayload.args = {
|
|
73
|
-
huriPayload: payloadData,
|
|
74
|
-
plugins: [CryptoAssetRenderPlugin],
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const WithSetBusyExternally = Template.bind({})
|
|
78
|
-
WithSetBusyExternally.args = {
|
|
79
|
-
busy: true,
|
|
80
|
-
huriPayload: payloadData,
|
|
81
|
-
plugins: [CryptoAssetRenderPlugin],
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const WithOnRefresh = Template.bind({})
|
|
85
|
-
WithOnRefresh.args = {
|
|
86
|
-
huriPayload: payloadData,
|
|
87
|
-
onRefresh: () => console.log('refreshed'),
|
|
88
|
-
plugins: [CryptoAssetRenderPlugin],
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export {
|
|
92
|
-
ApiError, Default, HiddenElements, ThrownError, WithOnRefresh, WithPassedPayload, WithSetBusyExternally,
|
|
93
|
-
}
|