@xylabs/sdk-react 2.7.4 → 2.7.8

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 (124) hide show
  1. package/README.md +29 -9
  2. package/dist/components/AppBarEx/AppBarEx.stories.d.ts +2 -2
  3. package/dist/components/AppBarEx/AppBarEx.stories.d.ts.map +1 -1
  4. package/dist/components/AppBarEx/AppBarEx.stories.js +5 -5
  5. package/dist/components/AppBarEx/AppBarEx.stories.js.map +1 -1
  6. package/dist/components/Background.d.ts.map +1 -1
  7. package/dist/components/Background.js +0 -1
  8. package/dist/components/Background.js.map +1 -1
  9. package/dist/components/BasePage/BasePage.stories.d.ts +1 -1
  10. package/dist/components/BasePage/BasePage.stories.d.ts.map +1 -1
  11. package/dist/components/BasePage/BasePage.stories.js +3 -2
  12. package/dist/components/BasePage/BasePage.stories.js.map +1 -1
  13. package/dist/components/Breadcrumbs/BreadcrumbsEx.stories.js +1 -1
  14. package/dist/components/Breadcrumbs/BreadcrumbsEx.stories.js.map +1 -1
  15. package/dist/components/ButtonEx/ButtonEx.stories.js +1 -1
  16. package/dist/components/ButtonEx/ButtonEx.stories.js.map +1 -1
  17. package/dist/components/CookieConsent/CookieConsent.stories.js +1 -1
  18. package/dist/components/CookieConsent/CookieConsent.stories.js.map +1 -1
  19. package/dist/components/Errors/ErrorViewer.stories.js +1 -1
  20. package/dist/components/Errors/ErrorViewer.stories.js.map +1 -1
  21. package/dist/components/Errors/ErrorsViewer.stories.js +1 -1
  22. package/dist/components/Errors/ErrorsViewer.stories.js.map +1 -1
  23. package/dist/components/EthAccount/EthAccount.d.ts.map +1 -1
  24. package/dist/components/EthAccount/EthAccount.js +29 -7
  25. package/dist/components/EthAccount/EthAccount.js.map +1 -1
  26. package/dist/components/EthAccount/EthAccount.stories.d.ts +4 -2
  27. package/dist/components/EthAccount/EthAccount.stories.d.ts.map +1 -1
  28. package/dist/components/EthAccount/EthAccount.stories.js +23 -6
  29. package/dist/components/EthAccount/EthAccount.stories.js.map +1 -1
  30. package/dist/components/EthAccount/EthAccountProps.d.ts +5 -7
  31. package/dist/components/EthAccount/EthAccountProps.d.ts.map +1 -1
  32. package/dist/components/FlexBox/BusyBox.stories.js +1 -1
  33. package/dist/components/FlexBox/BusyBox.stories.js.map +1 -1
  34. package/dist/components/FlexBox/FlexCol.stories.js +1 -1
  35. package/dist/components/FlexBox/FlexCol.stories.js.map +1 -1
  36. package/dist/components/FlexBox/FlexRow.stories.js +1 -1
  37. package/dist/components/FlexBox/FlexRow.stories.js.map +1 -1
  38. package/dist/components/InvertableThemeProvider/InvertableThemeProvider.d.ts.map +1 -1
  39. package/dist/components/InvertableThemeProvider/InvertableThemeProvider.js +8 -9
  40. package/dist/components/InvertableThemeProvider/InvertableThemeProvider.js.map +1 -1
  41. package/dist/components/InvertableThemeProvider/InvertableThemeProvider.stories.js +1 -1
  42. package/dist/components/InvertableThemeProvider/InvertableThemeProvider.stories.js.map +1 -1
  43. package/dist/components/NumberStatus/NumberStatus.stories.js +1 -1
  44. package/dist/components/NumberStatus/NumberStatus.stories.js.map +1 -1
  45. package/dist/components/QuickTipButton/QuickTipButton.stories.js +1 -1
  46. package/dist/components/QuickTipButton/QuickTipButton.stories.js.map +1 -1
  47. package/dist/components/ScrollToTop.d.ts +2 -0
  48. package/dist/components/ScrollToTop.d.ts.map +1 -0
  49. package/dist/components/ScrollToTop.js +11 -0
  50. package/dist/components/ScrollToTop.js.map +1 -0
  51. package/dist/components/TokenAmount/TokenAmount.stories.js +1 -1
  52. package/dist/components/TokenAmount/TokenAmount.stories.js.map +1 -1
  53. package/dist/components/dialogs/ErrorDialog.d.ts +4 -4
  54. package/dist/components/dialogs/ErrorDialog.d.ts.map +1 -1
  55. package/dist/components/dialogs/ErrorDialog.js +21 -11
  56. package/dist/components/dialogs/ErrorDialog.js.map +1 -1
  57. package/dist/components/dialogs/ErrorDialog.stories.d.ts +7 -0
  58. package/dist/components/dialogs/ErrorDialog.stories.d.ts.map +1 -0
  59. package/dist/components/dialogs/ErrorDialog.stories.js +22 -0
  60. package/dist/components/dialogs/ErrorDialog.stories.js.map +1 -0
  61. package/dist/components/dialogs/MessageDialog.d.ts +2 -3
  62. package/dist/components/dialogs/MessageDialog.d.ts.map +1 -1
  63. package/dist/components/dialogs/MessageDialog.js +1 -2
  64. package/dist/components/dialogs/MessageDialog.js.map +1 -1
  65. package/dist/components/dialogs/MessageDialog.stories.d.ts +7 -0
  66. package/dist/components/dialogs/MessageDialog.stories.d.ts.map +1 -0
  67. package/dist/components/dialogs/MessageDialog.stories.js +22 -0
  68. package/dist/components/dialogs/MessageDialog.stories.js.map +1 -0
  69. package/dist/components/index.d.ts +1 -0
  70. package/dist/components/index.d.ts.map +1 -1
  71. package/dist/components/index.js +1 -1
  72. package/dist/components/index.js.map +1 -1
  73. package/dist/hooks/index.d.ts +2 -1
  74. package/dist/hooks/index.d.ts.map +1 -1
  75. package/dist/hooks/index.js +2 -1
  76. package/dist/hooks/index.js.map +1 -1
  77. package/dist/hooks/useBreakpoint.d.ts.map +1 -1
  78. package/dist/hooks/useBreakpoint.js +2 -1
  79. package/dist/hooks/useBreakpoint.js.map +1 -1
  80. package/dist/hooks/useMediaQuery.d.ts +3 -0
  81. package/dist/hooks/useMediaQuery.d.ts.map +1 -0
  82. package/dist/hooks/useMediaQuery.js +5 -0
  83. package/dist/hooks/useMediaQuery.js.map +1 -0
  84. package/dist/lib/getApiStage.d.ts +1 -1
  85. package/dist/lib/getApiStage.d.ts.map +1 -1
  86. package/package.json +72 -74
  87. package/src/components/AppBarEx/AppBarEx.stories.tsx +5 -5
  88. package/src/components/Background.tsx +0 -1
  89. package/src/components/BasePage/BasePage.stories.tsx +3 -2
  90. package/src/components/Breadcrumbs/BreadcrumbsEx.stories.tsx +1 -1
  91. package/src/components/ButtonEx/ButtonEx.stories.tsx +1 -1
  92. package/src/components/CookieConsent/CookieConsent.stories.tsx +1 -1
  93. package/src/components/Errors/ErrorViewer.stories.tsx +1 -1
  94. package/src/components/Errors/ErrorsViewer.stories.tsx +1 -1
  95. package/src/components/EthAccount/EthAccount.stories.tsx +29 -6
  96. package/src/components/EthAccount/EthAccount.tsx +57 -6
  97. package/src/components/EthAccount/EthAccountProps.tsx +6 -7
  98. package/src/components/FlexBox/BusyBox.stories.tsx +1 -1
  99. package/src/components/FlexBox/FlexCol.stories.tsx +1 -1
  100. package/src/components/FlexBox/FlexRow.stories.tsx +1 -1
  101. package/src/components/InvertableThemeProvider/InvertableThemeProvider.stories.tsx +1 -1
  102. package/src/components/InvertableThemeProvider/InvertableThemeProvider.tsx +15 -9
  103. package/src/components/NumberStatus/NumberStatus.stories.tsx +1 -1
  104. package/src/components/QuickTipButton/QuickTipButton.stories.tsx +1 -1
  105. package/src/components/ScrollToTop.tsx +13 -0
  106. package/src/components/TokenAmount/TokenAmount.stories.tsx +1 -1
  107. package/src/components/dialogs/ErrorDialog.stories.tsx +27 -0
  108. package/src/components/dialogs/ErrorDialog.tsx +14 -14
  109. package/src/components/dialogs/MessageDialog.stories.tsx +27 -0
  110. package/src/components/dialogs/MessageDialog.tsx +2 -4
  111. package/src/components/index.ts +1 -1
  112. package/src/hooks/index.ts +2 -1
  113. package/src/hooks/useBreakpoint.ts +3 -1
  114. package/src/hooks/useMediaQuery.ts +6 -0
  115. package/dist/components/EthAccount/EthAccountBase.d.ts +0 -5
  116. package/dist/components/EthAccount/EthAccountBase.d.ts.map +0 -1
  117. package/dist/components/EthAccount/EthAccountBase.js +0 -41
  118. package/dist/components/EthAccount/EthAccountBase.js.map +0 -1
  119. package/dist/components/EthAccount/EthAccountTo.d.ts +0 -5
  120. package/dist/components/EthAccount/EthAccountTo.d.ts.map +0 -1
  121. package/dist/components/EthAccount/EthAccountTo.js +0 -30
  122. package/dist/components/EthAccount/EthAccountTo.js.map +0 -1
  123. package/src/components/EthAccount/EthAccountBase.tsx +0 -59
  124. package/src/components/EthAccount/EthAccountTo.tsx +0 -30
