@xylabs/sdk-react 2.7.3 → 2.7.7
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/README.md +29 -9
- package/dist/components/AppBarEx/AppBarEx.stories.d.ts +2 -2
- package/dist/components/AppBarEx/AppBarEx.stories.d.ts.map +1 -1
- package/dist/components/AppBarEx/AppBarEx.stories.js +5 -5
- package/dist/components/AppBarEx/AppBarEx.stories.js.map +1 -1
- package/dist/components/Background.d.ts.map +1 -1
- package/dist/components/Background.js +0 -1
- package/dist/components/Background.js.map +1 -1
- package/dist/components/BasePage/BasePage.d.ts.map +1 -1
- package/dist/components/BasePage/BasePage.js +1 -1
- package/dist/components/BasePage/BasePage.js.map +1 -1
- package/dist/components/BasePage/BasePage.stories.d.ts +1 -1
- package/dist/components/BasePage/BasePage.stories.d.ts.map +1 -1
- package/dist/components/BasePage/BasePage.stories.js +3 -2
- package/dist/components/BasePage/BasePage.stories.js.map +1 -1
- package/dist/components/Breadcrumbs/BreadcrumbsEx.stories.js +1 -1
- package/dist/components/Breadcrumbs/BreadcrumbsEx.stories.js.map +1 -1
- package/dist/components/ButtonEx/ButtonEx.stories.js +1 -1
- package/dist/components/ButtonEx/ButtonEx.stories.js.map +1 -1
- package/dist/components/CookieConsent/CookieConsent.d.ts.map +1 -1
- package/dist/components/CookieConsent/CookieConsent.js +1 -1
- package/dist/components/CookieConsent/CookieConsent.js.map +1 -1
- package/dist/components/CookieConsent/CookieConsent.stories.js +1 -1
- package/dist/components/CookieConsent/CookieConsent.stories.js.map +1 -1
- package/dist/components/Errors/ErrorViewer.stories.js +1 -1
- package/dist/components/Errors/ErrorViewer.stories.js.map +1 -1
- package/dist/components/Errors/ErrorsViewer.stories.js +1 -1
- package/dist/components/Errors/ErrorsViewer.stories.js.map +1 -1
- package/dist/components/EthAccount/EthAccount.stories.js +1 -1
- package/dist/components/EthAccount/EthAccount.stories.js.map +1 -1
- package/dist/components/EthAccount/EthAccountBase.d.ts.map +1 -1
- package/dist/components/EthAccount/EthAccountBase.js +2 -1
- package/dist/components/EthAccount/EthAccountBase.js.map +1 -1
- package/dist/components/FlexBox/BusyBox.stories.js +1 -1
- package/dist/components/FlexBox/BusyBox.stories.js.map +1 -1
- package/dist/components/FlexBox/FlexCol.stories.js +1 -1
- package/dist/components/FlexBox/FlexCol.stories.js.map +1 -1
- package/dist/components/FlexBox/FlexRow.stories.js +1 -1
- package/dist/components/FlexBox/FlexRow.stories.js.map +1 -1
- package/dist/components/InvertableThemeProvider/InvertableThemeProvider.d.ts.map +1 -1
- package/dist/components/InvertableThemeProvider/InvertableThemeProvider.js +8 -9
- package/dist/components/InvertableThemeProvider/InvertableThemeProvider.js.map +1 -1
- package/dist/components/InvertableThemeProvider/InvertableThemeProvider.stories.js +1 -1
- package/dist/components/InvertableThemeProvider/InvertableThemeProvider.stories.js.map +1 -1
- package/dist/components/NumberStatus/NumberStatus.stories.js +1 -1
- package/dist/components/NumberStatus/NumberStatus.stories.js.map +1 -1
- package/dist/components/QuickTipButton/QuickTipButton.stories.js +1 -1
- package/dist/components/QuickTipButton/QuickTipButton.stories.js.map +1 -1
- package/dist/components/ScrollToTop.d.ts +2 -0
- package/dist/components/ScrollToTop.d.ts.map +1 -0
- package/dist/components/ScrollToTop.js +11 -0
- package/dist/components/ScrollToTop.js.map +1 -0
- package/dist/components/TokenAmount/TokenAmount.stories.js +1 -1
- package/dist/components/TokenAmount/TokenAmount.stories.js.map +1 -1
- package/dist/components/dialogs/ErrorDialog.d.ts +4 -4
- package/dist/components/dialogs/ErrorDialog.d.ts.map +1 -1
- package/dist/components/dialogs/ErrorDialog.js +21 -11
- package/dist/components/dialogs/ErrorDialog.js.map +1 -1
- package/dist/components/dialogs/ErrorDialog.stories.d.ts +7 -0
- package/dist/components/dialogs/ErrorDialog.stories.d.ts.map +1 -0
- package/dist/components/dialogs/ErrorDialog.stories.js +22 -0
- package/dist/components/dialogs/ErrorDialog.stories.js.map +1 -0
- package/dist/components/dialogs/MessageDialog.d.ts +2 -3
- package/dist/components/dialogs/MessageDialog.d.ts.map +1 -1
- package/dist/components/dialogs/MessageDialog.js +1 -2
- package/dist/components/dialogs/MessageDialog.js.map +1 -1
- package/dist/components/dialogs/MessageDialog.stories.d.ts +7 -0
- package/dist/components/dialogs/MessageDialog.stories.d.ts.map +1 -0
- package/dist/components/dialogs/MessageDialog.stories.js +22 -0
- package/dist/components/dialogs/MessageDialog.stories.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useBreakpoint.d.ts.map +1 -1
- package/dist/hooks/useBreakpoint.js +2 -1
- package/dist/hooks/useBreakpoint.js.map +1 -1
- package/dist/hooks/useMediaQuery.d.ts +3 -0
- package/dist/hooks/useMediaQuery.d.ts.map +1 -0
- package/dist/hooks/useMediaQuery.js +5 -0
- package/dist/hooks/useMediaQuery.js.map +1 -0
- package/dist/lib/getApiStage.d.ts +1 -1
- package/dist/lib/getApiStage.d.ts.map +1 -1
- package/package.json +71 -73
- package/src/components/AppBarEx/AppBarEx.stories.tsx +5 -5
- package/src/components/Background.tsx +0 -1
- package/src/components/BasePage/BasePage.stories.tsx +3 -2
- package/src/components/BasePage/BasePage.tsx +2 -1
- package/src/components/Breadcrumbs/BreadcrumbsEx.stories.tsx +1 -1
- package/src/components/ButtonEx/ButtonEx.stories.tsx +1 -1
- package/src/components/CookieConsent/CookieConsent.stories.tsx +1 -1
- package/src/components/CookieConsent/CookieConsent.tsx +10 -1
- package/src/components/Errors/ErrorViewer.stories.tsx +1 -1
- package/src/components/Errors/ErrorsViewer.stories.tsx +1 -1
- package/src/components/EthAccount/EthAccount.stories.tsx +1 -1
- package/src/components/EthAccount/EthAccountBase.tsx +2 -1
- package/src/components/FlexBox/BusyBox.stories.tsx +1 -1
- package/src/components/FlexBox/FlexCol.stories.tsx +1 -1
- package/src/components/FlexBox/FlexRow.stories.tsx +1 -1
- package/src/components/InvertableThemeProvider/InvertableThemeProvider.stories.tsx +1 -1
- package/src/components/InvertableThemeProvider/InvertableThemeProvider.tsx +15 -9
- package/src/components/NumberStatus/NumberStatus.stories.tsx +1 -1
- package/src/components/QuickTipButton/QuickTipButton.stories.tsx +1 -1
- package/src/components/ScrollToTop.tsx +13 -0
- package/src/components/TokenAmount/TokenAmount.stories.tsx +1 -1
- package/src/components/dialogs/ErrorDialog.stories.tsx +27 -0
- package/src/components/dialogs/ErrorDialog.tsx +14 -14
- package/src/components/dialogs/MessageDialog.stories.tsx +27 -0
- package/src/components/dialogs/MessageDialog.tsx +2 -4
- package/src/components/index.ts +1 -1
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useBreakpoint.ts +3 -1
- package/src/hooks/useMediaQuery.ts +6 -0
|
@@ -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,7 +1,8 @@
|
|
|
1
|
-
import { Typography,
|
|
1
|
+
import { Typography, useTheme } from '@mui/material'
|
|
2
2
|
import { MouseEvent, useContext } from 'react'
|
|
3
3
|
|
|
4
4
|
import { EthersContext } from '../../contexts'
|
|
5
|
+
import { useMediaQuery } from '../../hooks'
|
|
5
6
|
import { ButtonEx } from '../ButtonEx'
|
|
6
7
|
import { FlexGrowRow, FlexRow } from '../FlexBox'
|
|
7
8
|
import { Identicon } from '../Identicon'
|
|
@@ -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> = (
|
|
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
|
|
12
|
-
const { options = clone(contextInvertableTheme.options) } = props
|
|
18
|
+
const clonedOptions = clone(options ?? contextInvertableTheme.options ?? {})
|
|
13
19
|
|
|
14
|
-
|
|
20
|
+
clonedOptions.palette = clonedOptions.palette ?? {}
|
|
15
21
|
|
|
16
22
|
if (invert) {
|
|
17
|
-
|
|
23
|
+
clonedOptions.palette.mode = clonedOptions.palette.mode === 'dark' ? 'light' : 'dark'
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
if (dark !== undefined) {
|
|
21
|
-
|
|
27
|
+
clonedOptions.palette.mode = dark ? 'dark' : 'light'
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
let theme = createTheme(
|
|
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
|
|
8
|
+
export interface ErrorDialogProps extends DialogProps {
|
|
9
9
|
error?: Error
|
|
10
|
-
|
|
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<
|
|
19
|
-
|
|
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
|
-
|
|
25
|
+
onAction?.(false)
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
const onRetryClicked = () => {
|
|
26
|
-
|
|
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
|
|
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<
|
|
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
|
|
5
|
+
export interface MessageDialogProps extends DialogProps {
|
|
6
6
|
onOk?: () => void
|
|
7
7
|
onCancel?: () => void
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const MessageDialog: React.FC<
|
|
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 }
|
package/src/components/index.ts
CHANGED
|
@@ -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 }
|
package/src/hooks/index.ts
CHANGED
|
@@ -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 }
|