spree_storefront 5.0.0.rc1

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 (341) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.md +13 -0
  3. data/Rakefile +15 -0
  4. data/app/assets/config/spree_storefront_manifest.js +6 -0
  5. data/app/assets/stylesheets/storefront_page_builder.css +51 -0
  6. data/app/controllers/concerns/spree/cart_methods.rb +40 -0
  7. data/app/controllers/concerns/spree/locale_urls.rb +23 -0
  8. data/app/controllers/concerns/spree/password_protected.rb +17 -0
  9. data/app/controllers/concerns/spree/theme_concern.rb +29 -0
  10. data/app/controllers/spree/account/addresses_controller.rb +16 -0
  11. data/app/controllers/spree/account/base_controller.rb +20 -0
  12. data/app/controllers/spree/account/newsletter_controller.rb +34 -0
  13. data/app/controllers/spree/account/orders_controller.rb +34 -0
  14. data/app/controllers/spree/account/profile_controller.rb +23 -0
  15. data/app/controllers/spree/account/store_credits_controller.rb +23 -0
  16. data/app/controllers/spree/account/wished_items_controller.rb +45 -0
  17. data/app/controllers/spree/addresses_controller.rb +101 -0
  18. data/app/controllers/spree/checkout_controller.rb +365 -0
  19. data/app/controllers/spree/contacts_controller.rb +46 -0
  20. data/app/controllers/spree/digital_links_controller.rb +48 -0
  21. data/app/controllers/spree/home_controller.rb +5 -0
  22. data/app/controllers/spree/line_items_controller.rb +96 -0
  23. data/app/controllers/spree/newsletter_subscribers_controller.rb +43 -0
  24. data/app/controllers/spree/order_status_controller.rb +32 -0
  25. data/app/controllers/spree/orders_controller.rb +104 -0
  26. data/app/controllers/spree/page_sections_controller.rb +17 -0
  27. data/app/controllers/spree/pages_controller.rb +13 -0
  28. data/app/controllers/spree/password_controller.rb +21 -0
  29. data/app/controllers/spree/policies_controller.rb +17 -0
  30. data/app/controllers/spree/posts_controller.rb +76 -0
  31. data/app/controllers/spree/products_controller.rb +99 -0
  32. data/app/controllers/spree/search_controller.rb +39 -0
  33. data/app/controllers/spree/seo_controller.rb +25 -0
  34. data/app/controllers/spree/settings_controller.rb +68 -0
  35. data/app/controllers/spree/store_controller.rb +247 -0
  36. data/app/controllers/spree/taxonomies_controller.rb +30 -0
  37. data/app/controllers/spree/taxons_controller.rb +46 -0
  38. data/app/controllers/spree/wishlists_controller.rb +19 -0
  39. data/app/finders/spree/storefront/variant_finder.rb +80 -0
  40. data/app/helpers/spree/analytics_helper.rb +28 -0
  41. data/app/helpers/spree/cart_helper.rb +48 -0
  42. data/app/helpers/spree/checkout_analytics_helper.rb +77 -0
  43. data/app/helpers/spree/checkout_helper.rb +58 -0
  44. data/app/helpers/spree/filters_helper.rb +180 -0
  45. data/app/helpers/spree/fonts_helper.rb +58 -0
  46. data/app/helpers/spree/orders_helper.rb +7 -0
  47. data/app/helpers/spree/page_helper.rb +67 -0
  48. data/app/helpers/spree/posts_helper.rb +42 -0
  49. data/app/helpers/spree/products_helper.rb +205 -0
  50. data/app/helpers/spree/storefront_helper.rb +86 -0
  51. data/app/helpers/spree/storefront_locale_helper.rb +42 -0
  52. data/app/helpers/spree/theme_helper.rb +244 -0
  53. data/app/helpers/spree/turbo_helper.rb +13 -0
  54. data/app/helpers/spree/turbo_stream_actions_helper.rb +13 -0
  55. data/app/helpers/spree/wishlist_helper.rb +7 -0
  56. data/app/javascript/spree/storefront/application.js +156 -0
  57. data/app/javascript/spree/storefront/controllers/accordion_controller.js +25 -0
  58. data/app/javascript/spree/storefront/controllers/account_nav_controller.js +10 -0
  59. data/app/javascript/spree/storefront/controllers/card_validation_controller.js +103 -0
  60. data/app/javascript/spree/storefront/controllers/carousel_controller.js +44 -0
  61. data/app/javascript/spree/storefront/controllers/cart_controller.js +10 -0
  62. data/app/javascript/spree/storefront/controllers/checkout_address_book_controller.js +28 -0
  63. data/app/javascript/spree/storefront/controllers/checkout_delivery_controller.js +39 -0
  64. data/app/javascript/spree/storefront/controllers/checkout_promotions_controller.js +28 -0
  65. data/app/javascript/spree/storefront/controllers/checkout_summary_controller.js +46 -0
  66. data/app/javascript/spree/storefront/controllers/clear_input_controller.js +23 -0
  67. data/app/javascript/spree/storefront/controllers/copy_input_controller.js +19 -0
  68. data/app/javascript/spree/storefront/controllers/dropdown_controller.js +14 -0
  69. data/app/javascript/spree/storefront/controllers/header_controller.js +33 -0
  70. data/app/javascript/spree/storefront/controllers/infinite_scroll_controller.js +31 -0
  71. data/app/javascript/spree/storefront/controllers/lightbox_controller.js +138 -0
  72. data/app/javascript/spree/storefront/controllers/mobile_nav_controller.js +17 -0
  73. data/app/javascript/spree/storefront/controllers/modal_controller.js +15 -0
  74. data/app/javascript/spree/storefront/controllers/no_ui_slider_controller.js +55 -0
  75. data/app/javascript/spree/storefront/controllers/pdp_desktop_gallery_controller.js +28 -0
  76. data/app/javascript/spree/storefront/controllers/plp_variant_picker_controller.js +151 -0
  77. data/app/javascript/spree/storefront/controllers/product_form_controller.js +136 -0
  78. data/app/javascript/spree/storefront/controllers/quantity_picker_controller.js +43 -0
  79. data/app/javascript/spree/storefront/controllers/search_suggestions_controller.js +61 -0
  80. data/app/javascript/spree/storefront/controllers/searchable_list_controller.js +25 -0
  81. data/app/javascript/spree/storefront/controllers/slideover_controller.js +40 -0
  82. data/app/javascript/spree/storefront/controllers/sticky_button_controller.js +32 -0
  83. data/app/javascript/spree/storefront/controllers/toggle_menu_controller.js +32 -0
  84. data/app/javascript/spree/storefront/controllers/turbo_stream_form_controller.js +51 -0
  85. data/app/javascript/spree/storefront/controllers/wished_item_controller.js +69 -0
  86. data/app/javascript/spree/storefront/helpers/lazy_load_controllers_with_manifest.js +78 -0
  87. data/app/javascript/spree/storefront/helpers/show_flash_message.js +25 -0
  88. data/app/models/spree/color_names.rb +35 -0
  89. data/app/models/spree/contact.rb +24 -0
  90. data/app/presenters/spree/colors_preview_styles_presenter.rb +84 -0
  91. data/app/presenters/spree/featured_product_presenter.rb +42 -0
  92. data/app/presenters/spree/mega_nav_presenter.rb +55 -0
  93. data/app/views/devise/passwords/edit.html.erb +22 -0
  94. data/app/views/devise/passwords/new.html.erb +16 -0
  95. data/app/views/devise/registrations/_form.html.erb +21 -0
  96. data/app/views/devise/registrations/edit.html.erb +24 -0
  97. data/app/views/devise/registrations/new.html.erb +27 -0
  98. data/app/views/devise/sessions/new.html.erb +25 -0
  99. data/app/views/devise/shared/_links.html.erb +22 -0
  100. data/app/views/layouts/spree/checkout.html.erb +58 -0
  101. data/app/views/layouts/spree/password.html.erb +34 -0
  102. data/app/views/layouts/spree/storefront.html.erb +38 -0
  103. data/app/views/spree/account/wished_items/create.turbo_stream.erb +8 -0
  104. data/app/views/spree/account/wished_items/destroy.turbo_stream.erb +20 -0
  105. data/app/views/spree/addresses/destroy.turbo_stream.erb +1 -0
  106. data/app/views/spree/addresses/edit.html.erb +57 -0
  107. data/app/views/spree/addresses/new.html.erb +71 -0
  108. data/app/views/spree/checkout/_address.html.erb +153 -0
  109. data/app/views/spree/checkout/_button_processing.html.erb +7 -0
  110. data/app/views/spree/checkout/_coupon_code.html.erb +55 -0
  111. data/app/views/spree/checkout/_credit_card.html.erb +12 -0
  112. data/app/views/spree/checkout/_delivery.html.erb +70 -0
  113. data/app/views/spree/checkout/_line_item.html.erb +26 -0
  114. data/app/views/spree/checkout/_line_items.html.erb +7 -0
  115. data/app/views/spree/checkout/_missing_all_line_items.html.erb +17 -0
  116. data/app/views/spree/checkout/_missing_line_items.html.erb +28 -0
  117. data/app/views/spree/checkout/_payment.html.erb +35 -0
  118. data/app/views/spree/checkout/_payment_methods.html.erb +72 -0
  119. data/app/views/spree/checkout/_payment_sources.html.erb +24 -0
  120. data/app/views/spree/checkout/_quick_checkout.html.erb +1 -0
  121. data/app/views/spree/checkout/_sidebar.html.erb +34 -0
  122. data/app/views/spree/checkout/_store_credit.html.erb +21 -0
  123. data/app/views/spree/checkout/_summary.html.erb +116 -0
  124. data/app/views/spree/checkout/_user_account.html.erb +9 -0
  125. data/app/views/spree/checkout/apply_coupon_code.turbo_stream.erb +45 -0
  126. data/app/views/spree/checkout/apply_store_credit.turbo_stream.erb +19 -0
  127. data/app/views/spree/checkout/edit.html.erb +98 -0
  128. data/app/views/spree/checkout/payment/_check.html.erb +0 -0
  129. data/app/views/spree/checkout/payment/_gateway.html.erb +74 -0
  130. data/app/views/spree/checkout/payment/_store_credit.html.erb +13 -0
  131. data/app/views/spree/checkout/remove_coupon_code.turbo_stream.erb +34 -0
  132. data/app/views/spree/checkout/remove_store_credit.turbo_stream.erb +19 -0
  133. data/app/views/spree/checkout/update.turbo_stream.erb +25 -0
  134. data/app/views/spree/home/index.html.erb +1 -0
  135. data/app/views/spree/line_items/create.turbo_stream.erb +13 -0
  136. data/app/views/spree/line_items/destroy.turbo_stream.erb +11 -0
  137. data/app/views/spree/line_items/update.turbo_stream.erb +10 -0
  138. data/app/views/spree/newsletter_subscribers/create.turbo_stream.erb +7 -0
  139. data/app/views/spree/order_status/new.html.erb +16 -0
  140. data/app/views/spree/page_sections/show.html.erb +3 -0
  141. data/app/views/spree/pages/show.html.erb +1 -0
  142. data/app/views/spree/password/show.html.erb +1 -0
  143. data/app/views/spree/posts/index.html.erb +1 -0
  144. data/app/views/spree/posts/related_products.html.erb +7 -0
  145. data/app/views/spree/posts/show.html.erb +1 -0
  146. data/app/views/spree/products/index.html.erb +1 -0
  147. data/app/views/spree/products/index.turbo_stream.erb +1 -0
  148. data/app/views/spree/products/related.html.erb +3 -0
  149. data/app/views/spree/products/show.html.erb +1 -0
  150. data/app/views/spree/search/show.html.erb +6 -0
  151. data/app/views/spree/search/show.turbo_stream.erb +1 -0
  152. data/app/views/spree/search/suggestions.turbo_stream.erb +8 -0
  153. data/app/views/spree/seo/robots.text.erb +31 -0
  154. data/app/views/spree/seo/sitemap.xml.erb +25 -0
  155. data/app/views/spree/shared/_fonts.html.erb +14 -0
  156. data/app/views/spree/shared/_head.html.erb +36 -0
  157. data/app/views/spree/shared/_load_more_products.turbo_stream.erb +7 -0
  158. data/app/views/spree/shared/_product_listing_page.html.erb +11 -0
  159. data/app/views/spree/shared/_products.html.erb +1 -0
  160. data/app/views/spree/taxonomies/show.html.erb +1 -0
  161. data/app/views/spree/taxons/show.html.erb +1 -0
  162. data/app/views/spree/taxons/show.turbo_stream.erb +1 -0
  163. data/app/views/spree/waitlists/create.turbo_stream.erb +9 -0
  164. data/app/views/themes/default/kaminari/storefront/_first_page.html.erb +8 -0
  165. data/app/views/themes/default/kaminari/storefront/_gap.html.erb +8 -0
  166. data/app/views/themes/default/kaminari/storefront/_last_page.html.erb +8 -0
  167. data/app/views/themes/default/kaminari/storefront/_next_page.html.erb +13 -0
  168. data/app/views/themes/default/kaminari/storefront/_page.html.erb +10 -0
  169. data/app/views/themes/default/kaminari/storefront/_paginator.html.erb +27 -0
  170. data/app/views/themes/default/kaminari/storefront/_prev_page.html.erb +13 -0
  171. data/app/views/themes/default/spree/account/_account_nav.html.erb +46 -0
  172. data/app/views/themes/default/spree/account/_order.html.erb +39 -0
  173. data/app/views/themes/default/spree/account/_orders.html.erb +16 -0
  174. data/app/views/themes/default/spree/account/addresses/_address.html.erb +42 -0
  175. data/app/views/themes/default/spree/account/addresses/index.html.erb +28 -0
  176. data/app/views/themes/default/spree/account/newsletter/_newsletter_settings.html.erb +13 -0
  177. data/app/views/themes/default/spree/account/newsletter/edit.html.erb +16 -0
  178. data/app/views/themes/default/spree/account/newsletter/update.html.erb +1 -0
  179. data/app/views/themes/default/spree/account/orders/index.html.erb +24 -0
  180. data/app/views/themes/default/spree/account/orders/show.html.erb +22 -0
  181. data/app/views/themes/default/spree/account/profile/edit.html.erb +36 -0
  182. data/app/views/themes/default/spree/account/store_credits/_store_credit_event.html.erb +29 -0
  183. data/app/views/themes/default/spree/account/store_credits/index.html.erb +31 -0
  184. data/app/views/themes/default/spree/checkout/_footer.html.erb +10 -0
  185. data/app/views/themes/default/spree/checkout/complete.html.erb +84 -0
  186. data/app/views/themes/default/spree/contacts/new.html.erb +23 -0
  187. data/app/views/themes/default/spree/orders/_cart.html.erb +14 -0
  188. data/app/views/themes/default/spree/orders/_empty.html.erb +11 -0
  189. data/app/views/themes/default/spree/orders/_line_item.html.erb +47 -0
  190. data/app/views/themes/default/spree/orders/_line_item_quantity.html.erb +11 -0
  191. data/app/views/themes/default/spree/orders/_summary.html.erb +41 -0
  192. data/app/views/themes/default/spree/orders/edit.html.erb +18 -0
  193. data/app/views/themes/default/spree/orders/show.html.erb +6 -0
  194. data/app/views/themes/default/spree/page_sections/_announcement_bar.html.erb +10 -0
  195. data/app/views/themes/default/spree/page_sections/_custom_code.html.erb +5 -0
  196. data/app/views/themes/default/spree/page_sections/_featured_product.html.erb +136 -0
  197. data/app/views/themes/default/spree/page_sections/_featured_taxon.html.erb +116 -0
  198. data/app/views/themes/default/spree/page_sections/_featured_taxons.html.erb +71 -0
  199. data/app/views/themes/default/spree/page_sections/_footer.html.erb +62 -0
  200. data/app/views/themes/default/spree/page_sections/_header.html.erb +166 -0
  201. data/app/views/themes/default/spree/page_sections/_image_banner.html.erb +57 -0
  202. data/app/views/themes/default/spree/page_sections/_image_with_text.html.erb +66 -0
  203. data/app/views/themes/default/spree/page_sections/_main_password_footer.html.erb +64 -0
  204. data/app/views/themes/default/spree/page_sections/_main_password_header.html.erb +54 -0
  205. data/app/views/themes/default/spree/page_sections/_newsletter.html.erb +47 -0
  206. data/app/views/themes/default/spree/page_sections/_page_title.html.erb +7 -0
  207. data/app/views/themes/default/spree/page_sections/_post_details.html.erb +19 -0
  208. data/app/views/themes/default/spree/page_sections/_post_grid.html.erb +11 -0
  209. data/app/views/themes/default/spree/page_sections/_product_details.html.erb +102 -0
  210. data/app/views/themes/default/spree/page_sections/_product_grid.html.erb +52 -0
  211. data/app/views/themes/default/spree/page_sections/_related_products.html.erb +15 -0
  212. data/app/views/themes/default/spree/page_sections/_rich_text.html.erb +18 -0
  213. data/app/views/themes/default/spree/page_sections/_taxon_banner.html.erb +37 -0
  214. data/app/views/themes/default/spree/page_sections/_taxon_grid.html.erb +103 -0
  215. data/app/views/themes/default/spree/page_sections/_video.html.erb +27 -0
  216. data/app/views/themes/default/spree/page_sections/nav/_desktop.html.erb +49 -0
  217. data/app/views/themes/default/spree/page_sections/nav/_mobile.html.erb +136 -0
  218. data/app/views/themes/default/spree/policies/show.html.erb +11 -0
  219. data/app/views/themes/default/spree/posts/_json_ld.html.erb +20 -0
  220. data/app/views/themes/default/spree/posts/_pagination.html.erb +1 -0
  221. data/app/views/themes/default/spree/posts/_post.html.erb +13 -0
  222. data/app/views/themes/default/spree/products/_add_to_cart_button.html.erb +58 -0
  223. data/app/views/themes/default/spree/products/_add_to_waitlist.html.erb +36 -0
  224. data/app/views/themes/default/spree/products/_add_to_wishlist.html.erb +33 -0
  225. data/app/views/themes/default/spree/products/_breadcrumbs.html.erb +23 -0
  226. data/app/views/themes/default/spree/products/_color_picker.html.erb +19 -0
  227. data/app/views/themes/default/spree/products/_color_swatches.html.erb +61 -0
  228. data/app/views/themes/default/spree/products/_details.html.erb +55 -0
  229. data/app/views/themes/default/spree/products/_featured_image.html.erb +37 -0
  230. data/app/views/themes/default/spree/products/_filters.html.erb +45 -0
  231. data/app/views/themes/default/spree/products/_json_ld.html.erb +38 -0
  232. data/app/views/themes/default/spree/products/_json_ld_list.html.erb +9 -0
  233. data/app/views/themes/default/spree/products/_json_ld_variant.html.erb +10 -0
  234. data/app/views/themes/default/spree/products/_label.html.erb +26 -0
  235. data/app/views/themes/default/spree/products/_media_gallery.html.erb +94 -0
  236. data/app/views/themes/default/spree/products/_price.html.erb +59 -0
  237. data/app/views/themes/default/spree/products/_product.html.erb +62 -0
  238. data/app/views/themes/default/spree/products/_quantity_selector.html.erb +32 -0
  239. data/app/views/themes/default/spree/products/_returns_policy_modal.html.erb +22 -0
  240. data/app/views/themes/default/spree/products/_show_more_button.html.erb +8 -0
  241. data/app/views/themes/default/spree/products/_sort.html.erb +45 -0
  242. data/app/views/themes/default/spree/products/_swiper.html.erb +85 -0
  243. data/app/views/themes/default/spree/products/_tags.html.erb +0 -0
  244. data/app/views/themes/default/spree/products/_variant_options.html.erb +71 -0
  245. data/app/views/themes/default/spree/products/_variant_picker.html.erb +50 -0
  246. data/app/views/themes/default/spree/products/filters/_availability.html.erb +32 -0
  247. data/app/views/themes/default/spree/products/filters/_colors.html.erb +23 -0
  248. data/app/views/themes/default/spree/products/filters/_generic.html.erb +75 -0
  249. data/app/views/themes/default/spree/products/filters/_price.html.erb +35 -0
  250. data/app/views/themes/default/spree/products/filters/_taxons.erb +78 -0
  251. data/app/views/themes/default/spree/search/_suggestions.html.erb +92 -0
  252. data/app/views/themes/default/spree/settings/show.html.erb +32 -0
  253. data/app/views/themes/default/spree/shared/_account_pane.html.erb +28 -0
  254. data/app/views/themes/default/spree/shared/_address.html.erb +35 -0
  255. data/app/views/themes/default/spree/shared/_cart_icon.html.erb +13 -0
  256. data/app/views/themes/default/spree/shared/_cart_pane.html.erb +38 -0
  257. data/app/views/themes/default/spree/shared/_css_variables.html.erb +54 -0
  258. data/app/views/themes/default/spree/shared/_custom_head.html.erb +0 -0
  259. data/app/views/themes/default/spree/shared/_error_messages.html.erb +9 -0
  260. data/app/views/themes/default/spree/shared/_error_messages_without_base_attribute.html.erb +15 -0
  261. data/app/views/themes/default/spree/shared/_flash.html.erb +16 -0
  262. data/app/views/themes/default/spree/shared/_flashes.html.erb +10 -0
  263. data/app/views/themes/default/spree/shared/_json_ld.html.erb +32 -0
  264. data/app/views/themes/default/spree/shared/_line_item_options.html.erb +18 -0
  265. data/app/views/themes/default/spree/shared/_logo.html.erb +42 -0
  266. data/app/views/themes/default/spree/shared/_meta_tags.html.erb +45 -0
  267. data/app/views/themes/default/spree/shared/_order_details.html.erb +106 -0
  268. data/app/views/themes/default/spree/shared/_order_line_item.html.erb +65 -0
  269. data/app/views/themes/default/spree/shared/_order_shipment.html.erb +71 -0
  270. data/app/views/themes/default/spree/shared/_search.html.erb +32 -0
  271. data/app/views/themes/default/spree/shared/_title.html.erb +3 -0
  272. data/app/views/themes/default/spree/shared/_wishlist_icon.html.erb +13 -0
  273. data/app/views/themes/default/spree/shared/icons/_account.html.erb +17 -0
  274. data/app/views/themes/default/spree/shared/icons/_arrow-left.html.erb +8 -0
  275. data/app/views/themes/default/spree/shared/icons/_arrow-right.html.erb +3 -0
  276. data/app/views/themes/default/spree/shared/icons/_bell.html.erb +9 -0
  277. data/app/views/themes/default/spree/shared/icons/_cart.html.erb +10 -0
  278. data/app/views/themes/default/spree/shared/icons/_cart_48.html.erb +6 -0
  279. data/app/views/themes/default/spree/shared/icons/_check.html.erb +4 -0
  280. data/app/views/themes/default/spree/shared/icons/_chevron.html.erb +15 -0
  281. data/app/views/themes/default/spree/shared/icons/_chevron_down.html.erb +5 -0
  282. data/app/views/themes/default/spree/shared/icons/_chevron_right.html.erb +15 -0
  283. data/app/views/themes/default/spree/shared/icons/_chevron_up.html.erb +3 -0
  284. data/app/views/themes/default/spree/shared/icons/_close.html.erb +9 -0
  285. data/app/views/themes/default/spree/shared/icons/_cross.html.erb +16 -0
  286. data/app/views/themes/default/spree/shared/icons/_delete.html.erb +3 -0
  287. data/app/views/themes/default/spree/shared/icons/_delivery.html.erb +5 -0
  288. data/app/views/themes/default/spree/shared/icons/_disabled.html.erb +13 -0
  289. data/app/views/themes/default/spree/shared/icons/_edit.html.erb +3 -0
  290. data/app/views/themes/default/spree/shared/icons/_facebook.html.erb +16 -0
  291. data/app/views/themes/default/spree/shared/icons/_filter.html.erb +8 -0
  292. data/app/views/themes/default/spree/shared/icons/_heart.html.erb +12 -0
  293. data/app/views/themes/default/spree/shared/icons/_info.html.erb +7 -0
  294. data/app/views/themes/default/spree/shared/icons/_instagram.html.erb +18 -0
  295. data/app/views/themes/default/spree/shared/icons/_lock.html.erb +13 -0
  296. data/app/views/themes/default/spree/shared/icons/_menu.html.erb +10 -0
  297. data/app/views/themes/default/spree/shared/icons/_minus.html.erb +5 -0
  298. data/app/views/themes/default/spree/shared/icons/_pinch.html.erb +6 -0
  299. data/app/views/themes/default/spree/shared/icons/_pinterest.html.erb +8 -0
  300. data/app/views/themes/default/spree/shared/icons/_plus.html.erb +17 -0
  301. data/app/views/themes/default/spree/shared/icons/_return.html.erb +11 -0
  302. data/app/views/themes/default/spree/shared/icons/_search.html.erb +17 -0
  303. data/app/views/themes/default/spree/shared/icons/_spinner.html.erb +1 -0
  304. data/app/views/themes/default/spree/shared/icons/_spotify.html.erb +8 -0
  305. data/app/views/themes/default/spree/shared/icons/_tiktok.html.erb +9 -0
  306. data/app/views/themes/default/spree/shared/icons/_twitter.html.erb +16 -0
  307. data/app/views/themes/default/spree/shared/icons/_youtube.html.erb +9 -0
  308. data/app/views/themes/default/spree/shared/icons/_zoom.html.erb +10 -0
  309. data/app/views/themes/default/spree/wishlists/_no_wished_items.html.erb +10 -0
  310. data/app/views/themes/default/spree/wishlists/_wished_item.html.erb +38 -0
  311. data/app/views/themes/default/spree/wishlists/show.html.erb +17 -0
  312. data/config/i18n-tasks.yml +176 -0
  313. data/config/importmap.rb +22 -0
  314. data/config/initializers/assets.rb +1 -0
  315. data/config/initializers/heroicon.rb +10 -0
  316. data/config/locales/en.yml +76 -0
  317. data/config/routes.rb +88 -0
  318. data/lib/generators/spree/storefront/install/install_generator.rb +45 -0
  319. data/lib/generators/spree/storefront/install/templates/application.tailwind.css +1760 -0
  320. data/lib/generators/spree/storefront/install/templates/dev +16 -0
  321. data/lib/generators/spree/storefront/install/templates/tailwind.config.js +128 -0
  322. data/lib/generators/spree/storefront/theme/templates/model.rb.tt +12 -0
  323. data/lib/generators/spree/storefront/theme/theme_generator.rb +41 -0
  324. data/lib/spree/storefront/configuration.rb +11 -0
  325. data/lib/spree/storefront/engine.rb +51 -0
  326. data/lib/spree/storefront/testing_support/capybara_utils.rb +13 -0
  327. data/lib/spree/storefront.rb +16 -0
  328. data/lib/spree_storefront.rb +1 -0
  329. data/vendor/colornames.json +1 -0
  330. data/vendor/javascript/@kanety--stimulus-accordion.js +4 -0
  331. data/vendor/javascript/@stimulus-components--carousel.js +4 -0
  332. data/vendor/javascript/card-validator.js +4 -0
  333. data/vendor/javascript/credit-card-type.js +4 -0
  334. data/vendor/javascript/headroom.js.js +19 -0
  335. data/vendor/javascript/nouislider.js +4 -0
  336. data/vendor/javascript/photoswipe--dist--photoswipe-lightbox.esm.js.js +667 -0
  337. data/vendor/javascript/photoswipe.js +1675 -0
  338. data/vendor/javascript/stimulus-read-more.js +4 -0
  339. data/vendor/javascript/stimulus-scroll-to.js +4 -0
  340. data/vendor/javascript/swiper--bundle.js +4 -0
  341. metadata +567 -0
