@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.
Files changed (106) hide show
  1. package/CHANGELOG.md +211 -1277
  2. package/components/AddProductsToCart/AddProductsToCartButton.tsx +4 -5
  3. package/components/AddProductsToCart/AddProductsToCartError.tsx +3 -2
  4. package/components/AddProductsToCart/AddProductsToCartFab.tsx +5 -6
  5. package/components/AddProductsToCart/AddProductsToCartForm.tsx +15 -19
  6. package/components/AddProductsToCart/AddProductsToCartQuantity.tsx +7 -5
  7. package/components/AddProductsToCart/AddProductsToCartSnackbar.tsx +2 -1
  8. package/components/AddProductsToCart/AddProductsToCartSnackbarMessage.tsx +5 -6
  9. package/components/AddProductsToCart/findAddedItems.ts +2 -2
  10. package/components/AddProductsToCart/toUserErrors.ts +2 -2
  11. package/components/AddProductsToCart/useAddProductsToCartAction.ts +4 -3
  12. package/components/AddProductsToCart/useFormAddProductsToCart.ts +3 -3
  13. package/components/JsonLdProduct/ProductPageJsonLd.tsx +1 -1
  14. package/components/JsonLdProduct/jsonLdProduct.tsx +2 -2
  15. package/components/ProductAddToCart/index.ts +0 -1
  16. package/components/ProductCustomizable/CustomizableAreaOption.tsx +5 -4
  17. package/components/ProductCustomizable/CustomizableCheckboxOption.tsx +4 -8
  18. package/components/ProductCustomizable/CustomizableDateOption.tsx +3 -3
  19. package/components/ProductCustomizable/CustomizableDropDownOption.tsx +6 -6
  20. package/components/ProductCustomizable/CustomizableFieldOption.tsx +3 -3
  21. package/components/ProductCustomizable/CustomizableMultipleOption.tsx +4 -8
  22. package/components/ProductCustomizable/CustomizableRadioOption.tsx +4 -8
  23. package/components/ProductCustomizable/ProductCustomizable.tsx +7 -6
  24. package/components/ProductFiltersPro/PriceSlider.tsx +4 -2
  25. package/components/ProductFiltersPro/ProductFilterEqualChip.tsx +1 -1
  26. package/components/ProductFiltersPro/ProductFilterEqualSection.tsx +1 -1
  27. package/components/ProductFiltersPro/ProductFilterRangeChip.tsx +1 -1
  28. package/components/ProductFiltersPro/ProductFiltersPro.tsx +10 -19
  29. package/components/ProductFiltersPro/ProductFiltersProAggregations.tsx +2 -2
  30. package/components/ProductFiltersPro/ProductFiltersProAllFiltersChip.tsx +7 -7
  31. package/components/ProductFiltersPro/ProductFiltersProAllFiltersSidebar.tsx +8 -15
  32. package/components/ProductFiltersPro/ProductFiltersProCategorySection.tsx +6 -8
  33. package/components/ProductFiltersPro/ProductFiltersProChips.tsx +4 -2
  34. package/components/ProductFiltersPro/ProductFiltersProClearAll.tsx +2 -2
  35. package/components/ProductFiltersPro/ProductFiltersProLayoutSidebar.tsx +8 -2
  36. package/components/ProductFiltersPro/ProductFiltersProLimitChip.tsx +4 -2
  37. package/components/ProductFiltersPro/ProductFiltersProLimitSection.tsx +3 -2
  38. package/components/ProductFiltersPro/ProductFiltersProNoResults.tsx +5 -4
  39. package/components/ProductFiltersPro/ProductFiltersProSortChip.tsx +4 -2
  40. package/components/ProductFiltersPro/ProductFiltersProSortDirectionArrow.tsx +5 -3
  41. package/components/ProductFiltersPro/ProductFiltersProSortSection.tsx +3 -2
  42. package/components/ProductFiltersPro/activeAggregations.ts +2 -2
  43. package/components/ProductFiltersPro/applyAggregationCount.ts +2 -2
  44. package/components/ProductFiltersPro/useProductFiltersProClearAllAction.ts +1 -1
  45. package/components/ProductFiltersPro/useProductFiltersProSort.tsx +3 -3
  46. package/components/ProductList/ProductList.graphql +4 -3
  47. package/components/ProductListCount/ProductListCount.tsx +3 -2
  48. package/components/ProductListFilters/FilterCheckboxType.tsx +5 -4
  49. package/components/ProductListFilters/FilterEqualType.tsx +7 -7
  50. package/components/ProductListFilters/FilterRangeType.tsx +4 -3
  51. package/components/ProductListFilters/ProductFilters.graphql +2 -2
  52. package/components/ProductListFilters/ProductListFilters.tsx +3 -3
  53. package/components/ProductListFiltersContainer/ProductListFiltersContainer.tsx +5 -4
  54. package/components/ProductListItem/ProductDiscountLabel.tsx +4 -3
  55. package/components/ProductListItem/ProductListItem.tsx +58 -31
  56. package/components/ProductListItem/ProductListItemImage.tsx +9 -7
  57. package/components/ProductListItem/ProductListItemImageContainer.tsx +9 -8
  58. package/components/ProductListItem/ProductListItemLinkOrDiv.tsx +13 -8
  59. package/components/ProductListItem/ProductListItemTitleAndPrice.tsx +4 -3
  60. package/components/ProductListItems/ProductListItemsBase.tsx +24 -18
  61. package/components/ProductListItems/ProductListParamsProvider.tsx +2 -2
  62. package/components/ProductListItems/filterTypes.tsx +4 -4
  63. package/components/ProductListItems/filteredProductList.tsx +2 -2
  64. package/components/ProductListItems/getFilterTypes.ts +2 -1
  65. package/components/ProductListItems/productListApplyCategoryDefaults.ts +5 -4
  66. package/components/ProductListItems/renderer.tsx +3 -2
  67. package/components/ProductListLink/ProductListLink.tsx +5 -3
  68. package/components/ProductListPagination/ProductListPagination.tsx +6 -5
  69. package/components/ProductListPrice/ProductListPrice.tsx +12 -7
  70. package/components/ProductListSort/ProductListSort.tsx +8 -6
  71. package/components/ProductListSuggestions/ProductListSearchSuggestion.graphql +3 -0
  72. package/components/ProductListSuggestions/ProductListSuggestions.graphql +1 -1
  73. package/components/ProductListSuggestions/ProductListSuggestions.tsx +2 -2
  74. package/components/ProductPage/ProductPageAddToCartRow.tsx +4 -3
  75. package/components/ProductPageBreadcrumb/ProductPageBreadcrumb.tsx +6 -4
  76. package/components/ProductPageBreadcrumb/ProductPageBreadcrumbs.tsx +3 -3
  77. package/components/ProductPageCategory/productPageCategory.ts +1 -1
  78. package/components/ProductPageDescription/ProductPageDescription.tsx +7 -6
  79. package/components/ProductPageGallery/ProductPageGallery.tsx +3 -7
  80. package/components/ProductPageMeta/ProductPageMeta.tsx +2 -2
  81. package/components/ProductPageName/ProductPageName.tsx +2 -2
  82. package/components/ProductPagePrice/ProductPagePrice.tsx +10 -11
  83. package/components/ProductPagePrice/ProductPagePriceTiers.tsx +5 -5
  84. package/components/ProductPagePrice/getProductTierPrice.ts +2 -2
  85. package/components/ProductPagePrice/useCustomizableOptionPrice.ts +7 -6
  86. package/components/ProductScroller/ProductScroller.tsx +11 -16
  87. package/components/ProductShortDescription/ProductShortDescription.tsx +3 -2
  88. package/components/ProductSidebarDelivery/ProductSidebarDelivery.tsx +4 -4
  89. package/components/ProductSpecs/ProductSpecs.tsx +5 -4
  90. package/components/ProductSpecs/ProductSpecsAggregations.tsx +2 -2
  91. package/components/ProductSpecs/ProductSpecsCustomAttributes.tsx +3 -3
  92. package/components/ProductStaticPaths/getProductStaticPaths.ts +4 -3
  93. package/components/ProductStaticPaths/getSitemapPaths.ts +3 -2
  94. package/components/ProductWeight/ProductWeight.tsx +5 -7
  95. package/components/index.ts +5 -0
  96. package/context/productListParamsContext.ts +1 -1
  97. package/hooks/useProductLink.ts +6 -2
  98. package/hooks/useProductList.ts +14 -17
  99. package/hooks/useProductListLink.ts +7 -5
  100. package/hooks/useProductListLinkReplace.ts +1 -1
  101. package/package.json +15 -15
  102. package/test/productURL.fixture.ts +1 -1
  103. package/tsconfig.json +1 -1
  104. package/components/ProductAddToCart/ProductAddToCart.tsx +0 -139
  105. package/components/ProductPageGallery/ProductImage.tsx +0 -10
  106. package/components/ProductPageGallery/ProductVideo.tsx +0 -10