@@ -11,7 +11,7 @@ const StorybookEntry = {
11
11
  page: null,
12
12
  },
13
13
  },
14
- title: 'BreadcrumbsEx',
14
+ title: 'Components/BreadcrumbsEx',
15
15
  } as ComponentMeta<typeof BreadcrumbsEx>
16
16
 
17
17
  const Template: ComponentStory<typeof BreadcrumbsEx> = (args) => (
@@ -11,7 +11,7 @@ const StorybookEntry = {
11
11
  page: null,
12
12
  },
13
13
  },
14
- title: 'ButtonEx',
14
+ title: 'Components/ButtonEx',
15
15
  } as ComponentMeta<typeof ButtonEx>
16
16
 
17
17
  const DefaultTemplate: ComponentStory<typeof ButtonEx> = (args) => (
@@ -13,7 +13,7 @@ const StorybookEntry = {
13
13
  page: null,
14
14
  },
15
15
  },
16
- title: 'CookieConsent',
16
+ title: 'Components/CookieConsent',
17
17
  } as ComponentMeta<typeof CookieConsent>
18
18
 
19
19
  const TemplateWithContext: ComponentStory<typeof CookieConsent> = (args) => {
@@ -10,7 +10,7 @@ const StorybookEntry = {
10
10
  page: null,
11
11
  },
12
12
  },
