@jetshop/ui 5.7.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 (687) hide show
  1. package/Accordion/Accordion.d.ts +33 -0
  2. package/Accordion/Accordion.js +59 -0
  3. package/Accordion/Accordion.js.map +1 -0
  4. package/Accordion/Accordion.test.js +73 -0
  5. package/Accordion/__doc_utils__/AccordionHeader.js +12 -0
  6. package/Auth/FormFields/CountriesInput.d.ts +14 -0
  7. package/Auth/FormFields/CountriesInput.js +28 -0
  8. package/Auth/FormFields/CountriesInput.js.map +1 -0
  9. package/Auth/LogInBehavior.d.ts +22 -0
  10. package/Auth/LogInBehavior.js +24 -0
  11. package/Auth/LogInBehavior.js.map +1 -0
  12. package/Auth/LogInFormProvider.d.ts +7 -0
  13. package/Auth/LogInFormProvider.js +71 -0
  14. package/Auth/LogInFormProvider.js.map +1 -0
  15. package/Auth/LogOut.d.ts +10 -0
  16. package/Auth/LogOut.js +24 -0
  17. package/Auth/LogOut.js.map +1 -0
  18. package/Auth/logInValidator.d.ts +8 -0
  19. package/Auth/logInValidator.js +16 -0
  20. package/Auth/logInValidator.js.map +1 -0
  21. package/Breadcrumbs/Breadcrumbs.d.ts +15 -0
  22. package/Breadcrumbs/Breadcrumbs.js +67 -0
  23. package/Breadcrumbs/Breadcrumbs.js.map +1 -0
  24. package/Breadcrumbs/getParentsOrCanonicalRoute.d.ts +3 -0
  25. package/Breadcrumbs/getParentsOrCanonicalRoute.js +13 -0
  26. package/Breadcrumbs/getParentsOrCanonicalRoute.js.map +1 -0
  27. package/Breadcrumbs/index.d.ts +1 -0
  28. package/Breadcrumbs/index.js +2 -0
  29. package/Breadcrumbs/index.js.map +1 -0
  30. package/Breakpoints.d.ts +13 -0
  31. package/Breakpoints.js +37 -0
  32. package/Breakpoints.js.map +1 -0
  33. package/Button/Button.d.ts +14 -0
  34. package/Button/Button.js +60 -0
  35. package/Button/Button.js.map +1 -0
  36. package/Button/OutlineButton.d.ts +4 -0
  37. package/Button/OutlineButton.js +10 -0
  38. package/Button/OutlineButton.js.map +1 -0
  39. package/Button/SecondaryButton.d.ts +3 -0
  40. package/Button/SecondaryButton.js +9 -0
  41. package/Button/SecondaryButton.js.map +1 -0
  42. package/Button/TrendButton.d.ts +3 -0
  43. package/Button/TrendButton.js +8 -0
  44. package/Button/TrendButton.js.map +1 -0
  45. package/Button/index.d.ts +4 -0
  46. package/Button/index.js +5 -0
  47. package/Button/index.js.map +1 -0
  48. package/CategoryLink.d.ts +9 -0
  49. package/CategoryLink.js +43 -0
  50. package/CategoryLink.js.map +1 -0
  51. package/ChannelSelector/ChannelListItem.d.ts +10 -0
  52. package/ChannelSelector/ChannelListItem.js +51 -0
  53. package/ChannelSelector/ChannelListItem.js.map +1 -0
  54. package/ChannelSelector/ChannelListItem.test.js +85 -0
  55. package/ChannelSelector/ChannelSelector.d.ts +63 -0
  56. package/ChannelSelector/ChannelSelector.js +80 -0
  57. package/ChannelSelector/ChannelSelector.js.map +1 -0
  58. package/ChannelSelector/ChannelSelector.test.js +167 -0
  59. package/ChannelSelector/ChannelSelectorButtons.d.ts +3 -0
  60. package/ChannelSelector/ChannelSelectorButtons.js +20 -0
  61. package/ChannelSelector/ChannelSelectorButtons.js.map +1 -0
  62. package/ChannelSelector/Channels.d.ts +17 -0
  63. package/ChannelSelector/Channels.js +12 -0
  64. package/ChannelSelector/Channels.js.map +1 -0
  65. package/ChannelSelector/Channels.test.js +90 -0
  66. package/ChannelSelector/LargeSelector.d.ts +3 -0
  67. package/ChannelSelector/LargeSelector.js +67 -0
  68. package/ChannelSelector/LargeSelector.js.map +1 -0
  69. package/ChannelSelector/MiniSelector.d.ts +4 -0
  70. package/ChannelSelector/MiniSelector.js +58 -0
  71. package/ChannelSelector/MiniSelector.js.map +1 -0
  72. package/ChannelSelector/Region.d.ts +28 -0
  73. package/ChannelSelector/Region.js +21 -0
  74. package/ChannelSelector/Region.js.map +1 -0
  75. package/ChannelSelector/Region.test.js +37 -0
  76. package/ChannelSelector/exampleChannels.js +577 -0
  77. package/ChannelSelector/groupBy.d.ts +7 -0
  78. package/ChannelSelector/groupBy.js +16 -0
  79. package/ChannelSelector/groupBy.js.map +1 -0
  80. package/ChannelSelector/groupBy.test.js +42 -0
  81. package/Checkbox/Checkbox.d.ts +10 -0
  82. package/Checkbox/Checkbox.js +69 -0
  83. package/Checkbox/Checkbox.js.map +1 -0
  84. package/Checkbox/CheckboxGroup.d.ts +23 -0
  85. package/Checkbox/CheckboxGroup.js +22 -0
  86. package/Checkbox/CheckboxGroup.js.map +1 -0
  87. package/Checkbox/index.d.ts +2 -0
  88. package/Checkbox/index.js +3 -0
  89. package/Checkbox/index.js.map +1 -0
  90. package/ContentPageLink.d.ts +9 -0
  91. package/ContentPageLink.js +37 -0
  92. package/ContentPageLink.js.map +1 -0
  93. package/ContentRenderer.d.ts +9 -0
  94. package/ContentRenderer.js +36 -0
  95. package/ContentRenderer.js.map +1 -0
  96. package/DropdownMenu/Button.d.ts +7 -0
  97. package/DropdownMenu/Button.js +32 -0
  98. package/DropdownMenu/Button.js.map +1 -0
  99. package/DropdownMenu/DropdownMenu.d.ts +21 -0
  100. package/DropdownMenu/DropdownMenu.js +73 -0
  101. package/DropdownMenu/DropdownMenu.js.map +1 -0
  102. package/DropdownMenu/Item.d.ts +13 -0
  103. package/DropdownMenu/Item.js +48 -0
  104. package/DropdownMenu/Item.js.map +1 -0
  105. package/DropdownMenu/Items.d.ts +16 -0
  106. package/DropdownMenu/Items.js +53 -0
  107. package/DropdownMenu/Items.js.map +1 -0
  108. package/DropdownMenu/index.d.ts +4 -0
  109. package/DropdownMenu/index.js +5 -0
  110. package/DropdownMenu/index.js.map +1 -0
  111. package/ErrorBoundary/Generic.d.ts +17 -0
  112. package/ErrorBoundary/Generic.js +72 -0
  113. package/ErrorBoundary/Generic.js.map +1 -0
  114. package/ErrorBoundary/PassThrough.d.ts +3 -0
  115. package/ErrorBoundary/PassThrough.js +7 -0
  116. package/ErrorBoundary/PassThrough.js.map +1 -0
  117. package/Gallery/Gallery.d.ts +38 -0
  118. package/Gallery/Gallery.js +122 -0
  119. package/Gallery/Gallery.js.map +1 -0
  120. package/Gallery/constructGallery.d.ts +14 -0
  121. package/Gallery/constructGallery.js +40 -0
  122. package/Gallery/constructGallery.js.map +1 -0
  123. package/Image/Fallback.d.ts +5 -0
  124. package/Image/Fallback.js +4 -0
  125. package/Image/Fallback.js.map +1 -0
  126. package/Image/Image.d.ts +49 -0
  127. package/Image/Image.js +211 -0
  128. package/Image/Image.js.map +1 -0
  129. package/Image/Image.test.js +277 -0
  130. package/Image/index.d.ts +1 -0
  131. package/Image/index.js +2 -0
  132. package/Image/index.js.map +1 -0
  133. package/Image/useConstructImage.d.ts +13 -0
  134. package/Image/useConstructImage.js +96 -0
  135. package/Image/useConstructImage.js.map +1 -0
  136. package/Image/utils/aspectRatioToFraction.d.ts +2 -0
  137. package/Image/utils/aspectRatioToFraction.js +11 -0
  138. package/Image/utils/aspectRatioToFraction.js.map +1 -0
  139. package/Image/utils/getFullUrl.d.ts +6 -0
  140. package/Image/utils/getFullUrl.js +18 -0
  141. package/Image/utils/getFullUrl.js.map +1 -0
  142. package/Image/utils/getImageWidth.d.ts +1 -0
  143. package/Image/utils/getImageWidth.js +12 -0
  144. package/Image/utils/getImageWidth.js.map +1 -0
  145. package/Image/utils/getImageWidths.d.ts +2 -0
  146. package/Image/utils/getImageWidths.js +14 -0
  147. package/Image/utils/getImageWidths.js.map +1 -0
  148. package/Image/utils/getLQIP.d.ts +8 -0
  149. package/Image/utils/getLQIP.js +20 -0
  150. package/Image/utils/getLQIP.js.map +1 -0
  151. package/Image/utils/getLargestSize.d.ts +7 -0
  152. package/Image/utils/getLargestSize.js +17 -0
  153. package/Image/utils/getLargestSize.js.map +1 -0
  154. package/Image/utils/getSizeForBreakpoint.d.ts +2 -0
  155. package/Image/utils/getSizeForBreakpoint.js +16 -0
  156. package/Image/utils/getSizeForBreakpoint.js.map +1 -0
  157. package/Image/utils/getSizesMap.d.ts +2 -0
  158. package/Image/utils/getSizesMap.js +22 -0
  159. package/Image/utils/getSizesMap.js.map +1 -0
  160. package/Image/utils/getSmallestSize.d.ts +2 -0
  161. package/Image/utils/getSmallestSize.js +12 -0
  162. package/Image/utils/getSmallestSize.js.map +1 -0
  163. package/Image/utils/getSrcSetFromWidths.d.ts +8 -0
  164. package/Image/utils/getSrcSetFromWidths.js +9 -0
  165. package/Image/utils/getSrcSetFromWidths.js.map +1 -0
  166. package/Image/utils/getSrcWithParams.d.ts +3 -0
  167. package/Image/utils/getSrcWithParams.js +26 -0
  168. package/Image/utils/getSrcWithParams.js.map +1 -0
  169. package/Image/utils/paddingForAspectRatio.d.ts +1 -0
  170. package/Image/utils/paddingForAspectRatio.js +6 -0
  171. package/Image/utils/paddingForAspectRatio.js.map +1 -0
  172. package/Image/utils/remToPx.d.ts +1 -0
  173. package/Image/utils/remToPx.js +2 -0
  174. package/Image/utils/remToPx.js.map +1 -0
  175. package/Image/utils/sizeToNumber.d.ts +2 -0
  176. package/Image/utils/sizeToNumber.js +27 -0
  177. package/Image/utils/sizeToNumber.js.map +1 -0
  178. package/Input/Input.d.ts +6 -0
  179. package/Input/Input.js +45 -0
  180. package/Input/Input.js.map +1 -0
  181. package/Input/index.d.ts +3 -0
  182. package/Input/index.js +4 -0
  183. package/Input/index.js.map +1 -0
  184. package/JetshopText.d.ts +3 -0
  185. package/JetshopText.js +12 -0
  186. package/JetshopText.js.map +1 -0
  187. package/Loading/LoadingBar.d.ts +8 -0
  188. package/Loading/LoadingBar.js +49 -0
  189. package/Loading/LoadingBar.js.map +1 -0
  190. package/Loading/LoadingLine.d.ts +31 -0
  191. package/Loading/LoadingLine.js +26 -0
  192. package/Loading/LoadingLine.js.map +1 -0
  193. package/Loading/LoadingLine.test.js +18 -0
  194. package/Loading/NetworkStatusContext.d.ts +15 -0
  195. package/Loading/NetworkStatusContext.js +4 -0
  196. package/Loading/NetworkStatusContext.js.map +1 -0
  197. package/Menu/GetMoreSubcategoriesQuery.gql +25 -0
  198. package/Menu/MenuContainer.d.ts +28 -0
  199. package/Menu/MenuContainer.js +46 -0
  200. package/Menu/MenuContainer.js.map +1 -0
  201. package/Menu/MenuContainer.test.js +245 -0
  202. package/Menu/RecursiveTree.d.ts +28 -0
  203. package/Menu/RecursiveTree.js +91 -0
  204. package/Menu/RecursiveTree.js.map +1 -0
  205. package/Menu/RecursiveTree.test.js +416 -0
  206. package/Modal/Drawer/Drawer.d.ts +11 -0
  207. package/Modal/Drawer/Drawer.js +31 -0
  208. package/Modal/Drawer/Drawer.js.map +1 -0
  209. package/Modal/Drawer/DrawerTarget.d.ts +6 -0
  210. package/Modal/Drawer/DrawerTarget.js +12 -0
  211. package/Modal/Drawer/DrawerTarget.js.map +1 -0
  212. package/Modal/Drawer/DrawerTarget.test.js +112 -0
  213. package/Modal/Drawer/DrawerTrigger.d.ts +9 -0
  214. package/Modal/Drawer/DrawerTrigger.js +12 -0
  215. package/Modal/Drawer/DrawerTrigger.js.map +1 -0
  216. package/Modal/Drawer/DrawerTrigger.test.js +51 -0
  217. package/Modal/Drawer/index.d.ts +3 -0
  218. package/Modal/Drawer/index.js +4 -0
  219. package/Modal/Drawer/index.js.map +1 -0
  220. package/Modal/Flyout/FlyoutTarget.d.ts +10 -0
  221. package/Modal/Flyout/FlyoutTarget.js +13 -0
  222. package/Modal/Flyout/FlyoutTarget.js.map +1 -0
  223. package/Modal/Flyout/FlyoutTarget.test.js +95 -0
  224. package/Modal/Flyout/FlyoutTrigger.d.ts +13 -0
  225. package/Modal/Flyout/FlyoutTrigger.js +17 -0
  226. package/Modal/Flyout/FlyoutTrigger.js.map +1 -0
  227. package/Modal/Flyout/FlyoutTrigger.test.js +72 -0
  228. package/Modal/Flyout/index.d.ts +2 -0
  229. package/Modal/Flyout/index.js +3 -0
  230. package/Modal/Flyout/index.js.map +1 -0
  231. package/Modal/ModalContext.d.ts +19 -0
  232. package/Modal/ModalContext.js +13 -0
  233. package/Modal/ModalContext.js.map +1 -0
  234. package/Modal/ModalProvider.d.ts +11 -0
  235. package/Modal/ModalProvider.js +38 -0
  236. package/Modal/ModalProvider.js.map +1 -0
  237. package/Modal/ModalProvider.test.js +29 -0
  238. package/Modal/ModalRoot.d.ts +3 -0
  239. package/Modal/ModalRoot.js +39 -0
  240. package/Modal/ModalRoot.js.map +1 -0
  241. package/Modal/ModalRoot.test.js +51 -0
  242. package/Modal/ModalTrigger.d.ts +9 -0
  243. package/Modal/ModalTrigger.js +9 -0
  244. package/Modal/ModalTrigger.js.map +1 -0
  245. package/Modal/TargetWrapper.d.ts +31 -0
  246. package/Modal/TargetWrapper.js +45 -0
  247. package/Modal/TargetWrapper.js.map +1 -0
  248. package/Modal/TargetWrapper.test.js +81 -0
  249. package/Modal/__test_utils__/getComponentWithModalContext.js +33 -0
  250. package/Pagination/Pagination.d.ts +8 -0
  251. package/Pagination/Pagination.js +38 -0
  252. package/Pagination/Pagination.js.map +1 -0
  253. package/Pagination/PaginationBehaviour.d.ts +52 -0
  254. package/Pagination/PaginationBehaviour.js +68 -0
  255. package/Pagination/PaginationBehaviour.js.map +1 -0
  256. package/Pagination/index.d.ts +2 -0
  257. package/Pagination/index.js +3 -0
  258. package/Pagination/index.js.map +1 -0
  259. package/PreOrderDateSelector/PreOrderDateSelector.d.ts +20 -0
  260. package/PreOrderDateSelector/PreOrderDateSelector.js +74 -0
  261. package/PreOrderDateSelector/PreOrderDateSelector.js.map +1 -0
  262. package/PreOrderDateSelector/index.d.ts +2 -0
  263. package/PreOrderDateSelector/index.js +3 -0
  264. package/PreOrderDateSelector/index.js.map +1 -0
  265. package/Price/Currency.d.ts +9 -0
  266. package/Price/Currency.js +11 -0
  267. package/Price/Currency.js.map +1 -0
  268. package/Price/Price.d.ts +28 -0
  269. package/Price/Price.js +35 -0
  270. package/Price/Price.js.map +1 -0
  271. package/Price/index.d.ts +1 -0
  272. package/Price/index.js +2 -0
  273. package/Price/index.js.map +1 -0
  274. package/ProductLink.d.ts +21 -0
  275. package/ProductLink.js +67 -0
  276. package/ProductLink.js.map +1 -0
  277. package/ProductList/Badges.d.ts +6 -0
  278. package/ProductList/Badges.js +56 -0
  279. package/ProductList/Badges.js.map +1 -0
  280. package/ProductList/GridProduct.d.ts +24 -0
  281. package/ProductList/GridProduct.js +59 -0
  282. package/ProductList/GridProduct.js.map +1 -0
  283. package/ProductList/ProductGrid.d.ts +15 -0
  284. package/ProductList/ProductGrid.js +29 -0
  285. package/ProductList/ProductGrid.js.map +1 -0
  286. package/ProductList/ProductImage.d.ts +12 -0
  287. package/ProductList/ProductImage.js +22 -0
  288. package/ProductList/ProductImage.js.map +1 -0
  289. package/ProductSpecifications/ProductSpecifications.d.ts +8 -0
  290. package/ProductSpecifications/ProductSpecifications.js +78 -0
  291. package/ProductSpecifications/ProductSpecifications.js.map +1 -0
  292. package/ScrollRestorationHandler/ScrollRestorationHandler.d.ts +8 -0
  293. package/ScrollRestorationHandler/ScrollRestorationHandler.js +17 -0
  294. package/ScrollRestorationHandler/ScrollRestorationHandler.js.map +1 -0
  295. package/ScrollRestorationHandler/ScrollRestorationHandler.test.js +75 -0
  296. package/ScrollRestorationHandler/index.d.ts +1 -0
  297. package/ScrollRestorationHandler/index.js +2 -0
  298. package/ScrollRestorationHandler/index.js.map +1 -0
  299. package/ScrollRestorationHandler/isInIgnoredRouteTypes.d.ts +6 -0
  300. package/ScrollRestorationHandler/isInIgnoredRouteTypes.js +8 -0
  301. package/ScrollRestorationHandler/isInIgnoredRouteTypes.js.map +1 -0
  302. package/ScrollRestorationHandler/useScrollRestore.d.ts +7 -0
  303. package/ScrollRestorationHandler/useScrollRestore.js +15 -0
  304. package/ScrollRestorationHandler/useScrollRestore.js.map +1 -0
  305. package/Search/AutocompleteQuery.gql +10 -0
  306. package/Search/SearchAutoCompleteContainer.d.ts +45 -0
  307. package/Search/SearchAutoCompleteContainer.js +175 -0
  308. package/Search/SearchAutoCompleteContainer.js.map +1 -0
  309. package/Search/SearchAutoCompleteContainer.test.js +460 -0
  310. package/Search/SearchField.d.ts +15 -0
  311. package/Search/SearchField.js +97 -0
  312. package/Search/SearchField.js.map +1 -0
  313. package/Search/SearchPage/PageOf.d.ts +5 -0
  314. package/Search/SearchPage/PageOf.js +7 -0
  315. package/Search/SearchPage/PageOf.js.map +1 -0
  316. package/Search/SearchPage/SearchMeta.d.ts +16 -0
  317. package/Search/SearchPage/SearchMeta.js +20 -0
  318. package/Search/SearchPage/SearchMeta.js.map +1 -0
  319. package/Search/SearchPage/SearchPageBehaviour.d.ts +19 -0
  320. package/Search/SearchPage/SearchPageBehaviour.js +67 -0
  321. package/Search/SearchPage/SearchPageBehaviour.js.map +1 -0
  322. package/Search/SuggestedTerm.d.ts +16 -0
  323. package/Search/SuggestedTerm.js +42 -0
  324. package/Search/SuggestedTerm.js.map +1 -0
  325. package/Search/index.d.ts +1 -0
  326. package/Search/index.js +2 -0
  327. package/Search/index.js.map +1 -0
  328. package/Select/Components.d.ts +28 -0
  329. package/Select/Components.js +91 -0
  330. package/Select/Components.js.map +1 -0
  331. package/Select/SelectComponents/Quantity.d.ts +5 -0
  332. package/Select/SelectComponents/Quantity.js +8 -0
  333. package/Select/SelectComponents/Quantity.js.map +1 -0
  334. package/Select/index.d.ts +5 -0
  335. package/Select/index.js +1 -0
  336. package/Select/index.js.map +1 -0
  337. package/SortOrder/SortOrder.d.ts +16 -0
  338. package/SortOrder/SortOrder.js +32 -0
  339. package/SortOrder/SortOrder.js.map +1 -0
  340. package/SortOrder/SortOrderDropdown.d.ts +9 -0
  341. package/SortOrder/SortOrderDropdown.js +25 -0
  342. package/SortOrder/SortOrderDropdown.js.map +1 -0
  343. package/SortOrder/SortOrderList.d.ts +7 -0
  344. package/SortOrder/SortOrderList.js +17 -0
  345. package/SortOrder/SortOrderList.js.map +1 -0
  346. package/StartPageRenderer/StartPageRenderer.d.ts +17 -0
  347. package/StartPageRenderer/StartPageRenderer.js +52 -0
  348. package/StartPageRenderer/StartPageRenderer.js.map +1 -0
  349. package/StartPageRenderer/index.d.ts +1 -0
  350. package/StartPageRenderer/index.js +2 -0
  351. package/StartPageRenderer/index.js.map +1 -0
  352. package/Stock/StockStatusContainer.d.ts +16 -0
  353. package/Stock/StockStatusContainer.js +40 -0
  354. package/Stock/StockStatusContainer.js.map +1 -0
  355. package/Stock/__tests__/StockStatusContainer.test.js +65 -0
  356. package/Text/Text.d.ts +11 -0
  357. package/Text/Text.js +22 -0
  358. package/Text/Text.js.map +1 -0
  359. package/Text/index.d.ts +3 -0
  360. package/Text/index.js +4 -0
  361. package/Text/index.js.map +1 -0
  362. package/Theme/createTheme.d.ts +16 -0
  363. package/Theme/createTheme.js +5 -0
  364. package/Theme/createTheme.js.map +1 -0
  365. package/Theme/cssReset.d.ts +1 -0
  366. package/Theme/cssReset.js +160 -0
  367. package/Theme/cssReset.js.map +1 -0
  368. package/Theme/normalizeCss.d.ts +1 -0
  369. package/Theme/normalizeCss.js +357 -0
  370. package/Theme/normalizeCss.js.map +1 -0
  371. package/Theme/sanitizeCss.d.ts +1 -0
  372. package/Theme/sanitizeCss.js +572 -0
  373. package/Theme/sanitizeCss.js.map +1 -0
  374. package/WindowGrid/WindowGrid.d.ts +11 -0
  375. package/WindowGrid/WindowGrid.js +58 -0
  376. package/WindowGrid/WindowGrid.js.map +1 -0
  377. package/WindowGrid/index.d.ts +1 -0
  378. package/WindowGrid/index.js +2 -0
  379. package/WindowGrid/index.js.map +1 -0
  380. package/WindowGrid/useResizeObserver.d.ts +8 -0
  381. package/WindowGrid/useResizeObserver.js +14 -0
  382. package/WindowGrid/useResizeObserver.js.map +1 -0
  383. package/WindowGrid/useScrollWithWindow.d.ts +12 -0
  384. package/WindowGrid/useScrollWithWindow.js +39 -0
  385. package/WindowGrid/useScrollWithWindow.js.map +1 -0
  386. package/dependencies.d.ts +99 -0
  387. package/fuzzySearch/fuzzySearch.d.ts +18 -0
  388. package/fuzzySearch/fuzzySearch.js +43 -0
  389. package/fuzzySearch/fuzzySearch.js.map +1 -0
  390. package/fuzzySearch/index.d.ts +1 -0
  391. package/fuzzySearch/index.js +2 -0
  392. package/fuzzySearch/index.js.map +1 -0
  393. package/global.d.ts +1 -0
  394. package/hooks/index.d.ts +2 -0
  395. package/hooks/index.js +3 -0
  396. package/hooks/index.js.map +1 -0
  397. package/hooks/useOnClickOutside.d.ts +6 -0
  398. package/hooks/useOnClickOutside.js +17 -0
  399. package/hooks/useOnClickOutside.js.map +1 -0
  400. package/hooks/useOnEsc.d.ts +4 -0
  401. package/hooks/useOnEsc.js +17 -0
  402. package/hooks/useOnEsc.js.map +1 -0
  403. package/package.json +67 -0
  404. package/setupTests.js +2 -0
  405. package/svg/Carrot.svg +1 -0
  406. package/svg/Check.svg +1 -0
  407. package/svg/Cross.svg +1 -0
  408. package/svg/facebook.svg +1 -0
  409. package/svg/flags/ad.svg +150 -0
  410. package/svg/flags/ae.svg +6 -0
  411. package/svg/flags/af.svg +81 -0
  412. package/svg/flags/ag.svg +14 -0
  413. package/svg/flags/ai.svg +767 -0
  414. package/svg/flags/al.svg +5 -0
  415. package/svg/flags/am.svg +5 -0
  416. package/svg/flags/ao.svg +13 -0
  417. package/svg/flags/aq.svg +6 -0
  418. package/svg/flags/ar.svg +31 -0
  419. package/svg/flags/as.svg +33 -0
  420. package/svg/flags/at.svg +6 -0
  421. package/svg/flags/au.svg +9 -0
  422. package/svg/flags/aw.svg +186 -0
  423. package/svg/flags/ax.svg +18 -0
  424. package/svg/flags/az.svg +8 -0
  425. package/svg/flags/ba.svg +12 -0
  426. package/svg/flags/bb.svg +6 -0
  427. package/svg/flags/bd.svg +4 -0
  428. package/svg/flags/be.svg +7 -0
  429. package/svg/flags/bf.svg +7 -0
  430. package/svg/flags/bg.svg +7 -0
  431. package/svg/flags/bh.svg +11 -0
  432. package/svg/flags/bi.svg +15 -0
  433. package/svg/flags/bj.svg +14 -0
  434. package/svg/flags/bl.svg +7 -0
  435. package/svg/flags/bm.svg +98 -0
  436. package/svg/flags/bn.svg +36 -0
  437. package/svg/flags/bo.svg +676 -0
  438. package/svg/flags/bq.svg +5 -0
  439. package/svg/flags/br.svg +45 -0
  440. package/svg/flags/bs.svg +13 -0
  441. package/svg/flags/bt.svg +89 -0
  442. package/svg/flags/bv.svg +13 -0
  443. package/svg/flags/bw.svg +7 -0
  444. package/svg/flags/by.svg +20 -0
  445. package/svg/flags/bz.svg +145 -0
  446. package/svg/flags/ca.svg +4 -0
  447. package/svg/flags/cc.svg +19 -0
  448. package/svg/flags/cd.svg +5 -0
  449. package/svg/flags/cf.svg +15 -0
  450. package/svg/flags/cg.svg +12 -0
  451. package/svg/flags/ch.svg +9 -0
  452. package/svg/flags/ci.svg +7 -0
  453. package/svg/flags/ck.svg +9 -0
  454. package/svg/flags/cl.svg +13 -0
  455. package/svg/flags/cm.svg +15 -0
  456. package/svg/flags/cn.svg +11 -0
  457. package/svg/flags/co.svg +7 -0
  458. package/svg/flags/cr.svg +7 -0
  459. package/svg/flags/cu.svg +13 -0
  460. package/svg/flags/cv.svg +13 -0
  461. package/svg/flags/cw.svg +14 -0
  462. package/svg/flags/cx.svg +15 -0
  463. package/svg/flags/cy.svg +6 -0
  464. package/svg/flags/cz.svg +12 -0
  465. package/svg/flags/de.svg +5 -0
  466. package/svg/flags/dj.svg +13 -0
  467. package/svg/flags/dk.svg +5 -0
  468. package/svg/flags/dm.svg +152 -0
  469. package/svg/flags/do.svg +6745 -0
  470. package/svg/flags/dz.svg +5 -0
  471. package/svg/flags/ec.svg +138 -0
  472. package/svg/flags/ee.svg +7 -0
  473. package/svg/flags/eg.svg +38 -0
  474. package/svg/flags/eh.svg +15 -0
  475. package/svg/flags/er.svg +8 -0
  476. package/svg/flags/es-ct.svg +4 -0
  477. package/svg/flags/es.svg +544 -0
  478. package/svg/flags/et.svg +14 -0
  479. package/svg/flags/eu.svg +28 -0
  480. package/svg/flags/fi.svg +5 -0
  481. package/svg/flags/fj.svg +120 -0
  482. package/svg/flags/fk.svg +89 -0
  483. package/svg/flags/fm.svg +11 -0
  484. package/svg/flags/fo.svg +12 -0
  485. package/svg/flags/fr.svg +7 -0
  486. package/svg/flags/ga.svg +7 -0
  487. package/svg/flags/gb-eng.svg +5 -0
  488. package/svg/flags/gb-nir.svg +131 -0
  489. package/svg/flags/gb-sct.svg +4 -0
  490. package/svg/flags/gb-wls.svg +9 -0
  491. package/svg/flags/gb.svg +15 -0
  492. package/svg/flags/gd.svg +27 -0
  493. package/svg/flags/ge.svg +6 -0
  494. package/svg/flags/gf.svg +5 -0
  495. package/svg/flags/gg.svg +9 -0
  496. package/svg/flags/gh.svg +6 -0
  497. package/svg/flags/gi.svg +32 -0
  498. package/svg/flags/gl.svg +4 -0
  499. package/svg/flags/gm.svg +14 -0
  500. package/svg/flags/gn.svg +7 -0
  501. package/svg/flags/gp.svg +7 -0
  502. package/svg/flags/gq.svg +23 -0
  503. package/svg/flags/gr.svg +22 -0
  504. package/svg/flags/gs.svg +201 -0
  505. package/svg/flags/gt.svg +204 -0
  506. package/svg/flags/gu.svg +39 -0
  507. package/svg/flags/gw.svg +13 -0
  508. package/svg/flags/gy.svg +9 -0
  509. package/svg/flags/hk.svg +30 -0
  510. package/svg/flags/hm.svg +9 -0
  511. package/svg/flags/hn.svg +18 -0
  512. package/svg/flags/hr.svg +58 -0
  513. package/svg/flags/ht.svg +116 -0
  514. package/svg/flags/hu.svg +7 -0
  515. package/svg/flags/id.svg +6 -0
  516. package/svg/flags/ie.svg +7 -0
  517. package/svg/flags/il.svg +14 -0
  518. package/svg/flags/im.svg +36 -0
  519. package/svg/flags/in.svg +25 -0
  520. package/svg/flags/io.svg +138 -0
  521. package/svg/flags/iq.svg +10 -0
  522. package/svg/flags/ir.svg +219 -0
  523. package/svg/flags/is.svg +12 -0
  524. package/svg/flags/it.svg +7 -0
  525. package/svg/flags/je.svg +31 -0
  526. package/svg/flags/jm.svg +8 -0
  527. package/svg/flags/jo.svg +16 -0
  528. package/svg/flags/jp.svg +11 -0
  529. package/svg/flags/ke.svg +23 -0
  530. package/svg/flags/kg.svg +15 -0
  531. package/svg/flags/kh.svg +61 -0
  532. package/svg/flags/ki.svg +36 -0
  533. package/svg/flags/km.svg +16 -0
  534. package/svg/flags/kn.svg +14 -0
  535. package/svg/flags/kp.svg +15 -0
  536. package/svg/flags/kr.svg +24 -0
  537. package/svg/flags/kw.svg +13 -0
  538. package/svg/flags/ky.svg +63 -0
  539. package/svg/flags/kz.svg +23 -0
  540. package/svg/flags/la.svg +12 -0
  541. package/svg/flags/lb.svg +15 -0
  542. package/svg/flags/lc.svg +8 -0
  543. package/svg/flags/li.svg +43 -0
  544. package/svg/flags/lk.svg +22 -0
  545. package/svg/flags/lr.svg +14 -0
  546. package/svg/flags/ls.svg +8 -0
  547. package/svg/flags/lt.svg +7 -0
  548. package/svg/flags/lu.svg +5 -0
  549. package/svg/flags/lv.svg +6 -0
  550. package/svg/flags/ly.svg +13 -0
  551. package/svg/flags/ma.svg +4 -0
  552. package/svg/flags/mc.svg +6 -0
  553. package/svg/flags/md.svg +70 -0
  554. package/svg/flags/me.svg +116 -0
  555. package/svg/flags/mf.svg +7 -0
  556. package/svg/flags/mg.svg +7 -0
  557. package/svg/flags/mh.svg +7 -0
  558. package/svg/flags/mk.svg +5 -0
  559. package/svg/flags/ml.svg +7 -0
  560. package/svg/flags/mm.svg +16 -0
  561. package/svg/flags/mn.svg +13 -0
  562. package/svg/flags/mo.svg +9 -0
  563. package/svg/flags/mp.svg +86 -0
  564. package/svg/flags/mq.svg +7 -0
  565. package/svg/flags/mr.svg +6 -0
  566. package/svg/flags/ms.svg +39 -0
  567. package/svg/flags/mt.svg +49 -0
  568. package/svg/flags/mu.svg +8 -0
  569. package/svg/flags/mv.svg +6 -0
  570. package/svg/flags/mw.svg +10 -0
  571. package/svg/flags/mx.svg +382 -0
  572. package/svg/flags/my.svg +15 -0
  573. package/svg/flags/mz.svg +21 -0
  574. package/svg/flags/na.svg +16 -0
  575. package/svg/flags/nc.svg +7 -0
  576. package/svg/flags/ne.svg +6 -0
  577. package/svg/flags/nf.svg +9 -0
  578. package/svg/flags/ng.svg +6 -0
  579. package/svg/flags/ni.svg +129 -0
  580. package/svg/flags/nl.svg +7 -0
  581. package/svg/flags/no.svg +7 -0
  582. package/svg/flags/np.svg +14 -0
  583. package/svg/flags/nr.svg +12 -0
  584. package/svg/flags/nu.svg +26 -0
  585. package/svg/flags/nz.svg +41 -0
  586. package/svg/flags/om.svg +115 -0
  587. package/svg/flags/pa.svg +14 -0
  588. package/svg/flags/pe.svg +244 -0
  589. package/svg/flags/pf.svg +19 -0
  590. package/svg/flags/pg.svg +9 -0
  591. package/svg/flags/ph.svg +13 -0
  592. package/svg/flags/pk.svg +15 -0
  593. package/svg/flags/pl.svg +6 -0
  594. package/svg/flags/pm.svg +7 -0
  595. package/svg/flags/pn.svg +62 -0
  596. package/svg/flags/pr.svg +13 -0
  597. package/svg/flags/ps.svg +15 -0
  598. package/svg/flags/pt.svg +57 -0
  599. package/svg/flags/pw.svg +11 -0
  600. package/svg/flags/py.svg +157 -0
  601. package/svg/flags/qa.svg +4 -0
  602. package/svg/flags/re.svg +7 -0
  603. package/svg/flags/ro.svg +7 -0
  604. package/svg/flags/rs.svg +292 -0
  605. package/svg/flags/ru.svg +7 -0
  606. package/svg/flags/rw.svg +13 -0
  607. package/svg/flags/sa.svg +26 -0
  608. package/svg/flags/sb.svg +13 -0
  609. package/svg/flags/sc.svg +14 -0
  610. package/svg/flags/sd.svg +13 -0
  611. package/svg/flags/se.svg +16 -0
  612. package/svg/flags/sg.svg +13 -0
  613. package/svg/flags/sh.svg +74 -0
  614. package/svg/flags/si.svg +18 -0
  615. package/svg/flags/sj.svg +7 -0
  616. package/svg/flags/sk.svg +9 -0
  617. package/svg/flags/sl.svg +7 -0
  618. package/svg/flags/sm.svg +91 -0
  619. package/svg/flags/sn.svg +8 -0
  620. package/svg/flags/so.svg +11 -0
  621. package/svg/flags/sr.svg +6 -0
  622. package/svg/flags/ss.svg +8 -0
  623. package/svg/flags/st.svg +16 -0
  624. package/svg/flags/sv.svg +606 -0
  625. package/svg/flags/sx.svg +56 -0
  626. package/svg/flags/sy.svg +6 -0
  627. package/svg/flags/sz.svg +45 -0
  628. package/svg/flags/tc.svg +67 -0
  629. package/svg/flags/td.svg +7 -0
  630. package/svg/flags/tf.svg +15 -0
  631. package/svg/flags/tg.svg +14 -0
  632. package/svg/flags/th.svg +7 -0
  633. package/svg/flags/tj.svg +22 -0
  634. package/svg/flags/tk.svg +5 -0
  635. package/svg/flags/tl.svg +13 -0
  636. package/svg/flags/tm.svg +206 -0
  637. package/svg/flags/tn.svg +13 -0
  638. package/svg/flags/to.svg +10 -0
  639. package/svg/flags/tr.svg +8 -0
  640. package/svg/flags/tt.svg +5 -0
  641. package/svg/flags/tv.svg +27 -0
  642. package/svg/flags/tw.svg +14 -0
  643. package/svg/flags/tz.svg +13 -0
  644. package/svg/flags/ua.svg +6 -0
  645. package/svg/flags/ug.svg +30 -0
  646. package/svg/flags/um.svg +15 -0
  647. package/svg/flags/un.svg +16 -0
  648. package/svg/flags/us.svg +10 -0
  649. package/svg/flags/uy.svg +28 -0
  650. package/svg/flags/uz.svg +30 -0
  651. package/svg/flags/va.svg +479 -0
  652. package/svg/flags/vc.svg +8 -0
  653. package/svg/flags/ve.svg +26 -0
  654. package/svg/flags/vg.svg +127 -0
  655. package/svg/flags/vi.svg +28 -0
  656. package/svg/flags/vn.svg +11 -0
  657. package/svg/flags/vu.svg +18 -0
  658. package/svg/flags/wf.svg +7 -0
  659. package/svg/flags/ws.svg +7 -0
  660. package/svg/flags/ye.svg +7 -0
  661. package/svg/flags/yt.svg +7 -0
  662. package/svg/flags/za.svg +17 -0
  663. package/svg/flags/zm.svg +27 -0
  664. package/svg/flags/zw.svg +21 -0
  665. package/svg/instagram.svg +1 -0
  666. package/test-utils/mock-response/product-status.js +44 -0
  667. package/utils/breakpoints.d.ts +23 -0
  668. package/utils/breakpoints.js +90 -0
  669. package/utils/breakpoints.js.map +1 -0
  670. package/utils/callAllEventHandlers.d.ts +5 -0
  671. package/utils/callAllEventHandlers.js +9 -0
  672. package/utils/callAllEventHandlers.js.map +1 -0
  673. package/utils/text.d.ts +1 -0
  674. package/utils/text.js +23 -0
  675. package/utils/text.js.map +1 -0
  676. package/utils/theme.d.ts +3 -0
  677. package/utils/theme.js +5 -0
  678. package/utils/theme.js.map +1 -0
  679. package/utils/useHoverIntent.d.ts +10 -0
  680. package/utils/useHoverIntent.js +76 -0
  681. package/utils/useHoverIntent.js.map +1 -0
  682. package/utils/usePropsOfType.d.ts +11 -0
  683. package/utils/usePropsOfType.js +18 -0
  684. package/utils/usePropsOfType.js.map +1 -0
  685. package/withFlightUI.d.ts +17 -0
  686. package/withFlightUI.js +20 -0
  687. package/withFlightUI.js.map +1 -0
