@xylabs/sdk-react 2.7.5 → 2.7.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.
Files changed (119) hide show
  1. package/dist/components/AppBarEx/AppBarEx.stories.d.ts +2 -2
  2. package/dist/components/AppBarEx/AppBarEx.stories.d.ts.map +1 -1
  3. package/dist/components/AppBarEx/AppBarEx.stories.js +5 -5
  4. package/dist/components/AppBarEx/AppBarEx.stories.js.map +1 -1
  5. package/dist/components/Background.d.ts.map +1 -1
  6. package/dist/components/Background.js +0 -1
  7. package/dist/components/Background.js.map +1 -1
  8. package/dist/components/BasePage/BasePage.stories.d.ts +1 -1
  9. package/dist/components/BasePage/BasePage.stories.d.ts.map +1 -1
  10. package/dist/components/BasePage/BasePage.stories.js +3 -2
  11. package/dist/components/BasePage/BasePage.stories.js.map +1 -1
  12. package/dist/components/Breadcrumbs/BreadcrumbsEx.stories.js +1 -1
  13. package/dist/components/Breadcrumbs/BreadcrumbsEx.stories.js.map +1 -1
  14. package/dist/components/ButtonEx/ButtonEx.stories.js +1 -1
  15. package/dist/components/ButtonEx/ButtonEx.stories.js.map +1 -1
  16. package/dist/components/CookieConsent/CookieConsent.stories.js +1 -1
  17. package/dist/components/CookieConsent/CookieConsent.stories.js.map +1 -1
  18. package/dist/components/Errors/ErrorViewer.stories.js +1 -1
  19. package/dist/components/Errors/ErrorViewer.stories.js.map +1 -1
  20. package/dist/components/Errors/ErrorsViewer.stories.js +1 -1
  21. package/dist/components/Errors/ErrorsViewer.stories.js.map +1 -1
  22. package/dist/components/EthAccount/EthAccount.d.ts.map +1 -1
  23. package/dist/components/EthAccount/EthAccount.js +30 -10
  24. package/dist/components/EthAccount/EthAccount.js.map +1 -1
  25. package/dist/components/EthAccount/EthAccount.stories.d.ts +7 -2
  26. package/dist/components/EthAccount/EthAccount.stories.d.ts.map +1 -1
  27. package/dist/components/EthAccount/EthAccount.stories.js +44 -6
  28. package/dist/components/EthAccount/EthAccount.stories.js.map +1 -1
  29. package/dist/components/EthAccount/EthAccountProps.d.ts +5 -7
  30. package/dist/components/EthAccount/EthAccountProps.d.ts.map +1 -1
  31. package/dist/components/FlexBox/BusyBox.stories.js +1 -1
  32. package/dist/components/FlexBox/BusyBox.stories.js.map +1 -1
  33. package/dist/components/FlexBox/FlexCol.stories.js +1 -1
  34. package/dist/components/FlexBox/FlexCol.stories.js.map +1 -1
  35. package/dist/components/FlexBox/FlexRow.stories.js +1 -1
  36. package/dist/components/FlexBox/FlexRow.stories.js.map +1 -1
  37. package/dist/components/InvertableThemeProvider/InvertableThemeProvider.stories.js +1 -1
  38. package/dist/components/InvertableThemeProvider/InvertableThemeProvider.stories.js.map +1 -1
  39. package/dist/components/NumberStatus/NumberStatus.stories.js +1 -1
  40. package/dist/components/NumberStatus/NumberStatus.stories.js.map +1 -1
  41. package/dist/components/QuickTipButton/QuickTipButton.stories.js +1 -1
  42. package/dist/components/QuickTipButton/QuickTipButton.stories.js.map +1 -1
  43. package/dist/components/ScrollToTop.d.ts +2 -0
  44. package/dist/components/ScrollToTop.d.ts.map +1 -0
  45. package/dist/components/ScrollToTop.js +11 -0
  46. package/dist/components/ScrollToTop.js.map +1 -0
  47. package/dist/components/TokenAmount/TokenAmount.stories.js +1 -1
  48. package/dist/components/TokenAmount/TokenAmount.stories.js.map +1 -1
  49. package/dist/components/dialogs/ErrorDialog.d.ts +4 -4
  50. package/dist/components/dialogs/ErrorDialog.d.ts.map +1 -1
  51. package/dist/components/dialogs/ErrorDialog.js +21 -11
  52. package/dist/components/dialogs/ErrorDialog.js.map +1 -1
  53. package/dist/components/dialogs/ErrorDialog.stories.d.ts +7 -0
  54. package/dist/components/dialogs/ErrorDialog.stories.d.ts.map +1 -0
  55. package/dist/components/dialogs/ErrorDialog.stories.js +22 -0
  56. package/dist/components/dialogs/ErrorDialog.stories.js.map +1 -0
  57. package/dist/components/dialogs/MessageDialog.d.ts +2 -3
  58. package/dist/components/dialogs/MessageDialog.d.ts.map +1 -1
  59. package/dist/components/dialogs/MessageDialog.js +1 -2
  60. package/dist/components/dialogs/MessageDialog.js.map +1 -1
  61. package/dist/components/dialogs/MessageDialog.stories.d.ts +7 -0
  62. package/dist/components/dialogs/MessageDialog.stories.d.ts.map +1 -0
  63. package/dist/components/dialogs/MessageDialog.stories.js +22 -0
  64. package/dist/components/dialogs/MessageDialog.stories.js.map +1 -0
  65. package/dist/components/index.d.ts +1 -0
  66. package/dist/components/index.d.ts.map +1 -1
  67. package/dist/components/index.js +1 -1
  68. package/dist/components/index.js.map +1 -1
  69. package/dist/hooks/index.d.ts +2 -1
  70. package/dist/hooks/index.d.ts.map +1 -1
  71. package/dist/hooks/index.js +2 -1
  72. package/dist/hooks/index.js.map +1 -1
  73. package/dist/hooks/useBreakpoint.d.ts.map +1 -1
  74. package/dist/hooks/useBreakpoint.js +2 -1
  75. package/dist/hooks/useBreakpoint.js.map +1 -1
  76. package/dist/hooks/useMediaQuery.d.ts +3 -0
  77. package/dist/hooks/useMediaQuery.d.ts.map +1 -0
  78. package/dist/hooks/useMediaQuery.js +5 -0
  79. package/dist/hooks/useMediaQuery.js.map +1 -0
  80. package/dist/lib/getApiStage.d.ts +1 -1
  81. package/dist/lib/getApiStage.d.ts.map +1 -1
  82. package/package.json +14 -16
  83. package/src/components/AppBarEx/AppBarEx.stories.tsx +5 -5
  84. package/src/components/Background.tsx +0 -1
  85. package/src/components/BasePage/BasePage.stories.tsx +3 -2
  86. package/src/components/Breadcrumbs/BreadcrumbsEx.stories.tsx +1 -1
  87. package/src/components/ButtonEx/ButtonEx.stories.tsx +1 -1
  88. package/src/components/CookieConsent/CookieConsent.stories.tsx +1 -1
  89. package/src/components/Errors/ErrorViewer.stories.tsx +1 -1
  90. package/src/components/Errors/ErrorsViewer.stories.tsx +1 -1
  91. package/src/components/EthAccount/EthAccount.stories.tsx +53 -6
  92. package/src/components/EthAccount/EthAccount.tsx +71 -7
  93. package/src/components/EthAccount/EthAccountProps.tsx +6 -7
  94. package/src/components/FlexBox/BusyBox.stories.tsx +1 -1
  95. package/src/components/FlexBox/FlexCol.stories.tsx +1 -1
  96. package/src/components/FlexBox/FlexRow.stories.tsx +1 -1
  97. package/src/components/InvertableThemeProvider/InvertableThemeProvider.stories.tsx +1 -1
  98. package/src/components/NumberStatus/NumberStatus.stories.tsx +1 -1
  99. package/src/components/QuickTipButton/QuickTipButton.stories.tsx +1 -1
  100. package/src/components/ScrollToTop.tsx +13 -0
  101. package/src/components/TokenAmount/TokenAmount.stories.tsx +1 -1
  102. package/src/components/dialogs/ErrorDialog.stories.tsx +27 -0
  103. package/src/components/dialogs/ErrorDialog.tsx +14 -14
  104. package/src/components/dialogs/MessageDialog.stories.tsx +27 -0
  105. package/src/components/dialogs/MessageDialog.tsx +2 -4
  106. package/src/components/index.ts +1 -1
  107. package/src/hooks/index.ts +2 -1
  108. package/src/hooks/useBreakpoint.ts +3 -1
  109. package/src/hooks/useMediaQuery.ts +6 -0
  110. package/dist/components/EthAccount/EthAccountBase.d.ts +0 -5
  111. package/dist/components/EthAccount/EthAccountBase.d.ts.map +0 -1
  112. package/dist/components/EthAccount/EthAccountBase.js +0 -41
  113. package/dist/components/EthAccount/EthAccountBase.js.map +0 -1
  114. package/dist/components/EthAccount/EthAccountTo.d.ts +0 -5
  115. package/dist/components/EthAccount/EthAccountTo.d.ts.map +0 -1
  116. package/dist/components/EthAccount/EthAccountTo.js +0 -30
  117. package/dist/components/EthAccount/EthAccountTo.js.map +0 -1
  118. package/src/components/EthAccount/EthAccountBase.tsx +0 -59
  119. package/src/components/EthAccount/EthAccountTo.tsx +0 -30
