@riosst100/pwa-marketplace 1.2.5 → 1.2.7

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 (129) hide show
  1. package/.github/workflows/dependabot.yml +28 -28
  2. package/package.json +18 -18
  3. package/src/Utilities/graphQL.js +76 -76
  4. package/src/componentOverrideMapping.js +17 -17
  5. package/src/components/BecomeSeller/becomeSeller.js +335 -335
  6. package/src/components/BecomeSeller/becomeSeller.module.css +46 -46
  7. package/src/components/BecomeSellerLink/becomeSellerLink.js +52 -52
  8. package/src/components/BecomeSellerLink/becomeSellerLink.module.css +12 -12
  9. package/src/components/BecomeSellerPage/becomeSellerPage.js +45 -45
  10. package/src/components/BecomeSellerPage/becomeSellerPage.module.css +21 -21
  11. package/src/components/Filter/index.js +53 -53
  12. package/src/components/Header/becomeSellerLink.js +28 -28
  13. package/src/components/Header/becomeSellerLink.module.css +12 -12
  14. package/src/components/Header/websiteSwitcher.js +109 -109
  15. package/src/components/Pagination/index.js +49 -49
  16. package/src/components/PhoneTextInput/phoneTextInput.module.css +21 -21
  17. package/src/components/ProductItem/index.js +50 -50
  18. package/src/components/Search/index.js +16 -16
  19. package/src/components/Seller/index.js +1 -1
  20. package/src/components/Seller/seller.js +249 -250
  21. package/src/components/SellerAccountPage/sellerAccountPage.js +110 -110
  22. package/src/components/SellerAccountPage/sellerAccountPage.module.css +55 -55
  23. package/src/components/SellerCountry/sellerCountry.gql.js +11 -11
  24. package/src/components/SellerInformation/index.js +1 -1
  25. package/src/components/SellerInformation/sellerInformation.js +90 -118
  26. package/src/components/SellerLocation/index.js +1 -1
  27. package/src/components/SellerLocation/sellerLocation.js +19 -23
  28. package/src/components/SellerLocation/sellerLocationItem.js +27 -25
  29. package/src/components/SellerPage/sellerPage.js +9 -9
  30. package/src/components/SellerProducts/sellerProducts.js +47 -67
  31. package/src/components/SellerReview/index.js +1 -1
  32. package/src/components/SellerReview/sellerReview.js +143 -143
  33. package/src/components/SellerReviewItem/sellerReviewItem.js +60 -60
  34. package/src/components/SellerVerification/sellerVerification.js +198 -198
  35. package/src/components/SellerVerification/sellerVerification.module.css +47 -47
  36. package/src/components/SellerVerificationPage/sellerVerificationPage.js +43 -43
  37. package/src/components/SellerVerificationPage/sellerVerificationPage.module.css +21 -21
  38. package/src/components/SortBy/index.js +24 -24
  39. package/src/components/WebsiteSwitcher/websiteSwitcher.js +109 -109
  40. package/src/components/commons/Slider/index.js +13 -13
  41. package/src/components/commons/Tabs/index.js +64 -64
  42. package/src/index.js +6 -6
  43. package/src/intercept.js +113 -113
  44. package/src/moduleOverrideWebpackPlugin.js +70 -70
  45. package/src/overwrites/peregrine/lib/store/actions/user/asyncActions.js +96 -96
  46. package/src/overwrites/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js +74 -74
  47. package/src/overwrites/peregrine/lib/talons/Adapter/useAdapter.js +208 -208
  48. package/src/overwrites/peregrine/lib/talons/Header/storeSwitcher.gql.js +45 -45
  49. package/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js +204 -204
  50. package/src/overwrites/peregrine/lib/talons/Region/useRegion.js +102 -102
  51. package/src/overwrites/peregrine/lib/talons/SignIn/signIn.gql.js +56 -56
  52. package/src/overwrites/peregrine/lib/talons/SignIn/useSignIn.js +226 -226
  53. package/src/overwrites/peregrine/lib/util/deriveErrorMessage.js +34 -34
  54. package/src/overwrites/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql +11 -11
  55. package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +112 -112
  56. package/src/overwrites/venia-ui/lib/components/Header/header.js +130 -130
  57. package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.js +105 -105
  58. package/src/overwrites/venia-ui/lib/components/Header/switcherItem.js +47 -47
  59. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -91
  60. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -123
  61. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -61
  62. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -50
  63. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -114
  64. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -71
  65. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -59
  66. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -34
  67. package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -1
  68. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -90
  69. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -12
  70. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -156
  71. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +30 -30
  72. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -89
  73. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +42 -42
  74. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -99
  75. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -28
  76. package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -11
  77. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -72
  78. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -30
  79. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -69
  80. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -7
  81. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -12
  82. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -52
  83. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -82
  84. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -87
  85. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -45
  86. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -43
  87. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -45
  88. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -110
  89. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -172
  90. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -62
  91. package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -1
  92. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -74
  93. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +49 -49
  94. package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -40
  95. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -48
  96. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -13
  97. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -49
  98. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -97
  99. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -24
  100. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -43
  101. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -13
  102. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -75
  103. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -6
  104. package/src/overwrites/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js +75 -75
  105. package/src/overwrites/venia-ui/lib/targets/venia-ui-intercept.js +70 -70
  106. package/src/queries/getAvailableWebsitesConfigData.graphql +14 -14
  107. package/src/queries/index.js +30 -30
  108. package/src/talons/BecomeSeller/becomeSeller.gql.js +45 -45
  109. package/src/talons/BecomeSeller/useBecomeSeller.js +145 -145
  110. package/src/talons/BecomeSellerLink/useBecomeSellerLink.js +11 -11
  111. package/src/talons/BecomeSellerPage/useBecomeSellerPage.js +76 -76
  112. package/src/talons/Header/useBecomeSellerLink.js +13 -13
  113. package/src/talons/Header/useWebsiteSwitcher.js +218 -218
  114. package/src/talons/Seller/seller.gql.js +139 -204
  115. package/src/talons/Seller/useSeller.js +66 -71
  116. package/src/talons/SellerAccountPage/useSellerAccountPage.js +174 -174
  117. package/src/talons/SellerCountry/useSellerCountry.js +25 -25
  118. package/src/talons/WebsiteByIp/getWebsiteByIp.gql.js +13 -13
  119. package/src/talons/WebsiteByIp/useWebsiteByIp.js +34 -34
  120. package/src/talons/WebsiteSwitcher/useWebsiteSwitcher.js +218 -218
  121. package/src/theme/vars.js +6 -6
  122. package/src/util/mapSeller.js +7 -7
  123. package/src/components/OperatingHours/index.js +0 -1
  124. package/src/components/OperatingHours/operatingHours.js +0 -32
  125. package/src/components/Seller/sellerAddressCard.js +0 -48
  126. package/src/components/SellerDetail/index.js +0 -1
  127. package/src/components/SellerDetail/sellerDetail.js +0 -158
  128. package/src/components/SellerPage/core.js +0 -10
  129. package/src/talons/SellerProducts/useSellerProducts.js +0 -129
