@graphcommerce/magento-product 9.0.0-canary.115 → 9.0.0-canary.116

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,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.116
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2452](https://github.com/graphcommerce-org/graphcommerce/pull/2452) [`5dfd3b2`](https://github.com/graphcommerce-org/graphcommerce/commit/5dfd3b201255ef35263485d04153d37bb7e4fe67) - Renamed useInContextQuery to usePrivateQuery ([@paales](https://github.com/paales))
8
+
3
9
  ## 9.0.0-canary.115
4
10
 
5
11
  ## 9.0.0-canary.114
@@ -1,2 +1 @@
1
- export * from './ProductAddToCart'
2
1
  export * from './ProductAddToCart.gql'
@@ -17,9 +17,7 @@ export type ProductFiltersProAllFiltersSidebarProps = ProductFiltersProAggregati
17
17
 
18
18
  /**
19
19
  * @deprecated Not used anymore
20
- *
21
- * @param props
22
- * @returns
20
+ * @public
23
21
  */
24
22
  export function ProductFiltersProAllFiltersSidebar(props: ProductFiltersProAllFiltersSidebarProps) {
25
23
  const { sort_fields, total_count, renderer, sx = [], category, params } = props
@@ -5,7 +5,9 @@ import {
5
5
  } from './ProductFiltersProAggregations'
6
6
 
7
7
  /**
8
- * @deprecated Not used anymore, use `<ProductFiltersProAggregations renderer={productFiltersProChipRenderer}/>`
8
+ * @deprecated Not used anymore, use `<ProductFiltersProAggregations
9
+ * renderer={productFiltersProChipRenderer}/>`
10
+ * @public
9
11
  */
10
12
  export function ProductFiltersProFilterChips(props: ProductFiltersProAggregationsProps) {
11
13
  const { renderer } = props
@@ -1,5 +1,5 @@
1
1
  import { FormAutoSubmit } from '@graphcommerce/ecommerce-ui'
2
- import { StickyBelowHeader, extendableComponent } from '@graphcommerce/next-ui'
2
+ import { extendableComponent, StickyBelowHeader } from '@graphcommerce/next-ui'
3
3
  import type { Theme } from '@mui/material'
4
4
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
5
5
  import { Box, Container, useMediaQuery } from '@mui/material'
@@ -25,6 +25,10 @@ const name = 'ProductFiltersProLayoutSidebar'
25
25
  const parts = ['root', 'content'] as const
26
26
  const { withState } = extendableComponent<OwnerProps, typeof name, typeof parts>(name, parts)
27
27
 
28
+ /**
29
+ * @deprecated
30
+ * @public
31
+ */
28
32
  export function ProductFiltersProLayoutSidebar(props: ProductFiltersProLayoutSidebarProps) {
29
33
  const {
30
34
  items,
@@ -4,7 +4,7 @@ query ProductList(
4
4
  $filters: ProductAttributeFilterInput = {}
5
5
  $sort: ProductAttributeSortInput = {}
6
6
  $search: String = ""
7
- $context: InContextInput = { loggedIn: false }
7
+ $context: PrivateContext
8
8
  $onlyItems: Boolean = false
9
9
  ) {
10
10
  products(
@@ -13,7 +13,7 @@ query ProductList(
13
13
  filter: $filters
14
14
  sort: $sort
15
15
  search: $search
16
- ) @inContext(context: $context) {
16
+ ) @privateContext(context: $context) {
17
17
  ...ProductListSuggestions @skip(if: $onlyItems)
18
18
  ...ProductListFilters @skip(if: $onlyItems)
19
19
  ...ProductListCount @skip(if: $onlyItems)
@@ -1,11 +1,11 @@
1
1
  query ProductFilters(
2
2
  $filters: ProductAttributeFilterInput = {}
3
3
  $search: String
4
- $context: InContextInput
4
+ $context: PrivateContext
5
5
  $pageSize: Int = 1
6
6
  ) {
7
7
  filters: products(filter: $filters, currentPage: 1, pageSize: $pageSize, search: $search)
8
- @inContext(context: $context) {
8
+ @privateContext(context: $context) {
9
9
  page_info {
10
10
  total_pages
11
11
  }
@@ -59,6 +59,7 @@ export type ProductProps = BaseProps & ProductListItemFragment
59
59
 
60
60
  export type ProductListItemProps = ProductProps | SkeletonProps
61
61
 
62
+ /** @public */
62
63
  export function ProductListItemReal(props: ProductProps) {
63
64
  const {
64
65
  subTitle,
@@ -135,6 +136,7 @@ export function ProductListItemReal(props: ProductProps) {
135
136
  )
136
137
  }
137
138
 
139
+ /** @public */
138
140
  export function ProductListItemSkeleton(props: BaseProps) {
139
141
  const { children, imageOnly = false, aspectRatio, titleComponent = 'h2', sx = [] } = props
140
142
 
@@ -8,6 +8,7 @@ export type ProductListItemRenderer = TypeRenderer<ProductListItemFragment | Ske
8
8
 
9
9
  /**
10
10
  * @deprecated Please use productListRenderer from the example directory instead.
11
+ * @public
11
12
  */
12
13
  export const renderer: ProductListItemRenderer = {
13
14
  Skeleton: ProductListItem,
@@ -1,4 +1,4 @@
1
- import { InContextMask } from '@graphcommerce/graphql'
1
+ import { PrivateQueryMask } from '@graphcommerce/graphql'
2
2
  import { Money } from '@graphcommerce/magento-store'
3
3
  import { extendableComponent } from '@graphcommerce/next-ui'
4
4
  import type { TypographyProps } from '@mui/material'
@@ -21,7 +21,7 @@ export function ProductListPrice(props: ProductListPriceProps) {
21
21
  return (
22
22
  <Typography component='div' variant='body1' className={classes.root} sx={sx}>
23
23
  {regular_price.value !== final_price.value && (
24
- <InContextMask
24
+ <PrivateQueryMask
25
25
  component='span'
26
26
  sx={{
27
27
  textDecoration: 'line-through',
@@ -32,11 +32,15 @@ export function ProductListPrice(props: ProductListPriceProps) {
32
32
  className={classes.discountPrice}
33
33
  >
34
34
  <Money {...regular_price} />
35
- </InContextMask>
35
+ </PrivateQueryMask>
36
36
  )}
37
- <InContextMask className={classes.finalPrice} component='span' skeleton={{ width: '3.5em' }}>
37
+ <PrivateQueryMask
38
+ className={classes.finalPrice}
39
+ component='span'
40
+ skeleton={{ width: '3.5em' }}
41
+ >
38
42
  <Money {...final_price} />
39
- </InContextMask>
43
+ </PrivateQueryMask>
40
44
  </Typography>
41
45
  )
42
46
  }
@@ -10,7 +10,7 @@ export type ProductPageAddToCartRowProps = {
10
10
  product: UseAddProductsToCartActionFragment
11
11
  }
12
12
 
13
- export function ProductPageAddToCartRow(props: ProductPageAddToCartRowProps) {
13
+ function ProductPageAddToCartRow(props: ProductPageAddToCartRowProps) {
14
14
  const { sx, children, after } = props
15
15
  return (
16
16
  <>
@@ -11,6 +11,7 @@ export type ProductPageBreadcrumbProps = ProductPageBreadcrumbFragment &
11
11
 
12
12
  /**
13
13
  * @deprecated Please use ProductPageBreadcrumbs
14
+ * @public
14
15
  */
15
16
  export function ProductPageBreadcrumb(props: ProductPageBreadcrumbProps) {
16
17
  const { categories, name, ...breadcrumbProps } = props
@@ -1,11 +1,11 @@
1
1
  import { useWatch } from '@graphcommerce/ecommerce-ui'
2
- import { InContextMask } from '@graphcommerce/graphql'
2
+ import { PrivateQueryMask } from '@graphcommerce/graphql'
3
3
  import { Money } from '@graphcommerce/magento-store'
4
4
  import { extendableComponent } from '@graphcommerce/next-ui'
5
5
  import type { AddToCartItemSelector } from '../AddProductsToCart'
6
6
  import { useFormAddProductsToCart } from '../AddProductsToCart'
7
- import type { ProductPagePriceFragment } from './ProductPagePrice.gql'
8
7
  import { getProductTierPrice } from './getProductTierPrice'
8
+ import type { ProductPagePriceFragment } from './ProductPagePrice.gql'
9
9
  import type { UseCustomizableOptionPriceProps } from './useCustomizableOptionPrice'
10
10
  import { useCustomizableOptionPrice } from './useCustomizableOptionPrice'
11
11
 
@@ -31,22 +31,22 @@ export function ProductPagePrice(props: ProductPagePriceProps) {
31
31
  return (
32
32
  <>
33
33
  {regularPrice.value !== price.value && (
34
- <InContextMask
34
+ <PrivateQueryMask
35
35
  component='span'
36
36
  className={classes.discountPrice}
37
37
  skeleton={{ variant: 'text', sx: { width: '3em', transform: 'none' } }}
38
38
  sx={[{ textDecoration: 'line-through', color: 'text.disabled', marginRight: '8px' }]}
39
39
  >
40
40
  <Money {...regularPrice} />
41
- </InContextMask>
41
+ </PrivateQueryMask>
42
42
  )}
43
- <InContextMask
43
+ <PrivateQueryMask
44
44
  component='span'
45
45
  skeleton={{ variant: 'text', sx: { width: '3em', transform: 'none' } }}
46
46
  className={classes.finalPrice}
47
47
  >
48
48
  <Money {...price} value={priceValue} />
49
- </InContextMask>
49
+ </PrivateQueryMask>
50
50
  </>
51
51
  )
52
52
  }
@@ -1,4 +1,4 @@
1
- import { InContextMask } from '@graphcommerce/graphql'
1
+ import { PrivateQueryMask } from '@graphcommerce/graphql'
2
2
  import { Money } from '@graphcommerce/magento-store'
3
3
  import { filterNonNullableKeys } from '@graphcommerce/next-ui'
4
4
  import { Trans } from '@lingui/react'
@@ -22,7 +22,7 @@ export function ProductPagePriceTiers(props: ProductPagePriceTiersProps) {
22
22
  if (!priceTiers.length) return null
23
23
 
24
24
  return (
25
- <InContextMask sx={sx} variant='rectangular'>
25
+ <PrivateQueryMask sx={sx} variant='rectangular'>
26
26
  {priceTiers.map(({ quantity, final_price, discount }) => (
27
27
  <div key={quantity}>
28
28
  <Trans
@@ -32,6 +32,6 @@ export function ProductPagePriceTiers(props: ProductPagePriceTiersProps) {
32
32
  />
33
33
  </div>
34
34
  ))}
35
- </InContextMask>
35
+ </PrivateQueryMask>
36
36
  )
37
37
  }
@@ -5,6 +5,7 @@ import { ProductStaticPathsDocument } from './ProductStaticPaths.gql'
5
5
 
6
6
  /**
7
7
  * @deprecated Not used anymore, use `getProductStaticPaths` instead.
8
+ * @public
8
9
  */
9
10
  export async function getSitemapPaths(
10
11
  client: ApolloClient<NormalizedCacheObject>,
@@ -6,6 +6,7 @@ import type { ProductWeightFragment } from './ProductWeight.gql'
6
6
 
7
7
  export type ProductWeightProps = Omit<UnitFormatProps, 'unit'> & { product: ProductWeightFragment }
8
8
 
9
+ /** @public */
9
10
  export function ProductWeight(props: ProductWeightProps) {
10
11
  const { product, ...rest } = props
11
12
 
@@ -2,7 +2,7 @@ import type { ProductLinkFragment } from './ProductLink.gql'
2
2
 
3
3
  export type ProductLinkProps = Omit<ProductLinkFragment, 'uid'>
4
4
 
5
- export const productRoute = import.meta.graphCommerce.productRoute ?? '/p/'
5
+ const productRoute = import.meta.graphCommerce.productRoute ?? '/p/'
6
6
 
7
7
  export function productPath(urlKey: string) {
8
8
  return `${productRoute}${urlKey}`
@@ -1,6 +1,6 @@
1
1
  import { debounce } from '@graphcommerce/ecommerce-ui'
2
2
  import type { ApolloClient } from '@graphcommerce/graphql'
3
- import { getInContextInput, useInContextQuery, useQuery } from '@graphcommerce/graphql'
3
+ import { getPrivateQueryContext, usePrivateQuery, useQuery } from '@graphcommerce/graphql'
4
4
  import { StoreConfigDocument } from '@graphcommerce/magento-store'
5
5
  import { showPageLoadIndicator } from '@graphcommerce/next-ui'
6
6
  import { useEventCallback } from '@mui/material'
@@ -41,7 +41,7 @@ export const prefetchProductList = debounce(
41
41
 
42
42
  showPageLoadIndicator.set(true)
43
43
 
44
- const context = getInContextInput(client)
44
+ const context = getPrivateQueryContext(client)
45
45
  const productList = client.query({
46
46
  query: ProductListDocument,
47
47
  variables: { ...variables, context },
@@ -103,8 +103,8 @@ export function useProductList<
103
103
  const { params, shallow } = useRouterFilterParams(props)
104
104
  const variables = useProductListApplyCategoryDefaults(params, category)
105
105
 
106
- const result = useInContextQuery(ProductListDocument, { variables, skip: !shallow }, props)
107
- const filters = useInContextQuery(
106
+ const result = usePrivateQuery(ProductListDocument, { variables, skip: !shallow }, props)
107
+ const filters = usePrivateQuery(
108
108
  ProductFiltersDocument,
109
109
  { variables: categoryDefaultsToProductListFilters(variables), skip: !shallow },
110
110
  props,
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": "9.0.0-canary.115",
5
+ "version": "9.0.0-canary.116",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -18,18 +18,18 @@
18
18
  "typescript": "5.7.2"
19
19
  },
20
20
  "peerDependencies": {
21
- "@graphcommerce/ecommerce-ui": "^9.0.0-canary.115",
22
- "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.115",
23
- "@graphcommerce/framer-next-pages": "^9.0.0-canary.115",
24
- "@graphcommerce/framer-scroller": "^9.0.0-canary.115",
25
- "@graphcommerce/graphql": "^9.0.0-canary.115",
26
- "@graphcommerce/graphql-mesh": "^9.0.0-canary.115",
27
- "@graphcommerce/image": "^9.0.0-canary.115",
28
- "@graphcommerce/magento-cart": "^9.0.0-canary.115",
29
- "@graphcommerce/magento-store": "^9.0.0-canary.115",
30
- "@graphcommerce/next-ui": "^9.0.0-canary.115",
31
- "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.115",
32
- "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.115",
21
+ "@graphcommerce/ecommerce-ui": "^9.0.0-canary.116",
22
+ "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.116",
23
+ "@graphcommerce/framer-next-pages": "^9.0.0-canary.116",
24
+ "@graphcommerce/framer-scroller": "^9.0.0-canary.116",
25
+ "@graphcommerce/graphql": "^9.0.0-canary.116",
26
+ "@graphcommerce/graphql-mesh": "^9.0.0-canary.116",
27
+ "@graphcommerce/image": "^9.0.0-canary.116",
28
+ "@graphcommerce/magento-cart": "^9.0.0-canary.116",
29
+ "@graphcommerce/magento-store": "^9.0.0-canary.116",
30
+ "@graphcommerce/next-ui": "^9.0.0-canary.116",
31
+ "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.116",
32
+ "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.116",
33
33
  "@lingui/core": "^4.2.1",
34
34
  "@lingui/macro": "^4.2.1",
35
35
  "@lingui/react": "^4.2.1",
@@ -1,142 +0,0 @@
1
- import { NumberFieldElement } from '@graphcommerce/ecommerce-ui'
2
- import type { ProductInterface } from '@graphcommerce/graphql-mesh'
3
- import { ApolloCartErrorAlert, useFormGqlMutationCart } from '@graphcommerce/magento-cart'
4
- import type { MoneyProps } from '@graphcommerce/magento-store'
5
- import { Money } from '@graphcommerce/magento-store'
6
- import {
7
- Button,
8
- IconSvg,
9
- MessageSnackbar,
10
- extendableComponent,
11
- iconChevronRight,
12
- } from '@graphcommerce/next-ui'
13
- import { Trans } from '@lingui/macro'
14
- import type { ButtonProps } from '@mui/material'
15
- import { Alert, Box, Divider, Typography } from '@mui/material'
16
- import React from 'react'
17
- import type { ProductAddToCartMutationVariables } from './ProductAddToCart.gql'
18
- import { ProductAddToCartDocument } from './ProductAddToCart.gql'
19
-
20
- const { classes, selectors } = extendableComponent('ProductAddToCart', [
21
- 'root',
22
- 'button',
23
- 'price',
24
- 'divider',
25
- 'buttonWrapper',
26
- ] as const)
27
-
28
- export type AddToCartProps = React.ComponentProps<typeof ProductAddToCart>
29
-
30
- /** @deprecated Please us AddProductsToCartForm and it's components */
31
- export function ProductAddToCart(
32
- props: Pick<ProductInterface, 'name'> & {
33
- variables: Omit<ProductAddToCartMutationVariables, 'cartId'>
34
- name: string
35
- price: MoneyProps
36
- additionalButtons?: React.ReactNode
37
- children?: React.ReactNode
38
- } & Omit<ButtonProps, 'type' | 'name'>,
39
- ) {
40
- const { name, children, variables, price, sx, additionalButtons, ...buttonProps } = props
41
-
42
- const form = useFormGqlMutationCart(ProductAddToCartDocument, {
43
- defaultValues: { ...variables },
44
- })
45
-
46
- const { handleSubmit, formState, error, control, required, data } = form
47
- const submitHandler = handleSubmit(() => {})
48
-
49
- return (
50
- <Box component='form' onSubmit={submitHandler} noValidate className={classes.root} sx={sx}>
51
- <Divider className={classes.divider} sx={(theme) => ({ margin: `${theme.spacings.xs} 0` })} />
52
-
53
- <Typography
54
- variant='h4'
55
- className={classes.price}
56
- sx={(theme) => ({
57
- fontWeight: theme.typography.fontWeightBold,
58
- margin: `${theme.spacings.sm} 0`,
59
- })}
60
- >
61
- <Money {...price} />
62
- </Typography>
63
-
64
- <NumberFieldElement
65
- variant='outlined'
66
- error={formState.isSubmitted && !!formState.errors.quantity}
67
- required={required.quantity}
68
- inputProps={{ min: 1 }}
69
- name='quantity'
70
- rules={{ required: required.quantity }}
71
- helperText={formState.isSubmitted && formState.errors.quantity?.message}
72
- disabled={formState.isSubmitting}
73
- size='small'
74
- control={control}
75
- />
76
- {children}
77
- <Box
78
- sx={(theme) => ({
79
- display: 'flex',
80
- alignItems: 'center',
81
- columnGap: theme.spacings.xs,
82
- })}
83
- className={classes.buttonWrapper}
84
- >
85
- <Button
86
- type='submit'
87
- className={classes.button}
88
- loading={formState.isSubmitting}
89
- color='primary'
90
- variant='pill'
91
- size='large'
92
- sx={(theme) => ({
93
- marginTop: theme.spacings.sm,
94
- marginBottom: theme.spacings.sm,
95
- width: '100%',
96
- })}
97
- {...buttonProps}
98
- >
99
- <Trans>Add to Cart</Trans>
100
- </Button>
101
- {additionalButtons}
102
- </Box>
103
-
104
- <ApolloCartErrorAlert error={error} />
105
-
106
- {data?.addProductsToCart?.user_errors.map((e) => (
107
- <Box key={e?.code}>
108
- <Alert severity='error'>{e?.message}</Alert>
109
- </Box>
110
- ))}
111
-
112
- <MessageSnackbar
113
- open={
114
- !formState.isSubmitting &&
115
- formState.isSubmitSuccessful &&
116
- !error?.message &&
117
- !data?.addProductsToCart?.user_errors?.length
118
- }
119
- variant='pill'
120
- severity='success'
121
- autoHide
122
- action={
123
- <Button
124
- href='/cart'
125
- id='view-shopping-cart-button'
126
- size='medium'
127
- variant='pill'
128
- color='secondary'
129
- endIcon={<IconSvg src={iconChevronRight} />}
130
- >
131
- <Trans>View shopping cart</Trans>
132
- </Button>
133
- }
134
- >
135
- <Trans>
136
- <strong>{name}</strong> has been added to your shopping cart!
137
- </Trans>
138
- </MessageSnackbar>
139
- </Box>
140
- )
141
- }
142
- ProductAddToCart.selectors = selectors
@@ -1,10 +0,0 @@
1
- import { Image } from '@graphcommerce/image'
2
- import type { ProductImageFragment } from './ProductImage.gql'
3
-
4
- export function ProductImage(props: ProductImageFragment) {
5
- const { url, label } = props
6
-
7
- if (!url) return null
8
-
9
- return <Image src={url} width={328} height={328} alt={label ?? ''} dontReportWronglySizedImages />
10
- }
@@ -1,10 +0,0 @@
1
- import type { ProductVideoFragment } from './ProductVideo.gql'
2
-
3
- export function ProductVideo(props: ProductVideoFragment) {
4
- const { video_content } = props
5
-
6
- if (!video_content?.video_url) return null
7
-
8
- // eslint-disable-next-line jsx-a11y/media-has-caption
9
- return <video src={video_content.video_url} />
10
- }