@graphcommerce/magento-product 8.0.6-canary.4 → 8.1.0-canary.11

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,29 @@
1
1
  # Change Log
2
2
 
3
+ ## 8.1.0-canary.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2255](https://github.com/graphcommerce-org/graphcommerce/pull/2255) [`679d07d`](https://github.com/graphcommerce-org/graphcommerce/commit/679d07dad5b5e2dab3c0f3d537716b6115af8ef7) - make the ProductPageMeta fragment injectable
8
+ ([@carlocarels90](https://github.com/carlocarels90))
9
+
10
+ ## 8.1.0-canary.10
11
+
12
+ ## 8.1.0-canary.9
13
+
14
+ ## 8.1.0-canary.8
15
+
16
+ ## 8.1.0-canary.7
17
+
18
+ ## 8.1.0-canary.6
19
+
20
+ ## 8.1.0-canary.5
21
+
22
+ ### Patch Changes
23
+
24
+ - [#2224](https://github.com/graphcommerce-org/graphcommerce/pull/2224) [`4dd2d01`](https://github.com/graphcommerce-org/graphcommerce/commit/4dd2d01b3e14e3107ee3e337bef2a8528d654e75) - When applying a filter it would not always scroll to the #products.
25
+ ([@FrankHarland](https://github.com/FrankHarland))
26
+
3
27
  ## 8.0.6-canary.4
4
28
 
5
29
  ### Patch Changes
@@ -3,6 +3,7 @@ export * from './AddProductsToCartButton'
3
3
  export * from './AddProductsToCartError'
4
4
  export * from './AddProductsToCartFab'
5
5
  export * from './AddProductsToCartForm'
6
+ export * from './AddProductsToCartSnackbar'
6
7
  export * from './AddProductsToCartQuantity'
7
8
  export * from './useAddProductsToCartAction'
8
9
  export * from './useFormAddProductsToCart'
@@ -1,10 +1,17 @@
1
1
  import { JsonLd } from '@graphcommerce/next-ui'
2
2
  import { JsonLdProductFragment } from './JsonLdProduct.gql'
3
3
 
4
- export function ProductPageJsonLd<
4
+ export type ProductPageJsonLdProps<
5
5
  T extends { '@type': string },
6
6
  P extends JsonLdProductFragment,
7
- >(props: { product: P; render: (product: P) => T & { '@context': 'https://schema.org' } }) {
7
+ > = {
8
+ product: P
9
+ render: (product: P) => T & { '@context': 'https://schema.org' }
10
+ }
11
+
12
+ export function ProductPageJsonLd<T extends { '@type': string }, P extends JsonLdProductFragment>(
13
+ props: ProductPageJsonLdProps<T, P>,
14
+ ) {
8
15
  const { product, render } = props
9
16
  return <JsonLd<T> item={render(product)} />
10
17
  }
@@ -1,2 +1,3 @@
1
1
  export * from './jsonLdProduct'
2
2
  export * from './ProductPageJsonLd'
3
+ export * from './JsonLdProduct.gql'
@@ -1,8 +1,9 @@
1
1
  import { useForm, UseFormProps, UseFormReturn } from '@graphcommerce/ecommerce-ui'
2
- import { useMemoObject } from '@graphcommerce/next-ui'
3
- import { useEventCallback } from '@mui/material'
2
+ import { useMatchMediaMotionValue, useMemoObject } from '@graphcommerce/next-ui'
3
+ import { useEventCallback, useTheme } from '@mui/material'
4
+ import { m, useTransform } from 'framer-motion'
4
5
  import { useRouter } from 'next/router'
5
- import React, { BaseSyntheticEvent, createContext, useContext, useMemo } from 'react'
6
+ import React, { BaseSyntheticEvent, createContext, useContext, useMemo, useRef } from 'react'
6
7
  import { productListLinkFromFilter } from '../../hooks/useProductListLink'
7
8
  import { ProductListFiltersFragment } from '../ProductListFilters/ProductListFilters.gql'
8
9
  import {
@@ -44,23 +45,30 @@ export type FilterFormProviderProps = Omit<
44
45
  params: ProductListParams
45
46
  } & DataProps
46
47
 
48
+ const isSidebar = import.meta.graphCommerce.productFiltersLayout === 'SIDEBAR'
49
+
47
50
  export function ProductFiltersPro(props: FilterFormProviderProps) {
48
51
  const { children, params, aggregations, appliedAggregations, filterTypes, ...formProps } = props
49
52
 
50
53
  const defaultValues = useMemoObject(toFilterParams(params))
51
54
  const form = useForm<ProductFilterParams>({ defaultValues, ...formProps })
55
+ const ref = useRef<HTMLFormElement>(null)
52
56
 
53
57
  const router = useRouter()
58
+ const theme = useTheme()
59
+ const isDesktop = useMatchMediaMotionValue('up', 'md')
60
+ const scrollMarginTop = useTransform(() => (isDesktop.get() ? 0 : theme.appShell.headerHeightSm))
61
+ const scroll = useTransform(() => !isSidebar || isDesktop.get())
54
62
 
55
63
  const submit = useEventCallback(
56
64
  form.handleSubmit(async (formValues) => {
57
- const queryUrl = router.query.url ?? []
58
- const comingFromURLWithoutFilters = !queryUrl.includes('q')
59
65
  const path = productListLinkFromFilter({ ...formValues, currentPage: 1 })
60
-
61
66
  if (router.asPath === path) return false
62
- if (comingFromURLWithoutFilters) return router.push(path, path)
63
- return router.replace(path, path)
67
+
68
+ const opts = { scroll: scroll.get() }
69
+ return (router.query.url ?? []).includes('q')
70
+ ? router.replace(path, path, opts)
71
+ : router.push(path, path, opts)
64
72
  }),
65
73
  )
66
74
 
@@ -78,7 +86,7 @@ export function ProductFiltersPro(props: FilterFormProviderProps) {
78
86
 
79
87
  return (
80
88
  <FilterFormContext.Provider value={filterFormContext}>
81
- <form noValidate onSubmit={submit} id='products' />
89
+ <m.form ref={ref} noValidate onSubmit={submit} id='products' style={{ scrollMarginTop }} />
82
90
  {children}
83
91
  </FilterFormContext.Provider>
84
92
  )
@@ -1,7 +1,7 @@
1
1
  import { LazyHydrate, RenderType, extendableComponent, responsiveVal } from '@graphcommerce/next-ui'
2
2
  import { Box, BoxProps } from '@mui/material'
3
3
  import { ProductListItemFragment } from '../../Api/ProductListItem.gql'
4
- import { AddProductsToCartForm } from '../../index'
4
+ import { AddProductsToCartForm } from '../AddProductsToCart'
5
5
  import { ProductListItemProps } from '../ProductListItem/ProductListItem'
6
6
  import { ProductListItemRenderer } from './renderer'
7
7
 
@@ -1,4 +1,4 @@
1
- fragment ProductPageMeta on ProductInterface {
1
+ fragment ProductPageMeta on ProductInterface @injectable {
2
2
  ...ProductLink
3
3
  sku
4
4
  name
@@ -11,7 +11,7 @@ export type ProductTypenames = NonNullable<
11
11
  export async function getProductStaticPaths(
12
12
  client: ApolloClient<NormalizedCacheObject>,
13
13
  locale: string,
14
- typename?: ProductTypenames,
14
+ options: { limit?: boolean } = { limit: import.meta.graphCommerce.limitSsg || false },
15
15
  ) {
16
16
  const query = client.query({
17
17
  query: ProductStaticPathsDocument,
@@ -36,8 +36,7 @@ export async function getProductStaticPaths(
36
36
  const paths: Return['paths'] = (await Promise.all(pages))
37
37
  .map((q) => q.data.products?.items)
38
38
  .flat(1)
39
- .filter((item) => (typename ? item?.__typename === typename : true))
40
39
  .map((p) => ({ params: { url: `${p?.url_key}` }, locale }))
41
40
 
42
- return import.meta.graphCommerce.limitSsg ? paths.slice(0, 1) : paths
41
+ return options.limit ? paths.slice(0, 1) : paths
43
42
  }
@@ -3,6 +3,9 @@ import { canonicalize, nonNullable } from '@graphcommerce/next-ui'
3
3
  import { productLink } from '../../hooks/useProductLink'
4
4
  import { ProductStaticPathsDocument } from './ProductStaticPaths.gql'
5
5
 
6
+ /**
7
+ * @deprecated Not used anymore, use `getProductStaticPaths` instead.
8
+ */
6
9
  export async function getSitemapPaths(
7
10
  client: ApolloClient<NormalizedCacheObject>,
8
11
  ctx: { locale?: string; defaultLocale?: string },
@@ -9,6 +9,9 @@ type UseProductLinkPushProps = {
9
9
  scroll?: boolean
10
10
  }
11
11
 
12
+ /**
13
+ * @deprecated replaced by custom function inside ProductFiltersPro
14
+ */
12
15
  export function useProductListLinkReplace(props?: UseProductLinkPushProps) {
13
16
  const { setParams } = useProductListParamsContext()
14
17
  const router = useRouter()
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-product",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "8.0.6-canary.4",
5
+ "version": "8.1.0-canary.11",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -18,18 +18,18 @@
18
18
  "typescript": "5.3.3"
19
19
  },
20
20
  "peerDependencies": {
21
- "@graphcommerce/ecommerce-ui": "^8.0.6-canary.4",
22
- "@graphcommerce/eslint-config-pwa": "^8.0.6-canary.4",
23
- "@graphcommerce/framer-next-pages": "^8.0.6-canary.4",
24
- "@graphcommerce/framer-scroller": "^8.0.6-canary.4",
25
- "@graphcommerce/graphql": "^8.0.6-canary.4",
26
- "@graphcommerce/graphql-mesh": "^8.0.6-canary.4",
27
- "@graphcommerce/image": "^8.0.6-canary.4",
28
- "@graphcommerce/magento-cart": "^8.0.6-canary.4",
29
- "@graphcommerce/magento-store": "^8.0.6-canary.4",
30
- "@graphcommerce/next-ui": "^8.0.6-canary.4",
31
- "@graphcommerce/prettier-config-pwa": "^8.0.6-canary.4",
32
- "@graphcommerce/typescript-config-pwa": "^8.0.6-canary.4",
21
+ "@graphcommerce/ecommerce-ui": "^8.1.0-canary.11",
22
+ "@graphcommerce/eslint-config-pwa": "^8.1.0-canary.11",
23
+ "@graphcommerce/framer-next-pages": "^8.1.0-canary.11",
24
+ "@graphcommerce/framer-scroller": "^8.1.0-canary.11",
25
+ "@graphcommerce/graphql": "^8.1.0-canary.11",
26
+ "@graphcommerce/graphql-mesh": "^8.1.0-canary.11",
27
+ "@graphcommerce/image": "^8.1.0-canary.11",
28
+ "@graphcommerce/magento-cart": "^8.1.0-canary.11",
29
+ "@graphcommerce/magento-store": "^8.1.0-canary.11",
30
+ "@graphcommerce/next-ui": "^8.1.0-canary.11",
31
+ "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.11",
32
+ "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.11",
33
33
  "@lingui/core": "^4.2.1",
34
34
  "@lingui/macro": "^4.2.1",
35
35
  "@lingui/react": "^4.2.1",
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "exclude": ["**/node_modules", "**/.*/"],
3
3
  "include": ["**/*.ts", "**/*.tsx"],
4
- "extends": "@graphcommerce/typescript-config-pwa/nextjs.json"
4
+ "extends": "@graphcommerce/typescript-config-pwa/nextjs.json",
5
5
  }