@xyo-network/react-chain-shared 1.5.7 → 1.5.9

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.
@@ -38,6 +38,78 @@ var StyledMenuItem = styled(MenuItem, {
38
38
  marginBottom: theme.spacing(1)
39
39
  }));
40
40
 
41
+ // src/components/stack/DetailsStack.tsx
42
+ import { Stack, styled as styled2, Tooltip, Typography, useTheme as useTheme2 } from "@mui/material";
43
+ import { isDefined } from "@xylabs/typeof";
44
+ import React2, { useMemo } from "react";
45
+ var DetailsStack = /* @__PURE__ */ __name(({ IconComponent, heading, children, tooltipTitle, ...props }) => {
46
+ const theme = useTheme2();
47
+ const hasTooltip = isDefined(tooltipTitle);
48
+ const resolvedIconComponent = useMemo(() => {
49
+ return IconComponent ? /* @__PURE__ */ React2.createElement(IconComponent, {
50
+ style: {
51
+ /** height and marginTop adjusted to account for font not filling container with line-height: 1 */
52
+ height: "0.85rem",
53
+ marginTop: 0.5,
54
+ marginLeft: theme.spacing(1)
55
+ }
56
+ }) : /* @__PURE__ */ React2.createElement(React2.Fragment, null);
57
+ }, [
58
+ IconComponent
59
+ ]);
60
+ return /* @__PURE__ */ React2.createElement(Stack, {
61
+ direction: "column",
62
+ flexGrow: 1,
63
+ flexWrap: "wrap",
64
+ minWidth: "1px",
65
+ ...props
66
+ }, /* @__PURE__ */ React2.createElement(SectionHeadingTypography, null, heading, hasTooltip ? /* @__PURE__ */ React2.createElement(Tooltip, {
67
+ title: tooltipTitle
68
+ }, resolvedIconComponent) : resolvedIconComponent), children);
69
+ }, "DetailsStack");
70
+ var SectionHeadingTypography = styled2(Typography, {
71
+ name: "SectionHeadingTypography"
72
+ })(({ theme }) => ({
73
+ display: "flex",
74
+ fontFamily: "monospace",
75
+ lineHeight: 1,
76
+ marginBottom: theme.spacing(1.5)
77
+ }));
78
+
79
+ // src/components/stack/LabelValueStack.tsx
80
+ import { Stack as Stack2, Typography as Typography2, useTheme as useTheme3 } from "@mui/material";
81
+ import React3 from "react";
82
+ var LabelValueStack = /* @__PURE__ */ __name(({ labels, values, ...props }) => {
83
+ const theme = useTheme3();
84
+ return /* @__PURE__ */ React3.createElement(Stack2, {
85
+ flexDirection: "row",
86
+ flexGrow: 1,
87
+ ...props
88
+ }, /* @__PURE__ */ React3.createElement(Stack2, null, labels.map((label) => /* @__PURE__ */ React3.createElement(Typography2, {
89
+ fontWeight: "300",
90
+ key: label,
91
+ variant: "body2",
92
+ sx: {
93
+ borderBottom: `1px solid ${theme.vars?.palette.divider}`,
94
+ opacity: 0.7
95
+ }
96
+ }, label, ":"))), /* @__PURE__ */ React3.createElement(Stack2, {
97
+ alignItems: "end",
98
+ flexGrow: 1
99
+ }, values.map((value, index) => /* @__PURE__ */ React3.createElement(Typography2, {
100
+ fontFamily: "monospace",
101
+ variant: "body2",
102
+ // Use matching label as key since values might be the same
103
+ key: labels[index],
104
+ width: "100%",
105
+ sx: {
106
+ display: "flex",
107
+ justifyContent: "end",
108
+ borderBottom: `1px solid ${theme.vars?.palette.divider}`
109
+ }
110
+ }, value))));
111
+ }, "LabelValueStack");
112
+
41
113
  // src/story/buildRandomBlockchain.ts
42
114
  import { Account } from "@xyo-network/account";
43
115
  import { buildRandomChain } from "@xyo-network/chain-protocol";
@@ -52,6 +124,8 @@ var buildRandomBlockChainBlocksOnly = /* @__PURE__ */ __name(async (blockCount =
52
124
  }, "buildRandomBlockChainBlocksOnly");