@@ -1,13 +1,77 @@
1
- import { EthAccountBase } from './EthAccountBase'
1
+ import { Typography, useTheme } from '@mui/material'
2
+ import { assertEx, EthAddress } from '@xylabs/sdk-js'
3
+ import { MouseEvent, useContext } from 'react'
4
+
5
+ import { EthersContext } from '../../contexts'
6
+ import { useMediaQuery } from '../../hooks'
7
+ import { ButtonEx } from '../ButtonEx'
8
+ import { FlexGrowRow, FlexRow } from '../FlexBox'
9
+ import { Identicon } from '../Identicon'
2
10
  import { EthAccountProps } from './EthAccountProps'
3
- import { EthAccountTo } from './EthAccountTo'
4
11
 
5
- const EthAccount: React.FC<EthAccountProps> = ({ to, toOptions, ...props }) => {
6
- if (to || toOptions) {
7
- return <EthAccountTo to={to} toOptions={toOptions} {...props} />
8
- } else {
9
- return <EthAccountBase {...props} />
12
+ const EthAccount: React.FC<EthAccountProps> = ({
13
+ address,
14
+ icon = false,
15
+ iconSize = 16,
16
+ iconOnly = false,
17
+ addressLength = 'auto',
18
+ fontFamily = '"Source Code Pro",monospace',
19
+ toEtherScan,
20
+ onButtonClick,
21
+ ...props
22
+ }) => {
23
+ const { localAddress } = useContext(EthersContext)
24
+ const theme = useTheme()
25
+
26
+ const large = useMediaQuery(theme.breakpoints.up('md'))
27
+
28
+ const isLocalAddress = address ? localAddress?.toString() === address.toString() : false
29
+
30
+ const onClickLocal = (event: MouseEvent<HTMLButtonElement>) => {
31
+ onButtonClick?.(event)
32
+ if (toEtherScan && address) {
33
+ window.open(`https://etherscan.io/address/${address.toString()}`, '_blank')
34
+ }
10
35
  }
36
+
37
+ const addressToDisplay = assertEx(address ?? EthAddress.fromString('0x00'), 'Bad Eth Address')
38
+
39
+ const testToDisplay =
40
+ addressLength === 'long'
41
+ ? addressToDisplay.toString()
42
+ : addressLength === 'short'
43
+ ? addressToDisplay.toShortString()
44
+ : large
45
+ ? addressToDisplay.toString()
46
+ : addressToDisplay.toShortString()
47
+
48
+ // Note: We use the all zero address for spacing in case it is
49
+
50
+ return (
51
+ <ButtonEx onClick={onClickLocal} title={`0x${address?.toHex()}`} {...props}>
52
+ <FlexGrowRow justifyContent="space-between" alignItems="center">
53
+ {icon ? <Identicon size={iconSize} value={address?.toHex()} /> : null}
54
+ {iconOnly ? null : (
55
+ <FlexRow>
56
+ <Typography
57
+ marginLeft={icon ? 1 : 0}
58
+ variant="body1"
59
+ fontFamily={fontFamily}
60
+ visibility={address ? 'inherit' : 'hidden'}
61
+ >
62
+ {testToDisplay}
63
+ </Typography>
64
+ {address ? null : (
65
+ <Typography position="absolute" marginLeft={icon ? 1 : 0} variant="body1" fontFamily={fontFamily}>
66
+ -- --
67
+ </Typography>
68
+ )}
69
+ </FlexRow>
70
+ )}
71
+ {isLocalAddress ? <FlexRow marginLeft={0.5}>(You)</FlexRow> : null}
72
+ </FlexGrowRow>
73
+ </ButtonEx>
74
+ )
11
75
  }
12
76
 
13
77
  export { EthAccount }
@@ -1,20 +1,19 @@
1
- import { BoxProps } from '@mui/material'
2
1
  import { EthAddress } from '@xylabs/sdk-js'
3
2
  import { MouseEventHandler } from 'react'
4
- import { NavigateOptions, To } from 'react-router-dom'
5
3
 
6
- interface EthAccountProps extends BoxProps {
4
+ import { ButtonExProps } from '../ButtonEx'
5
+
6
+ interface EthAccountProps extends ButtonExProps {
7
7
  address?: EthAddress | null
8
- auto?: boolean
8
+ addressLength?: 'auto' | 'short' | 'long'
9
9
  full?: boolean
10
10
  icon?: boolean
11
+ iconSize?: number
11
12
  iconOnly?: boolean
12
- size?: number
13
13
  text?: boolean
14
- to?: To
15
- toOptions?: NavigateOptions
16
14
  page?: string
17
15
  toEtherScan?: boolean
16
+ fontFamily?: string
18
17
  onButtonClick?: MouseEventHandler<HTMLButtonElement>
19
18
  }
20
19
 
@@ -10,7 +10,7 @@ const StorybookEntry = {
10
10
  page: null,
11
11
  },
12
12
  },
13
- title: 'BusyBox',
13
+ title: 'Components/BusyBox',
14
14
  } as ComponentMeta<typeof BusyBox>
15
15
 
16
16
  const BusyBoxTemplate: ComponentStory<typeof BusyBox> = (args) => <BusyBox {...args}></BusyBox>
@@ -11,7 +11,7 @@ const StorybookEntry = {
11
11
  page: null,
12
12
  },
13
13
  },