13
- title: 'ErrorViewer',
13
+ title: 'Components/ErrorViewer',
14
14
  } as ComponentMeta<typeof ErrorViewer>
15
15
 
16
16
  const Template: ComponentStory<typeof ErrorViewer> = (args) => <ErrorViewer {...args}></ErrorViewer>
@@ -10,7 +10,7 @@ const StorybookEntry = {
10
10
  page: null,
11
11
  },
12
12
  },
13
- title: 'ErrorsViewer',
13
+ title: 'Components/ErrorsViewer',
14
14
  } as ComponentMeta<typeof ErrorsViewer>
15
15
 
16
16
  const Template: ComponentStory<typeof ErrorsViewer> = (args) => <ErrorsViewer {...args}></ErrorsViewer>
@@ -1,6 +1,7 @@
1
1
  import { ComponentMeta, ComponentStory } from '@storybook/react'
2
2
  import { EthAddress } from '@xylabs/sdk-js'
3
3
 
4
+ import { FlexRow } from '../FlexBox'
4
5
  import { EthAccount } from './EthAccount'
5
6
 
6
7
  const StorybookEntry = {
@@ -11,21 +12,43 @@ const StorybookEntry = {
11
12
  page: null,
12
13
  },
13
14
  },
14
- title: 'EthAccount',
15
+ title: 'Components/EthAccount',
15
16
  } as ComponentMeta<typeof EthAccount>
