@rebuy/rebuy-hydrogen 3.0.0-beta.2 → 3.0.0-beta.20

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 (307) hide show
  1. package/README.md +988 -16
  2. package/dist/assets/Close.d.ts +2 -0
  3. package/dist/assets/Close.d.ts.map +1 -0
  4. package/dist/components/AddToCartBtn/AddToCartBtn.d.ts +1 -1
  5. package/dist/components/AddToCartBtn/AddToCartBtn.d.ts.map +1 -1
  6. package/dist/components/AddToCartBtn/HydrogenAddToCartBtn.d.ts +1 -1
  7. package/dist/components/AddToCartBtn/HydrogenAddToCartBtn.d.ts.map +1 -1
  8. package/dist/components/AddToCartBtn/HydrogenReactAddToCartBtn.d.ts +1 -1
  9. package/dist/components/AddToCartBtn/HydrogenReactAddToCartBtn.d.ts.map +1 -1
  10. package/dist/components/AddToCartBtn/types.d.ts +5 -0
  11. package/dist/components/AddToCartBtn/types.d.ts.map +1 -1
  12. package/dist/components/ProductCard/ProductCard.d.ts +1 -1
  13. package/dist/components/ProductCard/ProductCard.d.ts.map +1 -1
  14. package/dist/components/ProductCard/defaultSettings.d.ts +3 -0
  15. package/dist/components/ProductCard/defaultSettings.d.ts.map +1 -0
  16. package/dist/components/ProductCard/index.d.ts +1 -0
  17. package/dist/components/ProductCard/index.d.ts.map +1 -1
  18. package/dist/components/ProductCard/types.d.ts +46 -0
  19. package/dist/components/ProductCard/types.d.ts.map +1 -1
  20. package/dist/components/ProductCarousel/ProductCarousel.d.ts +3 -0
  21. package/dist/components/ProductCarousel/ProductCarousel.d.ts.map +1 -0
  22. package/dist/components/ProductCarousel/index.d.ts +2 -0
  23. package/dist/components/ProductCarousel/index.d.ts.map +1 -0
  24. package/dist/components/ProductCarousel/types.d.ts +18 -0
  25. package/dist/components/ProductCarousel/types.d.ts.map +1 -0
  26. package/dist/components/ProductPrice/ProductPrice.d.ts +2 -4
  27. package/dist/components/ProductPrice/ProductPrice.d.ts.map +1 -1
  28. package/dist/components/ProductPrice/types.d.ts +23 -0
  29. package/dist/components/ProductPrice/types.d.ts.map +1 -0
  30. package/dist/components/QuantityInput/QuantityInput.d.ts +3 -0
  31. package/dist/components/QuantityInput/QuantityInput.d.ts.map +1 -0
  32. package/dist/components/QuantityInput/index.d.ts +3 -0
  33. package/dist/components/QuantityInput/index.d.ts.map +1 -0
  34. package/dist/components/QuantityInput/types.d.ts +7 -0
  35. package/dist/components/QuantityInput/types.d.ts.map +1 -0
  36. package/dist/components/RebuyLink/RebuyLink.d.ts +3 -0
  37. package/dist/components/RebuyLink/RebuyLink.d.ts.map +1 -0
  38. package/dist/components/RebuyLink/index.d.ts +2 -0
  39. package/dist/components/RebuyLink/index.d.ts.map +1 -0
  40. package/dist/components/RebuyLink/types.d.ts +10 -0
  41. package/dist/components/RebuyLink/types.d.ts.map +1 -0
  42. package/dist/components/Timer/Timer.d.ts +3 -0
  43. package/dist/components/Timer/Timer.d.ts.map +1 -0
  44. package/dist/components/Timer/index.d.ts +3 -0
  45. package/dist/components/Timer/index.d.ts.map +1 -0
  46. package/dist/components/Timer/types.d.ts +20 -0
  47. package/dist/components/Timer/types.d.ts.map +1 -0
  48. package/dist/components/Title/Title.d.ts +1 -1
  49. package/dist/components/Title/Title.d.ts.map +1 -1
  50. package/dist/components/Title/types.d.ts +1 -0
  51. package/dist/components/Title/types.d.ts.map +1 -1
  52. package/dist/components/VariantSelect/VariantSelect.d.ts +1 -1
  53. package/dist/components/VariantSelect/VariantSelect.d.ts.map +1 -1
  54. package/dist/components/VariantSelect/types.d.ts +2 -0
  55. package/dist/components/VariantSelect/types.d.ts.map +1 -1
  56. package/dist/constants/api.d.ts +2 -0
  57. package/dist/constants/api.d.ts.map +1 -0
  58. package/dist/constants/debug.d.ts +28 -0
  59. package/dist/constants/debug.d.ts.map +1 -0
  60. package/dist/context/RebuyConfigContext.d.ts +23 -0
  61. package/dist/context/RebuyConfigContext.d.ts.map +1 -0
  62. package/dist/context/RebuyWidgetContext.d.ts +7 -0
  63. package/dist/context/RebuyWidgetContext.d.ts.map +1 -0
  64. package/dist/hooks/titleLevel.d.ts.map +1 -1
  65. package/dist/hooks/useBFCacheReset.d.ts +7 -0
  66. package/dist/hooks/useBFCacheReset.d.ts.map +1 -0
  67. package/dist/hooks/useBreakpoint.d.ts +5 -0
  68. package/dist/hooks/useBreakpoint.d.ts.map +1 -0
  69. package/dist/hooks/usePopupTrigger.d.ts +3 -0
  70. package/dist/hooks/usePopupTrigger.d.ts.map +1 -0
  71. package/dist/index.css +2680 -99
  72. package/dist/index.css.map +4 -4
  73. package/dist/index.d.ts +9 -0
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +9756 -1461
  76. package/dist/index.js.map +4 -4
  77. package/dist/index.mjs +9768 -1482
  78. package/dist/index.mjs.map +4 -4
  79. package/dist/providers/RebuyHydrogenContextProvider.d.ts +1 -1
  80. package/dist/providers/RebuyHydrogenContextProvider.d.ts.map +1 -1
  81. package/dist/providers/RebuyHydrogenReactContextProvider.d.ts +6 -1
  82. package/dist/providers/RebuyHydrogenReactContextProvider.d.ts.map +1 -1
  83. package/dist/providers/types.d.ts +29 -14
  84. package/dist/providers/types.d.ts.map +1 -1
  85. package/dist/queries/cart.queries.d.ts +4 -4
  86. package/dist/queries/cart.queries.d.ts.map +1 -1
  87. package/dist/smart-cart/RebuySmartCart.d.ts +10 -0
  88. package/dist/smart-cart/RebuySmartCart.d.ts.map +1 -0
  89. package/dist/smart-cart/components/AnnouncementBar/AnnouncementBar.d.ts +10 -0
  90. package/dist/smart-cart/components/AnnouncementBar/AnnouncementBar.d.ts.map +1 -0
  91. package/dist/smart-cart/components/CartItem/CartItem.d.ts +7 -0
  92. package/dist/smart-cart/components/CartItem/CartItem.d.ts.map +1 -0
  93. package/dist/smart-cart/components/CartItemList/CartItemList.d.ts +10 -0
  94. package/dist/smart-cart/components/CartItemList/CartItemList.d.ts.map +1 -0
  95. package/dist/smart-cart/components/CartNoteInput/CartNoteInput.d.ts +10 -0
  96. package/dist/smart-cart/components/CartNoteInput/CartNoteInput.d.ts.map +1 -0
  97. package/dist/smart-cart/components/CartSubtotal/CartSubtotal.d.ts +11 -0
  98. package/dist/smart-cart/components/CartSubtotal/CartSubtotal.d.ts.map +1 -0
  99. package/dist/smart-cart/components/CartTitleBar/CartTitleBar.d.ts +7 -0
  100. package/dist/smart-cart/components/CartTitleBar/CartTitleBar.d.ts.map +1 -0
  101. package/dist/smart-cart/components/CheckoutArea/CheckoutArea.d.ts +10 -0
  102. package/dist/smart-cart/components/CheckoutArea/CheckoutArea.d.ts.map +1 -0
  103. package/dist/smart-cart/components/CrossSell/CrossSell.d.ts +10 -0
  104. package/dist/smart-cart/components/CrossSell/CrossSell.d.ts.map +1 -0
  105. package/dist/smart-cart/components/CustomCode/CustomCodeBlock.d.ts +21 -0
  106. package/dist/smart-cart/components/CustomCode/CustomCodeBlock.d.ts.map +1 -0
  107. package/dist/smart-cart/components/DebugPanel/DebugPanel.d.ts +13 -0
  108. package/dist/smart-cart/components/DebugPanel/DebugPanel.d.ts.map +1 -0
  109. package/dist/smart-cart/components/DebugPanel/index.d.ts +11 -0
  110. package/dist/smart-cart/components/DebugPanel/index.d.ts.map +1 -0
  111. package/dist/smart-cart/components/DiscountCodeInput/DiscountCodeInput.d.ts +10 -0
  112. package/dist/smart-cart/components/DiscountCodeInput/DiscountCodeInput.d.ts.map +1 -0
  113. package/dist/smart-cart/components/EmptyCart/EmptyCart.d.ts +3 -0
  114. package/dist/smart-cart/components/EmptyCart/EmptyCart.d.ts.map +1 -0
  115. package/dist/smart-cart/components/LoginButton/LoginButton.d.ts +3 -0
  116. package/dist/smart-cart/components/LoginButton/LoginButton.d.ts.map +1 -0
  117. package/dist/smart-cart/components/ScreenReaderText/ScreenReaderText.d.ts +8 -0
  118. package/dist/smart-cart/components/ScreenReaderText/ScreenReaderText.d.ts.map +1 -0
  119. package/dist/smart-cart/components/SmartCartApp/SmartCartApp.d.ts +20 -0
  120. package/dist/smart-cart/components/SmartCartApp/SmartCartApp.d.ts.map +1 -0
  121. package/dist/smart-cart/components/SmartCartContainer/SmartCartContainer.d.ts +8 -0
  122. package/dist/smart-cart/components/SmartCartContainer/SmartCartContainer.d.ts.map +1 -0
  123. package/dist/smart-cart/components/TieredProgressBar/Icons.d.ts +5 -0
  124. package/dist/smart-cart/components/TieredProgressBar/Icons.d.ts.map +1 -0
  125. package/dist/smart-cart/components/TieredProgressBar/TPBGiftItem.d.ts +21 -0
  126. package/dist/smart-cart/components/TieredProgressBar/TPBGiftItem.d.ts.map +1 -0
  127. package/dist/smart-cart/components/TieredProgressBar/TieredProgressBar.d.ts +11 -0
  128. package/dist/smart-cart/components/TieredProgressBar/TieredProgressBar.d.ts.map +1 -0
  129. package/dist/smart-cart/components/TieredProgressBar/progressBarUtils.d.ts +173 -0
  130. package/dist/smart-cart/components/TieredProgressBar/progressBarUtils.d.ts.map +1 -0
  131. package/dist/smart-cart/components/TieredProgressBar/types.d.ts +261 -0
  132. package/dist/smart-cart/components/TieredProgressBar/types.d.ts.map +1 -0
  133. package/dist/smart-cart/components/_Layouts/AnchorSlot.d.ts +13 -0
  134. package/dist/smart-cart/components/_Layouts/AnchorSlot.d.ts.map +1 -0
  135. package/dist/smart-cart/components/_Layouts/DoubleColumnLayout.d.ts +9 -0
  136. package/dist/smart-cart/components/_Layouts/DoubleColumnLayout.d.ts.map +1 -0
  137. package/dist/smart-cart/components/_Layouts/SingleColumnLayout.d.ts +8 -0
  138. package/dist/smart-cart/components/_Layouts/SingleColumnLayout.d.ts.map +1 -0
  139. package/dist/smart-cart/components/componentRegistry.d.ts +3 -0
  140. package/dist/smart-cart/components/componentRegistry.d.ts.map +1 -0
  141. package/dist/smart-cart/constants.d.ts +58 -0
  142. package/dist/smart-cart/constants.d.ts.map +1 -0
  143. package/dist/smart-cart/context/SmartCartContext.d.ts +62 -0
  144. package/dist/smart-cart/context/SmartCartContext.d.ts.map +1 -0
  145. package/dist/smart-cart/context/StorefrontCartContext.d.ts +32 -0
  146. package/dist/smart-cart/context/StorefrontCartContext.d.ts.map +1 -0
  147. package/dist/smart-cart/hooks/useCartItemFeatures.d.ts +84 -0
  148. package/dist/smart-cart/hooks/useCartItemFeatures.d.ts.map +1 -0
  149. package/dist/smart-cart/hooks/useDiscountManager.d.ts +28 -0
  150. package/dist/smart-cart/hooks/useDiscountManager.d.ts.map +1 -0
  151. package/dist/smart-cart/hooks/useGeolocation.d.ts +12 -0
  152. package/dist/smart-cart/hooks/useGeolocation.d.ts.map +1 -0
  153. package/dist/smart-cart/hooks/useIsScrolled.d.ts +14 -0
  154. package/dist/smart-cart/hooks/useIsScrolled.d.ts.map +1 -0
  155. package/dist/smart-cart/hooks/useSmartCartApps.d.ts +17 -0
  156. package/dist/smart-cart/hooks/useSmartCartApps.d.ts.map +1 -0
  157. package/dist/smart-cart/store/tieredProgressBarStore.d.ts +76 -0
  158. package/dist/smart-cart/store/tieredProgressBarStore.d.ts.map +1 -0
  159. package/dist/smart-cart/types/rebuy-storefront-cart.d.ts +142 -0
  160. package/dist/smart-cart/types/rebuy-storefront-cart.d.ts.map +1 -0
  161. package/dist/smart-cart/types/rebuy.d.ts +15 -0
  162. package/dist/smart-cart/types/rebuy.d.ts.map +1 -0
  163. package/dist/smart-cart/types/shop.d.ts +26 -0
  164. package/dist/smart-cart/types/shop.d.ts.map +1 -0
  165. package/dist/smart-cart/types/smart-cart-app.d.ts +103 -0
  166. package/dist/smart-cart/types/smart-cart-app.d.ts.map +1 -0
  167. package/dist/smart-cart/types/smart-cart-component.d.ts +1350 -0
  168. package/dist/smart-cart/types/smart-cart-component.d.ts.map +1 -0
  169. package/dist/smart-cart/types/smart-cart.d.ts +82 -0
  170. package/dist/smart-cart/types/smart-cart.d.ts.map +1 -0
  171. package/dist/smart-cart/utils/cartItemUtils.d.ts +292 -0
  172. package/dist/smart-cart/utils/cartItemUtils.d.ts.map +1 -0
  173. package/dist/smart-cart/utils/debugLog.d.ts +77 -0
  174. package/dist/smart-cart/utils/debugLog.d.ts.map +1 -0
  175. package/dist/smart-cart/utils/debugStyles.d.ts +3342 -0
  176. package/dist/smart-cart/utils/debugStyles.d.ts.map +1 -0
  177. package/dist/smart-cart/utils/executeScriptsInContainer.d.ts +14 -0
  178. package/dist/smart-cart/utils/executeScriptsInContainer.d.ts.map +1 -0
  179. package/dist/smart-cart/utils/imageUtils.d.ts +2 -0
  180. package/dist/smart-cart/utils/imageUtils.d.ts.map +1 -0
  181. package/dist/smart-cart/utils/mapHydrogenCartToStorefrontCartData.d.ts +14 -0
  182. package/dist/smart-cart/utils/mapHydrogenCartToStorefrontCartData.d.ts.map +1 -0
  183. package/dist/smart-cart/utils/moneyUtils.d.ts +24 -0
  184. package/dist/smart-cart/utils/moneyUtils.d.ts.map +1 -0
  185. package/dist/smart-cart/utils/safeJsonParse.d.ts +2 -0
  186. package/dist/smart-cart/utils/safeJsonParse.d.ts.map +1 -0
  187. package/dist/types/common.d.ts +16 -0
  188. package/dist/types/common.d.ts.map +1 -1
  189. package/dist/types/rebuyCustom.d.ts +133 -17
  190. package/dist/types/rebuyCustom.d.ts.map +1 -1
  191. package/dist/types/shopify.d.ts +1 -2
  192. package/dist/types/shopify.d.ts.map +1 -1
  193. package/dist/types/widgets.d.ts +20078 -7
  194. package/dist/types/widgets.d.ts.map +1 -1
  195. package/dist/utils/convertToRebuyProduct.d.ts.map +1 -1
  196. package/dist/utils/createContextParameters.d.ts +1 -1
  197. package/dist/utils/createContextParameters.d.ts.map +1 -1
  198. package/dist/utils/filterContextUtils.d.ts +3 -0
  199. package/dist/utils/filterContextUtils.d.ts.map +1 -0
  200. package/dist/utils/getEncodedAttributes.d.ts.map +1 -1
  201. package/dist/utils/getRebuyConfig.d.ts +1 -1
  202. package/dist/utils/getRebuyConfig.d.ts.map +1 -1
  203. package/dist/utils/nonceManager.d.ts +10 -0
  204. package/dist/utils/nonceManager.d.ts.map +1 -0
  205. package/dist/utils/theme.d.ts +20 -0
  206. package/dist/utils/theme.d.ts.map +1 -0
  207. package/dist/widgetContainer/RebuyWidgetContainer.d.ts +1 -1
  208. package/dist/widgetContainer/RebuyWidgetContainer.d.ts.map +1 -1
  209. package/dist/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.d.ts.map +1 -1
  210. package/dist/widgets/RebuyDynamicBundleProducts/BundleImages.d.ts.map +1 -1
  211. package/dist/widgets/RebuyDynamicBundleProducts/BundlePrice.d.ts.map +1 -1
  212. package/dist/widgets/RebuyDynamicBundleProducts/BundleSelection.d.ts +1 -1
  213. package/dist/widgets/RebuyDynamicBundleProducts/BundleSelection.d.ts.map +1 -1
  214. package/dist/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.d.ts.map +1 -1
  215. package/dist/widgets/RebuyDynamicBundleProducts/Select.d.ts.map +1 -1
  216. package/dist/widgets/RebuyGiftWithPurchase/RebuyGiftWithPurchase.d.ts +11 -0
  217. package/dist/widgets/RebuyGiftWithPurchase/RebuyGiftWithPurchase.d.ts.map +1 -0
  218. package/dist/widgets/RebuyGiftWithPurchase/index.d.ts +3 -0
  219. package/dist/widgets/RebuyGiftWithPurchase/index.d.ts.map +1 -0
  220. package/dist/widgets/RebuyGiftWithPurchase/store/giftWithPurchaseStore.d.ts +31 -0
  221. package/dist/widgets/RebuyGiftWithPurchase/store/giftWithPurchaseStore.d.ts.map +1 -0
  222. package/dist/widgets/RebuyGiftWithPurchase/types.d.ts +12 -0
  223. package/dist/widgets/RebuyGiftWithPurchase/types.d.ts.map +1 -0
  224. package/dist/widgets/RebuyGiftWithPurchase/utils.d.ts +35 -0
  225. package/dist/widgets/RebuyGiftWithPurchase/utils.d.ts.map +1 -0
  226. package/dist/widgets/RebuyProductAddOns/RebuyProductAddOnCard.d.ts.map +1 -1
  227. package/dist/widgets/RebuyProductAddOns/RebuyProductAddOns.d.ts.map +1 -1
  228. package/dist/widgets/RebuyProductAddOns/types.d.ts.map +1 -1
  229. package/dist/widgets/RebuyProductRecommendations/RebuyProductRecommendations.d.ts.map +1 -1
  230. package/dist/widgets/RebuyProductViewed/RebuyProductViewed.d.ts +3 -0
  231. package/dist/widgets/RebuyProductViewed/RebuyProductViewed.d.ts.map +1 -0
  232. package/dist/widgets/RebuyProductViewed/index.d.ts +2 -0
  233. package/dist/widgets/RebuyProductViewed/index.d.ts.map +1 -0
  234. package/dist/widgets/RebuyProductViewed/types.d.ts +8 -0
  235. package/dist/widgets/RebuyProductViewed/types.d.ts.map +1 -0
  236. package/dist/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.d.ts +3 -0
  237. package/dist/widgets/RebuyRecentlyViewedProducts/RebuyRecentlyViewedProducts.d.ts.map +1 -0
  238. package/dist/widgets/RebuyRecentlyViewedProducts/index.d.ts +2 -0
  239. package/dist/widgets/RebuyRecentlyViewedProducts/index.d.ts.map +1 -0
  240. package/dist/widgets/RebuyRecentlyViewedProducts/types.d.ts +11 -0
  241. package/dist/widgets/RebuyRecentlyViewedProducts/types.d.ts.map +1 -0
  242. package/dist/widgets/RebuyWidget/RebuyWidget.d.ts +3 -0
  243. package/dist/widgets/RebuyWidget/RebuyWidget.d.ts.map +1 -0
  244. package/dist/widgets/RebuyWidget/WidgetContent.d.ts +3 -0
  245. package/dist/widgets/RebuyWidget/WidgetContent.d.ts.map +1 -0
  246. package/dist/widgets/RebuyWidget/index.d.ts +2 -0
  247. package/dist/widgets/RebuyWidget/index.d.ts.map +1 -0
  248. package/dist/widgets/RebuyWidget/types.d.ts +28 -0
  249. package/dist/widgets/RebuyWidget/types.d.ts.map +1 -0
  250. package/dist/zustandStores/productViewed.d.ts +9 -0
  251. package/dist/zustandStores/productViewed.d.ts.map +1 -0
  252. package/package.json +57 -41
  253. package/dist/types/rebuySmartCart.d.ts +0 -184
  254. package/dist/types/rebuySmartCart.d.ts.map +0 -1
  255. package/src/components/AddToCartBtn/AddToCartBtn.tsx +0 -45
  256. package/src/components/AddToCartBtn/HydrogenAddToCartBtn.tsx +0 -43
  257. package/src/components/AddToCartBtn/HydrogenReactAddToCartBtn.tsx +0 -35
  258. package/src/components/AddToCartBtn/index.ts +0 -1
  259. package/src/components/AddToCartBtn/types.ts +0 -27
  260. package/src/components/ProductCard/ProductCard.tsx +0 -70
  261. package/src/components/ProductCard/index.ts +0 -1
  262. package/src/components/ProductCard/types.ts +0 -10
  263. package/src/components/ProductPrice/ProductPrice.tsx +0 -49
  264. package/src/components/ProductPrice/index.ts +0 -1
  265. package/src/components/Title/Title.tsx +0 -19
  266. package/src/components/Title/index.ts +0 -1
  267. package/src/components/Title/types.ts +0 -7
  268. package/src/components/VariantSelect/VariantSelect.tsx +0 -45
  269. package/src/components/VariantSelect/index.ts +0 -1
  270. package/src/components/VariantSelect/types.ts +0 -6
  271. package/src/context/RebuyContext.tsx +0 -9
  272. package/src/hooks/titleLevel.tsx +0 -42
  273. package/src/index.ts +0 -7
  274. package/src/providers/RebuyHydrogenContextProvider.tsx +0 -112
  275. package/src/providers/RebuyHydrogenReactContextProvider.tsx +0 -192
  276. package/src/providers/types.ts +0 -58
  277. package/src/queries/cart.queries.ts +0 -467
  278. package/src/types/common.ts +0 -8
  279. package/src/types/css.d.ts +0 -11
  280. package/src/types/env.d.ts +0 -12
  281. package/src/types/rebuy.d.ts +0 -31
  282. package/src/types/rebuyCustom.ts +0 -263
  283. package/src/types/rebuySmartCart.ts +0 -188
  284. package/src/types/shopify.ts +0 -142
  285. package/src/types/widgets.ts +0 -29
  286. package/src/utils/convertToRebuyProduct.tsx +0 -319
  287. package/src/utils/createContextParameters.ts +0 -142
  288. package/src/utils/getEncodedAttributes.ts +0 -11
  289. package/src/utils/getRebuyConfig.ts +0 -31
  290. package/src/widgetContainer/RebuyWidgetContainer.tsx +0 -183
  291. package/src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.tsx +0 -50
  292. package/src/widgets/RebuyCompleteTheLook/index.ts +0 -1
  293. package/src/widgets/RebuyCompleteTheLook/types.ts +0 -5
  294. package/src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx +0 -62
  295. package/src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx +0 -93
  296. package/src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx +0 -65
  297. package/src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx +0 -118
  298. package/src/widgets/RebuyDynamicBundleProducts/Select.tsx +0 -41
  299. package/src/widgets/RebuyDynamicBundleProducts/index.ts +0 -1
  300. package/src/widgets/RebuyDynamicBundleProducts/types.ts +0 -23
  301. package/src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx +0 -66
  302. package/src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx +0 -218
  303. package/src/widgets/RebuyProductAddOns/index.ts +0 -1
  304. package/src/widgets/RebuyProductAddOns/types.ts +0 -24
  305. package/src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.tsx +0 -50
  306. package/src/widgets/RebuyProductRecommendations/index.ts +0 -1
  307. package/src/widgets/RebuyProductRecommendations/types.ts +0 -5