14
- title: 'FlexCol',
14
+ title: 'Components/FlexCol',
15
15
  } as ComponentMeta<typeof FlexCol>
16
16
 
17
17
  const Template: ComponentStory<typeof FlexCol> = (args) => <FlexCol {...args}></FlexCol>
@@ -11,7 +11,7 @@ const StorybookEntry = {
11
11
  page: null,
12
12
  },
13
13
  },
14
- title: 'FlexRow',
14
+ title: 'Components/FlexRow',
15
15
  } as ComponentMeta<typeof FlexRow>
16
16
 
17
17
  const Template: ComponentStory<typeof FlexRow> = (args) => <FlexRow {...args}></FlexRow>
@@ -10,7 +10,7 @@ const StorybookEntry = {
10
10
  page: null,
11
11
  },
12
12
  },
13
- title: 'InvertableThemeProvider',
13
+ title: 'Components/InvertableThemeProvider',
14
14
  } as ComponentMeta<typeof InvertableThemeProvider>
15
15
 
16
16
  const Template: ComponentStory<typeof InvertableThemeProvider> = (args) => (
@@ -10,7 +10,7 @@ const StorybookEntry = {
10
10
  page: null,
11
11
  },
12
12
  },
13
- title: 'NumberStatus',
13
+ title: 'Components/NumberStatus',
14
14
  } as ComponentMeta<typeof NumberStatus>