16
17
 
17
- const Template: ComponentStory<typeof EthAccount> = (args) => <EthAccount {...args}></EthAccount>
18
+ const Template: ComponentStory<typeof EthAccount> = (args) => (
19
+ <FlexRow>
20
+ <EthAccount variant="outlined" {...args}></EthAccount>
21
+ </FlexRow>
22
+ )
18
23
 
19
- const Default = Template.bind({})
20
- Default.args = {
24
+ const Long = Template.bind({})
25
+ Long.args = {
21
26
  address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
22
- auto: true,
27
+ addressLength: 'long',
23
28
  icon: true,
24
29
  title: 'Sample EthAccount',
25
30
  toEtherScan: true,
26
31
  }
27
32
 
28
- export { Default }
33
+ const Short = Template.bind({})
34
+ Short.args = {
35
+ address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
36
+ addressLength: 'short',
37
+ icon: true,
38
+ title: 'Sample EthAccount',
39
+ toEtherScan: true,
40
+ }
41
+
42
+ const Auto = Template.bind({})
43
+ Auto.args = {
44
+ address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
45
+ addressLength: 'auto',
46
+ icon: true,
47
+ title: 'Sample EthAccount',
48
+ toEtherScan: true,
49
+ }
50
+
51
+ export { Auto, Long, Short }
29
52
 
30
53
  // eslint-disable-next-line import/no-default-export
31
54
  export default StorybookEntry
@@ -1,12 +1,63 @@
1
- import { EthAccountBase } from './EthAccountBase'
1
+ import { Typography, useTheme } from '@mui/material'
2
+ import { MouseEvent, useContext } from 'react'
3
+
4
+ import { EthersContext } from '../../contexts'
5
+ import { useMediaQuery } from '../../hooks'
6
+ import { ButtonEx } from '../ButtonEx'
7
+ import { FlexGrowRow, FlexRow } from '../FlexBox'
8
+ import { Identicon } from '../Identicon'
2
9
  import { EthAccountProps } from './EthAccountProps'
3
- import { EthAccountTo } from './EthAccountTo'
4
10
 
5
- const EthAccount: React.FC<EthAccountProps> = ({ to, toOptions, ...props }) => {
6
- if (to || toOptions) {
7
- return <EthAccountTo to={to} toOptions={toOptions} {...props} />
11
+ const EthAccount: React.FC<EthAccountProps> = ({
12
+ address,
13
+ icon = false,
14
+ iconSize = 16,
15
+ iconOnly = false,
16
+ addressLength = 'auto',
17
+ fontFamily = '"Source Code Pro",monospace',
18
+ toEtherScan,
19
+ onButtonClick,
20
+ ...props
21
+ }) => {
22
+ const { localAddress } = useContext(EthersContext)
23
+ const theme = useTheme()
24
+
25
+ const large = useMediaQuery(theme.breakpoints.up('md'))
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 =
38
+ addressLength === 'long'
39
+ ? address.toString()
40
+ : addressLength === 'short'
41
+ ? address.toShortString()
42
+ : large
43
+ ? address.toString()
44
+ : address.toShortString()
45
+
46
+ return (
47
+ <ButtonEx onClick={onClickLocal} title={`0x${address?.toHex()}`} {...props}>
48
+ <FlexGrowRow justifyContent="space-between" alignItems="center">
49
+ {icon ? <Identicon size={iconSize} value={address?.toHex()} /> : null}
50
+ {iconOnly ? null : (
51
+ <Typography marginLeft={icon ? 1 : 0} variant="body1" fontFamily={fontFamily}>
52
+ {testToDisplay}
53
+ </Typography>
54
+ )}
55
+ {isLocalAddress ? <FlexRow marginLeft={0.5}>(You)</FlexRow> : null}
56
+ </FlexGrowRow>
57
+ </ButtonEx>
58
+ )
8
59
  } else {
9
- return <EthAccountBase {...props} />
60
+ return <ButtonEx {...props}>{' - - '}</ButtonEx>
10
61
  }
11
62
  }
12
63
 
@@ -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) => (
@@ -6,22 +6,28 @@ import React, { useContext } from 'react'
6
6
  import { InvertableThemeContext } from './InvertableThemeContext'
7
7
  import { InvertableThemeProviderProps } from './InvertableThemeProviderProps'
8
8
 
9
- const InvertableThemeProvider: React.FC<InvertableThemeProviderProps> = (props) => {
9
+ const InvertableThemeProvider: React.FC<InvertableThemeProviderProps> = ({
10
+ options,
11
+ children,
12
+ dark,
13
+ scoped = false,
14
+ invert = false,
15
+ noResponsiveFonts,
16
+ }) => {
10
17
  const contextInvertableTheme = useContext(InvertableThemeContext)
11
- const { children, dark, scoped = false, invert = false, noResponsiveFonts } = props
12
- const { options = clone(contextInvertableTheme.options) } = props
18
+ const clonedOptions = clone(options ?? contextInvertableTheme.options ?? {})
13
19
 
14
- options.palette = options.palette ?? {}
20
+ clonedOptions.palette = clonedOptions.palette ?? {}
15
21
 
16
22
  if (invert) {
17
- options.palette.mode = options.palette.mode === 'dark' ? 'light' : 'dark'
23
+ clonedOptions.palette.mode = clonedOptions.palette.mode === 'dark' ? 'light' : 'dark'
18
24
  }
19
25
 
20
26
  if (dark !== undefined) {
21
- options.palette.mode = dark ? 'dark' : 'light'
27
+ clonedOptions.palette.mode = dark ? 'dark' : 'light'
22
28
  }
23
29
 
24
- let theme = createTheme(options)
30
+ let theme = createTheme(clonedOptions)
25
31
 
26
32
  if (!noResponsiveFonts) {
27
33
  theme = responsiveFontSizes(theme)
@@ -29,12 +35,12 @@ const InvertableThemeProvider: React.FC<InvertableThemeProviderProps> = (props)
29
35
 
30
36
  return scoped ? (
31
37
  <ScopedCssBaseline>
32
- <InvertableThemeContext.Provider value={{ options }}>
38
+ <InvertableThemeContext.Provider value={{ options: clonedOptions }}>
33
39
  <ThemeProvider theme={theme}>{children}</ThemeProvider>
34
40
  </InvertableThemeContext.Provider>
35
41
  </ScopedCssBaseline>
36
42
  ) : (
37
- <InvertableThemeContext.Provider value={{ options }}>
43
+ <InvertableThemeContext.Provider value={{ options: clonedOptions }}>
38
44
  <ThemeProvider theme={theme}>{children}</ThemeProvider>
39
45
  </InvertableThemeContext.Provider>
40
46
  )
@@ -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"}