@@ -0,0 +1,244 @@
1
+ module Spree
2
+ module ThemeHelper
3
+ def current_page
4
+ @current_page ||= current_theme.pages.find_by(type: 'Spree::Pages::Homepage')
5
+ end
6
+
7
+ def current_theme
8
+ @current_theme ||= if params[:theme_id].present?
9
+ current_store.themes.find_by(id: params[:theme_id])
10
+ else
11
+ current_store.default_theme || current_store.themes.first
12
+ end
13
+ ensure
14
+ @current_theme ||= current_store.themes.first
15
+ end
16
+
17
+ def current_theme_preview
18
+ return if params[:theme_preview_id].blank?
19
+
20
+ @current_theme_preview ||= current_theme.previews.find_by(id: params[:theme_preview_id])
21
+ end
22
+
23
+ def current_page_preview
24
+ return if params[:page_preview_id].blank?
25
+
26
+ @current_page_preview ||= current_page.previews.find_by(id: params[:page_preview_id])
27
+ end
28
+
29
+ def current_page_or_preview
30
+ @current_page_or_preview ||= current_page_preview || current_page
31
+ end
32
+
33
+ def current_theme_or_preview
34
+ @current_theme_or_preview ||= current_theme_preview || current_theme
35
+ end
36
+
37
+ def current_header_logo
38
+ @current_header_logo ||= current_theme_or_preview.sections.find_by(type: 'Spree::PageSections::Header')&.logo
39
+ end
40
+
41
+ def page_builder_enabled?
42
+ @page_builder_enabled ||= (current_theme_preview.present? || current_page_preview.present?) && params[:page_builder] == 'true'
43
+ end
44
+
45
+ def theme_layout_sections
46
+ @theme_layout_sections ||= current_theme_or_preview.sections.includes(:links, { asset_attachment: :blob },
47
+ { blocks: [:rich_text_text, :links] }).all.each_with_object({}) do |section, hash|
48
+ hash[section.type.to_s.demodulize.underscore] = section
49
+ end
50
+ rescue StandardError => e
51
+ raise e unless Rails.env.production?
52
+
53
+ Rails.error.report(e, context: { theme_id: current_theme_or_preview.id }, source: 'spree.storefront')
54
+
55
+ {}
56
+ end
57
+
58
+ def theme_setting(name)
59
+ if current_theme_preview.present?
60
+ current_theme_preview.preferences.with_indifferent_access[name]
61
+ elsif current_theme.present?
62
+ current_theme.preferences.with_indifferent_access[name]
63
+ end
64
+ end
65
+
66
+ # This helper allows us to specify opacity in Tailwind's color palette
67
+ def theme_setting_rgb_components(name)
68
+ hex_color = theme_setting(name)
69
+ return unless hex_color.present?
70
+
71
+ rgb = hex_color[0..6].match(/^#(..)(..)(..)$/).captures.map(&:hex)
72
+ rgb.join(', ')
73
+ end
74
+
75
+ # https://makandracards.com/makandra/496431-ruby-how-to-convert-hex-color-codes-to-rgb-or-rgba
76
+ def hex_color_to_rgb(hex)
77
+ return unless hex.present?
78
+
79
+ rgb = hex[0..6].match(/^#(..)(..)(..)$/).captures.map(&:hex)
80
+ "rgb(#{rgb.join(', ')})"
81
+ end
82
+
83
+ def hex_color_to_rgba(hex)
84
+ return unless hex.present?
85
+
86
+ *rgb, alpha = hex.match(/^#(..)(..)(..)(..)?$/).captures.map { |hex_pair| hex_pair&.hex }
87
+ opacity = (alpha || 255) / 255.0
88
+ "rgba(#{rgb.join(', ')}, #{opacity.round(2)})"
89
+ end
90
+
91
+ def section_styles(section)
92
+ styles = {}
93
+
94
+ bg_color = section.preferred_background_color.presence || theme_setting('background_color')
95
+ styles['background-color'] = bg_color
96
+ styles['--section-background'] = bg_color
97
+ text_color = section.preferred_text_color.presence || theme_setting('text_color')
98
+ styles['color'] = text_color
99
+ styles['--section-color'] = text_color
100
+ styles['border-color'] = section.preferred_border_color.presence || theme_setting('border_color')
101
+ styles['padding-top'] = "#{section.preferred_top_padding.presence}px"
102
+ styles['padding-bottom'] = "#{section.preferred_bottom_padding.presence}px"
103
+ styles['border-top-width'] = "#{section.preferred_top_border_width.presence}px"
104
+ border_bottom_width = "#{section.preferred_bottom_border_width.presence}px"
105
+ styles['border-bottom-width'] = border_bottom_width
106
+ styles['--section--border-bottom-width'] = border_bottom_width
107
+
108
+ if section.respond_to?(:preferred_button_text_color) && section.preferred_button_text_color.present?
109
+ styles['--button-text-color'] = section.preferred_button_text_color
110
+ end
111
+
112
+ if section.respond_to?(:preferred_button_background_color) && section.preferred_button_background_color.present?
113
+ styles['--button-background-color'] = section.preferred_button_background_color
114
+ end
115
+
116
+ styles.map { |k, v| "#{k}: #{v}" }.join(';')
117
+ end
118
+
119
+ def section_heading_styles(section)
120
+ styles = {}
121
+
122
+ styles['text-transform'] = :uppercase if theme_setting('headings_uppercase')
123
+ if section.respond_to?(:preferred_heading_bottom_padding) && section.preferred_heading_bottom_padding.present?
124
+ styles['padding-bottom'] =
125
+ "#{section.preferred_heading_bottom_padding}px"
126
+ end
127
+
128
+ styles.compact_blank.map { |k, v| "#{k}: #{v}" }.join(';')
129
+ end
130
+
131
+ def block_attributes(block, allowed_styles: :all)
132
+ has_width_desktop = block.respond_to?(:preferred_width_desktop) && block.preferred_width_desktop.present? ? "width-desktop='true'" : nil
133
+
134
+ attributes = {
135
+ data: {
136
+ editor_id: "block-#{block.id}",
137
+ editor_name: block.display_name,
138
+ editor_parent_id: "section-#{block.section_id}",
139
+ editor_link: spree.respond_to?(:edit_admin_page_section_block_path) ? spree.edit_admin_page_section_block_path(block.section, block) : nil
140
+ },
141
+ id: "block-#{block.id}",
142
+ class: "block-#{block.class.name.demodulize.underscore.dasherize}",
143
+ style: block_styles(block, allowed_styles: allowed_styles),
144
+ width_desktop: has_width_desktop
145
+ }.compact_blank
146
+
147
+ tag.attributes(attributes)
148
+ end
149
+
150
+ def link_attributes(link, as_html: true)
151
+ parent_type = case link.parent_type
152
+ when 'Spree::PageSection'
153
+ :section
154
+ when 'Spree::PageBlock'
155
+ :block
156
+ else
157
+ return ''
158
+ end
159
+
160
+ attributes = if spree.respond_to?(:admin) && spree.respond_to?(:edit_admin_page_link_path) && spree.respond_to?(:edit_admin_page_section_block_path)
161
+ {
162
+ data: {
163
+ editor_id: "link-#{link.id}",
164
+ editor_name: link.label,
165
+ editor_parent_id: "#{parent_type}-#{link.parent_id}",
166
+ editor_link: case parent_type
167
+ when :section
168
+ spree.edit_admin_page_link_path(link, page_section_id: link.parent_id)
169
+ when :block
170
+ spree.edit_admin_page_link_path(link, block_id: link.parent_id)
171
+ end
172
+ },
173
+ id: "link-#{link.id}",
174
+ class: "link-#{link.class.name.demodulize.underscore.dasherize}"
175
+ }
176
+ else
177
+ {}
178
+ end
179
+
180
+ if as_html
181
+ tag.attributes(attributes)
182
+ else
183
+ attributes
184
+ end
185
+ end
186
+
187
+ def block_styles(block, allowed_styles: :all)
188
+ styles = {}
189
+
190
+ styles['text-align'] = block.preferred_text_alignment if block.respond_to?(:preferred_text_alignment) && block.preferred_text_alignment.present?
191
+ styles['width'] = "#{block.preferred_width_desktop}%" if block.respond_to?(:preferred_width_desktop) && block.preferred_width_desktop.present?
192
+ if block.respond_to?(:preferred_container_alignment)
193
+ styles['margin'] = case block.preferred_container_alignment
194
+ when 'center'
195
+ '0 auto'
196
+ when 'right'
197
+ '0 0 0 auto'
198
+ else
199
+ '0 auto 0 0'
200
+ end
201
+ end
202
+ styles['color'] = if block.respond_to?(:preferred_text_color) && block.preferred_text_color.present?
203
+ block.preferred_text_color
204
+ else
205
+ 'var(--section-color)'
206
+ end
207
+
208
+ styles['padding-top'] = "#{block.preferred_top_padding}px" if block.respond_to?(:preferred_top_padding) && block.preferred_top_padding.present?
209
+ if block.respond_to?(:preferred_bottom_padding) && block.preferred_bottom_padding.present?
210
+ styles['padding-bottom'] = "#{block.preferred_bottom_padding}px"
211
+ end
212
+ styles['text-transform'] = :uppercase if theme_setting('headings_uppercase') && block.type == 'heading'
213
+ styles['background-color'] = if block.respond_to?(:preferred_background_color) && block.preferred_background_color.present?
214
+ block.preferred_background_color
215
+ else
216
+ 'var(--section-background)'
217
+ end
218
+
219
+ if block.respond_to?(:preferred_button_background_color) && block.preferred_button_background_color.present?
220
+ styles['--button-background-color'] = block.preferred_button_background_color
221
+ end
222
+ if block.respond_to?(:preferred_button_text_color) && block.preferred_button_text_color.present?
223
+ styles['--button-text-color'] = block.preferred_button_text_color
224
+ end
225
+
226
+ styles = styles.compact_blank
227
+ styles = styles.slice(*allowed_styles) if allowed_styles != :all
228
+
229
+ styles.map { |k, v| "#{k}: #{v}" }.join(';')
230
+ end
231
+
232
+ def block_background_color_style(block)
233
+ return nil unless block.respond_to?(:preferred_background_color) && block.preferred_background_color.present?
234
+
235
+ "background-color: #{block.preferred_background_color};"
236
+ end
237
+
238
+ def block_css_classes(block)
239
+ classes = []
240
+ classes << "justify-#{block.preferred_justify}" if block.respond_to?(:preferred_justify) && block.preferred_justify.present?
241
+ classes.join(',')
242
+ end
243
+ end
244
+ end
@@ -0,0 +1,13 @@
1
+ module Spree
2
+ module TurboHelper
3
+ def spree_turbo_update_flashes
4
+ turbo_stream.update 'flash' do
5
+ render 'spree/shared/flashes'
6
+ end
7
+ end
8
+
9
+ def spree_turbo_update_cart(order = current_order)
10
+ turbo_stream.update_all '.cart-counter', order.item_count.positive? ? order.item_count : ''
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Spree
2
+ module TurboStreamActionsHelper
3
+ def slideover_open(slideover_name, target)
4
+ turbo_stream_action_tag "#{slideover_name}:open", target: target
5
+ end
6
+
7
+ def search_suggestions_close
8
+ turbo_stream_action_tag 'search-suggestions:close'
9
+ end
10
+
11
+ ::Turbo::Streams::TagBuilder.prepend(self)
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ module Spree
2
+ module WishlistHelper
3
+ def current_wishlist
4
+ @current_wishlist ||= try_spree_current_user&.default_wishlist_for_store(current_store)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,156 @@
1
+ import '@hotwired/turbo-rails'
2
+ import { Application } from '@hotwired/stimulus'
3
+
4
+ let application
5
+
6
+ if (typeof window.Stimulus === "undefined") {
7
+ application = Application.start()
8
+ application.debug = false
9
+ window.Stimulus = application
10
+ } else {
11
+ application = window.Stimulus
12
+ }
13
+
14
+ import { Alert, Toggle } from 'tailwindcss-stimulus-components'
15
+ application.register('alert', Alert)
16
+ application.register('toggle', Toggle)
17
+
18
+
19
+ // We need to preload the carousel controller, otherwise it causes a huge layout shift when it's loaded.
20
+ import CarouselController from 'spree/storefront/controllers/carousel_controller'
21
+ application.register('carousel', CarouselController)
22
+
23
+ // We need to make allow list of controllers to be loaded, this is needed because by default Stimulus will try to load all the controllers that it encounters in the DOM.
24
+ // Since Spree Storefront can be extended with custom views/partials, we need to be able to control which controllers can be loaded from our application.
25
+
26
+ const controllers = [
27
+ 'accordion',
28
+ 'account-nav',
29
+ 'address-autocomplete',
30
+ 'address-form',
31
+ 'auto-submit',
32
+ 'card-validation',
33
+ 'cart',
34
+ 'checkout-address-book',
35
+ 'checkout-delivery',
36
+ 'checkout-promotions',
37
+ 'checkout-summary',
38
+ 'clear-input',
39
+ 'copy-input',
40
+ 'dropdown',
41
+ 'enable-button',
42
+ 'header',
43
+ 'infinite-scroll',
44
+ 'lightbox',
45
+ 'mobile-nav',
46
+ 'modal',
47
+ 'no-ui-slider',
48
+ 'pdp-desktop-gallery',
49
+ 'plp-variant-picker',
50
+ 'product-form',
51
+ 'quantity-picker',
52
+ 'read-more',
53
+ 'reveal',
54
+ 'scroll-to',
55
+ 'search-suggestions',
56
+ 'searchable-list',
57
+ 'slideover-account',
58
+ 'slideover',
59
+ 'sticky-button',
60
+ 'toggle-menu',
61
+ 'turbo-stream-form',
62
+ 'wished-item',
63
+ ]
64
+
65
+
66
+ // Manifest is needed to load controllers that names don't match the controller filename, or are not in the controllers directory.
67
+ const manifest = {
68
+ "auto-submit": "@stimulus-components/auto-submit",
69
+ "address-form": "spree/core/controllers/address_form_controller",
70
+ "address-autocomplete": "spree/core/controllers/address_autocomplete_controller",
71
+ "enable-button": "spree/core/controllers/enable_button_controller",
72
+ "slideover-account": "spree/storefront/controllers/slideover_controller",
73
+ "reveal": "stimulus-reveal-controller",
74
+ "scroll-to": "stimulus-scroll-to",
75
+ "read-more": "stimulus-read-more",
76
+ }
77
+
78
+ import { lazyLoadControllersFromManifest } from "spree/storefront/helpers/lazy_load_controllers_with_manifest"
79
+
80
+ lazyLoadControllersFromManifest(controllers, "spree/storefront/controllers", application, manifest)
81
+
82
+
83
+ const scrollToOverlay = (overlay) => {
84
+ const { top, left } = overlay.getBoundingClientRect()
85
+
86
+ window.scroll({
87
+ behavior: 'smooth',
88
+ top: window.scrollY + top - window.innerHeight / 2 + overlay.offsetHeight / 2,
89
+ left: left + window.scrollX
90
+ })
91
+ }
92
+
93
+ // page builder UI
94
+ const toggleHighlightEditorOverlay = (query) => {
95
+ const overlay = document.querySelector(query)
96
+
97
+ if (overlay) {
98
+ if (overlay.classList.contains('editor-overlay-hover')) {
99
+ overlay.classList.remove('editor-overlay-hover')
100
+ } else {
101
+ overlay.classList.add('editor-overlay-hover')
102
+
103
+ scrollToOverlay(overlay)
104
+ }
105
+ }
106
+ }
107
+
108
+
109
+ const makeOverlayActive = (id) => {
110
+ const overlay = document.querySelector(`.editor-overlay[data-editor-id="${id}"]`)
111
+
112
+ document.querySelectorAll('.editor-overlay-active').forEach((el) => {
113
+ el.classList.remove('editor-overlay-active')
114
+ })
115
+
116
+ if (overlay) {
117
+ overlay.classList.add('editor-overlay-active')
118
+ scrollToOverlay(overlay)
119
+ }
120
+ }
121
+
122
+ const toggleHighlightElement = (id) => {
123
+ toggleHighlightEditorOverlay(`.editor-overlay[data-editor-id="${id}"]`)
124
+ }
125
+
126
+ window.scrollToOverlay = scrollToOverlay
127
+ window.toggleHighlightElement = toggleHighlightElement
128
+ window.makeOverlayActive = makeOverlayActive
129
+
130
+ document.addEventListener('turbo:submit-start', () => {
131
+ Turbo.navigator.delegate.adapter.progressBar.setValue(0)
132
+ Turbo.navigator.delegate.adapter.progressBar.show()
133
+ })
134
+
135
+ document.addEventListener('turbo:submit-end', () => {
136
+ Turbo.navigator.delegate.adapter.progressBar.setValue(100)
137
+ Turbo.navigator.delegate.adapter.progressBar.hide()
138
+ })
139
+
140
+ function replaceCsrfMetaTags() {
141
+ const csrfMetaTagsTemplate = document.querySelector('template#csrf_meta_tags')
142
+ if (!csrfMetaTagsTemplate) return
143
+
144
+ const csrfMetaTags = csrfMetaTagsTemplate.content.cloneNode(true)
145
+
146
+ document.head.querySelectorAll('meta[name="csrf-token"]').forEach((tag) => tag.remove())
147
+ document.head.querySelectorAll('meta[name="csrf-param"]').forEach((tag) => tag.remove())
148
+
149
+ document.head.appendChild(csrfMetaTags)
150
+ }
151
+
152
+ if (document.readyState === 'loading') {
153
+ document.addEventListener('DOMContentLoaded', replaceCsrfMetaTags)
154
+ } else {
155
+ replaceCsrfMetaTags()
156
+ }
@@ -0,0 +1,25 @@
1
+ import AccordionController from '@kanety/stimulus-accordion'
2
+
3
+ export default class extends AccordionController {
4
+ static values = {
5
+ storeKey: String,
6
+ closeOthers: Boolean
7
+ }
8
+
9
+ toggle(e) {
10
+ const closeOthers = this.hasCloseOthersValue ? this.closeOthersValue : true
11
+ this.togglers.forEach((toggler) => {
12
+ if (toggler.contains(e.target)) {
13
+ if (this.isOpened(toggler)) {
14
+ this.close(toggler)
15
+ } else {
16
+ this.open(toggler)
17
+ }
18
+ } else if (this.isOpened(toggler) && closeOthers) {
19
+ this.close(toggler)
20
+ }
21
+ })
22
+
23
+ e.preventDefault()
24
+ }
25
+ }
@@ -0,0 +1,10 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ connect() {
5
+ this.element.querySelector('[data-active=true]').scrollIntoView({
6
+ block: 'nearest',
7
+ inline: 'center'
8
+ })
9
+ }
10
+ }
@@ -0,0 +1,103 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+ import valid from "card-validator"
3
+
4
+ export default class extends Controller {
5
+ static targets = ["number", "expiry", "cvv", "typeContainer", "ccType"]
6
+
7
+ connect() {
8
+ this.numberTarget.addEventListener('input', this.validateCard.bind(this))
9
+ this.expiryTarget.addEventListener('input', this.validateExpiry.bind(this))
10
+ this.cvvTarget.addEventListener('input', this.validateCVV.bind(this))
11
+ }
12
+
13
+ validateCard(event) {
14
+ let value = event.target.value.replace(/\D/g, '')
15
+ const validation = valid.number(value)
16
+
17
+ // Format the card number with spaces
18
+ if (validation.card) {
19
+ const gaps = validation.card.gaps
20
+ let formatted = ''
21
+ let currentPosition = 0
22
+
23
+ // Add spaces based on the card type's gap positions
24
+ for (let i = 0; i < value.length; i++) {
25
+ if (gaps.includes(i)) {
26
+ formatted += ' '
27
+ }
28
+ formatted += value[i]
29
+ }
30
+
31
+ // Update input value with formatted number
32
+ event.target.value = formatted.trim()
33
+ } else {
34
+ // Default formatting for unknown card types (4 digit groups)
35
+ event.target.value = value.replace(/(.{4})/g, '$1 ').trim()
36
+ }
37
+
38
+ if (validation.isPotentiallyValid) {
39
+ event.target.classList.remove('invalid')
40
+ } else {
41
+ event.target.classList.add('invalid')
42
+ }
43
+
44
+ if (validation.card) {
45
+ // Update CVV validation length based on card type
46
+ this.cvvTarget.setAttribute('maxlength', validation.card.code.size)
47
+
48
+ // Update card type field and icon
49
+ const cardType = validation.card.type
50
+ this.ccTypeTarget.value = cardType.replace(/-/g, '_')
51
+ this.updateCardIcon(cardType)
52
+ } else {
53
+ this.ccTypeTarget.value = ''
54
+ this.typeContainerTarget.innerHTML = ''
55
+ }
56
+ }
57
+
58
+ updateCardIcon(cardType) {
59
+ const iconElement = document.getElementById(`credit-card-icon-${cardType}`)
60
+ if (iconElement) {
61
+ this.typeContainerTarget.innerHTML = iconElement.innerHTML
62
+ } else {
63
+ this.typeContainerTarget.innerHTML = ''
64
+ }
65
+ }
66
+
67
+ validateExpiry(event) {
68
+ let input = event.target.value.replace(/\D/g, '').substring(0, 6)
69
+
70
+ // Format as MM/YYYY
71
+ if (input.length > 2) {
72
+ input = input.substring(0, 2) + '/' + input.substring(2)
73
+ }
74
+
75
+ // Validate month
76
+ const monthValue = parseInt(input.substring(0, 2))
77
+ if (monthValue > 12) {
78
+ input = '12' + input.substring(2)
79
+ }
80
+
81
+ event.target.value = input
82
+
83
+ const [month, year] = input.split('/')
84
+ const validation = valid.expirationDate({ month, year })
85
+
86
+ if (validation.isPotentiallyValid) {
87
+ event.target.classList.remove('invalid')
88
+ } else {
89
+ event.target.classList.add('invalid')
90
+ }
91
+ }
92
+
93
+ validateCVV(event) {
94
+ const cvv = event.target.value
95
+ const validation = valid.cvv(cvv)
96
+
97
+ if (validation.isPotentiallyValid) {
98
+ event.target.classList.remove('invalid')
99
+ } else {
100
+ event.target.classList.add('invalid')
101
+ }
102
+ }
103
+ }
@@ -0,0 +1,44 @@
1
+ import Carousel from '@stimulus-components/carousel'
2
+
3
+ export default class extends Carousel {
4
+ static targets = ['pagination']
5
+
6
+ get defaultOptions() {
7
+ const setStyle = (el, display) => {
8
+ if (Array.isArray(el)) {
9
+ el.forEach((cEl) => (cEl.style.display = display))
10
+ } else {
11
+ el.style.display = display
12
+ }
13
+ }
14
+
15
+ return Object.assign(super.defaultOptions, {
16
+ pagination: {
17
+ el: this.hasPaginationTarget ? this.paginationTarget : undefined
18
+ },
19
+ on: {
20
+ // Hide the arrow buttons if there are not needed
21
+ init: function () {
22
+ if (this.navigation.prevEl && this.navigation.nextEl) {
23
+ if (!this.allowSlidePrev && !this.allowSlideNext) {
24
+ setStyle(this.navigation.prevEl, 'none')
25
+ setStyle(this.navigation.nextEl, 'none')
26
+ }
27
+ }
28
+ },
29
+ resize: function () {
30
+ if (this.navigation.prevEl && this.navigation.nextEl) {
31
+ if (!this.allowSlidePrev && !this.allowSlideNext) {
32
+ setStyle(this.navigation.prevEl, 'none')
33
+ setStyle(this.navigation.nextEl, 'none')
34
+ } else {
35
+ // Let class hide/show the arrows
36
+ setStyle(this.navigation.prevEl, null)
37
+ setStyle(this.navigation.nextEl, null)
38
+ }
39
+ }
40
+ }
41
+ }
42
+ })
43
+ }
44
+ }
@@ -0,0 +1,10 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ static targets = ['container', 'spinner']
5
+
6
+ disableCart() {
7
+ this.containerTarget.classList.add('pointer-events-none', 'opacity-50')
8
+ this.spinnerTarget.classList.remove('hidden')
9
+ }
10
+ }
@@ -0,0 +1,28 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ static targets = ["list", "newAddressForm", "addressId", "submit"]
5
+
6
+ select(event) {
7
+ const radio = event.target
8
+ if (radio.value == 0) {
9
+ this.newAddressFormTarget.classList.remove('hidden')
10
+ this.addressIdTarget.value = null
11
+ this.submitTarget.setAttribute('disabled', true)
12
+ } else {
13
+ this.newAddressFormTarget.classList.add('hidden')
14
+ this.addressIdTarget.value = radio.value
15
+ this.submitTarget.removeAttribute('disabled')
16
+ }
17
+
18
+ Array.from(document.getElementsByClassName('address-book-actions')).forEach(
19
+ (item) => item.classList.add('hidden')
20
+ )
21
+ const actions = Array.from(
22
+ radio.parentElement.getElementsByClassName('address-book-actions')
23
+ )
24
+ if (actions.length > 0) {
25
+ actions[0].classList.remove('hidden')
26
+ }
27
+ }
28
+ }