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.
- checksums.yaml +7 -0
- data/LICENSE.md +13 -0
- data/Rakefile +15 -0
- data/app/assets/config/spree_storefront_manifest.js +6 -0
- data/app/assets/stylesheets/storefront_page_builder.css +51 -0
- data/app/controllers/concerns/spree/cart_methods.rb +40 -0
- data/app/controllers/concerns/spree/locale_urls.rb +23 -0
- data/app/controllers/concerns/spree/password_protected.rb +17 -0
- data/app/controllers/concerns/spree/theme_concern.rb +29 -0
- data/app/controllers/spree/account/addresses_controller.rb +16 -0
- data/app/controllers/spree/account/base_controller.rb +20 -0
- data/app/controllers/spree/account/newsletter_controller.rb +34 -0
- data/app/controllers/spree/account/orders_controller.rb +34 -0
- data/app/controllers/spree/account/profile_controller.rb +23 -0
- data/app/controllers/spree/account/store_credits_controller.rb +23 -0
- data/app/controllers/spree/account/wished_items_controller.rb +45 -0
- data/app/controllers/spree/addresses_controller.rb +101 -0
- data/app/controllers/spree/checkout_controller.rb +365 -0
- data/app/controllers/spree/contacts_controller.rb +46 -0
- data/app/controllers/spree/digital_links_controller.rb +48 -0
- data/app/controllers/spree/home_controller.rb +5 -0
- data/app/controllers/spree/line_items_controller.rb +96 -0
- data/app/controllers/spree/newsletter_subscribers_controller.rb +43 -0
- data/app/controllers/spree/order_status_controller.rb +32 -0
- data/app/controllers/spree/orders_controller.rb +104 -0
- data/app/controllers/spree/page_sections_controller.rb +17 -0
- data/app/controllers/spree/pages_controller.rb +13 -0
- data/app/controllers/spree/password_controller.rb +21 -0
- data/app/controllers/spree/policies_controller.rb +17 -0
- data/app/controllers/spree/posts_controller.rb +76 -0
- data/app/controllers/spree/products_controller.rb +99 -0
- data/app/controllers/spree/search_controller.rb +39 -0
- data/app/controllers/spree/seo_controller.rb +25 -0
- data/app/controllers/spree/settings_controller.rb +68 -0
- data/app/controllers/spree/store_controller.rb +247 -0
- data/app/controllers/spree/taxonomies_controller.rb +30 -0
- data/app/controllers/spree/taxons_controller.rb +46 -0
- data/app/controllers/spree/wishlists_controller.rb +19 -0
- data/app/finders/spree/storefront/variant_finder.rb +80 -0
- data/app/helpers/spree/analytics_helper.rb +28 -0
- data/app/helpers/spree/cart_helper.rb +48 -0
- data/app/helpers/spree/checkout_analytics_helper.rb +77 -0
- data/app/helpers/spree/checkout_helper.rb +58 -0
- data/app/helpers/spree/filters_helper.rb +180 -0
- data/app/helpers/spree/fonts_helper.rb +58 -0
- data/app/helpers/spree/orders_helper.rb +7 -0
- data/app/helpers/spree/page_helper.rb +67 -0
- data/app/helpers/spree/posts_helper.rb +42 -0
- data/app/helpers/spree/products_helper.rb +205 -0
- data/app/helpers/spree/storefront_helper.rb +86 -0
- data/app/helpers/spree/storefront_locale_helper.rb +42 -0
- data/app/helpers/spree/theme_helper.rb +244 -0
- data/app/helpers/spree/turbo_helper.rb +13 -0
- data/app/helpers/spree/turbo_stream_actions_helper.rb +13 -0
- data/app/helpers/spree/wishlist_helper.rb +7 -0
- data/app/javascript/spree/storefront/application.js +156 -0
- data/app/javascript/spree/storefront/controllers/accordion_controller.js +25 -0
- data/app/javascript/spree/storefront/controllers/account_nav_controller.js +10 -0
- data/app/javascript/spree/storefront/controllers/card_validation_controller.js +103 -0
- data/app/javascript/spree/storefront/controllers/carousel_controller.js +44 -0
- data/app/javascript/spree/storefront/controllers/cart_controller.js +10 -0
- data/app/javascript/spree/storefront/controllers/checkout_address_book_controller.js +28 -0
- data/app/javascript/spree/storefront/controllers/checkout_delivery_controller.js +39 -0
- data/app/javascript/spree/storefront/controllers/checkout_promotions_controller.js +28 -0
- data/app/javascript/spree/storefront/controllers/checkout_summary_controller.js +46 -0
- data/app/javascript/spree/storefront/controllers/clear_input_controller.js +23 -0
- data/app/javascript/spree/storefront/controllers/copy_input_controller.js +19 -0
- data/app/javascript/spree/storefront/controllers/dropdown_controller.js +14 -0
- data/app/javascript/spree/storefront/controllers/header_controller.js +33 -0
- data/app/javascript/spree/storefront/controllers/infinite_scroll_controller.js +31 -0
- data/app/javascript/spree/storefront/controllers/lightbox_controller.js +138 -0
- data/app/javascript/spree/storefront/controllers/mobile_nav_controller.js +17 -0
- data/app/javascript/spree/storefront/controllers/modal_controller.js +15 -0
- data/app/javascript/spree/storefront/controllers/no_ui_slider_controller.js +55 -0
- data/app/javascript/spree/storefront/controllers/pdp_desktop_gallery_controller.js +28 -0
- data/app/javascript/spree/storefront/controllers/plp_variant_picker_controller.js +151 -0
- data/app/javascript/spree/storefront/controllers/product_form_controller.js +136 -0
- data/app/javascript/spree/storefront/controllers/quantity_picker_controller.js +43 -0
- data/app/javascript/spree/storefront/controllers/search_suggestions_controller.js +61 -0
- data/app/javascript/spree/storefront/controllers/searchable_list_controller.js +25 -0
- data/app/javascript/spree/storefront/controllers/slideover_controller.js +40 -0
- data/app/javascript/spree/storefront/controllers/sticky_button_controller.js +32 -0
- data/app/javascript/spree/storefront/controllers/toggle_menu_controller.js +32 -0
- data/app/javascript/spree/storefront/controllers/turbo_stream_form_controller.js +51 -0
- data/app/javascript/spree/storefront/controllers/wished_item_controller.js +69 -0
- data/app/javascript/spree/storefront/helpers/lazy_load_controllers_with_manifest.js +78 -0
- data/app/javascript/spree/storefront/helpers/show_flash_message.js +25 -0
- data/app/models/spree/color_names.rb +35 -0
- data/app/models/spree/contact.rb +24 -0
- data/app/presenters/spree/colors_preview_styles_presenter.rb +84 -0
- data/app/presenters/spree/featured_product_presenter.rb +42 -0
- data/app/presenters/spree/mega_nav_presenter.rb +55 -0
- data/app/views/devise/passwords/edit.html.erb +22 -0
- data/app/views/devise/passwords/new.html.erb +16 -0
- data/app/views/devise/registrations/_form.html.erb +21 -0
- data/app/views/devise/registrations/edit.html.erb +24 -0
- data/app/views/devise/registrations/new.html.erb +27 -0
- data/app/views/devise/sessions/new.html.erb +25 -0
- data/app/views/devise/shared/_links.html.erb +22 -0
- data/app/views/layouts/spree/checkout.html.erb +58 -0
- data/app/views/layouts/spree/password.html.erb +34 -0
- data/app/views/layouts/spree/storefront.html.erb +38 -0
- data/app/views/spree/account/wished_items/create.turbo_stream.erb +8 -0
- data/app/views/spree/account/wished_items/destroy.turbo_stream.erb +20 -0
- data/app/views/spree/addresses/destroy.turbo_stream.erb +1 -0
- data/app/views/spree/addresses/edit.html.erb +57 -0
- data/app/views/spree/addresses/new.html.erb +71 -0
- data/app/views/spree/checkout/_address.html.erb +153 -0
- data/app/views/spree/checkout/_button_processing.html.erb +7 -0
- data/app/views/spree/checkout/_coupon_code.html.erb +55 -0
- data/app/views/spree/checkout/_credit_card.html.erb +12 -0
- data/app/views/spree/checkout/_delivery.html.erb +70 -0
- data/app/views/spree/checkout/_line_item.html.erb +26 -0
- data/app/views/spree/checkout/_line_items.html.erb +7 -0
- data/app/views/spree/checkout/_missing_all_line_items.html.erb +17 -0
- data/app/views/spree/checkout/_missing_line_items.html.erb +28 -0
- data/app/views/spree/checkout/_payment.html.erb +35 -0
- data/app/views/spree/checkout/_payment_methods.html.erb +72 -0
- data/app/views/spree/checkout/_payment_sources.html.erb +24 -0
- data/app/views/spree/checkout/_quick_checkout.html.erb +1 -0
- data/app/views/spree/checkout/_sidebar.html.erb +34 -0
- data/app/views/spree/checkout/_store_credit.html.erb +21 -0
- data/app/views/spree/checkout/_summary.html.erb +116 -0
- data/app/views/spree/checkout/_user_account.html.erb +9 -0
- data/app/views/spree/checkout/apply_coupon_code.turbo_stream.erb +45 -0
- data/app/views/spree/checkout/apply_store_credit.turbo_stream.erb +19 -0
- data/app/views/spree/checkout/edit.html.erb +98 -0
- data/app/views/spree/checkout/payment/_check.html.erb +0 -0
- data/app/views/spree/checkout/payment/_gateway.html.erb +74 -0
- data/app/views/spree/checkout/payment/_store_credit.html.erb +13 -0
- data/app/views/spree/checkout/remove_coupon_code.turbo_stream.erb +34 -0
- data/app/views/spree/checkout/remove_store_credit.turbo_stream.erb +19 -0
- data/app/views/spree/checkout/update.turbo_stream.erb +25 -0
- data/app/views/spree/home/index.html.erb +1 -0
- data/app/views/spree/line_items/create.turbo_stream.erb +13 -0
- data/app/views/spree/line_items/destroy.turbo_stream.erb +11 -0
- data/app/views/spree/line_items/update.turbo_stream.erb +10 -0
- data/app/views/spree/newsletter_subscribers/create.turbo_stream.erb +7 -0
- data/app/views/spree/order_status/new.html.erb +16 -0
- data/app/views/spree/page_sections/show.html.erb +3 -0
- data/app/views/spree/pages/show.html.erb +1 -0
- data/app/views/spree/password/show.html.erb +1 -0
- data/app/views/spree/posts/index.html.erb +1 -0
- data/app/views/spree/posts/related_products.html.erb +7 -0
- data/app/views/spree/posts/show.html.erb +1 -0
- data/app/views/spree/products/index.html.erb +1 -0
- data/app/views/spree/products/index.turbo_stream.erb +1 -0
- data/app/views/spree/products/related.html.erb +3 -0
- data/app/views/spree/products/show.html.erb +1 -0
- data/app/views/spree/search/show.html.erb +6 -0
- data/app/views/spree/search/show.turbo_stream.erb +1 -0
- data/app/views/spree/search/suggestions.turbo_stream.erb +8 -0
- data/app/views/spree/seo/robots.text.erb +31 -0
- data/app/views/spree/seo/sitemap.xml.erb +25 -0
- data/app/views/spree/shared/_fonts.html.erb +14 -0
- data/app/views/spree/shared/_head.html.erb +36 -0
- data/app/views/spree/shared/_load_more_products.turbo_stream.erb +7 -0
- data/app/views/spree/shared/_product_listing_page.html.erb +11 -0
- data/app/views/spree/shared/_products.html.erb +1 -0
- data/app/views/spree/taxonomies/show.html.erb +1 -0
- data/app/views/spree/taxons/show.html.erb +1 -0
- data/app/views/spree/taxons/show.turbo_stream.erb +1 -0
- data/app/views/spree/waitlists/create.turbo_stream.erb +9 -0
- data/app/views/themes/default/kaminari/storefront/_first_page.html.erb +8 -0
- data/app/views/themes/default/kaminari/storefront/_gap.html.erb +8 -0
- data/app/views/themes/default/kaminari/storefront/_last_page.html.erb +8 -0
- data/app/views/themes/default/kaminari/storefront/_next_page.html.erb +13 -0
- data/app/views/themes/default/kaminari/storefront/_page.html.erb +10 -0
- data/app/views/themes/default/kaminari/storefront/_paginator.html.erb +27 -0
- data/app/views/themes/default/kaminari/storefront/_prev_page.html.erb +13 -0
- data/app/views/themes/default/spree/account/_account_nav.html.erb +46 -0
- data/app/views/themes/default/spree/account/_order.html.erb +39 -0
- data/app/views/themes/default/spree/account/_orders.html.erb +16 -0
- data/app/views/themes/default/spree/account/addresses/_address.html.erb +42 -0
- data/app/views/themes/default/spree/account/addresses/index.html.erb +28 -0
- data/app/views/themes/default/spree/account/newsletter/_newsletter_settings.html.erb +13 -0
- data/app/views/themes/default/spree/account/newsletter/edit.html.erb +16 -0
- data/app/views/themes/default/spree/account/newsletter/update.html.erb +1 -0
- data/app/views/themes/default/spree/account/orders/index.html.erb +24 -0
- data/app/views/themes/default/spree/account/orders/show.html.erb +22 -0
- data/app/views/themes/default/spree/account/profile/edit.html.erb +36 -0
- data/app/views/themes/default/spree/account/store_credits/_store_credit_event.html.erb +29 -0
- data/app/views/themes/default/spree/account/store_credits/index.html.erb +31 -0
- data/app/views/themes/default/spree/checkout/_footer.html.erb +10 -0
- data/app/views/themes/default/spree/checkout/complete.html.erb +84 -0
- data/app/views/themes/default/spree/contacts/new.html.erb +23 -0
- data/app/views/themes/default/spree/orders/_cart.html.erb +14 -0
- data/app/views/themes/default/spree/orders/_empty.html.erb +11 -0
- data/app/views/themes/default/spree/orders/_line_item.html.erb +47 -0
- data/app/views/themes/default/spree/orders/_line_item_quantity.html.erb +11 -0
- data/app/views/themes/default/spree/orders/_summary.html.erb +41 -0
- data/app/views/themes/default/spree/orders/edit.html.erb +18 -0
- data/app/views/themes/default/spree/orders/show.html.erb +6 -0
- data/app/views/themes/default/spree/page_sections/_announcement_bar.html.erb +10 -0
- data/app/views/themes/default/spree/page_sections/_custom_code.html.erb +5 -0
- data/app/views/themes/default/spree/page_sections/_featured_product.html.erb +136 -0
- data/app/views/themes/default/spree/page_sections/_featured_taxon.html.erb +116 -0
- data/app/views/themes/default/spree/page_sections/_featured_taxons.html.erb +71 -0
- data/app/views/themes/default/spree/page_sections/_footer.html.erb +62 -0
- data/app/views/themes/default/spree/page_sections/_header.html.erb +166 -0
- data/app/views/themes/default/spree/page_sections/_image_banner.html.erb +57 -0
- data/app/views/themes/default/spree/page_sections/_image_with_text.html.erb +66 -0
- data/app/views/themes/default/spree/page_sections/_main_password_footer.html.erb +64 -0
- data/app/views/themes/default/spree/page_sections/_main_password_header.html.erb +54 -0
- data/app/views/themes/default/spree/page_sections/_newsletter.html.erb +47 -0
- data/app/views/themes/default/spree/page_sections/_page_title.html.erb +7 -0
- data/app/views/themes/default/spree/page_sections/_post_details.html.erb +19 -0
- data/app/views/themes/default/spree/page_sections/_post_grid.html.erb +11 -0
- data/app/views/themes/default/spree/page_sections/_product_details.html.erb +102 -0
- data/app/views/themes/default/spree/page_sections/_product_grid.html.erb +52 -0
- data/app/views/themes/default/spree/page_sections/_related_products.html.erb +15 -0
- data/app/views/themes/default/spree/page_sections/_rich_text.html.erb +18 -0
- data/app/views/themes/default/spree/page_sections/_taxon_banner.html.erb +37 -0
- data/app/views/themes/default/spree/page_sections/_taxon_grid.html.erb +103 -0
- data/app/views/themes/default/spree/page_sections/_video.html.erb +27 -0
- data/app/views/themes/default/spree/page_sections/nav/_desktop.html.erb +49 -0
- data/app/views/themes/default/spree/page_sections/nav/_mobile.html.erb +136 -0
- data/app/views/themes/default/spree/policies/show.html.erb +11 -0
- data/app/views/themes/default/spree/posts/_json_ld.html.erb +20 -0
- data/app/views/themes/default/spree/posts/_pagination.html.erb +1 -0
- data/app/views/themes/default/spree/posts/_post.html.erb +13 -0
- data/app/views/themes/default/spree/products/_add_to_cart_button.html.erb +58 -0
- data/app/views/themes/default/spree/products/_add_to_waitlist.html.erb +36 -0
- data/app/views/themes/default/spree/products/_add_to_wishlist.html.erb +33 -0
- data/app/views/themes/default/spree/products/_breadcrumbs.html.erb +23 -0
- data/app/views/themes/default/spree/products/_color_picker.html.erb +19 -0
- data/app/views/themes/default/spree/products/_color_swatches.html.erb +61 -0
- data/app/views/themes/default/spree/products/_details.html.erb +55 -0
- data/app/views/themes/default/spree/products/_featured_image.html.erb +37 -0
- data/app/views/themes/default/spree/products/_filters.html.erb +45 -0
- data/app/views/themes/default/spree/products/_json_ld.html.erb +38 -0
- data/app/views/themes/default/spree/products/_json_ld_list.html.erb +9 -0
- data/app/views/themes/default/spree/products/_json_ld_variant.html.erb +10 -0
- data/app/views/themes/default/spree/products/_label.html.erb +26 -0
- data/app/views/themes/default/spree/products/_media_gallery.html.erb +94 -0
- data/app/views/themes/default/spree/products/_price.html.erb +59 -0
- data/app/views/themes/default/spree/products/_product.html.erb +62 -0
- data/app/views/themes/default/spree/products/_quantity_selector.html.erb +32 -0
- data/app/views/themes/default/spree/products/_returns_policy_modal.html.erb +22 -0
- data/app/views/themes/default/spree/products/_show_more_button.html.erb +8 -0
- data/app/views/themes/default/spree/products/_sort.html.erb +45 -0
- data/app/views/themes/default/spree/products/_swiper.html.erb +85 -0
- data/app/views/themes/default/spree/products/_tags.html.erb +0 -0
- data/app/views/themes/default/spree/products/_variant_options.html.erb +71 -0
- data/app/views/themes/default/spree/products/_variant_picker.html.erb +50 -0
- data/app/views/themes/default/spree/products/filters/_availability.html.erb +32 -0
- data/app/views/themes/default/spree/products/filters/_colors.html.erb +23 -0
- data/app/views/themes/default/spree/products/filters/_generic.html.erb +75 -0
- data/app/views/themes/default/spree/products/filters/_price.html.erb +35 -0
- data/app/views/themes/default/spree/products/filters/_taxons.erb +78 -0
- data/app/views/themes/default/spree/search/_suggestions.html.erb +92 -0
- data/app/views/themes/default/spree/settings/show.html.erb +32 -0
- data/app/views/themes/default/spree/shared/_account_pane.html.erb +28 -0
- data/app/views/themes/default/spree/shared/_address.html.erb +35 -0
- data/app/views/themes/default/spree/shared/_cart_icon.html.erb +13 -0
- data/app/views/themes/default/spree/shared/_cart_pane.html.erb +38 -0
- data/app/views/themes/default/spree/shared/_css_variables.html.erb +54 -0
- data/app/views/themes/default/spree/shared/_custom_head.html.erb +0 -0
- data/app/views/themes/default/spree/shared/_error_messages.html.erb +9 -0
- data/app/views/themes/default/spree/shared/_error_messages_without_base_attribute.html.erb +15 -0
- data/app/views/themes/default/spree/shared/_flash.html.erb +16 -0
- data/app/views/themes/default/spree/shared/_flashes.html.erb +10 -0
- data/app/views/themes/default/spree/shared/_json_ld.html.erb +32 -0
- data/app/views/themes/default/spree/shared/_line_item_options.html.erb +18 -0
- data/app/views/themes/default/spree/shared/_logo.html.erb +42 -0
- data/app/views/themes/default/spree/shared/_meta_tags.html.erb +45 -0
- data/app/views/themes/default/spree/shared/_order_details.html.erb +106 -0
- data/app/views/themes/default/spree/shared/_order_line_item.html.erb +65 -0
- data/app/views/themes/default/spree/shared/_order_shipment.html.erb +71 -0
- data/app/views/themes/default/spree/shared/_search.html.erb +32 -0
- data/app/views/themes/default/spree/shared/_title.html.erb +3 -0
- data/app/views/themes/default/spree/shared/_wishlist_icon.html.erb +13 -0
- data/app/views/themes/default/spree/shared/icons/_account.html.erb +17 -0
- data/app/views/themes/default/spree/shared/icons/_arrow-left.html.erb +8 -0
- data/app/views/themes/default/spree/shared/icons/_arrow-right.html.erb +3 -0
- data/app/views/themes/default/spree/shared/icons/_bell.html.erb +9 -0
- data/app/views/themes/default/spree/shared/icons/_cart.html.erb +10 -0
- data/app/views/themes/default/spree/shared/icons/_cart_48.html.erb +6 -0
- data/app/views/themes/default/spree/shared/icons/_check.html.erb +4 -0
- data/app/views/themes/default/spree/shared/icons/_chevron.html.erb +15 -0
- data/app/views/themes/default/spree/shared/icons/_chevron_down.html.erb +5 -0
- data/app/views/themes/default/spree/shared/icons/_chevron_right.html.erb +15 -0
- data/app/views/themes/default/spree/shared/icons/_chevron_up.html.erb +3 -0
- data/app/views/themes/default/spree/shared/icons/_close.html.erb +9 -0
- data/app/views/themes/default/spree/shared/icons/_cross.html.erb +16 -0
- data/app/views/themes/default/spree/shared/icons/_delete.html.erb +3 -0
- data/app/views/themes/default/spree/shared/icons/_delivery.html.erb +5 -0
- data/app/views/themes/default/spree/shared/icons/_disabled.html.erb +13 -0
- data/app/views/themes/default/spree/shared/icons/_edit.html.erb +3 -0
- data/app/views/themes/default/spree/shared/icons/_facebook.html.erb +16 -0
- data/app/views/themes/default/spree/shared/icons/_filter.html.erb +8 -0
- data/app/views/themes/default/spree/shared/icons/_heart.html.erb +12 -0
- data/app/views/themes/default/spree/shared/icons/_info.html.erb +7 -0
- data/app/views/themes/default/spree/shared/icons/_instagram.html.erb +18 -0
- data/app/views/themes/default/spree/shared/icons/_lock.html.erb +13 -0
- data/app/views/themes/default/spree/shared/icons/_menu.html.erb +10 -0
- data/app/views/themes/default/spree/shared/icons/_minus.html.erb +5 -0
- data/app/views/themes/default/spree/shared/icons/_pinch.html.erb +6 -0
- data/app/views/themes/default/spree/shared/icons/_pinterest.html.erb +8 -0
- data/app/views/themes/default/spree/shared/icons/_plus.html.erb +17 -0
- data/app/views/themes/default/spree/shared/icons/_return.html.erb +11 -0
- data/app/views/themes/default/spree/shared/icons/_search.html.erb +17 -0
- data/app/views/themes/default/spree/shared/icons/_spinner.html.erb +1 -0
- data/app/views/themes/default/spree/shared/icons/_spotify.html.erb +8 -0
- data/app/views/themes/default/spree/shared/icons/_tiktok.html.erb +9 -0
- data/app/views/themes/default/spree/shared/icons/_twitter.html.erb +16 -0
- data/app/views/themes/default/spree/shared/icons/_youtube.html.erb +9 -0
- data/app/views/themes/default/spree/shared/icons/_zoom.html.erb +10 -0
- data/app/views/themes/default/spree/wishlists/_no_wished_items.html.erb +10 -0
- data/app/views/themes/default/spree/wishlists/_wished_item.html.erb +38 -0
- data/app/views/themes/default/spree/wishlists/show.html.erb +17 -0
- data/config/i18n-tasks.yml +176 -0
- data/config/importmap.rb +22 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/heroicon.rb +10 -0
- data/config/locales/en.yml +76 -0
- data/config/routes.rb +88 -0
- data/lib/generators/spree/storefront/install/install_generator.rb +45 -0
- data/lib/generators/spree/storefront/install/templates/application.tailwind.css +1760 -0
- data/lib/generators/spree/storefront/install/templates/dev +16 -0
- data/lib/generators/spree/storefront/install/templates/tailwind.config.js +128 -0
- data/lib/generators/spree/storefront/theme/templates/model.rb.tt +12 -0
- data/lib/generators/spree/storefront/theme/theme_generator.rb +41 -0
- data/lib/spree/storefront/configuration.rb +11 -0
- data/lib/spree/storefront/engine.rb +51 -0
- data/lib/spree/storefront/testing_support/capybara_utils.rb +13 -0
- data/lib/spree/storefront.rb +16 -0
- data/lib/spree_storefront.rb +1 -0
- data/vendor/colornames.json +1 -0
- data/vendor/javascript/@kanety--stimulus-accordion.js +4 -0
- data/vendor/javascript/@stimulus-components--carousel.js +4 -0
- data/vendor/javascript/card-validator.js +4 -0
- data/vendor/javascript/credit-card-type.js +4 -0
- data/vendor/javascript/headroom.js.js +19 -0
- data/vendor/javascript/nouislider.js +4 -0
- data/vendor/javascript/photoswipe--dist--photoswipe-lightbox.esm.js.js +667 -0
- data/vendor/javascript/photoswipe.js +1675 -0
- data/vendor/javascript/stimulus-read-more.js +4 -0
- data/vendor/javascript/stimulus-scroll-to.js +4 -0
- data/vendor/javascript/swiper--bundle.js +4 -0
- metadata +567 -0
@@ -0,0 +1,667 @@
|
|
1
|
+
// photoswipe/dist/photoswipe-lightbox.esm.js@5.4.4 downloaded from https://ga.jspm.io/npm:photoswipe@5.4.4/dist/photoswipe-lightbox.esm.js
|
2
|
+
|
3
|
+
/** @typedef {import('../photoswipe.js').Point} Point */
|
4
|
+
/**
|
5
|
+
* @template {keyof HTMLElementTagNameMap} T
|
6
|
+
* @param {string} className
|
7
|
+
* @param {T} tagName
|
8
|
+
* @param {Node} [appendToEl]
|
9
|
+
* @returns {HTMLElementTagNameMap[T]}
|
10
|
+
*/
|
11
|
+
function createElement(t, e, i) { const s = document.createElement(e); t && (s.className = t); i && i.appendChild(s); return s }
|
12
|
+
/**
|
13
|
+
* Get transform string
|
14
|
+
*
|
15
|
+
* @param {number} x
|
16
|
+
* @param {number} [y]
|
17
|
+
* @param {number} [scale]
|
18
|
+
* @returns {string}
|
19
|
+
*/function toTransformString(t, e, i) { let s = `translate3d(${t}px,${e || 0}px,0)`; i !== void 0 && (s += ` scale3d(${i},${i},1)`); return s }
|
20
|
+
/**
|
21
|
+
* Apply width and height CSS properties to element
|
22
|
+
*
|
23
|
+
* @param {HTMLElement} el
|
24
|
+
* @param {string | number} w
|
25
|
+
* @param {string | number} h
|
26
|
+
*/function setWidthHeight(t, e, i) { t.style.width = typeof e === "number" ? `${e}px` : e; t.style.height = typeof i === "number" ? `${i}px` : i }
|
27
|
+
/** @typedef {LOAD_STATE[keyof LOAD_STATE]} LoadState */
|
28
|
+
/** @type {{ IDLE: 'idle'; LOADING: 'loading'; LOADED: 'loaded'; ERROR: 'error' }} */const t = { IDLE: "idle", LOADING: "loading", LOADED: "loaded", ERROR: "error" };
|
29
|
+
/**
|
30
|
+
* Check if click or keydown event was dispatched
|
31
|
+
* with a special key or via mouse wheel.
|
32
|
+
*
|
33
|
+
* @param {MouseEvent | KeyboardEvent} e
|
34
|
+
* @returns {boolean}
|
35
|
+
*/function specialKeyUsed(t) { return "button" in t && t.button === 1 || t.ctrlKey || t.metaKey || t.altKey || t.shiftKey }
|
36
|
+
/**
|
37
|
+
* Parse `gallery` or `children` options.
|
38
|
+
*
|
39
|
+
* @param {import('../photoswipe.js').ElementProvider} [option]
|
40
|
+
* @param {string} [legacySelector]
|
41
|
+
* @param {HTMLElement | Document} [parent]
|
42
|
+
* @returns HTMLElement[]
|
43
|
+
*/function getElementsFromOption(t, e, i = document) {
|
44
|
+
/** @type {HTMLElement[]} */
|
45
|
+
let s = []; if (t instanceof Element) s = [t]; else if (t instanceof NodeList || Array.isArray(t)) s = Array.from(t); else { const n = typeof t === "string" ? t : e; n && (s = Array.from(i.querySelectorAll(n))) } return s
|
46
|
+
}
|
47
|
+
/**
|
48
|
+
* Check if variable is PhotoSwipe class
|
49
|
+
*
|
50
|
+
* @param {any} fn
|
51
|
+
* @returns {boolean}
|
52
|
+
*/function isPswpClass(t) { return typeof t === "function" && t.prototype && t.prototype.goTo }
|
53
|
+
/**
|
54
|
+
* Check if browser is Safari
|
55
|
+
*
|
56
|
+
* @returns {boolean}
|
57
|
+
*/function isSafari() { return !!(navigator.vendor && navigator.vendor.match(/apple/i)) }
|
58
|
+
/** @typedef {import('../lightbox/lightbox.js').default} PhotoSwipeLightbox */
|
59
|
+
/** @typedef {import('../photoswipe.js').default} PhotoSwipe */
|
60
|
+
/** @typedef {import('../photoswipe.js').PhotoSwipeOptions} PhotoSwipeOptions */
|
61
|
+
/** @typedef {import('../photoswipe.js').DataSource} DataSource */
|
62
|
+
/** @typedef {import('../ui/ui-element.js').UIElementData} UIElementData */
|
63
|
+
/** @typedef {import('../slide/content.js').default} ContentDefault */
|
64
|
+
/** @typedef {import('../slide/slide.js').default} Slide */
|
65
|
+
/** @typedef {import('../slide/slide.js').SlideData} SlideData */
|
66
|
+
/** @typedef {import('../slide/zoom-level.js').default} ZoomLevel */
|
67
|
+
/** @typedef {import('../slide/get-thumb-bounds.js').Bounds} Bounds */
|
68
|
+
/**
|
69
|
+
* Allow adding an arbitrary props to the Content
|
70
|
+
* https://photoswipe.com/custom-content/#using-webp-image-format
|
71
|
+
* @typedef {ContentDefault & Record<string, any>} Content
|
72
|
+
*/
|
73
|
+
/** @typedef {{ x?: number; y?: number }} Point */
|
74
|
+
/**
|
75
|
+
* @typedef {Object} PhotoSwipeEventsMap https://photoswipe.com/events/
|
76
|
+
*
|
77
|
+
*
|
78
|
+
* https://photoswipe.com/adding-ui-elements/
|
79
|
+
*
|
80
|
+
* @prop {undefined} uiRegister
|
81
|
+
* @prop {{ data: UIElementData }} uiElementCreate
|
82
|
+
*
|
83
|
+
*
|
84
|
+
* https://photoswipe.com/events/#initialization-events
|
85
|
+
*
|
86
|
+
* @prop {undefined} beforeOpen
|
87
|
+
* @prop {undefined} firstUpdate
|
88
|
+
* @prop {undefined} initialLayout
|
89
|
+
* @prop {undefined} change
|
90
|
+
* @prop {undefined} afterInit
|
91
|
+
* @prop {undefined} bindEvents
|
92
|
+
*
|
93
|
+
*
|
94
|
+
* https://photoswipe.com/events/#opening-or-closing-transition-events
|
95
|
+
*
|
96
|
+
* @prop {undefined} openingAnimationStart
|
97
|
+
* @prop {undefined} openingAnimationEnd
|
98
|
+
* @prop {undefined} closingAnimationStart
|
99
|
+
* @prop {undefined} closingAnimationEnd
|
100
|
+
*
|
101
|
+
*
|
102
|
+
* https://photoswipe.com/events/#closing-events
|
103
|
+
*
|
104
|
+
* @prop {undefined} close
|
105
|
+
* @prop {undefined} destroy
|
106
|
+
*
|
107
|
+
*
|
108
|
+
* https://photoswipe.com/events/#pointer-and-gesture-events
|
109
|
+
*
|
110
|
+
* @prop {{ originalEvent: PointerEvent }} pointerDown
|
111
|
+
* @prop {{ originalEvent: PointerEvent }} pointerMove
|
112
|
+
* @prop {{ originalEvent: PointerEvent }} pointerUp
|
113
|
+
* @prop {{ bgOpacity: number }} pinchClose can be default prevented
|
114
|
+
* @prop {{ panY: number }} verticalDrag can be default prevented
|
115
|
+
*
|
116
|
+
*
|
117
|
+
* https://photoswipe.com/events/#slide-content-events
|
118
|
+
*
|
119
|
+
* @prop {{ content: Content }} contentInit
|
120
|
+
* @prop {{ content: Content; isLazy: boolean }} contentLoad can be default prevented
|
121
|
+
* @prop {{ content: Content; isLazy: boolean }} contentLoadImage can be default prevented
|
122
|
+
* @prop {{ content: Content; slide: Slide; isError?: boolean }} loadComplete
|
123
|
+
* @prop {{ content: Content; slide: Slide }} loadError
|
124
|
+
* @prop {{ content: Content; width: number; height: number }} contentResize can be default prevented
|
125
|
+
* @prop {{ content: Content; width: number; height: number; slide: Slide }} imageSizeChange
|
126
|
+
* @prop {{ content: Content }} contentLazyLoad can be default prevented
|
127
|
+
* @prop {{ content: Content }} contentAppend can be default prevented
|
128
|
+
* @prop {{ content: Content }} contentActivate can be default prevented
|
129
|
+
* @prop {{ content: Content }} contentDeactivate can be default prevented
|
130
|
+
* @prop {{ content: Content }} contentRemove can be default prevented
|
131
|
+
* @prop {{ content: Content }} contentDestroy can be default prevented
|
132
|
+
*
|
133
|
+
*
|
134
|
+
* undocumented
|
135
|
+
*
|
136
|
+
* @prop {{ point: Point; originalEvent: PointerEvent }} imageClickAction can be default prevented
|
137
|
+
* @prop {{ point: Point; originalEvent: PointerEvent }} bgClickAction can be default prevented
|
138
|
+
* @prop {{ point: Point; originalEvent: PointerEvent }} tapAction can be default prevented
|
139
|
+
* @prop {{ point: Point; originalEvent: PointerEvent }} doubleTapAction can be default prevented
|
140
|
+
*
|
141
|
+
* @prop {{ originalEvent: KeyboardEvent }} keydown can be default prevented
|
142
|
+
* @prop {{ x: number; dragging: boolean }} moveMainScroll
|
143
|
+
* @prop {{ slide: Slide }} firstZoomPan
|
144
|
+
* @prop {{ slide: Slide | undefined, data: SlideData, index: number }} gettingData
|
145
|
+
* @prop {undefined} beforeResize
|
146
|
+
* @prop {undefined} resize
|
147
|
+
* @prop {undefined} viewportSize
|
148
|
+
* @prop {undefined} updateScrollOffset
|
149
|
+
* @prop {{ slide: Slide }} slideInit
|
150
|
+
* @prop {{ slide: Slide }} afterSetContent
|
151
|
+
* @prop {{ slide: Slide }} slideLoad
|
152
|
+
* @prop {{ slide: Slide }} appendHeavy can be default prevented
|
153
|
+
* @prop {{ slide: Slide }} appendHeavyContent
|
154
|
+
* @prop {{ slide: Slide }} slideActivate
|
155
|
+
* @prop {{ slide: Slide }} slideDeactivate
|
156
|
+
* @prop {{ slide: Slide }} slideDestroy
|
157
|
+
* @prop {{ destZoomLevel: number, centerPoint: Point | undefined, transitionDuration: number | false | undefined }} beforeZoomTo
|
158
|
+
* @prop {{ slide: Slide }} zoomPanUpdate
|
159
|
+
* @prop {{ slide: Slide }} initialZoomPan
|
160
|
+
* @prop {{ slide: Slide }} calcSlideSize
|
161
|
+
* @prop {undefined} resolutionChanged
|
162
|
+
* @prop {{ originalEvent: WheelEvent }} wheel can be default prevented
|
163
|
+
* @prop {{ content: Content }} contentAppendImage can be default prevented
|
164
|
+
* @prop {{ index: number; itemData: SlideData }} lazyLoadSlide can be default prevented
|
165
|
+
* @prop {undefined} lazyLoad
|
166
|
+
* @prop {{ slide: Slide }} calcBounds
|
167
|
+
* @prop {{ zoomLevels: ZoomLevel, slideData: SlideData }} zoomLevelsUpdate
|
168
|
+
*
|
169
|
+
*
|
170
|
+
* legacy
|
171
|
+
*
|
172
|
+
* @prop {undefined} init
|
173
|
+
* @prop {undefined} initialZoomIn
|
174
|
+
* @prop {undefined} initialZoomOut
|
175
|
+
* @prop {undefined} initialZoomInEnd
|
176
|
+
* @prop {undefined} initialZoomOutEnd
|
177
|
+
* @prop {{ dataSource: DataSource | undefined, numItems: number }} numItems
|
178
|
+
* @prop {{ itemData: SlideData; index: number }} itemData
|
179
|
+
* @prop {{ index: number, itemData: SlideData, instance: PhotoSwipe }} thumbBounds
|
180
|
+
*/
|
181
|
+
/**
|
182
|
+
* @typedef {Object} PhotoSwipeFiltersMap https://photoswipe.com/filters/
|
183
|
+
*
|
184
|
+
* @prop {(numItems: number, dataSource: DataSource | undefined) => number} numItems
|
185
|
+
* Modify the total amount of slides. Example on Data sources page.
|
186
|
+
* https://photoswipe.com/filters/#numitems
|
187
|
+
*
|
188
|
+
* @prop {(itemData: SlideData, index: number) => SlideData} itemData
|
189
|
+
* Modify slide item data. Example on Data sources page.
|
190
|
+
* https://photoswipe.com/filters/#itemdata
|
191
|
+
*
|
192
|
+
* @prop {(itemData: SlideData, element: HTMLElement, linkEl: HTMLAnchorElement) => SlideData} domItemData
|
193
|
+
* Modify item data when it's parsed from DOM element. Example on Data sources page.
|
194
|
+
* https://photoswipe.com/filters/#domitemdata
|
195
|
+
*
|
196
|
+
* @prop {(clickedIndex: number, e: MouseEvent, instance: PhotoSwipeLightbox) => number} clickedIndex
|
197
|
+
* Modify clicked gallery item index.
|
198
|
+
* https://photoswipe.com/filters/#clickedindex
|
199
|
+
*
|
200
|
+
* @prop {(placeholderSrc: string | false, content: Content) => string | false} placeholderSrc
|
201
|
+
* Modify placeholder image source.
|
202
|
+
* https://photoswipe.com/filters/#placeholdersrc
|
203
|
+
*
|
204
|
+
* @prop {(isContentLoading: boolean, content: Content) => boolean} isContentLoading
|
205
|
+
* Modify if the content is currently loading.
|
206
|
+
* https://photoswipe.com/filters/#iscontentloading
|
207
|
+
*
|
208
|
+
* @prop {(isContentZoomable: boolean, content: Content) => boolean} isContentZoomable
|
209
|
+
* Modify if the content can be zoomed.
|
210
|
+
* https://photoswipe.com/filters/#iscontentzoomable
|
211
|
+
*
|
212
|
+
* @prop {(useContentPlaceholder: boolean, content: Content) => boolean} useContentPlaceholder
|
213
|
+
* Modify if the placeholder should be used for the content.
|
214
|
+
* https://photoswipe.com/filters/#usecontentplaceholder
|
215
|
+
*
|
216
|
+
* @prop {(isKeepingPlaceholder: boolean, content: Content) => boolean} isKeepingPlaceholder
|
217
|
+
* Modify if the placeholder should be kept after the content is loaded.
|
218
|
+
* https://photoswipe.com/filters/#iskeepingplaceholder
|
219
|
+
*
|
220
|
+
*
|
221
|
+
* @prop {(contentErrorElement: HTMLElement, content: Content) => HTMLElement} contentErrorElement
|
222
|
+
* Modify an element when the content has error state (for example, if image cannot be loaded).
|
223
|
+
* https://photoswipe.com/filters/#contenterrorelement
|
224
|
+
*
|
225
|
+
* @prop {(element: HTMLElement, data: UIElementData) => HTMLElement} uiElement
|
226
|
+
* Modify a UI element that's being created.
|
227
|
+
* https://photoswipe.com/filters/#uielement
|
228
|
+
*
|
229
|
+
* @prop {(thumbnail: HTMLElement | null | undefined, itemData: SlideData, index: number) => HTMLElement} thumbEl
|
230
|
+
* Modify the thumbnail element from which opening zoom animation starts or ends.
|
231
|
+
* https://photoswipe.com/filters/#thumbel
|
232
|
+
*
|
233
|
+
* @prop {(thumbBounds: Bounds | undefined, itemData: SlideData, index: number) => Bounds} thumbBounds
|
234
|
+
* Modify the thumbnail bounds from which opening zoom animation starts or ends.
|
235
|
+
* https://photoswipe.com/filters/#thumbbounds
|
236
|
+
*
|
237
|
+
* @prop {(srcsetSizesWidth: number, content: Content) => number} srcsetSizesWidth
|
238
|
+
*
|
239
|
+
* @prop {(preventPointerEvent: boolean, event: PointerEvent, pointerType: string) => boolean} preventPointerEvent
|
240
|
+
*
|
241
|
+
*/
|
242
|
+
/**
|
243
|
+
* @template {keyof PhotoSwipeFiltersMap} T
|
244
|
+
* @typedef {{ fn: PhotoSwipeFiltersMap[T], priority: number }} Filter
|
245
|
+
*/
|
246
|
+
/**
|
247
|
+
* @template {keyof PhotoSwipeEventsMap} T
|
248
|
+
* @typedef {PhotoSwipeEventsMap[T] extends undefined ? PhotoSwipeEvent<T> : PhotoSwipeEvent<T> & PhotoSwipeEventsMap[T]} AugmentedEvent
|
249
|
+
*/
|
250
|
+
/**
|
251
|
+
* @template {keyof PhotoSwipeEventsMap} T
|
252
|
+
* @typedef {(event: AugmentedEvent<T>) => void} EventCallback
|
253
|
+
*/
|
254
|
+
/**
|
255
|
+
* Base PhotoSwipe event object
|
256
|
+
*
|
257
|
+
* @template {keyof PhotoSwipeEventsMap} T
|
258
|
+
*/class PhotoSwipeEvent {
|
259
|
+
/**
|
260
|
+
* @param {T} type
|
261
|
+
* @param {PhotoSwipeEventsMap[T]} [details]
|
262
|
+
*/
|
263
|
+
constructor(t, e) { this.type = t; this.defaultPrevented = false; e && Object.assign(this, e) } preventDefault() { this.defaultPrevented = true }
|
264
|
+
} class Eventable {
|
265
|
+
constructor() {
|
266
|
+
/**
|
267
|
+
* @type {{ [T in keyof PhotoSwipeEventsMap]?: ((event: AugmentedEvent<T>) => void)[] }}
|
268
|
+
*/
|
269
|
+
this._listeners = {};
|
270
|
+
/**
|
271
|
+
* @type {{ [T in keyof PhotoSwipeFiltersMap]?: Filter<T>[] }}
|
272
|
+
*/this._filters = {};
|
273
|
+
/** @type {PhotoSwipe | undefined} */this.pswp = void 0;
|
274
|
+
/** @type {PhotoSwipeOptions | undefined} */this.options = void 0
|
275
|
+
}
|
276
|
+
/**
|
277
|
+
* @template {keyof PhotoSwipeFiltersMap} T
|
278
|
+
* @param {T} name
|
279
|
+
* @param {PhotoSwipeFiltersMap[T]} fn
|
280
|
+
* @param {number} priority
|
281
|
+
*/addFilter(t, e, i = 100) { var s, n, a; this._filters[t] || (this._filters[t] = []); (s = this._filters[t]) === null || s === void 0 || s.push({ fn: e, priority: i }); (n = this._filters[t]) === null || n === void 0 || n.sort(((t, e) => t.priority - e.priority)); (a = this.pswp) === null || a === void 0 || a.addFilter(t, e, i) }
|
282
|
+
/**
|
283
|
+
* @template {keyof PhotoSwipeFiltersMap} T
|
284
|
+
* @param {T} name
|
285
|
+
* @param {PhotoSwipeFiltersMap[T]} fn
|
286
|
+
*/removeFilter(t, e) { this._filters[t] && (this._filters[t] = this._filters[t].filter((t => t.fn !== e))); this.pswp && this.pswp.removeFilter(t, e) }
|
287
|
+
/**
|
288
|
+
* @template {keyof PhotoSwipeFiltersMap} T
|
289
|
+
* @param {T} name
|
290
|
+
* @param {Parameters<PhotoSwipeFiltersMap[T]>} args
|
291
|
+
* @returns {Parameters<PhotoSwipeFiltersMap[T]>[0]}
|
292
|
+
*/applyFilters(t, ...e) { var i; (i = this._filters[t]) === null || i === void 0 || i.forEach((t => { e[0] = t.fn.apply(this, e) })); return e[0] }
|
293
|
+
/**
|
294
|
+
* @template {keyof PhotoSwipeEventsMap} T
|
295
|
+
* @param {T} name
|
296
|
+
* @param {EventCallback<T>} fn
|
297
|
+
*/on(t, e) { var i, s; this._listeners[t] || (this._listeners[t] = []); (i = this._listeners[t]) === null || i === void 0 || i.push(e); (s = this.pswp) === null || s === void 0 || s.on(t, e) }
|
298
|
+
/**
|
299
|
+
* @template {keyof PhotoSwipeEventsMap} T
|
300
|
+
* @param {T} name
|
301
|
+
* @param {EventCallback<T>} fn
|
302
|
+
*/off(t, e) { var i; this._listeners[t] && (this._listeners[t] = this._listeners[t].filter((t => e !== t))); (i = this.pswp) === null || i === void 0 || i.off(t, e) }
|
303
|
+
/**
|
304
|
+
* @template {keyof PhotoSwipeEventsMap} T
|
305
|
+
* @param {T} name
|
306
|
+
* @param {PhotoSwipeEventsMap[T]} [details]
|
307
|
+
* @returns {AugmentedEvent<T>}
|
308
|
+
*/dispatch(t, e) {
|
309
|
+
var i; if (this.pswp) return this.pswp.dispatch(t, e); const s =
|
310
|
+
/** @type {AugmentedEvent<T>} */
|
311
|
+
new PhotoSwipeEvent(t, e); (i = this._listeners[t]) === null || i === void 0 || i.forEach((t => { t.call(this, s) })); return s
|
312
|
+
}
|
313
|
+
} class Placeholder {
|
314
|
+
/**
|
315
|
+
* @param {string | false} imageSrc
|
316
|
+
* @param {HTMLElement} container
|
317
|
+
*/
|
318
|
+
constructor(t, e) {
|
319
|
+
/** @type {HTMLImageElement | HTMLDivElement | null} */
|
320
|
+
this.element = createElement("pswp__img pswp__img--placeholder", t ? "img" : "div", e); if (t) {
|
321
|
+
const e =
|
322
|
+
/** @type {HTMLImageElement} */
|
323
|
+
this.element; e.decoding = "async"; e.alt = ""; e.src = t; e.setAttribute("role", "presentation")
|
324
|
+
} this.element.setAttribute("aria-hidden", "true")
|
325
|
+
}
|
326
|
+
/**
|
327
|
+
* @param {number} width
|
328
|
+
* @param {number} height
|
329
|
+
*/setDisplayedSize(t, e) { if (this.element) if (this.element.tagName === "IMG") { setWidthHeight(this.element, 250, "auto"); this.element.style.transformOrigin = "0 0"; this.element.style.transform = toTransformString(0, 0, t / 250) } else setWidthHeight(this.element, t, e) } destroy() { var t; (t = this.element) !== null && t !== void 0 && t.parentNode && this.element.remove(); this.element = null }
|
330
|
+
}
|
331
|
+
/** @typedef {import('./slide.js').default} Slide */
|
332
|
+
/** @typedef {import('./slide.js').SlideData} SlideData */
|
333
|
+
/** @typedef {import('../core/base.js').default} PhotoSwipeBase */
|
334
|
+
/** @typedef {import('../util/util.js').LoadState} LoadState */class Content {
|
335
|
+
/**
|
336
|
+
* @param {SlideData} itemData Slide data
|
337
|
+
* @param {PhotoSwipeBase} instance PhotoSwipe or PhotoSwipeLightbox instance
|
338
|
+
* @param {number} index
|
339
|
+
*/
|
340
|
+
constructor(e, i, s) {
|
341
|
+
this.instance = i; this.data = e; this.index = s;
|
342
|
+
/** @type {HTMLImageElement | HTMLDivElement | undefined} */this.element = void 0;
|
343
|
+
/** @type {Placeholder | undefined} */this.placeholder = void 0;
|
344
|
+
/** @type {Slide | undefined} */this.slide = void 0; this.displayedImageWidth = 0; this.displayedImageHeight = 0; this.width = Number(this.data.w) || Number(this.data.width) || 0; this.height = Number(this.data.h) || Number(this.data.height) || 0; this.isAttached = false; this.hasSlide = false; this.isDecoding = false;
|
345
|
+
/** @type {LoadState} */this.state = t.IDLE; this.data.type ? this.type = this.data.type : this.data.src ? this.type = "image" : this.type = "html"; this.instance.dispatch("contentInit", { content: this })
|
346
|
+
} removePlaceholder() { this.placeholder && !this.keepPlaceholder() && setTimeout((() => { if (this.placeholder) { this.placeholder.destroy(); this.placeholder = void 0 } }), 1e3) }
|
347
|
+
/**
|
348
|
+
* Preload content
|
349
|
+
*
|
350
|
+
* @param {boolean} isLazy
|
351
|
+
* @param {boolean} [reload]
|
352
|
+
*/load(t, e) { if (this.slide && this.usePlaceholder()) if (this.placeholder) { const t = this.placeholder.element; t && !t.parentElement && this.slide.container.prepend(t) } else { const t = this.instance.applyFilters("placeholderSrc", !(!this.data.msrc || !this.slide.isFirstSlide) && this.data.msrc, this); this.placeholder = new Placeholder(t, this.slide.container) } if ((!this.element || e) && !this.instance.dispatch("contentLoad", { content: this, isLazy: t }).defaultPrevented) { if (this.isImageContent()) { this.element = createElement("pswp__img", "img"); this.displayedImageWidth && this.loadImage(t) } else { this.element = createElement("pswp__content", "div"); this.element.innerHTML = this.data.html || "" } e && this.slide && this.slide.updateContentSize(true) } }
|
353
|
+
/**
|
354
|
+
* Preload image
|
355
|
+
*
|
356
|
+
* @param {boolean} isLazy
|
357
|
+
*/loadImage(e) {
|
358
|
+
var i, s; if (!this.isImageContent() || !this.element || this.instance.dispatch("contentLoadImage", { content: this, isLazy: e }).defaultPrevented) return; const n =
|
359
|
+
/** @type HTMLImageElement */
|
360
|
+
this.element; this.updateSrcsetSizes(); this.data.srcset && (n.srcset = this.data.srcset); n.src = (i = this.data.src) !== null && i !== void 0 ? i : ""; n.alt = (s = this.data.alt) !== null && s !== void 0 ? s : ""; this.state = t.LOADING; if (n.complete) this.onLoaded(); else { n.onload = () => { this.onLoaded() }; n.onerror = () => { this.onError() } }
|
361
|
+
}
|
362
|
+
/**
|
363
|
+
* Assign slide to content
|
364
|
+
*
|
365
|
+
* @param {Slide} slide
|
366
|
+
*/setSlide(t) { this.slide = t; this.hasSlide = true; this.instance = t.pswp } onLoaded() { this.state = t.LOADED; if (this.slide && this.element) { this.instance.dispatch("loadComplete", { slide: this.slide, content: this }); if (this.slide.isActive && this.slide.heavyAppended && !this.element.parentNode) { this.append(); this.slide.updateContentSize(true) } this.state !== t.LOADED && this.state !== t.ERROR || this.removePlaceholder() } } onError() { this.state = t.ERROR; if (this.slide) { this.displayError(); this.instance.dispatch("loadComplete", { slide: this.slide, isError: true, content: this }); this.instance.dispatch("loadError", { slide: this.slide, content: this }) } }
|
367
|
+
/**
|
368
|
+
* @returns {Boolean} If the content is currently loading
|
369
|
+
*/isLoading() { return this.instance.applyFilters("isContentLoading", this.state === t.LOADING, this) }
|
370
|
+
/**
|
371
|
+
* @returns {Boolean} If the content is in error state
|
372
|
+
*/isError() { return this.state === t.ERROR }
|
373
|
+
/**
|
374
|
+
* @returns {boolean} If the content is image
|
375
|
+
*/isImageContent() { return this.type === "image" }
|
376
|
+
/**
|
377
|
+
* Update content size
|
378
|
+
*
|
379
|
+
* @param {Number} width
|
380
|
+
* @param {Number} height
|
381
|
+
*/setDisplayedSize(t, e) { if (this.element) { this.placeholder && this.placeholder.setDisplayedSize(t, e); if (!this.instance.dispatch("contentResize", { content: this, width: t, height: e }).defaultPrevented) { setWidthHeight(this.element, t, e); if (this.isImageContent() && !this.isError()) { const i = !this.displayedImageWidth && t; this.displayedImageWidth = t; this.displayedImageHeight = e; i ? this.loadImage(false) : this.updateSrcsetSizes(); this.slide && this.instance.dispatch("imageSizeChange", { slide: this.slide, width: t, height: e, content: this }) } } } }
|
382
|
+
/**
|
383
|
+
* @returns {boolean} If the content can be zoomed
|
384
|
+
*/isZoomable() { return this.instance.applyFilters("isContentZoomable", this.isImageContent() && this.state !== t.ERROR, this) } updateSrcsetSizes() {
|
385
|
+
if (!this.isImageContent() || !this.element || !this.data.srcset) return; const t =
|
386
|
+
/** @type HTMLImageElement */
|
387
|
+
this.element; const e = this.instance.applyFilters("srcsetSizesWidth", this.displayedImageWidth, this); if (!t.dataset.largestUsedSize || e > parseInt(t.dataset.largestUsedSize, 10)) { t.sizes = e + "px"; t.dataset.largestUsedSize = String(e) }
|
388
|
+
}
|
389
|
+
/**
|
390
|
+
* @returns {boolean} If content should use a placeholder (from msrc by default)
|
391
|
+
*/usePlaceholder() { return this.instance.applyFilters("useContentPlaceholder", this.isImageContent(), this) } lazyLoad() { this.instance.dispatch("contentLazyLoad", { content: this }).defaultPrevented || this.load(true) }
|
392
|
+
/**
|
393
|
+
* @returns {boolean} If placeholder should be kept after content is loaded
|
394
|
+
*/keepPlaceholder() { return this.instance.applyFilters("isKeepingPlaceholder", this.isLoading(), this) } destroy() { this.hasSlide = false; this.slide = void 0; if (!this.instance.dispatch("contentDestroy", { content: this }).defaultPrevented) { this.remove(); if (this.placeholder) { this.placeholder.destroy(); this.placeholder = void 0 } if (this.isImageContent() && this.element) { this.element.onload = null; this.element.onerror = null; this.element = void 0 } } } displayError() {
|
395
|
+
if (this.slide) {
|
396
|
+
var t, e; let i = createElement("pswp__error-msg", "div"); i.innerText = (t = (e = this.instance.options) === null || e === void 0 ? void 0 : e.errorMsg) !== null && t !== void 0 ? t : ""; i =
|
397
|
+
/** @type {HTMLDivElement} */
|
398
|
+
this.instance.applyFilters("contentErrorElement", i, this); this.element = createElement("pswp__content pswp__error-msg-container", "div"); this.element.appendChild(i); this.slide.container.innerText = ""; this.slide.container.appendChild(this.element); this.slide.updateContentSize(true); this.removePlaceholder()
|
399
|
+
}
|
400
|
+
} append() {
|
401
|
+
if (this.isAttached || !this.element) return; this.isAttached = true; if (this.state === t.ERROR) { this.displayError(); return } if (this.instance.dispatch("contentAppend", { content: this }).defaultPrevented) return; const e = "decode" in this.element; if (this.isImageContent()) if (e && this.slide && (!this.slide.isActive || isSafari())) {
|
402
|
+
this.isDecoding = true;
|
403
|
+
/** @type {HTMLImageElement} */this.element.decode().catch((() => { })).finally((() => { this.isDecoding = false; this.appendImage() }))
|
404
|
+
} else this.appendImage(); else this.slide && !this.element.parentNode && this.slide.container.appendChild(this.element)
|
405
|
+
} activate() { if (!this.instance.dispatch("contentActivate", { content: this }).defaultPrevented && this.slide) { this.isImageContent() && this.isDecoding && !isSafari() ? this.appendImage() : this.isError() && this.load(false, true); this.slide.holderElement && this.slide.holderElement.setAttribute("aria-hidden", "false") } } deactivate() { this.instance.dispatch("contentDeactivate", { content: this }); this.slide && this.slide.holderElement && this.slide.holderElement.setAttribute("aria-hidden", "true") } remove() { this.isAttached = false; if (!this.instance.dispatch("contentRemove", { content: this }).defaultPrevented) { this.element && this.element.parentNode && this.element.remove(); this.placeholder && this.placeholder.element && this.placeholder.element.remove() } } appendImage() { if (this.isAttached && !this.instance.dispatch("contentAppendImage", { content: this }).defaultPrevented) { this.slide && this.element && !this.element.parentNode && this.slide.container.appendChild(this.element); this.state !== t.LOADED && this.state !== t.ERROR || this.removePlaceholder() } }
|
406
|
+
}
|
407
|
+
/** @typedef {import('../photoswipe.js').PhotoSwipeOptions} PhotoSwipeOptions */
|
408
|
+
/** @typedef {import('../core/base.js').default} PhotoSwipeBase */
|
409
|
+
/** @typedef {import('../photoswipe.js').Point} Point */
|
410
|
+
/** @typedef {import('../slide/slide.js').SlideData} SlideData */
|
411
|
+
/**
|
412
|
+
* @param {PhotoSwipeOptions} options
|
413
|
+
* @param {PhotoSwipeBase} pswp
|
414
|
+
* @returns {Point}
|
415
|
+
*/function getViewportSize(t, e) { if (t.getViewportSizeFn) { const i = t.getViewportSizeFn(t, e); if (i) return i } return { x: document.documentElement.clientWidth, y: window.innerHeight } }
|
416
|
+
/**
|
417
|
+
* Parses padding option.
|
418
|
+
* Supported formats:
|
419
|
+
*
|
420
|
+
* // Object
|
421
|
+
* padding: {
|
422
|
+
* top: 0,
|
423
|
+
* bottom: 0,
|
424
|
+
* left: 0,
|
425
|
+
* right: 0
|
426
|
+
* }
|
427
|
+
*
|
428
|
+
* // A function that returns the object
|
429
|
+
* paddingFn: (viewportSize, itemData, index) => {
|
430
|
+
* return {
|
431
|
+
* top: 0,
|
432
|
+
* bottom: 0,
|
433
|
+
* left: 0,
|
434
|
+
* right: 0
|
435
|
+
* };
|
436
|
+
* }
|
437
|
+
*
|
438
|
+
* // Legacy variant
|
439
|
+
* paddingLeft: 0,
|
440
|
+
* paddingRight: 0,
|
441
|
+
* paddingTop: 0,
|
442
|
+
* paddingBottom: 0,
|
443
|
+
*
|
444
|
+
* @param {'left' | 'top' | 'bottom' | 'right'} prop
|
445
|
+
* @param {PhotoSwipeOptions} options PhotoSwipe options
|
446
|
+
* @param {Point} viewportSize PhotoSwipe viewport size, for example: { x:800, y:600 }
|
447
|
+
* @param {SlideData} itemData Data about the slide
|
448
|
+
* @param {number} index Slide index
|
449
|
+
* @returns {number}
|
450
|
+
*/function parsePaddingOption(t, e, i, s, n) { let a = 0; if (e.paddingFn) a = e.paddingFn(i, s, n)[t]; else if (e.padding) a = e.padding[t]; else { const i = "padding" + t[0].toUpperCase() + t.slice(1); e[i] && (a = e[i]) } return Number(a) || 0 }
|
451
|
+
/**
|
452
|
+
* @param {PhotoSwipeOptions} options
|
453
|
+
* @param {Point} viewportSize
|
454
|
+
* @param {SlideData} itemData
|
455
|
+
* @param {number} index
|
456
|
+
* @returns {Point}
|
457
|
+
*/function getPanAreaSize(t, e, i, s) { return { x: e.x - parsePaddingOption("left", t, e, i, s) - parsePaddingOption("right", t, e, i, s), y: e.y - parsePaddingOption("top", t, e, i, s) - parsePaddingOption("bottom", t, e, i, s) } } const e = 4e3;
|
458
|
+
/** @typedef {import('../photoswipe.js').default} PhotoSwipe */
|
459
|
+
/** @typedef {import('../photoswipe.js').PhotoSwipeOptions} PhotoSwipeOptions */
|
460
|
+
/** @typedef {import('../photoswipe.js').Point} Point */
|
461
|
+
/** @typedef {import('../slide/slide.js').SlideData} SlideData */
|
462
|
+
/** @typedef {'fit' | 'fill' | number | ((zoomLevelObject: ZoomLevel) => number)} ZoomLevelOption */class ZoomLevel {
|
463
|
+
/**
|
464
|
+
* @param {PhotoSwipeOptions} options PhotoSwipe options
|
465
|
+
* @param {SlideData} itemData Slide data
|
466
|
+
* @param {number} index Slide index
|
467
|
+
* @param {PhotoSwipe} [pswp] PhotoSwipe instance, can be undefined if not initialized yet
|
468
|
+
*/
|
469
|
+
constructor(t, e, i, s) {
|
470
|
+
this.pswp = s; this.options = t; this.itemData = e; this.index = i;
|
471
|
+
/** @type { Point | null } */this.panAreaSize = null;
|
472
|
+
/** @type { Point | null } */this.elementSize = null; this.fit = 1; this.fill = 1; this.vFill = 1; this.initial = 1; this.secondary = 1; this.max = 1; this.min = 1
|
473
|
+
}
|
474
|
+
/**
|
475
|
+
* Calculate initial, secondary and maximum zoom level for the specified slide.
|
476
|
+
*
|
477
|
+
* It should be called when either image or viewport size changes.
|
478
|
+
*
|
479
|
+
* @param {number} maxWidth
|
480
|
+
* @param {number} maxHeight
|
481
|
+
* @param {Point} panAreaSize
|
482
|
+
*/update(t, e, i) {
|
483
|
+
/** @type {Point} */
|
484
|
+
const s = { x: t, y: e }; this.elementSize = s; this.panAreaSize = i; const n = i.x / s.x; const a = i.y / s.y; this.fit = Math.min(1, n < a ? n : a); this.fill = Math.min(1, n > a ? n : a); this.vFill = Math.min(1, a); this.initial = this._getInitial(); this.secondary = this._getSecondary(); this.max = Math.max(this.initial, this.secondary, this._getMax()); this.min = Math.min(this.fit, this.initial, this.secondary); this.pswp && this.pswp.dispatch("zoomLevelsUpdate", { zoomLevels: this, slideData: this.itemData })
|
485
|
+
}
|
486
|
+
/**
|
487
|
+
* Parses user-defined zoom option.
|
488
|
+
*
|
489
|
+
* @private
|
490
|
+
* @param {'initial' | 'secondary' | 'max'} optionPrefix Zoom level option prefix (initial, secondary, max)
|
491
|
+
* @returns { number | undefined }
|
492
|
+
*/_parseZoomLevelOption(t) {
|
493
|
+
const e =
|
494
|
+
/** @type {'initialZoomLevel' | 'secondaryZoomLevel' | 'maxZoomLevel'} */
|
495
|
+
t + "ZoomLevel"; const i = this.options[e]; if (i) return typeof i === "function" ? i(this) : i === "fill" ? this.fill : i === "fit" ? this.fit : Number(i)
|
496
|
+
} _getSecondary() { let t = this._parseZoomLevelOption("secondary"); if (t) return t; t = Math.min(1, this.fit * 3); this.elementSize && t * this.elementSize.x > e && (t = e / this.elementSize.x); return t } _getInitial() { return this._parseZoomLevelOption("initial") || this.fit } _getMax() { return this._parseZoomLevelOption("max") || Math.max(1, this.fit * 4) }
|
497
|
+
}
|
498
|
+
/**
|
499
|
+
* Lazy-load an image
|
500
|
+
* This function is used both by Lightbox and PhotoSwipe core,
|
501
|
+
* thus it can be called before dialog is opened.
|
502
|
+
*
|
503
|
+
* @param {SlideData} itemData Data about the slide
|
504
|
+
* @param {PhotoSwipeBase} instance PhotoSwipe or PhotoSwipeLightbox instance
|
505
|
+
* @param {number} index
|
506
|
+
* @returns {Content} Image that is being decoded or false.
|
507
|
+
*/function lazyLoadData(t, e, i) {
|
508
|
+
const s = e.createContentFromData(t, i);
|
509
|
+
/** @type {ZoomLevel | undefined} */let n; const { options: a } = e; if (a) { n = new ZoomLevel(a, t, -1); let l; l = e.pswp ? e.pswp.viewportSize : getViewportSize(a, e); const o = getPanAreaSize(a, l, t, i); n.update(s.width, s.height, o) } s.lazyLoad(); n && s.setDisplayedSize(Math.ceil(s.width * n.initial), Math.ceil(s.height * n.initial)); return s
|
510
|
+
}
|
511
|
+
/**
|
512
|
+
* Lazy-loads specific slide.
|
513
|
+
* This function is used both by Lightbox and PhotoSwipe core,
|
514
|
+
* thus it can be called before dialog is opened.
|
515
|
+
*
|
516
|
+
* By default, it loads image based on viewport size and initial zoom level.
|
517
|
+
*
|
518
|
+
* @param {number} index Slide index
|
519
|
+
* @param {PhotoSwipeBase} instance PhotoSwipe or PhotoSwipeLightbox eventable instance
|
520
|
+
* @returns {Content | undefined}
|
521
|
+
*/function lazyLoadSlide(t, e) { const i = e.getItemData(t); if (!e.dispatch("lazyLoadSlide", { index: t, itemData: i }).defaultPrevented) return lazyLoadData(i, e, t) }
|
522
|
+
/** @typedef {import("../photoswipe.js").default} PhotoSwipe */
|
523
|
+
/** @typedef {import("../slide/slide.js").SlideData} SlideData */class PhotoSwipeBase extends Eventable {
|
524
|
+
/**
|
525
|
+
* Get total number of slides
|
526
|
+
*
|
527
|
+
* @returns {number}
|
528
|
+
*/
|
529
|
+
getNumItems() { var t; let e = 0; const i = (t = this.options) === null || t === void 0 ? void 0 : t.dataSource; if (i && "length" in i) e = i.length; else if (i && "gallery" in i) { i.items || (i.items = this._getGalleryDOMElements(i.gallery)); i.items && (e = i.items.length) } const s = this.dispatch("numItems", { dataSource: i, numItems: e }); return this.applyFilters("numItems", s.numItems, i) }
|
530
|
+
/**
|
531
|
+
* @param {SlideData} slideData
|
532
|
+
* @param {number} index
|
533
|
+
* @returns {Content}
|
534
|
+
*/createContentFromData(t, e) { return new Content(t, this, e) }
|
535
|
+
/**
|
536
|
+
* Get item data by index.
|
537
|
+
*
|
538
|
+
* "item data" should contain normalized information that PhotoSwipe needs to generate a slide.
|
539
|
+
* For example, it may contain properties like
|
540
|
+
* `src`, `srcset`, `w`, `h`, which will be used to generate a slide with image.
|
541
|
+
*
|
542
|
+
* @param {number} index
|
543
|
+
* @returns {SlideData}
|
544
|
+
*/getItemData(t) {
|
545
|
+
var e; const i = (e = this.options) === null || e === void 0 ? void 0 : e.dataSource;
|
546
|
+
/** @type {SlideData | HTMLElement} */let s = {}; if (Array.isArray(i)) s = i[t]; else if (i && "gallery" in i) { i.items || (i.items = this._getGalleryDOMElements(i.gallery)); s = i.items[t] } let n = s; n instanceof Element && (n = this._domElementToItemData(n)); const a = this.dispatch("itemData", { itemData: n || {}, index: t }); return this.applyFilters("itemData", a.itemData, t)
|
547
|
+
}
|
548
|
+
/**
|
549
|
+
* Get array of gallery DOM elements,
|
550
|
+
* based on childSelector and gallery element.
|
551
|
+
*
|
552
|
+
* @param {HTMLElement} galleryElement
|
553
|
+
* @returns {HTMLElement[]}
|
554
|
+
*/_getGalleryDOMElements(t) { var e, i; return (e = this.options) !== null && e !== void 0 && e.children || (i = this.options) !== null && i !== void 0 && i.childSelector ? getElementsFromOption(this.options.children, this.options.childSelector, t) || [] : [t] }
|
555
|
+
/**
|
556
|
+
* Converts DOM element to item data object.
|
557
|
+
*
|
558
|
+
* @param {HTMLElement} element DOM element
|
559
|
+
* @returns {SlideData}
|
560
|
+
*/_domElementToItemData(t) {
|
561
|
+
/** @type {SlideData} */
|
562
|
+
const e = { element: t }; const i =
|
563
|
+
/** @type {HTMLAnchorElement} */
|
564
|
+
t.tagName === "A" ? t : t.querySelector("a"); if (i) { e.src = i.dataset.pswpSrc || i.href; i.dataset.pswpSrcset && (e.srcset = i.dataset.pswpSrcset); e.width = i.dataset.pswpWidth ? parseInt(i.dataset.pswpWidth, 10) : 0; e.height = i.dataset.pswpHeight ? parseInt(i.dataset.pswpHeight, 10) : 0; e.w = e.width; e.h = e.height; i.dataset.pswpType && (e.type = i.dataset.pswpType); const n = t.querySelector("img"); if (n) { var s; e.msrc = n.currentSrc || n.src; e.alt = (s = n.getAttribute("alt")) !== null && s !== void 0 ? s : "" } (i.dataset.pswpCropped || i.dataset.cropped) && (e.thumbCropped = true) } return this.applyFilters("domItemData", e, t, i)
|
565
|
+
}
|
566
|
+
/**
|
567
|
+
* Lazy-load by slide data
|
568
|
+
*
|
569
|
+
* @param {SlideData} itemData Data about the slide
|
570
|
+
* @param {number} index
|
571
|
+
* @returns {Content} Image that is being decoded or false.
|
572
|
+
*/lazyLoadData(t, e) { return lazyLoadData(t, this, e) }
|
573
|
+
}
|
574
|
+
/**
|
575
|
+
* @template T
|
576
|
+
* @typedef {import('../types.js').Type<T>} Type<T>
|
577
|
+
*/
|
578
|
+
/** @typedef {import('../photoswipe.js').default} PhotoSwipe */
|
579
|
+
/** @typedef {import('../photoswipe.js').PhotoSwipeOptions} PhotoSwipeOptions */
|
580
|
+
/** @typedef {import('../photoswipe.js').DataSource} DataSource */
|
581
|
+
/** @typedef {import('../photoswipe.js').Point} Point */
|
582
|
+
/** @typedef {import('../slide/content.js').default} Content */
|
583
|
+
/** @typedef {import('../core/eventable.js').PhotoSwipeEventsMap} PhotoSwipeEventsMap */
|
584
|
+
/** @typedef {import('../core/eventable.js').PhotoSwipeFiltersMap} PhotoSwipeFiltersMap */
|
585
|
+
/**
|
586
|
+
* @template {keyof PhotoSwipeEventsMap} T
|
587
|
+
* @typedef {import('../core/eventable.js').EventCallback<T>} EventCallback<T>
|
588
|
+
*/class PhotoSwipeLightbox extends PhotoSwipeBase {
|
589
|
+
/**
|
590
|
+
* @param {PhotoSwipeOptions} [options]
|
591
|
+
*/
|
592
|
+
constructor(t) {
|
593
|
+
super();
|
594
|
+
/** @type {PhotoSwipeOptions} */this.options = t || {}; this._uid = 0; this.shouldOpen = false;
|
595
|
+
/**
|
596
|
+
* @private
|
597
|
+
* @type {Content | undefined}
|
598
|
+
*/this._preloadedContent = void 0; this.onThumbnailsClick = this.onThumbnailsClick.bind(this)
|
599
|
+
} init() { getElementsFromOption(this.options.gallery, this.options.gallerySelector).forEach((t => { t.addEventListener("click", this.onThumbnailsClick, false) })) }
|
600
|
+
/**
|
601
|
+
* @param {MouseEvent} e
|
602
|
+
*/onThumbnailsClick(t) {
|
603
|
+
if (specialKeyUsed(t) || window.pswp) return;
|
604
|
+
/** @type {Point | null} */let e = { x: t.clientX, y: t.clientY }; e.x || e.y || (e = null); let i = this.getClickedIndex(t); i = this.applyFilters("clickedIndex", i, t, this);
|
605
|
+
/** @type {DataSource} */const s = {
|
606
|
+
gallery:
|
607
|
+
/** @type {HTMLElement} */
|
608
|
+
t.currentTarget
|
609
|
+
}; if (i >= 0) { t.preventDefault(); this.loadAndOpen(i, s, e) }
|
610
|
+
}
|
611
|
+
/**
|
612
|
+
* Get index of gallery item that was clicked.
|
613
|
+
*
|
614
|
+
* @param {MouseEvent} e click event
|
615
|
+
* @returns {number}
|
616
|
+
*/getClickedIndex(t) {
|
617
|
+
if (this.options.getClickedIndexFn) return this.options.getClickedIndexFn.call(this, t); const e =
|
618
|
+
/** @type {HTMLElement} */
|
619
|
+
t.target; const i = getElementsFromOption(this.options.children, this.options.childSelector,
|
620
|
+
/** @type {HTMLElement} */
|
621
|
+
t.currentTarget); const s = i.findIndex((t => t === e || t.contains(e))); return s !== -1 ? s : this.options.children || this.options.childSelector ? -1 : 0
|
622
|
+
}
|
623
|
+
/**
|
624
|
+
* Load and open PhotoSwipe
|
625
|
+
*
|
626
|
+
* @param {number} index
|
627
|
+
* @param {DataSource} [dataSource]
|
628
|
+
* @param {Point | null} [initialPoint]
|
629
|
+
* @returns {boolean}
|
630
|
+
*/loadAndOpen(t, e, i) { if (window.pswp || !this.options) return false; if (!e && this.options.gallery && this.options.children) { const t = getElementsFromOption(this.options.gallery); t[0] && (e = { gallery: t[0] }) } this.options.index = t; this.options.initialPointerPos = i; this.shouldOpen = true; this.preload(t, e); return true }
|
631
|
+
/**
|
632
|
+
* Load the main module and the slide content by index
|
633
|
+
*
|
634
|
+
* @param {number} index
|
635
|
+
* @param {DataSource} [dataSource]
|
636
|
+
*/preload(t, e) {
|
637
|
+
const { options: i } = this; e && (i.dataSource = e);
|
638
|
+
/** @type {Promise<Type<PhotoSwipe>>[]} */const s = []; const n = typeof i.pswpModule; if (isPswpClass(i.pswpModule)) s.push(Promise.resolve(
|
639
|
+
/** @type {Type<PhotoSwipe>} */
|
640
|
+
i.pswpModule)); else {
|
641
|
+
if (n === "string") throw new Error("pswpModule as string is no longer supported"); if (n !== "function") throw new Error("pswpModule is not valid"); s.push(
|
642
|
+
/** @type {() => Promise<Type<PhotoSwipe>>} */
|
643
|
+
i.pswpModule())
|
644
|
+
} typeof i.openPromise === "function" && s.push(i.openPromise()); i.preloadFirstSlide !== false && t >= 0 && (this._preloadedContent = lazyLoadSlide(t, this)); const a = ++this._uid; Promise.all(s).then((t => { if (this.shouldOpen) { const e = t[0]; this._openPhotoswipe(e, a) } }))
|
645
|
+
}
|
646
|
+
/**
|
647
|
+
* @private
|
648
|
+
* @param {Type<PhotoSwipe> | { default: Type<PhotoSwipe> }} module
|
649
|
+
* @param {number} uid
|
650
|
+
*/_openPhotoswipe(t, e) {
|
651
|
+
if (e !== this._uid && this.shouldOpen) return; this.shouldOpen = false; if (window.pswp) return;
|
652
|
+
/**
|
653
|
+
* Pass data to PhotoSwipe and open init
|
654
|
+
*
|
655
|
+
* @type {PhotoSwipe}
|
656
|
+
*/const i = typeof t === "object" ? new t.default(this.options) : new t(this.options); this.pswp = i; window.pswp = i;
|
657
|
+
/** @type {(keyof PhotoSwipeEventsMap)[]} */Object.keys(this._listeners).forEach((t => {
|
658
|
+
var e; (e = this._listeners[t]) === null || e === void 0 || e.forEach((e => {
|
659
|
+
i.on(t,
|
660
|
+
/** @type {EventCallback<typeof name>} */
|
661
|
+
e)
|
662
|
+
}))
|
663
|
+
}));
|
664
|
+
/** @type {(keyof PhotoSwipeFiltersMap)[]} */Object.keys(this._filters).forEach((t => { var e; (e = this._filters[t]) === null || e === void 0 || e.forEach((e => { i.addFilter(t, e.fn, e.priority) })) })); if (this._preloadedContent) { i.contentLoader.addToCache(this._preloadedContent); this._preloadedContent = void 0 } i.on("destroy", (() => { this.pswp = void 0; delete window.pswp })); i.init()
|
665
|
+
} destroy() { var t; (t = this.pswp) === null || t === void 0 || t.destroy(); this.shouldOpen = false; this._listeners = {}; getElementsFromOption(this.options.gallery, this.options.gallerySelector).forEach((t => { t.removeEventListener("click", this.onThumbnailsClick, false) })) }
|
666
|
+
} export { PhotoSwipeLightbox as default };
|
667
|
+
//# sourceMappingURL=photoswipe-lightbox.esm.js.map
|