@magento/peregrine 11.0.0-beta.1 → 12.0.0-alpha.3

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 (133) hide show
  1. package/lib/Apollo/magentoGqlCacheLink.js +59 -0
  2. package/lib/List/item.js +12 -9
  3. package/lib/List/list.js +10 -7
  4. package/lib/Price/price.js +0 -1
  5. package/lib/context/cart.js +9 -10
  6. package/lib/hooks/hook-wrappers/useInformedFieldStateWrapper.js +27 -0
  7. package/lib/hooks/useDelayedTransition.js +127 -0
  8. package/lib/hooks/useDetectScrollWidth.js +77 -0
  9. package/lib/hooks/useInternalLink.js +21 -0
  10. package/lib/hooks/useIntersectionObserver.js +7 -0
  11. package/lib/hooks/useIsInViewport.js +44 -0
  12. package/lib/store/actions/app/actions.js +2 -1
  13. package/lib/store/reducers/app.js +8 -1
  14. package/lib/talons/AccountInformationPage/useAccountInformationPage.js +0 -1
  15. package/lib/talons/Adapter/useAdapter.js +23 -3
  16. package/lib/talons/AddressBookPage/useAddressBookPage.js +0 -10
  17. package/lib/talons/Breadcrumbs/breadcrumbs.gql.js +11 -2
  18. package/lib/talons/Breadcrumbs/useBreadcrumbs.js +19 -5
  19. package/lib/talons/CartPage/GiftCards/giftCardFragments.gql.ee.js +14 -0
  20. package/lib/talons/CartPage/GiftCards/giftCardFragments.gql.js +8 -0
  21. package/lib/talons/CartPage/GiftCards/giftCardQueries.gql.ee.js +73 -0
  22. package/lib/talons/CartPage/GiftCards/useGiftCards.js +25 -16
  23. package/lib/talons/CartPage/PriceAdjustments/CouponCode/couponCode.gql.js +56 -0
  24. package/lib/talons/CartPage/PriceAdjustments/CouponCode/couponCodeFragments.gql.js +10 -0
  25. package/lib/talons/CartPage/PriceAdjustments/{useCouponCode.js → CouponCode/useCouponCode.js} +10 -6
  26. package/lib/talons/CartPage/{GiftOptions → PriceAdjustments/GiftOptions}/client-schema.graphql +0 -0
  27. package/lib/talons/CartPage/PriceAdjustments/GiftOptions/giftOptions.gql.js +21 -0
  28. package/lib/talons/CartPage/{GiftOptions → PriceAdjustments/GiftOptions}/useGiftOptions.js +5 -3
  29. package/lib/talons/CartPage/PriceAdjustments/ShippingMethods/shippingMethods.gql.js +43 -0
  30. package/lib/talons/CartPage/PriceAdjustments/ShippingMethods/shippingMethodsFragments.gql.js +60 -0
  31. package/lib/talons/CartPage/PriceAdjustments/ShippingMethods/useShippingForm.js +8 -9
  32. package/lib/talons/CartPage/PriceAdjustments/ShippingMethods/useShippingMethods.js +7 -5
  33. package/lib/talons/CartPage/PriceAdjustments/ShippingMethods/useShippingRadios.js +1 -1
  34. package/lib/talons/CartPage/PriceSummary/priceSummary.gql.js +16 -0
  35. package/lib/talons/CartPage/PriceSummary/usePriceSummary.js +6 -5
  36. package/lib/talons/CartPage/ProductListing/EditModal/productForm.gql.js +78 -0
  37. package/lib/talons/CartPage/ProductListing/EditModal/productFormFragment.gql.js +47 -0
  38. package/lib/talons/CartPage/ProductListing/EditModal/useProductForm.js +18 -8
  39. package/lib/talons/CartPage/ProductListing/product.gql.js +4 -3
  40. package/lib/talons/CartPage/ProductListing/productListing.gql.ce.js +13 -1
  41. package/lib/talons/CartPage/ProductListing/productListing.gql.ee.js +13 -1
  42. package/lib/talons/CartPage/ProductListing/productListingFragments.gql.js +52 -0
  43. package/lib/talons/CartPage/ProductListing/useProduct.js +22 -18
  44. package/lib/talons/CartPage/ProductListing/useProductListing.js +8 -13
  45. package/lib/talons/CartPage/ProductListing/useQuantity.js +2 -1
  46. package/lib/talons/CartPage/cartPage.gql.js +16 -0
  47. package/lib/talons/CartPage/cartPageFragments.gql.js +21 -0
  48. package/lib/talons/CartPage/useCartPage.js +7 -6
  49. package/lib/talons/CategoryList/categoryList.gql.js +11 -2
  50. package/lib/talons/CategoryList/useCategoryList.js +8 -1
  51. package/lib/talons/CategoryList/useCategoryTile.js +10 -4
  52. package/lib/talons/CategoryTree/categoryTree.gql.js +11 -2
  53. package/lib/talons/CategoryTree/useCategoryTree.js +12 -3
  54. package/lib/talons/CheckoutPage/AddressBook/addressBook.gql.js +34 -0
  55. package/lib/talons/CheckoutPage/AddressBook/addressBookFragments.gql.js +31 -0
  56. package/lib/talons/CheckoutPage/AddressBook/useAddressBook.js +16 -8
  57. package/lib/talons/CheckoutPage/PaymentInformation/braintreeSummary.gql.js +1 -1
  58. package/lib/talons/CheckoutPage/PaymentInformation/editModal.gql.js +16 -0
  59. package/lib/talons/CheckoutPage/PaymentInformation/paymentInformation.gql.js +4 -8
  60. package/lib/talons/CheckoutPage/PaymentInformation/paymentMethods.gql.js +17 -0
  61. package/lib/talons/CheckoutPage/PaymentInformation/useBraintreeSummary.js +1 -1
  62. package/lib/talons/CheckoutPage/PaymentInformation/useEditModal.js +6 -5
  63. package/lib/talons/CheckoutPage/PaymentInformation/usePaymentInformation.js +22 -16
  64. package/lib/talons/CheckoutPage/PaymentInformation/usePaymentMethods.js +6 -3
  65. package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/customerForm.gql.js +55 -0
  66. package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js +44 -0
  67. package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/useCustomerForm.js +11 -14
  68. package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/useGuestForm.js +6 -7
  69. package/lib/talons/CheckoutPage/ShippingInformation/shippingInformation.gql.js +54 -0
  70. package/lib/talons/CheckoutPage/ShippingInformation/shippingInformationFragments.gql.js +25 -0
  71. package/lib/talons/CheckoutPage/ShippingInformation/useShippingInformation.js +11 -6
  72. package/lib/talons/CheckoutPage/ShippingMethod/shippingMethod.gql.js +64 -0
  73. package/lib/talons/CheckoutPage/ShippingMethod/shippingMethodFragments.gql.js +64 -0
  74. package/lib/talons/CheckoutPage/{useShippingMethod.js → ShippingMethod/useShippingMethod.js} +11 -8
  75. package/lib/talons/Cms/cmsPage.gql.js +2 -2
  76. package/lib/talons/Cms/useCmsPage.js +2 -2
  77. package/lib/talons/CommunicationsPage/useCommunicationsPage.js +1 -2
  78. package/lib/talons/CreateAccount/createAccount.gql.js +3 -0
  79. package/lib/talons/CreateAccount/useCreateAccount.js +2 -4
  80. package/lib/talons/CreateAccountPage/useCreateAccountPage.js +38 -9
  81. package/lib/talons/FilterModal/useFilterList.js +17 -3
  82. package/lib/talons/FilterModal/useFilterModal.js +4 -5
  83. package/lib/talons/FilterSidebar/useFilterSidebar.js +4 -5
  84. package/lib/talons/ForgotPasswordPage/useForgotPasswordPage.js +46 -0
  85. package/lib/talons/FormError/useFormError.js +10 -3
  86. package/lib/talons/Gallery/__fixtures__/apolloMocks.js +8 -6
  87. package/lib/talons/Gallery/addToCart.gql.js +17 -0
  88. package/lib/talons/Gallery/gallery.gql.ce.js +4 -3
  89. package/lib/talons/Gallery/gallery.gql.ee.js +4 -3
  90. package/lib/talons/Gallery/useAddToCartButton.js +81 -0
  91. package/lib/talons/Gallery/useGallery.js +4 -7
  92. package/lib/talons/Gallery/useGalleryItem.js +7 -1
  93. package/lib/talons/Header/useCartTrigger.js +14 -7
  94. package/lib/talons/Link/useLink.js +68 -0
  95. package/lib/talons/MagentoRoute/magentoRoute.gql.js +12 -3
  96. package/lib/talons/MagentoRoute/useMagentoRoute.js +115 -30
  97. package/lib/talons/MegaMenu/megaMenu.gql.js +10 -4
  98. package/lib/talons/MegaMenu/useMegaMenu.js +61 -11
  99. package/lib/talons/MegaMenu/useMegaMenuItem.js +61 -0
  100. package/lib/talons/MegaMenu/useSubMenu.js +20 -0
  101. package/lib/talons/MiniCart/ProductList/productListFragments.gql.js +0 -1
  102. package/lib/talons/MiniCart/miniCart.gql.js +4 -3
  103. package/lib/talons/MiniCart/useMiniCart.js +15 -12
  104. package/lib/talons/Navigation/useNavigation.js +6 -1
  105. package/lib/talons/OrderHistoryPage/orderRow.gql.js +0 -1
  106. package/lib/talons/OrderHistoryPage/useOrderHistoryPage.js +2 -14
  107. package/lib/talons/PageLoadingIndicator/usePageLoadingIndicator.js +52 -0
  108. package/lib/talons/Postcode/usePostcode.js +2 -1
  109. package/lib/talons/ProductFullDetail/useProductFullDetail.js +30 -5
  110. package/lib/talons/Region/useRegion.js +12 -10
  111. package/lib/talons/RootComponents/Category/categoryFragments.gql.js +5 -4
  112. package/lib/talons/RootComponents/Product/productDetailFragment.gql.js +7 -0
  113. package/lib/talons/SavedPaymentsPage/useSavedPaymentsPage.js +1 -11
  114. package/lib/talons/SearchBar/useAutocomplete.js +1 -1
  115. package/lib/talons/SearchBar/useSearchField.js +2 -1
  116. package/lib/talons/SearchBar/useSuggestedCategory.js +4 -6
  117. package/lib/talons/SearchPage/searchPage.gql.js +10 -9
  118. package/lib/talons/SignIn/signIn.gql.js +3 -0
  119. package/lib/talons/SignInPage/useSignInPage.js +63 -0
  120. package/lib/talons/Wishlist/AddToListButton/helpers/useSingleWishlist.js +2 -2
  121. package/lib/talons/Wishlist/AddToListButton/useAddToListButton.ee.js +2 -1
  122. package/lib/talons/WishlistPage/useActionMenu.js +39 -5
  123. package/lib/talons/WishlistPage/useWishlist.js +4 -4
  124. package/lib/talons/WishlistPage/useWishlistPage.js +3 -11
  125. package/lib/talons/WishlistPage/wishlist.gql.js +1 -1
  126. package/lib/talons/WishlistPage/wishlistConfig.gql.ce.js +14 -0
  127. package/lib/talons/WishlistPage/wishlistConfig.gql.ee.js +15 -0
  128. package/lib/targets/peregrine-declare.js +0 -4
  129. package/lib/util/deriveErrorMessage.js +12 -6
  130. package/lib/util/images.js +3 -2
  131. package/lib/util/isSupportedProductType.js +5 -0
  132. package/lib/util/magentoRouteData.js +9 -0
  133. package/package.json +8 -8
