@graphcommerce/magento-compare 6.2.0-canary.9

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 (47) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/Config.graphqls +17 -0
  3. package/components/CompareFab.tsx +100 -0
  4. package/components/CompareListAttributes.tsx +45 -0
  5. package/components/CompareListForm.tsx +83 -0
  6. package/components/CompareListIntroText.tsx +21 -0
  7. package/components/CompareListItems.tsx +28 -0
  8. package/components/CompareListRow.tsx +62 -0
  9. package/components/CompareListRowMoreInformation.tsx +58 -0
  10. package/components/CompareListSelect.tsx +77 -0
  11. package/components/CompareMessageSnackbar.tsx +59 -0
  12. package/components/CompareProductButton.tsx +59 -0
  13. package/components/CompareProductToggle.tsx +155 -0
  14. package/components/EmptyCompareList.tsx +19 -0
  15. package/components/EmptyCompareListButton.tsx +58 -0
  16. package/components/index.ts +13 -0
  17. package/graphql/AddProductsToCompareList.graphql +5 -0
  18. package/graphql/AssignCustomerToCompareList.graphql +5 -0
  19. package/graphql/ComparableItem.graphql +11 -0
  20. package/graphql/CompareList.graphql +5 -0
  21. package/graphql/CompareListFragment.graphql +12 -0
  22. package/graphql/CompareProductIdInternal.graphql +6 -0
  23. package/graphql/CompareSummary.graphql +5 -0
  24. package/graphql/CompareSummaryFragment.graphql +7 -0
  25. package/graphql/CreateCompareList.graphql +5 -0
  26. package/graphql/CurrentCompareUid.graphql +6 -0
  27. package/graphql/CurrentCompareUid.graphqls +7 -0
  28. package/graphql/CustomerCompareList.graphql +7 -0
  29. package/graphql/DeleteCompareList.graphql +5 -0
  30. package/graphql/RemoveProductsFromCompareList.graphql +5 -0
  31. package/graphql/index.ts +12 -0
  32. package/hooks/index.ts +6 -0
  33. package/hooks/useAssignCurrentCompareListUid.ts +16 -0
  34. package/hooks/useClearCurrentCompareListUid.ts +15 -0
  35. package/hooks/useCompareList.ts +10 -0
  36. package/hooks/useCompareListStyles.ts +21 -0
  37. package/hooks/useCompareListUidCreate.ts +27 -0
  38. package/hooks/useCompareSummary.ts +13 -0
  39. package/index.ts +3 -0
  40. package/next-env.d.ts +4 -0
  41. package/package.json +38 -0
  42. package/plugins/AddCompareFabNextToCart.tsx +19 -0
  43. package/plugins/AddCompareToProductPage.tsx +36 -0
  44. package/plugins/AddCompareTypePolicies.tsx +25 -0
  45. package/plugins/CompareAbleProductListItem.tsx +41 -0
  46. package/tsconfig.json +5 -0
  47. package/typePolicies.ts +12 -0
@@ -0,0 +1,41 @@
1
+ import { ProductListItemProps } from '@graphcommerce/magento-product'
2
+ import type { IfConfig, PluginProps } from '@graphcommerce/next-config'
3
+ import { Box } from '@mui/material'
4
+ import { CompareProductToggle } from '../components'
5
+
6
+ export const component = 'ProductListItem' // Component to extend, required
7
+ export const exported = '@graphcommerce/magento-product' // Location where the component is exported, required
8
+ export const ifConfig: IfConfig = 'compare'
9
+
10
+ function CompareAbleProductListItem(props: PluginProps<ProductListItemProps>) {
11
+ const { Prev, ...rest } = props
12
+ const { children, topRight } = props
13
+ if (import.meta.graphCommerce.compareVariant === 'CHECKBOX')
14
+ return (
15
+ <Prev topRight={topRight} {...rest}>
16
+ <Box sx={{ display: 'flex', justifyContent: 'flex-end' }}>
17
+ <CompareProductToggle {...rest} product={props} />
18
+ </Box>
19
+ {children}
20
+ </Prev>
21
+ )
22
+
23
+ if (
24
+ import.meta.graphCommerce.compareVariant === 'ICON' ||
25
+ !import.meta.graphCommerce.compareVariant
26
+ )
27
+ return (
28
+ <Prev
29
+ {...rest}
30
+ topRight={
31
+ <>
32
+ {topRight}
33
+ <CompareProductToggle {...rest} product={props} />
34
+ </>
35
+ }
36
+ >
37
+ {children}
38
+ </Prev>
39
+ )
40
+ }
41
+ export const Plugin = CompareAbleProductListItem
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "exclude": ["**/node_modules", "**/.*/"],
3
+ "include": ["**/*.ts", "**/*.tsx"],
4
+ "extends": "@graphcommerce/typescript-config-pwa/nextjs.json"
5
+ }
@@ -0,0 +1,12 @@
1
+ import type { StrictTypedTypePolicies } from '@graphcommerce/graphql'
2
+ import type { QuerycompareListArgs } from '@graphcommerce/graphql-mesh'
3
+
4
+ export const compareTypePolicies: StrictTypedTypePolicies = {
5
+ Query: {
6
+ fields: {
7
+ // currentCartId: (_, { toReference }) => toReference({ __typename: 'CurrentCartId' }),
8
+ compareList: (_, { args, toReference }) =>
9
+ toReference({ __typename: 'CompareList', uid: (args as QuerycompareListArgs)?.uid }),
10
+ },
11
+ },
12
+ }