@@ -1,139 +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 { Money, MoneyProps } from '@graphcommerce/magento-store'
5
- import {
6
- Button,
7
- MessageSnackbar,
8
- iconChevronRight,
9
- IconSvg,
10
- extendableComponent,
11
- } from '@graphcommerce/next-ui'
12
- import { Trans } from '@lingui/macro'
13
- import { Divider, Typography, ButtonProps, Box, Alert } from '@mui/material'
14
- import React from 'react'
15
- import { ProductAddToCartDocument, ProductAddToCartMutationVariables } from './ProductAddToCart.gql'
16
-
17
- const { classes, selectors } = extendableComponent('ProductAddToCart', [
18
- 'root',
19
- 'button',
20
- 'price',
21
- 'divider',
22
- 'buttonWrapper',
23
- ] as const)
24
-
25
- export type AddToCartProps = React.ComponentProps<typeof ProductAddToCart>
26
-
27
- /** @deprecated Please us AddProductsToCartForm and it's components */
28
- export function ProductAddToCart(
29
- props: Pick<ProductInterface, 'name'> & {
30
- variables: Omit<ProductAddToCartMutationVariables, 'cartId'>
31
- name: string
32
- price: MoneyProps
33
- additionalButtons?: React.ReactNode
34
- children?: React.ReactNode
35
- } & Omit<ButtonProps, 'type' | 'name'>,
36
- ) {
37
- const { name, children, variables, price, sx, additionalButtons, ...buttonProps } = props
38
-
39
- const form = useFormGqlMutationCart(ProductAddToCartDocument, {
40
- defaultValues: { ...variables },
41
- })
42
-
43
- const { handleSubmit, formState, error, control, required, data } = form
44
- const submitHandler = handleSubmit(() => {})
45
-
46
- return (
47
- <Box component='form' onSubmit={submitHandler} noValidate className={classes.root} sx={sx}>
48
- <Divider className={classes.divider} sx={(theme) => ({ margin: `${theme.spacings.xs} 0` })} />
49
-
50
- <Typography
51
- variant='h4'
52
- className={classes.price}
53
- sx={(theme) => ({
54
- fontWeight: theme.typography.fontWeightBold,
55
- margin: `${theme.spacings.sm} 0`,
56
- })}
57
- >
58
- <Money {...price} />
59
- </Typography>
60
-
61
- <NumberFieldElement
62
- variant='outlined'
63
- error={formState.isSubmitted && !!formState.errors.quantity}
64
- required={required.quantity}
65
- inputProps={{ min: 1 }}
66
- name='quantity'
67
- rules={{ required: required.quantity }}
68
- helperText={formState.isSubmitted && formState.errors.quantity?.message}
69
- disabled={formState.isSubmitting}
70
- size='small'
71
- control={control}
72
- />
73
- {children}
74
- <Box
75
- sx={(theme) => ({
76
- display: 'flex',
77
- alignItems: 'center',
78
- columnGap: theme.spacings.xs,
79
- })}
80
- className={classes.buttonWrapper}
81
- >
82
- <Button
83
- type='submit'
84
- className={classes.button}
85
- loading={formState.isSubmitting}
86
- color='primary'
87
- variant='pill'
88
- size='large'
89
- sx={(theme) => ({
90
- marginTop: theme.spacings.sm,
91
- marginBottom: theme.spacings.sm,
92
- width: '100%',
93
- })}
94
- {...buttonProps}
95
- >
96
- <Trans>Add to Cart</Trans>
97
- </Button>
98
- {additionalButtons}
99
- </Box>
100
-
101
- <ApolloCartErrorAlert error={error} />
102
-
103
- {data?.addProductsToCart?.user_errors.map((e) => (
104
- <Box key={e?.code}>
105
- <Alert severity='error'>{e?.message}</Alert>
106
- </Box>
107
- ))}
108
-
109
- <MessageSnackbar
110
- open={
111
- !formState.isSubmitting &&
112
- formState.isSubmitSuccessful &&
113
- !error?.message &&
114
- !data?.addProductsToCart?.user_errors?.length
115
- }
116
- variant='pill'
117
- severity='success'
118
- autoHide
119
- action={
120
- <Button
121
- href='/cart'
122
- id='view-shopping-cart-button'
123
- size='medium'
124
- variant='pill'
125
- color='secondary'
126
- endIcon={<IconSvg src={iconChevronRight} />}
127
- >
128
- <Trans>View shopping cart</Trans>
129
- </Button>
130
- }
131
- >
132
- <Trans>
133
- <strong>{name}</strong> has been added to your shopping cart!
134
- </Trans>
135
- </MessageSnackbar>
136
- </Box>
137
- )
138
- }
139
- ProductAddToCart.selectors = selectors
@@ -1,10 +0,0 @@
1
- import { Image } from '@graphcommerce/image'
2
- import { 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 { 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
- }