@@ -18,8 +18,8 @@ export const useWishlist = (props = {}) => {
18
18
  const [isOpen, setIsOpen] = useState(!isCollapsed);
19
19
  const [isFetchingMore, setIsFetchingMore] = useState(false);
20
20
 
21
- const [fetchWhislistItems, queryResult] = useLazyQuery(
22
- operations.getCustomerWhislistItems,
21
+ const [fetchWishlistItems, queryResult] = useLazyQuery(
22
+ operations.getCustomerWishlistItems,
23
23
  {
24
24
  fetchPolicy: 'cache-and-network',
25
25
  nextFetchPolicy: 'cache-first',
@@ -52,9 +52,9 @@ export const useWishlist = (props = {}) => {
52
52
  useEffect(() => {
53
53
  setPage(1);
54
54
  if (itemsCount >= 1 && isOpen === true && !data) {
55
- fetchWhislistItems();
55
+ fetchWishlistItems();
56
56
  }
57
- }, [itemsCount, isOpen, fetchWhislistItems, data]);
57
+ }, [itemsCount, isOpen, fetchWishlistItems, data]);
58
58
 
59
59
  const items =
60
60
  data && data.customer.wishlist_v2.items_v2.items
@@ -1,9 +1,8 @@
1
- import { useEffect, useMemo } from 'react';
2
- import { useHistory } from 'react-router-dom';
1
+ import { useMemo } from 'react';
3
2
  import { useQuery } from '@apollo/client';
4
3
 
5
- import { useUserContext } from '../../context/user';
6
- import mergeOperations from '../../util/shallowMerge';
4
+ import { useUserContext } from '@magento/peregrine/lib/context/user';
5
+ import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
7
6
 
8
7
  import defaultOperations from './wishlistPage.gql';
9
8
 
@@ -16,7 +15,6 @@ export const useWishlistPage = (props = {}) => {
16
15
  const operations = mergeOperations(defaultOperations, props.operations);
17
16
  const { getCustomerWishlistQuery } = operations;
18
17
 
19
- const history = useHistory();
20
18
  const [{ isSignedIn }] = useUserContext();
21
19
 
22
20
  const { data, error, loading } = useQuery(getCustomerWishlistQuery, {
@@ -33,12 +31,6 @@ export const useWishlistPage = (props = {}) => {
33
31
  return new Map([['getCustomerWishlistQuery', error]]);
34
32
  }, [error]);
35
33
 
36
- useEffect(() => {
37
- if (!isSignedIn) {
38
- history.push('/');
39
- }
40
- }, [history, isSignedIn]);
41
-
42
34
  return {
43
35
  errors,
44
36
  loading,
@@ -54,6 +54,6 @@ export const UPDATE_WISHLIST = gql`
54
54
 
55
55
  export default {
56
56
  getCustomerWishlistQuery: GET_CUSTOMER_WISHLIST,
57
- getCustomerWhislistItems: GET_CUSTOMER_WISHLIST_ITEMS,
57
+ getCustomerWishlistItems: GET_CUSTOMER_WISHLIST_ITEMS,
58
58
  updateWishlistMutation: UPDATE_WISHLIST
59
59
  };
@@ -0,0 +1,14 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ export const GET_WISHLIST_CONFIG = gql`
4
+ query GetWishlistConfigForWishlistPageCE {
5
+ storeConfig {
6
+ id
7
+ magento_wishlist_general_is_enabled
8
+ }
9
+ }
10
+ `;
11
+
12
+ export default {
13
+ getWishlistConfigQuery: GET_WISHLIST_CONFIG
14
+ };
@@ -0,0 +1,15 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ export const GET_WISHLIST_CONFIG = gql`
4
+ query GetWishlistConfigForWishlistPageEE {
5
+ storeConfig {
6
+ id
7
+ magento_wishlist_general_is_enabled
8
+ enable_multiple_wishlists
9
+ }
10
+ }
11
+ `;
12
+
13
+ export default {
14
+ getWishlistConfigQuery: GET_WISHLIST_CONFIG
15
+ };
@@ -20,8 +20,6 @@ module.exports = targets => {
20
20
  *
21
21
  * @member {tapable.AsyncSeriesHook}
22
22
  *
23
- * @see [list of wrappable hooks][]
24
- *
25
23
  * @see [Intercept function signature]{@link hookInterceptFunction}
26
24
  *
27
25
  * @example <caption>Access the tapable object</caption>
@@ -49,8 +47,6 @@ module.exports = targets => {
49
47
  *
50
48
  * @member {tapable.AsyncSeriesHook}
51
49
  *
52
- * @see [list of wrappable talons][]
53
- *
54
50
  * @see [Intercept function signature]{@link hookInterceptFunction}
55
51
  *
56
52
  * @example <caption>Access the tapable object</caption>
@@ -4,22 +4,28 @@
4
4
  * @param {Error} error the error to map
5
5
  * @return {String} error message
6
6
  */
7
- const toString = error => {
7
+
8
+ const toString = (error, defaultErrorMessage) => {
8
9
  const { graphQLErrors, message } = error;
9
10
 
10
- return graphQLErrors && graphQLErrors.length
11
- ? graphQLErrors.map(({ message }) => message).join(', ')
12
- : message;
11
+ if (graphQLErrors && graphQLErrors.length) {
12
+ if (defaultErrorMessage) {
13
+ return defaultErrorMessage;
14
+ }
15
+ return graphQLErrors.map(({ message }) => message).join(', ');
16
+ }
17
+
18
+ return message;
13
19
  };
14
20
 
15
21
  /**
16
22
  * A function to derive an error string from an array of errors.
17
23
  */
18
- export const deriveErrorMessage = errors => {
24
+ export const deriveErrorMessage = (errors, defaultErrorMessage = '') => {
19
25
  const errorCollection = [];
20
26
  for (const error of errors) {
21
27
  if (error) {
22
- errorCollection.push(toString(error));
28
+ errorCollection.push(toString(error, defaultErrorMessage));
23
29
  }
24
30
  }
25
31
 
@@ -1,3 +1,4 @@
1
- // 4x5 transparent png
1
+ // 4x5 transparent svg
2
+ // svg source = <svg xmlns='http://www.w3.org/2000/svg' width='4' height='5'><rect width='4' height='5' style='fill: none' /></svg>
2
3
  export const transparentPlaceholder =
3
- 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAFCAQAAADIpIVQAAAADklEQVR42mNkgAJGIhgAALQABsHyMOcAAAAASUVORK5CYII=';
4
+ 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSc0JyBoZWlnaHQ9JzUnPjxyZWN0IHdpZHRoPSc0JyBoZWlnaHQ9JzUnIHN0eWxlPSdmaWxsOiBub25lJyAvPjwvc3ZnPg==';
@@ -0,0 +1,5 @@
1
+ const SUPPORTED_PRODUCT_TYPES = ['SimpleProduct', 'ConfigurableProduct'];
2
+
3
+ export const isSupportedProductType = productType => {
4
+ return SUPPORTED_PRODUCT_TYPES.includes(productType);
5
+ };
@@ -0,0 +1,9 @@
1
+ export const getComponentData = routeData => {
2
+ const excludedKeys = ['redirect_code', 'relative_url'];
3
+
4
+ return Object.fromEntries(
5
+ Object.entries(routeData).filter(([key]) => {
6
+ return !excludedKeys.includes(key);
7
+ })
8
+ );
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magento/peregrine",
3
- "version": "11.0.0-beta.1",
3
+ "version": "12.0.0-alpha.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -27,9 +27,9 @@
27
27
  "intl-locales-supported": "~1.8.12",
28
28
  "react": "~17.0.1",
29
29
  "react-dom": "~17.0.1",
30
- "react-intl": "~5.7.0",
31
- "react-redux": "~7.1.1",
32
- "react-router-dom": "~5.1.0",
30
+ "react-intl": "~5.20.0",
31
+ "react-redux": "~7.2.2",
32
+ "react-router-dom": "~5.2.0",
33
33
  "react-test-renderer": "~17.0.1",
34
34
  "redux": "~4.0.4",
35
35
  "redux-actions": "~2.6.5",
@@ -38,12 +38,12 @@
38
38
  "peerDependencies": {
39
39
  "@apollo/client": "~3.1.2",
40
40
  "@babel/runtime": "~7.4.2",
41
- "informed": "~3.27.0",
41
+ "informed": "~3.29.0",
42
42
  "react": "~17.0.1",
43
43
  "react-dom": "~17.0.1",
44
- "react-intl": "~5.7.0",
45
- "react-redux": "~7.1.1",
46
- "react-router-dom": "~5.1.0",
44
+ "react-intl": "~5.20.0",
45
+ "react-redux": "~7.2.2",
46
+ "react-router-dom": "~5.2.0",
47
47
  "redux": "~4.0.4",
48
48
  "redux-actions": "~2.6.5"
49
49
  },