53
125
  export {
54
126
  ActiveMenuItem,
127
+ DetailsStack,
128
+ LabelValueStack,
55
129
  buildRandomBlockChain,
56
130
  buildRandomBlockChainBlocksOnly
57
131
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/menu-item/ActiveMenuItem.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 { Account } from '@xyo-network/account'\nimport { buildRandomChain } from '@xyo-network/chain-protocol'\nimport type { HydratedBlock } from '@xyo-network/xl1-protocol'\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: HydratedBlock[] = 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;AAGP,GA1B8E;AA4B9E,IAAMK,iBAAiBS,OAAOC,UAAU;EAAEC,MAAM;AAAiB,CAAA,EAAG,CAAC,EAAEb,MAAK,OAAQ;EAClFc,SAAS;EACTC,eAAe;EACfC,KAAKhB,MAAMiB,QAAQ,CAAA;EACnBC,SAAS;EACTC,aAAanB,MAAMiB,QAAQ,CAAA;EAC3BG,cAAcpB,MAAMiB,QAAQ,CAAA;AAC9B,EAAA;;;ACzCA,SAASI,eAAe;AACxB,SAASC,wBAAwB;AAG1B,IAAMC,wBAAwB,8BAAOC,aAAa,OAAE;AAEzD,QAAMC,uBAAuB,MAAMC,QAAQC,OAAM;AAGjD,QAAMC,SAA0B,MAAMC,iBAAiBJ,sBAAsBD,UAAAA;AAC7E,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","Account","buildRandomChain","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"],"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/typeof'\nimport type { ComponentType, SVGAttributes } from 'react'\nimport React, { useMemo } from 'react'\n\nexport interface DetailsStackProps extends StackProps {\n IconComponent?: ComponentType<SVGAttributes<SVGElement>>\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 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 : <></>\n }, [IconComponent])\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 {resolvedIconComponent}\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 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\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 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 {value}\n </Typography>\n ))}\n </Stack>\n </Stack>\n )\n}\n","import { Account } from '@xyo-network/account'\nimport { buildRandomChain } from '@xyo-network/chain-protocol'\nimport type { HydratedBlock } from '@xyo-network/xl1-protocol'\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: HydratedBlock[] = 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":"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","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","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","styled","Typography","name","display","fontFamily","lineHeight","marginBottom","Stack","Typography","useTheme","React","LabelValueStack","labels","values","props","theme","useTheme","React","Stack","flexDirection","flexGrow","map","label","Typography","fontWeight","key","variant","sx","borderBottom","vars","palette","divider","opacity","alignItems","value","index","fontFamily","width","display","justifyContent","Account","buildRandomChain","buildRandomBlockChain","blockCount","initialBlockProducer","Account","random","blocks","buildRandomChain","buildRandomBlockChainBlocksOnly","chain"]}
@@ -1,2 +1,3 @@
1
1
  export * from './menu-item/index.ts';
2
+ export * from './stack/index.ts';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { StackProps } from '@mui/material';
2
+ import type { ComponentType, SVGAttributes } from 'react';
3
+ import React from 'react';
4
+ export interface DetailsStackProps extends StackProps {
5
+ IconComponent?: ComponentType<SVGAttributes<SVGElement>>;
6
+ heading?: string;
7
+ tooltipTitle?: string;
8
+ }
9
+ export declare const DetailsStack: React.FC<DetailsStackProps>;
10
+ //# sourceMappingURL=DetailsStack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DetailsStack.d.ts","sourceRoot":"","sources":["../../../../src/components/stack/DetailsStack.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAM/C,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO,KAAkB,MAAM,OAAO,CAAA;AAEtC,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,aAAa,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAA;IACxD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAoCpD,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { StackProps } from '@mui/material';
2
+ import React from 'react';
3
+ export interface LabelValueStackProps extends StackProps {
4
+ labels: string[];
5
+ values: (string | undefined)[];
6
+ }
7
+ export declare const LabelValueStack: React.FC<LabelValueStackProps>;
8
+ //# sourceMappingURL=LabelValueStack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LabelValueStack.d.ts","sourceRoot":"","sources":["../../../../src/components/stack/LabelValueStack.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAI/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,MAAM,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAA;CAC/B;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAsC1D,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './DetailsStack.tsx';
2
+ export * from './LabelValueStack.tsx';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stack/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,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.5.7",
4
+ "version": "1.5.9",
5
5
  "description": "XYO Layer One React SDK",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@xyo-network/account": "^3.18.0",
42
- "@xyo-network/chain-protocol": "^1.5.7",
42
+ "@xyo-network/chain-protocol": "^1.5.9",
43
43
  "@xyo-network/xl1-protocol": "^1.4.14"
44
44
  },
