@graphcommerce/next-ui 4.0.0 → 4.1.1
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/CHANGELOG.md +86 -0
- package/Form/Form.tsx +3 -1
- package/Layout/components/LayoutHeaderBack.tsx +8 -9
- package/LayoutDefault/components/LayoutDefault.tsx +4 -1
- package/LayoutParts/Logo.tsx +1 -1
- package/LayoutParts/MenuFab.tsx +6 -5
- package/LayoutParts/MenuFabItem.tsx +2 -2
- package/Page/types.ts +2 -1
- package/Theme/DarkLightModeThemeProvider.tsx +119 -0
- package/Theme/index.ts +1 -0
- package/icons/index.tsx +2 -0
- package/index.ts +0 -1
- package/package.json +25 -29
- package/ApolloError/ApolloErrorAlert.tsx +0 -58
- package/ApolloError/ApolloErrorFullPage.tsx +0 -31
- package/ApolloError/ApolloErrorSnackbar.tsx +0 -35
- package/ApolloError/index.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,91 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1274](https://github.com/ho-nl/m2-pwa/pull/1274)
|
|
8
|
+
[`381e4c86a`](https://github.com/ho-nl/m2-pwa/commit/381e4c86a8321ce96e1fa5c7d3c0a0c0ff3e02c7)
|
|
9
|
+
Thanks [@paales](https://github.com/paales)! - Moved `ApolloErrorAlert`, `ApolloErrorFullPage` and
|
|
10
|
+
`ApolloErrorSnackbar` to the ecommerce-ui package.
|
|
11
|
+
|
|
12
|
+
Created `ComposedSubmitButton` and `ComposedSubmitLinkOrButton` to reduce complexity from
|
|
13
|
+
`magento-graphcms` example.
|
|
14
|
+
|
|
15
|
+
Removed dependency an `@graphcommerce/react-hook-form` from `magento-graphcms` example.
|
|
16
|
+
|
|
17
|
+
Added dependency `@graphcommerce/ecommerce-ui` from `magento-graphcms` example.
|
|
18
|
+
|
|
19
|
+
* [#1276](https://github.com/ho-nl/m2-pwa/pull/1276)
|
|
20
|
+
[`ce09388e0`](https://github.com/ho-nl/m2-pwa/commit/ce09388e0d7ef33aee660612340f6fbae15ceec2)
|
|
21
|
+
Thanks [@paales](https://github.com/paales)! - We've moved lots of internal packages from
|
|
22
|
+
`dependencies` to `peerDependencies`. The result of this is that there will be significantly less
|
|
23
|
+
duplicate packages in the node_modules folders.
|
|
24
|
+
|
|
25
|
+
- [#1276](https://github.com/ho-nl/m2-pwa/pull/1276)
|
|
26
|
+
[`e7c8e2756`](https://github.com/ho-nl/m2-pwa/commit/e7c8e2756d637cbcd2e793d62ef5721d35d9fa7b)
|
|
27
|
+
Thanks [@paales](https://github.com/paales)! - CartFab positioning was incorrect
|
|
28
|
+
|
|
29
|
+
* [#1276](https://github.com/ho-nl/m2-pwa/pull/1276)
|
|
30
|
+
[`52a45bba4`](https://github.com/ho-nl/m2-pwa/commit/52a45bba4dc6dd6df3c81f5023df7d23ed8a534d)
|
|
31
|
+
Thanks [@paales](https://github.com/paales)! - Upgraded to
|
|
32
|
+
[NextJS 12.1](https://nextjs.org/blog/next-12-1)! This is just for compatibility, but we'll be
|
|
33
|
+
implementing
|
|
34
|
+
[On-demand Incremental Static Regeneration](https://nextjs.org/blog/next-12-1#on-demand-incremental-static-regeneration-beta)
|
|
35
|
+
soon.
|
|
36
|
+
|
|
37
|
+
This will greatly reduce the requirement to rebuid stuff and we'll add a management UI on the
|
|
38
|
+
frontend to be able to revalidate pages manually.
|
|
39
|
+
|
|
40
|
+
* Updated dependencies
|
|
41
|
+
[[`381e4c86a`](https://github.com/ho-nl/m2-pwa/commit/381e4c86a8321ce96e1fa5c7d3c0a0c0ff3e02c7),
|
|
42
|
+
[`ce09388e0`](https://github.com/ho-nl/m2-pwa/commit/ce09388e0d7ef33aee660612340f6fbae15ceec2),
|
|
43
|
+
[`52a45bba4`](https://github.com/ho-nl/m2-pwa/commit/52a45bba4dc6dd6df3c81f5023df7d23ed8a534d)]:
|
|
44
|
+
- @graphcommerce/framer-next-pages@3.0.2
|
|
45
|
+
- @graphcommerce/framer-scroller@2.0.2
|
|
46
|
+
- @graphcommerce/framer-utils@3.0.2
|
|
47
|
+
- @graphcommerce/image@3.0.2
|
|
48
|
+
|
|
49
|
+
## 4.1.0
|
|
50
|
+
|
|
51
|
+
### Minor Changes
|
|
52
|
+
|
|
53
|
+
- [#1273](https://github.com/ho-nl/m2-pwa/pull/1273)
|
|
54
|
+
[`8c4e4f7cd`](https://github.com/ho-nl/m2-pwa/commit/8c4e4f7cdd2fa4252788fbc9889d0803bba20eef)
|
|
55
|
+
Thanks [@paales](https://github.com/paales)! - Added darkmode support! ☀️🌑, adds a toggle to the
|
|
56
|
+
hamburger menu.
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- [#1271](https://github.com/ho-nl/m2-pwa/pull/1271)
|
|
61
|
+
[`e0008d60d`](https://github.com/ho-nl/m2-pwa/commit/e0008d60d712603219129dd411d1985bf1ebbed1)
|
|
62
|
+
Thanks [@paales](https://github.com/paales)! - make sure the CartFab and MenuFab are stylable with
|
|
63
|
+
sx
|
|
64
|
+
|
|
65
|
+
* [#1271](https://github.com/ho-nl/m2-pwa/pull/1271)
|
|
66
|
+
[`5d9f8320f`](https://github.com/ho-nl/m2-pwa/commit/5d9f8320ff9621d7357fbe01319ab0cafdf9095d)
|
|
67
|
+
Thanks [@paales](https://github.com/paales)! - prevent layout from breaking when url has params
|
|
68
|
+
|
|
69
|
+
- [#1271](https://github.com/ho-nl/m2-pwa/pull/1271)
|
|
70
|
+
[`5082b8c81`](https://github.com/ho-nl/m2-pwa/commit/5082b8c8191cc3e0b4627678bf837af093513d57)
|
|
71
|
+
Thanks [@paales](https://github.com/paales)! - Prevent showing back button on homepage when query
|
|
72
|
+
parameter is present
|
|
73
|
+
|
|
74
|
+
## 4.0.1
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- [`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514)
|
|
79
|
+
Thanks [@paales](https://github.com/paales)! - Added homepage and repository package.json files,
|
|
80
|
+
so that the packages link to back to the website and repository
|
|
81
|
+
- Updated dependencies
|
|
82
|
+
[[`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514)]:
|
|
83
|
+
- @graphcommerce/framer-next-pages@3.0.1
|
|
84
|
+
- @graphcommerce/framer-scroller@2.0.1
|
|
85
|
+
- @graphcommerce/framer-utils@3.0.1
|
|
86
|
+
- @graphcommerce/graphql@3.0.1
|
|
87
|
+
- @graphcommerce/image@3.0.1
|
|
88
|
+
|
|
3
89
|
## 4.0.0
|
|
4
90
|
|
|
5
91
|
### Major Changes
|
package/Form/Form.tsx
CHANGED
|
@@ -30,6 +30,8 @@ const styles = ({ theme, contained = false, background }: { theme: Theme } & For
|
|
|
30
30
|
},
|
|
31
31
|
])
|
|
32
32
|
|
|
33
|
-
export const Form = styled('form'
|
|
33
|
+
export const Form = styled('form', {
|
|
34
|
+
shouldForwardProp: (prop) => prop !== 'contained',
|
|
35
|
+
})<FormStyleProps>(styles)
|
|
34
36
|
|
|
35
37
|
export const FormDiv = styled('div')<FormStyleProps>(styles)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useUp, usePrevUp, usePageContext } from '@graphcommerce/framer-next-pages'
|
|
2
|
-
import { usePrevPageRouter } from '@graphcommerce/framer-next-pages/hooks/usePrevPageRouter'
|
|
3
2
|
import { t } from '@lingui/macro'
|
|
4
3
|
import PageLink from 'next/link'
|
|
5
4
|
import { useRouter } from 'next/router'
|
|
@@ -10,31 +9,31 @@ import { iconChevronLeft } from '../../icons'
|
|
|
10
9
|
export type BackProps = Omit<LinkOrButtonProps, 'onClick' | 'children'>
|
|
11
10
|
|
|
12
11
|
export function useShowBack() {
|
|
13
|
-
const
|
|
12
|
+
const path = useRouter().asPath.split('?')[0]
|
|
14
13
|
const up = useUp()
|
|
15
14
|
const prevUp = usePrevUp()
|
|
16
15
|
const { backSteps } = usePageContext()
|
|
17
16
|
|
|
18
|
-
const canClickBack = backSteps > 0 &&
|
|
17
|
+
const canClickBack = backSteps > 0 && path !== prevUp?.href
|
|
19
18
|
|
|
20
19
|
if (canClickBack) return true
|
|
21
|
-
if (up?.href && up.href !==
|
|
20
|
+
if (up?.href && up.href !== path) return true
|
|
22
21
|
return false
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
export default function LayoutHeaderBack(props: BackProps) {
|
|
26
25
|
const router = useRouter()
|
|
26
|
+
const path = router.asPath.split('?')[0]
|
|
27
27
|
const up = useUp()
|
|
28
|
-
const prevRouter = usePrevPageRouter()
|
|
29
28
|
const prevUp = usePrevUp()
|
|
30
29
|
const { backSteps } = usePageContext()
|
|
31
30
|
|
|
32
31
|
const backIcon = <SvgIcon src={iconChevronLeft} size='medium' />
|
|
33
|
-
const canClickBack = backSteps > 0 &&
|
|
32
|
+
const canClickBack = backSteps > 0 && path !== prevUp?.href
|
|
34
33
|
|
|
35
34
|
let label = t`Back`
|
|
36
|
-
if (up?.href ===
|
|
37
|
-
if (prevUp?.href ===
|
|
35
|
+
if (up?.href === path && up?.title) label = up.title
|
|
36
|
+
if (prevUp?.href === path && prevUp?.title) label = prevUp.title
|
|
38
37
|
|
|
39
38
|
if (canClickBack) {
|
|
40
39
|
return (
|
|
@@ -51,7 +50,7 @@ export default function LayoutHeaderBack(props: BackProps) {
|
|
|
51
50
|
)
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
if (up?.href && up.href !==
|
|
53
|
+
if (up?.href && up.href !== path)
|
|
55
54
|
return (
|
|
56
55
|
<PageLink href={up.href} passHref>
|
|
57
56
|
<LinkOrButton
|
|
@@ -97,7 +97,10 @@ export function LayoutDefault(props: LayoutDefaultProps) {
|
|
|
97
97
|
padding: `0 ${theme.page.horizontal}`,
|
|
98
98
|
position: 'sticky',
|
|
99
99
|
marginTop: `calc(${theme.appShell.headerHeightMd} * -1 + calc(${fabIconSize} / 2))`,
|
|
100
|
-
top: `calc(${theme.appShell.headerHeightMd} / 2 -
|
|
100
|
+
top: `calc(${theme.appShell.headerHeightMd} / 2 - ${responsiveVal(
|
|
101
|
+
42 / 2,
|
|
102
|
+
56 / 2,
|
|
103
|
+
)})`,
|
|
101
104
|
},
|
|
102
105
|
[theme.breakpoints.down('md')]: {
|
|
103
106
|
position: 'fixed',
|
package/LayoutParts/Logo.tsx
CHANGED
|
@@ -63,7 +63,7 @@ export const Logo = forwardRef<HTMLDivElement, LogoProps>((props, ref) => {
|
|
|
63
63
|
/>
|
|
64
64
|
)
|
|
65
65
|
|
|
66
|
-
return router.asPath === '/' ? (
|
|
66
|
+
return router.asPath.split('?')[0] === '/' ? (
|
|
67
67
|
<LogoContainer ref={ref} sx={sx} className={classes.parent}>
|
|
68
68
|
{img}
|
|
69
69
|
</LogoContainer>
|
package/LayoutParts/MenuFab.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Divider, Fab, ListItem, Menu, styled, Box } from '@mui/material'
|
|
1
|
+
import { Divider, Fab, ListItem, Menu, styled, Box, SxProps, Theme } from '@mui/material'
|
|
2
2
|
import { m } from 'framer-motion'
|
|
3
3
|
import { useRouter } from 'next/router'
|
|
4
4
|
import React, { useEffect } from 'react'
|
|
@@ -16,10 +16,11 @@ export type MenuFabProps = {
|
|
|
16
16
|
search?: React.ReactNode
|
|
17
17
|
menuIcon?: React.ReactNode
|
|
18
18
|
closeIcon?: React.ReactNode
|
|
19
|
+
sx?: SxProps<Theme>
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const { classes, selectors } = extendableComponent('MenuFab', [
|
|
22
|
-
'
|
|
23
|
+
'wrapper',
|
|
23
24
|
'fab',
|
|
24
25
|
'shadow',
|
|
25
26
|
'menu',
|
|
@@ -28,7 +29,7 @@ const { classes, selectors } = extendableComponent('MenuFab', [
|
|
|
28
29
|
const fabIconSize = responsiveVal(42, 56) // @todo generalize this
|
|
29
30
|
|
|
30
31
|
export function MenuFab(props: MenuFabProps) {
|
|
31
|
-
const { children, secondary, search, menuIcon, closeIcon } = props
|
|
32
|
+
const { children, secondary, search, menuIcon, closeIcon, sx = [] } = props
|
|
32
33
|
const router = useRouter()
|
|
33
34
|
const [openEl, setOpenEl] = React.useState<null | HTMLElement>(null)
|
|
34
35
|
|
|
@@ -41,9 +42,9 @@ export function MenuFab(props: MenuFabProps) {
|
|
|
41
42
|
}, [router])
|
|
42
43
|
|
|
43
44
|
return (
|
|
44
|
-
<Box sx={{ width: fabIconSize, height: fabIconSize }}>
|
|
45
|
+
<Box sx={[{ width: fabIconSize, height: fabIconSize }, ...(Array.isArray(sx) ? sx : [sx])]}>
|
|
45
46
|
<MotionDiv
|
|
46
|
-
className={classes.
|
|
47
|
+
className={classes.wrapper}
|
|
47
48
|
sx={(theme) => ({
|
|
48
49
|
[theme.breakpoints.down('md')]: {
|
|
49
50
|
opacity: '1 !important',
|
|
@@ -8,8 +8,8 @@ export type MenuFabItemProps = Omit<ListItemButtonProps<'a'>, 'href' | 'button'>
|
|
|
8
8
|
export function MenuFabItem(props: MenuFabItemProps) {
|
|
9
9
|
const { href, children, sx = [], ...listItemProps } = props
|
|
10
10
|
const hrefString = href.toString()
|
|
11
|
-
const
|
|
12
|
-
const active = hrefString === '/' ?
|
|
11
|
+
const path = useRouter().asPath.split('?')[0]
|
|
12
|
+
const active = hrefString === '/' ? path === hrefString : path.startsWith(hrefString)
|
|
13
13
|
|
|
14
14
|
return (
|
|
15
15
|
<PageLink key={href.toString()} href={href} passHref>
|
package/Page/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ParsedUrlQuery } from 'querystring'
|
|
2
|
-
import { NormalizedCacheObject } from '@graphcommerce/graphql'
|
|
3
2
|
import { UpPage } from '@graphcommerce/framer-next-pages/types'
|
|
3
|
+
// todo: remove references to GraphQL
|
|
4
|
+
import { NormalizedCacheObject } from '@graphcommerce/graphql'
|
|
4
5
|
import { GetStaticProps as GetStaticPropsNext } from 'next'
|
|
5
6
|
|
|
6
7
|
type AnyObj = Record<string, unknown>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Trans } from '@lingui/macro'
|
|
2
|
+
import {
|
|
3
|
+
Theme,
|
|
4
|
+
ThemeProvider,
|
|
5
|
+
useMediaQuery,
|
|
6
|
+
Fab,
|
|
7
|
+
FabProps,
|
|
8
|
+
ListItemButton,
|
|
9
|
+
ListItemIcon,
|
|
10
|
+
ListItemText,
|
|
11
|
+
ListItemButtonProps,
|
|
12
|
+
} from '@mui/material'
|
|
13
|
+
import { useRouter } from 'next/router'
|
|
14
|
+
import { createContext, useContext, useEffect, useMemo, useState } from 'react'
|
|
15
|
+
import { SvgIcon } from '../SvgIcon/SvgIcon'
|
|
16
|
+
import { iconMoon, iconSun } from '../icons'
|
|
17
|
+
|
|
18
|
+
type Mode = 'dark' | 'light'
|
|
19
|
+
type UserMode = 'auto' | Mode
|
|
20
|
+
|
|
21
|
+
type ColorModeContext = {
|
|
22
|
+
userMode: UserMode
|
|
23
|
+
browserMode: Mode
|
|
24
|
+
currentMode: Mode
|
|
25
|
+
toggle: () => void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const colorModeContext = createContext(undefined as unknown as ColorModeContext)
|
|
29
|
+
colorModeContext.displayName = 'ColorModeContext'
|
|
30
|
+
|
|
31
|
+
type ThemeProviderProps = {
|
|
32
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
33
|
+
light: Theme
|
|
34
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
35
|
+
dark: Theme
|
|
36
|
+
|
|
37
|
+
children: React.ReactNode
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Wrapper around `import { ThemeProvider } from '@mui/material'`
|
|
42
|
+
*
|
|
43
|
+
* The multi DarkLightModeThemeProvider allows switching between light and dark mode based on URL
|
|
44
|
+
* and on user input.
|
|
45
|
+
*
|
|
46
|
+
* If you *just* wan't a single theme, use the import { ThemeProvider } from '@mui/material' instead.
|
|
47
|
+
*/
|
|
48
|
+
export function DarkLightModeThemeProvider(props: ThemeProviderProps) {
|
|
49
|
+
const { children, light, dark } = props
|
|
50
|
+
|
|
51
|
+
// todo: Save this in local storage
|
|
52
|
+
const [userMode, setUserMode] = useState<UserMode>('auto')
|
|
53
|
+
const browserMode: Mode = useMediaQuery('(prefers-color-scheme: dark)') ? 'dark' : 'light'
|
|
54
|
+
|
|
55
|
+
// If the user has set a mode, use that. Otherwise, use the browser mode.
|
|
56
|
+
const currentMode = userMode === 'auto' ? browserMode : userMode
|
|
57
|
+
const theme = currentMode === 'light' ? light : dark
|
|
58
|
+
|
|
59
|
+
// If a URL parameter is present, switch from auto to light or dark mode
|
|
60
|
+
const { asPath } = useRouter()
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (asPath.includes('darkmode')) setUserMode('dark')
|
|
63
|
+
}, [asPath])
|
|
64
|
+
|
|
65
|
+
// Create the context
|
|
66
|
+
const colorContext: ColorModeContext = useMemo(
|
|
67
|
+
() => ({
|
|
68
|
+
browserMode,
|
|
69
|
+
userMode,
|
|
70
|
+
currentMode,
|
|
71
|
+
toggle: () => setUserMode(currentMode === 'light' ? 'dark' : 'light'),
|
|
72
|
+
}),
|
|
73
|
+
[browserMode, currentMode, userMode],
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<colorModeContext.Provider value={colorContext}>
|
|
78
|
+
<ThemeProvider theme={theme}>{children}</ThemeProvider>
|
|
79
|
+
</colorModeContext.Provider>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function useColorMode() {
|
|
84
|
+
return useContext(colorModeContext)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function DarkLightModeToggleFab(props: Omit<FabProps, 'onClick'>) {
|
|
88
|
+
const { currentMode, toggle } = useColorMode()
|
|
89
|
+
return (
|
|
90
|
+
<Fab size='large' color='inherit' onClick={toggle} {...props}>
|
|
91
|
+
<SvgIcon src={currentMode === 'light' ? iconMoon : iconSun} size='large' />
|
|
92
|
+
</Fab>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A button that switches between light and dark mode
|
|
98
|
+
*
|
|
99
|
+
* To disable this functionality
|
|
100
|
+
*/
|
|
101
|
+
export function DarkLightModeMenuSecondaryItem(props: ListItemButtonProps) {
|
|
102
|
+
const { sx = [] } = props
|
|
103
|
+
const { currentMode, toggle } = useColorMode()
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<ListItemButton {...props} sx={[{}, ...(Array.isArray(sx) ? sx : [sx])]} dense onClick={toggle}>
|
|
107
|
+
<ListItemIcon sx={{ minWidth: 'unset', paddingRight: '8px' }}>
|
|
108
|
+
<SvgIcon src={currentMode === 'light' ? iconMoon : iconSun} size='medium' />
|
|
109
|
+
</ListItemIcon>
|
|
110
|
+
<ListItemText>
|
|
111
|
+
{currentMode === 'light' ? (
|
|
112
|
+
<Trans>Switch to Dark Mode</Trans>
|
|
113
|
+
) : (
|
|
114
|
+
<Trans>Switch to Light Mode</Trans>
|
|
115
|
+
)}
|
|
116
|
+
</ListItemText>
|
|
117
|
+
</ListItemButton>
|
|
118
|
+
)
|
|
119
|
+
}
|
package/Theme/index.ts
CHANGED
package/icons/index.tsx
CHANGED
|
@@ -36,3 +36,5 @@ export { default as iconParty } from './happy-face.svg'
|
|
|
36
36
|
export { default as iconStar } from './star.svg'
|
|
37
37
|
export { default as iconEmailOutline } from './envelope-alt.svg'
|
|
38
38
|
export { default as icon404 } from './explore.svg'
|
|
39
|
+
export { default as iconSun } from './sun.svg'
|
|
40
|
+
export { default as iconMoon } from './moon.svg'
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphcommerce/next-ui",
|
|
3
|
-
"
|
|
3
|
+
"homepage": "https://www.graphcommerce.org/",
|
|
4
|
+
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
+
"version": "4.1.1",
|
|
4
6
|
"author": "",
|
|
5
7
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
10
|
+
"eslintConfig": {
|
|
11
|
+
"extends": "@graphcommerce/eslint-config-pwa",
|
|
12
|
+
"parserOptions": {
|
|
13
|
+
"project": "./tsconfig.json"
|
|
14
|
+
}
|
|
10
15
|
},
|
|
11
16
|
"dependencies": {
|
|
12
17
|
"@emotion/babel-preset-css-prop": "^11.2.0",
|
|
@@ -14,40 +19,31 @@
|
|
|
14
19
|
"@emotion/react": "^11.7.1",
|
|
15
20
|
"@emotion/server": "^11.4.0",
|
|
16
21
|
"@emotion/styled": "^11.6.0",
|
|
17
|
-
"@graphcommerce/framer-next-pages": "^3.0.
|
|
18
|
-
"@graphcommerce/framer-scroller": "^2.0.
|
|
19
|
-
"@graphcommerce/framer-utils": "^3.0.
|
|
20
|
-
"@graphcommerce/
|
|
21
|
-
"
|
|
22
|
+
"@graphcommerce/framer-next-pages": "^3.0.2",
|
|
23
|
+
"@graphcommerce/framer-scroller": "^2.0.2",
|
|
24
|
+
"@graphcommerce/framer-utils": "^3.0.2",
|
|
25
|
+
"@graphcommerce/image": "^3.0.2",
|
|
26
|
+
"react-is": "^17.0.2",
|
|
27
|
+
"react-schemaorg": "^2.0.0",
|
|
28
|
+
"schema-dts": "^1.0.0",
|
|
29
|
+
"type-fest": "^2.11.2"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
22
32
|
"@lingui/macro": "^3.13.2",
|
|
23
33
|
"@mui/base": "^5.0.0-alpha.68",
|
|
24
34
|
"@mui/lab": "^5.0.0-alpha.68",
|
|
25
35
|
"@mui/material": "^5.4.1",
|
|
26
36
|
"framer-motion": "^6.2.4",
|
|
27
|
-
"graphql": "^16.3.0",
|
|
28
37
|
"next": "^12.0.10",
|
|
29
38
|
"react": "^17.0.2",
|
|
30
|
-
"react-dom": "^17.0.2"
|
|
31
|
-
"react-is": "^17.0.2",
|
|
32
|
-
"react-schemaorg": "^2.0.0",
|
|
33
|
-
"schema-dts": "^1.0.0",
|
|
34
|
-
"type-fest": "^2.11.2"
|
|
39
|
+
"react-dom": "^17.0.2"
|
|
35
40
|
},
|
|
36
41
|
"devDependencies": {
|
|
37
|
-
"@graphcommerce/eslint-config-pwa": "^4.0.
|
|
38
|
-
"@graphcommerce/prettier-config-pwa": "^4.0.
|
|
39
|
-
"@graphcommerce/typescript-config-pwa": "^4.0.
|
|
40
|
-
"@playwright/test": "^1.
|
|
42
|
+
"@graphcommerce/eslint-config-pwa": "^4.0.2",
|
|
43
|
+
"@graphcommerce/prettier-config-pwa": "^4.0.1",
|
|
44
|
+
"@graphcommerce/typescript-config-pwa": "^4.0.1",
|
|
45
|
+
"@playwright/test": "^1.19.1",
|
|
41
46
|
"@types/react-is": "^17.0.3",
|
|
42
|
-
"graphql-tag": "2.12.6",
|
|
43
47
|
"typescript": "^4.5.5"
|
|
44
|
-
},
|
|
45
|
-
"sideEffects": false,
|
|
46
|
-
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
47
|
-
"eslintConfig": {
|
|
48
|
-
"extends": "@graphcommerce/eslint-config-pwa",
|
|
49
|
-
"parserOptions": {
|
|
50
|
-
"project": "./tsconfig.json"
|
|
51
|
-
}
|
|
52
48
|
}
|
|
53
49
|
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { ApolloError } from '@graphcommerce/graphql'
|
|
2
|
-
import { AlertProps, Alert, Box, SxProps, Theme } from '@mui/material'
|
|
3
|
-
import { AnimatePresence } from 'framer-motion'
|
|
4
|
-
import { AnimatedRow } from '../AnimatedRow'
|
|
5
|
-
import { extendableComponent } from '../Styles/extendableComponent'
|
|
6
|
-
|
|
7
|
-
const { classes, selectors } = extendableComponent('ApolloErrorAlert', ['root', 'alert'] as const)
|
|
8
|
-
|
|
9
|
-
export type ApolloErrorAlertProps = {
|
|
10
|
-
error?: ApolloError
|
|
11
|
-
graphqlErrorAlertProps?: Omit<AlertProps, 'severity'>
|
|
12
|
-
networkErrorAlertProps?: Omit<AlertProps, 'severity'>
|
|
13
|
-
sx?: SxProps<Theme>
|
|
14
|
-
}
|
|
15
|
-
export default function ApolloErrorAlert(props: ApolloErrorAlertProps) {
|
|
16
|
-
const { error, graphqlErrorAlertProps, networkErrorAlertProps, sx } = props
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<AnimatePresence initial={false}>
|
|
20
|
-
{error && (
|
|
21
|
-
<AnimatedRow key='alerts'>
|
|
22
|
-
<Box sx={sx} className={classes.root}>
|
|
23
|
-
<AnimatePresence initial={false}>
|
|
24
|
-
{error.graphQLErrors.map((e, index) => (
|
|
25
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
26
|
-
<AnimatedRow key={index}>
|
|
27
|
-
<div className={classes.alert}>
|
|
28
|
-
<Alert severity='error' {...graphqlErrorAlertProps}>
|
|
29
|
-
{e.message}
|
|
30
|
-
</Alert>
|
|
31
|
-
</div>
|
|
32
|
-
</AnimatedRow>
|
|
33
|
-
))}
|
|
34
|
-
{error.networkError && (
|
|
35
|
-
<AnimatedRow key='networkError'>
|
|
36
|
-
<Box
|
|
37
|
-
sx={(theme) => ({
|
|
38
|
-
paddingTop: theme.spacings.xxs,
|
|
39
|
-
paddingBottom: theme.spacings.xxs,
|
|
40
|
-
})}
|
|
41
|
-
className={classes.alert}
|
|
42
|
-
key='networkError'
|
|
43
|
-
>
|
|
44
|
-
<Alert severity='error' {...networkErrorAlertProps}>
|
|
45
|
-
Network Error: {error.networkError.message}
|
|
46
|
-
</Alert>
|
|
47
|
-
</Box>
|
|
48
|
-
</AnimatedRow>
|
|
49
|
-
)}
|
|
50
|
-
</AnimatePresence>
|
|
51
|
-
</Box>
|
|
52
|
-
</AnimatedRow>
|
|
53
|
-
)}
|
|
54
|
-
</AnimatePresence>
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
ApolloErrorAlert.selectors = selectors
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ApolloError } from '@graphcommerce/graphql'
|
|
2
|
-
import { AlertProps } from '@mui/material'
|
|
3
|
-
import { FullPageMessage, FullPageMessageProps } from '../FullPageMessage'
|
|
4
|
-
import ApolloErrorAlert from './ApolloErrorAlert'
|
|
5
|
-
|
|
6
|
-
export type ApolloErrorFullPageProps = {
|
|
7
|
-
error?: ApolloError
|
|
8
|
-
graphqlErrorAlertProps?: Omit<AlertProps, 'severity'>
|
|
9
|
-
networkErrorAlertProps?: Omit<AlertProps, 'severity'>
|
|
10
|
-
} & Omit<FullPageMessageProps, 'title' | 'description'>
|
|
11
|
-
|
|
12
|
-
export default function ApolloErrorFullPage(props: ApolloErrorFullPageProps) {
|
|
13
|
-
const {
|
|
14
|
-
error,
|
|
15
|
-
graphqlErrorAlertProps,
|
|
16
|
-
networkErrorAlertProps,
|
|
17
|
-
children,
|
|
18
|
-
...fullPageMessageProps
|
|
19
|
-
} = props
|
|
20
|
-
|
|
21
|
-
const singleError = error?.graphQLErrors.length === 1
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<FullPageMessage
|
|
25
|
-
title={singleError ? error?.graphQLErrors[0].message : 'Several errors occured'}
|
|
26
|
-
{...fullPageMessageProps}
|
|
27
|
-
>
|
|
28
|
-
{singleError ? children : <ApolloErrorAlert error={error} />}
|
|
29
|
-
</FullPageMessage>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ApolloError } from '@graphcommerce/graphql'
|
|
2
|
-
import { Trans } from '@lingui/macro'
|
|
3
|
-
import { Button } from '@mui/material'
|
|
4
|
-
import { MessageSnackbar } from '../Snackbar/MessageSnackbar'
|
|
5
|
-
import { MessageSnackbarImplProps } from '../Snackbar/MessageSnackbarImpl'
|
|
6
|
-
|
|
7
|
-
export type ApolloErrorSnackbarProps = {
|
|
8
|
-
error?: ApolloError
|
|
9
|
-
} & Pick<MessageSnackbarImplProps, 'action' | 'onClose'>
|
|
10
|
-
|
|
11
|
-
export default function ApolloErrorSnackbar(props: ApolloErrorSnackbarProps) {
|
|
12
|
-
const { error, action, ...passedProps } = props
|
|
13
|
-
|
|
14
|
-
if (!error) return null
|
|
15
|
-
return (
|
|
16
|
-
<MessageSnackbar
|
|
17
|
-
variant='pill'
|
|
18
|
-
severity='error'
|
|
19
|
-
{...passedProps}
|
|
20
|
-
open={!!error}
|
|
21
|
-
action={
|
|
22
|
-
action ?? (
|
|
23
|
-
<Button size='medium' variant='pill' color='secondary'>
|
|
24
|
-
<Trans>Ok</Trans>
|
|
25
|
-
</Button>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
>
|
|
29
|
-
<>
|
|
30
|
-
{error.graphQLErrors.map((e) => e.message)}
|
|
31
|
-
{error.networkError && <>Network Error: {error.networkError.message}</>}
|
|
32
|
-
</>
|
|
33
|
-
</MessageSnackbar>
|
|
34
|
-
)
|
|
35
|
-
}
|
package/ApolloError/index.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from './ApolloErrorAlert'
|
|
2
|
-
export { default as ApolloErrorAlert } from './ApolloErrorAlert'
|
|
3
|
-
export * from './ApolloErrorFullPage'
|
|
4
|
-
export { default as ApolloErrorFullPage } from './ApolloErrorFullPage'
|
|
5
|
-
export * from './ApolloErrorSnackbar'
|
|
6
|
-
export { default as ApolloErrorSnackbar } from './ApolloErrorSnackbar'
|