15
15
 
16
16
  const NumberStatusTemplate: ComponentStory<typeof NumberStatus> = (args) => <NumberStatus {...args}></NumberStatus>
@@ -11,7 +11,7 @@ const StorybookEntry = {
11
11
  page: null,
12
12
  },
13
13
  },
14
- title: 'QuickTipButton',
14
+ title: 'Components/QuickTipButton',
15
15
  } as ComponentMeta<typeof QuickTipButton>
16
16
 
17
17
  const Template: ComponentStory<typeof QuickTipButton> = (args) => <QuickTipButton {...args}></QuickTipButton>
@@ -0,0 +1,13 @@
1
+ import { useEffect } from 'react'
2
+ import { useLocation } from 'react-router-dom'
3
+
4
+ // The point of this component it to return to the top of the page on any router navigate
5
+
6
+ export const ScrollToTop = () => {
7
+ const { pathname } = useLocation()
8
+ useEffect(() => {
9
+ window.scrollTo(0, 0)
10
+ }, [pathname])
11
+
12
+ return null
13
+ }
@@ -11,7 +11,7 @@ const StorybookEntry = {
11
11
  page: null,
12
12
  },
13
13
  },
14
- title: 'TokenAmount',
14
+ title: 'Components/TokenAmount',
15
15
  } as ComponentMeta<typeof TokenAmount>
16
16
 
17
17
  const Template: ComponentStory<typeof TokenAmount> = (args) => <TokenAmount {...args}></TokenAmount>
