@salla.sa/twilight-theme-engine 1.0.85 → 1.0.87
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/README.md +4 -3
- package/bin/twilight-check-manifest.mjs +16 -0
- package/dist/{AddToCartForm-B5C2M4OZ.js → AddToCartForm-P644O2QL.js} +4 -4
- package/dist/{AddToCartForm-B5C2M4OZ.js.map → AddToCartForm-P644O2QL.js.map} +1 -1
- package/dist/{BlogAuthorPage-GTF4UGSS.js → BlogAuthorPage-VWSO6MPY.js} +13 -11
- package/dist/BlogAuthorPage-VWSO6MPY.js.map +1 -0
- package/dist/{BlogCategoryPage-TN7Y4NBP.js → BlogCategoryPage-K2KSQ6T6.js} +13 -11
- package/dist/BlogCategoryPage-K2KSQ6T6.js.map +1 -0
- package/dist/{BlogPage-TDB3M3PI.js → BlogPage-XRM7VWOZ.js} +12 -10
- package/dist/BlogPage-XRM7VWOZ.js.map +1 -0
- package/dist/{BlogSinglePage-4A52Q5QW.js → BlogSinglePage-XIAXT54H.js} +12 -10
- package/dist/BlogSinglePage-XIAXT54H.js.map +1 -0
- package/dist/{BlogTagPage-TOVPBETA.js → BlogTagPage-IHOA267V.js} +13 -11
- package/dist/BlogTagPage-IHOA267V.js.map +1 -0
- package/dist/{BrandsPage-VUDGYSQI.js → BrandsPage-ZFEILRT3.js} +12 -10
- package/dist/BrandsPage-ZFEILRT3.js.map +1 -0
- package/dist/{Breadcrumb-CI3SN5YR.js → Breadcrumb-CVSISL2K.js} +12 -10
- package/dist/Breadcrumb-CVSISL2K.js.map +1 -0
- package/dist/{CartItem-BHLEURAB.js → CartItem-EOI7P3JA.js} +12 -10
- package/dist/CartItem-EOI7P3JA.js.map +1 -0
- package/dist/{CartSummary-QERVESYN.js → CartSummary-RZGUBDKJ.js} +12 -10
- package/dist/CartSummary-RZGUBDKJ.js.map +1 -0
- package/dist/{Copyright-RL6ALKRC.js → Copyright-5BLYSP24.js} +4 -4
- package/dist/{Copyright-RL6ALKRC.js.map → Copyright-5BLYSP24.js.map} +1 -1
- package/dist/{CustomerLayout-VRZUWGQK.js → CustomerLayout-6F4BJAMU.js} +12 -10
- package/dist/CustomerLayout-6F4BJAMU.js.map +1 -0
- package/dist/{Footer-ZWBZCMDL.js → Footer-NF2NLDLR.js} +6 -6
- package/dist/{Footer-ZWBZCMDL.js.map → Footer-NF2NLDLR.js.map} +1 -1
- package/dist/{Header-WNK4O66B.js → Header-6DQJ5X7J.js} +9 -7
- package/dist/{Header-WNK4O66B.js.map → Header-6DQJ5X7J.js.map} +1 -1
- package/dist/{LoyaltyPage-CGTHWJ76.js → LoyaltyPage-YHWHIWCS.js} +12 -10
- package/dist/LoyaltyPage-YHWHIWCS.js.map +1 -0
- package/dist/{LoyaltyPointsPage-QSU6K3PW.js → LoyaltyPointsPage-T6K3H5A5.js} +10 -3
- package/dist/LoyaltyPointsPage-T6K3H5A5.js.map +1 -0
- package/dist/{MainMenu-V3T7F32R.js → MainMenu-Y2TAM7DK.js} +4 -4
- package/dist/{MainMenu-V3T7F32R.js.map → MainMenu-Y2TAM7DK.js.map} +1 -1
- package/dist/{MasterLayout-XQF644LD.js → MasterLayout-GBEEFFPG.js} +12 -10
- package/dist/{MasterLayout-XQF644LD.js.map → MasterLayout-GBEEFFPG.js.map} +1 -1
- package/dist/{MobileMenu-U4BVQYKH.js → MobileMenu-RE5XVGZL.js} +12 -10
- package/dist/MobileMenu-RE5XVGZL.js.map +1 -0
- package/dist/{NotificationsPage-ZRRQY7TF.js → NotificationsPage-QAFWZAS3.js} +12 -10
- package/dist/NotificationsPage-QAFWZAS3.js.map +1 -0
- package/dist/{OrderSinglePage-O3XYVMG5.js → OrderSinglePage-T4PRXTKG.js} +12 -10
- package/dist/OrderSinglePage-T4PRXTKG.js.map +1 -0
- package/dist/{OrdersPage-CMXZF5MI.js → OrdersPage-3S6ZS56E.js} +12 -10
- package/dist/OrdersPage-3S6ZS56E.js.map +1 -0
- package/dist/{PageSingle-IIG2US43.js → PageSingle-W3UTXDOW.js} +4 -4
- package/dist/{PageSingle-IIG2US43.js.map → PageSingle-W3UTXDOW.js.map} +1 -1
- package/dist/{ProductDetails-65GDABI7.js → ProductDetails-X5A7TG3F.js} +14 -7
- package/dist/ProductDetails-X5A7TG3F.js.map +1 -0
- package/dist/{ProfilePage-SNJ4WXU4.js → ProfilePage-DUH3AILJ.js} +12 -10
- package/dist/ProfilePage-DUH3AILJ.js.map +1 -0
- package/dist/{ReviewsPage-UT7UT55J.js → ReviewsPage-2C2P7VS3.js} +4 -4
- package/dist/{ReviewsPage-UT7UT55J.js.map → ReviewsPage-2C2P7VS3.js.map} +1 -1
- package/dist/{SeoCartWidget-DBJAXJKT.js → SeoCartWidget-VYLGEW2I.js} +12 -10
- package/dist/SeoCartWidget-VYLGEW2I.js.map +1 -0
- package/dist/{SettingsPage-FLTIOPU5.js → SettingsPage-OZJEW6CW.js} +12 -10
- package/dist/SettingsPage-OZJEW6CW.js.map +1 -0
- package/dist/{StoreClosedNotification-ZT3QKDKS.js → StoreClosedNotification-QHIZBNXO.js} +13 -11
- package/dist/{StoreClosedNotification-ZT3QKDKS.js.map → StoreClosedNotification-QHIZBNXO.js.map} +1 -1
- package/dist/{TestimonialsPage-CU7HKU4O.js → TestimonialsPage-K6WJKKME.js} +4 -4
- package/dist/{TestimonialsPage-CU7HKU4O.js.map → TestimonialsPage-K6WJKKME.js.map} +1 -1
- package/dist/{ThankYouPage-5X6B4X3T.js → ThankYouPage-H6QQEI5R.js} +12 -10
- package/dist/ThankYouPage-H6QQEI5R.js.map +1 -0
- package/dist/{WalletPage-H2BKIDPA.js → WalletPage-G5IBGN6B.js} +12 -10
- package/dist/WalletPage-G5IBGN6B.js.map +1 -0
- package/dist/{WishlistPage-RS5UCIQ3.js → WishlistPage-AIOTAB6L.js} +12 -10
- package/dist/WishlistPage-AIOTAB6L.js.map +1 -0
- package/dist/api/advertisement.d.ts +33 -0
- package/dist/api/advertisement.d.ts.map +1 -0
- package/dist/api/advertisement.js +8 -0
- package/dist/api/advertisement.js.map +1 -0
- package/dist/boot/critical-style.d.ts +3 -0
- package/dist/boot/critical-style.d.ts.map +1 -0
- package/dist/boot/index.d.ts +15 -0
- package/dist/boot/index.d.ts.map +1 -0
- package/dist/boot.d.ts +1 -0
- package/dist/boot.js +69 -0
- package/dist/boot.js.map +1 -0
- package/dist/chunk-4FJGZQD3.js +6 -0
- package/dist/chunk-4FJGZQD3.js.map +1 -0
- package/dist/{chunk-SDFDS4Q3.js → chunk-BCJTF3V7.js} +20 -4
- package/dist/chunk-BCJTF3V7.js.map +1 -0
- package/dist/chunk-DBW7XXNE.js +103 -0
- package/dist/chunk-DBW7XXNE.js.map +1 -0
- package/dist/{chunk-22SH7OVF.js → chunk-E7WWO3V3.js} +3 -3
- package/dist/{chunk-22SH7OVF.js.map → chunk-E7WWO3V3.js.map} +1 -1
- package/dist/{chunk-SE5JYWOK.js → chunk-EZHXVHXY.js} +4 -4
- package/dist/{chunk-SE5JYWOK.js.map → chunk-EZHXVHXY.js.map} +1 -1
- package/dist/{chunk-JO7JWV34.js → chunk-FWYKOQV5.js} +5 -5
- package/dist/chunk-FWYKOQV5.js.map +1 -0
- package/dist/{chunk-JRNH3FUF.js → chunk-FYHF62KI.js} +4 -4
- package/dist/{chunk-JRNH3FUF.js.map → chunk-FYHF62KI.js.map} +1 -1
- package/dist/{chunk-UJKFBZFJ.js → chunk-GJ5IMPNY.js} +7 -7
- package/dist/{chunk-UJKFBZFJ.js.map → chunk-GJ5IMPNY.js.map} +1 -1
- package/dist/chunk-IVBOLREE.js +29 -0
- package/dist/chunk-IVBOLREE.js.map +1 -0
- package/dist/chunk-LWPKBVIE.js +14 -0
- package/dist/{chunk-7WAXN2PP.js.map → chunk-LWPKBVIE.js.map} +1 -1
- package/dist/{chunk-SX5MF2YA.js → chunk-N3BCZIGS.js} +4 -4
- package/dist/{chunk-SX5MF2YA.js.map → chunk-N3BCZIGS.js.map} +1 -1
- package/dist/{chunk-NZVR4OF7.js → chunk-NXQZ4RLM.js} +8 -8
- package/dist/chunk-NXQZ4RLM.js.map +1 -0
- package/dist/{chunk-NXQJA7D3.js → chunk-PCURRKIH.js} +3 -3
- package/dist/{chunk-NXQJA7D3.js.map → chunk-PCURRKIH.js.map} +1 -1
- package/dist/{chunk-4CZRUAZB.js → chunk-PU2LHFDQ.js} +10 -11
- package/dist/chunk-PU2LHFDQ.js.map +1 -0
- package/dist/{chunk-OWX2CPNQ.js → chunk-UQIVX4YA.js} +3 -3
- package/dist/{chunk-OWX2CPNQ.js.map → chunk-UQIVX4YA.js.map} +1 -1
- package/dist/chunk-X5NK4TZH.js +228 -0
- package/dist/chunk-X5NK4TZH.js.map +1 -0
- package/dist/{chunk-6SWDSRIL.js → chunk-XKNXYQ2K.js} +6 -6
- package/dist/{chunk-6SWDSRIL.js.map → chunk-XKNXYQ2K.js.map} +1 -1
- package/dist/{chunk-KHBSGD2D.js → chunk-XO7B3VWS.js} +3 -3
- package/dist/{chunk-KHBSGD2D.js.map → chunk-XO7B3VWS.js.map} +1 -1
- package/dist/cli/check-manifest.d.ts +10 -0
- package/dist/cli/check-manifest.d.ts.map +1 -0
- package/dist/cli/check-manifest.js +44 -0
- package/dist/cli/check-manifest.js.map +1 -0
- package/dist/components/cart/index.js +1 -1
- package/dist/components/common/index.js +2 -2
- package/dist/components/drawer/index.js +10 -8
- package/dist/components/home/index.js +12 -10
- package/dist/components/layout/Footer.d.ts.map +1 -1
- package/dist/components/layout/MasterLayout.d.ts.map +1 -1
- package/dist/components/layout/PageAdvertisements.d.ts +7 -0
- package/dist/components/layout/PageAdvertisements.d.ts.map +1 -0
- package/dist/components/layout/index.d.ts +1 -0
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/components/layout/index.js +8 -1
- package/dist/components/product/index.js +11 -9
- package/dist/components/store/index.js +12 -10
- package/dist/components/store/index.js.map +1 -1
- package/dist/{document-class-67HTP45G.js → document-class-FRL7JHWD.js} +6 -5
- package/dist/{document-class-67HTP45G.js.map → document-class-FRL7JHWD.js.map} +1 -1
- package/dist/hooks/index.js +10 -8
- package/dist/hooks/useGtm.js +10 -8
- package/dist/hooks/useMoney.js +10 -8
- package/dist/hooks/useStore.js +10 -8
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/{not-found-QTHBFPNT.js → not-found-E6AR4CZ4.js} +12 -10
- package/dist/not-found-E6AR4CZ4.js.map +1 -0
- package/dist/providers/index.js +10 -8
- package/dist/routes/account/orders.js +1 -1
- package/dist/routes/account.js +6 -6
- package/dist/routes/blog.js +5 -5
- package/dist/routes/brands.js +1 -1
- package/dist/routes/cart.js +14 -12
- package/dist/routes/cart.js.map +1 -1
- package/dist/routes/home.js +13 -11
- package/dist/routes/loyalty.js +2 -2
- package/dist/routes/page.js +1 -1
- package/dist/routes/product-listing.js +12 -10
- package/dist/routes/product-listing.js.map +1 -1
- package/dist/routes/product.js +12 -10
- package/dist/routes/product.js.map +1 -1
- package/dist/routes/root/beforeLoad.d.ts +2 -2
- package/dist/routes/root/beforeLoad.d.ts.map +1 -1
- package/dist/routes/root/head.d.ts.map +1 -1
- package/dist/routes/testimonials.js +2 -2
- package/dist/routes/thank-you.js +1 -1
- package/dist/skeleton.js +13 -11
- package/dist/tanstack/document-class.d.ts.map +1 -1
- package/dist/tanstack/index.d.ts +1 -0
- package/dist/tanstack/index.d.ts.map +1 -1
- package/dist/tanstack/stylesheet.d.ts +15 -0
- package/dist/tanstack/stylesheet.d.ts.map +1 -0
- package/dist/tanstack.js +33 -4
- package/dist/tanstack.js.map +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +14 -25
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugins/twilight-manifest.d.ts +23 -0
- package/dist/vite/plugins/twilight-manifest.d.ts.map +1 -1
- package/dist/vite/plugins/twilight-schema.plugin.d.ts.map +1 -1
- package/package.json +16 -3
- package/tailwind/components/Component.tsx.txt +21 -0
- package/tailwind/components/ComponentRegistry.ts.txt +66 -0
- package/tailwind/components/cart/CartItem.tsx.txt +211 -0
- package/tailwind/components/cart/CartSummary.tsx.txt +269 -0
- package/tailwind/components/cart/PreOrderNotification.tsx.txt +16 -0
- package/tailwind/components/cart/PriceQuoteButton.tsx.txt +21 -0
- package/tailwind/components/cart/SeoCartWidget.tsx.txt +99 -0
- package/tailwind/components/cart/index.ts.txt +11 -0
- package/tailwind/components/cart/lazy.ts.txt +15 -0
- package/tailwind/components/collapse/Collapse.tsx.txt +95 -0
- package/tailwind/components/collapse/index.ts.txt +41 -0
- package/tailwind/components/common/Breadcrumb.tsx.txt +27 -0
- package/tailwind/components/common/BreadcrumbJsonLd.tsx.txt +40 -0
- package/tailwind/components/common/BreadcrumbTrail.tsx.txt +97 -0
- package/tailwind/components/common/CurrencySymbol.tsx.txt +8 -0
- package/tailwind/components/common/DeferredData.tsx.txt +122 -0
- package/tailwind/components/common/ErrorPage.tsx.txt +69 -0
- package/tailwind/components/common/Image.tsx.txt +119 -0
- package/tailwind/components/common/Link.tsx.txt +36 -0
- package/tailwind/components/common/Link.types.ts.txt +85 -0
- package/tailwind/components/common/NoContent.tsx.txt +27 -0
- package/tailwind/components/common/RenderWhenVisible.tsx.txt +92 -0
- package/tailwind/components/common/index.ts.txt +42 -0
- package/tailwind/components/common/lazy.ts.txt +28 -0
- package/tailwind/components/defineComponent.ts.txt +32 -0
- package/tailwind/components/drawer/Drawer.tsx.txt +219 -0
- package/tailwind/components/drawer/index.ts.txt +38 -0
- package/tailwind/components/dropdown/Dropdown.tsx.txt +166 -0
- package/tailwind/components/dropdown/index.ts.txt +40 -0
- package/tailwind/components/home/BundleComponent.tsx.txt +35 -0
- package/tailwind/components/home/ComponentErrorBoundary.tsx.txt +98 -0
- package/tailwind/components/home/FeaturedProductsStyle1.tsx.txt +125 -0
- package/tailwind/components/home/FeaturedProductsStyle2.tsx.txt +127 -0
- package/tailwind/components/home/FeaturedProductsStyle3.tsx.txt +71 -0
- package/tailwind/components/home/FixedBanner.tsx.txt +68 -0
- package/tailwind/components/home/FixedProducts.tsx.txt +72 -0
- package/tailwind/components/home/HomePageRenderer.tsx.txt +284 -0
- package/tailwind/components/home/PageBlocks.tsx.txt +24 -0
- package/tailwind/components/home/ParallaxBackground.tsx.txt +50 -0
- package/tailwind/components/home/PhotosSlider.tsx.txt +61 -0
- package/tailwind/components/home/ProductsSlider.tsx.txt +87 -0
- package/tailwind/components/home/ReorderProducts.tsx.txt +38 -0
- package/tailwind/components/home/SquarePhotos.tsx.txt +68 -0
- package/tailwind/components/home/StoreFeatures.tsx.txt +34 -0
- package/tailwind/components/home/Testimonials.tsx.txt +36 -0
- package/tailwind/components/home/Youtube.tsx.txt +48 -0
- package/tailwind/components/home/index.ts.txt +50 -0
- package/tailwind/components/home/lazy.ts.txt +17 -0
- package/tailwind/components/home/register.ts.txt +44 -0
- package/tailwind/components/home/reorder-hooks.ts.txt +52 -0
- package/tailwind/components/home/types.ts.txt +4 -0
- package/tailwind/components/layout/Copyright.tsx.txt +23 -0
- package/tailwind/components/layout/CustomerLayout.tsx.txt +91 -0
- package/tailwind/components/layout/Footer.tsx.txt +341 -0
- package/tailwind/components/layout/Header.tsx.txt +154 -0
- package/tailwind/components/layout/MasterLayout.tsx.txt +62 -0
- package/tailwind/components/layout/PageAdvertisements.tsx.txt +131 -0
- package/tailwind/components/layout/WidgetHead.tsx.txt +53 -0
- package/tailwind/components/layout/index.ts.txt +27 -0
- package/tailwind/components/layout/lazy.ts.txt +25 -0
- package/tailwind/components/layout/types.ts.txt +11 -0
- package/tailwind/components/modal/ImageModal.tsx.txt +70 -0
- package/tailwind/components/modal/Modal.tsx.txt +245 -0
- package/tailwind/components/modal/index.ts.txt +39 -0
- package/tailwind/components/modal/lazy.ts.txt +10 -0
- package/tailwind/components/navigation/MainMenu.tsx.txt +94 -0
- package/tailwind/components/navigation/MobileMenu.tsx.txt +160 -0
- package/tailwind/components/navigation/index.ts.txt +4 -0
- package/tailwind/components/navigation/lazy.ts.txt +11 -0
- package/tailwind/components/product/AddToCartForm.tsx.txt +365 -0
- package/tailwind/components/product/ProductCard.tsx.txt +305 -0
- package/tailwind/components/product/ProductDetails.tsx.txt +267 -0
- package/tailwind/components/product/ProductGallery.tsx.txt +234 -0
- package/tailwind/components/product/index.ts.txt +15 -0
- package/tailwind/components/product/lazy.ts.txt +9 -0
- package/tailwind/components/snippets/AppsSnippets.tsx.txt +225 -0
- package/tailwind/components/snippets/SallaSdkScripts.tsx.txt +14 -0
- package/tailwind/components/snippets/index.ts.txt +4 -0
- package/tailwind/components/store/StoreClosedNotification.tsx.txt +73 -0
- package/tailwind/components/store/index.ts.txt +8 -0
- package/tailwind/components/store/lazy.ts.txt +8 -0
- package/tailwind/components/toast/Toaster.tsx.txt +177 -0
- package/tailwind/components/toast/index.ts.txt +10 -0
- package/tailwind/components/toast/types.ts.txt +38 -0
- package/tailwind/components/toast/useToast.ts.txt +61 -0
- package/tailwind/components/tracking/GoogleTag.tsx.txt +77 -0
- package/tailwind/components/tracking/SiftSnippet.tsx.txt +49 -0
- package/tailwind/components/tracking/TwilightBundles.tsx.txt +67 -0
- package/tailwind/components/tracking/index.ts.txt +11 -0
- package/tailwind/components/tracking/lazy.ts.txt +11 -0
- package/tailwind/components/useComponent.ts.txt +12 -0
- package/tailwind/routes/account/index.tsx.txt +16 -0
- package/tailwind/routes/account/notifications/NotificationsPage.tsx.txt +54 -0
- package/tailwind/routes/account/notifications/index.tsx.txt +39 -0
- package/tailwind/routes/account/notifications/loader.ts.txt +22 -0
- package/tailwind/routes/account/notifications/types.ts.txt +18 -0
- package/tailwind/routes/account/orders/OrderSinglePage.tsx.txt +181 -0
- package/tailwind/routes/account/orders/OrdersPage.tsx.txt +28 -0
- package/tailwind/routes/account/orders/index.tsx.txt +86 -0
- package/tailwind/routes/account/orders/loader.ts.txt +66 -0
- package/tailwind/routes/account/orders/single/OrderActions.tsx.txt +197 -0
- package/tailwind/routes/account/orders/single/OrderHeader.tsx.txt +143 -0
- package/tailwind/routes/account/orders/single/OrderItemRow.tsx.txt +209 -0
- package/tailwind/routes/account/orders/single/OrderSections.tsx.txt +215 -0
- package/tailwind/routes/account/orders/single/types.ts.txt +38 -0
- package/tailwind/routes/account/orders/types.ts.txt +29 -0
- package/tailwind/routes/account/profile/ProfilePage.tsx.txt +30 -0
- package/tailwind/routes/account/profile/index.tsx.txt +39 -0
- package/tailwind/routes/account/profile/loader.ts.txt +16 -0
- package/tailwind/routes/account/profile/types.ts.txt +5 -0
- package/tailwind/routes/account/settings/SettingsPage.tsx.txt +13 -0
- package/tailwind/routes/account/settings/index.tsx.txt +39 -0
- package/tailwind/routes/account/settings/loader.ts.txt +13 -0
- package/tailwind/routes/account/settings/types.ts.txt +5 -0
- package/tailwind/routes/account/types.ts.txt +320 -0
- package/tailwind/routes/account/wallet/WalletPage.tsx.txt +195 -0
- package/tailwind/routes/account/wallet/index.tsx.txt +38 -0
- package/tailwind/routes/account/wallet/loader.ts.txt +27 -0
- package/tailwind/routes/account/wallet/types.ts.txt +11 -0
- package/tailwind/routes/account/wishlist/WishlistPage.tsx.txt +314 -0
- package/tailwind/routes/account/wishlist/WishlistShare.tsx.txt +248 -0
- package/tailwind/routes/account/wishlist/index.tsx.txt +40 -0
- package/tailwind/routes/account/wishlist/loader.ts.txt +26 -0
- package/tailwind/routes/account/wishlist/types.ts.txt +9 -0
- package/tailwind/routes/blog/BlogAuthorPage.tsx.txt +82 -0
- package/tailwind/routes/blog/BlogCategoryPage.tsx.txt +84 -0
- package/tailwind/routes/blog/BlogPage.tsx.txt +191 -0
- package/tailwind/routes/blog/BlogSinglePage.tsx.txt +168 -0
- package/tailwind/routes/blog/BlogTagPage.tsx.txt +84 -0
- package/tailwind/routes/blog/BlogTags.tsx.txt +54 -0
- package/tailwind/routes/blog/components.tsx.txt +87 -0
- package/tailwind/routes/blog/index.tsx.txt +238 -0
- package/tailwind/routes/blog/loader.ts.txt +173 -0
- package/tailwind/routes/blog/types.ts.txt +106 -0
- package/tailwind/routes/brands/BrandsPage.tsx.txt +179 -0
- package/tailwind/routes/brands/index.tsx.txt +47 -0
- package/tailwind/routes/brands/loader.ts.txt +14 -0
- package/tailwind/routes/brands/types.ts.txt +53 -0
- package/tailwind/routes/cart/CartPage.tsx.txt +112 -0
- package/tailwind/routes/cart/index.tsx.txt +39 -0
- package/tailwind/routes/cart/loader.ts.txt +15 -0
- package/tailwind/routes/cart/types.ts.txt +6 -0
- package/tailwind/routes/home/HomePage.tsx.txt +53 -0
- package/tailwind/routes/home/index.tsx.txt +56 -0
- package/tailwind/routes/home/loader.ts.txt +24 -0
- package/tailwind/routes/home/types.ts.txt +11 -0
- package/tailwind/routes/index.ts.txt +94 -0
- package/tailwind/routes/lazy.ts.txt +105 -0
- package/tailwind/routes/loyalty/LoyaltyPage.tsx.txt +17 -0
- package/tailwind/routes/loyalty/LoyaltyPointsPage.tsx.txt +11 -0
- package/tailwind/routes/loyalty/index.tsx.txt +81 -0
- package/tailwind/routes/loyalty/loader.ts.txt +53 -0
- package/tailwind/routes/loyalty/types.ts.txt +109 -0
- package/tailwind/routes/not-found.tsx.txt +50 -0
- package/tailwind/routes/page/PageSingle.tsx.txt +34 -0
- package/tailwind/routes/page/index.tsx.txt +60 -0
- package/tailwind/routes/page/loader.ts.txt +19 -0
- package/tailwind/routes/page/types.ts.txt +34 -0
- package/tailwind/routes/product/ProductPage.tsx.txt +77 -0
- package/tailwind/routes/product/index.tsx.txt +157 -0
- package/tailwind/routes/product/loader.ts.txt +35 -0
- package/tailwind/routes/product/types.ts.txt +6 -0
- package/tailwind/routes/product-listing/ProductListPage.tsx.txt +321 -0
- package/tailwind/routes/product-listing/index.tsx.txt +95 -0
- package/tailwind/routes/product-listing/loader.ts.txt +323 -0
- package/tailwind/routes/product-listing/types.ts.txt +96 -0
- package/tailwind/routes/product-listing/useAppliedFilters.ts.txt +130 -0
- package/tailwind/routes/product-short-link.ts.txt +104 -0
- package/tailwind/routes/root/beforeLoad.ts.txt +354 -0
- package/tailwind/routes/root/head.ts.txt +424 -0
- package/tailwind/routes/root/index.ts.txt +2 -0
- package/tailwind/routes/seo-redirects.ts.txt +82 -0
- package/tailwind/routes/testimonials/ReviewsPage.tsx.txt +12 -0
- package/tailwind/routes/testimonials/TestimonialsPage.tsx.txt +80 -0
- package/tailwind/routes/testimonials/index.tsx.txt +80 -0
- package/tailwind/routes/testimonials/loader.ts.txt +29 -0
- package/tailwind/routes/testimonials/types.ts.txt +9 -0
- package/tailwind/routes/thank-you/ThankYouPage.tsx.txt +241 -0
- package/tailwind/routes/thank-you/index.tsx.txt +49 -0
- package/tailwind/routes/thank-you/loader.ts.txt +40 -0
- package/tailwind/routes/thank-you/types.ts.txt +16 -0
- package/tailwind/routes/types.ts.txt +41 -0
- package/dist/BlogAuthorPage-GTF4UGSS.js.map +0 -1
- package/dist/BlogCategoryPage-TN7Y4NBP.js.map +0 -1
- package/dist/BlogPage-TDB3M3PI.js.map +0 -1
- package/dist/BlogSinglePage-4A52Q5QW.js.map +0 -1
- package/dist/BlogTagPage-TOVPBETA.js.map +0 -1
- package/dist/BrandsPage-VUDGYSQI.js.map +0 -1
- package/dist/Breadcrumb-CI3SN5YR.js.map +0 -1
- package/dist/CartItem-BHLEURAB.js.map +0 -1
- package/dist/CartSummary-QERVESYN.js.map +0 -1
- package/dist/CustomerLayout-VRZUWGQK.js.map +0 -1
- package/dist/LoyaltyPage-CGTHWJ76.js.map +0 -1
- package/dist/LoyaltyPointsPage-QSU6K3PW.js.map +0 -1
- package/dist/MobileMenu-U4BVQYKH.js.map +0 -1
- package/dist/NotificationsPage-ZRRQY7TF.js.map +0 -1
- package/dist/OrderSinglePage-O3XYVMG5.js.map +0 -1
- package/dist/OrdersPage-CMXZF5MI.js.map +0 -1
- package/dist/ProductDetails-65GDABI7.js.map +0 -1
- package/dist/ProfilePage-SNJ4WXU4.js.map +0 -1
- package/dist/SeoCartWidget-DBJAXJKT.js.map +0 -1
- package/dist/SettingsPage-FLTIOPU5.js.map +0 -1
- package/dist/ThankYouPage-5X6B4X3T.js.map +0 -1
- package/dist/WalletPage-H2BKIDPA.js.map +0 -1
- package/dist/WishlistPage-RS5UCIQ3.js.map +0 -1
- package/dist/chunk-4CZRUAZB.js.map +0 -1
- package/dist/chunk-7WAXN2PP.js +0 -14
- package/dist/chunk-JO7JWV34.js.map +0 -1
- package/dist/chunk-NZVR4OF7.js.map +0 -1
- package/dist/chunk-SDFDS4Q3.js.map +0 -1
- package/dist/not-found-QTHBFPNT.js.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { WalletPageProps } from './types';
|
|
2
|
+
import type { LoaderContext } from '../../types';
|
|
3
|
+
import { wallet } from '../../../api/wallet';
|
|
4
|
+
import { getTwilightContext } from '../../../twilight/context';
|
|
5
|
+
import { orUnauthorized, unauthorized } from '../../../providers/NavigationProvider';
|
|
6
|
+
import { getAuthToken } from '../../../api/client';
|
|
7
|
+
import { RouteId } from '../../../router/route-ids';
|
|
8
|
+
|
|
9
|
+
export async function walletLoader(ctx: LoaderContext): Promise<WalletPageProps> {
|
|
10
|
+
if (!getAuthToken()) throw unauthorized();
|
|
11
|
+
const pageNum = Number(ctx.search?.page) || 1;
|
|
12
|
+
const data = await orUnauthorized(wallet.list({ page: pageNum }));
|
|
13
|
+
|
|
14
|
+
const i18n = getTwilightContext().i18n;
|
|
15
|
+
return {
|
|
16
|
+
page: {
|
|
17
|
+
title: i18n.t('common.titles.wallet') || 'Wallet',
|
|
18
|
+
slug: RouteId.CUSTOMER_WALLET,
|
|
19
|
+
},
|
|
20
|
+
query: { page: pageNum },
|
|
21
|
+
transactions: data.items,
|
|
22
|
+
balance: data.balance,
|
|
23
|
+
pagination: {
|
|
24
|
+
next: data.next,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Page } from '../../../types';
|
|
2
|
+
import type { RoutePagination, PageQuery } from '../../types';
|
|
3
|
+
import type { TransactionItem } from '../../../api/wallet';
|
|
4
|
+
|
|
5
|
+
export interface WalletPageProps {
|
|
6
|
+
page: Page;
|
|
7
|
+
query: PageQuery;
|
|
8
|
+
transactions: TransactionItem[];
|
|
9
|
+
balance: number;
|
|
10
|
+
pagination: RoutePagination;
|
|
11
|
+
}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
|
2
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { ItemsList } from '@salla.sa/twilight-components-react';
|
|
4
|
+
import { SallaAddProductButton } from '@salla.sa/twilight-components-react/add-product-button';
|
|
5
|
+
import { SallaButton } from '@salla.sa/twilight-components-react/button';
|
|
6
|
+
import { wishlist } from '../../../api/wishlist';
|
|
7
|
+
import type { Product } from '../../../types';
|
|
8
|
+
import { HookSlot, useWishlist, useMoney } from '../../../hooks';
|
|
9
|
+
import { useTranslation } from '../../../providers/I18nProvider';
|
|
10
|
+
import type { WishlistPageProps } from './types';
|
|
11
|
+
import { WishlistShareBar, useWishlistShare } from './WishlistShare';
|
|
12
|
+
import { NoContent, Image } from '../../../components/common';
|
|
13
|
+
import { useLocation } from '../../../providers/NavigationProvider';
|
|
14
|
+
import { onSallaEvent } from '../../../utils/sdk-helpers';
|
|
15
|
+
|
|
16
|
+
interface WishlistCardSelection {
|
|
17
|
+
/** "Share specific items" mode: the card shows a checkbox and toggles on click. */
|
|
18
|
+
selecting: boolean;
|
|
19
|
+
selected: boolean;
|
|
20
|
+
onToggle: (id: number) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// The loaded component copies host attributes (not properties) onto its inner salla-button.
|
|
24
|
+
const setAddButtonAttributes = (el: HTMLElement | null) => {
|
|
25
|
+
el?.setAttribute('loader-position', 'center');
|
|
26
|
+
el?.setAttribute('fill', 'outline');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const REMOVING_MS = 300;
|
|
30
|
+
|
|
31
|
+
const REMOVING_STYLE: CSSProperties = {
|
|
32
|
+
opacity: 0,
|
|
33
|
+
transform: 'scale(0.95)',
|
|
34
|
+
transition: `opacity ${REMOVING_MS}ms ease-in-out, transform ${REMOVING_MS}ms ease-in-out`,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function WishlistCard({
|
|
38
|
+
product: prod,
|
|
39
|
+
selection,
|
|
40
|
+
removing,
|
|
41
|
+
onRemoved,
|
|
42
|
+
}: {
|
|
43
|
+
product: Product;
|
|
44
|
+
selection?: WishlistCardSelection;
|
|
45
|
+
/** Fades the card out, then calls `onRemoved` once the fade ends. */
|
|
46
|
+
removing?: boolean;
|
|
47
|
+
onRemoved?: (id: number) => void;
|
|
48
|
+
}) {
|
|
49
|
+
const { remove } = useWishlist();
|
|
50
|
+
const { format } = useMoney();
|
|
51
|
+
|
|
52
|
+
// Drops the card even when `transitionend` never fires (hidden tab, overridden styles).
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!removing) return;
|
|
55
|
+
const timer = setTimeout(() => onRemoved?.(Number(prod.id)), REMOVING_MS + 50);
|
|
56
|
+
return () => clearTimeout(timer);
|
|
57
|
+
}, [removing, onRemoved, prod.id]);
|
|
58
|
+
|
|
59
|
+
const handleRemove = () => {
|
|
60
|
+
if (prod.id) {
|
|
61
|
+
remove(Number(prod.id));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const displayPrice = prod.sale_price ?? prod.price;
|
|
66
|
+
const regularPrice = prod.regular_price;
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
id={`wishlist-product-${prod.id}`}
|
|
71
|
+
className={`product-entry product-entry--wishlist${selection?.selected ? ' is-selected' : ''}`}
|
|
72
|
+
style={removing ? REMOVING_STYLE : undefined}
|
|
73
|
+
onTransitionEnd={(event) => {
|
|
74
|
+
if (removing && event.target === event.currentTarget && event.propertyName === 'opacity') {
|
|
75
|
+
onRemoved?.(Number(prod.id));
|
|
76
|
+
}
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
{selection?.selecting && (
|
|
80
|
+
<input
|
|
81
|
+
type="checkbox"
|
|
82
|
+
className="s-wishlist-select shrink-0 rtl:ml-4 ltr:mr-4"
|
|
83
|
+
aria-label={prod.name}
|
|
84
|
+
checked={selection.selected}
|
|
85
|
+
onChange={() => selection.onToggle(Number(prod.id))}
|
|
86
|
+
/>
|
|
87
|
+
)}
|
|
88
|
+
<div className="flex items-center mb-4 sm:mb-0">
|
|
89
|
+
<a href={prod.url} className="product-entry__image">
|
|
90
|
+
<Image
|
|
91
|
+
className="object-cover w-full h-full"
|
|
92
|
+
src={prod.image?.url}
|
|
93
|
+
alt={prod.image?.alt ?? prod.name}
|
|
94
|
+
aspectRatio="1/1"
|
|
95
|
+
/>
|
|
96
|
+
</a>
|
|
97
|
+
<div className="flex-1 rtl:pr-5 ltr:pl-5">
|
|
98
|
+
<h3 className="text-sm text-gray-800 leading-6 mb-1.5 rtl:pl-5 ltr:pr-5 rtl:md:pl-8 ltr:md:pr-8 line-clamp-1">
|
|
99
|
+
<a href={prod.url}>{prod.name}</a>
|
|
100
|
+
</h3>
|
|
101
|
+
<div className="w-full center-between">
|
|
102
|
+
{prod.is_on_sale && regularPrice ? (
|
|
103
|
+
<div className="space-x-1 rtl:space-x-reverse">
|
|
104
|
+
<h4 className="inline-block text-sm font-bold text-red-400">
|
|
105
|
+
{format(displayPrice)}
|
|
106
|
+
</h4>
|
|
107
|
+
<span className="text-sm text-gray-500 line-through">{format(regularPrice)}</span>
|
|
108
|
+
</div>
|
|
109
|
+
) : (
|
|
110
|
+
<h4 className="text-sm font-bold">{format(displayPrice)}</h4>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
<div className="flex items-center space-x-4 rtl:space-x-reverse">
|
|
116
|
+
<SallaAddProductButton
|
|
117
|
+
ref={setAddButtonAttributes}
|
|
118
|
+
productStatus={prod.status}
|
|
119
|
+
productId={prod.id}
|
|
120
|
+
productType={prod.type}
|
|
121
|
+
loaderPosition="center"
|
|
122
|
+
fill="outline"
|
|
123
|
+
className="flex-grow w-full sm:grow-0 md:w-40"
|
|
124
|
+
/>
|
|
125
|
+
<SallaButton
|
|
126
|
+
loaderPosition="center"
|
|
127
|
+
shape="icon"
|
|
128
|
+
size="small"
|
|
129
|
+
color="danger"
|
|
130
|
+
className="btn--delete"
|
|
131
|
+
onClick={handleRemove}
|
|
132
|
+
>
|
|
133
|
+
<i className="sicon-cancel" />
|
|
134
|
+
</SallaButton>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** The loaded wishlist pages, reloaded from the server once every loaded card is removed (like Twig). */
|
|
141
|
+
function useWishlistItems(
|
|
142
|
+
{ query, products, pagination }: WishlistPageProps,
|
|
143
|
+
onRemoved: (id: number) => void
|
|
144
|
+
) {
|
|
145
|
+
const queryClient = useQueryClient();
|
|
146
|
+
// Track the next page to load (starts at page 2 since page 1 is SSR)
|
|
147
|
+
const nextPageRef = useRef(query.page + 1);
|
|
148
|
+
const [removedIds, setRemovedIds] = useState<ReadonlySet<number>>(() => new Set());
|
|
149
|
+
const [removingIds, setRemovingIds] = useState<ReadonlySet<number>>(() => new Set());
|
|
150
|
+
const [reloaded, setReloaded] = useState<{
|
|
151
|
+
items: Product[];
|
|
152
|
+
next: string | null;
|
|
153
|
+
generation: number;
|
|
154
|
+
} | null>(null);
|
|
155
|
+
const loadedRef = useRef({
|
|
156
|
+
ids: products.map((prod) => Number(prod.id)),
|
|
157
|
+
hasMore: !!pagination?.next,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// A `?page=` navigation keeps this instance, so drop what the previous page removed or reloaded.
|
|
161
|
+
const [loadedProducts, setLoadedProducts] = useState(products);
|
|
162
|
+
if (loadedProducts !== products) {
|
|
163
|
+
setLoadedProducts(products);
|
|
164
|
+
setRemovedIds(new Set());
|
|
165
|
+
setRemovingIds(new Set());
|
|
166
|
+
setReloaded(null);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
nextPageRef.current = query.page + 1;
|
|
171
|
+
loadedRef.current = {
|
|
172
|
+
ids: products.map((prod) => Number(prod.id)),
|
|
173
|
+
hasMore: !!pagination?.next,
|
|
174
|
+
};
|
|
175
|
+
}, [products, query.page, pagination?.next]);
|
|
176
|
+
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
const handleRemoved = (_response: unknown, id: unknown) => {
|
|
179
|
+
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
180
|
+
(reduceMotion ? setRemovedIds : setRemovingIds)((current) =>
|
|
181
|
+
new Set(current).add(Number(id))
|
|
182
|
+
);
|
|
183
|
+
onRemoved(Number(id));
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
return onSallaEvent('wishlist::removed', handleRemoved);
|
|
187
|
+
}, [onRemoved]);
|
|
188
|
+
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
const { ids, hasMore } = loadedRef.current;
|
|
191
|
+
if (!ids.length || !ids.every((id) => removedIds.has(id))) return;
|
|
192
|
+
|
|
193
|
+
const reset = (items: Product[], next: string | null) => {
|
|
194
|
+
nextPageRef.current = query.page + 1;
|
|
195
|
+
loadedRef.current = { ids: items.map((prod) => Number(prod.id)), hasMore: !!next };
|
|
196
|
+
setRemovedIds(new Set());
|
|
197
|
+
setRemovingIds(new Set());
|
|
198
|
+
setReloaded((current) => ({ items, next, generation: (current?.generation ?? 0) + 1 }));
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
if (!hasMore) {
|
|
202
|
+
reset([], null);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let cancelled = false;
|
|
207
|
+
queryClient
|
|
208
|
+
.fetchQuery({ ...wishlist.queries.list({ page: query.page }), staleTime: 0 })
|
|
209
|
+
.then((result) => {
|
|
210
|
+
if (!cancelled) reset(result.items, result.next);
|
|
211
|
+
})
|
|
212
|
+
// A failed reload keeps the list as it is; later pages still load on scroll.
|
|
213
|
+
.catch(() => undefined);
|
|
214
|
+
return () => {
|
|
215
|
+
cancelled = true;
|
|
216
|
+
};
|
|
217
|
+
}, [removedIds, query.page, products, queryClient]);
|
|
218
|
+
|
|
219
|
+
const loader = async () => {
|
|
220
|
+
const pageToLoad = nextPageRef.current;
|
|
221
|
+
const result = await wishlist.list({ page: pageToLoad });
|
|
222
|
+
|
|
223
|
+
nextPageRef.current = pageToLoad + 1;
|
|
224
|
+
loadedRef.current = {
|
|
225
|
+
ids: [...loadedRef.current.ids, ...result.items.map((prod) => Number(prod.id))],
|
|
226
|
+
hasMore: !!result.next,
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
return {
|
|
230
|
+
items: result.items,
|
|
231
|
+
next: result.next,
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const finishRemoving = useCallback((id: number) => {
|
|
236
|
+
setRemovedIds((current) => (current.has(id) ? current : new Set(current).add(id)));
|
|
237
|
+
}, []);
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
items: reloaded ? reloaded.items : products,
|
|
241
|
+
next: reloaded ? reloaded.next : pagination?.next,
|
|
242
|
+
generation: reloaded?.generation ?? 0,
|
|
243
|
+
removedIds,
|
|
244
|
+
removingIds,
|
|
245
|
+
finishRemoving,
|
|
246
|
+
loader,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function WishlistPage(props: WishlistPageProps) {
|
|
251
|
+
const { t } = useTranslation();
|
|
252
|
+
const { pathname, searchStr } = useLocation();
|
|
253
|
+
const shareState = useWishlistShare();
|
|
254
|
+
const selectedIdSet = useMemo(() => new Set(shareState.selectedIds), [shareState.selectedIds]);
|
|
255
|
+
const { items, next, generation, removedIds, removingIds, finishRemoving, loader } =
|
|
256
|
+
useWishlistItems(props, shareState.deselect);
|
|
257
|
+
const hasRemaining = items.some((prod) => !removedIds.has(Number(prod.id)));
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
<div className="space-y-5" id="wishlist">
|
|
261
|
+
{/* The SDK unconditionally auto-renders its own `<salla-wishlist-actions>` into this
|
|
262
|
+
slot on every `customer.wishlist` page (tools/twilight's init-static-sections.js),
|
|
263
|
+
but that widget only works alongside a sibling `<salla-products-list>` web
|
|
264
|
+
component -- this page renders its products via the React-native `ItemsList`
|
|
265
|
+
instead, so the SDK's widget never finds one and sits permanently disabled.
|
|
266
|
+
`WishlistShareBar` below is this page's own, fully working replacement for the
|
|
267
|
+
exact same "Share" feature. The slot itself stays (removing it would also drop
|
|
268
|
+
whatever themes/apps register here via the hook registry, not just this widget);
|
|
269
|
+
`#wishlist > salla-wishlist-actions` (user-pages.scss) hides just the dead
|
|
270
|
+
SDK widget, which the SDK always inserts as this element's first child. */}
|
|
271
|
+
<HookSlot name="customer:wishlist.items.start" />
|
|
272
|
+
<WishlistShareBar state={shareState} hasProducts={hasRemaining || !!next} />
|
|
273
|
+
<ItemsList<Product>
|
|
274
|
+
key={generation}
|
|
275
|
+
items={items}
|
|
276
|
+
loader={loader}
|
|
277
|
+
mode={next ? 'infinite' : 'static'}
|
|
278
|
+
pageUrl={pathname + searchStr}
|
|
279
|
+
className="s-products-list"
|
|
280
|
+
itemsClassName="s-products-list-wrapper s-products-list-row-cards"
|
|
281
|
+
empty={
|
|
282
|
+
<div className="text-center py-16">
|
|
283
|
+
<NoContent
|
|
284
|
+
icon="sicon-heart"
|
|
285
|
+
message={t('common.errors.no_wishlist', "You don't have any wishes")}
|
|
286
|
+
actionLabel={t('pages.offer.continue_shopping', 'Continue shopping')}
|
|
287
|
+
actionUrl="/"
|
|
288
|
+
/>
|
|
289
|
+
</div>
|
|
290
|
+
}
|
|
291
|
+
t={(key, fallback) => t(key, fallback || key)}
|
|
292
|
+
>
|
|
293
|
+
{(items) => {
|
|
294
|
+
const remaining = items.filter((item) => !removedIds.has(Number(item.id)));
|
|
295
|
+
shareState.loadedIdsRef.current = remaining.map((item) => Number(item.id));
|
|
296
|
+
return remaining.map((prod) => (
|
|
297
|
+
<WishlistCard
|
|
298
|
+
key={prod.id}
|
|
299
|
+
product={prod}
|
|
300
|
+
removing={removingIds.has(Number(prod.id))}
|
|
301
|
+
onRemoved={finishRemoving}
|
|
302
|
+
selection={{
|
|
303
|
+
selecting: shareState.selecting,
|
|
304
|
+
selected: selectedIdSet.has(Number(prod.id)),
|
|
305
|
+
onToggle: shareState.toggleSelected,
|
|
306
|
+
}}
|
|
307
|
+
/>
|
|
308
|
+
));
|
|
309
|
+
}}
|
|
310
|
+
</ItemsList>
|
|
311
|
+
<HookSlot name="customer:wishlist.items.end" />
|
|
312
|
+
</div>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { SallaButton } from '@salla.sa/twilight-components-react/button';
|
|
3
|
+
// The eager (non-deferred) export: the share dialog is opened imperatively through a ref, and the
|
|
4
|
+
// deferred wrapper doesn't attach it until it has hydrated — a click before that would do nothing.
|
|
5
|
+
import { SallaSocialShareCore as SallaSocialShare } from '@salla.sa/twilight-components-react/social-share';
|
|
6
|
+
import { useTranslation } from '../../../providers/I18nProvider';
|
|
7
|
+
|
|
8
|
+
type ShareResponse = { data?: { url?: string }; url?: string } | undefined;
|
|
9
|
+
type SocialShareElement = HTMLElement & {
|
|
10
|
+
url?: string;
|
|
11
|
+
refresh?: () => Promise<void>;
|
|
12
|
+
open?: () => Promise<void>;
|
|
13
|
+
close?: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Share state for the wishlist page: the "Share" dropdown (share the whole list / share
|
|
18
|
+
* specific items), the selection used by "specific items", and the share request itself.
|
|
19
|
+
* Mirrors what the SDK's `<salla-wishlist-actions>` does, but drives the page's own React
|
|
20
|
+
* list — that component needs a sibling `<salla-products-list>`, which this page doesn't render.
|
|
21
|
+
*/
|
|
22
|
+
export function useWishlistShare() {
|
|
23
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
24
|
+
const [selecting, setSelecting] = useState(false);
|
|
25
|
+
const [selectedIds, setSelectedIds] = useState<number[]>([]);
|
|
26
|
+
const [sharing, setSharing] = useState(false);
|
|
27
|
+
const [shareUrl, setShareUrl] = useState('');
|
|
28
|
+
/** Ids of every product currently rendered (later cursor pages included), for "select all". */
|
|
29
|
+
const loadedIdsRef = useRef<number[]>([]);
|
|
30
|
+
const socialShareRef = useRef<SocialShareElement | null>(null);
|
|
31
|
+
|
|
32
|
+
const share = useCallback(async (ids: number[], selectAll: boolean) => {
|
|
33
|
+
if (!window.salla?.wishlist?.share) return;
|
|
34
|
+
setSharing(true);
|
|
35
|
+
try {
|
|
36
|
+
const response = (await window.salla.wishlist.share(ids, selectAll)) as ShareResponse;
|
|
37
|
+
const url = response?.data?.url || response?.url || '';
|
|
38
|
+
if (!url) return;
|
|
39
|
+
setShareUrl(url);
|
|
40
|
+
const element = socialShareRef.current;
|
|
41
|
+
if (element) {
|
|
42
|
+
element.url = url;
|
|
43
|
+
await element.refresh?.();
|
|
44
|
+
await element.open?.();
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
// The SDK reports a failed share itself (notification); nothing to recover here.
|
|
48
|
+
} finally {
|
|
49
|
+
setSharing(false);
|
|
50
|
+
}
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
53
|
+
const shareAll = useCallback(() => {
|
|
54
|
+
setMenuOpen(false);
|
|
55
|
+
void share([], true);
|
|
56
|
+
}, [share]);
|
|
57
|
+
|
|
58
|
+
const shareSelected = useCallback(() => {
|
|
59
|
+
if (selectedIds.length) void share(selectedIds, false);
|
|
60
|
+
}, [share, selectedIds]);
|
|
61
|
+
|
|
62
|
+
const startSelecting = useCallback(() => {
|
|
63
|
+
setMenuOpen(false);
|
|
64
|
+
setSelecting(true);
|
|
65
|
+
}, []);
|
|
66
|
+
|
|
67
|
+
const cancelSelecting = useCallback(() => {
|
|
68
|
+
setSelecting(false);
|
|
69
|
+
setSelectedIds([]);
|
|
70
|
+
setShareUrl('');
|
|
71
|
+
void socialShareRef.current?.close?.();
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
const toggleSelected = useCallback((id: number) => {
|
|
75
|
+
setShareUrl('');
|
|
76
|
+
setSelectedIds((current) =>
|
|
77
|
+
current.includes(id) ? current.filter((existing) => existing !== id) : [...current, id]
|
|
78
|
+
);
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
const selectedIdsRef = useRef(selectedIds);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
selectedIdsRef.current = selectedIds;
|
|
84
|
+
}, [selectedIds]);
|
|
85
|
+
|
|
86
|
+
const deselect = useCallback((id: number) => {
|
|
87
|
+
if (!selectedIdsRef.current.includes(id)) return;
|
|
88
|
+
// A link built for the old selection would still offer the removed product.
|
|
89
|
+
setShareUrl('');
|
|
90
|
+
const element = socialShareRef.current;
|
|
91
|
+
if (element) {
|
|
92
|
+
element.url = undefined;
|
|
93
|
+
void element.close?.();
|
|
94
|
+
}
|
|
95
|
+
setSelectedIds((current) => current.filter((existing) => existing !== id));
|
|
96
|
+
}, []);
|
|
97
|
+
|
|
98
|
+
const toggleAll = useCallback(() => {
|
|
99
|
+
setShareUrl('');
|
|
100
|
+
setSelectedIds((current) =>
|
|
101
|
+
current.length && current.length === loadedIdsRef.current.length
|
|
102
|
+
? []
|
|
103
|
+
: [...loadedIdsRef.current]
|
|
104
|
+
);
|
|
105
|
+
}, []);
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
menuOpen,
|
|
109
|
+
setMenuOpen,
|
|
110
|
+
selecting,
|
|
111
|
+
selectedIds,
|
|
112
|
+
sharing,
|
|
113
|
+
shareUrl,
|
|
114
|
+
loadedIdsRef,
|
|
115
|
+
socialShareRef,
|
|
116
|
+
shareAll,
|
|
117
|
+
shareSelected,
|
|
118
|
+
startSelecting,
|
|
119
|
+
cancelSelecting,
|
|
120
|
+
toggleSelected,
|
|
121
|
+
toggleAll,
|
|
122
|
+
deselect,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export type WishlistShareState = ReturnType<typeof useWishlistShare>;
|
|
127
|
+
|
|
128
|
+
/** The bar above the wishlist: the "Share" dropdown, or — while picking products — the selection controls. */
|
|
129
|
+
export function WishlistShareBar({
|
|
130
|
+
state,
|
|
131
|
+
hasProducts,
|
|
132
|
+
}: {
|
|
133
|
+
state: WishlistShareState;
|
|
134
|
+
hasProducts: boolean;
|
|
135
|
+
}) {
|
|
136
|
+
const { t } = useTranslation();
|
|
137
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
138
|
+
const { menuOpen, setMenuOpen } = state;
|
|
139
|
+
|
|
140
|
+
// Close the dropdown on an outside click or Escape.
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (!menuOpen) return;
|
|
143
|
+
const onPointerDown = (event: MouseEvent) => {
|
|
144
|
+
if (!rootRef.current?.contains(event.target as Node)) setMenuOpen(false);
|
|
145
|
+
};
|
|
146
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
147
|
+
if (event.key === 'Escape') setMenuOpen(false);
|
|
148
|
+
};
|
|
149
|
+
document.addEventListener('mousedown', onPointerDown);
|
|
150
|
+
document.addEventListener('keydown', onKeyDown);
|
|
151
|
+
return () => {
|
|
152
|
+
document.removeEventListener('mousedown', onPointerDown);
|
|
153
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
154
|
+
};
|
|
155
|
+
}, [menuOpen, setMenuOpen]);
|
|
156
|
+
|
|
157
|
+
const selectedCount = state.selectedIds.length;
|
|
158
|
+
const allSelected = selectedCount > 0 && selectedCount === state.loadedIdsRef.current.length;
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<div ref={rootRef} className="s-wishlist-actions">
|
|
162
|
+
<div className="s-wishlist-actions-bar flex items-center justify-end gap-3 mb-3">
|
|
163
|
+
{state.selecting ? (
|
|
164
|
+
<div className="s-wishlist-actions-selection flex items-center gap-3">
|
|
165
|
+
<label className="s-wishlist-actions-select-all inline-flex items-center gap-2 text-sm">
|
|
166
|
+
<input
|
|
167
|
+
type="checkbox"
|
|
168
|
+
checked={allSelected}
|
|
169
|
+
ref={(input) => {
|
|
170
|
+
if (input) input.indeterminate = selectedCount > 0 && !allSelected;
|
|
171
|
+
}}
|
|
172
|
+
onChange={state.toggleAll}
|
|
173
|
+
/>
|
|
174
|
+
{t('pages.wishlist.select_all', 'Select all')}
|
|
175
|
+
</label>
|
|
176
|
+
<SallaButton
|
|
177
|
+
color="primary"
|
|
178
|
+
disabled={selectedCount === 0 || state.sharing}
|
|
179
|
+
onClick={state.shareSelected}
|
|
180
|
+
>
|
|
181
|
+
{t('pages.wishlist.share', 'Share')}
|
|
182
|
+
{selectedCount > 0 ? ` (${selectedCount})` : ''}
|
|
183
|
+
</SallaButton>
|
|
184
|
+
<SallaButton fill="outline" color="light" onClick={state.cancelSelecting}>
|
|
185
|
+
{t('common.elements.cancel', 'Cancel')}
|
|
186
|
+
</SallaButton>
|
|
187
|
+
</div>
|
|
188
|
+
) : (
|
|
189
|
+
<div className="s-wishlist-actions-dropdown relative">
|
|
190
|
+
<SallaButton
|
|
191
|
+
color="primary"
|
|
192
|
+
fill="outline"
|
|
193
|
+
disabled={!hasProducts || state.sharing}
|
|
194
|
+
aria-haspopup="true"
|
|
195
|
+
aria-expanded={menuOpen}
|
|
196
|
+
onClick={() => setMenuOpen(!menuOpen)}
|
|
197
|
+
>
|
|
198
|
+
<span className="flex items-center justify-center gap-2">
|
|
199
|
+
<i className="sicon-share-alt" aria-hidden="true" />
|
|
200
|
+
{t('pages.wishlist.share', 'Share')}
|
|
201
|
+
<i className="sicon-keyboard_arrow_down" aria-hidden="true" />
|
|
202
|
+
</span>
|
|
203
|
+
</SallaButton>
|
|
204
|
+
{menuOpen && (
|
|
205
|
+
<ul
|
|
206
|
+
role="menu"
|
|
207
|
+
className="s-wishlist-actions-menu absolute z-10 mt-2 min-w-48 rounded-md bg-white py-2 shadow-default rtl:right-0 ltr:left-0"
|
|
208
|
+
>
|
|
209
|
+
<li role="none">
|
|
210
|
+
<button
|
|
211
|
+
type="button"
|
|
212
|
+
role="menuitem"
|
|
213
|
+
className="s-wishlist-actions-item block w-full px-4 py-2 text-start text-sm text-gray-700 hover:bg-gray-50"
|
|
214
|
+
onClick={state.shareAll}
|
|
215
|
+
>
|
|
216
|
+
{t('pages.wishlist.share_all', 'Share the list')}
|
|
217
|
+
</button>
|
|
218
|
+
</li>
|
|
219
|
+
<li role="none">
|
|
220
|
+
<button
|
|
221
|
+
type="button"
|
|
222
|
+
role="menuitem"
|
|
223
|
+
className="s-wishlist-actions-item block w-full px-4 py-2 text-start text-sm text-gray-700 hover:bg-gray-50"
|
|
224
|
+
onClick={state.startSelecting}
|
|
225
|
+
>
|
|
226
|
+
{t('pages.wishlist.share_specific', 'Share specific items')}
|
|
227
|
+
</button>
|
|
228
|
+
</li>
|
|
229
|
+
</ul>
|
|
230
|
+
)}
|
|
231
|
+
</div>
|
|
232
|
+
)}
|
|
233
|
+
</div>
|
|
234
|
+
{/* Same setup as the SDK's <salla-wishlist-actions>: the centered modal variant, opened by the
|
|
235
|
+
dropdown rather than by the component's own round share button, so the default
|
|
236
|
+
`widget` slot (that button) is replaced by an empty anchor. */}
|
|
237
|
+
<SallaSocialShare
|
|
238
|
+
ref={state.socialShareRef as never}
|
|
239
|
+
url={state.shareUrl || undefined}
|
|
240
|
+
mode="modal"
|
|
241
|
+
modalTitle={t('pages.wishlist.share_list_title', 'Share wishlist')}
|
|
242
|
+
className="s-wishlist-actions-social"
|
|
243
|
+
>
|
|
244
|
+
<span slot="widget" className="s-wishlist-actions-social-anchor" aria-hidden="true" />
|
|
245
|
+
</SallaSocialShare>
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { HeadDescriptor } from '../../../utils/head';
|
|
2
|
+
import { buildHreflangAlternates } from '../../../utils/baseHead';
|
|
3
|
+
import { lazy } from 'react';
|
|
4
|
+
import { wishlistLoader } from './loader';
|
|
5
|
+
import type { WishlistPageProps } from './types';
|
|
6
|
+
import type { LoaderContext } from '../../types';
|
|
7
|
+
import type { TwilightContext } from '../../../twilight/context';
|
|
8
|
+
import { RouteId } from '../../../router/route-ids';
|
|
9
|
+
|
|
10
|
+
const LazyWishlistPage = lazy(() =>
|
|
11
|
+
import('./WishlistPage').then((m) => ({ default: m.WishlistPage }))
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const WishlistPage = LazyWishlistPage;
|
|
15
|
+
export { wishlistLoader } from './loader';
|
|
16
|
+
export type { WishlistPageProps } from './types';
|
|
17
|
+
|
|
18
|
+
export const Wishlist = {
|
|
19
|
+
id: RouteId.CUSTOMER_WISHLIST,
|
|
20
|
+
loader: async (
|
|
21
|
+
ctx: LoaderContext,
|
|
22
|
+
extend?: (
|
|
23
|
+
data: WishlistPageProps,
|
|
24
|
+
ctx: { params: Record<string, never> }
|
|
25
|
+
) => Promise<Record<string, unknown>> | Record<string, unknown>
|
|
26
|
+
): Promise<WishlistPageProps> => {
|
|
27
|
+
const data = await wishlistLoader(ctx);
|
|
28
|
+
if (extend) {
|
|
29
|
+
const extra = await extend(data, { params: {} });
|
|
30
|
+
return { ...data, ...extra } as WishlistPageProps;
|
|
31
|
+
}
|
|
32
|
+
return data;
|
|
33
|
+
},
|
|
34
|
+
head: (ctx: TwilightContext, data: WishlistPageProps): HeadDescriptor => ({
|
|
35
|
+
title: data.page.title,
|
|
36
|
+
description: data.page.description,
|
|
37
|
+
alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),
|
|
38
|
+
}),
|
|
39
|
+
Component: LazyWishlistPage,
|
|
40
|
+
} as const;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { WishlistPageProps } from './types';
|
|
2
|
+
import type { LoaderContext } from '../../types';
|
|
3
|
+
import { wishlist } from '../../../api/wishlist';
|
|
4
|
+
import { getTwilightContext } from '../../../twilight/context';
|
|
5
|
+
import { orUnauthorized, unauthorized } from '../../../providers/NavigationProvider';
|
|
6
|
+
import { getAuthToken } from '../../../api/client';
|
|
7
|
+
import { RouteId } from '../../../router/route-ids';
|
|
8
|
+
|
|
9
|
+
export async function wishlistLoader(ctx: LoaderContext): Promise<WishlistPageProps> {
|
|
10
|
+
if (!getAuthToken()) throw unauthorized();
|
|
11
|
+
const pageNum = Number(ctx.search?.page) || 1;
|
|
12
|
+
const data = await orUnauthorized(wishlist.list({ page: pageNum }));
|
|
13
|
+
|
|
14
|
+
const i18n = getTwilightContext().i18n;
|
|
15
|
+
return {
|
|
16
|
+
page: {
|
|
17
|
+
title: i18n.t('common.titles.wishlist') || 'Wishlist',
|
|
18
|
+
slug: RouteId.CUSTOMER_WISHLIST,
|
|
19
|
+
},
|
|
20
|
+
query: { page: pageNum },
|
|
21
|
+
products: data.items,
|
|
22
|
+
pagination: {
|
|
23
|
+
next: data.next,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|