@anker-in/headless-ui 1.2.2 → 1.2.3-alpha.1778583232121
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.
- package/dist/cjs/biz-components/AccordionCards/index.js +1 -1
- package/dist/cjs/biz-components/AccordionCards/index.js.map +3 -3
- package/dist/cjs/biz-components/ActivityMechanism/index.js +1 -1
- package/dist/cjs/biz-components/ActivityMechanism/index.js.map +3 -3
- package/dist/cjs/biz-components/ActivitySchedule/index.js +1 -1
- package/dist/cjs/biz-components/ActivitySchedule/index.js.map +3 -3
- package/dist/cjs/biz-components/AiuiProvider/index.js +1 -1
- package/dist/cjs/biz-components/AiuiProvider/index.js.map +3 -3
- package/dist/cjs/biz-components/AnchorNavigation/index.js +1 -1
- package/dist/cjs/biz-components/AnchorNavigation/index.js.map +3 -3
- package/dist/cjs/biz-components/BrandCardLink/BrandCardLink.js +1 -1
- package/dist/cjs/biz-components/BrandCardLink/BrandCardLink.js.map +3 -3
- package/dist/cjs/biz-components/Category/SwiperCategory.js +1 -1
- package/dist/cjs/biz-components/Category/SwiperCategory.js.map +3 -3
- package/dist/cjs/biz-components/Category/index.js +1 -1
- package/dist/cjs/biz-components/Category/index.js.map +3 -3
- package/dist/cjs/biz-components/Evaluate/index.js +1 -1
- package/dist/cjs/biz-components/Evaluate/index.js.map +3 -3
- package/dist/cjs/biz-components/EventSchedule/index.js +1 -1
- package/dist/cjs/biz-components/EventSchedule/index.js.map +3 -3
- package/dist/cjs/biz-components/Faq/Faq.js +1 -1
- package/dist/cjs/biz-components/Faq/Faq.js.map +2 -2
- package/dist/cjs/biz-components/Faq/types.d.ts +0 -1
- package/dist/cjs/biz-components/Faq/types.js +1 -1
- package/dist/cjs/biz-components/Faq/types.js.map +1 -1
- package/dist/cjs/biz-components/FeatureCards/FeatureCards.js +1 -1
- package/dist/cjs/biz-components/FeatureCards/FeatureCards.js.map +3 -3
- package/dist/cjs/biz-components/GiftBox/index.js +1 -1
- package/dist/cjs/biz-components/GiftBox/index.js.map +2 -2
- package/dist/cjs/biz-components/GiftShelf/index.js +1 -1
- package/dist/cjs/biz-components/GiftShelf/index.js.map +3 -3
- package/dist/cjs/biz-components/GiftTierShelf/index.js +1 -1
- package/dist/cjs/biz-components/GiftTierShelf/index.js.map +3 -3
- package/dist/cjs/biz-components/Graphic/index.js +1 -1
- package/dist/cjs/biz-components/Graphic/index.js.map +2 -2
- package/dist/cjs/biz-components/GraphicOverlay/GraphicOverlay.js +1 -1
- package/dist/cjs/biz-components/GraphicOverlay/GraphicOverlay.js.map +3 -3
- package/dist/cjs/biz-components/HeaderNavigation/MobileTextLinksMenu.d.ts +12 -0
- package/dist/cjs/biz-components/HeaderNavigation/MobileTextLinksMenu.js +2 -0
- package/dist/cjs/biz-components/HeaderNavigation/MobileTextLinksMenu.js.map +7 -0
- package/dist/cjs/biz-components/HeaderNavigation/TextLinksDropdown.d.ts +10 -0
- package/dist/cjs/biz-components/HeaderNavigation/TextLinksDropdown.js +2 -0
- package/dist/cjs/biz-components/HeaderNavigation/TextLinksDropdown.js.map +7 -0
- package/dist/cjs/biz-components/HeaderNavigation/index.js +1 -1
- package/dist/cjs/biz-components/HeaderNavigation/index.js.map +3 -3
- package/dist/cjs/biz-components/HeaderNavigation/types.d.ts +8 -1
- package/dist/cjs/biz-components/HeaderNavigation/types.js +1 -1
- package/dist/cjs/biz-components/HeaderNavigation/types.js.map +2 -2
- package/dist/cjs/biz-components/HeaderNavigation/withCategory.d.ts +1 -0
- package/dist/cjs/biz-components/HeaderNavigation/withCategory.js +1 -1
- package/dist/cjs/biz-components/HeaderNavigation/withCategory.js.map +3 -3
- package/dist/cjs/biz-components/HeroBanner/HeroBanner.js +1 -1
- package/dist/cjs/biz-components/HeroBanner/HeroBanner.js.map +3 -3
- package/dist/cjs/biz-components/HeroBanner/HeroBannerCarousel.js +1 -1
- package/dist/cjs/biz-components/HeroBanner/HeroBannerCarousel.js.map +3 -3
- package/dist/cjs/biz-components/HeroBanner/types.d.ts +5 -0
- package/dist/cjs/biz-components/HeroBanner/types.js +1 -1
- package/dist/cjs/biz-components/HeroBanner/types.js.map +1 -1
- package/dist/cjs/biz-components/ImageOverlayShelf/ProductCard.js +1 -1
- package/dist/cjs/biz-components/ImageOverlayShelf/ProductCard.js.map +2 -2
- package/dist/cjs/biz-components/ImageWithText/ImageWithText.js +1 -1
- package/dist/cjs/biz-components/ImageWithText/ImageWithText.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/types.d.ts +2 -0
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/types.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/types.js.map +1 -1
- package/dist/cjs/biz-components/LotteryShared/ErrorModal.d.ts +4 -0
- package/dist/cjs/biz-components/LotteryShared/ErrorModal.js.map +2 -2
- package/dist/cjs/biz-components/LotteryShared/MyRewardsModal.d.ts +13 -13
- package/dist/cjs/biz-components/LotteryShared/MyRewardsModal.js +1 -1
- package/dist/cjs/biz-components/LotteryShared/MyRewardsModal.js.map +3 -3
- package/dist/cjs/biz-components/LotteryShared/types.d.ts +9 -0
- package/dist/cjs/biz-components/LotteryShared/types.js.map +2 -2
- package/dist/cjs/biz-components/Marquee/Marquee.d.ts +11 -4
- package/dist/cjs/biz-components/Marquee/Marquee.js +1 -1
- package/dist/cjs/biz-components/Marquee/Marquee.js.map +3 -3
- package/dist/cjs/biz-components/Marquee/index.d.ts +1 -1
- package/dist/cjs/biz-components/Marquee/index.js +1 -1
- package/dist/cjs/biz-components/Marquee/index.js.map +2 -2
- package/dist/cjs/biz-components/Marquee/type.d.ts +22 -4
- package/dist/cjs/biz-components/Marquee/type.js +1 -1
- package/dist/cjs/biz-components/Marquee/type.js.map +1 -1
- package/dist/cjs/biz-components/Media/index.js +1 -1
- package/dist/cjs/biz-components/Media/index.js.map +2 -2
- package/dist/cjs/biz-components/MediaPlayerBase/index.js +1 -1
- package/dist/cjs/biz-components/MediaPlayerBase/index.js.map +3 -3
- package/dist/cjs/biz-components/MediaPlayerMulti/index.js +1 -1
- package/dist/cjs/biz-components/MediaPlayerMulti/index.js.map +3 -3
- package/dist/cjs/biz-components/MediaTextOverlay/MediaTextOverlay.d.ts +9 -0
- package/dist/cjs/biz-components/MediaTextOverlay/MediaTextOverlay.js +2 -0
- package/dist/cjs/biz-components/MediaTextOverlay/MediaTextOverlay.js.map +7 -0
- package/dist/cjs/biz-components/MediaTextOverlay/index.d.ts +2 -0
- package/dist/cjs/biz-components/MediaTextOverlay/index.js +2 -0
- package/dist/cjs/biz-components/MediaTextOverlay/index.js.map +7 -0
- package/dist/cjs/biz-components/MediaTextOverlay/types.d.ts +24 -0
- package/dist/cjs/biz-components/MediaTextOverlay/types.js +2 -0
- package/dist/cjs/biz-components/MediaTextOverlay/types.js.map +7 -0
- package/dist/cjs/biz-components/MemberEquity/index.js +2 -2
- package/dist/cjs/biz-components/MemberEquity/index.js.map +3 -3
- package/dist/cjs/biz-components/MultiLayoutGraphicBlock/MultiLayoutGraphicBlock.js +1 -1
- package/dist/cjs/biz-components/MultiLayoutGraphicBlock/MultiLayoutGraphicBlock.js.map +3 -3
- package/dist/cjs/biz-components/NavigationSearch/index.js +2 -2
- package/dist/cjs/biz-components/NavigationSearch/index.js.map +2 -2
- package/dist/cjs/biz-components/ProductHero/ProductHero.js +1 -1
- package/dist/cjs/biz-components/ProductHero/ProductHero.js.map +3 -3
- package/dist/cjs/biz-components/ProductLottery/types.d.ts +62 -5
- package/dist/cjs/biz-components/ProductLottery/types.js +1 -1
- package/dist/cjs/biz-components/ProductLottery/types.js.map +2 -2
- package/dist/cjs/biz-components/ProductNav/ProductNav.js +1 -1
- package/dist/cjs/biz-components/ProductNav/ProductNav.js.map +3 -3
- package/dist/cjs/biz-components/PromotionalBar/index.js +1 -1
- package/dist/cjs/biz-components/PromotionalBar/index.js.map +3 -3
- package/dist/cjs/biz-components/SecondaryBanner/SecondaryBannerCarousel.d.ts +1 -0
- package/dist/cjs/biz-components/SecondaryBanner/SecondaryBannerCarousel.js +1 -1
- package/dist/cjs/biz-components/SecondaryBanner/SecondaryBannerCarousel.js.map +3 -3
- package/dist/cjs/biz-components/SecondaryBanner/index.d.ts +9 -0
- package/dist/cjs/biz-components/SecondaryBanner/index.js +1 -1
- package/dist/cjs/biz-components/SecondaryBanner/index.js.map +3 -3
- package/dist/cjs/biz-components/ShelfDisplay/index.js +1 -1
- package/dist/cjs/biz-components/ShelfDisplay/index.js.map +2 -2
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplay.d.ts +1 -0
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplay.js +1 -1
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplay.js.map +1 -1
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js +1 -1
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js.map +3 -3
- package/dist/cjs/biz-components/Subscribe/index.js +1 -1
- package/dist/cjs/biz-components/Subscribe/index.js.map +2 -2
- package/dist/cjs/biz-components/SwiperBox/index.js +1 -1
- package/dist/cjs/biz-components/SwiperBox/index.js.map +3 -3
- package/dist/cjs/biz-components/ThreeDCarousel/ThreeDCarousel.js +1 -1
- package/dist/cjs/biz-components/ThreeDCarousel/ThreeDCarousel.js.map +3 -3
- package/dist/cjs/biz-components/Title/index.js +1 -1
- package/dist/cjs/biz-components/Title/index.js.map +3 -3
- package/dist/cjs/biz-components/WebPushPopup/index.d.ts +44 -0
- package/dist/cjs/biz-components/WebPushPopup/index.js +2 -0
- package/dist/cjs/biz-components/WebPushPopup/index.js.map +7 -0
- package/dist/cjs/biz-components/WheelLottery/index.js +1 -1
- package/dist/cjs/biz-components/WheelLottery/index.js.map +3 -3
- package/dist/cjs/biz-components/index.d.ts +6 -0
- package/dist/cjs/biz-components/index.js +1 -1
- package/dist/cjs/biz-components/index.js.map +3 -3
- package/dist/cjs/components/Countdown.js +1 -1
- package/dist/cjs/components/Countdown.js.map +3 -3
- package/dist/cjs/components/button.d.ts +4 -0
- package/dist/cjs/components/button.js +1 -1
- package/dist/cjs/components/button.js.map +3 -3
- package/dist/cjs/components/link.js +1 -1
- package/dist/cjs/components/link.js.map +2 -2
- package/dist/cjs/helpers/index.d.ts +1 -1
- package/dist/cjs/helpers/index.js +1 -1
- package/dist/cjs/helpers/index.js.map +2 -2
- package/dist/cjs/helpers/isLexicalEmpty.d.ts +5 -0
- package/dist/cjs/helpers/isLexicalEmpty.js +1 -1
- package/dist/cjs/helpers/isLexicalEmpty.js.map +3 -3
- package/dist/cjs/hooks/useEmarsysWebPush.d.ts +111 -0
- package/dist/cjs/hooks/useEmarsysWebPush.js +2 -0
- package/dist/cjs/hooks/useEmarsysWebPush.js.map +7 -0
- package/dist/cjs/hooks/useProductListTrack.d.ts +43 -0
- package/dist/cjs/hooks/useProductListTrack.js +2 -0
- package/dist/cjs/hooks/useProductListTrack.js.map +7 -0
- package/dist/esm/biz-components/AccordionCards/index.js +1 -1
- package/dist/esm/biz-components/AccordionCards/index.js.map +3 -3
- package/dist/esm/biz-components/ActivityMechanism/index.js +1 -1
- package/dist/esm/biz-components/ActivityMechanism/index.js.map +3 -3
- package/dist/esm/biz-components/ActivitySchedule/index.js +1 -1
- package/dist/esm/biz-components/ActivitySchedule/index.js.map +3 -3
- package/dist/esm/biz-components/AiuiProvider/index.js +1 -1
- package/dist/esm/biz-components/AiuiProvider/index.js.map +3 -3
- package/dist/esm/biz-components/AnchorNavigation/index.js +1 -1
- package/dist/esm/biz-components/AnchorNavigation/index.js.map +3 -3
- package/dist/esm/biz-components/BrandCardLink/BrandCardLink.js +1 -1
- package/dist/esm/biz-components/BrandCardLink/BrandCardLink.js.map +3 -3
- package/dist/esm/biz-components/Category/SwiperCategory.js +1 -1
- package/dist/esm/biz-components/Category/SwiperCategory.js.map +3 -3
- package/dist/esm/biz-components/Category/index.js +1 -1
- package/dist/esm/biz-components/Category/index.js.map +3 -3
- package/dist/esm/biz-components/Evaluate/index.js +1 -1
- package/dist/esm/biz-components/Evaluate/index.js.map +3 -3
- package/dist/esm/biz-components/EventSchedule/index.js +1 -1
- package/dist/esm/biz-components/EventSchedule/index.js.map +3 -3
- package/dist/esm/biz-components/Faq/Faq.js +1 -1
- package/dist/esm/biz-components/Faq/Faq.js.map +2 -2
- package/dist/esm/biz-components/Faq/types.d.ts +0 -1
- package/dist/esm/biz-components/FeatureCards/FeatureCards.js +1 -1
- package/dist/esm/biz-components/FeatureCards/FeatureCards.js.map +3 -3
- package/dist/esm/biz-components/GiftBox/index.js +1 -1
- package/dist/esm/biz-components/GiftBox/index.js.map +2 -2
- package/dist/esm/biz-components/GiftShelf/index.js +1 -1
- package/dist/esm/biz-components/GiftShelf/index.js.map +3 -3
- package/dist/esm/biz-components/GiftTierShelf/index.js +1 -1
- package/dist/esm/biz-components/GiftTierShelf/index.js.map +3 -3
- package/dist/esm/biz-components/Graphic/index.js +1 -1
- package/dist/esm/biz-components/Graphic/index.js.map +2 -2
- package/dist/esm/biz-components/GraphicOverlay/GraphicOverlay.js +1 -1
- package/dist/esm/biz-components/GraphicOverlay/GraphicOverlay.js.map +3 -3
- package/dist/esm/biz-components/HeaderNavigation/MobileTextLinksMenu.d.ts +12 -0
- package/dist/esm/biz-components/HeaderNavigation/MobileTextLinksMenu.js +2 -0
- package/dist/esm/biz-components/HeaderNavigation/MobileTextLinksMenu.js.map +7 -0
- package/dist/esm/biz-components/HeaderNavigation/TextLinksDropdown.d.ts +10 -0
- package/dist/esm/biz-components/HeaderNavigation/TextLinksDropdown.js +2 -0
- package/dist/esm/biz-components/HeaderNavigation/TextLinksDropdown.js.map +7 -0
- package/dist/esm/biz-components/HeaderNavigation/index.js +1 -1
- package/dist/esm/biz-components/HeaderNavigation/index.js.map +3 -3
- package/dist/esm/biz-components/HeaderNavigation/types.d.ts +8 -1
- package/dist/esm/biz-components/HeaderNavigation/types.js +1 -1
- package/dist/esm/biz-components/HeaderNavigation/types.js.map +2 -2
- package/dist/esm/biz-components/HeaderNavigation/withCategory.d.ts +1 -0
- package/dist/esm/biz-components/HeaderNavigation/withCategory.js +1 -1
- package/dist/esm/biz-components/HeaderNavigation/withCategory.js.map +3 -3
- package/dist/esm/biz-components/HeroBanner/HeroBanner.js +1 -1
- package/dist/esm/biz-components/HeroBanner/HeroBanner.js.map +3 -3
- package/dist/esm/biz-components/HeroBanner/HeroBannerCarousel.js +1 -1
- package/dist/esm/biz-components/HeroBanner/HeroBannerCarousel.js.map +3 -3
- package/dist/esm/biz-components/HeroBanner/types.d.ts +5 -0
- package/dist/esm/biz-components/ImageOverlayShelf/ProductCard.js +1 -1
- package/dist/esm/biz-components/ImageOverlayShelf/ProductCard.js.map +2 -2
- package/dist/esm/biz-components/ImageWithText/ImageWithText.js +1 -1
- package/dist/esm/biz-components/ImageWithText/ImageWithText.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/PurchaseBar/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/PurchaseBar/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/PurchaseBar/types.d.ts +2 -0
- package/dist/esm/biz-components/LotteryShared/ErrorModal.d.ts +4 -0
- package/dist/esm/biz-components/LotteryShared/ErrorModal.js.map +2 -2
- package/dist/esm/biz-components/LotteryShared/MyRewardsModal.d.ts +13 -13
- package/dist/esm/biz-components/LotteryShared/MyRewardsModal.js +1 -1
- package/dist/esm/biz-components/LotteryShared/MyRewardsModal.js.map +3 -3
- package/dist/esm/biz-components/LotteryShared/types.d.ts +9 -0
- package/dist/esm/biz-components/LotteryShared/types.js.map +2 -2
- package/dist/esm/biz-components/Marquee/Marquee.d.ts +11 -4
- package/dist/esm/biz-components/Marquee/Marquee.js +1 -1
- package/dist/esm/biz-components/Marquee/Marquee.js.map +3 -3
- package/dist/esm/biz-components/Marquee/index.d.ts +1 -1
- package/dist/esm/biz-components/Marquee/index.js +1 -1
- package/dist/esm/biz-components/Marquee/index.js.map +3 -3
- package/dist/esm/biz-components/Marquee/type.d.ts +22 -4
- package/dist/esm/biz-components/Media/index.js +1 -1
- package/dist/esm/biz-components/Media/index.js.map +2 -2
- package/dist/esm/biz-components/MediaPlayerBase/index.js +1 -1
- package/dist/esm/biz-components/MediaPlayerBase/index.js.map +3 -3
- package/dist/esm/biz-components/MediaPlayerMulti/index.js +1 -1
- package/dist/esm/biz-components/MediaPlayerMulti/index.js.map +3 -3
- package/dist/esm/biz-components/MediaTextOverlay/MediaTextOverlay.d.ts +9 -0
- package/dist/esm/biz-components/MediaTextOverlay/MediaTextOverlay.js +2 -0
- package/dist/esm/biz-components/MediaTextOverlay/MediaTextOverlay.js.map +7 -0
- package/dist/esm/biz-components/MediaTextOverlay/index.d.ts +2 -0
- package/dist/esm/biz-components/MediaTextOverlay/index.js +2 -0
- package/dist/esm/biz-components/MediaTextOverlay/index.js.map +7 -0
- package/dist/esm/biz-components/MediaTextOverlay/types.d.ts +24 -0
- package/dist/esm/biz-components/MediaTextOverlay/types.js +1 -0
- package/dist/esm/biz-components/MediaTextOverlay/types.js.map +7 -0
- package/dist/esm/biz-components/MemberEquity/index.js +2 -2
- package/dist/esm/biz-components/MemberEquity/index.js.map +3 -3
- package/dist/esm/biz-components/MultiLayoutGraphicBlock/MultiLayoutGraphicBlock.js +1 -1
- package/dist/esm/biz-components/MultiLayoutGraphicBlock/MultiLayoutGraphicBlock.js.map +3 -3
- package/dist/esm/biz-components/NavigationSearch/index.js +2 -2
- package/dist/esm/biz-components/NavigationSearch/index.js.map +3 -3
- package/dist/esm/biz-components/ProductHero/ProductHero.js +1 -1
- package/dist/esm/biz-components/ProductHero/ProductHero.js.map +3 -3
- package/dist/esm/biz-components/ProductLottery/types.d.ts +62 -5
- package/dist/esm/biz-components/ProductLottery/types.js.map +2 -2
- package/dist/esm/biz-components/ProductNav/ProductNav.js +1 -1
- package/dist/esm/biz-components/ProductNav/ProductNav.js.map +3 -3
- package/dist/esm/biz-components/PromotionalBar/index.js +1 -1
- package/dist/esm/biz-components/PromotionalBar/index.js.map +3 -3
- package/dist/esm/biz-components/SecondaryBanner/SecondaryBannerCarousel.d.ts +1 -0
- package/dist/esm/biz-components/SecondaryBanner/SecondaryBannerCarousel.js +1 -1
- package/dist/esm/biz-components/SecondaryBanner/SecondaryBannerCarousel.js.map +3 -3
- package/dist/esm/biz-components/SecondaryBanner/index.d.ts +9 -0
- package/dist/esm/biz-components/SecondaryBanner/index.js +1 -1
- package/dist/esm/biz-components/SecondaryBanner/index.js.map +3 -3
- package/dist/esm/biz-components/ShelfDisplay/index.js +1 -1
- package/dist/esm/biz-components/ShelfDisplay/index.js.map +2 -2
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplay.d.ts +1 -0
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplay.js.map +1 -1
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js +1 -1
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js.map +3 -3
- package/dist/esm/biz-components/Subscribe/index.js +1 -1
- package/dist/esm/biz-components/Subscribe/index.js.map +2 -2
- package/dist/esm/biz-components/SwiperBox/index.js +1 -1
- package/dist/esm/biz-components/SwiperBox/index.js.map +3 -3
- package/dist/esm/biz-components/ThreeDCarousel/ThreeDCarousel.js +1 -1
- package/dist/esm/biz-components/ThreeDCarousel/ThreeDCarousel.js.map +3 -3
- package/dist/esm/biz-components/Title/index.js +1 -1
- package/dist/esm/biz-components/Title/index.js.map +3 -3
- package/dist/esm/biz-components/WebPushPopup/index.d.ts +44 -0
- package/dist/esm/biz-components/WebPushPopup/index.js +2 -0
- package/dist/esm/biz-components/WebPushPopup/index.js.map +7 -0
- package/dist/esm/biz-components/WheelLottery/index.js +1 -1
- package/dist/esm/biz-components/WheelLottery/index.js.map +2 -2
- package/dist/esm/biz-components/index.d.ts +6 -0
- package/dist/esm/biz-components/index.js +1 -1
- package/dist/esm/biz-components/index.js.map +3 -3
- package/dist/esm/components/Countdown.js +1 -1
- package/dist/esm/components/Countdown.js.map +3 -3
- package/dist/esm/components/button.d.ts +4 -0
- package/dist/esm/components/button.js +1 -1
- package/dist/esm/components/button.js.map +3 -3
- package/dist/esm/components/link.js +1 -1
- package/dist/esm/components/link.js.map +2 -2
- package/dist/esm/helpers/index.d.ts +1 -1
- package/dist/esm/helpers/index.js +1 -1
- package/dist/esm/helpers/index.js.map +3 -3
- package/dist/esm/helpers/isLexicalEmpty.d.ts +5 -0
- package/dist/esm/helpers/isLexicalEmpty.js +1 -1
- package/dist/esm/helpers/isLexicalEmpty.js.map +3 -3
- package/dist/esm/hooks/useEmarsysWebPush.d.ts +111 -0
- package/dist/esm/hooks/useEmarsysWebPush.js +2 -0
- package/dist/esm/hooks/useEmarsysWebPush.js.map +7 -0
- package/dist/esm/hooks/useProductListTrack.d.ts +43 -0
- package/dist/esm/hooks/useProductListTrack.js +2 -0
- package/dist/esm/hooks/useProductListTrack.js.map +7 -0
- package/package.json +1 -1
- package/style.css +143 -11
- package/tailwind.config.js +10 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export interface EmarsysContactInfo {
|
|
2
|
+
/** Emarsys 联系人字段 ID(如 10372) */
|
|
3
|
+
fieldId: number;
|
|
4
|
+
/** 字段值(如用户唯一标识) */
|
|
5
|
+
fieldValue: string;
|
|
6
|
+
}
|
|
7
|
+
export interface EmarsysInitConfig {
|
|
8
|
+
/** Emarsys Domain Code,从后台获取 */
|
|
9
|
+
applicationCode: string;
|
|
10
|
+
/** macOS Safari 16+ 使用 VAPID 替代 APNS */
|
|
11
|
+
enableMacSafariVapid?: boolean;
|
|
12
|
+
/** 默认推送通知标题 */
|
|
13
|
+
defaultNotificationTitle?: string;
|
|
14
|
+
/** 默认推送通知图标 URL */
|
|
15
|
+
defaultNotificationIcon?: string;
|
|
16
|
+
/** 是否自动触发浏览器订阅弹窗,强烈建议设为 false */
|
|
17
|
+
autoSubscribe?: boolean;
|
|
18
|
+
/** 开发阶段开启 SDK 日志 */
|
|
19
|
+
enableLogging?: boolean;
|
|
20
|
+
serviceWorker: {
|
|
21
|
+
/** Service Worker 文件路径(需放在网站根目录) */
|
|
22
|
+
url: string;
|
|
23
|
+
/** VAPID 公钥(Base64 URL-safe 编码) */
|
|
24
|
+
applicationServerPublicKey: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
type EmarsysSdkEventName = 'onReady' | 'onSubscribe' | 'onUnsubscribe' | 'onPermissionPrompt' | 'onPermissionGranted' | 'onPermissionDenied' | 'onSWInitError';
|
|
28
|
+
type EmarsysSdkCommand = ['init', EmarsysInitConfig] | [EmarsysSdkEventName, () => void];
|
|
29
|
+
interface EmarsysSdkApi {
|
|
30
|
+
subscribe: () => void;
|
|
31
|
+
unsubscribe: () => void;
|
|
32
|
+
login: (contactInfo: EmarsysContactInfo) => Promise<boolean>;
|
|
33
|
+
logout: () => Promise<boolean>;
|
|
34
|
+
isSubscribed: () => Promise<boolean>;
|
|
35
|
+
isRegistered: () => boolean;
|
|
36
|
+
customEvent: (eventName: string, payload?: Record<string, unknown>) => Promise<boolean>;
|
|
37
|
+
push: (command: EmarsysSdkCommand | ((sdk: EmarsysSdkApi) => void)) => void;
|
|
38
|
+
}
|
|
39
|
+
declare global {
|
|
40
|
+
interface Window {
|
|
41
|
+
WebEmarsysSdk: EmarsysSdkApi | (EmarsysSdkCommand | ((sdk: EmarsysSdkApi) => void))[];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export interface UseEmarsysWebPushOptions {
|
|
45
|
+
/** Emarsys Domain Code */
|
|
46
|
+
applicationCode: string;
|
|
47
|
+
/** VAPID 公钥 */
|
|
48
|
+
applicationServerPublicKey: string;
|
|
49
|
+
/** Service Worker 路径,默认 'service-worker.js'(不含前导斜杠) */
|
|
50
|
+
serviceWorkerUrl?: string;
|
|
51
|
+
/** 默认通知标题 */
|
|
52
|
+
defaultNotificationTitle?: string;
|
|
53
|
+
/** 默认通知图标 URL */
|
|
54
|
+
defaultNotificationIcon?: string;
|
|
55
|
+
/** 联系人主键字段 ID(由 Emarsys 后台配置) */
|
|
56
|
+
fieldId: number;
|
|
57
|
+
/**
|
|
58
|
+
* 当前用户的联系人标识(如 hashed email / customer ID)。
|
|
59
|
+
* null 表示未登录的匿名访客。
|
|
60
|
+
*/
|
|
61
|
+
contactValue: string | null;
|
|
62
|
+
/** 是否开启调试日志,默认 false */
|
|
63
|
+
enableLogging?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* 点击"稍后"后的弹窗冷却天数,默认 7 天。
|
|
66
|
+
* 冷却期间不再展示自定义弹窗。
|
|
67
|
+
*/
|
|
68
|
+
dismissCooldownDays?: number;
|
|
69
|
+
/**
|
|
70
|
+
* SDK 是否已通过外部 <Script> 标签加载完毕。
|
|
71
|
+
* 传入此 flag 以便 hook 在正确时机初始化。
|
|
72
|
+
* 默认 true(假设 SDK 已经加载)。
|
|
73
|
+
*/
|
|
74
|
+
sdkLoaded?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface UseEmarsysWebPushReturn {
|
|
77
|
+
/** 手动触发浏览器原生订阅弹窗(供"订阅"按钮调用) */
|
|
78
|
+
subscribe: () => void;
|
|
79
|
+
/** 取消推送订阅 */
|
|
80
|
+
unsubscribe: () => void;
|
|
81
|
+
/** 是否应向用户展示自定义引导弹窗 */
|
|
82
|
+
shouldShowPopup: boolean;
|
|
83
|
+
/** 关闭自定义弹窗并写入冷却标记 */
|
|
84
|
+
dismissPopup: () => void;
|
|
85
|
+
/** 当前是否已订阅(异步检测完成后更新) */
|
|
86
|
+
isSubscribed: boolean;
|
|
87
|
+
/** SDK 是否就绪 */
|
|
88
|
+
isReady: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* useEmarsysWebPush
|
|
92
|
+
*
|
|
93
|
+
* 封装 Emarsys Web Push SDK 的订阅生命周期,包括:
|
|
94
|
+
* - SDK 初始化
|
|
95
|
+
* - 自定义弹窗展示逻辑(两步策略,避免直接触发浏览器原生弹窗)
|
|
96
|
+
* - 已登录联系人的 login / logout 自动管理
|
|
97
|
+
* - 已有订阅用户的迁移(从旧推送系统迁移)
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```tsx
|
|
101
|
+
* const { shouldShowPopup, subscribe, dismissPopup } = useEmarsysWebPush({
|
|
102
|
+
* applicationCode: process.env.NEXT_PUBLIC_EMARSYS_APP_CODE!,
|
|
103
|
+
* applicationServerPublicKey: process.env.NEXT_PUBLIC_EMARSYS_VAPID_PUBLIC_KEY!,
|
|
104
|
+
* fieldId: 10372,
|
|
105
|
+
* contactValue: user?.customerId ?? null,
|
|
106
|
+
* sdkLoaded: scriptLoaded,
|
|
107
|
+
* })
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export declare function useEmarsysWebPush({ applicationCode, applicationServerPublicKey, serviceWorkerUrl, defaultNotificationTitle, defaultNotificationIcon, fieldId, contactValue, enableLogging, dismissCooldownDays, sdkLoaded, }: UseEmarsysWebPushOptions): UseEmarsysWebPushReturn;
|
|
111
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var E=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var x=(e,i)=>{for(var o in i)E(e,o,{get:i[o],enumerable:!0})},T=(e,i,o,l)=>{if(i&&typeof i=="object"||typeof i=="function")for(let u of U(i))!D.call(e,u)&&u!==o&&E(e,u,{get:()=>i[u],enumerable:!(l=O(i,u))||l.enumerable});return e};var K=e=>T(E({},"__esModule",{value:!0}),e);var j={};x(j,{useEmarsysWebPush:()=>B});module.exports=K(j);var n=require("react");const w="emarsysSubscribe",m="emarsysLogin",W="anker_push_dismissed";function M(){return typeof navigator>"u"?!1:/iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase())}function Y(){return typeof window>"u"?!1:window.matchMedia("(display-mode: standalone)").matches||"standalone"in window.navigator&&window.navigator.standalone===!0}function a(e,i,o){try{if(e==="get")return localStorage.getItem(i);e==="set"&&o!==void 0&&localStorage.setItem(i,o),e==="remove"&&localStorage.removeItem(i)}catch{}return null}function c(){if(typeof window>"u")return null;const e=window.WebEmarsysSdk;return!e||Array.isArray(e)?null:e}function B({applicationCode:e,applicationServerPublicKey:i,serviceWorkerUrl:o="service-worker.js",defaultNotificationTitle:l,defaultNotificationIcon:u,fieldId:k,contactValue:d,enableLogging:h=!1,dismissCooldownDays:v=7,sdkLoaded:b=!0}){const[p,R]=(0,n.useState)(!1),[C,S]=(0,n.useState)(!1),[L,g]=(0,n.useState)(!1),y=(0,n.useRef)(!1),P=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(!b||typeof window>"u")return;const s=o.replace(/^\/+/,"").replace(/^https?:\/\/[^/]+\//,"");window.WebEmarsysSdk=window.WebEmarsysSdk||[],window.WebEmarsysSdk.push(["init",{applicationCode:e,enableMacSafariVapid:!0,defaultNotificationTitle:l,defaultNotificationIcon:u,autoSubscribe:!1,enableLogging:h,serviceWorker:{url:s,applicationServerPublicKey:i}}])},[b,e,i,o,l,u,h]);const f=(0,n.useCallback)(s=>{if(y.current)return;const r=c();r&&r.isSubscribed().then(t=>{t&&r.login({fieldId:k,fieldValue:s}).then(I=>{I&&(a("set",m,"login"),y.current=!0)})})},[k]),A=(0,n.useCallback)(()=>{const s=c();s&&s.isSubscribed().then(r=>{r&&s.logout().then(t=>{t&&(a("remove",m),y.current=!1)})})},[]);(0,n.useEffect)(()=>{if(!b||typeof window>"u"||M()&&!Y())return;window.WebEmarsysSdk=window.WebEmarsysSdk||[];const s=window.WebEmarsysSdk;s.push(["onReady",()=>{R(!0),c()?.isSubscribed().then(t=>{S(t)}),s.push(["onPermissionGranted",()=>{!a("get",w)&&!P.current&&(c()?.subscribe(),a("set",w,"subscribe"))}]);let r=!1;s.push(["onPermissionGranted",()=>{r=!0}]),s.push(["onPermissionDenied",()=>{r=!0}]),setTimeout(()=>{if(r)return;const t=a("get",W);t&&Date.now()-parseInt(t,10)<v*24*60*60*1e3||g(!0)},2e3)}]),s.push(["onSubscribe",()=>{S(!0),a("set",w,"subscribe"),d&&f(d)}]),s.push(["onUnsubscribe",()=>{S(!1)}])},[b,d,v,f]),(0,n.useEffect)(()=>{p&&(d?a("get",m)||f(d):a("get",m)&&A())},[p,d,f,A]);const G=(0,n.useCallback)(()=>{g(!1),P.current=!0;const s=c();if(!s){window.WebEmarsysSdk.push(t=>{t.subscribe()});return}s.subscribe()},[]),_=(0,n.useCallback)(()=>{c()?.unsubscribe()},[]),N=(0,n.useCallback)(()=>{g(!1),a("set",W,String(Date.now()))},[]);return{subscribe:G,unsubscribe:_,shouldShowPopup:L,dismissPopup:N,isSubscribed:C,isReady:p}}
|
|
2
|
+
//# sourceMappingURL=useEmarsysWebPush.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useEmarsysWebPush.ts"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useRef, useState } from 'react'\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Emarsys Web Push SDK \u5168\u5C40\u7C7B\u578B\u58F0\u660E\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface EmarsysContactInfo {\n /** Emarsys \u8054\u7CFB\u4EBA\u5B57\u6BB5 ID\uFF08\u5982 10372\uFF09 */\n fieldId: number\n /** \u5B57\u6BB5\u503C\uFF08\u5982\u7528\u6237\u552F\u4E00\u6807\u8BC6\uFF09 */\n fieldValue: string\n}\n\nexport interface EmarsysInitConfig {\n /** Emarsys Domain Code\uFF0C\u4ECE\u540E\u53F0\u83B7\u53D6 */\n applicationCode: string\n /** macOS Safari 16+ \u4F7F\u7528 VAPID \u66FF\u4EE3 APNS */\n enableMacSafariVapid?: boolean\n /** \u9ED8\u8BA4\u63A8\u9001\u901A\u77E5\u6807\u9898 */\n defaultNotificationTitle?: string\n /** \u9ED8\u8BA4\u63A8\u9001\u901A\u77E5\u56FE\u6807 URL */\n defaultNotificationIcon?: string\n /** \u662F\u5426\u81EA\u52A8\u89E6\u53D1\u6D4F\u89C8\u5668\u8BA2\u9605\u5F39\u7A97\uFF0C\u5F3A\u70C8\u5EFA\u8BAE\u8BBE\u4E3A false */\n autoSubscribe?: boolean\n /** \u5F00\u53D1\u9636\u6BB5\u5F00\u542F SDK \u65E5\u5FD7 */\n enableLogging?: boolean\n serviceWorker: {\n /** Service Worker \u6587\u4EF6\u8DEF\u5F84\uFF08\u9700\u653E\u5728\u7F51\u7AD9\u6839\u76EE\u5F55\uFF09 */\n url: string\n /** VAPID \u516C\u94A5\uFF08Base64 URL-safe \u7F16\u7801\uFF09 */\n applicationServerPublicKey: string\n }\n}\n\ntype EmarsysSdkEventName =\n | 'onReady'\n | 'onSubscribe'\n | 'onUnsubscribe'\n | 'onPermissionPrompt'\n | 'onPermissionGranted'\n | 'onPermissionDenied'\n | 'onSWInitError'\n\ntype EmarsysSdkCommand = ['init', EmarsysInitConfig] | [EmarsysSdkEventName, () => void]\n\ninterface EmarsysSdkApi {\n subscribe: () => void\n unsubscribe: () => void\n login: (contactInfo: EmarsysContactInfo) => Promise<boolean>\n logout: () => Promise<boolean>\n isSubscribed: () => Promise<boolean>\n isRegistered: () => boolean\n customEvent: (eventName: string, payload?: Record<string, unknown>) => Promise<boolean>\n push: (command: EmarsysSdkCommand | ((sdk: EmarsysSdkApi) => void)) => void\n}\n\ndeclare global {\n interface Window {\n WebEmarsysSdk: EmarsysSdkApi | (EmarsysSdkCommand | ((sdk: EmarsysSdkApi) => void))[]\n }\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Hook \u5165\u53C2\u7C7B\u578B\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface UseEmarsysWebPushOptions {\n /** Emarsys Domain Code */\n applicationCode: string\n /** VAPID \u516C\u94A5 */\n applicationServerPublicKey: string\n /** Service Worker \u8DEF\u5F84\uFF0C\u9ED8\u8BA4 'service-worker.js'\uFF08\u4E0D\u542B\u524D\u5BFC\u659C\u6760\uFF09 */\n serviceWorkerUrl?: string\n /** \u9ED8\u8BA4\u901A\u77E5\u6807\u9898 */\n defaultNotificationTitle?: string\n /** \u9ED8\u8BA4\u901A\u77E5\u56FE\u6807 URL */\n defaultNotificationIcon?: string\n /** \u8054\u7CFB\u4EBA\u4E3B\u952E\u5B57\u6BB5 ID\uFF08\u7531 Emarsys \u540E\u53F0\u914D\u7F6E\uFF09 */\n fieldId: number\n /**\n * \u5F53\u524D\u7528\u6237\u7684\u8054\u7CFB\u4EBA\u6807\u8BC6\uFF08\u5982 hashed email / customer ID\uFF09\u3002\n * null \u8868\u793A\u672A\u767B\u5F55\u7684\u533F\u540D\u8BBF\u5BA2\u3002\n */\n contactValue: string | null\n /** \u662F\u5426\u5F00\u542F\u8C03\u8BD5\u65E5\u5FD7\uFF0C\u9ED8\u8BA4 false */\n enableLogging?: boolean\n /**\n * \u70B9\u51FB\"\u7A0D\u540E\"\u540E\u7684\u5F39\u7A97\u51B7\u5374\u5929\u6570\uFF0C\u9ED8\u8BA4 7 \u5929\u3002\n * \u51B7\u5374\u671F\u95F4\u4E0D\u518D\u5C55\u793A\u81EA\u5B9A\u4E49\u5F39\u7A97\u3002\n */\n dismissCooldownDays?: number\n /**\n * SDK \u662F\u5426\u5DF2\u901A\u8FC7\u5916\u90E8 <Script> \u6807\u7B7E\u52A0\u8F7D\u5B8C\u6BD5\u3002\n * \u4F20\u5165\u6B64 flag \u4EE5\u4FBF hook \u5728\u6B63\u786E\u65F6\u673A\u521D\u59CB\u5316\u3002\n * \u9ED8\u8BA4 true\uFF08\u5047\u8BBE SDK \u5DF2\u7ECF\u52A0\u8F7D\uFF09\u3002\n */\n sdkLoaded?: boolean\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Hook \u8FD4\u56DE\u503C\u7C7B\u578B\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface UseEmarsysWebPushReturn {\n /** \u624B\u52A8\u89E6\u53D1\u6D4F\u89C8\u5668\u539F\u751F\u8BA2\u9605\u5F39\u7A97\uFF08\u4F9B\"\u8BA2\u9605\"\u6309\u94AE\u8C03\u7528\uFF09 */\n subscribe: () => void\n /** \u53D6\u6D88\u63A8\u9001\u8BA2\u9605 */\n unsubscribe: () => void\n /** \u662F\u5426\u5E94\u5411\u7528\u6237\u5C55\u793A\u81EA\u5B9A\u4E49\u5F15\u5BFC\u5F39\u7A97 */\n shouldShowPopup: boolean\n /** \u5173\u95ED\u81EA\u5B9A\u4E49\u5F39\u7A97\u5E76\u5199\u5165\u51B7\u5374\u6807\u8BB0 */\n dismissPopup: () => void\n /** \u5F53\u524D\u662F\u5426\u5DF2\u8BA2\u9605\uFF08\u5F02\u6B65\u68C0\u6D4B\u5B8C\u6210\u540E\u66F4\u65B0\uFF09 */\n isSubscribed: boolean\n /** SDK \u662F\u5426\u5C31\u7EEA */\n isReady: boolean\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// \u5DE5\u5177\u51FD\u6570\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst STORAGE_KEY_SUBSCRIBE = 'emarsysSubscribe'\nconst STORAGE_KEY_LOGIN = 'emarsysLogin'\nconst STORAGE_KEY_DISMISSED = 'anker_push_dismissed'\n\nfunction isIOS(): boolean {\n if (typeof navigator === 'undefined') return false\n return /iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase())\n}\n\nfunction isStandaloneWebApp(): boolean {\n if (typeof window === 'undefined') return false\n return (\n window.matchMedia('(display-mode: standalone)').matches ||\n // Safari standalone \u5C5E\u6027\uFF08\u975E\u6807\u51C6\uFF09\n ('standalone' in window.navigator && (window.navigator as Navigator & { standalone?: boolean }).standalone === true)\n )\n}\n\nfunction safeLocalStorage(action: 'get', key: string): string | null\nfunction safeLocalStorage(action: 'set', key: string, value: string): void\nfunction safeLocalStorage(action: 'remove', key: string): void\nfunction safeLocalStorage(action: 'get' | 'set' | 'remove', key: string, value?: string): string | null | void {\n try {\n if (action === 'get') return localStorage.getItem(key)\n if (action === 'set' && value !== undefined) localStorage.setItem(key, value)\n if (action === 'remove') localStorage.removeItem(key)\n } catch {\n // SSR \u6216\u9690\u79C1\u6A21\u5F0F\u4E0B localStorage \u4E0D\u53EF\u7528\n }\n return null\n}\n\nfunction getSdkApi(): EmarsysSdkApi | null {\n if (typeof window === 'undefined') return null\n const sdk = window.WebEmarsysSdk\n if (!sdk || Array.isArray(sdk)) return null\n return sdk as EmarsysSdkApi\n}\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// \u6838\u5FC3 Hook\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * useEmarsysWebPush\n *\n * \u5C01\u88C5 Emarsys Web Push SDK \u7684\u8BA2\u9605\u751F\u547D\u5468\u671F\uFF0C\u5305\u62EC\uFF1A\n * - SDK \u521D\u59CB\u5316\n * - \u81EA\u5B9A\u4E49\u5F39\u7A97\u5C55\u793A\u903B\u8F91\uFF08\u4E24\u6B65\u7B56\u7565\uFF0C\u907F\u514D\u76F4\u63A5\u89E6\u53D1\u6D4F\u89C8\u5668\u539F\u751F\u5F39\u7A97\uFF09\n * - \u5DF2\u767B\u5F55\u8054\u7CFB\u4EBA\u7684 login / logout \u81EA\u52A8\u7BA1\u7406\n * - \u5DF2\u6709\u8BA2\u9605\u7528\u6237\u7684\u8FC1\u79FB\uFF08\u4ECE\u65E7\u63A8\u9001\u7CFB\u7EDF\u8FC1\u79FB\uFF09\n *\n * @example\n * ```tsx\n * const { shouldShowPopup, subscribe, dismissPopup } = useEmarsysWebPush({\n * applicationCode: process.env.NEXT_PUBLIC_EMARSYS_APP_CODE!,\n * applicationServerPublicKey: process.env.NEXT_PUBLIC_EMARSYS_VAPID_PUBLIC_KEY!,\n * fieldId: 10372,\n * contactValue: user?.customerId ?? null,\n * sdkLoaded: scriptLoaded,\n * })\n * ```\n */\nexport function useEmarsysWebPush({\n applicationCode,\n applicationServerPublicKey,\n serviceWorkerUrl = 'service-worker.js',\n defaultNotificationTitle,\n defaultNotificationIcon,\n fieldId,\n contactValue,\n enableLogging = false,\n dismissCooldownDays = 7,\n sdkLoaded = true,\n}: UseEmarsysWebPushOptions): UseEmarsysWebPushReturn {\n const [isReady, setIsReady] = useState(false)\n const [isSubscribed, setIsSubscribed] = useState(false)\n const [shouldShowPopup, setShouldShowPopup] = useState(false)\n\n // \u907F\u514D\u91CD\u590D login/logout\n const hasPerformedLogin = useRef(false)\n // \u8FFD\u8E2A\u5F53\u524D session \u5185\u662F\u5426\u5DF2\u4E3B\u52A8\u89E6\u53D1\u8FC7 subscribe\n const isGeneralSubscribeRef = useRef(false)\n\n // \u2500\u2500 \u521D\u59CB\u5316 SDK \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n useEffect(() => {\n if (!sdkLoaded || typeof window === 'undefined') return\n\n // SDK v4.7.0 \u5185\u90E8 registerServiceWorker() \u6267\u884C `/${url}` \u62FC\u63A5\uFF0C\n // \u56E0\u6B64\u6B64\u5904\u5FC5\u987B\u4F20\u4E0D\u542B\u524D\u5BFC\u659C\u6760\u7684\u7EAF\u8DEF\u5F84\uFF08\u5982 'service-worker.js'\uFF09\uFF0C\n // \u4F20\u5165\u5E26\u659C\u6760\u7684\u8DEF\u5F84\u6216\u7EDD\u5BF9 URL \u5747\u4F1A\u5BFC\u81F4\u53CC\u659C\u6760/\u8DE8\u57DF SecurityError\u3002\n const swPath = serviceWorkerUrl.replace(/^\\/+/, '').replace(/^https?:\\/\\/[^/]+\\//, '')\n\n window.WebEmarsysSdk = window.WebEmarsysSdk || []\n const sdk = window.WebEmarsysSdk as (EmarsysSdkCommand | ((api: EmarsysSdkApi) => void))[]\n\n sdk.push([\n 'init',\n {\n applicationCode,\n enableMacSafariVapid: true,\n defaultNotificationTitle,\n defaultNotificationIcon,\n autoSubscribe: false,\n enableLogging,\n serviceWorker: {\n url: swPath,\n applicationServerPublicKey,\n },\n },\n ])\n }, [\n sdkLoaded,\n applicationCode,\n applicationServerPublicKey,\n serviceWorkerUrl,\n defaultNotificationTitle,\n defaultNotificationIcon,\n enableLogging,\n ])\n\n // \u2500\u2500 \u6267\u884C Emarsys login\uFF08\u5173\u8054\u5DF2\u77E5\u8054\u7CFB\u4EBA\uFF09\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const performLogin = useCallback(\n (value: string) => {\n if (hasPerformedLogin.current) return\n const api = getSdkApi()\n if (!api) return\n\n api.isSubscribed().then(subscribed => {\n if (!subscribed) return\n api.login({ fieldId, fieldValue: value }).then(result => {\n if (result) {\n safeLocalStorage('set', STORAGE_KEY_LOGIN, 'login')\n hasPerformedLogin.current = true\n }\n })\n })\n },\n [fieldId]\n )\n\n // \u2500\u2500 \u6267\u884C Emarsys logout\uFF08\u89E3\u9664\u8054\u7CFB\u4EBA\u5173\u8054\uFF09\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const performLogout = useCallback(() => {\n const api = getSdkApi()\n if (!api) return\n\n api.isSubscribed().then(subscribed => {\n if (!subscribed) return\n api.logout().then(result => {\n if (result) {\n safeLocalStorage('remove', STORAGE_KEY_LOGIN)\n hasPerformedLogin.current = false\n }\n })\n })\n }, [])\n\n // \u2500\u2500 \u6CE8\u518C SDK \u56DE\u8C03 & \u4E1A\u52A1\u903B\u8F91 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n useEffect(() => {\n if (!sdkLoaded || typeof window === 'undefined') return\n\n // iOS \u6D4F\u89C8\u5668\uFF08\u975E PWA \u6A21\u5F0F\uFF09\u4E0D\u505A\u4EFB\u4F55\u64CD\u4F5C\n if (isIOS() && !isStandaloneWebApp()) return\n\n window.WebEmarsysSdk = window.WebEmarsysSdk || []\n const sdk = window.WebEmarsysSdk as (EmarsysSdkCommand | ((api: EmarsysSdkApi) => void))[]\n\n sdk.push([\n 'onReady',\n () => {\n setIsReady(true)\n\n // \u68C0\u67E5\u5F53\u524D\u8BA2\u9605\u72B6\u6001\n getSdkApi()\n ?.isSubscribed()\n .then(subscribed => {\n setIsSubscribed(subscribed)\n })\n\n // \u5DF2\u6709\u8BA2\u9605\u7528\u6237\u8FC1\u79FB\uFF08\u65E7\u63A8\u9001\u7CFB\u7EDF \u2192 Emarsys\uFF09\n sdk.push([\n 'onPermissionGranted',\n () => {\n if (!safeLocalStorage('get', STORAGE_KEY_SUBSCRIBE) && !isGeneralSubscribeRef.current) {\n getSdkApi()?.subscribe()\n safeLocalStorage('set', STORAGE_KEY_SUBSCRIBE, 'subscribe')\n }\n },\n ])\n\n // \u5224\u65AD\u662F\u5426\u9700\u8981\u5C55\u793A\u81EA\u5B9A\u4E49\u5F15\u5BFC\u5F39\u7A97\n // \u5EF6\u8FDF 2 \u79D2\uFF0C\u7B49\u5F85 onPermissionGranted / onPermissionDenied \u5F02\u6B65\u56DE\u8C03\n let permissionAlreadyHandled = false\n sdk.push([\n 'onPermissionGranted',\n () => {\n permissionAlreadyHandled = true\n },\n ])\n sdk.push([\n 'onPermissionDenied',\n () => {\n permissionAlreadyHandled = true\n },\n ])\n\n setTimeout(() => {\n if (permissionAlreadyHandled) return\n\n // \u68C0\u67E5\u51B7\u5374\u671F\n const dismissedAt = safeLocalStorage('get', STORAGE_KEY_DISMISSED)\n if (dismissedAt) {\n const elapsed = Date.now() - parseInt(dismissedAt, 10)\n if (elapsed < dismissCooldownDays * 24 * 60 * 60 * 1000) return\n }\n\n setShouldShowPopup(true)\n }, 2000)\n },\n ])\n\n // \u8BA2\u9605\u6210\u529F\u540E\u66F4\u65B0\u72B6\u6001\u5E76\u6267\u884C login\n sdk.push([\n 'onSubscribe',\n () => {\n setIsSubscribed(true)\n safeLocalStorage('set', STORAGE_KEY_SUBSCRIBE, 'subscribe')\n if (contactValue) {\n performLogin(contactValue)\n }\n },\n ])\n\n sdk.push([\n 'onUnsubscribe',\n () => {\n setIsSubscribed(false)\n },\n ])\n }, [sdkLoaded, contactValue, dismissCooldownDays, performLogin])\n\n // \u2500\u2500 \u76D1\u542C contactValue \u53D8\u5316\uFF0C\u81EA\u52A8 login / logout \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n useEffect(() => {\n if (!isReady) return\n\n if (contactValue) {\n if (!safeLocalStorage('get', STORAGE_KEY_LOGIN)) {\n performLogin(contactValue)\n }\n } else {\n if (safeLocalStorage('get', STORAGE_KEY_LOGIN)) {\n performLogout()\n }\n }\n }, [isReady, contactValue, performLogin, performLogout])\n\n // \u2500\u2500 \u5BF9\u5916\u66B4\u9732\u7684 API \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n const subscribe = useCallback(() => {\n setShouldShowPopup(false)\n isGeneralSubscribeRef.current = true\n const api = getSdkApi()\n if (!api) {\n const sdk = window.WebEmarsysSdk as ((api: EmarsysSdkApi) => void)[]\n sdk.push(sdkApi => {\n sdkApi.subscribe()\n })\n return\n }\n api.subscribe()\n }, [])\n\n const unsubscribe = useCallback(() => {\n getSdkApi()?.unsubscribe()\n }, [])\n\n const dismissPopup = useCallback(() => {\n setShouldShowPopup(false)\n safeLocalStorage('set', STORAGE_KEY_DISMISSED, String(Date.now()))\n }, [])\n\n return {\n subscribe,\n unsubscribe,\n shouldShowPopup,\n dismissPopup,\n isSubscribed,\n isReady,\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyD,iBA0HzD,MAAMC,EAAwB,mBACxBC,EAAoB,eACpBC,EAAwB,uBAE9B,SAASC,GAAiB,CACxB,OAAI,OAAO,UAAc,IAAoB,GACtC,mBAAmB,KAAK,UAAU,UAAU,YAAY,CAAC,CAClE,CAEA,SAASC,GAA8B,CACrC,OAAI,OAAO,OAAW,IAAoB,GAExC,OAAO,WAAW,4BAA4B,EAAE,SAE/C,eAAgB,OAAO,WAAc,OAAO,UAAmD,aAAe,EAEnH,CAKA,SAASC,EAAiBC,EAAkCC,EAAaC,EAAsC,CAC7G,GAAI,CACF,GAAIF,IAAW,M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K,GAAK,GAAK,KAGrDO,EAAmB,EAAI,CACzB,EAAG,GAAI,CACT,CACF,CAAC,EAGDhB,EAAI,KAAK,CACP,cACA,IAAM,CACJc,EAAgB,EAAI,EACpBnB,EAAiB,MAAOL,EAAuB,WAAW,EACtDiB,GACFa,EAAab,CAAY,CAE7B,CACF,CAAC,EAEDP,EAAI,KAAK,CACP,gBACA,IAAM,CACJc,EAAgB,EAAK,CACvB,CACF,CAAC,CACH,EAAG,CAACJ,EAAWH,EAAcE,EAAqBW,CAAY,CAAC,KAG/D,aAAU,IAAM,CACTT,IAEDJ,EACGZ,EAAiB,MAAOJ,CAAiB,GAC5C6B,EAAab,CAAY,EAGvBZ,EAAiB,MAAOJ,CAAiB,GAC3CiC,EAAc,EAGpB,EAAG,CAACb,EAASJ,EAAca,EAAcI,CAAa,CAAC,EAIvD,MAAMG,KAAY,eAAY,IAAM,CAClCX,EAAmB,EAAK,EACxBE,EAAsB,QAAU,GAChC,MAAMG,EAAMtB,EAAU,EACtB,GAAI,CAACsB,EAAK,CACI,OAAO,cACf,KAAKO,GAAU,CACjBA,EAAO,UAAU,CACnB,CAAC,EACD,MACF,CACAP,EAAI,UAAU,CAChB,EAAG,CAAC,CAAC,EAECQ,KAAc,eAAY,IAAM,CACpC9B,EAAU,GAAG,YAAY,CAC3B,EAAG,CAAC,CAAC,EAEC+B,KAAe,eAAY,IAAM,CACrCd,EAAmB,EAAK,EACxBrB,EAAiB,MAAOH,EAAuB,OAAO,KAAK,IAAI,CAAC,CAAC,CACnE,EAAG,CAAC,CAAC,EAEL,MAAO,CACL,UAAAmC,EACA,YAAAE,EACA,gBAAAd,EACA,aAAAe,EACA,aAAAjB,EACA,QAAAF,CACF,CACF",
|
|
6
|
+
"names": ["useEmarsysWebPush_exports", "__export", "useEmarsysWebPush", "__toCommonJS", "import_react", "STORAGE_KEY_SUBSCRIBE", "STORAGE_KEY_LOGIN", "STORAGE_KEY_DISMISSED", "isIOS", "isStandaloneWebApp", "safeLocalStorage", "action", "key", "value", "getSdkApi", "sdk", "applicationCode", "applicationServerPublicKey", "serviceWorkerUrl", "defaultNotificationTitle", "defaultNotificationIcon", "fieldId", "contactValue", "enableLogging", "dismissCooldownDays", "sdkLoaded", "isReady", "setIsReady", "isSubscribed", "setIsSubscribed", "shouldShowPopup", "setShouldShowPopup", "hasPerformedLogin", "isGeneralSubscribeRef", "swPath", "performLogin", "api", "subscribed", "result", "performLogout", "permissionAlreadyHandled", "dismissedAt", "subscribe", "sdkApi", "unsubscribe", "dismissPopup"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { Product } from '../biz-components/Listing/types/product.js';
|
|
3
|
+
/** 单个产品项的埋点数据(CMS 配置的简化产品) */
|
|
4
|
+
export interface ProductItem {
|
|
5
|
+
sku?: string;
|
|
6
|
+
handle?: string;
|
|
7
|
+
custom_price?: number;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
/** Hook 入参 */
|
|
11
|
+
export interface ProductListTrackOptions {
|
|
12
|
+
/** 组件容器 ref,用于 view_item_list 的视口检测 */
|
|
13
|
+
containerRef: RefObject<HTMLDivElement>;
|
|
14
|
+
/** 列表名称,用于 item_list_name 字段 */
|
|
15
|
+
listName: string;
|
|
16
|
+
/** 产品列表(简化数据,来自 CMS 配置) */
|
|
17
|
+
items: ProductItem[];
|
|
18
|
+
/** 构建时产品完整数据(来自 Shopify API) */
|
|
19
|
+
products?: Product[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 产品列表埋点 Hook
|
|
23
|
+
*
|
|
24
|
+
* 封装两个 GA4 电商事件:
|
|
25
|
+
* - `view_item_list` — 组件进入视口时自动触发一次(产品列表露出)
|
|
26
|
+
* - `select_item` — 返回 trackSelectItem 函数,点击产品时手动调用(产品选择)
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const { trackSelectItem } = useProductListTrack({
|
|
31
|
+
* containerRef: innerRef,
|
|
32
|
+
* listName: 'gift_tier_shelf',
|
|
33
|
+
* items: availableItems.map(item => item.products?.[0]).filter(Boolean),
|
|
34
|
+
* products: buildData?.products,
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* // 点击产品卡片时
|
|
38
|
+
* <Card onClick={() => { trackSelectItem(product, index); onCardClick?.() }} />
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const useProductListTrack: ({ containerRef, listName, items, products }: ProductListTrackOptions) => {
|
|
42
|
+
trackSelectItem: (item: ProductItem, index: number) => void;
|
|
43
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var n in t)l(e,n,{get:t[n],enumerable:!0})},h=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of k(t))!f.call(e,r)&&r!==n&&l(e,r,{get:()=>t[r],enumerable:!(i=g(t,r))||i.enumerable});return e};var b=e=>h(l({},"__esModule",{value:!0}),e);var L={};P(L,{useProductListTrack:()=>x});module.exports=b(L);var s=require("react"),p=require("../shared/track.js"),v=require("../biz-components/AiuiProvider/index.js");const I=(e,t)=>e.map((n,i)=>{const r=t?.find(o=>o.handle===n.handle)||null,c=r?.variants?.find(o=>o?.sku===n.sku)||null;return{item_id:n.sku||c?.sku||"",item_name:c?.title||r?.title||"",item_variant:c?.title||"",price:n.custom_price??c?.price?.amount??"",index:i+1}}),x=({containerRef:e,listName:t,items:n,products:i})=>{const{trackingData:r}=(0,v.useAiuiContext)(),c=(0,s.useRef)(!1);return(0,s.useEffect)(()=>{if(!e.current||c.current||!i?.length)return;const a=new IntersectionObserver(([m])=>{m.isIntersecting&&!c.current&&(c.current=!0,(0,p.gaTrack)({event:"ga4Event",event_name:"view_item_list",event_parameters:{page_group:r?.pageGroup||"Home Page",item_list_name:t,items:I(n,i)}}),a.disconnect())},{threshold:0});return a.observe(e.current),()=>a.disconnect()},[i,n,r,t,e]),{trackSelectItem:(0,s.useCallback)((a,m)=>{const _=i?.find(d=>d.handle===a.handle)||null,u=_?.variants?.find(d=>d?.sku===a.sku)||null;(0,p.gaTrack)({event:"ga4Event",event_name:"select_item",event_parameters:{page_group:r?.pageGroup||"Home Page",item_list_name:t,items:[{item_id:a.sku||u?.sku||"",item_name:u?.title||_?.title||"",item_variant:u?.title||"",price:a.custom_price??u?.price?.amount??"",index:m+1}]}})},[i,r,t])}};
|
|
2
|
+
//# sourceMappingURL=useProductListTrack.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useProductListTrack.ts"],
|
|
4
|
+
"sourcesContent": ["import { type RefObject, useRef, useEffect, useCallback } from 'react'\nimport { gaTrack } from '../shared/track.js'\nimport { useAiuiContext } from '../biz-components/AiuiProvider/index.js'\nimport type { Product, ProductVariant } from '../biz-components/Listing/types/product.js'\n\n/** \u5355\u4E2A\u4EA7\u54C1\u9879\u7684\u57CB\u70B9\u6570\u636E\uFF08CMS \u914D\u7F6E\u7684\u7B80\u5316\u4EA7\u54C1\uFF09 */\nexport interface ProductItem {\n sku?: string\n handle?: string\n custom_price?: number\n [key: string]: any\n}\n\n/** Hook \u5165\u53C2 */\nexport interface ProductListTrackOptions {\n /** \u7EC4\u4EF6\u5BB9\u5668 ref\uFF0C\u7528\u4E8E view_item_list \u7684\u89C6\u53E3\u68C0\u6D4B */\n containerRef: RefObject<HTMLDivElement>\n /** \u5217\u8868\u540D\u79F0\uFF0C\u7528\u4E8E item_list_name \u5B57\u6BB5 */\n listName: string\n /** \u4EA7\u54C1\u5217\u8868\uFF08\u7B80\u5316\u6570\u636E\uFF0C\u6765\u81EA CMS \u914D\u7F6E\uFF09 */\n items: ProductItem[]\n /** \u6784\u5EFA\u65F6\u4EA7\u54C1\u5B8C\u6574\u6570\u636E\uFF08\u6765\u81EA Shopify API\uFF09 */\n products?: Product[]\n}\n\n/**\n * \u6839\u636E\u7B80\u5316\u4EA7\u54C1 + \u5B8C\u6574\u4EA7\u54C1\u6570\u636E\uFF0C\u6784\u5EFA GA4 \u6807\u51C6 items \u6570\u7EC4\n */\nconst resolveItemList = (items: ProductItem[], products?: Product[]) => {\n return items.map((item, index) => {\n const matchedProduct = products?.find(p => p.handle === item.handle) || null\n const variant = matchedProduct?.variants?.find((v: ProductVariant) => v?.sku === item.sku) || null\n return {\n item_id: item.sku || variant?.sku || '',\n item_name: variant?.title || matchedProduct?.title || '',\n item_variant: variant?.title || '',\n price: item.custom_price ?? variant?.price?.amount ?? '',\n index: index + 1,\n }\n })\n}\n\n/**\n * \u4EA7\u54C1\u5217\u8868\u57CB\u70B9 Hook\n *\n * \u5C01\u88C5\u4E24\u4E2A GA4 \u7535\u5546\u4E8B\u4EF6\uFF1A\n * - `view_item_list` \u2014 \u7EC4\u4EF6\u8FDB\u5165\u89C6\u53E3\u65F6\u81EA\u52A8\u89E6\u53D1\u4E00\u6B21\uFF08\u4EA7\u54C1\u5217\u8868\u9732\u51FA\uFF09\n * - `select_item` \u2014 \u8FD4\u56DE trackSelectItem \u51FD\u6570\uFF0C\u70B9\u51FB\u4EA7\u54C1\u65F6\u624B\u52A8\u8C03\u7528\uFF08\u4EA7\u54C1\u9009\u62E9\uFF09\n *\n * @example\n * ```tsx\n * const { trackSelectItem } = useProductListTrack({\n * containerRef: innerRef,\n * listName: 'gift_tier_shelf',\n * items: availableItems.map(item => item.products?.[0]).filter(Boolean),\n * products: buildData?.products,\n * })\n *\n * // \u70B9\u51FB\u4EA7\u54C1\u5361\u7247\u65F6\n * <Card onClick={() => { trackSelectItem(product, index); onCardClick?.() }} />\n * ```\n */\nexport const useProductListTrack = ({ containerRef, listName, items, products }: ProductListTrackOptions) => {\n const { trackingData } = useAiuiContext()\n const hasViewed = useRef(false)\n\n // view_item_list \u2014 \u8FDB\u5165\u89C6\u53E3\u89E6\u53D1\u4E00\u6B21\n useEffect(() => {\n if (!containerRef.current || hasViewed.current || !products?.length) return\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting && !hasViewed.current) {\n hasViewed.current = true\n gaTrack({\n event: 'ga4Event',\n event_name: 'view_item_list',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n item_list_name: listName,\n items: resolveItemList(items, products),\n },\n })\n observer.disconnect()\n }\n },\n { threshold: 0 }\n )\n\n observer.observe(containerRef.current)\n return () => observer.disconnect()\n }, [products, items, trackingData, listName, containerRef])\n\n // select_item \u2014 \u70B9\u51FB\u67D0\u4EA7\u54C1\u65F6\u8C03\u7528\n const trackSelectItem = useCallback(\n (item: ProductItem, index: number) => {\n const matchedProduct = products?.find(p => p.handle === item.handle) || null\n const variant = matchedProduct?.variants?.find((v: ProductVariant) => v?.sku === item.sku) || null\n\n gaTrack({\n event: 'ga4Event',\n event_name: 'select_item',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n item_list_name: listName,\n items: [\n {\n item_id: item.sku || variant?.sku || '',\n item_name: variant?.title || matchedProduct?.title || '',\n item_variant: variant?.title || '',\n price: item.custom_price ?? variant?.price?.amount ?? '',\n index: index + 1,\n },\n ],\n },\n })\n },\n [products, trackingData, listName]\n )\n\n return { trackSelectItem }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA+D,iBAC/DC,EAAwB,8BACxBC,EAA+B,mDA0B/B,MAAMC,EAAkB,CAACC,EAAsBC,IACtCD,EAAM,IAAI,CAACE,EAAMC,IAAU,CAChC,MAAMC,EAAiBH,GAAU,KAAKI,GAAKA,EAAE,SAAWH,EAAK,MAAM,GAAK,KAClEI,EAAUF,GAAgB,UAAU,KAAMG,GAAsBA,GAAG,MAAQL,EAAK,GAA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GAAS,OAASF,GAAgB,OAAS,GACtD,aAAcE,GAAS,OAAS,GAChC,MAAOJ,EAAK,cAAgBI,GAAS,OAAO,QAAU,GACtD,MAAOH,EAAQ,CACjB,CACF,CACF,CACF,CAAC,CACH,EACA,CAACF,EAAUS,EAAcD,CAAQ,CACnC,CAEyB,CAC3B",
|
|
6
|
+
"names": ["useProductListTrack_exports", "__export", "useProductListTrack", "__toCommonJS", "import_react", "import_track", "import_AiuiProvider", "resolveItemList", "items", "products", "item", "index", "matchedProduct", "p", "variant", "v", "containerRef", "listName", "trackingData", "hasViewed", "observer", "entry"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as r,jsxs as a}from"react/jsx-runtime";import
|
|
1
|
+
"use client";import{jsx as r,jsxs as a}from"react/jsx-runtime";import D from"../Title/index.js";import{cn as o}from"../../helpers/utils.js";import I from"../../components/picture.js";import H from"../../components/button.js";import S from"../SwiperBox/index.js";import{withLayout as C}from"../../shared/Styles.js";import A,{useState as N,useRef as T,useCallback as j,useImperativeHandle as z,useEffect as L}from"react";import{useExposure as M}from"../../hooks/useExposure.js";import{trackUrlRef as $}from"../../shared/trackUrlRef.js";import{useAiuiContext as R}from"../AiuiProvider/index.js";import P from"../../shared/throttle.js";import{Heading as E}from"../../components/heading.js";const l="image",s="scene_banner",O=({item:e,idx:t,itemShape:c,hoverIndex:d,getRef:m,handleSwiperItemClick:x,contentWidth:p,primaryButton:u,event:f,data:v,accordionRef:k})=>{const y=d===t,g=y?8:1,{trackingData:w}=R(),h=w?.contextHandle||"";return M({current:k.current[t]},{componentType:l,componentName:s,componentTitle:e?.title,position:t+1,componentDescription:e?.subTitle}),a("div",{style:{flex:`${g} 1 0%`,transition:"all 0.6s"},ref:n=>{n&&m(t,n)},className:o("relative cursor-pointer overflow-hidden",c==="round"?"rounded-2xl":""),onMouseEnter:()=>x(t),onClick:()=>{x(t)},children:[r("a",{href:$(e?.imgLink,`${h}_${l}_${s}`),"data-headless-type-name":`${l}#${s}`,"data-headless-title-desc-button":`${e?.title}#${e?.subTitle}`,children:r(I,{source:e?.img?.url,className:"size-full object-cover [&_img]:h-full [&_img]:object-cover",alt:e?.img?.alt||""})}),a("div",{style:{width:p},className:o("absolute inset-x-0 bottom-0 flex w-full items-end justify-between overflow-hidden px-8 pb-8 opacity-0 transition-opacity duration-[600ms] ease-in",y&&p?"opacity-100":"opacity-0"),children:[a("div",{className:"mr-16 flex-1 overflow-hidden",children:[r(E,{as:"h3",className:"laptop:text-2xl desktop:text-[32px] text-info-primary mb-1 text-xl font-bold",children:e?.title}),r(E,{as:"h4",className:"lg-desktop:text-[18px] desktop:text-[16px] text-info-primary line-clamp-2 text-[14px] font-[700]",children:e?.subTitle})]}),u&&a(H,{className:o("mb-1.5 font-bold"),as:"a",href:$(e?.link,`${h}_${l}_${s}`),"data-headless-type-name":`${l}#${s}`,"data-headless-title-desc-button":`${e?.title}#${e?.subTitle}#${u}`,onClick:()=>f?.primaryButton?.(v,t),children:[u,r("span",{className:"sr-only",children:e?.title??e?.subTitle})]})]})]},t)},V=({data:e,configuration:t})=>{const c=T(null),{trackingData:d}=R(),m=d?.contextHandle||"";return M(c,{componentType:l,componentName:s,componentTitle:e?.title,position:t?.index+1,componentDescription:e?.subTitle}),a("div",{ref:c,className:o("bg-container-secondary-1 relative w-full shrink-0 grow-0 overflow-hidden border border-solid",t?.itemShape==="round"?"rounded-2xl":""),children:[r("a",{href:$(e?.imgLink,`${m}_${l}_${s}`),"data-headless-type-name":`${l}#${s}`,"data-headless-title-desc-button":`${e?.title}@${e?.subTitle}`,"data-headless-nav-position":`''#${t?.index+1}`,children:r(I,{className:"size-full object-cover [&_img]:h-full [&_img]:object-cover",source:e?.mobileImg?.url||"",alt:e?.mobileImg?.alt||""})}),a("div",{className:o("absolute inset-x-0 bottom-0 overflow-hidden px-4 pb-4"),children:[a("div",{className:"tablet:mb-6 mb-4 flex-1 overflow-hidden",children:[r("h3",{className:"text-info-primary line-clamp-3 text-2xl font-bold leading-[1.2]",dangerouslySetInnerHTML:{__html:e?.title}}),r("h4",{className:"text-info-primary line-clamp-2 text-sm font-bold",dangerouslySetInnerHTML:{__html:e?.subTitle}})]}),t?.primaryButton&&r(H,{as:"a",variant:"secondary","aria-label":e?.title??e?.subTitle,className:o("text-info-primary text-sm font-bold"),href:$(e.link,`${m}_${l}_${s}`),"data-headless-type-name":`${l}#${s}`,"data-headless-nav-position":`''#${t?.index+1}`,"data-headless-title-desc-button":`${e?.title}#${e?.subTitle}#${t?.primaryButton}`,children:t?.primaryButton})]})]})},B=A.forwardRef(({data:e,autoplay:t={enabled:!1,loop:!1,interval:1500},className:c="",event:d,...m},x)=>{const[p,u]=N(0),f=T(0),v=T([]),[k,y]=N(0),g=T(null);z(x,()=>g.current);const w=(n,i)=>{i&&(v.current[n]=i)};L(()=>{const n=()=>{v.current[f.current]&&y(v.current[f.current].offsetWidth)};n();const i=P(n,300);return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]);const h=j(n=>{p!==n&&(u(n),f.current=n)},[e?.products,p]);return L(()=>{let n;return t?.enabled&&(n=setInterval(()=>{u(i=>{const _=i??0;let b;if(t.loop!==!1)b=(_+1)%e?.products?.length;else if(b=_+1,b>=e?.products?.length)return b=e?.products?.length-1,n&&clearInterval(n),_;return f.current=b,b})},t?.interval)),()=>{n&&clearInterval(n)}},[t?.enabled,t?.interval,t?.loop,e?.products?.length,h]),a("div",{...m,ref:g,children:[e?.title&&r(D,{data:{title:e?.title}}),r("div",{className:o("laptop:block hidden",{"aiui-dark":e?.theme==="dark"}),children:r("div",{className:o("lg-desktop:h-[calc(560_/_1920*100vw)] desktop:h-[calc(448_/_1440*100vw)] laptop:h-[calc(336_/_1025*100vw)] flex max-h-[560px] min-h-[336px] w-full gap-4 overflow-hidden",c),children:e?.products?.map((n,i)=>r(O,{item:n,idx:i,itemShape:e?.itemShape,hoverIndex:p,getRef:w,handleSwiperItemClick:h,contentWidth:k,primaryButton:e?.primaryButton,event:d,data:e,accordionRef:v},i))})}),r("div",{className:o("laptop:hidden block",{"aiui-dark":e?.theme==="dark"}),children:r(S,{className:o("h-[400px] !overflow-visible",c),id:"AccordionCards"+e?.key,data:{list:e?.products,configuration:{shape:e?.shape,itemShape:e?.itemShape,primaryButton:e?.primaryButton,event:d,title:e?.title}},Slide:V,breakpoints:{0:{spaceBetween:12,freeMode:!1,slidesPerView:1},374:{spaceBetween:12,freeMode:!1,slidesPerView:1.2},768:{spaceBetween:16,freeMode:!1,slidesPerView:2.3}}})})]})});B.displayName="AccordionCards";var te=C(B);export{te as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/AccordionCards/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\nimport Title from '../Title/index.js'\nimport { cn } from '../../helpers/utils.js'\nimport Picture from '../../components/picture.js'\nimport Button from '../../components/button.js'\nimport SwiperBox from '../SwiperBox/index.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport React, { useState, useRef, useCallback, useImperativeHandle, useEffect, type RefObject } from 'react'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { trackUrlRef } from '../../shared/trackUrlRef.js'\nimport type { Img } from '../../types/props.js'\nimport throttle from '../../shared/throttle.js'\nimport { Heading } from '../../components/heading.js'\n\nconst componentType = 'image'\nconst componentName = 'scene_banner'\n\n/** Hook\uFF1A\u76D1\u542C\u7A97\u53E3\u5BBD\u5EA6 */\ntype ItemType = {\n /** \u6807\u9898\u6587\u672C */\n title: string\n /** \u56FE\u7247*/\n img: Img\n mobileImg?: Img\n /** \u5185\u5BB9\u8282\u70B9 */\n subTitle: string\n link?: string\n imgLink?: string\n}\n\nexport type AccordionCardsType = Omit<React.HTMLAttributes<HTMLDivElement>, 'className'> & {\n className?: string\n data: {\n key?: string\n title?: string\n products: Array<ItemType>\n /** \u6309\u94AE\u5F62\u72B6 */\n shape?: 'round' | 'square'\n /** \u5361\u7247\u5F62\u72B6 */\n itemShape?: 'round' | 'square'\n /** \u4E3B\u6309\u94AE\u914D\u7F6E */\n primaryButton?: string\n theme?: 'light' | 'dark'\n }\n /**\n * \u81EA\u52A8\u64AD\u653E\u914D\u7F6E\n */\n autoplay?: {\n /**\n * \u662F\u5426\u5F00\u542F\u81EA\u52A8\u64AD\u653E\n */\n enabled: boolean\n /**\n * \u662F\u5426\u5FAA\u73AF\u64AD\u653E\n */\n loop?: boolean\n /**\n * \u81EA\u52A8\u64AD\u653E\u95F4\u9694\u65F6\u95F4\uFF0C\u5355\u4F4D\u6BEB\u79D2\n */\n interval?: number\n }\n /** \u6309\u94AE\u4E8B\u4EF6*/\n event?: {\n primaryButton?: (_v: any, _index: number) => void\n }\n}\n\nconst AccordionCardsPcItem = ({\n item,\n idx,\n itemShape,\n hoverIndex,\n getRef,\n handleSwiperItemClick,\n contentWidth,\n primaryButton,\n event,\n data,\n accordionRef,\n}: {\n item: ItemType\n idx: number\n itemShape: 'round' | 'square' | undefined\n hoverIndex: number | null\n getRef: (_idx: number, _el: HTMLDivElement) => void\n handleSwiperItemClick: (_idx: number) => void\n contentWidth: number\n primaryButton: string | undefined\n event: any\n data: AccordionCardsType['data']\n accordionRef: React.MutableRefObject<HTMLDivElement[]>\n}) => {\n const isExpanded = hoverIndex === idx\n const flexValue = isExpanded ? 8 : 1\n\n useExposure({ current: accordionRef.current[idx] } as RefObject<HTMLDivElement>, {\n componentType,\n componentName,\n componentTitle: item?.title,\n position: idx + 1,\n componentDescription: item?.subTitle,\n })\n\n return (\n <div\n key={idx}\n style={{\n flex: `${flexValue} 1 0%`,\n transition: 'all 0.6s',\n }}\n ref={(el: HTMLDivElement | null) => {\n if (el) getRef(idx, el)\n }}\n className={cn('relative cursor-pointer overflow-hidden', itemShape === 'round' ? 'rounded-2xl' : '')}\n onMouseEnter={() => handleSwiperItemClick(idx)}\n onClick={() => {\n handleSwiperItemClick(idx)\n }}\n >\n <a\n href={trackUrlRef(item?.imgLink, `${componentType}_${componentName}`)}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-title-desc-button={`${item?.title}#${item?.subTitle}`}\n >\n <Picture\n source={item?.img?.url}\n className=\"size-full object-cover [&_img]:h-full [&_img]:object-cover\"\n alt={item?.img?.alt || ''}\n />\n </a>\n <div\n style={{\n width: contentWidth,\n }}\n className={cn(\n 'absolute inset-x-0 bottom-0 flex w-full items-end justify-between overflow-hidden px-8 pb-8 opacity-0 transition-opacity duration-[600ms] ease-in',\n isExpanded && contentWidth ? 'opacity-100' : 'opacity-0'\n )}\n >\n <div className=\"mr-16 flex-1 overflow-hidden\">\n <Heading as=\"h3\" className=\"laptop:text-2xl desktop:text-[32px] text-info-primary mb-1 text-xl font-bold\">\n {item?.title}\n </Heading>\n <Heading\n as=\"h4\"\n className=\"lg-desktop:text-[18px] desktop:text-[16px] text-info-primary line-clamp-2 text-[14px] font-[700]\"\n >\n {item?.subTitle}\n </Heading>\n </div>\n {primaryButton && (\n <Button\n className={cn('mb-1.5 font-bold')}\n as=\"a\"\n href={trackUrlRef(item?.link, `${componentType}_${componentName}`)}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-title-desc-button={`${item?.title}#${item?.subTitle}#${primaryButton}`}\n onClick={() => event?.primaryButton?.(data, idx)}\n >\n {primaryButton}\n <span className=\"sr-only\">{item?.title ?? item?.subTitle}</span>\n </Button>\n )}\n </div>\n </div>\n )\n}\n\nconst MobileItem = ({ data, configuration }: { data: ItemType; configuration?: any }) => {\n const ref = useRef<HTMLDivElement>(null)\n\n useExposure(ref, {\n componentType,\n componentName,\n componentTitle: data?.title,\n position: configuration?.index + 1,\n componentDescription: data?.subTitle,\n })\n\n return (\n <div\n ref={ref}\n className={cn(\n 'bg-container-secondary-1 relative w-full shrink-0 grow-0 overflow-hidden border border-solid',\n configuration?.itemShape === 'round' ? 'rounded-2xl' : ''\n )}\n >\n <a\n href={trackUrlRef(data?.imgLink, `${componentType}_${componentName}`)}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-title-desc-button={`${data?.title}@${data?.subTitle}`}\n data-headless-nav-position={`''#${configuration?.index + 1}`}\n >\n <Picture\n className=\"size-full object-cover [&_img]:h-full [&_img]:object-cover\"\n source={data?.mobileImg?.url || ''}\n alt={data?.mobileImg?.alt || ''}\n />\n </a>\n <div className={cn('absolute inset-x-0 bottom-0 overflow-hidden px-4 pb-4')}>\n <div className=\"tablet:mb-6 mb-4 flex-1 overflow-hidden\">\n <h3\n className=\"text-info-primary line-clamp-3 text-2xl font-bold leading-[1.2]\"\n dangerouslySetInnerHTML={{ __html: data?.title }}\n ></h3>\n <h4\n className=\"text-info-primary line-clamp-2 text-sm font-bold\"\n dangerouslySetInnerHTML={{ __html: data?.subTitle }}\n ></h4>\n </div>\n\n {configuration?.primaryButton && (\n <Button\n as=\"a\"\n variant=\"secondary\"\n aria-label={data?.title ?? data?.subTitle}\n className={cn('text-info-primary text-sm font-bold')}\n href={trackUrlRef(data.link, `${componentType}_${componentName}`)}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-nav-position={`''#${configuration?.index + 1}`}\n data-headless-title-desc-button={`${data?.title}#${data?.subTitle}#${configuration?.primaryButton}`}\n >\n {configuration?.primaryButton}\n </Button>\n )}\n </div>\n </div>\n )\n}\n\nconst AccordionCards = React.forwardRef<HTMLDivElement, AccordionCardsType>(\n ({ data, autoplay = { enabled: false, loop: false, interval: 1500 }, className = '', event, ...rest }, ref) => {\n const [hoverIndex, setHoverIndex] = useState<number | null>(0)\n\n const hoverIndexRef = useRef<number>(0)\n const accordionRef = useRef<HTMLDivElement[]>([])\n const [contentWidth, setContentWidth] = useState<number>(0)\n\n const innerRef = useRef<HTMLDivElement>(null)\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement)\n\n const getRef = (index: number, el: HTMLDivElement) => {\n if (el) {\n accordionRef.current[index] = el\n }\n }\n\n useEffect(() => {\n const handleResize = () => {\n if (accordionRef.current[hoverIndexRef.current]) {\n setContentWidth(accordionRef.current[hoverIndexRef.current].offsetWidth)\n }\n }\n handleResize()\n const throttleResize = throttle(handleResize, 300)\n window.addEventListener('resize', throttleResize)\n return () => window.removeEventListener('resize', throttleResize)\n }, [])\n\n const handleSwiperItemClick = useCallback(\n (idx: number) => {\n if (hoverIndex === idx) return\n // \u66F4\u65B0\u5BBD\u5EA6\u76F8\u5173\u72B6\u6001\n setHoverIndex(idx)\n hoverIndexRef.current = idx\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [data?.products, hoverIndex]\n )\n\n useEffect(() => {\n let autoPlayTimer: NodeJS.Timeout\n if (autoplay?.enabled) {\n autoPlayTimer = setInterval(() => {\n setHoverIndex(prev => {\n const currentIndex = prev ?? 0\n let nextIndex: number\n\n if (autoplay.loop !== false) {\n // \u9ED8\u8BA4\u5FAA\u73AF\u64AD\u653E\n nextIndex = (currentIndex + 1) % data?.products?.length\n } else {\n // \u4E0D\u5FAA\u73AF\uFF1A\u64AD\u653E\u5230\u6700\u540E\u4E00\u4E2A\u540E\u505C\u6B62\n nextIndex = currentIndex + 1\n if (nextIndex >= data?.products?.length) {\n nextIndex = data?.products?.length - 1\n // \u505C\u6B62\u81EA\u52A8\u64AD\u653E\n if (autoPlayTimer) {\n clearInterval(autoPlayTimer)\n }\n return currentIndex // \u4FDD\u6301\u5728\u6700\u540E\u4E00\u4E2A\n }\n }\n\n hoverIndexRef.current = nextIndex\n return nextIndex\n })\n }, autoplay?.interval)\n }\n return () => {\n if (autoPlayTimer) {\n clearInterval(autoPlayTimer)\n }\n }\n }, [autoplay?.enabled, autoplay?.interval, autoplay?.loop, data?.products?.length, handleSwiperItemClick])\n\n return (\n <div {...rest} ref={innerRef}>\n {data?.title && <Title data={{ title: data?.title }} />}\n <div className={cn('laptop:block hidden', { 'aiui-dark': data?.theme === 'dark' })}>\n <div\n className={cn(\n 'lg-desktop:h-[calc(560_/_1920*100vw)] desktop:h-[calc(448_/_1440*100vw)] laptop:h-[calc(336_/_1025*100vw)] flex max-h-[560px] min-h-[336px] w-full gap-4 overflow-hidden',\n className\n )}\n >\n {data?.products?.map((item, idx) => (\n <AccordionCardsPcItem\n key={idx}\n item={item}\n idx={idx}\n itemShape={data?.itemShape}\n hoverIndex={hoverIndex}\n getRef={getRef}\n handleSwiperItemClick={handleSwiperItemClick}\n contentWidth={contentWidth}\n primaryButton={data?.primaryButton}\n event={event}\n data={data}\n accordionRef={accordionRef}\n />\n ))}\n </div>\n </div>\n <div className={cn('laptop:hidden block', { 'aiui-dark': data?.theme === 'dark' })}>\n <SwiperBox\n className={cn('h-[400px] !overflow-visible', className)}\n id={'AccordionCards' + data?.key}\n data={{\n list: data?.products,\n configuration: {\n shape: data?.shape,\n itemShape: data?.itemShape,\n primaryButton: data?.primaryButton,\n event: event,\n title: data?.title,\n },\n }}\n Slide={MobileItem}\n breakpoints={{\n 0: {\n spaceBetween: 12,\n freeMode: false,\n slidesPerView: 1,\n },\n 374: {\n spaceBetween: 12,\n freeMode: false,\n slidesPerView: 1.2,\n },\n 768: {\n spaceBetween: 16,\n freeMode: false,\n slidesPerView: 2.3,\n },\n }}\n />\n </div>\n </div>\n )\n }\n)\n\nAccordionCards.displayName = 'AccordionCards'\nexport default withLayout(AccordionCards)\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "Title", "cn", "Picture", "Button", "SwiperBox", "withLayout", "React", "useState", "useRef", "useCallback", "useImperativeHandle", "useEffect", "useExposure", "trackUrlRef", "throttle", "Heading", "componentType", "componentName", "AccordionCardsPcItem", "item", "idx", "itemShape", "hoverIndex", "getRef", "handleSwiperItemClick", "contentWidth", "primaryButton", "event", "data", "accordionRef", "isExpanded", "flexValue", "el", "MobileItem", "configuration", "ref", "AccordionCards", "autoplay", "className", "rest", "setHoverIndex", "hoverIndexRef", "setContentWidth", "innerRef", "index", "handleResize", "throttleResize", "autoPlayTimer", "prev", "currentIndex", "nextIndex", "AccordionCards_default"]
|
|
4
|
+
"sourcesContent": ["'use client'\nimport Title from '../Title/index.js'\nimport { cn } from '../../helpers/utils.js'\nimport Picture from '../../components/picture.js'\nimport Button from '../../components/button.js'\nimport SwiperBox from '../SwiperBox/index.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport React, { useState, useRef, useCallback, useImperativeHandle, useEffect, type RefObject } from 'react'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { trackUrlRef } from '../../shared/trackUrlRef.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\nimport type { Img } from '../../types/props.js'\nimport throttle from '../../shared/throttle.js'\nimport { Heading } from '../../components/heading.js'\n\nconst componentType = 'image'\nconst componentName = 'scene_banner'\n\n/** Hook\uFF1A\u76D1\u542C\u7A97\u53E3\u5BBD\u5EA6 */\ntype ItemType = {\n /** \u6807\u9898\u6587\u672C */\n title: string\n /** \u56FE\u7247*/\n img: Img\n mobileImg?: Img\n /** \u5185\u5BB9\u8282\u70B9 */\n subTitle: string\n link?: string\n imgLink?: string\n}\n\nexport type AccordionCardsType = Omit<React.HTMLAttributes<HTMLDivElement>, 'className'> & {\n className?: string\n data: {\n key?: string\n title?: string\n products: Array<ItemType>\n /** \u6309\u94AE\u5F62\u72B6 */\n shape?: 'round' | 'square'\n /** \u5361\u7247\u5F62\u72B6 */\n itemShape?: 'round' | 'square'\n /** \u4E3B\u6309\u94AE\u914D\u7F6E */\n primaryButton?: string\n theme?: 'light' | 'dark'\n }\n /**\n * \u81EA\u52A8\u64AD\u653E\u914D\u7F6E\n */\n autoplay?: {\n /**\n * \u662F\u5426\u5F00\u542F\u81EA\u52A8\u64AD\u653E\n */\n enabled: boolean\n /**\n * \u662F\u5426\u5FAA\u73AF\u64AD\u653E\n */\n loop?: boolean\n /**\n * \u81EA\u52A8\u64AD\u653E\u95F4\u9694\u65F6\u95F4\uFF0C\u5355\u4F4D\u6BEB\u79D2\n */\n interval?: number\n }\n /** \u6309\u94AE\u4E8B\u4EF6*/\n event?: {\n primaryButton?: (_v: any, _index: number) => void\n }\n}\n\nconst AccordionCardsPcItem = ({\n item,\n idx,\n itemShape,\n hoverIndex,\n getRef,\n handleSwiperItemClick,\n contentWidth,\n primaryButton,\n event,\n data,\n accordionRef,\n}: {\n item: ItemType\n idx: number\n itemShape: 'round' | 'square' | undefined\n hoverIndex: number | null\n getRef: (_idx: number, _el: HTMLDivElement) => void\n handleSwiperItemClick: (_idx: number) => void\n contentWidth: number\n primaryButton: string | undefined\n event: any\n data: AccordionCardsType['data']\n accordionRef: React.MutableRefObject<HTMLDivElement[]>\n}) => {\n const isExpanded = hoverIndex === idx\n const flexValue = isExpanded ? 8 : 1\n\n const { trackingData } = useAiuiContext()\n const contextHandle = trackingData?.contextHandle || ''\n\n useExposure({ current: accordionRef.current[idx] } as RefObject<HTMLDivElement>, {\n componentType,\n componentName,\n componentTitle: item?.title,\n position: idx + 1,\n componentDescription: item?.subTitle,\n })\n\n return (\n <div\n key={idx}\n style={{\n flex: `${flexValue} 1 0%`,\n transition: 'all 0.6s',\n }}\n ref={(el: HTMLDivElement | null) => {\n if (el) getRef(idx, el)\n }}\n className={cn('relative cursor-pointer overflow-hidden', itemShape === 'round' ? 'rounded-2xl' : '')}\n onMouseEnter={() => handleSwiperItemClick(idx)}\n onClick={() => {\n handleSwiperItemClick(idx)\n }}\n >\n <a\n href={trackUrlRef(item?.imgLink, `${contextHandle}_${componentType}_${componentName}`)}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-title-desc-button={`${item?.title}#${item?.subTitle}`}\n >\n <Picture\n source={item?.img?.url}\n className=\"size-full object-cover [&_img]:h-full [&_img]:object-cover\"\n alt={item?.img?.alt || ''}\n />\n </a>\n <div\n style={{\n width: contentWidth,\n }}\n className={cn(\n 'absolute inset-x-0 bottom-0 flex w-full items-end justify-between overflow-hidden px-8 pb-8 opacity-0 transition-opacity duration-[600ms] ease-in',\n isExpanded && contentWidth ? 'opacity-100' : 'opacity-0'\n )}\n >\n <div className=\"mr-16 flex-1 overflow-hidden\">\n <Heading as=\"h3\" className=\"laptop:text-2xl desktop:text-[32px] text-info-primary mb-1 text-xl font-bold\">\n {item?.title}\n </Heading>\n <Heading\n as=\"h4\"\n className=\"lg-desktop:text-[18px] desktop:text-[16px] text-info-primary line-clamp-2 text-[14px] font-[700]\"\n >\n {item?.subTitle}\n </Heading>\n </div>\n {primaryButton && (\n <Button\n className={cn('mb-1.5 font-bold')}\n as=\"a\"\n href={trackUrlRef(item?.link, `${contextHandle}_${componentType}_${componentName}`)}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-title-desc-button={`${item?.title}#${item?.subTitle}#${primaryButton}`}\n onClick={() => event?.primaryButton?.(data, idx)}\n >\n {primaryButton}\n <span className=\"sr-only\">{item?.title ?? item?.subTitle}</span>\n </Button>\n )}\n </div>\n </div>\n )\n}\n\nconst MobileItem = ({ data, configuration }: { data: ItemType; configuration?: any }) => {\n const ref = useRef<HTMLDivElement>(null)\n const { trackingData } = useAiuiContext()\n const contextHandle = trackingData?.contextHandle || ''\n useExposure(ref, {\n componentType,\n componentName,\n componentTitle: data?.title,\n position: configuration?.index + 1,\n componentDescription: data?.subTitle,\n })\n\n return (\n <div\n ref={ref}\n className={cn(\n 'bg-container-secondary-1 relative w-full shrink-0 grow-0 overflow-hidden border border-solid',\n configuration?.itemShape === 'round' ? 'rounded-2xl' : ''\n )}\n >\n <a\n href={trackUrlRef(data?.imgLink, `${contextHandle}_${componentType}_${componentName}`)}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-title-desc-button={`${data?.title}@${data?.subTitle}`}\n data-headless-nav-position={`''#${configuration?.index + 1}`}\n >\n <Picture\n className=\"size-full object-cover [&_img]:h-full [&_img]:object-cover\"\n source={data?.mobileImg?.url || ''}\n alt={data?.mobileImg?.alt || ''}\n />\n </a>\n <div className={cn('absolute inset-x-0 bottom-0 overflow-hidden px-4 pb-4')}>\n <div className=\"tablet:mb-6 mb-4 flex-1 overflow-hidden\">\n <h3\n className=\"text-info-primary line-clamp-3 text-2xl font-bold leading-[1.2]\"\n dangerouslySetInnerHTML={{ __html: data?.title }}\n ></h3>\n <h4\n className=\"text-info-primary line-clamp-2 text-sm font-bold\"\n dangerouslySetInnerHTML={{ __html: data?.subTitle }}\n ></h4>\n </div>\n\n {configuration?.primaryButton && (\n <Button\n as=\"a\"\n variant=\"secondary\"\n aria-label={data?.title ?? data?.subTitle}\n className={cn('text-info-primary text-sm font-bold')}\n href={trackUrlRef(data.link, `${contextHandle}_${componentType}_${componentName}`)}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-nav-position={`''#${configuration?.index + 1}`}\n data-headless-title-desc-button={`${data?.title}#${data?.subTitle}#${configuration?.primaryButton}`}\n >\n {configuration?.primaryButton}\n </Button>\n )}\n </div>\n </div>\n )\n}\n\nconst AccordionCards = React.forwardRef<HTMLDivElement, AccordionCardsType>(\n ({ data, autoplay = { enabled: false, loop: false, interval: 1500 }, className = '', event, ...rest }, ref) => {\n const [hoverIndex, setHoverIndex] = useState<number | null>(0)\n\n const hoverIndexRef = useRef<number>(0)\n const accordionRef = useRef<HTMLDivElement[]>([])\n const [contentWidth, setContentWidth] = useState<number>(0)\n\n const innerRef = useRef<HTMLDivElement>(null)\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement)\n\n const getRef = (index: number, el: HTMLDivElement) => {\n if (el) {\n accordionRef.current[index] = el\n }\n }\n\n useEffect(() => {\n const handleResize = () => {\n if (accordionRef.current[hoverIndexRef.current]) {\n setContentWidth(accordionRef.current[hoverIndexRef.current].offsetWidth)\n }\n }\n handleResize()\n const throttleResize = throttle(handleResize, 300)\n window.addEventListener('resize', throttleResize)\n return () => window.removeEventListener('resize', throttleResize)\n }, [])\n\n const handleSwiperItemClick = useCallback(\n (idx: number) => {\n if (hoverIndex === idx) return\n // \u66F4\u65B0\u5BBD\u5EA6\u76F8\u5173\u72B6\u6001\n setHoverIndex(idx)\n hoverIndexRef.current = idx\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [data?.products, hoverIndex]\n )\n\n useEffect(() => {\n let autoPlayTimer: NodeJS.Timeout\n if (autoplay?.enabled) {\n autoPlayTimer = setInterval(() => {\n setHoverIndex(prev => {\n const currentIndex = prev ?? 0\n let nextIndex: number\n\n if (autoplay.loop !== false) {\n // \u9ED8\u8BA4\u5FAA\u73AF\u64AD\u653E\n nextIndex = (currentIndex + 1) % data?.products?.length\n } else {\n // \u4E0D\u5FAA\u73AF\uFF1A\u64AD\u653E\u5230\u6700\u540E\u4E00\u4E2A\u540E\u505C\u6B62\n nextIndex = currentIndex + 1\n if (nextIndex >= data?.products?.length) {\n nextIndex = data?.products?.length - 1\n // \u505C\u6B62\u81EA\u52A8\u64AD\u653E\n if (autoPlayTimer) {\n clearInterval(autoPlayTimer)\n }\n return currentIndex // \u4FDD\u6301\u5728\u6700\u540E\u4E00\u4E2A\n }\n }\n\n hoverIndexRef.current = nextIndex\n return nextIndex\n })\n }, autoplay?.interval)\n }\n return () => {\n if (autoPlayTimer) {\n clearInterval(autoPlayTimer)\n }\n }\n }, [autoplay?.enabled, autoplay?.interval, autoplay?.loop, data?.products?.length, handleSwiperItemClick])\n\n return (\n <div {...rest} ref={innerRef}>\n {data?.title && <Title data={{ title: data?.title }} />}\n <div className={cn('laptop:block hidden', { 'aiui-dark': data?.theme === 'dark' })}>\n <div\n className={cn(\n 'lg-desktop:h-[calc(560_/_1920*100vw)] desktop:h-[calc(448_/_1440*100vw)] laptop:h-[calc(336_/_1025*100vw)] flex max-h-[560px] min-h-[336px] w-full gap-4 overflow-hidden',\n className\n )}\n >\n {data?.products?.map((item, idx) => (\n <AccordionCardsPcItem\n key={idx}\n item={item}\n idx={idx}\n itemShape={data?.itemShape}\n hoverIndex={hoverIndex}\n getRef={getRef}\n handleSwiperItemClick={handleSwiperItemClick}\n contentWidth={contentWidth}\n primaryButton={data?.primaryButton}\n event={event}\n data={data}\n accordionRef={accordionRef}\n />\n ))}\n </div>\n </div>\n <div className={cn('laptop:hidden block', { 'aiui-dark': data?.theme === 'dark' })}>\n <SwiperBox\n className={cn('h-[400px] !overflow-visible', className)}\n id={'AccordionCards' + data?.key}\n data={{\n list: data?.products,\n configuration: {\n shape: data?.shape,\n itemShape: data?.itemShape,\n primaryButton: data?.primaryButton,\n event: event,\n title: data?.title,\n },\n }}\n Slide={MobileItem}\n breakpoints={{\n 0: {\n spaceBetween: 12,\n freeMode: false,\n slidesPerView: 1,\n },\n 374: {\n spaceBetween: 12,\n freeMode: false,\n slidesPerView: 1.2,\n },\n 768: {\n spaceBetween: 16,\n freeMode: false,\n slidesPerView: 2.3,\n },\n }}\n />\n </div>\n </div>\n )\n }\n)\n\nAccordionCards.displayName = 'AccordionCards'\nexport default withLayout(AccordionCards)\n"],
|
|
5
|
+
"mappings": "aAgIQ,cAAAA,EAeA,QAAAC,MAfA,oBA/HR,OAAOC,MAAW,oBAClB,OAAS,MAAAC,MAAU,yBACnB,OAAOC,MAAa,8BACpB,OAAOC,MAAY,6BACnB,OAAOC,MAAe,wBACtB,OAAS,cAAAC,MAAkB,yBAC3B,OAAOC,GAAS,YAAAC,EAAU,UAAAC,EAAQ,eAAAC,EAAa,uBAAAC,EAAqB,aAAAC,MAAiC,QACrG,OAAS,eAAAC,MAAmB,6BAC5B,OAAS,eAAAC,MAAmB,8BAC5B,OAAS,kBAAAC,MAAsB,2BAE/B,OAAOC,MAAc,2BACrB,OAAS,WAAAC,MAAe,8BAExB,MAAMC,EAAgB,QAChBC,EAAgB,eAoDhBC,EAAuB,CAAC,CAC5B,KAAAC,EACA,IAAAC,EACA,UAAAC,EACA,WAAAC,EACA,OAAAC,EACA,sBAAAC,EACA,aAAAC,EACA,cAAAC,EACA,MAAAC,EACA,KAAAC,EACA,aAAAC,CACF,IAYM,CACJ,MAAMC,EAAaR,IAAeF,EAC5BW,EAAYD,EAAa,EAAI,EAE7B,CAAE,aAAAE,CAAa,EAAInB,EAAe,EAClCoB,EAAgBD,GAAc,eAAiB,GAErD,OAAArB,EAAY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AAS,EACtD,GAAI,iBAAmBZ,GAAM,IAC7B,KAAM,CACJ,KAAMA,GAAM,SACZ,cAAe,CACb,MAAOA,GAAM,MACb,UAAWA,GAAM,UACjB,cAAeA,GAAM,cACrB,MAAOD,EACP,MAAOC,GAAM,KACf,CACF,EACA,MAAOO,EACP,YAAa,CACX,EAAG,CACD,aAAc,GACd,SAAU,GACV,cAAe,CACjB,EACA,IAAK,CACH,aAAc,GACd,SAAU,GACV,cAAe,GACjB,EACA,IAAK,CACH,aAAc,GACd,SAAU,GACV,cAAe,GACjB,CACF,EACF,EACF,GACF,CAEJ,CACF,EAEAG,EAAe,YAAc,iBAC7B,IAAOe,GAAQjD,EAAWkC,CAAc",
|
|
6
|
+
"names": ["jsx", "jsxs", "Title", "cn", "Picture", "Button", "SwiperBox", "withLayout", "React", "useState", "useRef", "useCallback", "useImperativeHandle", "useEffect", "useExposure", "trackUrlRef", "useAiuiContext", "throttle", "Heading", "componentType", "componentName", "AccordionCardsPcItem", "item", "idx", "itemShape", "hoverIndex", "getRef", "handleSwiperItemClick", "contentWidth", "primaryButton", "event", "data", "accordionRef", "isExpanded", "flexValue", "trackingData", "contextHandle", "el", "MobileItem", "configuration", "ref", "AccordionCards", "autoplay", "className", "rest", "setHoverIndex", "hoverIndexRef", "setContentWidth", "innerRef", "index", "handleResize", "throttleResize", "autoPlayTimer", "prev", "currentIndex", "nextIndex", "AccordionCards_default"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as l,jsxs as A}from"react/jsx-runtime";import M,{useImperativeHandle as R,useRef as T}from"react";import{Heading as V,Picture as C,Text as D,Button as N,Link as H,Container as L}from"../../components/index.js";import"../../shared/Styles.js";import{cn as r,extractLexicalText as x}from"../../helpers/index.js";import{useExposure as P}from"../../hooks/useExposure.js";import{trackUrlRef as k}from"../../shared/trackUrlRef.js";import{cva as f}from"class-variance-authority";import{getLocalizedPath as $}from"../../helpers/index.js";import{useAiuiContext as w}from"../AiuiProvider/index.js";const d="image",m="activity_mechanism",B=f("line-clamp-2",{variants:{theme:{light:"text-[#080A0F]",dark:"text-white"}},defaultVariants:{theme:"light"}}),z=f("desktop:text-[16px] mt-1 line-clamp-2 text-[14px] font-bold leading-[1.4] tracking-[-0.02em]",{variants:{theme:{light:"text-[#080A0F]",dark:"text-white/80"}},defaultVariants:{theme:"light"}}),E=f("mt-2 !p-0 text-[14px]",{variants:{theme:{light:"text-[#080A0F]",dark:"text-white"}},defaultVariants:{theme:"light"}}),h={default:767,tablet:1024,laptop:1439,desktop:1919,lgDesktop:9999},S=t=>{if(!t)return"";const e=[];return t.lgDesktop?.url&&e.push(`${t.lgDesktop.url}`),t.desktop?.url&&e.push(`${t.desktop.url} ${h.desktop}`),t.laptop?.url&&e.push(`${t.laptop.url} ${h.laptop}`),t.tablet?.url&&e.push(`${t.tablet.url} ${h.tablet}`),t.default?.url&&e.push(`${t.default.url} ${h.default}`),e.join(", ")},_=t=>t&&(t.default?.alt||t.tablet?.alt||t.laptop?.alt||t.desktop?.alt||t.lgDesktop?.alt)||"",F=({item:t,theme:e,classNames:s})=>{const{title:i,description:p,linkText:a,linkHref:o,backgroundImage:c}=t,n=S(c),u=_(c),{locale:v="us",trackingData:g}=w();return l("div",{className:r("rounded-card relative flex flex-col overflow-hidden","desktop:px-6 h-[280px] p-4","laptop:gap-4 gap-3","laptop:h-[320px] lg-desktop:[400px]",s?.card),"data-headless-type-name":`${d}#${m}`,"data-headless-title-desc-button":`${t.title||""}#${t.description||""}#${t.linkText||""}`,children:A(H,{asChild:!o,href:$(k(o,`${g?.contextHandle||""}_${d}_${m}`),v),className:"no-underline",children:[n&&l(C,{source:n,alt:u||i,className:r("absolute inset-0 size-full",s?.background),imgClassName:"size-full object-cover"}),A("div",{className:"relative z-10",children:[l(V,{as:"h3",size:3,className:r(B({theme:e}),s?.title),children:i}),l(D,{as:"p",className:r(z({theme:e}),s?.description),children:p}),a&&o&&l(N,{variant:"link",as:"a",href:$(k(o,`${g?.contextHandle||""}_${d}_${m}`),v),className:r(E({theme:e}),s?.link),"data-headless-title-desc-button":`${i}#${p}#${a}`,children:a})]})]})})},y=M.forwardRef(({data:t,classNames:e},s)=>{const{items:i=[],theme:p="light"}=t,a=T(null);if(R(s,()=>a.current),P(a,{componentType:d,componentName:m,componentTitle:x(i[0]?.title)||"",componentDescription:x(i[0]?.description)||""}),!i||i.length===0)return null;const o={1:"laptop:grid-cols-1 desktop:grid-cols-1 lg-desktop:grid-cols-1",2:"laptop:grid-cols-2 desktop:grid-cols-2 lg-desktop:grid-cols-2",3:"tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-3 lg-desktop:grid-cols-3",4:"laptop:grid-cols-4 desktop:grid-cols-4 lg-desktop:grid-cols-4"},c=o[Math.min(i.length,4)]||o[4];return l(L,{"data-ui-component-id":"ActivityMechanism",className:r("activity-mechanism","w-full",e?.root),ref:a,children:l("div",{className:r("tablet:grid-cols-2 laptop:gap-4 grid grid-cols-1 gap-3",c,e?.grid),children:i.map((n,u)=>l(F,{item:n,theme:p,classNames:{...e,...i?.length===3&&{card:e?.card+" first:tablet:col-span-full first:laptop:col-span-1"}}},`${n.title}-${u}`))})})});y.displayName="ActivityMechanism";var X=y;export{X as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/ActivityMechanism/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\nimport React, { useImperativeHandle, useRef } from 'react'\nimport { Heading, Picture, Text, Button, Link, Container } from '../../components/index.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport type {\n ActivityMechanismProps,\n ActivityMechanismItem,\n ActivityMechanismSemanticName,\n ResponsiveBackgroundImage,\n} from './types.js'\nimport { cn } from '../../helpers/
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "React", "useImperativeHandle", "useRef", "Heading", "Picture", "Text", "Button", "Link", "Container", "cn", "useExposure", "trackUrlRef", "cva", "getLocalizedPath", "useAiuiContext", "componentType", "componentName", "titleVariants", "descriptionVariants", "linkVariants", "BREAKPOINTS", "buildResponsiveSource", "backgroundImage", "sources", "getDefaultAlt", "ActivityMechanismCard", "item", "theme", "classNames", "title", "description", "linkText", "linkHref", "responsiveSource", "defaultAlt", "locale", "ActivityMechanism", "data", "ref", "items", "innerRef", "gridColsMap", "gridColsClass", "index", "ActivityMechanism_default"]
|
|
4
|
+
"sourcesContent": ["'use client'\nimport React, { useImperativeHandle, useRef } from 'react'\nimport { Heading, Picture, Text, Button, Link, Container } from '../../components/index.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport type {\n ActivityMechanismProps,\n ActivityMechanismItem,\n ActivityMechanismSemanticName,\n ResponsiveBackgroundImage,\n} from './types.js'\nimport { cn, extractLexicalText } from '../../helpers/index.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { trackUrlRef } from '../../shared/trackUrlRef.js'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { getLocalizedPath } from '../../helpers/index.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\n\nconst componentType = 'image'\nconst componentName = 'activity_mechanism'\n\n/**\n * \u6807\u9898\u6837\u5F0F\u53D8\u4F53\n */\nconst titleVariants = cva('line-clamp-2', {\n variants: {\n theme: {\n light: 'text-[#080A0F]',\n dark: 'text-white',\n },\n },\n defaultVariants: {\n theme: 'light',\n },\n})\n\n/**\n * \u63CF\u8FF0\u6837\u5F0F\u53D8\u4F53\n */\nconst descriptionVariants = cva(\n 'desktop:text-[16px] mt-1 line-clamp-2 text-[14px] font-bold leading-[1.4] tracking-[-0.02em]',\n {\n variants: {\n theme: {\n light: 'text-[#080A0F]',\n dark: 'text-white/80',\n },\n },\n defaultVariants: {\n theme: 'light',\n },\n }\n)\n\n/**\n * \u94FE\u63A5\u6837\u5F0F\u53D8\u4F53\n */\nconst linkVariants = cva('mt-2 !p-0 text-[14px]', {\n variants: {\n theme: {\n light: 'text-[#080A0F]',\n dark: 'text-white',\n },\n },\n defaultVariants: {\n theme: 'light',\n },\n})\n\ntype ThemeVariants = VariantProps<typeof titleVariants>\n\n/**\n * \u65AD\u70B9\u914D\u7F6E\uFF08\u4E0E Tailwind \u65AD\u70B9\u5BF9\u5E94\uFF09\n * Picture \u7EC4\u4EF6\u4F7F\u7528 max-width \u5A92\u4F53\u67E5\u8BE2\uFF0C\u6240\u4EE5\u9700\u8981\u6309\u4ECE\u5C0F\u5230\u5927\u7684\u987A\u5E8F\u6392\u5217\n */\nconst BREAKPOINTS = {\n default: 767, // <768px (\u79FB\u52A8\u7AEF)\n tablet: 1024, // 768px - 1024px\n laptop: 1439, // 1025px - 1439px\n desktop: 1919, // 1440px - 1919px\n lgDesktop: 9999, // \u22651920px (\u6700\u5927\u503C\uFF0C\u4F5C\u4E3A\u9ED8\u8BA4\u56FE\u7247)\n} as const\n\n/**\n * \u5C06\u54CD\u5E94\u5F0F\u80CC\u666F\u56FE\u7247\u5BF9\u8C61\u8F6C\u6362\u4E3A Picture \u7EC4\u4EF6\u7684 source \u5B57\u7B26\u4E32\n * \u683C\u5F0F: \"url1 767, url2 1024, url3 1439, url4 1919, url5\"\n */\nconst buildResponsiveSource = (backgroundImage?: ResponsiveBackgroundImage): string => {\n if (!backgroundImage) return ''\n\n const sources: string[] = []\n\n // \u6309\u65AD\u70B9\u987A\u5E8F\u6DFB\u52A0\u56FE\u7247 URL\n // lgDesktop \u4F5C\u4E3A\u9ED8\u8BA4\u56FE\u7247\uFF0C\u4E0D\u9700\u8981\u65AD\u70B9\u503C\n if (backgroundImage.lgDesktop?.url) {\n sources.push(`${backgroundImage.lgDesktop.url}`)\n }\n if (backgroundImage.desktop?.url) {\n sources.push(`${backgroundImage.desktop.url} ${BREAKPOINTS.desktop}`)\n }\n if (backgroundImage.laptop?.url) {\n sources.push(`${backgroundImage.laptop.url} ${BREAKPOINTS.laptop}`)\n }\n if (backgroundImage.tablet?.url) {\n sources.push(`${backgroundImage.tablet.url} ${BREAKPOINTS.tablet}`)\n }\n if (backgroundImage.default?.url) {\n sources.push(`${backgroundImage.default.url} ${BREAKPOINTS.default}`)\n }\n\n return sources.join(', ')\n}\n\n/**\n * \u83B7\u53D6\u54CD\u5E94\u5F0F\u80CC\u666F\u56FE\u7247\u7684\u9ED8\u8BA4 alt \u6587\u672C\n */\nconst getDefaultAlt = (backgroundImage?: ResponsiveBackgroundImage): string => {\n if (!backgroundImage) return ''\n return (\n backgroundImage.default?.alt ||\n backgroundImage.tablet?.alt ||\n backgroundImage.laptop?.alt ||\n backgroundImage.desktop?.alt ||\n backgroundImage.lgDesktop?.alt ||\n ''\n )\n}\n\n/**\n * \u5355\u4E2A\u6D3B\u52A8\u673A\u5236\u5361\u7247\u7EC4\u4EF6\n */\nconst ActivityMechanismCard: React.FC<{\n item: ActivityMechanismItem\n theme?: ThemeVariants['theme']\n classNames?: Partial<Record<ActivityMechanismSemanticName, string>>\n}> = ({ item, theme, classNames }) => {\n const { title, description, linkText, linkHref, backgroundImage } = item\n const responsiveSource = buildResponsiveSource(backgroundImage)\n const defaultAlt = getDefaultAlt(backgroundImage)\n const { locale = 'us', trackingData } = useAiuiContext()\n\n return (\n <div\n className={cn(\n 'rounded-card relative flex flex-col overflow-hidden',\n 'desktop:px-6 h-[280px] p-4',\n 'laptop:gap-4 gap-3',\n 'laptop:h-[320px] lg-desktop:[400px]',\n classNames?.card\n )}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-title-desc-button={`${item.title || ''}#${item.description || ''}#${item.linkText || ''}`}\n >\n <Link\n asChild={!linkHref}\n href={getLocalizedPath(\n trackUrlRef(linkHref, `${trackingData?.contextHandle || ''}_${componentType}_${componentName}`),\n locale\n )}\n className=\"no-underline\"\n >\n {/* \u54CD\u5E94\u5F0F\u80CC\u666F\u56FE\u7247 */}\n {responsiveSource && (\n <Picture\n source={responsiveSource}\n alt={defaultAlt || title}\n className={cn('absolute inset-0 size-full', classNames?.background)}\n imgClassName=\"size-full object-cover\"\n />\n )}\n\n {/* \u6587\u672C\u5185\u5BB9\u533A\u57DF */}\n <div className=\"relative z-10\">\n <Heading as=\"h3\" size={3} className={cn(titleVariants({ theme }), classNames?.title)}>\n {title}\n </Heading>\n <Text as=\"p\" className={cn(descriptionVariants({ theme }), classNames?.description)}>\n {description}\n </Text>\n {linkText && linkHref && (\n <Button\n variant=\"link\"\n as=\"a\"\n href={getLocalizedPath(\n trackUrlRef(linkHref, `${trackingData?.contextHandle || ''}_${componentType}_${componentName}`),\n locale\n )}\n className={cn(linkVariants({ theme }), classNames?.link)}\n data-headless-title-desc-button={`${title}#${description}#${linkText}`}\n >\n {linkText}\n </Button>\n )}\n </div>\n </Link>\n </div>\n )\n}\n\n/**\n * ActivityMechanism - \u6D3B\u52A8\u673A\u5236\u7EC4\u4EF6\n *\n * @description \u5C55\u793A\u6D3B\u52A8\u673A\u5236/\u4F1A\u5458\u6743\u76CA\u7B49\u5361\u7247\u5217\u8868\u7684\u7EC4\u4EF6\uFF0C\u652F\u6301\u54CD\u5E94\u5F0F\u5E03\u5C40\u548C\u4E3B\u9898\u5207\u6362\n */\nconst ActivityMechanism = React.forwardRef<HTMLDivElement, ActivityMechanismProps>(({ data, classNames }, ref) => {\n const { items = [], theme = 'light' } = data\n\n const innerRef = useRef<HTMLDivElement>(null)\n\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement)\n\n useExposure(innerRef, {\n componentType,\n componentName,\n componentTitle: extractLexicalText(items[0]?.title) || '',\n componentDescription: extractLexicalText(items[0]?.description) || '',\n })\n\n if (!items || items.length === 0) {\n return null\n }\n\n // \u6839\u636E items \u6570\u91CF\u6620\u5C04 laptop/desktop/lg-desktop \u7684\u5217\u6570\u7C7B\u540D\n // \u4F7F\u7528\u663E\u5F0F\u7C7B\u540D\u6620\u5C04\u4EE5\u786E\u4FDD Tailwind \u80FD\u6B63\u786E\u626B\u63CF\n const gridColsMap: Record<number, string> = {\n 1: 'laptop:grid-cols-1 desktop:grid-cols-1 lg-desktop:grid-cols-1',\n 2: 'laptop:grid-cols-2 desktop:grid-cols-2 lg-desktop:grid-cols-2',\n 3: 'tablet:grid-cols-2 laptop:grid-cols-3 desktop:grid-cols-3 lg-desktop:grid-cols-3',\n 4: 'laptop:grid-cols-4 desktop:grid-cols-4 lg-desktop:grid-cols-4',\n }\n const gridColsClass = gridColsMap[Math.min(items.length, 4)] || gridColsMap[4]\n\n return (\n <Container\n data-ui-component-id=\"ActivityMechanism\"\n className={cn('activity-mechanism', 'w-full', classNames?.root)}\n ref={innerRef}\n >\n <div className={cn('tablet:grid-cols-2 laptop:gap-4 grid grid-cols-1 gap-3', gridColsClass, classNames?.grid)}>\n {items.map((item, index) => (\n <ActivityMechanismCard\n key={`${item.title}-${index}`}\n item={item}\n theme={theme}\n classNames={{\n ...classNames,\n ...(items?.length === 3 && {\n card: classNames?.card + ' ' + 'first:tablet:col-span-full first:laptop:col-span-1',\n }),\n }}\n />\n ))}\n </div>\n </Container>\n )\n})\n\nActivityMechanism.displayName = 'ActivityMechanism'\n\nexport default ActivityMechanism\n"],
|
|
5
|
+
"mappings": "aAkKU,cAAAA,EASF,QAAAC,MATE,oBAjKV,OAAOC,GAAS,uBAAAC,EAAqB,UAAAC,MAAc,QACnD,OAAS,WAAAC,EAAS,WAAAC,EAAS,QAAAC,EAAM,UAAAC,EAAQ,QAAAC,EAAM,aAAAC,MAAiB,4BAChE,MAA2B,yBAO3B,OAAS,MAAAC,EAAI,sBAAAC,MAA0B,yBACvC,OAAS,eAAAC,MAAmB,6BAC5B,OAAS,eAAAC,MAAmB,8BAC5B,OAAS,OAAAC,MAA8B,2BACvC,OAAS,oBAAAC,MAAwB,yBACjC,OAAS,kBAAAC,MAAsB,2BAE/B,MAAMC,EAAgB,QAChBC,EAAgB,qBAKhBC,EAAgBL,EAAI,eAAgB,CACxC,SAAU,CACR,MAAO,CACL,MAAO,iBACP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SAAAA,EACH,GAEJ,GACF,EACF,CAEJ,EAOMM,EAAoBtC,EAAM,WAAmD,CAAC,CAAE,KAAAuC,EAAM,WAAAV,CAAW,EAAGW,IAAQ,CAChH,KAAM,CAAE,MAAAC,EAAQ,CAAC,EAAG,MAAAb,EAAQ,OAAQ,EAAIW,EAElCG,EAAWxC,EAAuB,IAAI,EAW5C,GATAD,EAAoBuC,EAAK,IAAME,EAAS,OAAyB,EAEjE/B,EAAY+B,EAAU,CACpB,cAAA1B,EACA,cAAAC,EACA,eAAgBP,EAAmB+B,EAAM,CAAC,GAAG,KAAK,GAAK,GACvD,qBAAsB/B,EAAmB+B,EAAM,CAAC,GAAG,WAAW,GAAK,EACrE,CAAC,EAEG,CAACA,GAASA,EAAM,SAAW,EAC7B,OAAO,KAKT,MAAME,EAAsC,CAC1C,EAAG,gEACH,EAAG,gEACH,EAAG,mFACH,EAAG,+DACL,EACMC,EAAgBD,EAAY,KAAK,IAAIF,EAAM,OAAQ,CAAC,CAAC,GAAKE,EAAY,CAAC,EAE7E,OACE7C,EAACU,EAAA,CACC,uBAAqB,oBACrB,UAAWC,EAAG,qBAAsB,SAAUoB,GAAY,IAAI,EAC9D,IAAKa,EAEL,SAAA5C,EAAC,OAAI,UAAWW,EAAG,yDAA0DmC,EAAef,GAAY,IAAI,EACzG,SAAAY,EAAM,IAAI,CAACd,EAAMkB,IAChB/C,EAAC4B,EAAA,CAEC,KAAMC,EACN,MAAOC,EACP,WAAY,CACV,GAAGC,EACH,GAAIY,GAAO,SAAW,GAAK,CACzB,KAAMZ,GAAY,KAAO,qDAC3B,CACF,GARK,GAAGF,EAAK,KAAK,IAAIkB,CAAK,EAS7B,CACD,EACH,EACF,CAEJ,CAAC,EAEDP,EAAkB,YAAc,oBAEhC,IAAOQ,EAAQR",
|
|
6
|
+
"names": ["jsx", "jsxs", "React", "useImperativeHandle", "useRef", "Heading", "Picture", "Text", "Button", "Link", "Container", "cn", "extractLexicalText", "useExposure", "trackUrlRef", "cva", "getLocalizedPath", "useAiuiContext", "componentType", "componentName", "titleVariants", "descriptionVariants", "linkVariants", "BREAKPOINTS", "buildResponsiveSource", "backgroundImage", "sources", "getDefaultAlt", "ActivityMechanismCard", "item", "theme", "classNames", "title", "description", "linkText", "linkHref", "responsiveSource", "defaultAlt", "locale", "trackingData", "ActivityMechanism", "data", "ref", "items", "innerRef", "gridColsMap", "gridColsClass", "index", "ActivityMechanism_default"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as
|
|
1
|
+
"use client";import{jsx as t,jsxs as g}from"react/jsx-runtime";import*as o from"react";import{cn as n}from"../../helpers/index.js";import{useAiuiContext as C}from"../AiuiProvider/index.js";import{trackUrlRef as P}from"../../shared/trackUrlRef.js";import{getLocalizedPath as z}from"../../helpers/index.js";import{Text as I,Picture as L,Heading as w,Container as V,Link as B}from"../../components/index.js";import{cva as x}from"class-variance-authority";import{Swiper as E,SwiperSlide as $}from"swiper/react";import{withLayout as H}from"../../shared/Styles.js";import{useExposure as T}from"../../hooks/useExposure.js";const v="image",h="activity_schedule",D=x("rounded-card laptop:px-6 laptop:py-4 relative flex min-w-0 flex-col justify-between gap-2 overflow-hidden px-4 py-3",{variants:{state:{"active-light":"bg-gradient-to-r from-[#3555aa] to-[#6988e3]","active-dark":"bg-gradient-to-r from-[#3555aa] to-[#6988e3]","inactive-light":"bg-[#EAEAEC]","inactive-dark":"bg-[#1E2024]"},size:{small:"laptop:h-[160px] h-[120px]",large:"laptop:h-[240px] h-[200px]"}},defaultVariants:{state:"inactive-light",size:"small"}}),f=x("font-bold leading-[1.2]",{variants:{state:{"active-light":"text-white","active-dark":"text-white","inactive-light":"text-[#080A0F]","inactive-dark":"text-white"}},defaultVariants:{state:"inactive-light"}}),y=o.memo(({item:e,theme:a="light",className:d,size:r})=>{const s=e.isActive||!1,{locale:p="us",trackingData:m}=C(),i=m?.contextHandle||"",l=`${s?"active":"inactive"}-${a}`;return t("div",{className:n(D({state:l,size:r}),d),"data-ui-component-id":"ActivityScheduleCard","data-headless-type-name":`${v}#${h}`,"data-headless-title-desc-button":`${e.title}##`,children:g(B,{asChild:!e?.link,href:e?.link?P(z(e.link,p),`${i}_${v}_${h}`):void 0,className:"size-full no-underline hover:text-current",children:[(s?e.activeIcon:e.inactiveIcon)&&t("div",{className:"laptop:w-[160px] aspect-1 absolute right-0 top-0 z-10 w-[120px]",children:t(L,{source:s?e.activeIcon.url:e.inactiveIcon.url,alt:s?e.activeIcon.alt:e.inactiveIcon.alt,className:"aspect-square"})}),g("div",{className:"relative z-20 flex h-full flex-col justify-between",children:[t(w,{as:"h3",size:3,html:e.title,className:n(f({state:l}))}),g("div",{className:"flex flex-col gap-1",children:[t("div",{className:"flex flex-col justify-end overflow-hidden",children:t(w,{as:"h4",size:2,html:e.subtitle,className:n(" line-clamp-2",f({state:l}))})}),r==="large"&&e.description&&t(I,{html:e.description,className:n("lg-desktop:text-[18px] desktop:text-[16px] line-clamp-3 text-[14px] leading-[1.4]",f({state:l}))})]})]})]})})});y.displayName="ActivityScheduleCard";const k=o.forwardRef(({classNames:e={},data:a,...d},r)=>{const s=o.useRef(null);o.useImperativeHandle(r,()=>s.current),T(s,{componentType:v,componentName:h,componentTitle:a.scheduleList?.[0]?.title||"",componentDescription:""});const p=a.theme||"light",m=a.size||"large",i=o.useMemo(()=>a?.scheduleList?.length||2,[a?.scheduleList]),l=o.useMemo(()=>{const c=N=>{switch(N){case"mobile":return{slidesPerView:1.17,spaceBetween:12};case"tablet":return i===2?{slidesPerView:2,spaceBetween:12}:{slidesPerView:2.4,spaceBetween:12};case"laptop":return i===2?{}:i===4?{slidesPerView:3.2,spaceBetween:16}:{slidesPerView:i,spaceBetween:16};case"desktop":return i===2?{slidesPerView:2,spaceBetween:16}:{slidesPerView:i,spaceBetween:16}}},u=c("mobile"),S=c("tablet"),b=c("laptop"),A=c("desktop");return{0:u,768:S,1024:b,1440:A}},[i]);return t(V,{ref:s,className:n(e?.root),childClassName:"overflow-hidden","data-ui-component-id":"ActivitySchedule",...d,children:t(E,{breakpoints:l,className:"w-full !overflow-visible",children:a.scheduleList.map((c,u)=>t($,{children:t(y,{item:c,theme:p,size:m,className:e?.card})},"activityScheduleCardItem"+u))})})});k.displayName="ActivitySchedule";var K=H(k);export{K as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|