@@ -1,90 +1,90 @@
1
- import React, { useEffect, useRef, useState } from 'react';
2
-
3
- import { useIsInViewport } from '@magento/peregrine/lib/hooks/useIsInViewport';
4
- import { useMegaMenu } from '@magento/peregrine/lib/talons/MegaMenu/useMegaMenu';
5
- import { useStyle } from '@magento/venia-ui/lib/classify';
6
-
7
- import MegaMenuItem from './megaMenuItem';
8
- import defaultClasses from './megaMenu.module.css';
9
- import cn from 'classnames';
10
-
11
- /**
12
- * The MegaMenu component displays menu with categories on desktop devices
13
- */
14
- const MegaMenu = (props) => {
15
- const { rootClassName, megaMenuItemClassname, titleClassName } = props
16
- const mainNavRef = useRef(null);
17
-
18
- const classes = useStyle(defaultClasses, props.classes);
19
- // const rootClass = cn(classes.megaMenu, rootClassName);
20
- const rootClass = cn('xs_hidden xl_flex flex-grow justify-self-center', rootClassName);
21
-
22
- const {
23
- megaMenuData,
24
- activeCategoryId,
25
- subMenuState,
26
- disableFocus,
27
- handleSubMenuFocus,
28
- categoryUrlSuffix,
29
- handleNavigate,
30
- handleClickOutside
31
- } = useMegaMenu({ mainNavRef });
32
-
33
- const [mainNavWidth, setMainNavWidth] = useState(0);
34
- const shouldRenderItems = useIsInViewport({
35
- elementRef: mainNavRef
36
- });
37
-
38
- useEffect(() => {
39
- const handleResize = () => {
40
- const navWidth = mainNavRef.current
41
- ? mainNavRef.current.offsetWidth
42
- : null;
43
-
44
- setMainNavWidth(navWidth);
45
- };
46
-
47
- window.addEventListener('resize', handleResize);
48
-
49
- handleResize();
50
-
51
- return () => {
52
- window.removeEventListener('resize', handleResize);
53
- };
54
- });
55
-
56
- const items = megaMenuData.children
57
- ? megaMenuData.children.map(category => {
58
- return (
59
- <MegaMenuItem
60
- category={category}
61
- activeCategoryId={activeCategoryId}
62
- categoryUrlSuffix={categoryUrlSuffix}
63
- mainNavWidth={mainNavWidth}
64
- onNavigate={handleNavigate}
65
- key={category.uid}
66
- subMenuState={subMenuState}
67
- disableFocus={disableFocus}
68
- handleSubMenuFocus={handleSubMenuFocus}
69
- handleClickOutside={handleClickOutside}
70
- megaMenuItemClassname={megaMenuItemClassname}
71
- titleClassName={titleClassName}
72
- />
73
- );
74
- })
75
- : null;
76
-
77
- return (
78
- <nav
79
- ref={mainNavRef}
80
- className={rootClass}
81
- data-cy="MegaMenu-megaMenu"
82
- role="navigation"
83
- onFocus={handleSubMenuFocus}
84
- >
85
- {shouldRenderItems ? items : null}
86
- </nav>
87
- );
88
- };
89
-
90
- export default MegaMenu;
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+
3
+ import { useIsInViewport } from '@magento/peregrine/lib/hooks/useIsInViewport';
4
+ import { useMegaMenu } from '@magento/peregrine/lib/talons/MegaMenu/useMegaMenu';
5
+ import { useStyle } from '@magento/venia-ui/lib/classify';
6
+
7
+ import MegaMenuItem from './megaMenuItem';
8
+ import defaultClasses from './megaMenu.module.css';
9
+ import cn from 'classnames';
10
+
11
+ /**
12
+ * The MegaMenu component displays menu with categories on desktop devices
13
+ */
14
+ const MegaMenu = (props) => {
15
+ const { rootClassName, megaMenuItemClassname, titleClassName } = props
16
+ const mainNavRef = useRef(null);
17
+
18
+ const classes = useStyle(defaultClasses, props.classes);
19
+ // const rootClass = cn(classes.megaMenu, rootClassName);
20
+ const rootClass = cn('xs_hidden xl_flex flex-grow justify-self-center', rootClassName);
21
+
22
+ const {
23
+ megaMenuData,
24
+ activeCategoryId,
25
+ subMenuState,
26
+ disableFocus,
27
+ handleSubMenuFocus,
28
+ categoryUrlSuffix,
29
+ handleNavigate,
30
+ handleClickOutside
31
+ } = useMegaMenu({ mainNavRef });
32
+
33
+ const [mainNavWidth, setMainNavWidth] = useState(0);
34
+ const shouldRenderItems = useIsInViewport({
35
+ elementRef: mainNavRef
36
+ });
37
+
38
+ useEffect(() => {
39
+ const handleResize = () => {
40
+ const navWidth = mainNavRef.current
41
+ ? mainNavRef.current.offsetWidth
42
+ : null;
43
+
44
+ setMainNavWidth(navWidth);
45
+ };
46
+
47
+ window.addEventListener('resize', handleResize);
48
+
49
+ handleResize();
50
+
51
+ return () => {
52
+ window.removeEventListener('resize', handleResize);
53
+ };
54
+ });
55
+
56
+ const items = megaMenuData.children
57
+ ? megaMenuData.children.map(category => {
58
+ return (
59
+ <MegaMenuItem
60
+ category={category}
61
+ activeCategoryId={activeCategoryId}
62
+ categoryUrlSuffix={categoryUrlSuffix}
63
+ mainNavWidth={mainNavWidth}
64
+ onNavigate={handleNavigate}
65
+ key={category.uid}
66
+ subMenuState={subMenuState}
67
+ disableFocus={disableFocus}
68
+ handleSubMenuFocus={handleSubMenuFocus}
69
+ handleClickOutside={handleClickOutside}
70
+ megaMenuItemClassname={megaMenuItemClassname}
71
+ titleClassName={titleClassName}
72
+ />
73
+ );
74
+ })
75
+ : null;
76
+
77
+ return (
78
+ <nav
79
+ ref={mainNavRef}
80
+ className={rootClass}
81
+ data-cy="MegaMenu-megaMenu"
82
+ role="navigation"
83
+ onFocus={handleSubMenuFocus}
84
+ >
85
+ {shouldRenderItems ? items : null}
86
+ </nav>
87
+ );
88
+ };
89
+
90
+ export default MegaMenu;
@@ -1,12 +1,12 @@
1
- .megaMenu {
2
- composes: col-end-10 from global;
3
- composes: col-start-3 from global;
4
- composes: flex-grow from global;
5
- composes: hidden from global;
6
- composes: justify-self-center from global;
7
- }
8
-
9
- /* Large screen styles */
10
- .megaMenu {
11
- composes: lg_flex from global;
12
- }
1
+ .megaMenu {
2
+ composes: col-end-10 from global;
3
+ composes: col-start-3 from global;
4
+ composes: flex-grow from global;
5
+ composes: hidden from global;
6
+ composes: justify-self-center from global;
7
+ }
8
+
9
+ /* Large screen styles */
10
+ .megaMenu {
11
+ composes: lg_flex from global;
12
+ }
@@ -1,156 +1,156 @@
1
- import React, { useMemo } from 'react';
2
- import { ChevronDown as ArrowDown } from 'react-feather';
3
- import { Link } from 'react-router-dom';
4
- import PropTypes from 'prop-types';
5
-
6
- import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
7
- import { useMegaMenuItem } from '@magento/peregrine/lib/talons/MegaMenu/useMegaMenuItem';
8
-
9
- import { useStyle } from '@magento/venia-ui/lib/classify';
10
- import defaultClasses from './megaMenuItem.module.css';
11
- import Submenu from './submenu';
12
- import { ArrowDown2 } from 'iconsax-react';
13
- import { textPrimary } from '@riosst100/pwa-marketplace/src/theme/vars';
14
- import cn from 'classnames';
15
-
16
- /**
17
- * The MegaMenuItem component displays mega menu item
18
- *
19
- * @param {MegaMenuCategory} props.category
20
- * @param {String} props.activeCategoryId - uid of active category
21
- * @param {int} props.mainNavWidth - width of the main nav. It's used for setting min-width of the submenu
22
- * @param {function} props.onNavigate - function called when clicking on Link
23
- */
24
- const MegaMenuItem = props => {
25
- const {
26
- activeCategoryId,
27
- category,
28
- mainNavWidth,
29
- categoryUrlSuffix,
30
- subMenuState,
31
- disableFocus,
32
- onNavigate,
33
- handleSubMenuFocus,
34
- handleClickOutside,
35
- megaMenuItemClassname,
36
- titleClassName,
37
- } = props;
38
-
39
- const classes = useStyle(defaultClasses, props.classes);
40
- const categoryUrl = resourceUrl(
41
- `/${category.url_path}${categoryUrlSuffix || ''}`
42
- );
43
-
44
- const talonProps = useMegaMenuItem({
45
- category,
46
- activeCategoryId,
47
- subMenuState,
48
- disableFocus
49
- });
50
-
51
- const {
52
- isFocused,
53
- isActive,
54
- handleMenuItemFocus,
55
- handleCloseSubMenu,
56
- isMenuActive,
57
- handleKeyDown
58
- } = talonProps;
59
-
60
- const itemClassName = isMenuActive
61
- ? classes.megaMenuItem_active
62
- : classes.megaMenuItem;
63
-
64
- const children = useMemo(() => {
65
- return category.children.length ? (
66
- <Submenu
67
- isFocused={isFocused}
68
- subMenuState={subMenuState}
69
- items={category.children}
70
- mainNavWidth={mainNavWidth}
71
- handleCloseSubMenu={handleCloseSubMenu}
72
- categoryUrlSuffix={categoryUrlSuffix}
73
- onNavigate={onNavigate}
74
- />
75
- ) : null;
76
- }, [
77
- category,
78
- isFocused,
79
- mainNavWidth,
80
- subMenuState,
81
- handleCloseSubMenu,
82
- categoryUrlSuffix,
83
- onNavigate
84
- ]);
85
-
86
- const maybeDownArrowIcon = category.children.length ? (
87
- <ArrowDown2 className='ml-2' size="16" color={textPrimary} variant="Outline" />
88
- ) : null;
89
-
90
- const linkAttributes = category.children.length
91
- ? {
92
- 'aria-label': `Category: ${category.name}. ${category.children.length
93
- } sub-categories`
94
- }
95
- : {};
96
-
97
- return (
98
- <div
99
- className={cn(itemClassName, megaMenuItemClassname)}
100
- data-cy="MegaMenu-MegaMenuItem-megaMenuItem"
101
- onMouseEnter={() => {
102
- handleSubMenuFocus();
103
- handleMenuItemFocus();
104
- }}
105
- onFocus={() => {
106
- handleSubMenuFocus();
107
- handleMenuItemFocus();
108
- }}
109
- onTouchStart={() => {
110
- handleSubMenuFocus();
111
- handleMenuItemFocus();
112
- }}
113
- onMouseLeave={e => {
114
- handleClickOutside(e);
115
- handleCloseSubMenu();
116
- }}
117
- >
118
- <Link
119
- {...linkAttributes}
120
- onKeyDown={handleKeyDown}
121
- className={cn(
122
- isActive ? classes.megaMenuLinkActive : classes.megaMenuLink,
123
- titleClassName
124
- )}
125
- data-cy="MegaMenu-MegaMenuItem-link"
126
- to={categoryUrl}
127
- onClick={onNavigate}
128
- >
129
- {category.name}
130
- {maybeDownArrowIcon}
131
- </Link>
132
- {children}
133
- </div>
134
- );
135
- };
136
-
137
- export default MegaMenuItem;
138
-
139
- MegaMenuItem.propTypes = {
140
- category: PropTypes.shape({
141
- children: PropTypes.array,
142
- uid: PropTypes.string.isRequired,
143
- include_in_menu: PropTypes.number,
144
- isActive: PropTypes.bool.isRequired,
145
- name: PropTypes.string.isRequired,
146
- path: PropTypes.array.isRequired,
147
- position: PropTypes.number.isRequired,
148
- url_path: PropTypes.string.isRequired
149
- }).isRequired,
150
- activeCategoryId: PropTypes.string,
151
- mainNavWidth: PropTypes.number.isRequired,
152
- categoryUrlSuffix: PropTypes.string,
153
- onNavigate: PropTypes.func.isRequired,
154
- handleSubMenuFocus: PropTypes.func.isRequired,
155
- handleClickOutside: PropTypes.func.isRequired
156
- };
1
+ import React, { useMemo } from 'react';
2
+ import { ChevronDown as ArrowDown } from 'react-feather';
3
+ import { Link } from 'react-router-dom';
4
+ import PropTypes from 'prop-types';
5
+
6
+ import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
7
+ import { useMegaMenuItem } from '@magento/peregrine/lib/talons/MegaMenu/useMegaMenuItem';
8
+
9
+ import { useStyle } from '@magento/venia-ui/lib/classify';
10
+ import defaultClasses from './megaMenuItem.module.css';
11
+ import Submenu from './submenu';
12
+ import { ArrowDown2 } from 'iconsax-react';
13
+ import { textPrimary } from '@riosst100/pwa-marketplace/src/theme/vars';
14
+ import cn from 'classnames';
15
+
16
+ /**
17
+ * The MegaMenuItem component displays mega menu item
18
+ *
19
+ * @param {MegaMenuCategory} props.category
20
+ * @param {String} props.activeCategoryId - uid of active category
21
+ * @param {int} props.mainNavWidth - width of the main nav. It's used for setting min-width of the submenu
22
+ * @param {function} props.onNavigate - function called when clicking on Link
23
+ */
24
+ const MegaMenuItem = props => {
25
+ const {
26
+ activeCategoryId,
27
+ category,
28
+ mainNavWidth,
29
+ categoryUrlSuffix,
30
+ subMenuState,
31
+ disableFocus,
32
+ onNavigate,
33
+ handleSubMenuFocus,
34
+ handleClickOutside,
35
+ megaMenuItemClassname,
36
+ titleClassName,
37
+ } = props;
38
+
39
+ const classes = useStyle(defaultClasses, props.classes);
40
+ const categoryUrl = resourceUrl(
41
+ `/${category.url_path}${categoryUrlSuffix || ''}`
42
+ );
43
+
44
+ const talonProps = useMegaMenuItem({
45
+ category,
46
+ activeCategoryId,
47
+ subMenuState,
48
+ disableFocus
49
+ });
50
+
51
+ const {
52
+ isFocused,
53
+ isActive,
54
+ handleMenuItemFocus,
55
+ handleCloseSubMenu,
56
+ isMenuActive,
57
+ handleKeyDown
58
+ } = talonProps;
59
+
60
+ const itemClassName = isMenuActive
61
+ ? classes.megaMenuItem_active
62
+ : classes.megaMenuItem;
63
+
64
+ const children = useMemo(() => {
65
+ return category.children.length ? (
66
+ <Submenu
67
+ isFocused={isFocused}
68
+ subMenuState={subMenuState}
69
+ items={category.children}
70
+ mainNavWidth={mainNavWidth}
71
+ handleCloseSubMenu={handleCloseSubMenu}
72
+ categoryUrlSuffix={categoryUrlSuffix}
73
+ onNavigate={onNavigate}
74
+ />
75
+ ) : null;
76
+ }, [
77
+ category,
78
+ isFocused,
79
+ mainNavWidth,
80
+ subMenuState,
81
+ handleCloseSubMenu,
82
+ categoryUrlSuffix,
83
+ onNavigate
84
+ ]);
85
+
86
+ const maybeDownArrowIcon = category.children.length ? (
87
+ <ArrowDown2 className='ml-2' size="16" color={textPrimary} variant="Outline" />
88
+ ) : null;
89
+
90
+ const linkAttributes = category.children.length
91
+ ? {
92
+ 'aria-label': `Category: ${category.name}. ${category.children.length
93
+ } sub-categories`
94
+ }
95
+ : {};
96
+
97
+ return (
98
+ <div
99
+ className={cn(itemClassName, megaMenuItemClassname)}
100
+ data-cy="MegaMenu-MegaMenuItem-megaMenuItem"
101
+ onMouseEnter={() => {
102
+ handleSubMenuFocus();
103
+ handleMenuItemFocus();
104
+ }}
105
+ onFocus={() => {
106
+ handleSubMenuFocus();
107
+ handleMenuItemFocus();
108
+ }}
109
+ onTouchStart={() => {
110
+ handleSubMenuFocus();
111
+ handleMenuItemFocus();
112
+ }}
113
+ onMouseLeave={e => {
114
+ handleClickOutside(e);
115
+ handleCloseSubMenu();
116
+ }}
117
+ >
118
+ <Link
119
+ {...linkAttributes}
120
+ onKeyDown={handleKeyDown}
121
+ className={cn(
122
+ isActive ? classes.megaMenuLinkActive : classes.megaMenuLink,
123
+ titleClassName
124
+ )}
125
+ data-cy="MegaMenu-MegaMenuItem-link"
126
+ to={categoryUrl}
127
+ onClick={onNavigate}
128
+ >
129
+ {category.name}
130
+ {maybeDownArrowIcon}
131
+ </Link>
132
+ {children}
133
+ </div>
134
+ );
135
+ };
136
+
137
+ export default MegaMenuItem;
138
+
139
+ MegaMenuItem.propTypes = {
140
+ category: PropTypes.shape({
141
+ children: PropTypes.array,
142
+ uid: PropTypes.string.isRequired,
143
+ include_in_menu: PropTypes.number,
144
+ isActive: PropTypes.bool.isRequired,
145
+ name: PropTypes.string.isRequired,
146
+ path: PropTypes.array.isRequired,
147
+ position: PropTypes.number.isRequired,
148
+ url_path: PropTypes.string.isRequired
149
+ }).isRequired,
150
+ activeCategoryId: PropTypes.string,
151
+ mainNavWidth: PropTypes.number.isRequired,
152
+ categoryUrlSuffix: PropTypes.string,
153
+ onNavigate: PropTypes.func.isRequired,
154
+ handleSubMenuFocus: PropTypes.func.isRequired,
155
+ handleClickOutside: PropTypes.func.isRequired
156
+ };
@@ -1,31 +1,31 @@
1
- .megaMenuItem {
2
- /* composes: px-3 from global;
3
- composes: py-0 from global; */
4
- }
5
-
6
- .megaMenuLink {
7
- composes: items-center from global;
8
- composes: inline-flex from global;
9
- /* min-height: 5rem; */
10
- }
11
-
12
- .megaMenuLinkActive {
13
- composes: megaMenuLink;
14
- composes: underline from global;
15
- }
16
-
17
- .megaMenuItem_active {
18
- composes: megaMenuItem;
19
- composes: flex from global;
20
- }
21
-
22
- .arrowDown {
23
- composes: leading-[0] from global;
24
- composes: pl-2xs from global;
25
- }
26
-
27
- /* TODO @TW: cannot compose */
28
- .megaMenuItem:hover .megaMenuLink,
29
- .megaMenuItem:focus .megaMenuLink {
30
- text-decoration: underline;
1
+ .megaMenuItem {
2
+ /* composes: px-3 from global;
3
+ composes: py-0 from global; */
4
+ }
5
+
6
+ .megaMenuLink {
7
+ composes: items-center from global;
8
+ composes: inline-flex from global;
9
+ /* min-height: 5rem; */
10
+ }
11
+
12
+ .megaMenuLinkActive {
13
+ composes: megaMenuLink;
14
+ composes: underline from global;
15
+ }
16
+
17
+ .megaMenuItem_active {
18
+ composes: megaMenuItem;
19
+ composes: flex from global;
20
+ }
21
+
22
+ .arrowDown {
23
+ composes: leading-[0] from global;
24
+ composes: pl-2xs from global;
25
+ }
26
+
27
+ /* TODO @TW: cannot compose */
28
+ .megaMenuItem:hover .megaMenuLink,
29
+ .megaMenuItem:focus .megaMenuLink {
30
+ text-decoration: underline;
31
31
  }