@@ -0,0 +1,27 @@
1
+ import { ComponentMeta, ComponentStory } from '@storybook/react'
2
+
3
+ import { ErrorDialog } from './ErrorDialog'
4
+
5
+ const StorybookEntry = {
6
+ argTypes: {},
7
+ component: ErrorDialog,
8
+ parameters: {
9
+ docs: {
10
+ page: null,
11
+ },
12
+ },
13
+ title: 'Dialogs/ErrorDialog',
14
+ } as ComponentMeta<typeof ErrorDialog>
15
+
16
+ const Template: ComponentStory<typeof ErrorDialog> = (args) => <ErrorDialog {...args}></ErrorDialog>
17
+
18
+ const Default = Template.bind({})
19
+ Default.args = {
20
+ error: Error('Test Error'),
21
+ title: 'Test Error',
22
+ }
23
+
24
+ export { Default }
25
+
26
+ // eslint-disable-next-line import/no-default-export
27
+ export default StorybookEntry
@@ -1,13 +1,13 @@
1
- import { Dialog, DialogActions, DialogContent, DialogTitle, Typography } from '@mui/material'
1
+ import { Dialog, DialogActions, DialogContent, DialogProps, DialogTitle, Typography } from '@mui/material'
2
2
  import { AxiosError } from 'axios'
3
3
  import React from 'react'
4
4
 
5
5
  import { ButtonEx } from '../ButtonEx'
6
6
  import { FlexRow } from '../FlexBox'
7
7
 