45
45
  "devDependencies": {
@@ -1 +1,2 @@
1
1
  export * from './menu-item/index.ts'
2
+ export * from './stack/index.ts'
@@ -0,0 +1,59 @@
1
+ import type { StackProps } from '@mui/material'
2
+ import {
3
+ Stack, styled, Tooltip, Typography,
4
+ useTheme,
5
+ } from '@mui/material'
6
+ import { isDefined } from '@xylabs/typeof'
7
+ import type { ComponentType, SVGAttributes } from 'react'
8
+ import React, { useMemo } from 'react'
9
+
10
+ export interface DetailsStackProps extends StackProps {
11
+ IconComponent?: ComponentType<SVGAttributes<SVGElement>>
12
+ heading?: string
13
+ tooltipTitle?: string
14
+ }
15
+
16
+ export const DetailsStack: React.FC<DetailsStackProps> = ({
17
+ IconComponent, heading, children, tooltipTitle, ...props
18
+ }) => {
19
+ const theme = useTheme()
20
+
21
+ const hasTooltip = isDefined(tooltipTitle)
22
+ const resolvedIconComponent = useMemo(() => {
23
+ return IconComponent
24
+ ? (
25
+ <IconComponent
26
+ style={{
27
+ /** height and marginTop adjusted to account for font not filling container with line-height: 1 */
28
+ height: '0.85rem',
29
+ marginTop: 0.5,
30
+ marginLeft: theme.spacing(1),
31
+ }}
32
+ />
33
+ )
34
+ : <></>
35
+ }, [IconComponent])
36
+
37
+ return (
38
+ <Stack direction="column" flexGrow={1} flexWrap="wrap" minWidth="1px" {...props}>
39
+ <SectionHeadingTypography>
40
+ {heading}
41
+ {hasTooltip
42
+ ? (
43
+ <Tooltip title={tooltipTitle}>
44
+ {resolvedIconComponent}
45
+ </Tooltip>
46
+ )
47
+ : resolvedIconComponent}
48
+ </SectionHeadingTypography>
49
+ {children}
50
+ </Stack>
51
+ )
52
+ }
53
+
54
+ const SectionHeadingTypography = styled(Typography, { name: 'SectionHeadingTypography' })(({ theme }) => ({
55
+ display: 'flex',
56
+ fontFamily: 'monospace',
57
+ lineHeight: 1,
58
+ marginBottom: theme.spacing(1.5),
59
+ }))
@@ -0,0 +1,50 @@
1
+ import type { StackProps } from '@mui/material'
2
+ import {
3
+ Stack, Typography, useTheme,
4
+ } from '@mui/material'
5
+ import React from 'react'
6
+
7
+ export interface LabelValueStackProps extends StackProps {
8
+ labels: string[]
9
+ values: (string | undefined)[]
10
+ }
11
+
12
+ export const LabelValueStack: React.FC<LabelValueStackProps> = ({
13
+ labels, values, ...props
14
+ }) => {
15
+ const theme = useTheme()
16
+
17
+ return (
18
+ <Stack flexDirection="row" flexGrow={1} {...props}>
19
+ <Stack>
20
+ {labels.map(label => (
21
+ <Typography
22
+ fontWeight="300"
23
+ key={label}
24
+ variant="body2"
25
+ sx={{ borderBottom: `1px solid ${theme.vars?.palette.divider}`, opacity: 0.7 }}
26
+ >
27
+ {label}
28
+ :
29
+ </Typography>
30
+ ))}
31
+ </Stack>
32
+ <Stack alignItems="end" flexGrow={1}>
33
+ {values.map((value, index) => (
34
+ <Typography
35
+ fontFamily="monospace"
36
+ variant="body2"
37
+ // Use matching label as key since values might be the same
38
+ key={labels[index]}
39
+ width="100%"
40
+ sx={{
41
+ display: 'flex', justifyContent: 'end', borderBottom: `1px solid ${theme.vars?.palette.divider}`,
42
+ }}
43
+ >
44
+ {value}
45
+ </Typography>
46
+ ))}
47
+ </Stack>
48
+ </Stack>
49
+ )
50
+ }
@@ -0,0 +1,2 @@
1
+ export * from './DetailsStack.tsx'
2
+ export * from './LabelValueStack.tsx'