@graphcommerce/magento-product 9.0.0-canary.98 → 9.0.0
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 +211 -1277
- package/components/AddProductsToCart/AddProductsToCartButton.tsx +4 -5
- package/components/AddProductsToCart/AddProductsToCartError.tsx +3 -2
- package/components/AddProductsToCart/AddProductsToCartFab.tsx +5 -6
- package/components/AddProductsToCart/AddProductsToCartForm.tsx +15 -19
- package/components/AddProductsToCart/AddProductsToCartQuantity.tsx +7 -5
- package/components/AddProductsToCart/AddProductsToCartSnackbar.tsx +2 -1
- package/components/AddProductsToCart/AddProductsToCartSnackbarMessage.tsx +5 -6
- package/components/AddProductsToCart/findAddedItems.ts +2 -2
- package/components/AddProductsToCart/toUserErrors.ts +2 -2
- package/components/AddProductsToCart/useAddProductsToCartAction.ts +4 -3
- package/components/AddProductsToCart/useFormAddProductsToCart.ts +3 -3
- package/components/JsonLdProduct/ProductPageJsonLd.tsx +1 -1
- package/components/JsonLdProduct/jsonLdProduct.tsx +2 -2
- package/components/ProductAddToCart/index.ts +0 -1
- package/components/ProductCustomizable/CustomizableAreaOption.tsx +5 -4
- package/components/ProductCustomizable/CustomizableCheckboxOption.tsx +4 -8
- package/components/ProductCustomizable/CustomizableDateOption.tsx +3 -3
- package/components/ProductCustomizable/CustomizableDropDownOption.tsx +6 -6
- package/components/ProductCustomizable/CustomizableFieldOption.tsx +3 -3
- package/components/ProductCustomizable/CustomizableMultipleOption.tsx +4 -8
- package/components/ProductCustomizable/CustomizableRadioOption.tsx +4 -8
- package/components/ProductCustomizable/ProductCustomizable.tsx +7 -6
- package/components/ProductFiltersPro/PriceSlider.tsx +4 -2
- package/components/ProductFiltersPro/ProductFilterEqualChip.tsx +1 -1
- package/components/ProductFiltersPro/ProductFilterEqualSection.tsx +1 -1
- package/components/ProductFiltersPro/ProductFilterRangeChip.tsx +1 -1
- package/components/ProductFiltersPro/ProductFiltersPro.tsx +10 -19
- package/components/ProductFiltersPro/ProductFiltersProAggregations.tsx +2 -2
- package/components/ProductFiltersPro/ProductFiltersProAllFiltersChip.tsx +7 -7
- package/components/ProductFiltersPro/ProductFiltersProAllFiltersSidebar.tsx +8 -15
- package/components/ProductFiltersPro/ProductFiltersProCategorySection.tsx +6 -8
- package/components/ProductFiltersPro/ProductFiltersProChips.tsx +4 -2
- package/components/ProductFiltersPro/ProductFiltersProClearAll.tsx +2 -2
- package/components/ProductFiltersPro/ProductFiltersProLayoutSidebar.tsx +8 -2
- package/components/ProductFiltersPro/ProductFiltersProLimitChip.tsx +4 -2
- package/components/ProductFiltersPro/ProductFiltersProLimitSection.tsx +3 -2
- package/components/ProductFiltersPro/ProductFiltersProNoResults.tsx +5 -4
- package/components/ProductFiltersPro/ProductFiltersProSortChip.tsx +4 -2
- package/components/ProductFiltersPro/ProductFiltersProSortDirectionArrow.tsx +5 -3
- package/components/ProductFiltersPro/ProductFiltersProSortSection.tsx +3 -2
- package/components/ProductFiltersPro/activeAggregations.ts +2 -2
- package/components/ProductFiltersPro/applyAggregationCount.ts +2 -2
- package/components/ProductFiltersPro/useProductFiltersProClearAllAction.ts +1 -1
- package/components/ProductFiltersPro/useProductFiltersProSort.tsx +3 -3
- package/components/ProductList/ProductList.graphql +4 -3
- package/components/ProductListCount/ProductListCount.tsx +3 -2
- package/components/ProductListFilters/FilterCheckboxType.tsx +5 -4
- package/components/ProductListFilters/FilterEqualType.tsx +7 -7
- package/components/ProductListFilters/FilterRangeType.tsx +4 -3
- package/components/ProductListFilters/ProductFilters.graphql +2 -2
- package/components/ProductListFilters/ProductListFilters.tsx +3 -3
- package/components/ProductListFiltersContainer/ProductListFiltersContainer.tsx +5 -4
- package/components/ProductListItem/ProductDiscountLabel.tsx +4 -3
- package/components/ProductListItem/ProductListItem.tsx +58 -31
- package/components/ProductListItem/ProductListItemImage.tsx +9 -7
- package/components/ProductListItem/ProductListItemImageContainer.tsx +9 -8
- package/components/ProductListItem/ProductListItemLinkOrDiv.tsx +13 -8
- package/components/ProductListItem/ProductListItemTitleAndPrice.tsx +4 -3
- package/components/ProductListItems/ProductListItemsBase.tsx +24 -18
- package/components/ProductListItems/ProductListParamsProvider.tsx +2 -2
- package/components/ProductListItems/filterTypes.tsx +4 -4
- package/components/ProductListItems/filteredProductList.tsx +2 -2
- package/components/ProductListItems/getFilterTypes.ts +2 -1
- package/components/ProductListItems/productListApplyCategoryDefaults.ts +5 -4
- package/components/ProductListItems/renderer.tsx +3 -2
- package/components/ProductListLink/ProductListLink.tsx +5 -3
- package/components/ProductListPagination/ProductListPagination.tsx +6 -5
- package/components/ProductListPrice/ProductListPrice.tsx +12 -7
- package/components/ProductListSort/ProductListSort.tsx +8 -6
- package/components/ProductListSuggestions/ProductListSearchSuggestion.graphql +3 -0
- package/components/ProductListSuggestions/ProductListSuggestions.graphql +1 -1
- package/components/ProductListSuggestions/ProductListSuggestions.tsx +2 -2
- package/components/ProductPage/ProductPageAddToCartRow.tsx +4 -3
- package/components/ProductPageBreadcrumb/ProductPageBreadcrumb.tsx +6 -4
- package/components/ProductPageBreadcrumb/ProductPageBreadcrumbs.tsx +3 -3
- package/components/ProductPageCategory/productPageCategory.ts +1 -1
- package/components/ProductPageDescription/ProductPageDescription.tsx +7 -6
- package/components/ProductPageGallery/ProductPageGallery.tsx +3 -7
- package/components/ProductPageMeta/ProductPageMeta.tsx +2 -2
- package/components/ProductPageName/ProductPageName.tsx +2 -2
- package/components/ProductPagePrice/ProductPagePrice.tsx +10 -11
- package/components/ProductPagePrice/ProductPagePriceTiers.tsx +5 -5
- package/components/ProductPagePrice/getProductTierPrice.ts +2 -2
- package/components/ProductPagePrice/useCustomizableOptionPrice.ts +7 -6
- package/components/ProductScroller/ProductScroller.tsx +11 -16
- package/components/ProductShortDescription/ProductShortDescription.tsx +3 -2
- package/components/ProductSidebarDelivery/ProductSidebarDelivery.tsx +4 -4
- package/components/ProductSpecs/ProductSpecs.tsx +5 -4
- package/components/ProductSpecs/ProductSpecsAggregations.tsx +2 -2
- package/components/ProductSpecs/ProductSpecsCustomAttributes.tsx +3 -3
- package/components/ProductStaticPaths/getProductStaticPaths.ts +4 -3
- package/components/ProductStaticPaths/getSitemapPaths.ts +3 -2
- package/components/ProductWeight/ProductWeight.tsx +5 -7
- package/components/index.ts +5 -0
- package/context/productListParamsContext.ts +1 -1
- package/hooks/useProductLink.ts +6 -2
- package/hooks/useProductList.ts +14 -17
- package/hooks/useProductListLink.ts +7 -5
- package/hooks/useProductListLinkReplace.ts +1 -1
- package/package.json +15 -15
- package/test/productURL.fixture.ts +1 -1
- package/tsconfig.json +1 -1
- package/components/ProductAddToCart/ProductAddToCart.tsx +0 -139
- package/components/ProductPageGallery/ProductImage.tsx +0 -10
- package/components/ProductPageGallery/ProductVideo.tsx +0 -10
@@ -1,14 +1,13 @@
|
|
1
1
|
import { useWatch } from '@graphcommerce/ecommerce-ui'
|
2
|
-
import {
|
2
|
+
import { PrivateQueryMask } from '@graphcommerce/graphql'
|
3
3
|
import { Money } from '@graphcommerce/magento-store'
|
4
4
|
import { extendableComponent } from '@graphcommerce/next-ui'
|
5
|
-
import { AddToCartItemSelector
|
6
|
-
import {
|
5
|
+
import type { AddToCartItemSelector } from '../AddProductsToCart'
|
6
|
+
import { useFormAddProductsToCart } from '../AddProductsToCart'
|
7
7
|
import { getProductTierPrice } from './getProductTierPrice'
|
8
|
-
import {
|
9
|
-
|
10
|
-
|
11
|
-
} from './useCustomizableOptionPrice'
|
8
|
+
import type { ProductPagePriceFragment } from './ProductPagePrice.gql'
|
9
|
+
import type { UseCustomizableOptionPriceProps } from './useCustomizableOptionPrice'
|
10
|
+
import { useCustomizableOptionPrice } from './useCustomizableOptionPrice'
|
12
11
|
|
13
12
|
export type ProductPagePriceProps = { product: ProductPagePriceFragment } & AddToCartItemSelector &
|
14
13
|
UseCustomizableOptionPriceProps
|
@@ -32,22 +31,22 @@ export function ProductPagePrice(props: ProductPagePriceProps) {
|
|
32
31
|
return (
|
33
32
|
<>
|
34
33
|
{regularPrice.value !== price.value && (
|
35
|
-
<
|
34
|
+
<PrivateQueryMask
|
36
35
|
component='span'
|
37
36
|
className={classes.discountPrice}
|
38
37
|
skeleton={{ variant: 'text', sx: { width: '3em', transform: 'none' } }}
|
39
38
|
sx={[{ textDecoration: 'line-through', color: 'text.disabled', marginRight: '8px' }]}
|
40
39
|
>
|
41
40
|
<Money {...regularPrice} />
|
42
|
-
</
|
41
|
+
</PrivateQueryMask>
|
43
42
|
)}
|
44
|
-
<
|
43
|
+
<PrivateQueryMask
|
45
44
|
component='span'
|
46
45
|
skeleton={{ variant: 'text', sx: { width: '3em', transform: 'none' } }}
|
47
46
|
className={classes.finalPrice}
|
48
47
|
>
|
49
48
|
<Money {...price} value={priceValue} />
|
50
|
-
</
|
49
|
+
</PrivateQueryMask>
|
51
50
|
</>
|
52
51
|
)
|
53
52
|
}
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import {
|
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'
|
5
|
-
import { SxProps, Theme } from '@mui/material'
|
6
|
-
import { ProductPagePriceFragment } from './ProductPagePrice.gql'
|
5
|
+
import type { SxProps, Theme } from '@mui/material'
|
6
|
+
import type { ProductPagePriceFragment } from './ProductPagePrice.gql'
|
7
7
|
|
8
8
|
export type ProductPagePriceTiersProps = {
|
9
9
|
sx?: SxProps<Theme>
|
@@ -22,7 +22,7 @@ export function ProductPagePriceTiers(props: ProductPagePriceTiersProps) {
|
|
22
22
|
if (!priceTiers.length) return null
|
23
23
|
|
24
24
|
return (
|
25
|
-
<
|
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
|
-
</
|
35
|
+
</PrivateQueryMask>
|
36
36
|
)
|
37
37
|
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { MoneyFragment } from '@graphcommerce/magento-store'
|
2
|
-
import { ProductPagePriceFragment } from './ProductPagePrice.gql'
|
1
|
+
import type { MoneyFragment } from '@graphcommerce/magento-store'
|
2
|
+
import type { ProductPagePriceFragment } from './ProductPagePrice.gql'
|
3
3
|
|
4
4
|
export function getProductTierPrice(
|
5
5
|
price: Pick<ProductPagePriceFragment, 'price_tiers'>,
|
@@ -1,15 +1,16 @@
|
|
1
1
|
import { useWatch } from '@graphcommerce/ecommerce-ui'
|
2
|
-
import { MoneyFragment } from '@graphcommerce/magento-store'
|
2
|
+
import type { MoneyFragment } from '@graphcommerce/magento-store'
|
3
3
|
import { filterNonNullableKeys, isTypename, nonNullable } from '@graphcommerce/next-ui'
|
4
|
-
import { AddToCartItemSelector
|
5
|
-
import {
|
6
|
-
|
4
|
+
import type { AddToCartItemSelector } from '../AddProductsToCart'
|
5
|
+
import { useFormAddProductsToCart } from '../AddProductsToCart'
|
6
|
+
import type {
|
7
|
+
AnyOption,
|
7
8
|
CustomizableProductOptionBase,
|
8
9
|
OptionValueSelector,
|
9
|
-
AnyOption,
|
10
10
|
SelectorsProp,
|
11
11
|
} from '../ProductCustomizable/productCustomizableSelectors'
|
12
|
-
import {
|
12
|
+
import { productCustomizableSelectors } from '../ProductCustomizable/productCustomizableSelectors'
|
13
|
+
import type { ProductPagePriceFragment } from './ProductPagePrice.gql'
|
13
14
|
import { getProductTierPrice } from './getProductTierPrice'
|
14
15
|
|
15
16
|
export type UseCustomizableOptionPriceProps = {
|
@@ -1,18 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
|
4
|
-
|
5
|
-
ContainerProps,
|
6
|
-
SxProps,
|
7
|
-
Theme,
|
8
|
-
Typography,
|
9
|
-
TypographyProps,
|
10
|
-
useTheme,
|
11
|
-
} from '@mui/material'
|
1
|
+
import type { ItemScrollerProps } from '@graphcommerce/next-ui'
|
2
|
+
import { ItemScroller, RenderType, responsiveVal } from '@graphcommerce/next-ui'
|
3
|
+
import type { ContainerProps, SxProps, Theme, TypographyProps } from '@mui/material'
|
4
|
+
import { Box, Container, Typography, useTheme } from '@mui/material'
|
12
5
|
import React, { forwardRef, useContext } from 'react'
|
13
6
|
import { AddProductsToCartContext, AddProductsToCartForm } from '../AddProductsToCart'
|
14
|
-
import { ProductListItemProps } from '../ProductListItem/ProductListItem'
|
15
|
-
import { ProductListItemRenderer, ProductListItemType } from '../ProductListItems/renderer'
|
7
|
+
import type { ProductListItemProps } from '../ProductListItem/ProductListItem'
|
8
|
+
import type { ProductListItemRenderer, ProductListItemType } from '../ProductListItems/renderer'
|
16
9
|
|
17
10
|
export type ProductScrollerProps = {
|
18
11
|
title?: React.ReactNode
|
@@ -22,7 +15,8 @@ export type ProductScrollerProps = {
|
|
22
15
|
sx?: SxProps<Theme>
|
23
16
|
containerProps?: ContainerProps
|
24
17
|
titleProps?: TypographyProps
|
25
|
-
itemScrollerProps?: ItemScrollerProps
|
18
|
+
itemScrollerProps?: Omit<ItemScrollerProps, 'children'>
|
19
|
+
sizes?: string
|
26
20
|
}
|
27
21
|
export const ProductScroller = forwardRef<HTMLDivElement, ProductScrollerProps>(
|
28
22
|
(props: ProductScrollerProps, ref) => {
|
@@ -35,13 +29,14 @@ export const ProductScroller = forwardRef<HTMLDivElement, ProductScrollerProps>(
|
|
35
29
|
containerProps,
|
36
30
|
titleProps,
|
37
31
|
itemScrollerProps,
|
32
|
+
sizes = responsiveVal(200, 300),
|
38
33
|
} = props
|
39
34
|
|
40
35
|
const theme = useTheme()
|
41
36
|
|
42
37
|
const Wrapper = useContext(AddProductsToCartContext) ? React.Fragment : AddProductsToCartForm
|
43
38
|
|
44
|
-
if (!items) return null
|
39
|
+
if (!items || !items.length) return null
|
45
40
|
|
46
41
|
return (
|
47
42
|
<Box sx={sx} ref={ref}>
|
@@ -61,7 +56,7 @@ export const ProductScroller = forwardRef<HTMLDivElement, ProductScrollerProps>(
|
|
61
56
|
renderer={productListRenderer}
|
62
57
|
{...item}
|
63
58
|
imageOnly={imageOnly}
|
64
|
-
sizes={
|
59
|
+
sizes={sizes}
|
65
60
|
/>
|
66
61
|
))}
|
67
62
|
</ItemScroller>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { extendableComponent } from '@graphcommerce/next-ui'
|
2
|
-
import { SxProps, Theme
|
3
|
-
import {
|
2
|
+
import type { SxProps, Theme } from '@mui/material'
|
3
|
+
import { Typography } from '@mui/material'
|
4
|
+
import type { ProductShortDescriptionFragment } from './ProductShortDescription.gql'
|
4
5
|
|
5
6
|
export type ProductShortDescriptionProps = {
|
6
7
|
product: ProductShortDescriptionFragment
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { breakpointVal, iconOrderBefore
|
1
|
+
import { IconSvg, breakpointVal, iconOrderBefore } from '@graphcommerce/next-ui'
|
2
2
|
import { Trans } from '@lingui/react'
|
3
3
|
import { Box, darken, lighten } from '@mui/material'
|
4
|
-
import { UseAddProductsToCartActionFragment } from '../AddProductsToCart/UseAddProductsToCartAction.gql'
|
4
|
+
import type { UseAddProductsToCartActionFragment } from '../AddProductsToCart/UseAddProductsToCartAction.gql'
|
5
5
|
|
6
|
-
type ProductSidebarDeliveryProps = {
|
6
|
+
export type ProductSidebarDeliveryProps = {
|
7
7
|
product?: UseAddProductsToCartActionFragment
|
8
8
|
}
|
9
9
|
|
@@ -39,7 +39,7 @@ export function ProductSidebarDelivery(props: ProductSidebarDeliveryProps) {
|
|
39
39
|
"image title"
|
40
40
|
". subtitle"
|
41
41
|
`,
|
42
|
-
gridTemplateColumns:
|
42
|
+
gridTemplateColumns: 'min-content auto',
|
43
43
|
columnGap: theme.spacings.xxs,
|
44
44
|
background:
|
45
45
|
theme.palette.mode === 'light'
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
1
|
+
import { Row, SectionContainer, extendableComponent, responsiveVal } from '@graphcommerce/next-ui'
|
2
|
+
import type { SxProps, Theme } from '@mui/material'
|
3
|
+
import { Box } from '@mui/material'
|
4
|
+
import type { ProductSpecsFragment } from './ProductSpecs.gql'
|
4
5
|
import { ProductSpecsAggregations } from './ProductSpecsAggregations'
|
5
6
|
import { ProductSpecsCustomAttributes } from './ProductSpecsCustomAttributes'
|
6
7
|
|
@@ -10,7 +11,7 @@ export type ProductSpecsProps = ProductSpecsFragment & {
|
|
10
11
|
children?: React.ReactNode
|
11
12
|
}
|
12
13
|
|
13
|
-
const name = 'ProductSpecs'
|
14
|
+
const name = 'ProductSpecs'
|
14
15
|
const parts = ['root', 'specs', 'options'] as const
|
15
16
|
const { classes } = extendableComponent(name, parts)
|
16
17
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { extendableComponent } from '@graphcommerce/next-ui'
|
2
2
|
import { Box } from '@mui/material'
|
3
|
-
import { ProductSpecsFragment } from './ProductSpecs.gql'
|
3
|
+
import type { ProductSpecsFragment } from './ProductSpecs.gql'
|
4
4
|
|
5
|
-
const name = 'ProductSpecs'
|
5
|
+
const name = 'ProductSpecs'
|
6
6
|
const parts = ['root', 'specs', 'options'] as const
|
7
7
|
const { classes } = extendableComponent(name, parts)
|
8
8
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { useQuery } from '@graphcommerce/graphql'
|
2
|
-
import {
|
2
|
+
import { ListFormat, extendableComponent } from '@graphcommerce/next-ui'
|
3
3
|
import { Box } from '@mui/material'
|
4
|
-
import { ProductSpecsFragment } from './ProductSpecs.gql'
|
4
|
+
import type { ProductSpecsFragment } from './ProductSpecs.gql'
|
5
5
|
import { ProductSpecsTypesDocument } from './ProductSpecsTypes.gql'
|
6
6
|
|
7
|
-
const name = 'ProductSpecs'
|
7
|
+
const name = 'ProductSpecs'
|
8
8
|
const parts = ['root', 'specs', 'options'] as const
|
9
9
|
const { classes } = extendableComponent(name, parts)
|
10
10
|
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import { ApolloClient, ApolloQueryResult, NormalizedCacheObject } from '@graphcommerce/graphql'
|
2
|
-
import { GetStaticPathsResult } from 'next'
|
3
|
-
import {
|
1
|
+
import type { ApolloClient, ApolloQueryResult, NormalizedCacheObject } from '@graphcommerce/graphql'
|
2
|
+
import type { GetStaticPathsResult } from 'next'
|
3
|
+
import type { ProductStaticPathsQuery } from './ProductStaticPaths.gql'
|
4
|
+
import { ProductStaticPathsDocument } from './ProductStaticPaths.gql'
|
4
5
|
|
5
6
|
type Return = GetStaticPathsResult<{ url: string }>
|
6
7
|
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import { ApolloClient, NormalizedCacheObject } from '@graphcommerce/graphql'
|
1
|
+
import type { ApolloClient, NormalizedCacheObject } from '@graphcommerce/graphql'
|
2
2
|
import { canonicalize, nonNullable } from '@graphcommerce/next-ui'
|
3
3
|
import { productLink } from '../../hooks/useProductLink'
|
4
4
|
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>,
|
@@ -24,7 +25,7 @@ export async function getSitemapPaths(
|
|
24
25
|
|
25
26
|
const options = { locale, defaultLocale, pathname: '/', isLocaleDomain: false }
|
26
27
|
const lastmod = new Date().toISOString()
|
27
|
-
const changefreq = 'daily'
|
28
|
+
const changefreq = 'daily'
|
28
29
|
const priority = 0.7
|
29
30
|
|
30
31
|
const paths = (await Promise.all(result))
|
@@ -1,10 +1,12 @@
|
|
1
1
|
import { useQuery } from '@graphcommerce/graphql'
|
2
2
|
import { StoreConfigDocument } from '@graphcommerce/magento-store'
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import type { UnitFormatProps } from '@graphcommerce/next-ui'
|
4
|
+
import { UnitFormat } from '@graphcommerce/next-ui'
|
5
|
+
import type { ProductWeightFragment } from './ProductWeight.gql'
|
5
6
|
|
6
7
|
export type ProductWeightProps = Omit<UnitFormatProps, 'unit'> & { product: ProductWeightFragment }
|
7
8
|
|
9
|
+
/** @public */
|
8
10
|
export function ProductWeight(props: ProductWeightProps) {
|
9
11
|
const { product, ...rest } = props
|
10
12
|
|
@@ -14,9 +16,5 @@ export function ProductWeight(props: ProductWeightProps) {
|
|
14
16
|
|
15
17
|
const unit = conf?.storeConfig?.weight_unit === 'lbs' ? 'pound' : 'kilogram'
|
16
18
|
|
17
|
-
return
|
18
|
-
<UnitFormat unit={unit} {...rest}>
|
19
|
-
{product.weight}
|
20
|
-
</UnitFormat>
|
21
|
-
)
|
19
|
+
return <UnitFormat unit={unit} {...rest} value={product.weight} />
|
22
20
|
}
|
package/components/index.ts
CHANGED
@@ -8,6 +8,10 @@ export * from './ProductListCount/ProductListCount'
|
|
8
8
|
export * from './ProductListFilters'
|
9
9
|
export * from './ProductListFiltersContainer/ProductListFiltersContainer'
|
10
10
|
export * from './ProductListItem/ProductListItem'
|
11
|
+
export * from './ProductListItem/ProductListItemImage'
|
12
|
+
export * from './ProductListItem/ProductListItemTitleAndPrice'
|
13
|
+
export * from './ProductListItem/ProductListItemImageContainer'
|
14
|
+
export * from './ProductListItem/ProductListItemLinkOrDiv'
|
11
15
|
export * from './ProductListItems/filteredProductList'
|
12
16
|
export * from './ProductListItems/filterTypes'
|
13
17
|
export * from './ProductListItems/getFilterTypes'
|
@@ -43,3 +47,4 @@ export * from './ProductWeight/ProductWeight'
|
|
43
47
|
export * from './ProductListPrice'
|
44
48
|
export * from './ProductListSuggestions/ProductListSuggestions'
|
45
49
|
export * from './ProductListSuggestions/ProductListSuggestions.gql'
|
50
|
+
export * from './ProductListSuggestions/ProductListSearchSuggestion.gql'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import { ProductListParams } from '../components/ProductListItems/filterTypes'
|
2
|
+
import type { ProductListParams } from '../components/ProductListItems/filterTypes'
|
3
3
|
|
4
4
|
export const productListParamsContext = React.createContext<{
|
5
5
|
params: ProductListParams
|
package/hooks/useProductLink.ts
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
import { ProductLinkFragment } from './ProductLink.gql'
|
1
|
+
import type { ProductLinkFragment } from './ProductLink.gql'
|
2
2
|
|
3
3
|
export type ProductLinkProps = Omit<ProductLinkFragment, 'uid'>
|
4
4
|
|
5
|
-
|
5
|
+
const productRoute = import.meta.graphCommerce.productRoute ?? '/p/'
|
6
|
+
|
7
|
+
export function productPath(urlKey: string) {
|
8
|
+
return `${productRoute}${urlKey}`
|
9
|
+
}
|
6
10
|
|
7
11
|
export function productLink(link: ProductLinkProps) {
|
8
12
|
return `${productRoute}${link.url_key}`
|
package/hooks/useProductList.ts
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
import { debounce } from '@graphcommerce/ecommerce-ui'
|
2
|
-
import {
|
3
|
-
|
4
|
-
useQuery,
|
5
|
-
useInContextQuery,
|
6
|
-
getInContextInput,
|
7
|
-
} from '@graphcommerce/graphql'
|
2
|
+
import type { ApolloClient } from '@graphcommerce/graphql'
|
3
|
+
import { getPrivateQueryContext, usePrivateQuery, useQuery } from '@graphcommerce/graphql'
|
8
4
|
import { StoreConfigDocument } from '@graphcommerce/magento-store'
|
9
5
|
import { showPageLoadIndicator } from '@graphcommerce/next-ui'
|
10
6
|
import { useEventCallback } from '@mui/material'
|
11
|
-
import {
|
7
|
+
import type {
|
12
8
|
FilterFormProviderProps,
|
13
|
-
ProductFiltersDocument,
|
14
9
|
ProductFiltersQuery,
|
15
10
|
ProductFiltersQueryVariables,
|
16
11
|
} from '../components'
|
17
|
-
import {
|
18
|
-
|
12
|
+
import { ProductFiltersDocument } from '../components'
|
13
|
+
import type {
|
19
14
|
ProductListQuery,
|
20
15
|
ProductListQueryVariables,
|
21
16
|
} from '../components/ProductList/ProductList.gql'
|
22
|
-
import {
|
23
|
-
import {
|
17
|
+
import { ProductListDocument } from '../components/ProductList/ProductList.gql'
|
18
|
+
import type { CategoryDefaultFragment } from '../components/ProductListItems/CategoryDefault.gql'
|
19
|
+
import type { ProductListParams } from '../components/ProductListItems/filterTypes'
|
20
|
+
import { toProductListParams } from '../components/ProductListItems/filterTypes'
|
24
21
|
import { useRouterFilterParams } from '../components/ProductListItems/filteredProductList'
|
25
22
|
import {
|
26
|
-
productListApplyCategoryDefaults,
|
27
23
|
categoryDefaultsToProductListFilters,
|
24
|
+
productListApplyCategoryDefaults,
|
28
25
|
useProductListApplyCategoryDefaults,
|
29
26
|
} from '../components/ProductListItems/productListApplyCategoryDefaults'
|
30
27
|
|
@@ -37,14 +34,14 @@ export const prefetchProductList = debounce(
|
|
37
34
|
variables: ProductListQueryVariables,
|
38
35
|
filtersVariables: ProductFiltersQueryVariables,
|
39
36
|
next: Next,
|
40
|
-
client: ApolloClient<
|
37
|
+
client: ApolloClient<unknown>,
|
41
38
|
shallow: boolean,
|
42
39
|
) => {
|
43
40
|
if (!shallow) return next(shallow)
|
44
41
|
|
45
42
|
showPageLoadIndicator.set(true)
|
46
43
|
|
47
|
-
const context =
|
44
|
+
const context = getPrivateQueryContext(client)
|
48
45
|
const productList = client.query({
|
49
46
|
query: ProductListDocument,
|
50
47
|
variables: { ...variables, context },
|
@@ -106,8 +103,8 @@ export function useProductList<
|
|
106
103
|
const { params, shallow } = useRouterFilterParams(props)
|
107
104
|
const variables = useProductListApplyCategoryDefaults(params, category)
|
108
105
|
|
109
|
-
const result =
|
110
|
-
const filters =
|
106
|
+
const result = usePrivateQuery(ProductListDocument, { variables, skip: !shallow }, props)
|
107
|
+
const filters = usePrivateQuery(
|
111
108
|
ProductFiltersDocument,
|
112
109
|
{ variables: categoryDefaultsToProductListFilters(variables), skip: !shallow },
|
113
110
|
props,
|
@@ -1,9 +1,11 @@
|
|
1
|
+
import type {
|
2
|
+
ProductFilterParams,
|
3
|
+
ProductListParams,
|
4
|
+
} from '../components/ProductListItems/filterTypes'
|
1
5
|
import {
|
2
6
|
isFilterTypeEqual,
|
3
7
|
isFilterTypeMatch,
|
4
8
|
isFilterTypeRange,
|
5
|
-
ProductFilterParams,
|
6
|
-
ProductListParams,
|
7
9
|
toFilterParams,
|
8
10
|
} from '../components/ProductListItems/filterTypes'
|
9
11
|
|
@@ -17,15 +19,15 @@ export function productListLinkFromFilter(props: ProductFilterParams): string {
|
|
17
19
|
if (isSearch) urlBase = search ? `search/${search}` : 'search'
|
18
20
|
|
19
21
|
// base url path generation
|
20
|
-
let paginateSort =
|
21
|
-
let query =
|
22
|
+
let paginateSort = ''
|
23
|
+
let query = ''
|
22
24
|
|
23
25
|
if (currentPage && currentPage > 1) paginateSort += `/page/${currentPage}`
|
24
26
|
|
25
27
|
// todo(paales): How should the URL look like with multiple sorts?
|
26
28
|
// Something like: /sort/position,price/dir/asc,asc
|
27
29
|
if (sort) query += `/sort/${sort}`
|
28
|
-
if (dir) query +=
|
30
|
+
if (dir) query += '/dir/desc'
|
29
31
|
if (pageSize) query += `/page-size/${pageSize}`
|
30
32
|
|
31
33
|
// Apply filters
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useRouter } from 'next/router'
|
2
|
-
import { ProductListParams } from '../components/ProductListItems/filterTypes'
|
2
|
+
import type { ProductListParams } from '../components/ProductListItems/filterTypes'
|
3
3
|
import { productListLink } from './useProductListLink'
|
4
4
|
import { useProductListParamsContext } from './useProductListParamsContext'
|
5
5
|
|
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
|
5
|
+
"version": "9.0.0",
|
6
6
|
"sideEffects": false,
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
8
8
|
"eslintConfig": {
|
@@ -15,26 +15,26 @@
|
|
15
15
|
"schema-dts": "^1.1.2"
|
16
16
|
},
|
17
17
|
"devDependencies": {
|
18
|
-
"typescript": "5.
|
18
|
+
"typescript": "5.7.2"
|
19
19
|
},
|
20
20
|
"peerDependencies": {
|
21
|
-
"@graphcommerce/ecommerce-ui": "^9.0.0
|
22
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.0
|
23
|
-
"@graphcommerce/framer-next-pages": "^9.0.0
|
24
|
-
"@graphcommerce/framer-scroller": "^9.0.0
|
25
|
-
"@graphcommerce/graphql": "^9.0.0
|
26
|
-
"@graphcommerce/graphql-mesh": "^9.0.0
|
27
|
-
"@graphcommerce/image": "^9.0.0
|
28
|
-
"@graphcommerce/magento-cart": "^9.0.0
|
29
|
-
"@graphcommerce/magento-store": "^9.0.0
|
30
|
-
"@graphcommerce/next-ui": "^9.0.0
|
31
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.0
|
32
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.0
|
21
|
+
"@graphcommerce/ecommerce-ui": "^9.0.0",
|
22
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0",
|
23
|
+
"@graphcommerce/framer-next-pages": "^9.0.0",
|
24
|
+
"@graphcommerce/framer-scroller": "^9.0.0",
|
25
|
+
"@graphcommerce/graphql": "^9.0.0",
|
26
|
+
"@graphcommerce/graphql-mesh": "^9.0.0",
|
27
|
+
"@graphcommerce/image": "^9.0.0",
|
28
|
+
"@graphcommerce/magento-cart": "^9.0.0",
|
29
|
+
"@graphcommerce/magento-store": "^9.0.0",
|
30
|
+
"@graphcommerce/next-ui": "^9.0.0",
|
31
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0",
|
32
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0",
|
33
33
|
"@lingui/core": "^4.2.1",
|
34
34
|
"@lingui/macro": "^4.2.1",
|
35
35
|
"@lingui/react": "^4.2.1",
|
36
36
|
"@mui/material": "^5.10.16",
|
37
|
-
"framer-motion": "^
|
37
|
+
"framer-motion": "^11.0.0",
|
38
38
|
"next": "*",
|
39
39
|
"react": "^18.2.0",
|
40
40
|
"react-dom": "^18.2.0"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
2
2
|
import { test as base } from '@graphcommerce/magento-store/test/apolloClientStore.fixture'
|
3
3
|
import { ProductStaticPathsDocument } from '../components/ProductStaticPaths/ProductStaticPaths.gql'
|
4
|
-
import { ProductTypenames } from '../components/ProductStaticPaths/getProductStaticPaths'
|
4
|
+
import type { ProductTypenames } from '../components/ProductStaticPaths/getProductStaticPaths'
|
5
5
|
import { productLink } from '../hooks/useProductLink'
|
6
6
|
|
7
7
|
type ProductUrls = {
|
package/tsconfig.json
CHANGED