@graphcommerce/next-ui 9.0.0-canary.88 → 9.0.0-canary.92

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.92
4
+
5
+ ## 9.0.0-canary.91
6
+
7
+ ## 9.0.0-canary.90
8
+
9
+ ## 9.0.0-canary.89
10
+
11
+ ### Patch Changes
12
+
13
+ - [#2393](https://github.com/graphcommerce-org/graphcommerce/pull/2393) [`8946991`](https://github.com/graphcommerce-org/graphcommerce/commit/894699122c2748724acf439ce3ff14fa56a1e68c) - Solve an issue where the success page would show a back button which would go back to the payment page (which would be empty) ([@carlocarels90](https://github.com/carlocarels90))
14
+
3
15
  ## 9.0.0-canary.88
4
16
 
5
17
  ## 9.0.0-canary.87
@@ -1,13 +1,14 @@
1
1
  import { Box, SxProps, Theme } from '@mui/material'
2
2
  import React from 'react'
3
3
  import { extendableComponent } from '../../Styles'
4
- import { LayoutHeaderBack, useShowBack } from './LayoutHeaderBack'
4
+ import { BackProps, LayoutHeaderBack, useShowBack } from './LayoutHeaderBack'
5
5
  import { LayoutHeaderClose, useShowClose } from './LayoutHeaderClose'
6
6
  import { LayoutHeaderContent, LayoutHeaderContentProps } from './LayoutHeaderContent'
7
7
  import { FloatingProps } from './LayoutHeadertypes'
8
8
 
9
9
  export type LayoutHeaderProps = FloatingProps &
10
- Omit<LayoutHeaderContentProps, 'left' | 'right'> & {
10
+ Omit<LayoutHeaderContentProps, 'left' | 'right'> &
11
+ Pick<BackProps, 'disableBackNavigation'> & {
11
12
  /**
12
13
  * Button to display on the left side of the title
13
14
  *
@@ -44,10 +45,9 @@ type ComponentStyleProps = {
44
45
  size: 'small' | 'responsive'
45
46
  }
46
47
 
47
- const { selectors, withState } = extendableComponent<ComponentStyleProps, 'LayoutHeader'>(
48
- 'LayoutHeader',
49
- ['root'] as const,
50
- )
48
+ const { withState } = extendableComponent<ComponentStyleProps, 'LayoutHeader'>('LayoutHeader', [
49
+ 'root',
50
+ ] as const)
51
51
 
52
52
  export const LayoutHeader = React.memo<LayoutHeaderProps>((props) => {
53
53
  const {
@@ -63,6 +63,7 @@ export const LayoutHeader = React.memo<LayoutHeaderProps>((props) => {
63
63
  bgColor,
64
64
  hideSm = false,
65
65
  hideMd = false,
66
+ disableBackNavigation,
66
67
  } = props
67
68
  const showBack = useShowBack() && !hideBackButton
68
69
  const showClose = useShowClose()
@@ -76,7 +77,12 @@ export const LayoutHeader = React.memo<LayoutHeaderProps>((props) => {
76
77
  if (divider || primary || secondary) floatingSm = false
77
78
 
78
79
  const close = showClose && <LayoutHeaderClose />
79
- const back = showBack && <LayoutHeaderBack breakpoint={floatingSm ? 'xs' : undefined} />
80
+ const back = showBack && (
81
+ <LayoutHeaderBack
82
+ breakpoint={floatingSm ? 'xs' : undefined}
83
+ disableBackNavigation={disableBackNavigation}
84
+ />
85
+ )
80
86
 
81
87
  let left = secondary
82
88
  let right = primary
@@ -12,7 +12,12 @@ import { IconSvg } from '../../IconSvg'
12
12
  import { responsiveVal } from '../../Styles'
13
13
  import { iconChevronLeft } from '../../icons'
14
14
 
15
- export type BackProps = Omit<LinkOrButtonProps, 'onClick' | 'children'>
15
+ export type BackProps = Omit<LinkOrButtonProps, 'onClick' | 'children'> & {
16
+ /**
17
+ * Will not use `router.back()` if available, and will always use the `up.href`
18
+ */
19
+ disableBackNavigation?: boolean
20
+ }
16
21
 
17
22
  export function useShowBack() {
18
23
  const path = useRouter().asPath.split('?')[0]
@@ -21,10 +26,7 @@ export function useShowBack() {
21
26
  const { backSteps } = usePageContext()
22
27
 
23
28
  const canClickBack = backSteps > 0 && path !== prevUp?.href
24
-
25
- if (canClickBack) return true
26
- if (up?.href && up.href !== path) return true
27
- return false
29
+ return canClickBack || (up?.href && up.href !== path)
28
30
  }
29
31
 
30
32
  const buttonSx: SxProps<Theme> = (theme) => ({
@@ -41,6 +43,7 @@ const buttonSx: SxProps<Theme> = (theme) => ({
41
43
  })
42
44
 
43
45
  export function LayoutHeaderBack(props: BackProps) {
46
+ const { disableBackNavigation = false } = props
44
47
  const router = useRouter()
45
48
  const path = router.asPath.split('?')[0]
46
49
  const up = useUp()
@@ -49,7 +52,7 @@ export function LayoutHeaderBack(props: BackProps) {
49
52
  const prevPageRouter = usePrevPageRouter()
50
53
 
51
54
  const backIcon = <IconSvg src={iconChevronLeft} size='medium' />
52
- const canClickBack = backSteps > 0 && path !== prevUp?.href
55
+ const canClickBack = backSteps > 0 && path !== prevUp?.href && !disableBackNavigation
53
56
 
54
57
  let label = i18n._(/* i18n */ 'Back')
55
58
  if (up?.href === path && up?.title) label = up.title
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/next-ui",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "9.0.0-canary.88",
5
+ "version": "9.0.0-canary.92",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -26,13 +26,13 @@
26
26
  "typescript": "5.5.3"
27
27
  },
28
28
  "peerDependencies": {
29
- "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.88",
30
- "@graphcommerce/framer-next-pages": "^9.0.0-canary.88",
31
- "@graphcommerce/framer-scroller": "^9.0.0-canary.88",
32
- "@graphcommerce/framer-utils": "^9.0.0-canary.88",
33
- "@graphcommerce/image": "^9.0.0-canary.88",
34
- "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.88",
35
- "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.88",
29
+ "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.92",
30
+ "@graphcommerce/framer-next-pages": "^9.0.0-canary.92",
31
+ "@graphcommerce/framer-scroller": "^9.0.0-canary.92",
32
+ "@graphcommerce/framer-utils": "^9.0.0-canary.92",
33
+ "@graphcommerce/image": "^9.0.0-canary.92",
34
+ "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.92",
35
+ "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.92",
36
36
  "@lingui/core": "^4.2.1",
37
37
  "@lingui/macro": "^4.2.1",
38
38
  "@lingui/react": "^4.2.1",