@xyo-network/react-chain-shared 1.20.1 → 1.20.3
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/index.mjs +17 -0
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/story/IframeWalletWarningDecorator.d.ts +10 -0
- package/dist/browser/story/IframeWalletWarningDecorator.d.ts.map +1 -0
- package/dist/browser/story/index.d.ts +1 -0
- package/dist/browser/story/index.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/story/IframeWalletWarningDecorator.tsx +36 -0
- package/src/story/index.ts +1 -0
package/dist/browser/index.mjs
CHANGED
|
@@ -132,9 +132,26 @@ var buildRandomBlockChainBlocksOnly = /* @__PURE__ */ __name(async (blockCount =
|
|
|
132
132
|
const chain = await buildRandomChain(await Account.random(), blockCount);
|
|
133
133
|
return chain;
|
|
134
134
|
}, "buildRandomBlockChainBlocksOnly");
|
|
135
|
+
|
|
136
|
+
// src/story/IframeWalletWarningDecorator.tsx
|
|
137
|
+
import { Alert, Stack as Stack3 } from "@mui/material";
|
|
138
|
+
import { isXyoGlobal } from "@xyo-network/react-chain-model";
|
|
139
|
+
import React4 from "react";
|
|
140
|
+
var inIframe = globalThis.self !== window.top;
|
|
141
|
+
var IframeWalletWarningDecorator = /* @__PURE__ */ __name((Story, args) => {
|
|
142
|
+
const hasXyoGlobal = isXyoGlobal(globalThis.xyo);
|
|
143
|
+
return /* @__PURE__ */ React4.createElement(Stack3, {
|
|
144
|
+
gap: 2
|
|
145
|
+
}, inIframe ? /* @__PURE__ */ React4.createElement(Alert, {
|
|
146
|
+
severity: "warning"
|
|
147
|
+
}, "This story is running in an iframe. Please run it in a standalone browser window to test the wallet extension.") : null, hasXyoGlobal ? null : /* @__PURE__ */ React4.createElement(Alert, {
|
|
148
|
+
severity: "warning"
|
|
149
|
+
}, "No wallet extension found. Please install the Xyo Wallet Chrome Extension."), /* @__PURE__ */ React4.createElement(Story, args));
|
|
150
|
+
}, "IframeWalletWarningDecorator");
|
|
135
151
|
export {
|
|
136
152
|
ActiveMenuItem,
|
|
137
153
|
DetailsStack,
|
|
154
|
+
IframeWalletWarningDecorator,
|
|
138
155
|
LabelValueStack,
|
|
139
156
|
buildRandomBlockChain,
|
|
140
157
|
buildRandomBlockChainBlocksOnly
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/menu-item/ActiveMenuItem.tsx","../../src/components/stack/DetailsStack.tsx","../../src/components/stack/LabelValueStack.tsx","../../src/story/buildRandomBlockchain.ts"],"sourcesContent":["import type { MenuItemProps } from '@mui/material'\nimport {\n MenuItem, styled, useTheme,\n} from '@mui/material'\nimport React from 'react'\n\nexport const ActiveMenuItem: React.FC<MenuItemProps & { active?: boolean }> = ({\n active, children, sx, ...props\n}) => {\n const theme = useTheme()\n return (\n <StyledMenuItem\n disableRipple\n sx={{\n // left border color and background color for active state\n 'borderLeft': `5px solid ${active ? theme.vars.palette.secondary.light : 'transparent'}`,\n 'backgroundColor': active ? theme.vars.palette.secondary.dark : 'transparent',\n // force white text color for active state for improved readability with background color\n 'color': active ? 'white' : 'unset',\n '&:hover': {\n // overriding default hover color and backgroundColor since active state conflicts visually with\n // default styles of MenuItem hover\n ...(active ? { backgroundColor: theme.vars.palette.secondary.dark } : {}),\n color: active ? 'white' : 'unset',\n },\n ...sx,\n }}\n {...props}\n >\n {children}\n </StyledMenuItem>\n )\n}\n\nconst StyledMenuItem = styled(MenuItem, { name: 'StyledMenuItem' })(({ theme }) => ({\n display: 'flex-inline',\n flexDirection: 'row',\n gap: theme.spacing(1),\n padding: 0,\n paddingLeft: theme.spacing(1),\n marginBottom: theme.spacing(1),\n}))\n","import type { StackProps } from '@mui/material'\nimport {\n Stack, styled, Tooltip, Typography,\n useTheme,\n} from '@mui/material'\nimport { isDefined } from '@xylabs/sdk-js'\nimport type {\n ComponentType, ReactNode, SVGAttributes,\n} from 'react'\nimport React, { useMemo } from 'react'\n\nconst isComponentType = (value: unknown): value is ComponentType<SVGAttributes<SVGElement>> =>\n typeof value === 'function'\n || (typeof value === 'object' && value !== null && ('$$typeof' in value || 'render' in value))\n\nexport interface DetailsStackProps extends StackProps {\n IconComponent?: ComponentType<SVGAttributes<SVGElement>> | ReactNode\n heading?: string\n tooltipTitle?: string\n}\n\nexport const DetailsStack: React.FC<DetailsStackProps> = ({\n IconComponent, heading, children, tooltipTitle, ...props\n}) => {\n const theme = useTheme()\n\n const hasTooltip = isDefined(tooltipTitle)\n const resolvedIconComponent = useMemo(() => {\n return isComponentType(IconComponent)\n ? (\n <IconComponent\n style={{\n /** height and marginTop adjusted to account for font not filling container with line-height: 1 */\n height: '0.85rem',\n marginTop: 0.5,\n marginLeft: theme.spacing(1),\n }}\n />\n )\n : IconComponent ?? null\n }, [IconComponent, theme])\n\n return (\n <Stack direction=\"column\" flexGrow={1} flexWrap=\"wrap\" minWidth=\"1px\" {...props}>\n <SectionHeadingTypography>\n {heading}\n {hasTooltip\n ? (\n <Tooltip title={tooltipTitle}>\n <span>{resolvedIconComponent}</span>\n </Tooltip>\n )\n : resolvedIconComponent}\n </SectionHeadingTypography>\n {children}\n </Stack>\n )\n}\n\nconst SectionHeadingTypography = styled(Typography, { name: 'SectionHeadingTypography' })(({ theme }) => ({\n display: 'flex',\n fontFamily: 'monospace',\n lineHeight: 1,\n marginBottom: theme.spacing(1.5),\n}))\n","import type { StackProps } from '@mui/material'\nimport {\n Stack, Typography, useTheme,\n} from '@mui/material'\nimport { ellipsize, isAddress } from '@xylabs/sdk-js'\nimport React from 'react'\n\nexport interface LabelValueStackProps extends StackProps {\n labels: string[]\n values: (string | undefined)[]\n}\n\nexport const LabelValueStack: React.FC<LabelValueStackProps> = ({\n labels, values, ...props\n}) => {\n const theme = useTheme()\n const formattedValue = (value: string | undefined): string | undefined => {\n if (isAddress(value)) {\n return ellipsize(value, 8)\n }\n return value\n }\n return (\n <Stack flexDirection=\"row\" flexGrow={1} {...props}>\n <Stack>\n {labels.map(label => (\n <Typography\n fontWeight=\"300\"\n key={label}\n variant=\"body2\"\n sx={{ borderBottom: `1px solid ${theme.vars?.palette.divider}`, opacity: 0.7 }}\n >\n {label}\n :\n </Typography>\n ))}\n </Stack>\n <Stack alignItems=\"end\" flexGrow={1}>\n {values.map((value, index) => (\n <Typography\n title={value}\n fontFamily=\"monospace\"\n variant=\"body2\"\n // Use matching label as key since values might be the same\n key={labels[index]}\n width=\"100%\"\n sx={{\n display: 'flex', justifyContent: 'end', borderBottom: `1px solid ${theme.vars?.palette.divider}`,\n }}\n >\n {formattedValue(value)}\n </Typography>\n ))}\n </Stack>\n </Stack>\n )\n}\n","import { buildRandomChain } from '@xyo-network/chain-protocol'\nimport { Account } from '@xyo-network/sdk-js'\n\nexport const buildRandomBlockChain = async (blockCount = 10) => {\n // Create a producer\n const initialBlockProducer = await Account.random()\n\n // Create multiple blocks\n const blocks = await buildRandomChain(initialBlockProducer, blockCount)\n return blocks\n}\n\nexport const buildRandomBlockChainBlocksOnly = async (blockCount = 10) => {\n const chain = await buildRandomChain(await Account.random(), blockCount)\n return chain\n}\n"],"mappings":";;;;AACA,SACEA,UAAUC,QAAQC,gBACb;AACP,OAAOC,WAAW;AAEX,IAAMC,iBAAiE,wBAAC,EAC7EC,QAAQC,UAAUC,IAAI,GAAGC,MAAAA,MAC1B;AACC,QAAMC,QAAQC,SAAAA;AACd,SACE,sBAAA,cAACC,gBAAAA;IACCC,eAAAA;IACAL,IAAI;;MAEF,cAAc,aAAaF,SAASI,MAAMI,KAAKC,QAAQC,UAAUC,QAAQ,aAAA;MACzE,mBAAmBX,SAASI,MAAMI,KAAKC,QAAQC,UAAUE,OAAO;;MAEhE,SAASZ,SAAS,UAAU;MAC5B,WAAW;;;QAGT,GAAIA,SAAS;UAAEa,iBAAiBT,MAAMI,KAAKC,QAAQC,UAAUE;QAAK,IAAI,CAAC;QACvEE,OAAOd,SAAS,UAAU;MAC5B;MACA,GAAGE;IACL;IACC,GAAGC;KAEHF,QAAAA;AAG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,8BAAOC,aAAa,OAAE;AAEzD,QAAMC,uBAAuB,MAAMC,QAAQC,OAAM;AAGjD,QAAMC,SAAS,MAAMC,iBAAiBJ,sBAAsBD,UAAAA;AAC5D,SAAOI;AACT,GAPqC;AAS9B,IAAME,kCAAkC,8BAAON,aAAa,OAAE;AACnE,QAAMO,QAAQ,MAAMF,iBAAiB,MAAMH,QAAQC,OAAM,GAAIH,UAAAA;AAC7D,SAAOO;AACT,GAH+C;","names":["MenuItem","styled","useTheme","React","ActiveMenuItem","active","children","sx","props","theme","useTheme","StyledMenuItem","disableRipple","vars","palette","secondary","light","dark","backgroundColor","color","styled","MenuItem","name","display","flexDirection","gap","spacing","padding","paddingLeft","marginBottom","Stack","styled","Tooltip","Typography","useTheme","isDefined","React","useMemo","isComponentType","value","DetailsStack","IconComponent","heading","children","tooltipTitle","props","theme","useTheme","hasTooltip","isDefined","resolvedIconComponent","useMemo","React","style","height","marginTop","marginLeft","spacing","Stack","direction","flexGrow","flexWrap","minWidth","SectionHeadingTypography","Tooltip","title","span","styled","Typography","name","display","fontFamily","lineHeight","marginBottom","Stack","Typography","useTheme","ellipsize","isAddress","React","LabelValueStack","labels","values","props","theme","useTheme","formattedValue","value","isAddress","ellipsize","React","Stack","flexDirection","flexGrow","map","label","Typography","fontWeight","key","variant","sx","borderBottom","vars","palette","divider","opacity","alignItems","index","title","fontFamily","width","display","justifyContent","buildRandomChain","Account","buildRandomBlockChain","blockCount","initialBlockProducer","Account","random","blocks","buildRandomChain","buildRandomBlockChainBlocksOnly","chain"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/menu-item/ActiveMenuItem.tsx","../../src/components/stack/DetailsStack.tsx","../../src/components/stack/LabelValueStack.tsx","../../src/story/buildRandomBlockchain.ts","../../src/story/IframeWalletWarningDecorator.tsx"],"sourcesContent":["import type { MenuItemProps } from '@mui/material'\nimport {\n MenuItem, styled, useTheme,\n} from '@mui/material'\nimport React from 'react'\n\nexport const ActiveMenuItem: React.FC<MenuItemProps & { active?: boolean }> = ({\n active, children, sx, ...props\n}) => {\n const theme = useTheme()\n return (\n <StyledMenuItem\n disableRipple\n sx={{\n // left border color and background color for active state\n 'borderLeft': `5px solid ${active ? theme.vars.palette.secondary.light : 'transparent'}`,\n 'backgroundColor': active ? theme.vars.palette.secondary.dark : 'transparent',\n // force white text color for active state for improved readability with background color\n 'color': active ? 'white' : 'unset',\n '&:hover': {\n // overriding default hover color and backgroundColor since active state conflicts visually with\n // default styles of MenuItem hover\n ...(active ? { backgroundColor: theme.vars.palette.secondary.dark } : {}),\n color: active ? 'white' : 'unset',\n },\n ...sx,\n }}\n {...props}\n >\n {children}\n </StyledMenuItem>\n )\n}\n\nconst StyledMenuItem = styled(MenuItem, { name: 'StyledMenuItem' })(({ theme }) => ({\n display: 'flex-inline',\n flexDirection: 'row',\n gap: theme.spacing(1),\n padding: 0,\n paddingLeft: theme.spacing(1),\n marginBottom: theme.spacing(1),\n}))\n","import type { StackProps } from '@mui/material'\nimport {\n Stack, styled, Tooltip, Typography,\n useTheme,\n} from '@mui/material'\nimport { isDefined } from '@xylabs/sdk-js'\nimport type {\n ComponentType, ReactNode, SVGAttributes,\n} from 'react'\nimport React, { useMemo } from 'react'\n\nconst isComponentType = (value: unknown): value is ComponentType<SVGAttributes<SVGElement>> =>\n typeof value === 'function'\n || (typeof value === 'object' && value !== null && ('$$typeof' in value || 'render' in value))\n\nexport interface DetailsStackProps extends StackProps {\n IconComponent?: ComponentType<SVGAttributes<SVGElement>> | ReactNode\n heading?: string\n tooltipTitle?: string\n}\n\nexport const DetailsStack: React.FC<DetailsStackProps> = ({\n IconComponent, heading, children, tooltipTitle, ...props\n}) => {\n const theme = useTheme()\n\n const hasTooltip = isDefined(tooltipTitle)\n const resolvedIconComponent = useMemo(() => {\n return isComponentType(IconComponent)\n ? (\n <IconComponent\n style={{\n /** height and marginTop adjusted to account for font not filling container with line-height: 1 */\n height: '0.85rem',\n marginTop: 0.5,\n marginLeft: theme.spacing(1),\n }}\n />\n )\n : IconComponent ?? null\n }, [IconComponent, theme])\n\n return (\n <Stack direction=\"column\" flexGrow={1} flexWrap=\"wrap\" minWidth=\"1px\" {...props}>\n <SectionHeadingTypography>\n {heading}\n {hasTooltip\n ? (\n <Tooltip title={tooltipTitle}>\n <span>{resolvedIconComponent}</span>\n </Tooltip>\n )\n : resolvedIconComponent}\n </SectionHeadingTypography>\n {children}\n </Stack>\n )\n}\n\nconst SectionHeadingTypography = styled(Typography, { name: 'SectionHeadingTypography' })(({ theme }) => ({\n display: 'flex',\n fontFamily: 'monospace',\n lineHeight: 1,\n marginBottom: theme.spacing(1.5),\n}))\n","import type { StackProps } from '@mui/material'\nimport {\n Stack, Typography, useTheme,\n} from '@mui/material'\nimport { ellipsize, isAddress } from '@xylabs/sdk-js'\nimport React from 'react'\n\nexport interface LabelValueStackProps extends StackProps {\n labels: string[]\n values: (string | undefined)[]\n}\n\nexport const LabelValueStack: React.FC<LabelValueStackProps> = ({\n labels, values, ...props\n}) => {\n const theme = useTheme()\n const formattedValue = (value: string | undefined): string | undefined => {\n if (isAddress(value)) {\n return ellipsize(value, 8)\n }\n return value\n }\n return (\n <Stack flexDirection=\"row\" flexGrow={1} {...props}>\n <Stack>\n {labels.map(label => (\n <Typography\n fontWeight=\"300\"\n key={label}\n variant=\"body2\"\n sx={{ borderBottom: `1px solid ${theme.vars?.palette.divider}`, opacity: 0.7 }}\n >\n {label}\n :\n </Typography>\n ))}\n </Stack>\n <Stack alignItems=\"end\" flexGrow={1}>\n {values.map((value, index) => (\n <Typography\n title={value}\n fontFamily=\"monospace\"\n variant=\"body2\"\n // Use matching label as key since values might be the same\n key={labels[index]}\n width=\"100%\"\n sx={{\n display: 'flex', justifyContent: 'end', borderBottom: `1px solid ${theme.vars?.palette.divider}`,\n }}\n >\n {formattedValue(value)}\n </Typography>\n ))}\n </Stack>\n </Stack>\n )\n}\n","import { buildRandomChain } from '@xyo-network/chain-protocol'\nimport { Account } from '@xyo-network/sdk-js'\n\nexport const buildRandomBlockChain = async (blockCount = 10) => {\n // Create a producer\n const initialBlockProducer = await Account.random()\n\n // Create multiple blocks\n const blocks = await buildRandomChain(initialBlockProducer, blockCount)\n return blocks\n}\n\nexport const buildRandomBlockChainBlocksOnly = async (blockCount = 10) => {\n const chain = await buildRandomChain(await Account.random(), blockCount)\n return chain\n}\n","import { Alert, Stack } from '@mui/material'\nimport type { Decorator } from '@storybook/react-vite'\nimport { isXyoGlobal } from '@xyo-network/react-chain-model'\nimport React from 'react'\n\nconst inIframe = globalThis.self !== window.top\n\n/**\n * Storybook decorator that displays warning banners when:\n * - the story is rendered inside an iframe (prompt user to open in a standalone tab), or\n * - the XYO wallet extension is not detected (prompt user to install it).\n *\n * Stories that require direct browser-extension access should use this decorator.\n */\nexport const IframeWalletWarningDecorator: Decorator = (Story, args) => {\n const hasXyoGlobal = isXyoGlobal((globalThis as Record<string, unknown>).xyo)\n return (\n <Stack gap={2}>\n {inIframe\n ? (\n <Alert severity=\"warning\">\n This story is running in an iframe. Please run it in a standalone browser window to test the wallet extension.\n </Alert>\n )\n : null}\n {hasXyoGlobal\n ? null\n : (\n <Alert severity=\"warning\">\n No wallet extension found. Please install the Xyo Wallet Chrome Extension.\n </Alert>\n )}\n <Story {...args} />\n </Stack>\n )\n}\n"],"mappings":";;;;AACA,SACEA,UAAUC,QAAQC,gBACb;AACP,OAAOC,WAAW;AAEX,IAAMC,iBAAiE,wBAAC,EAC7EC,QAAQC,UAAUC,IAAI,GAAGC,MAAAA,MAC1B;AACC,QAAMC,QAAQC,SAAAA;AACd,SACE,sBAAA,cAACC,gBAAAA;IACCC,eAAAA;IACAL,IAAI;;MAEF,cAAc,aAAaF,SAASI,MAAMI,KAAKC,QAAQC,UAAUC,QAAQ,aAAA;MACzE,mBAAmBX,SAASI,MAAMI,KAAKC,QAAQC,UAAUE,OAAO;;MAEhE,SAASZ,SAAS,UAAU;MAC5B,WAAW;;;QAGT,GAAIA,SAAS;UAAEa,iBAAiBT,MAAMI,KAAKC,Q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CAAAA,CAAAA,CAAAA,CAAAA;AAM5B,GA5C+D;;;ACZ/D,SAAS0B,wBAAwB;AACjC,SAASC,eAAe;AAEjB,IAAMC,wBAAwB,8BAAOC,aAAa,OAAE;AAEzD,QAAMC,uBAAuB,MAAMC,QAAQC,OAAM;AAGjD,QAAMC,SAAS,MAAMC,iBAAiBJ,sBAAsBD,UAAAA;AAC5D,SAAOI;AACT,GAPqC;AAS9B,IAAME,kCAAkC,8BAAON,aAAa,OAAE;AACnE,QAAMO,QAAQ,MAAMF,iBAAiB,MAAMH,QAAQC,OAAM,GAAIH,UAAAA;AAC7D,SAAOO;AACT,GAH+C;;;ACZ/C,SAASC,OAAOC,SAAAA,cAAa;AAE7B,SAASC,mBAAmB;AAC5B,OAAOC,YAAW;AAElB,IAAMC,WAAWC,WAAWC,SAASC,OAAOC;AASrC,IAAMC,+BAA0C,wBAACC,OAAOC,SAAAA;AAC7D,QAAMC,eAAeC,YAAaR,WAAuCS,GAAG;AAC5E,SACE,gBAAAC,OAAA,cAACC,QAAAA;IAAMC,KAAK;KACTb,WAEK,gBAAAW,OAAA,cAACG,OAAAA;IAAMC,UAAS;KAAU,gHAAA,IAI5B,MACHP,eACG,OAEE,gBAAAG,OAAA,cAACG,OAAAA;IAAMC,UAAS;KAAU,4EAAA,GAIhC,gBAAAJ,OAAA,cAACL,OAAUC,IAAAA,CAAAA;AAGjB,GArBuD;","names":["MenuItem","styled","useTheme","React","ActiveMenuItem","active","children","sx","props","theme","useTheme","StyledMenuItem","disableRipple","vars","palette","secondary","light","dark","backgroundColor","color","styled","MenuItem","name","display","flexDirection","gap","spacing","padding","paddingLeft","marginBottom","Stack","styled","Tooltip","Typography","useTheme","isDefined","React","useMemo","isComponentType","value","DetailsStack","IconComponent","heading","children","tooltipTitle","props","theme","useTheme","hasTooltip","isDefined","resolvedIconComponent","useMemo","React","style","height","marginTop","marginLeft","spacing","Stack","direction","flexGrow","flexWrap","minWidth","SectionHeadingTypography","Tooltip","title","span","styled","Typography","name","display","fontFamily","lineHeight","marginBottom","Stack","Typography","useTheme","ellipsize","isAddress","React","LabelValueStack","labels","values","props","theme","useTheme","formattedValue","value","isAddress","ellipsize","React","Stack","flexDirection","flexGrow","map","label","Typography","fontWeight","key","variant","sx","borderBottom","vars","palette","divider","opacity","alignItems","index","title","fontFamily","width","display","justifyContent","buildRandomChain","Account","buildRandomBlockChain","blockCount","initialBlockProducer","Account","random","blocks","buildRandomChain","buildRandomBlockChainBlocksOnly","chain","Alert","Stack","isXyoGlobal","React","inIframe","globalThis","self","window","top","IframeWalletWarningDecorator","Story","args","hasXyoGlobal","isXyoGlobal","xyo","React","Stack","gap","Alert","severity"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Decorator } from '@storybook/react-vite';
|
|
2
|
+
/**
|
|
3
|
+
* Storybook decorator that displays warning banners when:
|
|
4
|
+
* - the story is rendered inside an iframe (prompt user to open in a standalone tab), or
|
|
5
|
+
* - the XYO wallet extension is not detected (prompt user to install it).
|
|
6
|
+
*
|
|
7
|
+
* Stories that require direct browser-extension access should use this decorator.
|
|
8
|
+
*/
|
|
9
|
+
export declare const IframeWalletWarningDecorator: Decorator;
|
|
10
|
+
//# sourceMappingURL=IframeWalletWarningDecorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IframeWalletWarningDecorator.d.ts","sourceRoot":"","sources":["../../../src/story/IframeWalletWarningDecorator.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAMtD;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,EAAE,SAqB1C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/story/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/story/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,oCAAoC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/react-chain-shared",
|
|
4
|
-
"version": "1.20.
|
|
4
|
+
"version": "1.20.3",
|
|
5
5
|
"description": "XYO Layer One React SDK",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -49,17 +49,18 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@xylabs/sdk-js": "~5.0.80",
|
|
52
|
-
"@xyo-network/chain-protocol": "~1.20.
|
|
52
|
+
"@xyo-network/chain-protocol": "~1.20.3",
|
|
53
|
+
"@xyo-network/react-chain-model": "~1.20.3"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@emotion/react": "~11.14.0",
|
|
56
57
|
"@emotion/styled": "~11.14.1",
|
|
57
|
-
"@mui/material": "~7.3.
|
|
58
|
+
"@mui/material": "~7.3.9",
|
|
58
59
|
"@types/react": "~19.2.14",
|
|
59
|
-
"@xylabs/ts-scripts-yarn3": "~7.
|
|
60
|
-
"@xylabs/tsconfig": "~7.
|
|
61
|
-
"@xylabs/tsconfig-dom": "~7.
|
|
62
|
-
"@xylabs/tsconfig-react": "~7.
|
|
60
|
+
"@xylabs/ts-scripts-yarn3": "~7.4.10",
|
|
61
|
+
"@xylabs/tsconfig": "~7.4.10",
|
|
62
|
+
"@xylabs/tsconfig-dom": "~7.4.10",
|
|
63
|
+
"@xylabs/tsconfig-react": "~7.4.10",
|
|
63
64
|
"@xyo-network/sdk-js": "~5.3.15",
|
|
64
65
|
"axios": "^1.13.6",
|
|
65
66
|
"react": "~19.2.4",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Alert, Stack } from '@mui/material'
|
|
2
|
+
import type { Decorator } from '@storybook/react-vite'
|
|
3
|
+
import { isXyoGlobal } from '@xyo-network/react-chain-model'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
|
|
6
|
+
const inIframe = globalThis.self !== window.top
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Storybook decorator that displays warning banners when:
|
|
10
|
+
* - the story is rendered inside an iframe (prompt user to open in a standalone tab), or
|
|
11
|
+
* - the XYO wallet extension is not detected (prompt user to install it).
|
|
12
|
+
*
|
|
13
|
+
* Stories that require direct browser-extension access should use this decorator.
|
|
14
|
+
*/
|
|
15
|
+
export const IframeWalletWarningDecorator: Decorator = (Story, args) => {
|
|
16
|
+
const hasXyoGlobal = isXyoGlobal((globalThis as Record<string, unknown>).xyo)
|
|
17
|
+
return (
|
|
18
|
+
<Stack gap={2}>
|
|
19
|
+
{inIframe
|
|
20
|
+
? (
|
|
21
|
+
<Alert severity="warning">
|
|
22
|
+
This story is running in an iframe. Please run it in a standalone browser window to test the wallet extension.
|
|
23
|
+
</Alert>
|
|
24
|
+
)
|
|
25
|
+
: null}
|
|
26
|
+
{hasXyoGlobal
|
|
27
|
+
? null
|
|
28
|
+
: (
|
|
29
|
+
<Alert severity="warning">
|
|
30
|
+
No wallet extension found. Please install the Xyo Wallet Chrome Extension.
|
|
31
|
+
</Alert>
|
|
32
|
+
)}
|
|
33
|
+
<Story {...args} />
|
|
34
|
+
</Stack>
|
|
35
|
+
)
|
|
36
|
+
}
|
package/src/story/index.ts
CHANGED