@@ -0,0 +1,416 @@
1
+ import { render, act, cleanup, wait } from '@testing-library/react';
2
+ import React from 'react';
3
+ import RecursiveTree from './RecursiveTree';
4
+ import getMoreSubcategories from './GetMoreSubcategoriesQuery.gql';
5
+ import { MockedProvider } from '@apollo/react-testing';
6
+ import { StaticRouter } from 'react-router';
7
+
8
+ afterEach(cleanup);
9
+
10
+ const MOCK_CATEGORIES = [
11
+ {
12
+ id: 159,
13
+ name: 'News!',
14
+ level: 1,
15
+ parentId: null,
16
+ hasSubcategories: true,
17
+ primaryRoute: {
18
+ path: '/news',
19
+ __typename: 'Route'
20
+ },
21
+ subcategories: [
22
+ {
23
+ id: 160,
24
+ name: 'All products',
25
+ level: 2,
26
+ parentId: 159,
27
+ hasSubcategories: false,
28
+ primaryRoute: {
29
+ path: '/news/all-products',
30
+ __typename: 'Route'
31
+ },
32
+ subcategories: [],
33
+ __typename: 'Category'
34
+ },
35
+ {
36
+ id: 161,
37
+ name: 'Ladies',
38
+ level: 2,
39
+ parentId: 159,
40
+ hasSubcategories: false,
41
+ primaryRoute: {
42
+ path: '/news/ladies',
43
+ __typename: 'Route'
44
+ },
45
+ subcategories: [],
46
+ __typename: 'Category'
47
+ },
48
+ {
49
+ id: 162,
50
+ name: 'Mens',
51
+ level: 2,
52
+ parentId: 159,
53
+ hasSubcategories: false,
54
+ primaryRoute: {
55
+ path: '/news/mens',
56
+ __typename: 'Route'
57
+ },
58
+ subcategories: [],
59
+ __typename: 'Category'
60
+ },
61
+ {
62
+ id: 164,
63
+ name: 'Kids',
64
+ level: 2,
65
+ parentId: 159,
66
+ hasSubcategories: true,
67
+ primaryRoute: {
68
+ path: '/news/kids',
69
+ __typename: 'Route'
70
+ },
71
+ subcategories: [
72
+ {
73
+ id: 302,
74
+ name: 'Tier 3',
75
+ level: 3,
76
+ parentId: 164,
77
+ primaryRoute: null,
78
+ __typename: 'Category'
79
+ }
80
+ ],
81
+ __typename: 'Category'
82
+ }
83
+ ],
84
+ __typename: 'Category'
85
+ },
86
+ {
87
+ id: 1159,
88
+ name: 'News!',
89
+ level: 1,
90
+ parentId: null,
91
+ hasSubcategories: true,
92
+ primaryRoute: {
93
+ path: '/news',
94
+ __typename: 'Route'
95
+ },
96
+ subcategories: [
97
+ {
98
+ id: 1160,
99
+ name: 'All products',
100
+ level: 2,
101
+ parentId: 1159,
102
+ hasSubcategories: false,
103
+ primaryRoute: {
104
+ path: '/news/all-products',
105
+ __typename: 'Route'
106
+ },
107
+ subcategories: [],
108
+ __typename: 'Category'
109
+ },
110
+ {
111
+ id: 1161,
112
+ name: 'Ladies',
113
+ level: 2,
114
+ parentId: 1159,
115
+ hasSubcategories: false,
116
+ primaryRoute: {
117
+ path: '/news/ladies',
118
+ __typename: 'Route'
119
+ },
120
+ subcategories: [],
121
+ __typename: 'Category'
122
+ },
123
+ {
124
+ id: 1162,
125
+ name: 'Mens',
126
+ level: 2,
127
+ parentId: 1159,
128
+ hasSubcategories: false,
129
+ primaryRoute: {
130
+ path: '/news/mens',
131
+ __typename: 'Route'
132
+ },
133
+ subcategories: [],
134
+ __typename: 'Category'
135
+ },
136
+ {
137
+ id: 1164,
138
+ name: 'Kids',
139
+ level: 2,
140
+ parentId: 1159,
141
+ hasSubcategories: true,
142
+ primaryRoute: {
143
+ path: '/news/kids',
144
+ __typename: 'Route'
145
+ },
146
+ subcategories: [
147
+ {
148
+ id: 3102,
149
+ name: 'Tier 3',
150
+ level: 3,
151
+ parentId: 1164,
152
+ primaryRoute: null,
153
+ __typename: 'Category'
154
+ }
155
+ ],
156
+ __typename: 'Category'
157
+ }
158
+ ],
159
+ __typename: 'Category'
160
+ },
161
+ {
162
+ id: 159,
163
+ name: 'News!',
164
+ level: 1,
165
+ parentId: null,
166
+ hasSubcategories: true,
167
+ primaryRoute: {
168
+ path: '/news',
169
+ __typename: 'Route'
170
+ },
171
+ subcategories: [
172
+ {
173
+ id: 160,
174
+ name: 'All products',
175
+ level: 2,
176
+ parentId: 159,
177
+ hasSubcategories: true,
178
+ primaryRoute: {
179
+ path: '/news/all-products',
180
+ __typename: 'Route'
181
+ },
182
+ subcategories: [
183
+ {
184
+ id: 3102,
185
+ name: 'Tier 3',
186
+ level: 3,
187
+ parentId: 1164,
188
+ primaryRoute: {
189
+ path: '/news/all-products/tier-3',
190
+ __typename: 'Route'
191
+ },
192
+ hasSubcategories: true,
193
+ __typename: 'Category'
194
+ }
195
+ ],
196
+ __typename: 'Category'
197
+ }
198
+ ],
199
+ __typename: 'Category'
200
+ }
201
+ ];
202
+
203
+ const tier4 = {
204
+ __typename: 'Category',
205
+ hasSubcategories: false,
206
+ id: 8000,
207
+ name: 'Tier 4',
208
+ level: 4,
209
+ parentId: 3102,
210
+ primaryRoute: null,
211
+ subcategories: []
212
+ };
213
+
214
+ describe('RecursiveNav', () => {
215
+ it('renders child as fn with args', () => {
216
+ const { renderArg } = setup();
217
+ expect(renderArg).toMatchSnapshot();
218
+ });
219
+ });
220
+
221
+ describe('the fetchMore render arg', () => {
222
+ it('fetches more categories and adds them to the subcategories object', async () => {
223
+ const { childrenSpy, renderArg } = setup();
224
+
225
+ let promise;
226
+
227
+ act(() => {
228
+ promise = renderArg.fetchMore();
229
+ });
230
+
231
+ await promise;
232
+ expect(childrenSpy).toHaveBeenLastCalledWith(
233
+ expect.objectContaining({
234
+ subcategories: [expect.objectContaining({ id: 9000 })]
235
+ })
236
+ );
237
+ });
238
+
239
+ it('does not fetch more categories when the current category level is an even number', async () => {
240
+ const { childrenSpy, renderArg } = setup({
241
+ containerProps: {
242
+ category: MOCK_CATEGORIES[0].subcategories[0]
243
+ }
244
+ });
245
+
246
+ let promise;
247
+
248
+ act(() => {
249
+ promise = renderArg.fetchMore();
250
+ });
251
+
252
+ await promise;
253
+ expect(childrenSpy).toHaveBeenLastCalledWith(
254
+ expect.objectContaining({
255
+ subcategories: []
256
+ })
257
+ );
258
+ });
259
+ });
260
+
261
+ describe('the category render arg', () => {
262
+ it('just passes through the base category', () => {
263
+ const { renderArg } = setup({
264
+ containerProps: {
265
+ category: MOCK_CATEGORIES[0]
266
+ }
267
+ });
268
+
269
+ expect(renderArg.category).toBe(MOCK_CATEGORIES[0]);
270
+ });
271
+ });
272
+
273
+ describe('the renderRecursive render arg', () => {
274
+ it('renders for each subcategory of the current category', () => {
275
+ const { queryByText, getByText, renderArg } = setup();
276
+
277
+ expect(getByText(/News!/)).toBeInTheDocument();
278
+ MOCK_CATEGORIES[0].subcategories.forEach(cat =>
279
+ expect(queryByText(cat.name)).not.toBeInTheDocument()
280
+ );
281
+
282
+ renderArg.menuContainerProps.setActiveCategory(MOCK_CATEGORIES[0]);
283
+
284
+ MOCK_CATEGORIES[0].subcategories.forEach(cat =>
285
+ expect(getByText(cat.name)).toBeInTheDocument()
286
+ );
287
+ });
288
+ });
289
+
290
+ describe('the initialOpenMatchingCategories prop', () => {
291
+ it('automatically opens categories matching the current path', () => {
292
+ const renderFn = jest.fn(props => props.renderSubnav);
293
+ setup({
294
+ containerProps: {
295
+ category: MOCK_CATEGORIES[0],
296
+ initialOpenMatchingCategories: true
297
+ },
298
+ path: '/news/all-products',
299
+ renderFn
300
+ });
301
+
302
+ expect(renderFn).toHaveBeenCalledTimes(5);
303
+ expect(renderFn).toHaveBeenCalledWith(
304
+ expect.objectContaining({
305
+ menuContainerProps: expect.objectContaining({
306
+ activeCategories: expect.arrayContaining([MOCK_CATEGORIES[0]])
307
+ })
308
+ })
309
+ );
310
+ expect(renderFn).toHaveBeenCalledWith(
311
+ expect.objectContaining({
312
+ menuContainerProps: expect.objectContaining({
313
+ activeCategories: expect.arrayContaining([
314
+ MOCK_CATEGORIES[0].subcategories[0]
315
+ ])
316
+ })
317
+ })
318
+ );
319
+ });
320
+
321
+ it('fetches subcategories from the api if they are not already fetched', async () => {
322
+ const renderFn = jest.fn(props => props.renderSubnav);
323
+ setup({
324
+ containerProps: {
325
+ category: MOCK_CATEGORIES[2],
326
+ initialOpenMatchingCategories: true
327
+ },
328
+ path: '/news/all-products',
329
+ renderFn
330
+ });
331
+
332
+ await wait();
333
+
334
+ expect(renderFn).toHaveBeenCalledTimes(5);
335
+ expect(renderFn).toHaveBeenCalledWith(
336
+ expect.objectContaining({
337
+ subcategories: expect.arrayContaining([tier4])
338
+ })
339
+ );
340
+ });
341
+ });
342
+
343
+ function setup({
344
+ containerProps = { category: MOCK_CATEGORIES[0] },
345
+ renderFn,
346
+ path
347
+ } = {}) {
348
+ let renderArg;
349
+
350
+ const childrenSpy = jest.fn(controllerArg => {
351
+ renderArg = controllerArg;
352
+
353
+ if (renderFn) return renderFn(controllerArg);
354
+ return (
355
+ <div>
356
+ <span>{controllerArg.category.name}</span>
357
+ <nav>{controllerArg.renderSubnav}</nav>
358
+ </div>
359
+ );
360
+ });
361
+
362
+ const utils = render(
363
+ <StaticRouter location={path} context={{}}>
364
+ <MockedProvider
365
+ mocks={[
366
+ {
367
+ request: {
368
+ query: getMoreSubcategories,
369
+ variables: { id: MOCK_CATEGORIES[0].id }
370
+ },
371
+ result: {
372
+ data: {
373
+ category: {
374
+ __typename: 'Category',
375
+ hasSubcategories: true,
376
+ subcategories: [
377
+ {
378
+ id: 9000,
379
+ name: 'Mock category',
380
+ level: 2,
381
+ parentId: null,
382
+ primaryRoute: null,
383
+ hasSubcategories: false,
384
+ subcategories: [],
385
+ __typename: 'Category'
386
+ }
387
+ ]
388
+ }
389
+ }
390
+ }
391
+ },
392
+ {
393
+ request: {
394
+ query: getMoreSubcategories,
395
+ variables: {
396
+ id: MOCK_CATEGORIES[2].subcategories[0].subcategories[0].id
397
+ }
398
+ },
399
+ result: {
400
+ data: {
401
+ category: {
402
+ ...MOCK_CATEGORIES[2].subcategories[0].subcategories[0],
403
+ subcategories: [tier4]
404
+ }
405
+ }
406
+ }
407
+ }
408
+ ]}
409
+ >
410
+ <RecursiveTree {...containerProps}>{childrenSpy}</RecursiveTree>
411
+ </MockedProvider>
412
+ </StaticRouter>
413
+ );
414
+
415
+ return { ...utils, childrenSpy, renderArg };
416
+ }
@@ -0,0 +1,11 @@
1
+ import { SFC } from 'react';
2
+ export interface DrawerProps {
3
+ /** Whether to attach the drawer to the right of the screen. Defauts to false. */
4
+ right: boolean;
5
+ /** The size of the drawer in pixels. Defaults to 320. */
6
+ size: number;
7
+ /** Whether the drawer is open or not. Defaults to false. */
8
+ isOpen: boolean;
9
+ }
10
+ declare const Drawer: SFC<DrawerProps>;
11
+ export default Drawer;
@@ -0,0 +1,31 @@
1
+ import { css, cx } from 'linaria';
2
+ import React from 'react';
3
+ const containerStyles = css `
4
+ background: white;
5
+ height: 100%;
6
+ position: fixed;
7
+ display: flex;
8
+ flex-direction: column;
9
+ top: 0;
10
+ height: 100%;
11
+ z-index: 99999;
12
+ max-width: 100%;
13
+ -webkit-overflow-scrolling: touch;
14
+ overflow-y: auto;
15
+
16
+ transition: transform 0.3s ease-in-out;
17
+ `;
18
+ const Drawer = ({ right = false, size = 320, isOpen = false, children }) => {
19
+ const initialPosition = right // this is for server side rendering since popmotion doesn't support it
20
+ ? {
21
+ transform: `translateX(${isOpen ? 0 : size}px)`,
22
+ right: 0
23
+ }
24
+ : {
25
+ transform: `translateX(-${isOpen ? 0 : size}px)`,
26
+ left: 0
27
+ };
28
+ return (React.createElement("div", { className: cx(containerStyles, isOpen ? 'open' : 'closed', right ? 'right' : 'left'), style: Object.assign({ width: `${size}px` }, initialPosition) }, children));
29
+ };
30
+ export default Drawer;
31
+ //# sourceMappingURL=Drawer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Drawer.js","sourceRoot":"","sources":["Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,KAAc,MAAM,OAAO,CAAC;AAEnC,MAAM,eAAe,GAAG,GAAG,CAAA;;;;;;;;;;;;;;CAc1B,CAAC;AAWF,MAAM,MAAM,GAAqB,CAAC,EAChC,KAAK,GAAG,KAAK,EACb,IAAI,GAAG,GAAG,EACV,MAAM,GAAG,KAAK,EACd,QAAQ,EACT,EAAE,EAAE;IACH,MAAM,eAAe,GAAG,KAAK,CAAC,uEAAuE;QACnG,CAAC,CAAC;YACE,SAAS,EAAE,cAAc,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK;YAC/C,KAAK,EAAE,CAAC;SACT;QACH,CAAC,CAAC;YACE,SAAS,EAAE,eAAe,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK;YAChD,IAAI,EAAE,CAAC;SACR,CAAC;IACN,OAAO,CACL,6BACE,SAAS,EAAE,EAAE,CACX,eAAe,EACf,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAC1B,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CACzB,EACD,KAAK,kBAAI,KAAK,EAAE,GAAG,IAAI,IAAI,IAAK,eAAe,KAE9C,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ import { ModalState } from '../ModalContext';
3
+ export declare const DrawerTarget: React.SFC<{
4
+ id: string;
5
+ children(args: ModalState): any;
6
+ }>;
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import ModalContext from '../ModalContext';
3
+ import TargetWrapper from '../TargetWrapper';
4
+ export const DrawerTarget = ({ id, children }) => {
5
+ return (React.createElement(ModalContext.Consumer, null, ({ modalId, isOpen, hideTarget, modalType }) => {
6
+ // For drawers, the child should always render.
7
+ // Drawers implement their own hide/show behaviour that relies
8
+ // on `isOpen` being toggled to trigger the animation
9
+ return (React.createElement(TargetWrapper, { modalType: modalType, hideTarget: hideTarget, isOpen: isOpen && modalId === id, preventOverflow: false }, children));
10
+ }));
11
+ };
12
+ //# sourceMappingURL=DrawerTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DrawerTarget.js","sourceRoot":"","sources":["DrawerTarget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,YAA4B,MAAM,iBAAiB,CAAC;AAC3D,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAGpB,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;IACxB,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,QACnB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE;QAC9C,+CAA+C;QAC/C,8DAA8D;QAC9D,qDAAqD;QACrD,OAAO,CACL,oBAAC,aAAa,IACZ,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,IAAI,OAAO,KAAK,EAAE,EAChC,eAAe,EAAE,KAAK,IAErB,QAAQ,CACK,CACjB,CAAC;IACJ,CAAC,CACqB,CACzB,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,112 @@
1
+ import React from 'react';
2
+ import getComponentWithModalContext, {
3
+ defaultContext
4
+ } from '../__test_utils__/getComponentWithModalContext';
5
+
6
+ beforeEach(() => {
7
+ jest.resetModules();
8
+ });
9
+
10
+ const target = getComponentWithModalContext(
11
+ 'Drawer/DrawerTarget',
12
+ 'DrawerTarget'
13
+ );
14
+
15
+ xdescribe('DrawerTarget', () => {
16
+ describe('renders a child component', () => {
17
+ let wrapper;
18
+ let reachableChild = jest.fn().mockReturnValue('I will always render');
19
+
20
+ afterEach(() => {
21
+ expect(wrapper.text()).toBe('I will always render');
22
+ });
23
+
24
+ it('no matter what the context state is', () => {
25
+ const DrawerTarget = target({
26
+ ...defaultContext,
27
+ modalType: 'drawer',
28
+ isOpen: false
29
+ });
30
+ wrapper = mount(<DrawerTarget>{reachableChild}</DrawerTarget>);
31
+ });
32
+
33
+ it('with `isOpen` prop passed', () => {
34
+ expect(
35
+ wrapper
36
+ .children()
37
+ .children()
38
+ .props().isOpen
39
+ ).toBeDefined();
40
+ });
41
+
42
+ it('with `modalType` prop passed', () => {
43
+ expect(
44
+ wrapper
45
+ .children()
46
+ .children()
47
+ .props().modalType
48
+ ).toBe('drawer');
49
+ });
50
+
51
+ it('with `hideTarget` func passed', () => {
52
+ expect(
53
+ wrapper
54
+ .children()
55
+ .children()
56
+ .props().hideTarget
57
+ ).toBe(defaultContext.hideTarget);
58
+ });
59
+
60
+ describe('with `isOpen` prop set to `true`', () => {
61
+ it('when `isOpen` is true and `modalId` matches `id`', () => {
62
+ const DrawerTarget = target({
63
+ ...defaultContext,
64
+ modalType: 'drawer',
65
+ isOpen: true,
66
+ modalId: 'foo'
67
+ });
68
+ wrapper = mount(<DrawerTarget id="foo">{reachableChild}</DrawerTarget>);
69
+ expect(
70
+ wrapper
71
+ .children()
72
+ .children()
73
+ .props().isOpen
74
+ ).toBe(true);
75
+ });
76
+ });
77
+
78
+ describe('with `isOpen` prop set to `false`', () => {
79
+ it('when `isOpen` is false', () => {
80
+ const DrawerTarget = target({
81
+ ...defaultContext,
82
+ modalType: 'drawer',
83
+ isOpen: false,
84
+ modalId: 'foo'
85
+ });
86
+ wrapper = mount(<DrawerTarget id="foo">{reachableChild}</DrawerTarget>);
87
+ expect(
88
+ wrapper
89
+ .children()
90
+ .children()
91
+ .props().isOpen
92
+ ).toBe(false);
93
+ });
94
+
95
+ it('when received `modalId` does not match `id` prop', () => {
96
+ const DrawerTarget = target({
97
+ ...defaultContext,
98
+ modalType: 'drawer',
99
+ isOpen: true,
100
+ modalId: 'bar'
101
+ });
102
+ wrapper = mount(<DrawerTarget id="foo">{reachableChild}</DrawerTarget>);
103
+ expect(
104
+ wrapper
105
+ .children()
106
+ .children()
107
+ .props().isOpen
108
+ ).toBe(false);
109
+ });
110
+ });
111
+ });
112
+ });
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { ModalState } from '../ModalContext';
3
+ export declare const DrawerTrigger: React.SFC<{
4
+ id: string;
5
+ /** Whether to show a clickable semi-opaque Cover behind the flyout */
6
+ showCover: boolean;
7
+ coverStyles?: {};
8
+ children: (args: Partial<ModalState>) => React.ReactNode;
9
+ }>;
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import ModalContext from '../ModalContext';
3
+ export const DrawerTrigger = ({ id, children, showCover = true, coverStyles }) => {
4
+ return (React.createElement(ModalContext.Consumer, null, ({ showTarget, modalId, hideTarget }) => {
5
+ return children({
6
+ showTarget: () => showTarget(null, 'drawer', id, { showCover, coverStyles }),
7
+ hideTarget,
8
+ isOpen: modalId === id
9
+ });
10
+ }));
11
+ };
12
+ //# sourceMappingURL=DrawerTrigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DrawerTrigger.js","sourceRoot":"","sources":["DrawerTrigger.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,YAA4B,MAAM,iBAAiB,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAMrB,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,GAAG,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE;IACvD,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,QACnB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE;QACvC,OAAO,QAAQ,CAAC;YACd,UAAU,EAAE,GAAG,EAAE,CACf,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;YAC5D,UAAU;YACV,MAAM,EAAE,OAAO,KAAK,EAAE;SACvB,CAAC,CAAC;IACL,CAAC,CACqB,CACzB,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import getComponentWithModalContext, {
3
+ defaultContext
4
+ } from '../__test_utils__/getComponentWithModalContext';
5
+
6
+ beforeEach(() => {
7
+ jest.resetModules();
8
+ });
9
+
10
+ const trigger = getComponentWithModalContext(
11
+ 'Drawer/DrawerTrigger',
12
+ 'DrawerTrigger'
13
+ );
14
+
15
+ xdescribe('DrawerTrigger', () => {
16
+ let funcAsChild = jest.fn().mockReturnValue(<div>Rendered child</div>);
17
+
18
+ it('renders a Consumer', () => {
19
+ const DrawerTrigger = trigger();
20
+ const wrapper = mount(<DrawerTrigger>{funcAsChild}</DrawerTrigger>);
21
+ expect(wrapper.find('Consumer')).toHaveLength(1);
22
+ });
23
+ describe('takes a func as child prop', () => {
24
+ it('calls it with `showTarget`, `hideTarget`, and `open`', () => {
25
+ const DrawerTrigger = trigger();
26
+
27
+ mount(<DrawerTrigger id="foo">{funcAsChild}</DrawerTrigger>);
28
+ expect(funcAsChild).toHaveBeenCalledWith(
29
+ expect.objectContaining({
30
+ showTarget: expect.any(Function),
31
+ hideTarget: defaultContext.hideTarget,
32
+ isOpen: defaultContext.isOpen
33
+ })
34
+ );
35
+ });
36
+ it('calls `showTarget` with `id` passed via prop', () => {
37
+ const DrawerTrigger = trigger();
38
+ const wrapper = mount(
39
+ <DrawerTrigger id="foo">
40
+ {({ showTarget }) => <div onClick={showTarget}>hello</div>}
41
+ </DrawerTrigger>
42
+ );
43
+ wrapper.find('div').simulate('click');
44
+ expect(defaultContext.showTarget).toHaveBeenCalledWith(
45
+ null,
46
+ 'drawer',
47
+ 'foo'
48
+ );
49
+ });
50
+ });
51
+ });
@@ -0,0 +1,3 @@
1
+ export { DrawerTrigger } from './DrawerTrigger';
2
+ export { DrawerTarget } from './DrawerTarget';
3
+ export { default } from './Drawer';
@@ -0,0 +1,4 @@
1
+ export { DrawerTrigger } from './DrawerTrigger';
2
+ export { DrawerTarget } from './DrawerTarget';
3
+ export { default } from './Drawer';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}