@graphcommerce/magento-product 8.1.0-canary.3 → 8.1.0-canary.5

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 (34) hide show
  1. package/CHANGELOG.md +95 -2
  2. package/components/AddProductsToCart/AddProductsToCartSnackbar.tsx +13 -14
  3. package/components/AddProductsToCart/findAddedItems.ts +81 -0
  4. package/components/AddProductsToCart/index.ts +3 -0
  5. package/components/AddProductsToCart/useAddProductsToCartAction.ts +4 -2
  6. package/components/JsonLdProduct/JsonLdProductOffer.graphql +2 -3
  7. package/components/JsonLdProduct/ProductPageJsonLd.tsx +9 -4
  8. package/components/JsonLdProduct/index.ts +1 -0
  9. package/components/ProductAddToCart/ProductAddToCart.tsx +6 -4
  10. package/components/ProductCustomizable/CustomizableAreaOption.tsx +41 -7
  11. package/components/ProductCustomizable/CustomizableDateOption.tsx +60 -7
  12. package/components/ProductCustomizable/CustomizableDropDownOption.tsx +63 -15
  13. package/components/ProductCustomizable/CustomizableFieldOption.tsx +40 -4
  14. package/components/ProductFiltersPro/ProductFiltersPro.tsx +25 -10
  15. package/components/ProductFiltersPro/ProductFiltersProAllFiltersChip.tsx +6 -2
  16. package/components/ProductFiltersPro/ProductFiltersProAllFiltersSidebar.tsx +6 -2
  17. package/components/ProductFiltersPro/ProductFiltersProSortChip.tsx +9 -28
  18. package/components/ProductFiltersPro/ProductFiltersProSortDirectionArrow.tsx +17 -0
  19. package/components/ProductFiltersPro/ProductFiltersProSortSection.tsx +7 -32
  20. package/components/ProductFiltersPro/useProductFiltersProSort.tsx +74 -0
  21. package/components/ProductListItems/CategoryDefault.graphql +5 -0
  22. package/components/ProductListItems/ProductListItemsBase.tsx +1 -1
  23. package/components/ProductListItems/filterTypes.tsx +1 -1
  24. package/components/ProductListItems/filteredProductList.tsx +1 -1
  25. package/components/ProductListItems/productListApplyCategoryDefaults.ts +28 -0
  26. package/components/ProductPageBreadcrumb/ProductPageBreadcrumb.tsx +5 -3
  27. package/components/ProductPagePrice/ProductPagePrice.graphql +3 -0
  28. package/components/ProductPagePrice/ProductPagePrice.tsx +11 -4
  29. package/components/ProductPagePrice/useCustomizableOptionPrice.ts +127 -0
  30. package/components/index.ts +2 -0
  31. package/hooks/useProductListLink.ts +10 -5
  32. package/hooks/useProductListLinkReplace.ts +3 -0
  33. package/package.json +13 -13
  34. package/tsconfig.json +1 -1
@@ -13,6 +13,8 @@ export * from './ProductListItems/filterTypes'
13
13
  export * from './ProductListItems/getFilterTypes'
14
14
  export * from './ProductListItems/ProductListItems.gql'
15
15
  export * from './ProductListItems/ProductListItemsBase'
16
+ export * from './ProductListItems/productListApplyCategoryDefaults'
17
+ export * from './ProductListItems/CategoryDefault.gql'
16
18
  export * from './ProductListItems/ProductListParamsProvider'
17
19
  export * from './ProductListItems/renderer'
18
20
  export * from './ProductListLink/ProductListLink'
@@ -2,11 +2,13 @@ import {
2
2
  isFilterTypeEqual,
3
3
  isFilterTypeMatch,
4
4
  isFilterTypeRange,
5
+ ProductFilterParams,
5
6
  ProductListParams,
7
+ toFilterParams,
6
8
  } from '../components/ProductListItems/filterTypes'
7
9
 
8
- export function productListLink(props: ProductListParams): string {
9
- const { url, sort, currentPage, pageSize, filters: incoming } = props
10
+ export function productListLinkFromFilter(props: ProductFilterParams): string {
11
+ const { url, sort, dir, currentPage, pageSize, filters: incoming } = props
10
12
  const isSearch = url.startsWith('search')
11
13
  const filters = isSearch ? incoming : { ...incoming, category_uid: undefined }
12
14
  const uid = incoming?.category_uid?.eq || incoming?.category_uid?.in?.[0]
@@ -19,9 +21,8 @@ export function productListLink(props: ProductListParams): string {
19
21
 
20
22
  // todo(paales): How should the URL look like with multiple sorts?
21
23
  // Something like: /sort/position,price/dir/asc,asc
22
- const [sortBy] = Object.keys(sort)
23
- if (sort && sortBy) query += `/sort/${sortBy}`
24
- if (sort && sortBy && sort[sortBy] && sort[sortBy] === 'DESC') query += `/dir/desc`
24
+ if (sort) query += `/sort/${sort}`
25
+ if (dir) query += `/dir/desc`
25
26
  if (pageSize) query += `/page-size/${pageSize}`
26
27
 
27
28
  // Apply filters
@@ -42,6 +43,10 @@ export function productListLink(props: ProductListParams): string {
42
43
  return query ? `/${url}${paginateSort}/q${query}` : `/${url}${paginateSort}`
43
44
  }
44
45
 
46
+ export function productListLink(props: ProductListParams): string {
47
+ return productListLinkFromFilter(toFilterParams(props))
48
+ }
49
+
45
50
  export function useProductListLink(props: ProductListParams): string {
46
51
  return productListLink({ ...props, url: `${props.url}` })
47
52
  }
@@ -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.1.0-canary.3",
5
+ "version": "8.1.0-canary.5",
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.1.0-canary.3",
22
- "@graphcommerce/eslint-config-pwa": "^8.1.0-canary.3",
23
- "@graphcommerce/framer-next-pages": "^8.1.0-canary.3",
24
- "@graphcommerce/framer-scroller": "^8.1.0-canary.3",
25
- "@graphcommerce/graphql": "^8.1.0-canary.3",
26
- "@graphcommerce/graphql-mesh": "^8.1.0-canary.3",
27
- "@graphcommerce/image": "^8.1.0-canary.3",
28
- "@graphcommerce/magento-cart": "^8.1.0-canary.3",
29
- "@graphcommerce/magento-store": "^8.1.0-canary.3",
30
- "@graphcommerce/next-ui": "^8.1.0-canary.3",
31
- "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.3",
32
- "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.3",
21
+ "@graphcommerce/ecommerce-ui": "^8.1.0-canary.5",
22
+ "@graphcommerce/eslint-config-pwa": "^8.1.0-canary.5",
23
+ "@graphcommerce/framer-next-pages": "^8.1.0-canary.5",
24
+ "@graphcommerce/framer-scroller": "^8.1.0-canary.5",
25
+ "@graphcommerce/graphql": "^8.1.0-canary.5",
26
+ "@graphcommerce/graphql-mesh": "^8.1.0-canary.5",
27
+ "@graphcommerce/image": "^8.1.0-canary.5",
28
+ "@graphcommerce/magento-cart": "^8.1.0-canary.5",
29
+ "@graphcommerce/magento-store": "^8.1.0-canary.5",
30
+ "@graphcommerce/next-ui": "^8.1.0-canary.5",
31
+ "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.5",
32
+ "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.5",
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
  }