@@ -1,319 +0,0 @@
1
- import type { RebuyProductVariant } from '~/types/rebuyCustom';
2
- import type { HydrogenProduct } from '~/types/shopify';
3
-
4
- export const convertToRebuyProduct = (
5
- isHydrogenReact: boolean,
6
- product?: HydrogenProduct
7
- ) => {
8
- const mainProductVariants: RebuyProductVariant[] = isHydrogenReact
9
- ? product?.variants?.nodes?.map((variant) => {
10
- return {
11
- ...variant,
12
- };
13
- }) || []
14
- : product?.adjacentVariants.map((variant) => {
15
- return {
16
- availableForSale: variant.availableForSale,
17
- compareAtPriceV2: {
18
- amount: variant.compareAtPrice?.amount || '',
19
- currencyCode:
20
- variant.compareAtPrice?.currencyCode || 'USD',
21
- },
22
- id: variant.id,
23
- image: {
24
- altText: variant.image?.altText || '',
25
- height: variant.image?.height || 100,
26
- id: variant.image?.id || '',
27
- url: variant.image?.url || '',
28
- width: variant.image?.width || 100,
29
- },
30
- priceV2: {
31
- amount: variant.price.amount || '',
32
- currencyCode: variant.price.currencyCode || 'USD',
33
- },
34
- product: {
35
- handle: product.handle,
36
- id: product.id,
37
- title: product.title,
38
- vendor: product.vendor,
39
- },
40
- selectedOptions: variant.selectedOptions,
41
- sku: variant.sku || '',
42
- title: variant.title || '',
43
- };
44
- }) || [];
45
-
46
- return isHydrogenReact
47
- ? {
48
- collections: {
49
- nodes:
50
- product?.collections.nodes.map((collection) => {
51
- return {
52
- handle: collection.handle,
53
- };
54
- }) || [],
55
- },
56
- compareAtPriceRange: {
57
- maxVariantCompareAtPrice: null,
58
- minVariantCompareAtPrice: null,
59
- },
60
- description: product?.description || '',
61
- descriptionHtml: product?.descriptionHtml || '',
62
- featuredImage: {
63
- altText: product?.featuredImage?.altText || '',
64
- height: product?.featuredImage?.height || 100,
65
- id: product?.featuredImage?.id || '',
66
- url: product?.featuredImage?.url || '',
67
- width: product?.featuredImage?.width || 100,
68
- },
69
- handle: product?.handle || '',
70
- id: product?.id || '',
71
- images: [
72
- { altText: '', height: 100, id: '', url: '', width: 100 },
73
- ],
74
- media: [],
75
- metafields: [],
76
- options: [],
77
- priceRange: product?.priceRange || {
78
- maxVariantPrice: { amount: '0', currencyCode: 'USD' },
79
- minVariantPrice: { amount: '0', currencyCode: 'USD' },
80
- },
81
- selected: true,
82
- selectedOptions:
83
- product?.selectedVariant?.selectedOptions?.reduce(
84
- (acc, option) => {
85
- return { ...acc, [option.name]: option.value };
86
- },
87
- {}
88
- ) || {},
89
- selectedSellingPlan: {},
90
- selectedSellingPlanAllocation: {},
91
- selectedVariant: {
92
- availableForSale:
93
- product?.selectedVariant?.availableForSale || false,
94
- compareAtPriceV2: {
95
- amount:
96
- product?.selectedVariant?.compareAtPrice?.amount ||
97
- '',
98
- currencyCode:
99
- product?.selectedVariant?.compareAtPrice
100
- ?.currencyCode || 'USD',
101
- },
102
- id: product?.selectedVariant?.id || '',
103
- image: {
104
- altText: product?.selectedVariant?.image?.altText || '',
105
- height: product?.selectedVariant?.image?.height || 100,
106
- id: product?.selectedVariant?.image?.id || '',
107
- url: product?.selectedVariant?.image?.url || '',
108
- width: product?.selectedVariant?.image?.width || 100,
109
- },
110
- priceV2: {
111
- amount: product?.selectedVariant?.price.amount || '',
112
- currencyCode:
113
- product?.selectedVariant?.price.currencyCode || 'USD',
114
- },
115
- product: {
116
- handle: product?.handle || '',
117
- id: product?.id || '',
118
- title: product?.title || '',
119
- vendor: product?.vendor || '',
120
- },
121
- selectedOptions:
122
- product?.selectedVariant?.selectedOptions || [],
123
- sku: product?.selectedVariant?.sku || '',
124
- title: product?.selectedVariant?.title || '',
125
- },
126
- sellingPlanGroups: [],
127
- seo: {
128
- description: product?.seo?.description || '',
129
- title: product?.seo?.title || '',
130
- },
131
- title: product?.title || '',
132
- variants: {
133
- nodes: mainProductVariants,
134
- },
135
- vendor: product?.vendor || '',
136
- }
137
- : {
138
- collections: {
139
- nodes: [],
140
- },
141
- compareAtPriceRange: {
142
- maxVariantCompareAtPrice: null,
143
- minVariantCompareAtPrice: null,
144
- },
145
- description: product?.description || '',
146
- descriptionHtml: product?.descriptionHtml || '',
147
- featuredImage: {
148
- altText:
149
- product?.selectedOrFirstAvailableVariant?.image
150
- ?.altText || '',
151
- height:
152
- product?.selectedOrFirstAvailableVariant?.image?.height ||
153
- 100,
154
- id: product?.selectedOrFirstAvailableVariant?.image?.id || '',
155
- url:
156
- product?.selectedOrFirstAvailableVariant?.image?.url ||
157
- '',
158
- width:
159
- product?.selectedOrFirstAvailableVariant?.image?.width ||
160
- 100,
161
- },
162
- handle: product?.handle || '',
163
- id: product?.id || '',
164
- images: [
165
- {
166
- altText:
167
- product?.selectedOrFirstAvailableVariant?.image
168
- ?.altText || '',
169
- height:
170
- product?.selectedOrFirstAvailableVariant?.image
171
- ?.height || 100,
172
- id:
173
- product?.selectedOrFirstAvailableVariant?.image?.id ||
174
- '',
175
- url:
176
- product?.selectedOrFirstAvailableVariant?.image
177
- ?.url || '',
178
- width:
179
- product?.selectedOrFirstAvailableVariant?.image
180
- ?.width || 100,
181
- },
182
- ],
183
- media: [],
184
- metafields: [],
185
- options: [],
186
- priceRange: product?.priceRange || {
187
- maxVariantPrice: { amount: '0', currencyCode: 'USD' },
188
- minVariantPrice: { amount: '0', currencyCode: 'USD' },
189
- },
190
- selected: true,
191
- selectedOptions:
192
- product?.selectedOrFirstAvailableVariant?.selectedOptions?.reduce(
193
- (acc, option) => {
194
- return { ...acc, [option.name]: option.value };
195
- },
196
- {}
197
- ) || {},
198
- selectedSellingPlan: {},
199
- selectedSellingPlanAllocation: {},
200
- selectedVariant: {
201
- availableForSale:
202
- product?.selectedOrFirstAvailableVariant
203
- ?.availableForSale || false,
204
- compareAtPriceV2: {
205
- amount:
206
- product?.selectedOrFirstAvailableVariant
207
- ?.compareAtPrice?.amount || '',
208
- currencyCode:
209
- product?.selectedOrFirstAvailableVariant
210
- ?.compareAtPrice?.currencyCode || 'USD',
211
- },
212
- id: product?.selectedOrFirstAvailableVariant?.id || '',
213
- image: {
214
- altText:
215
- product?.selectedOrFirstAvailableVariant?.image
216
- ?.altText || '',
217
- height:
218
- product?.selectedOrFirstAvailableVariant?.image
219
- ?.height || 100,
220
- id:
221
- product?.selectedOrFirstAvailableVariant?.image?.id ||
222
- '',
223
- url:
224
- product?.selectedOrFirstAvailableVariant?.image
225
- ?.url || '',
226
- width:
227
- product?.selectedOrFirstAvailableVariant?.image
228
- ?.width || 100,
229
- },
230
- priceV2: {
231
- amount:
232
- product?.selectedOrFirstAvailableVariant?.price
233
- .amount || '',
234
- currencyCode:
235
- product?.selectedOrFirstAvailableVariant?.price
236
- .currencyCode || 'USD',
237
- },
238
- product: {
239
- handle: product?.handle || '',
240
- id: product?.id || '',
241
- title: product?.title || '',
242
- vendor: product?.vendor || '',
243
- },
244
- selectedOptions:
245
- product?.selectedOrFirstAvailableVariant
246
- ?.selectedOptions || [],
247
- sku: product?.selectedOrFirstAvailableVariant?.sku || '',
248
- title: product?.selectedOrFirstAvailableVariant?.title || '',
249
- },
250
- sellingPlanGroups: [],
251
- seo: {
252
- description: null,
253
- title: null,
254
- },
255
- title: product?.title || '',
256
- variants: {
257
- nodes: [
258
- {
259
- availableForSale:
260
- product?.selectedOrFirstAvailableVariant
261
- ?.availableForSale || false,
262
- compareAtPriceV2: {
263
- amount:
264
- product?.selectedOrFirstAvailableVariant
265
- ?.compareAtPrice?.amount || '',
266
- currencyCode:
267
- product?.selectedOrFirstAvailableVariant
268
- ?.compareAtPrice?.currencyCode || 'USD',
269
- },
270
- id:
271
- product?.selectedOrFirstAvailableVariant?.id ||
272
- '',
273
- image: {
274
- altText:
275
- product?.selectedOrFirstAvailableVariant
276
- ?.image?.altText || '',
277
- height:
278
- product?.selectedOrFirstAvailableVariant
279
- ?.image?.height || 100,
280
- id:
281
- product?.selectedOrFirstAvailableVariant
282
- ?.image?.id || '',
283
- url:
284
- product?.selectedOrFirstAvailableVariant
285
- ?.image?.url || '',
286
- width:
287
- product?.selectedOrFirstAvailableVariant
288
- ?.image?.width || 100,
289
- },
290
- priceV2: {
291
- amount:
292
- product?.selectedOrFirstAvailableVariant
293
- ?.price.amount || '',
294
- currencyCode:
295
- product?.selectedOrFirstAvailableVariant
296
- ?.price.currencyCode || 'USD',
297
- },
298
- product: {
299
- handle: product?.handle || '',
300
- id: product?.id || '',
301
- title: product?.title || '',
302
- vendor: product?.vendor || '',
303
- },
304
- selectedOptions:
305
- product?.selectedOrFirstAvailableVariant
306
- ?.selectedOptions || [],
307
- sku:
308
- product?.selectedOrFirstAvailableVariant?.sku ||
309
- '',
310
- title:
311
- product?.selectedOrFirstAvailableVariant?.title ||
312
- '',
313
- },
314
- ...mainProductVariants,
315
- ],
316
- },
317
- vendor: product?.vendor || '',
318
- };
319
- };
@@ -1,142 +0,0 @@
1
- import * as Utilities from '@rebuy/rebuy/utilities';
2
-
3
- import type { Attribute } from '@shopify/hydrogen-react/storefront-api-types';
4
- import type {
5
- CartContext,
6
- CartItem,
7
- ContextParameters,
8
- RebuyContextProps,
9
- } from '~/types/rebuyCustom';
10
-
11
- import { getEncodedAttributes } from '~/utils/getEncodedAttributes';
12
-
13
- export const createContextParameters = ({
14
- cacheKey,
15
- cartAttributes,
16
- cartId,
17
- cartLines,
18
- cartLinesLength,
19
- cartNote,
20
- cartSubtotal,
21
- cartTotalQuantity,
22
- isHydrogenReact,
23
- queryObject,
24
- windowUrl,
25
- }: RebuyContextProps) => {
26
- const contextParameters: ContextParameters = {
27
- cache_key: cacheKey,
28
- cart_count: 0,
29
- cart_item_count: 0,
30
- cart_line_count: 0,
31
- cart_subtotal: 0,
32
- isHydrogenReact,
33
- time: '',
34
- url: windowUrl,
35
- };
36
-
37
- const cartContext: CartContext = {
38
- attributes: '',
39
- item_count: 0,
40
- items: [],
41
- line_count: 0,
42
- note: '',
43
- subtotal: 0,
44
- token: '',
45
- };
46
- if (Object.prototype.hasOwnProperty.call(queryObject, 'time')) {
47
- contextParameters.time = queryObject.time;
48
- }
49
-
50
- // Set Cart: token
51
- if (cartId) {
52
- cartContext.token = Utilities.getIdFromGraphUrl(cartId, 'Cart');
53
- contextParameters.cart_token = Utilities.getIdFromGraphUrl(
54
- cartId,
55
- 'Cart'
56
- );
57
- }
58
-
59
- // Set Cart: subtotal
60
- if (cartSubtotal) {
61
- cartContext.subtotal = Utilities.amountToCents(
62
- parseFloat(cartSubtotal)
63
- );
64
- contextParameters.cart_subtotal = Utilities.amountToCents(
65
- parseFloat(cartSubtotal)
66
- );
67
- }
68
-
69
- // Set Cart: line count
70
- if (cartLinesLength) {
71
- const totalLines = cartLinesLength;
72
- cartContext.line_count = totalLines;
73
- contextParameters.cart_count = totalLines;
74
- contextParameters.cart_line_count = totalLines;
75
- }
76
-
77
- // Set Cart: item count
78
- if (cartTotalQuantity) {
79
- cartContext.item_count = cartTotalQuantity;
80
- contextParameters.cart_item_count = cartTotalQuantity;
81
- }
82
-
83
- if (cartLines) {
84
- cartContext.items = [];
85
-
86
- for (const cartItem of cartLines) {
87
- const item: CartItem = {
88
- attributes: [],
89
- product_id: '',
90
- properties: '',
91
- quantity: cartItem?.quantity,
92
- variant_id: '',
93
- };
94
-
95
- if (cartItem?.merchandise?.product?.id) {
96
- item.product_id = Utilities.getIdFromGraphUrl(
97
- cartItem.merchandise.product.id,
98
- 'Product'
99
- );
100
- }
101
-
102
- if (cartItem?.merchandise?.id) {
103
- item.variant_id = Utilities.getIdFromGraphUrl(
104
- cartItem.merchandise.id,
105
- 'ProductVariant'
106
- );
107
- }
108
-
109
- if (cartItem?.attributes?.length) {
110
- const validAttributes = cartItem.attributes.filter(
111
- (attr: Attribute) =>
112
- attr !== undefined &&
113
- typeof attr.key === 'string' &&
114
- typeof attr.value === 'string'
115
- );
116
- item.properties = getEncodedAttributes(validAttributes);
117
- }
118
- cartContext.items.push(item);
119
- }
120
- }
121
-
122
- // Set Cart: attributes
123
- if (cartAttributes) {
124
- const validAttributes = cartAttributes.filter(
125
- (attr): attr is Attribute =>
126
- attr !== undefined &&
127
- typeof attr.key === 'string' &&
128
- typeof attr.value === 'string'
129
- );
130
- cartContext.attributes = getEncodedAttributes(validAttributes);
131
- }
132
-
133
- // Set Cart: notes
134
- if (cartNote) {
135
- cartContext.note = cartNote;
136
- }
137
-
138
- // Set cart
139
- contextParameters.cart = cartContext;
140
-
141
- return contextParameters;
142
- };
@@ -1,11 +0,0 @@
1
- import type { Attribute } from '@shopify/hydrogen-react/storefront-api-types';
2
-
3
- export const getEncodedAttributes = (attributes: Attribute[]) =>
4
- encodeURIComponent(
5
- JSON.stringify(
6
- attributes.reduce(
7
- (merged, { key, value }) => ({ ...merged, [key]: value }),
8
- {}
9
- )
10
- )
11
- );
@@ -1,31 +0,0 @@
1
- import { RebuyClient } from '@rebuy/rebuy';
2
- import type { RebuyConfig, RebuyResponse } from '~/types/rebuyCustom';
3
-
4
- export const getRebuyConfig = async (
5
- rebuyKey: string,
6
- storeDomain: string
7
- ): Promise<RebuyConfig> => {
8
- try {
9
- const request = {
10
- parameters: { shop: storeDomain },
11
- url: `/api/v1/user/config`,
12
- };
13
-
14
- const { data: rebuy, ...response } = (await new RebuyClient(
15
- rebuyKey
16
- ).getShieldedAsset(request.url, request.parameters)) as RebuyResponse;
17
-
18
- if (!rebuy?.shop) {
19
- throw new Error(
20
- 'Rebuy configuration is not properly set up - missing shop',
21
- { cause: response }
22
- );
23
- }
24
- return rebuy;
25
- } catch (error: unknown) {
26
- const err = error as Error;
27
- console.warn('Error fetching Rebuy shop config');
28
- console.error(err, err.cause);
29
- throw err;
30
- }
31
- };
@@ -1,183 +0,0 @@
1
- import { RebuyClient } from '@rebuy/rebuy';
2
- import * as Utilities from '@rebuy/rebuy/utilities';
3
- import { flattenConnection } from '@shopify/hydrogen';
4
- import React, {
5
- ComponentType,
6
- useContext,
7
- useEffect,
8
- useMemo,
9
- useState,
10
- } from 'react';
11
-
12
- import type {
13
- RebuyProduct,
14
- RebuyWidgetContainerProps,
15
- RebuyWidgetMetadata,
16
- } from '~/types/rebuyCustom';
17
-
18
- import { RebuyContext } from '~/context/RebuyContext';
19
-
20
- type RebuyWidgetContainerComponent = {
21
- (props: RebuyWidgetContainerProps): JSX.Element;
22
- } & ComponentType<RebuyWidgetContainerProps>;
23
-
24
- const RebuyWidgetContainerBase = ({
25
- children,
26
- ...props
27
- }: RebuyWidgetContainerProps) => {
28
- const {
29
- collection,
30
- collectionId,
31
- dataSource,
32
- limit,
33
- options,
34
- product,
35
- productId,
36
- variant,
37
- variantId,
38
- } = props;
39
-
40
- const contextParameters = useContext(RebuyContext);
41
-
42
- const [Rebuy, setRebuy] = useState<RebuyClient | null>(null);
43
- const [initialized, setInitialized] = useState(false);
44
- const shopifyProductId = product?.id ?? productId ?? null;
45
- const shopifyVariantId = variant?.id ?? variantId ?? null;
46
- const shopifyCollectionId = collection?.id ?? collectionId ?? null;
47
- const [products, setProducts] = useState<RebuyProduct[]>([]);
48
- const [metadata, setMetadata] = useState<RebuyWidgetMetadata>();
49
-
50
- const REBUY_API_KEY = import.meta.env.PUBLIC_REBUY_API_KEY;
51
-
52
- // Initialize Rebuy API client
53
- useEffect(() => {
54
- if (!Rebuy) {
55
- const client = new RebuyClient(REBUY_API_KEY);
56
- client.setContextParameters(
57
- contextParameters as Record<string, unknown> // TODO: fix this type when @rebuy/rebuy is moved to typescript
58
- );
59
-
60
- if (options) {
61
- client.setDefaultParameters(options as Record<string, unknown>); // TODO: fix this type when @rebuy/rebuy is moved to typescript
62
- }
63
-
64
- setRebuy(client);
65
- setInitialized(true);
66
- }
67
- }, [REBUY_API_KEY, Rebuy, contextParameters, options]);
68
-
69
- useEffect(() => {
70
- if (!Rebuy) return;
71
-
72
- Rebuy.setContextParameters(
73
- contextParameters as Record<string, unknown> // TODO: fix this type when @rebuy/rebuy is moved to typescript
74
- );
75
- }, [Rebuy, contextParameters]);
76
-
77
- // Memoize request object on prop changes (e.g. product)
78
- const request = useMemo(() => {
79
- const request = {
80
- endpoint: dataSource || '/api/v1/products/recommended',
81
- params: {} as Record<string, string | number>, // Keeping this object generic to allow for custom endpoints
82
- };
83
-
84
- if (shopifyProductId) {
85
- request.params.shopify_product_ids = Utilities.getIdFromGraphUrl(
86
- shopifyProductId,
87
- 'Product'
88
- );
89
- }
90
-
91
- if (shopifyProductId) {
92
- request.params.shopify_product_ids = Utilities.getIdFromGraphUrl(
93
- shopifyProductId,
94
- 'Product'
95
- );
96
- }
97
-
98
- if (shopifyVariantId) {
99
- request.params.shopify_variant_ids = Utilities.getIdFromGraphUrl(
100
- shopifyVariantId,
101
- 'ProductVariant'
102
- );
103
- }
104
-
105
- if (shopifyCollectionId) {
106
- request.params.shopify_collection_ids = Utilities.getIdFromGraphUrl(
107
- shopifyCollectionId,
108
- 'Collection'
109
- );
110
- }
111
-
112
- if (limit) {
113
- request.params.limit = limit;
114
- }
115
-
116
- return request;
117
- }, [
118
- dataSource,
119
- shopifyProductId,
120
- shopifyVariantId,
121
- shopifyCollectionId,
122
- limit,
123
- ]);
124
-
125
- // Update product recommendations on cart or request change
126
- useEffect(() => {
127
- let isMounted = true;
128
- if (!Rebuy || !initialized) return;
129
-
130
- const fetchData = async () => {
131
- const { data, metadata } = (await Rebuy.getStorefrontData(
132
- request.endpoint,
133
- request.params
134
- )) as {
135
- data: RebuyProduct[];
136
- metadata: RebuyWidgetMetadata;
137
- };
138
-
139
- // Set state only if mounted
140
- if (isMounted) {
141
- setProducts(
142
- Array.isArray(data)
143
- ? data.map((product) => ({
144
- ...product,
145
- variants: {
146
- nodes: product.variants
147
- ? flattenConnection(product.variants)
148
- : [],
149
- },
150
- }))
151
- : []
152
- );
153
- setMetadata(metadata);
154
- }
155
- };
156
-
157
- fetchData();
158
- // Unmounted?
159
- return () => {
160
- isMounted = false;
161
- };
162
- }, [Rebuy, initialized, request]);
163
-
164
- const childrenWithProps = (props: RebuyWidgetContainerProps) =>
165
- React.Children.map(children, (child) =>
166
- React.isValidElement(child)
167
- ? React.cloneElement(child, props)
168
- : child
169
- );
170
-
171
- const childProps = {
172
- ...props,
173
- isHydrogenReact: contextParameters?.contextParameters?.isHydrogenReact,
174
- key: product?.id,
175
- metadata,
176
- products,
177
- };
178
-
179
- return childrenWithProps(childProps);
180
- };
181
-
182
- export const RebuyWidgetContainer =
183
- RebuyWidgetContainerBase as RebuyWidgetContainerComponent;