8
- interface Props {
8
+ export interface ErrorDialogProps extends DialogProps {
9
9
  error?: Error
10
- onClose?: (retry: boolean) => void
10
+ onAction?: (retry: boolean) => void
11
11
  title?: string
12
12
  }
13
13
 
@@ -15,22 +15,25 @@ const toAxiosError = (error: Error) => {
15
15
  return (error as AxiosError).isAxiosError ? (error as AxiosError) : undefined
16
16
  }
17
17
 
18
- const ErrorDialogOpen: React.FC<Props> = (props) => {
19
- const { onClose, title = 'Oops. Something went wrong.', error = Error('Unknown Error') } = props
20
-
18
+ const ErrorDialogOpen: React.FC<ErrorDialogProps> = ({
19
+ onAction,
20
+ title = 'Oops. Something went wrong.',
21
+ error = Error('Unknown Error'),
22
+ ...props
23
+ }) => {
21
24
  const onCloseClicked = () => {
22
- onClose?.(false)
25
+ onAction?.(false)
23
26
  }
24
27
 
25
28
  const onRetryClicked = () => {
26
- onClose?.(true)
29
+ onAction?.(true)
27
30
  }
28
31
 
29
32
  const axiosError = toAxiosError(error)
30
33
  const message = error.message ?? error.toString()
31
34
 
32
35
  return (
33
- <Dialog onClose={onClose} open={!!error}>
36
+ <Dialog {...props}>
34
37
  <DialogTitle>{title}</DialogTitle>
35
38
  <DialogContent>
36
39
  <FlexRow>
@@ -53,13 +56,10 @@ const ErrorDialogOpen: React.FC<Props> = (props) => {
53
56
  )
54
57
  }
55
58
 
56
- const ErrorDialog: React.FC<Props> = (props) => {
57
- const { error } = props
59
+ export const ErrorDialog: React.FC<ErrorDialogProps> = ({ open, error, ...props }) => {
58
60
  if (error) {
59
- return <ErrorDialogOpen {...props} />
61
+ return <ErrorDialogOpen open={!!error || open} error={error} {...props} />
60
62
  } else {
61
63
  return null
62
64
  }
63
65
  }
64
-
65
- export { ErrorDialog }
@@ -0,0 +1,27 @@
1
+ import { ComponentMeta, ComponentStory } from '@storybook/react'
2
+
3
+ import { MessageDialog } from './MessageDialog'
4
+
5
+ const StorybookEntry = {
6
+ argTypes: {},
7
+ component: MessageDialog,
8
+ parameters: {
9
+ docs: {
10
+ page: null,
11
+ },
12
+ },
13
+ title: 'Dialogs/MessageDialog',
14
+ } as ComponentMeta<typeof MessageDialog>
15
+
16
+ const Template: ComponentStory<typeof MessageDialog> = (args) => <MessageDialog {...args}>Test Message</MessageDialog>
17
+
18
+ const Default = Template.bind({})
19
+ Default.args = {
20
+ open: true,
21
+ title: 'Test Error',
22
+ }
23
+
24
+ export { Default }
25
+
26
+ // eslint-disable-next-line import/no-default-export
27
+ export default StorybookEntry
@@ -2,12 +2,12 @@ import { Button, Dialog, DialogActions, DialogContent, DialogProps, DialogTitle
2
2
 
3
3
  import { FlexCol, FlexRow } from '../FlexBox'
4
4
 
5
- interface Props extends DialogProps {
5
+ export interface MessageDialogProps extends DialogProps {
6
6
  onOk?: () => void
7
7
  onCancel?: () => void
8
8
  }
9
9
 
10
- const MessageDialog: React.FC<Props> = ({ onOk, onCancel, children, title, ...props }) => {
10
+ export const MessageDialog: React.FC<MessageDialogProps> = ({ onOk, onCancel, children, title, ...props }) => {
11
11
  return (
12
12
  <Dialog {...props}>
13
13
  <DialogTitle>{title}</DialogTitle>
@@ -27,5 +27,3 @@ const MessageDialog: React.FC<Props> = ({ onOk, onCancel, children, title, ...pr
27
27
  </Dialog>
28
28
  )
29
29
  }
30
-
31
- export { MessageDialog }
@@ -19,7 +19,7 @@ export * from './LinkEx'
19
19
  export * from './NumberStatus'
20
20
  export * from './QuickTipButton'
21
21
  export * from './RichResult'
22
+ export * from './ScrollToTop'
22
23
  export * from './TokenAmount'
23
24
 
24
- // eslint-disable-next-line @delagen/deprecation/deprecation
25
25
  export { Background, CoverProgress, HoverScale, Identicon, RedirectWithQuery, ScrollToTopButton }
@@ -1,6 +1,7 @@
1
1
  import { useBreakpoint } from './useBreakpoint'
2
+ import { useMediaQuery } from './useMediaQuery'
2
3
  import { useMounted } from './useMounted'
3
4
  import { useNavigateToEthAddress } from './useNavigateToEthAddress'
4
5
  import { useWindowSize } from './useWindowSize'
5
6
 
6
- export { useBreakpoint, useMounted, useNavigateToEthAddress, useWindowSize }
7
+ export { useBreakpoint, useMediaQuery, useMounted, useNavigateToEthAddress, useWindowSize }
@@ -1,4 +1,6 @@
1
- import { useMediaQuery, useTheme } from '@mui/material'
1
+ import { useTheme } from '@mui/material'
2
+
3
+ import { useMediaQuery } from './useMediaQuery'
2
4
 
3
5
  const useBreakpoint = () => {
4
6
  const theme = useTheme()
@@ -0,0 +1,6 @@
1
+ /* eslint-disable import/no-deprecated */
2
+ import { useMediaQuery } from '@mui/material'
3
+
4
+ export { useMediaQuery }
5
+
6
+ /* file exists to deal with false warning */
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { EthAccountProps } from './EthAccountProps';
3
- declare const EthAccountBase: React.FC<EthAccountProps>;
4
- export { EthAccountBase };
5
- //# sourceMappingURL=EthAccountBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EthAccountBase.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccountBase.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA+C7C,CAAA;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -1,41 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { Typography, useMediaQuery, useTheme } from '@mui/material';
14
- import { useContext } from 'react';
15
- import { EthersContext } from '../../contexts';
16
- import { ButtonEx } from '../ButtonEx';
17
- import { FlexGrowRow, FlexRow } from '../FlexBox';
18
- import { Identicon } from '../Identicon';
19
- const EthAccountBase = (_a) => {
20
- var { address, icon = false, iconOnly = false, full = false, auto, size = 16, toEtherScan, onButtonClick } = _a, props = __rest(_a, ["address", "icon", "iconOnly", "full", "auto", "size", "toEtherScan", "onButtonClick"]);
21
- const { localAddress } = useContext(EthersContext);
22
- const theme = useTheme();
23
- const large = useMediaQuery(theme.breakpoints.up('md'));
24
- const fontFamily = '"Source Code Pro",monospace';
25
- if (address) {
26
- const isLocalAddress = (localAddress === null || localAddress === void 0 ? void 0 : localAddress.toString()) === address.toString();
27
- const onClickLocal = (event) => {
28
- onButtonClick === null || onButtonClick === void 0 ? void 0 : onButtonClick(event);
29
- if (toEtherScan) {
30
- window.open(`https://etherscan.io/address/${address.toString()}`, '_blank');
31
- }
32
- };
33
- const testToDisplay = full || !auto ? address.toString() : large ? address.toString() : address.toShortString();
34
- return (_jsx(FlexRow, Object.assign({ margin: 0.5, padding: 0.5, title: `0x${address === null || address === void 0 ? void 0 : address.toHex()}` }, props, { children: _jsx(ButtonEx, Object.assign({ fullWidth: true, onClick: onClickLocal, variant: "outlined" }, { children: _jsxs(FlexGrowRow, Object.assign({ justifyContent: "space-between", alignItems: "center" }, { children: [icon ? _jsx(Identicon, { size: size, value: address === null || address === void 0 ? void 0 : address.toHex() }, void 0) : null, iconOnly ? null : (_jsx(Typography, Object.assign({ variant: "body1", fontFamily: fontFamily, style: { textTransform: 'none' } }, { children: testToDisplay }), void 0)), isLocalAddress ? _jsx(FlexRow, Object.assign({ marginLeft: 0.5 }, { children: "(You)" }), void 0) : null] }), void 0) }), void 0) }), void 0));
35
- }
36
- else {
37
- return _jsx(FlexRow, Object.assign({}, props, { children: ' - - ' }), void 0);
38
- }
39
- };
40
- export { EthAccountBase };
41
- //# sourceMappingURL=EthAccountBase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EthAccountBase.js","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccountBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAc,UAAU,EAAE,MAAM,OAAO,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGxC,MAAM,cAAc,GAA8B,CAAC,EAUlD,EAAE,EAAE;QAV8C,EACjD,OAAO,EACP,IAAI,GAAG,KAAK,EACZ,QAAQ,GAAG,KAAK,EAChB,IAAI,GAAG,KAAK,EACZ,IAAI,EACJ,IAAI,GAAG,EAAE,EACT,WAAW,EACX,aAAa,OAEd,EADI,KAAK,cATyC,uFAUlD,CADS;IAER,MAAM,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,CAAA;IAClD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IAExB,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IACvD,MAAM,UAAU,GAAG,6BAA6B,CAAA;IAEhD,IAAI,OAAO,EAAE;QACX,MAAM,cAAc,GAAG,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ,EAAE,MAAK,OAAO,CAAC,QAAQ,EAAE,CAAA;QAEtE,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,EAAE;YAC5D,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,KAAK,CAAC,CAAA;YACtB,IAAI,WAAW,EAAE;gBACf,MAAM,CAAC,IAAI,CAAC,gCAAgC,OAAO,CAAC,QAAQ,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;aAC5E;QACH,CAAC,CAAA;QAED,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,CAAA;QAE/G,OAAO,CACL,KAAC,OAAO,kBAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,EAAE,EAAE,IAAM,KAAK,cAC3E,KAAC,QAAQ,kBAAC,SAAS,QAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAC,UAAU,gBAC3D,MAAC,WAAW,kBAAC,cAAc,EAAC,eAAe,EAAC,UAAU,EAAC,QAAQ,iBAC5D,IAAI,CAAC,CAAC,CAAC,KAAC,SAAS,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,EAAE,WAAI,CAAC,CAAC,CAAC,IAAI,EAChE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACjB,KAAC,UAAU,kBAAC,OAAO,EAAC,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,gBACjF,aAAa,YACH,CACd,EACA,cAAc,CAAC,CAAC,CAAC,KAAC,OAAO,kBAAC,UAAU,EAAE,GAAG,mCAAiB,CAAC,CAAC,CAAC,IAAI,aACtD,YACL,YACH,CACX,CAAA;KACF;SAAM;QACL,OAAO,KAAC,OAAO,oBAAK,KAAK,cAAG,OAAO,YAAW,CAAA;KAC/C;AACH,CAAC,CAAA;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { EthAccountProps } from './EthAccountProps';
3
- declare const EthAccountTo: React.FC<EthAccountProps>;
4
- export { EthAccountTo };
5
- //# sourceMappingURL=EthAccountTo.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EthAccountTo.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccountTo.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqB3C,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -1,30 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { useNavigateToEthAddress } from '../../hooks';
14
- import { EthAccountBase } from './EthAccountBase';
15
- const EthAccountTo = (_a) => {
16
- var { address, to, page, toOptions, toEtherScan, onButtonClick } = _a, props = __rest(_a, ["address", "to", "page", "toOptions", "toEtherScan", "onButtonClick"]);
17
- const { navigateToEthAddress } = useNavigateToEthAddress();
18
- if (address) {
19
- const localOnClick = (event) => {
20
- onButtonClick === null || onButtonClick === void 0 ? void 0 : onButtonClick(event);
21
- if (to) {
22
- navigateToEthAddress(address, event, page, to, toOptions, toEtherScan);
23
- }
24
- };
25
- return _jsx(EthAccountBase, Object.assign({ onButtonClick: localOnClick }, props), void 0);
26
- }
27
- return null;
28
- };
29
- export { EthAccountTo };
30
- //# sourceMappingURL=EthAccountTo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EthAccountTo.js","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccountTo.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGjD,MAAM,YAAY,GAA8B,CAAC,EAQhD,EAAE,EAAE;QAR4C,EAC/C,OAAO,EACP,EAAE,EACF,IAAI,EACJ,SAAS,EACT,WAAW,EACX,aAAa,OAEd,EADI,KAAK,cAPuC,sEAQhD,CADS;IAER,MAAM,EAAE,oBAAoB,EAAE,GAAG,uBAAuB,EAAE,CAAA;IAC1D,IAAI,OAAO,EAAE;QACX,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,EAAE;YAC5D,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,KAAK,CAAC,CAAA;YACtB,IAAI,EAAE,EAAE;gBACN,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;aACvE;QACH,CAAC,CAAA;QAED,OAAO,KAAC,cAAc,kBAAC,aAAa,EAAE,YAAY,IAAM,KAAK,UAAI,CAAA;KAClE;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -1,59 +0,0 @@
1
- import { Typography, useMediaQuery, useTheme } from '@mui/material'
2
- import { MouseEvent, useContext } from 'react'
3
-
4
- import { EthersContext } from '../../contexts'
5
- import { ButtonEx } from '../ButtonEx'
6
- import { FlexGrowRow, FlexRow } from '../FlexBox'
7
- import { Identicon } from '../Identicon'
8
- import { EthAccountProps } from './EthAccountProps'
9
-
10
- const EthAccountBase: React.FC<EthAccountProps> = ({
11
- address,
12
- icon = false,
13
- iconOnly = false,
14
- full = false,
15
- auto,
16
- size = 16,
17
- toEtherScan,
18
- onButtonClick,
19
- ...props
20
- }) => {
21
- const { localAddress } = useContext(EthersContext)
22
- const theme = useTheme()
23
-
24
- const large = useMediaQuery(theme.breakpoints.up('md'))
25
- const fontFamily = '"Source Code Pro",monospace'
26
-
27
- if (address) {
28
- const isLocalAddress = localAddress?.toString() === address.toString()
29
-
30
- const onClickLocal = (event: MouseEvent<HTMLButtonElement>) => {
31
- onButtonClick?.(event)
32
- if (toEtherScan) {
33
- window.open(`https://etherscan.io/address/${address.toString()}`, '_blank')
34
- }
35
- }
36
-
37
- const testToDisplay = full || !auto ? address.toString() : large ? address.toString() : address.toShortString()
38
-
39
- return (
40
- <FlexRow margin={0.5} padding={0.5} title={`0x${address?.toHex()}`} {...props}>
41
- <ButtonEx fullWidth onClick={onClickLocal} variant="outlined">
42
- <FlexGrowRow justifyContent="space-between" alignItems="center">
43
- {icon ? <Identicon size={size} value={address?.toHex()} /> : null}
44
- {iconOnly ? null : (
45
- <Typography variant="body1" fontFamily={fontFamily} style={{ textTransform: 'none' }}>
46
- {testToDisplay}
47
- </Typography>
48
- )}
49
- {isLocalAddress ? <FlexRow marginLeft={0.5}>(You)</FlexRow> : null}
50
- </FlexGrowRow>
51
- </ButtonEx>
52
- </FlexRow>
53
- )
54
- } else {
55
- return <FlexRow {...props}>{' - - '}</FlexRow>
56
- }
57
- }
58
-
59
- export { EthAccountBase }
@@ -1,30 +0,0 @@
1
- import { MouseEvent } from 'react'
2
-
3
- import { useNavigateToEthAddress } from '../../hooks'
4
- import { EthAccountBase } from './EthAccountBase'
5
- import { EthAccountProps } from './EthAccountProps'
6
-
7
- const EthAccountTo: React.FC<EthAccountProps> = ({
8
- address,
9
- to,
10
- page,
11
- toOptions,
12
- toEtherScan,
13
- onButtonClick,
14
- ...props
15
- }) => {
16
- const { navigateToEthAddress } = useNavigateToEthAddress()
17
- if (address) {
18
- const localOnClick = (event: MouseEvent<HTMLButtonElement>) => {
19
- onButtonClick?.(event)
20
- if (to) {
21
- navigateToEthAddress(address, event, page, to, toOptions, toEtherScan)
22
- }
23
- }
24
-
25
- return <EthAccountBase onButtonClick={localOnClick} {...props} />
26
- }
27
- return null
28
- }
29
-
30
- export { EthAccountTo }