@dropins/storefront-wishlist 0.2.1-alpha → 0.2.2-alpha
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/api/getProductBySku/graphql/getProductBySku.graphql.d.ts +1 -1
- package/api/index.d.ts +1 -0
- package/api/initialize/index.d.ts +16 -0
- package/api/mergeWishlists/index.d.ts +18 -0
- package/api/mergeWishlists/mergeWishlists.d.ts +4 -0
- package/api.js +4 -4
- package/chunks/WishlistItem.js +1 -1
- package/chunks/mergeWishlists.js +287 -0
- package/chunks/removeProductsFromWishlist.js +2 -2
- package/components/ProductItem/ProductItem.d.ts +3 -2
- package/components/Wishlist/WishlistItemSkeleton.d.ts +4 -0
- package/components/Wishlist/WishlistSkeleton.d.ts +4 -0
- package/components/Wishlist/index.d.ts +2 -0
- package/containers/Wishlist/Wishlist.d.ts +2 -0
- package/containers/Wishlist.js +15 -1
- package/containers/WishlistItem/WishlistItem.d.ts +4 -1
- package/containers/WishlistToggle.js +1 -1
- package/data/models/product.d.ts +8 -1
- package/data/models/wishlist.d.ts +10 -0
- package/data/transforms/__fixtures__/wishlistData.d.ts +5 -2
- package/data/transforms/transform-wishlist.d.ts +4 -1
- package/i18n/en_US.json.d.ts +2 -1
- package/lib/persisted-data.d.ts +2 -1
- package/lib/state.d.ts +1 -0
- package/package.json +1 -1
- package/render.js +2 -2
- package/chunks/initializeWishlist.js +0 -237
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export declare const GET_PRODUCT_BY_SKU = "\n query GET_PRODUCT_BY_SKU($sku: String!) {\n products(filter: { sku: { eq: $sku } }) {\n items {\n sku\n name\n thumbnail {\n label\n url\n }\n price_range {\n minimum_price {\n regular_price {\n currency\n value\n }\n final_price {\n currency\n value\n }\n discount {\n amount_off\n percent_off\n }\n }\n }\n stock_status\n ... on SimpleProduct {\n stock_status\n options {\n uid\n }\n }\n ... on ConfigurableProduct {\n configurable_options {\n uid\n attribute_uid\n attribute_code\n values {\n uid\n }\n }\n variants {\n product {\n sku\n stock_status\n }\n }\n }\n ... on BundleProduct {\n items {\n uid\n title\n options {\n uid\n label\n quantity\n }\n }\n }\n }\n }\n }\n";
|
|
17
|
+
export declare const GET_PRODUCT_BY_SKU = "\n query GET_PRODUCT_BY_SKU($sku: String!) {\n products(filter: { sku: { eq: $sku } }) {\n items {\n __typename\n sku\n name\n thumbnail {\n label\n url\n }\n price_range {\n minimum_price {\n regular_price {\n currency\n value\n }\n final_price {\n currency\n value\n }\n discount {\n amount_off\n percent_off\n }\n }\n }\n stock_status\n ... on SimpleProduct {\n stock_status\n options {\n uid\n }\n }\n ... on ConfigurableProduct {\n configurable_options {\n uid\n attribute_uid\n attribute_code\n values {\n uid\n }\n }\n variants {\n product {\n sku\n stock_status\n }\n }\n }\n ... on GiftCardProduct {\n giftcard_type\n giftcard_amounts {\n uid\n website_id\n value\n attribute_id\n website_value\n }\n gift_card_options {\n title\n required\n uid\n ... on CustomizableFieldOption {\n value: value {\n uid\n }\n }\n }\n }\n ... on BundleProduct {\n items {\n uid\n title\n options {\n uid\n label\n quantity\n }\n }\n }\n }\n }\n }\n";
|
|
18
18
|
//# sourceMappingURL=getProductBySku.graphql.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
1
17
|
export * from './initialize';
|
|
2
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './mergeWishlists';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{W as _,t as h,b as
|
|
3
|
+
import{W as _,t as h,b as c}from"./chunks/mergeWishlists.js";import{a as G,c as H,h as F,j as v,d as L,g as U,e as A,i as M,f as N,m as R,r as $}from"./chunks/mergeWishlists.js";import{s as l,g as u,f as n,h as I}from"./chunks/removeProductsFromWishlist.js";import{j as O,e as Q,k as b,c as B,r as C,a as Y,b as x,d as z,i as j}from"./chunks/removeProductsFromWishlist.js";import{events as m}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";const d=`
|
|
4
4
|
query GET_WISHLIST_BY_ID_QUERY(
|
|
5
5
|
$wishlistId: ID!,
|
|
6
6
|
) {
|
|
@@ -25,7 +25,7 @@ import{W as _,t as h,b as u}from"./chunks/initializeWishlist.js";import{a as G,c
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
${_}
|
|
28
|
-
`,w=async(r,o,e)=>{if(!l.authenticated)return
|
|
28
|
+
`,w=async(r,o,e)=>{if(!l.authenticated)return u();if(!r)throw Error("Wishlist ID is not set");return n(d,{variables:{wishlistId:r,currentPage:o,pageSize:e}}).then(({errors:s,data:t})=>{var a;if(s)return I(s);if(!((a=t==null?void 0:t.customer)!=null&&a.wishlist_v2))return null;const i=h(t.customer.wishlist_v2);return m.emit("wishlist/data",i),i})},W=`
|
|
29
29
|
mutation UPDATE_PRODUCTS_IN_WISHLIST_MUTATION(
|
|
30
30
|
$wishlistId: ID!,
|
|
31
31
|
$wishlistItems: [WishlistItemUpdateInput!]!,
|
|
@@ -44,5 +44,5 @@ ${_}
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
${
|
|
48
|
-
`,E=async r=>{const o=l.wishlistId;if(!o)throw Error("Wishlist ID is not set");return n(
|
|
47
|
+
${c}
|
|
48
|
+
`,E=async r=>{const o=l.wishlistId;if(!o)throw Error("Wishlist ID is not set");return n(W,{variables:{wishlistId:o,wishlistItems:r.map(({wishlistItemId:e,quantity:s,description:t,selectedOptions:i,enteredOptions:a})=>({wishlistItemId:e,quantity:s,description:t,selected_options:i,entered_options:a}))}}).then(({errors:e,data:s})=>{var i;const t=[...((i=s==null?void 0:s.updateProductsInWishlist)==null?void 0:i.user_errors)??[],...e??[]];return t.length>0?I(t):h(s.updateProductsInWishlist.wishlist)})};export{G as addProductsToWishlist,O as clearPersistedLocalStorage,H as config,n as fetchGraphQl,Q as getConfig,F as getDefaultWishlist,v as getGuestWishlist,u as getPersistedWishlistData,L as getProductBySku,U as getStoreConfig,w as getWishlistById,b as getWishlistItemFromStorage,A as getWishlists,M as initialize,N as initializeWishlist,R as mergeWishlists,B as removeFetchGraphQlHeader,C as removeProductsFromWishlist,$ as resetWishlist,Y as setEndpoint,x as setFetchGraphQlHeader,z as setFetchGraphQlHeaders,j as setPersistedWishlistData,E as updateProductsInWishlist};
|
package/chunks/WishlistItem.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as
|
|
3
|
+
import{jsx as t,Fragment as R,jsxs as f}from"@dropins/tools/preact-jsx-runtime.js";import{classes as l}from"@dropins/tools/lib.js";import{Price as w,Button as L,Icon as U,Image as W}from"@dropins/tools/components.js";import{useState as $}from"@dropins/tools/preact-compat.js";import{s as m,r as B}from"./removeProductsFromWishlist.js";import{events as G}from"@dropins/tools/event-bus.js";import{a as M,S as j}from"./Trash.js";import{useText as z}from"@dropins/tools/i18n.js";const V=({taxes:e,displayMode:s})=>t(R,{children:e.map((r,c)=>f("div",{"data-testid":`wishlist-product-item-tax-${c}`,className:"wishlist-product-item-tax",children:[t("span",{className:"wishlist-product-item-tax-label",children:r.label}),t(w,{className:"wishlist-product-item-tax-price",amount:r.money.value,currency:r.money.currency}),t("span",{className:"wishlist-product-item-tax-display-mode",children:s==="INCLUDING_FPT_AND_DESCRIPTION"?"incl.":"excl."})]},c))}),q=({className:e,item:s,onCartActionButtonClick:r,onTrashButtonClick:c,fixedProductTaxesEnabled:n,fixedProductTaxesEnabledDisplayInProductLists:u,routeProdDetailPage:d,...o})=>{var i,h,x,P,v,I,N,y,T,_,b,g,S,E,C,A,O,F,k;const a=z({cartActionBtn:"ProductItem.CartActionButton",trashActionBtn:"ProductItem.TrashActionButton"}),p=((x=(h=(i=s.product)==null?void 0:i.prices)==null?void 0:h.discount)==null?void 0:x.amountOff)!==0||((I=(v=(P=s.product)==null?void 0:P.prices)==null?void 0:v.discount)==null?void 0:I.percentOff)!==0;return t("div",{...o,className:l(["wishlist-product-item",e]),children:f("div",{className:"wishlist-product-item__content",children:[t("a",{className:"wishlist-product-item-image","data-testid":"wishlist-product-item-image",href:d(s.product),children:t(K,{images:(N=s.product)!=null&&N.image?[s.product.image]:[]})}),f("div",{className:"wishlist-product-item__title","data-testid":"wishlist-product-item-header",children:[t("a",{className:"wishlist-product-item-name","data-testid":"wishlist-product-item-name",href:d(s.product),children:(y=s.product)==null?void 0:y.name}),t(L,{"data-testid":"wishlist-product-item-remove-button",className:"wishlist-product-item-button__remove",variant:"tertiary",onClick:()=>c==null?void 0:c(),icon:t(U,{source:M,size:"24",stroke:"2",viewBox:"0 0 24 24","aria-label":a.trashActionBtn})}),t(w,{className:l(["wishlist-product-item-price",p?"strikeout":""]),"data-testid":"wishlist-product-item-price",amount:(_=(T=s.product)==null?void 0:T.prices)==null?void 0:_.regularPrice.value,currency:(g=(b=s.product)==null?void 0:b.prices)==null?void 0:g.regularPrice.currency}),p&&t(w,{className:"wishlist-product-item-discounted-price","data-testid":"wishlist-product-item-discounted-price",amount:(E=(S=s.product)==null?void 0:S.prices)==null?void 0:E.finalPrice.value,currency:(A=(C=s.product)==null?void 0:C.prices)==null?void 0:A.finalPrice.currency}),n&&(u==="INCLUDING_FPT_AND_DESCRIPTION"||u==="EXCLUDING_FPT_INCLUDING_DESCRIPTION_FINAL_PRICE")&&((F=(O=s.product)==null?void 0:O.prices)==null?void 0:F.fixedProductTaxes)&&t(V,{taxes:s.product.prices.fixedProductTaxes,displayMode:u})]}),t(L,{"data-testid":"wishlist-product-item-move-to-cart-button",size:"medium",type:"submit",icon:t(U,{source:j}),disabled:((k=s.product)==null?void 0:k.stockStatus)!=="IN_STOCK","aria-label":a.cartActionBtn,onClick:()=>r==null?void 0:r(),children:a.cartActionBtn})]})})},K=({className:e,children:s,images:r,...c})=>{const[n,u]=$(0);return f(R,{children:[t("div",{...c,className:l(["image-carousel",e]),children:t("div",{className:l(["overflow-hidden relative max-w-[200px]",e]),children:r==null?void 0:r.map((d,o)=>o===n&&t(W,{className:"image-carousel-image",alt:d.alt,src:d.src}))})}),(r==null?void 0:r.length)>1&&t("div",{className:l(["absolute","image-switcher-area"]),children:r==null?void 0:r.map((d,o)=>t("span",{className:l(["image-switcher",n===o?"image-switcher-active":"image-switcher-inactive"]),onClick:a=>{u(o),a.stopPropagation()}},o))})]})},te=({initialData:e=null,moveProdToCart:s,routeProdDetailPage:r})=>{var u,d,o,a,p;if(!(e!=null&&e.product))return null;const c=async(i=!0)=>{try{return await B([e]),console.log(`Product ${e.product.sku} removed from wishlist!`),i&&G.emit("wishlist/alert",{action:"remove",item:e}),!0}catch(h){return console.error(`Product ${e.product.sku} could not be removed from wishlist`,h),!1}};return t(q,{item:e,onCartActionButtonClick:async()=>{try{return await s([{sku:e.product.sku,quantity:1,optionsUIDs:e.selectedOptions.map(i=>i.uid),enteredOptions:e.enteredOptions}]),console.log(`Product ${e.product.sku} successfully moved to cart 🛒`),G.emit("wishlist/alert",{action:"move",item:e}),await c(!1)}catch(i){return console.error("Cart creation/update failed: ",i),i.toString().includes("You need to choose options for your item.")&&(sessionStorage.setItem("incompleteProduct",e.product.sku),window.location.replace(r(e.product))),!1}},onTrashButtonClick:c,fixedProductTaxesEnabled:((u=m.config)==null?void 0:u.fixedProductTaxesEnabled)??!1,fixedProductTaxesApply:((d=m.config)==null?void 0:d.fixedProductTaxesApply)??!1,fixedProductTaxesEnabledDisplayInProductLists:(o=m.config)==null?void 0:o.fixedProductTaxesEnabledDisplayInProductLists,fixedProductTaxesEnabledDisplayInProductView:(a=m.config)==null?void 0:a.fixedProductTaxesEnabledDisplayInProductView,fixedProductTaxesEnabledDisplayInSalesModules:(p=m.config)==null?void 0:p.fixedProductTaxesEnabledDisplayInSalesModules,routeProdDetailPage:r})};export{te as W};
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{Initializer as N}from"@dropins/tools/lib.js";import{events as c}from"@dropins/tools/event-bus.js";import{s as u,i as R,f as b,h as E,g as x,j as O}from"./removeProductsFromWishlist.js";const S=new N({init:async e=>{const t={isGuestWishlistEnabled:!1,...e};S.config.setConfig(t),w().catch(console.error)},listeners:()=>[c.on("authenticated",async e=>{if(u.authenticated&&!e&&c.emit("wishlist/reset",void 0),e&&!u.authenticated){u.authenticated=e;const t=await w().catch(console.error);t&&J(t)}},{eager:!0}),c.on("wishlist/data",e=>{R(e)}),c.on("wishlist/reset",()=>{j().catch(console.error),c.emit("wishlist/data",null)})]}),se=S.config;function G(e){if(!e)return null;const t=i=>{switch(i){case 1:return"INCLUDING_FPT_AND_DESCRIPTION";case 2:return"EXCLUDING_FPT_INCLUDING_DESCRIPTION_FINAL_PRICE";case 3:return"EXCLUDING_FPT";default:return"INCLUDING_FPT_ONLY"}};return{wishlistIsEnabled:e.storeConfig.magento_wishlist_general_is_enabled,wishlistMultipleListIsEnabled:e.storeConfig.enable_multiple_wishlists,wishlistMaxNumber:e.storeConfig.maximum_number_of_wishlists,fixedProductTaxesEnabled:e.storeConfig.fixed_product_taxes_enable,fixedProductTaxesApply:e.storeConfig.fixed_product_taxes_apply_tax_to_fpt,fixedProductTaxesEnabledDisplayInProductLists:t(e.storeConfig.fixed_product_taxes_display_prices_in_product_lists),fixedProductTaxesEnabledDisplayInSalesModules:t(e.storeConfig.fixed_product_taxes_display_prices_in_sales_modules),fixedProductTaxesEnabledDisplayInProductView:t(e.storeConfig.fixed_product_taxes_display_prices_on_product_view_page)}}function P(e){var t,i;return e?{type:e.__typename,name:e.name,sku:e.sku,uid:e.uid,image:A(e),stockStatus:e.stock_status,canonicalUrl:e.canonical_url,urlKey:e.url_key,categories:(t=e.categories)==null?void 0:t.map(s=>s.name),prices:W(e),productAttributes:D(e),options:e.gift_card_options?(i=e.gift_card_options)==null?void 0:i.map(s=>({uid:s.uid,required:s.required,title:s.title})):[]}:null}function A(e){var t,i;return{src:(t=e.thumbnail)==null?void 0:t.url,alt:(i=e.thumbnail)==null?void 0:i.label}}function W(e){var t,i,s,r,n,l,d,m,o,p,_,a,f,h,g,I,T,y;return{regularPrice:{currency:((s=(i=(t=e.price_range)==null?void 0:t.minimum_price)==null?void 0:i.regular_price)==null?void 0:s.currency)??"USD",value:((l=(n=(r=e.price_range)==null?void 0:r.minimum_price)==null?void 0:n.regular_price)==null?void 0:l.value)??0},finalPrice:{currency:((o=(m=(d=e.price_range)==null?void 0:d.minimum_price)==null?void 0:m.final_price)==null?void 0:o.currency)??"USD",value:((a=(_=(p=e.price_range)==null?void 0:p.minimum_price)==null?void 0:_.final_price)==null?void 0:a.value)??0},discount:{amountOff:((g=(h=(f=e.price_range)==null?void 0:f.minimum_price)==null?void 0:h.discount)==null?void 0:g.amount_off)??0,percentOff:((y=(T=(I=e.price_range)==null?void 0:I.minimum_price)==null?void 0:T.discount)==null?void 0:y.percent_off)??0},fixedProductTaxes:U(e)}}function D(e){var t,i;return(i=(t=e.custom_attributesV2)==null?void 0:t.items)==null?void 0:i.map(s=>{const r=s.code.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");return{...s,code:r}})}function U(e){var t,i,s,r,n;return(i=(t=e.price_range)==null?void 0:t.minimum_price)!=null&&i.fixed_product_taxes?(n=(r=(s=e.price_range)==null?void 0:s.minimum_price)==null?void 0:r.fixed_product_taxes)==null?void 0:n.map(l=>({money:{value:l.amount.value,currency:l.amount.currency},label:l.label})):[]}function v(e,t){return e?{id:e.id,updated_at:e.updated_at,sharing_code:e.sharing_code,items_count:e.items_count,items:M(e,t??[])}:null}function M(e,t){var i,s;return(s=(i=e==null?void 0:e.items_v2)==null?void 0:i.items)!=null&&s.length?e.items_v2.items.map(r=>({id:r.id,quantity:r.quantity,description:r.description,added_at:r.added_at,enteredOptions:t,selectedOptions:r.configurable_options?r.configurable_options.map(n=>({value:n.value_label,label:n.option_label,uid:n.configurable_product_option_uid})):[],product:P(r.product)})):[]}const F=`
|
|
4
|
+
query STORE_CONFIG_QUERY {
|
|
5
|
+
storeConfig {
|
|
6
|
+
magento_wishlist_general_is_enabled
|
|
7
|
+
enable_multiple_wishlists
|
|
8
|
+
maximum_number_of_wishlists
|
|
9
|
+
fixed_product_taxes_enable
|
|
10
|
+
fixed_product_taxes_apply_tax_to_fpt
|
|
11
|
+
fixed_product_taxes_display_prices_in_product_lists
|
|
12
|
+
fixed_product_taxes_display_prices_in_sales_modules
|
|
13
|
+
fixed_product_taxes_display_prices_on_product_view_page
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`,k=async()=>b(F,{method:"GET",cache:"force-cache"}).then(({errors:e,data:t})=>e?E(e):G(t)),L=`
|
|
17
|
+
query GET_PRODUCT_BY_SKU($sku: String!) {
|
|
18
|
+
products(filter: { sku: { eq: $sku } }) {
|
|
19
|
+
items {
|
|
20
|
+
__typename
|
|
21
|
+
sku
|
|
22
|
+
name
|
|
23
|
+
thumbnail {
|
|
24
|
+
label
|
|
25
|
+
url
|
|
26
|
+
}
|
|
27
|
+
price_range {
|
|
28
|
+
minimum_price {
|
|
29
|
+
regular_price {
|
|
30
|
+
currency
|
|
31
|
+
value
|
|
32
|
+
}
|
|
33
|
+
final_price {
|
|
34
|
+
currency
|
|
35
|
+
value
|
|
36
|
+
}
|
|
37
|
+
discount {
|
|
38
|
+
amount_off
|
|
39
|
+
percent_off
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
stock_status
|
|
44
|
+
... on SimpleProduct {
|
|
45
|
+
stock_status
|
|
46
|
+
options {
|
|
47
|
+
uid
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
... on ConfigurableProduct {
|
|
51
|
+
configurable_options {
|
|
52
|
+
uid
|
|
53
|
+
attribute_uid
|
|
54
|
+
attribute_code
|
|
55
|
+
values {
|
|
56
|
+
uid
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
variants {
|
|
60
|
+
product {
|
|
61
|
+
sku
|
|
62
|
+
stock_status
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
... on GiftCardProduct {
|
|
67
|
+
giftcard_type
|
|
68
|
+
giftcard_amounts {
|
|
69
|
+
uid
|
|
70
|
+
website_id
|
|
71
|
+
value
|
|
72
|
+
attribute_id
|
|
73
|
+
website_value
|
|
74
|
+
}
|
|
75
|
+
gift_card_options {
|
|
76
|
+
title
|
|
77
|
+
required
|
|
78
|
+
uid
|
|
79
|
+
... on CustomizableFieldOption {
|
|
80
|
+
value: value {
|
|
81
|
+
uid
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
... on BundleProduct {
|
|
87
|
+
items {
|
|
88
|
+
uid
|
|
89
|
+
title
|
|
90
|
+
options {
|
|
91
|
+
uid
|
|
92
|
+
label
|
|
93
|
+
quantity
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`,q=async e=>{if(!e)throw Error("Product SKU is not set");return b(L,{variables:{sku:e}}).then(({errors:t,data:i})=>{var s;return t?E(t):(s=i==null?void 0:i.products)!=null&&s.items?P(i.products.items[0]):null})},$=`
|
|
101
|
+
fragment PRICE_RANGE_FRAGMENT on PriceRange {
|
|
102
|
+
minimum_price {
|
|
103
|
+
regular_price {
|
|
104
|
+
value
|
|
105
|
+
currency
|
|
106
|
+
}
|
|
107
|
+
final_price {
|
|
108
|
+
value
|
|
109
|
+
currency
|
|
110
|
+
}
|
|
111
|
+
discount {
|
|
112
|
+
percent_off
|
|
113
|
+
amount_off
|
|
114
|
+
}
|
|
115
|
+
fixed_product_taxes {
|
|
116
|
+
amount {
|
|
117
|
+
currency
|
|
118
|
+
value
|
|
119
|
+
}
|
|
120
|
+
label
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
maximum_price {
|
|
124
|
+
regular_price {
|
|
125
|
+
value
|
|
126
|
+
currency
|
|
127
|
+
}
|
|
128
|
+
final_price {
|
|
129
|
+
value
|
|
130
|
+
currency
|
|
131
|
+
}
|
|
132
|
+
discount {
|
|
133
|
+
percent_off
|
|
134
|
+
amount_off
|
|
135
|
+
}
|
|
136
|
+
fixed_product_taxes {
|
|
137
|
+
amount {
|
|
138
|
+
currency
|
|
139
|
+
value
|
|
140
|
+
}
|
|
141
|
+
label
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
`,z=`
|
|
146
|
+
fragment PRODUCT_FRAGMENT on ProductInterface {
|
|
147
|
+
name
|
|
148
|
+
sku
|
|
149
|
+
uid
|
|
150
|
+
thumbnail {
|
|
151
|
+
url
|
|
152
|
+
label
|
|
153
|
+
}
|
|
154
|
+
url_key
|
|
155
|
+
categories {
|
|
156
|
+
url_path
|
|
157
|
+
url_key
|
|
158
|
+
name
|
|
159
|
+
}
|
|
160
|
+
stock_status
|
|
161
|
+
canonical_url
|
|
162
|
+
custom_attributesV2(filters: {is_visible_on_front: true}){
|
|
163
|
+
items {
|
|
164
|
+
code
|
|
165
|
+
...on AttributeValue {
|
|
166
|
+
value
|
|
167
|
+
}
|
|
168
|
+
...on AttributeSelectedOptions {
|
|
169
|
+
selected_options {
|
|
170
|
+
value
|
|
171
|
+
label
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
price_range {
|
|
177
|
+
...PRICE_RANGE_FRAGMENT
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
${$}
|
|
182
|
+
`,H=`
|
|
183
|
+
fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {
|
|
184
|
+
type
|
|
185
|
+
customizable_option_uid
|
|
186
|
+
label
|
|
187
|
+
is_required
|
|
188
|
+
values {
|
|
189
|
+
label
|
|
190
|
+
value
|
|
191
|
+
price{
|
|
192
|
+
type
|
|
193
|
+
units
|
|
194
|
+
value
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
`,B=`
|
|
199
|
+
fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
|
|
200
|
+
__typename
|
|
201
|
+
id
|
|
202
|
+
quantity
|
|
203
|
+
description
|
|
204
|
+
added_at
|
|
205
|
+
product {
|
|
206
|
+
...PRODUCT_FRAGMENT
|
|
207
|
+
}
|
|
208
|
+
... on ConfigurableWishlistItem {
|
|
209
|
+
configurable_options {
|
|
210
|
+
option_label
|
|
211
|
+
value_label
|
|
212
|
+
configurable_product_option_uid
|
|
213
|
+
}
|
|
214
|
+
configured_variant {
|
|
215
|
+
canonical_url
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
... on GiftCardWishlistItem {
|
|
219
|
+
added_at
|
|
220
|
+
description
|
|
221
|
+
gift_card_options {
|
|
222
|
+
amount {
|
|
223
|
+
value
|
|
224
|
+
currency
|
|
225
|
+
}
|
|
226
|
+
custom_giftcard_amount {
|
|
227
|
+
value
|
|
228
|
+
currency
|
|
229
|
+
}
|
|
230
|
+
message
|
|
231
|
+
recipient_email
|
|
232
|
+
recipient_name
|
|
233
|
+
sender_email
|
|
234
|
+
sender_name
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
customizable_options {
|
|
238
|
+
...CUSTOMIZABLE_OPTIONS_FRAGMENT
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
${z}
|
|
243
|
+
${H}
|
|
244
|
+
`,C=`
|
|
245
|
+
fragment WISHLIST_FRAGMENT on Wishlist {
|
|
246
|
+
id
|
|
247
|
+
updated_at
|
|
248
|
+
sharing_code
|
|
249
|
+
items_count
|
|
250
|
+
items_v2 {
|
|
251
|
+
items {
|
|
252
|
+
...WISHLIST_ITEM_FRAGMENT
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
${B}
|
|
258
|
+
`,Y=`
|
|
259
|
+
query GET_WISHLISTS_QUERY {
|
|
260
|
+
customer {
|
|
261
|
+
wishlists {
|
|
262
|
+
...WISHLIST_FRAGMENT
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
${C}
|
|
268
|
+
`,Q=async()=>u.authenticated?b(Y).then(({errors:e,data:t})=>{var i;return e?E(e):(i=t==null?void 0:t.customer)!=null&&i.wishlists?t.customer.wishlists.map(s=>v(s)):null}):x(),K=`
|
|
269
|
+
mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(
|
|
270
|
+
$wishlistId: ID!,
|
|
271
|
+
$wishlistItems: [WishlistItemInput!]!,
|
|
272
|
+
) {
|
|
273
|
+
addProductsToWishlist(
|
|
274
|
+
wishlistId: $wishlistId
|
|
275
|
+
wishlistItems: $wishlistItems
|
|
276
|
+
) {
|
|
277
|
+
wishlist {
|
|
278
|
+
...WISHLIST_FRAGMENT
|
|
279
|
+
}
|
|
280
|
+
user_errors {
|
|
281
|
+
code
|
|
282
|
+
message
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
${C}
|
|
287
|
+
`,V=async e=>{var s,r,n,l,d,m;if(!e)return null;const t=x();let i={id:(t==null?void 0:t.id)??"",updated_at:"",sharing_code:"",items_count:0,items:(t==null?void 0:t.items)??[]};for(const o of e){if((s=t.items)==null?void 0:s.some(a=>a.product.sku===o.sku))continue;const _=await q(o.sku);_&&(i.items=[...i.items,{quantity:o.quantity,selectedOptions:o.optionsUIDs?(r=o.optionsUIDs)==null?void 0:r.map(a=>({uid:a})):[],enteredOptions:o.enteredOptions?(n=o.enteredOptions)==null?void 0:n.map(a=>({uid:a.uid,value:a.value})):[],product:_}])}if(i.items_count=(l=i.items)==null?void 0:l.length,c.emit("wishlist/data",i),u.authenticated){if(!u.wishlistId)throw c.emit("wishlist/data",t),Error("Wishlist ID is not set");const o={wishlistId:u.wishlistId,wishlistItems:e.map(({sku:h,parentSku:g,quantity:I,optionsUIDs:T,enteredOptions:y})=>({sku:h,parent_sku:g,quantity:I,selected_options:T,entered_options:y}))},{errors:p,data:_}=await b(K,{variables:o}),a=[...((d=_==null?void 0:_.addProductsToWishlist)==null?void 0:d.user_errors)??[],...p??[]];if(a.length>0)return c.emit("wishlist/data",t),E(a);const f=v(_.addProductsToWishlist.wishlist,((m=e[0])==null?void 0:m.enteredOptions)??[]);c.emit("wishlist/data",f)}return null},j=()=>(u.wishlistId=null,u.authenticated=!1,Promise.resolve(null)),w=async()=>{if(u.initializing)return null;u.initializing=!0,u.config||(u.config=await k());const e=u.authenticated?await Z():await X();return c.emit("wishlist/initialized",e),c.emit("wishlist/data",e),u.initializing=!1,e};async function Z(){const e=await Q(),t=e?e[0]:null;return t?(u.wishlistId=t.id,t):null}async function X(){try{return await x()}catch(e){throw console.error(e),e}}const J=async e=>{var r;if(!e)return null;const t=x(!0),i=[];if((r=t==null?void 0:t.items)==null||r.forEach(n=>{e.items.some(d=>d.product.sku===n.product.sku)||(n.product.quantity=1,i.push(n.product))}),i.length===0)return null;const s=await V(i);return O(),s};export{B as W,V as a,C as b,se as c,q as d,Q as e,w as f,k as g,Z as h,S as i,X as j,J as m,j as r,v as t};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{events as d}from"@dropins/tools/event-bus.js";import{FetchGraphQL as m}from"@dropins/tools/fetch-graphql.js";function S(
|
|
3
|
+
import{events as d}from"@dropins/tools/event-bus.js";import{FetchGraphQL as m}from"@dropins/tools/fetch-graphql.js";function S(e){const s=document.cookie.split(";");for(const t of s)if(t.trim().startsWith(`${e}=`))return t.trim().substring(e.length+1);return null}const g={wishlistId:null,authenticated:!1,isLoading:!0},i=new Proxy(g,{set(e,s,t){if(e[s]=t,s==="wishlistId"){if(t===i.wishlistId)return!0;if(t===null)return document.cookie="DROPIN__WISHLIST__WISHLIST-ID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/",!0;const r=new Date;r.setDate(r.getDate()+30),document.cookie=`DROPIN__WISHLIST__WISHLIST-ID=${t}; expires=${r.toUTCString()}; path=/`}return Reflect.set(e,s,t)},get(e,s){return s==="wishlistId"?S("DROPIN__WISHLIST__WISHLIST-ID"):e[s]}}),o="DROPIN__WISHLIST__WISHLIST__DATA";function E(e){const s=i.authenticated?sessionStorage:localStorage;if(e)try{s.setItem(o,JSON.stringify(e))}catch(t){_(t)?console.error("Storage quota exceeded:",t):console.error("Error saving wishlist:",t)}else s.removeItem(o)}const _=e=>e instanceof DOMException&&e.name==="QuotaExceededError";function f(e=!1){const s=i.authenticated&&!e?sessionStorage:localStorage;try{const t=s.getItem(o);return t?JSON.parse(t):{id:"",items:[]}}catch(t){return console.error("Error retrieving wishlist:",t),{id:"",items:[]}}}function O(){localStorage.removeItem(o)}function H(e){var r;const s=i.authenticated?sessionStorage:localStorage,t=s.getItem(o)?JSON.parse(s.getItem(o)):{items:[]};return(r=t==null?void 0:t.items)==null?void 0:r.find(a=>{var n;return((n=a.product)==null?void 0:n.sku)===e})}const{setEndpoint:L,setFetchGraphQlHeader:P,removeFetchGraphQlHeader:F,setFetchGraphQlHeaders:R,fetchGraphQl:p,getConfig:$}=new m().getMethods(),w=e=>{const s=e.map(t=>t.message).join(" ");throw Error(s)},T=`
|
|
4
4
|
mutation REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION(
|
|
5
5
|
$wishlistId: ID!,
|
|
6
6
|
$wishlistItemsIds: [ID!]!,
|
|
@@ -15,4 +15,4 @@ import{events as d}from"@dropins/tools/event-bus.js";import{FetchGraphQL as m}fr
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
`,x=async e=>{var r,a,n;const s=f(),t={...s,items:(r=s.items)==null?void 0:r.filter(c=>!e.map(l=>l.product.sku).includes(c.product.sku))};if(t.items_count=(a=t.items)==null?void 0:a.length,d.emit("wishlist/data",t),i.authenticated){if(!i.wishlistId)throw Error("Wishlist ID is not set");const c=e.map(u=>u.id),{errors:l,data:I}=await p(T,{variables:{wishlistId:i.wishlistId,wishlistItemsIds:c}}),h=[...((n=I==null?void 0:I.removeProductsFromWishlist)==null?void 0:n.user_errors)??[],...l??[]];return h.length>0?(d.emit("wishlist/data",s),w(h)):null}return null};export{L as a,P as b,F as c,R as d,$ as e,p as f,f as g,w as h,E as i,O as j,H as k,x as r,i as s};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FunctionComponent } from 'preact';
|
|
2
2
|
import { HTMLAttributes } from 'preact/compat';
|
|
3
|
-
import { Product } from '../../data/models';
|
|
3
|
+
import { Item, Product } from '../../data/models';
|
|
4
4
|
|
|
5
5
|
export interface ProductItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
6
|
className?: string;
|
|
7
|
-
item?:
|
|
7
|
+
item?: Item;
|
|
8
8
|
onCartActionButtonClick?: () => boolean;
|
|
9
9
|
onTrashButtonClick?: () => boolean;
|
|
10
10
|
fixedProductTaxesEnabled: boolean;
|
|
@@ -12,6 +12,7 @@ export interface ProductItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
12
12
|
fixedProductTaxesEnabledDisplayInProductLists?: string;
|
|
13
13
|
fixedProductTaxesEnabledDisplayInSalesModules?: string;
|
|
14
14
|
fixedProductTaxesEnabledDisplayInProductView?: string;
|
|
15
|
+
routeProdDetailPage: (product: Product) => string;
|
|
15
16
|
}
|
|
16
17
|
export declare const ProductItem: FunctionComponent<ProductItemProps>;
|
|
17
18
|
//# sourceMappingURL=ProductItem.d.ts.map
|
|
@@ -15,5 +15,7 @@
|
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
17
|
export * from './Wishlist';
|
|
18
|
+
export * from './WishlistSkeleton';
|
|
19
|
+
export * from './WishlistItemSkeleton';
|
|
18
20
|
export { Wishlist as default } from './Wishlist';
|
|
19
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'preact/compat';
|
|
2
2
|
import { Container } from '../../../@adobe-commerce/elsie/src/lib';
|
|
3
|
+
import { Product } from '../../data/models';
|
|
3
4
|
|
|
4
5
|
export interface WishlistProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
6
|
routeEmptyWishlistCTA?: () => string;
|
|
@@ -8,6 +9,7 @@ export interface WishlistProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
8
9
|
sku: string;
|
|
9
10
|
quantity: number;
|
|
10
11
|
}[]) => Promise<any>;
|
|
12
|
+
routeProdDetailPage: (product: Product) => string;
|
|
11
13
|
}
|
|
12
14
|
export declare const Wishlist: Container<WishlistProps>;
|
|
13
15
|
//# sourceMappingURL=Wishlist.d.ts.map
|
package/containers/Wishlist.js
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as
|
|
3
|
+
import{jsx as i,jsxs as d,Fragment as H}from"@dropins/tools/preact-jsx-runtime.js";import{useState as w,useCallback as j,useEffect as F,useMemo as k,Fragment as B}from"@dropins/tools/preact-compat.js";import{classes as y,VComponent as R}from"@dropins/tools/lib.js";import{IllustratedMessage as z,Button as A,Icon as V,SkeletonRow as Y,Skeleton as q}from"@dropins/tools/components.js";import{W as G}from"../chunks/WishlistItem.js";import{events as I}from"@dropins/tools/event-bus.js";import{s as b}from"../chunks/removeProductsFromWishlist.js";import{useText as $,Text as M}from"@dropins/tools/i18n.js";import{W as J}from"../chunks/WishlistAlert.js";import{S as K}from"../chunks/Heart.js";import"../chunks/Trash.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/HeartFilled.js";const O=({className:l,children:s,ctaLinkURL:e,...c})=>{const r=$({emptyWishlist:"Wishlist.EmptyWishlist.heading",message:"Wishlist.EmptyWishlist.message",cta:"Wishlist.EmptyWishlist.cta"});return i("div",{...c,className:y(["wishlist-empty-wishlist",l]),children:i(z,{className:y(["wishlist-empty-wishlist__wrapper",l]),"data-testid":"wishlist-empty-wishlist",heading:r.emptyWishlist,icon:i(V,{className:"wishlist-empty-wishlist__icon",source:K}),message:i("p",{children:r.message}),action:e?i(A,{"data-testid":"wishlist-empty-wishlist-button",size:"medium",variant:"primary",type:"submit",href:e,children:r.cta},"routeHome"):void 0})})},S=()=>i(Y,{children:`
|
|
4
|
+
<svg
|
|
5
|
+
width="100%"
|
|
6
|
+
height="100%"
|
|
7
|
+
viewBox="0 0 288 658"
|
|
8
|
+
fill="none"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
preserveAspectRatio="xMinYMin meet"
|
|
11
|
+
>
|
|
12
|
+
<rect x="6" y="24" width="282px" height="480" rx="8" fill="#E8E8E8" />
|
|
13
|
+
<rect x="6" y="522" width="280" height="22" rx="4" fill="#E8E8E8" />
|
|
14
|
+
<rect x="6" y="556" width="132" height="22" rx="4" fill="#E8E8E8" />
|
|
15
|
+
<rect x="6" y="592" width="280" height="48" rx="24" fill="#D9D9D9" />
|
|
16
|
+
</svg>
|
|
17
|
+
`}),Q=()=>d(q,{"data-testid":"wishlist-loader",children:[i(S,{}),i(S,{}),i(S,{})]}),hi=({routeEmptyWishlistCTA:l,routeToWishlist:s,moveProdToCart:e,routeProdDetailPage:c,...r})=>{const[f,m]=w(null),[v,N]=w(b.authenticated),[L,g]=w(b.isLoading),_=n=>N(n),[p,a]=w(null),W=j(n=>{const{action:o,item:h}=n;a(i(J,{action:o,item:h}))},[s]);return F(()=>{const n=I.on("authenticated",_),o=I.on("wishlist/alert",t=>W(t)),h=I.on("wishlist/data",t=>{m(t),g(!1)});return()=>{n==null||n.off(),h==null||h.off(),o==null||o.off()}},[W]),i(U,{...r,wishlistData:f,wishlistAlert:p,routeEmptyWishlistCTA:l,moveProdToCart:e,isLoggedIn:v,isLoading:L,routeProdDetailPage:c})},U=({className:l,wishlistData:s,wishlistAlert:e,isLoggedIn:c,isLoading:r,moveProdToCart:f,routeEmptyWishlistCTA:m,onLoginClick:v,routeProdDetailPage:N=null,...L})=>{const[g,_]=w(e),p=$({wishlistHeading:"Wishlist.Wishlist.heading",wishlistLoadingHeading:"Wishlist.Wishlist.loading"}),a=k(()=>{var t;return((t=s==null?void 0:s.items)==null?void 0:t.length)>0?s.items.map(x=>{var u;return i(G,{initialData:x,moveProdToCart:f,routeProdDetailPage:N},(u=x.product)==null?void 0:u.sku)}):null},[s,f]);F(()=>{if(e){_(e);const t=setTimeout(()=>{_(null)},5e3);return()=>clearTimeout(t)}},[e]);const W=k(()=>g?i(R,{node:g,className:"wishlist-wishlist__alert"}):null,[g]),n=()=>d(H,{children:[i("div",{className:"wishlist-wishlist__heading","data-testid":"wishlist-heading-wrapper",children:i("div",{className:"wishlist-wishlist__heading-text","data-testid":"loader-wishlist-heading",children:p.wishlistLoadingHeading})}),i(Q,{})]}),o=()=>a?d(H,{children:[h,i("div",{className:"wishlist-wishlist__content",children:a})]}):i("div",{className:y(["wishlist-wishlist__content","wishlist-wishlist__content--empty"]),children:d("div",{children:[i(O,{"data-testid":"empty-wishlist",ctaLinkURL:m==null?void 0:m()}),!c&&i(X,{onLoginClick:v})]})}),h=k(()=>{var t;return a?i("div",{className:"wishlist-wishlist__heading","data-testid":"wishlist-heading-wrapper",children:i("div",{className:"wishlist-wishlist__heading-text","data-testid":"default-wishlist-heading",children:(t=p.wishlistHeading)==null?void 0:t.split(" {count}").map((x,u)=>{var E;return d(B,{children:[x,u===0&&i("span",{className:"wishlist-wishlist__heading-count","data-testid":"wishlist-heading-count",children:`${s==null?void 0:s.items_count} products`})]},((E=s==null?void 0:s.id)==null?void 0:E.toString())+u)})})}):null},[p,a,s]);return d("div",{...L,className:y(["wishlist-wishlist",l]),children:[W,r?n():o()]})},X=({onLoginClick:l})=>d("div",{className:"wishlist-login__sign-in",children:[i("a",{"data-testid":"log-in-link",className:"wishlist-login__link",href:"",rel:"noreferrer",onClick:l,role:"button",children:i(M,{id:"Wishlist.Login.logIn"})}),i(M,{id:"Wishlist.Login.sync"})]});export{hi as Wishlist,hi as default};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'preact/compat';
|
|
2
2
|
import { Container } from '../../../@adobe-commerce/elsie/src/lib';
|
|
3
|
-
import { Item } from '../../data/models';
|
|
3
|
+
import { Item, Product } from '../../data/models';
|
|
4
4
|
|
|
5
5
|
export interface WishlistItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
6
|
initialData: Item | null;
|
|
7
7
|
moveProdToCart: (products: {
|
|
8
8
|
sku: string;
|
|
9
9
|
quantity: number;
|
|
10
|
+
optionsUIDs?: [];
|
|
11
|
+
enteredOptions?: [];
|
|
10
12
|
}[]) => Promise<any>;
|
|
13
|
+
routeProdDetailPage: (product: Product) => string;
|
|
11
14
|
}
|
|
12
15
|
export declare const WishlistItem: Container<WishlistItemProps>;
|
|
13
16
|
//# sourceMappingURL=WishlistItem.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{useState as a,useEffect as D}from"@dropins/tools/preact-compat.js";import{Button as E,Icon as c}from"@dropins/tools/components.js";import{events as i}from"@dropins/tools/event-bus.js";import{s as F,g as H,r as L}from"../chunks/removeProductsFromWishlist.js";import{c as T,a as b}from"../chunks/
|
|
3
|
+
import{jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{useState as a,useEffect as D}from"@dropins/tools/preact-compat.js";import{Button as E,Icon as c}from"@dropins/tools/components.js";import{events as i}from"@dropins/tools/event-bus.js";import{s as F,g as H,r as L}from"../chunks/removeProductsFromWishlist.js";import{c as T,a as b}from"../chunks/mergeWishlists.js";import{S as j}from"../chunks/HeartFilled.js";import{S as q}from"../chunks/Heart.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const R=({product:s,iconWishlisted:d,iconToWishlist:u,size:h,variant:f,disabled:g,labelToWishlist:v,labelWishlisted:p,onClick:I})=>{const[W,k]=a(F.authenticated),[n,e]=a(!1),[r,w]=a(null),{isGuestWishlistEnabled:S}=T.getConfig();D(()=>{const y=t=>k(t),P=()=>{var m;const t=H(),l=(m=t==null?void 0:t.items)==null?void 0:m.find(x=>x.product.sku===s.sku);w(l??null),e(!!l)};i.on("authenticated",y),i.on("wishlist/data",P)},[s.sku]);const C=async()=>{n?(await L([r]),e(!1),i.emit("wishlist/alert",{action:"remove",item:r})):(await b([{sku:s.sku,quantity:1}]),e(!0),i.emit("wishlist/alert",{action:"add",item:{product:s}}))};return!W&&!S?null:o(E,{active:n,"data-testid":"wishlist-toggle",size:h??"medium",variant:f??"tertiary",disabled:g,icon:o(c,{source:u??q}),activeIcon:o(c,{source:d??j}),onClick:I??C,children:v,activeChildren:p})};export{R as WishlistToggle,R as default};
|
package/data/models/product.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
17
|
export interface Product {
|
|
18
|
+
type: string;
|
|
18
19
|
name: string;
|
|
19
20
|
sku: string;
|
|
20
21
|
uid: string;
|
|
@@ -25,6 +26,7 @@ export interface Product {
|
|
|
25
26
|
categories: string[];
|
|
26
27
|
prices: PriceDetails;
|
|
27
28
|
productAttributes?: Attribute[];
|
|
29
|
+
options: Option[];
|
|
28
30
|
}
|
|
29
31
|
export interface PriceDetails {
|
|
30
32
|
regularPrice: MoneyProps;
|
|
@@ -35,7 +37,7 @@ export interface PriceDetails {
|
|
|
35
37
|
};
|
|
36
38
|
fixedProductTaxes: FixedProductTaxesProps[];
|
|
37
39
|
}
|
|
38
|
-
interface MoneyProps {
|
|
40
|
+
export interface MoneyProps {
|
|
39
41
|
value: number;
|
|
40
42
|
currency: string;
|
|
41
43
|
}
|
|
@@ -56,5 +58,10 @@ interface Attribute {
|
|
|
56
58
|
value?: string;
|
|
57
59
|
selected_options?: AttributeOption[];
|
|
58
60
|
}
|
|
61
|
+
interface Option {
|
|
62
|
+
uid: string;
|
|
63
|
+
required: boolean;
|
|
64
|
+
title: string;
|
|
65
|
+
}
|
|
59
66
|
export {};
|
|
60
67
|
//# sourceMappingURL=product.d.ts.map
|
|
@@ -13,7 +13,17 @@ export interface Item {
|
|
|
13
13
|
quantity: number;
|
|
14
14
|
description: string;
|
|
15
15
|
added_at: string;
|
|
16
|
+
selectedOptions: ConfigurableOption[];
|
|
17
|
+
enteredOptions?: {
|
|
18
|
+
uid: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}[];
|
|
16
21
|
product: Product;
|
|
17
22
|
customizableOptions: SelectedCustomizableOption[];
|
|
18
23
|
}
|
|
24
|
+
export interface ConfigurableOption {
|
|
25
|
+
value: string;
|
|
26
|
+
label: string;
|
|
27
|
+
uid: string;
|
|
28
|
+
}
|
|
19
29
|
//# sourceMappingURL=wishlist.d.ts.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Wishlist } from '../../models/wishlist';
|
|
2
2
|
|
|
3
|
-
declare const wishlist: Wishlist;
|
|
4
|
-
export
|
|
3
|
+
export declare const wishlist: Wishlist;
|
|
4
|
+
export declare const wishlistWithProductWithOptions: Wishlist;
|
|
5
|
+
export declare const wishlistWithProductOutOfStock: Wishlist;
|
|
6
|
+
export declare const wishlistWithProductWithoutDiscount: Wishlist;
|
|
7
|
+
export declare const wishlistWithProductWithoutTaxes: Wishlist;
|
|
5
8
|
//# sourceMappingURL=wishlistData.d.ts.map
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Wishlist } from '../models/wishlist';
|
|
2
2
|
|
|
3
|
-
export declare function transformWishlist(data: any
|
|
3
|
+
export declare function transformWishlist(data: any, enteredOptions?: {
|
|
4
|
+
uid: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}[]): Wishlist | null;
|
|
4
7
|
//# sourceMappingURL=transform-wishlist.d.ts.map
|
package/i18n/en_US.json.d.ts
CHANGED
package/lib/persisted-data.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Wishlist } from '../data/models';
|
|
2
2
|
|
|
3
3
|
export declare function setPersistedWishlistData(data: Wishlist | null): void;
|
|
4
|
-
export declare function getPersistedWishlistData(): Wishlist | {};
|
|
4
|
+
export declare function getPersistedWishlistData(guest?: boolean): Wishlist | {};
|
|
5
|
+
export declare function clearPersistedLocalStorage(): void;
|
|
5
6
|
export declare function getWishlistItemFromStorage(productSku: string): any;
|
|
6
7
|
//# sourceMappingURL=persisted-data.d.ts.map
|
package/lib/state.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-wishlist", "version": "0.2.
|
|
1
|
+
{"name": "@dropins/storefront-wishlist", "version": "0.2.2-alpha", "@dropins/tools": "~1.0.0", "license": "SEE LICENSE IN LICENSE.md"}
|
package/render.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
(function(r,i){try{if(typeof document<"u"){const
|
|
4
|
-
import{jsx as
|
|
3
|
+
(function(r,i){try{if(typeof document<"u"){const e=document.createElement("style"),n=i.styleId;for(const t in i.attributes)e.setAttribute(t,i.attributes[t]);e.setAttribute("data-dropin",n),e.appendChild(document.createTextNode(r));const a=document.querySelector('style[data-dropin="sdk"]');if(a)a.after(e);else{const t=document.querySelector('link[rel="stylesheet"], style');t?t.before(e):document.head.append(e)}}}catch(e){console.error("dropin-styles (injectCodeFunction)",e)}})(".wishlist-empty-wishlist{container-type:inline-size;container-name:wishlist}.wishlist-empty-wishlist__wrapper .dropin-card--secondary{display:grid;grid-auto-rows:min-content;justify-content:center;text-align:center;border:unset}.wishlist-empty-wishlist .dropin-illustrated-message__heading{font:var(--type-headline-1-font)}.wishlist-empty-wishlist .dropin-illustrated-message__message{font:var(--type-body-1-default-font)}@container wishlist (width < 737px){.wishlist-empty-wishlist__wrapper .dropin-card{border:unset;border-style:hidden}}.wishlist-wishlist{container-type:inline-size;container-name:wishlist-grid;max-width:inherit}.wishlist-wishlist__content{display:grid;gap:var(--spacing-medium);margin:auto;padding:var(--spacing-medium) 0}.wishlist-wishlist__heading{color:var(--color-neutral-800);display:grid;font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);padding:var(--spacing-small) 0;row-gap:var(--spacing-xsmall)}.wishlist-wishlist__heading-count{color:#6d6d6d;margin-left:var(--spacing-xxsmall);letter-spacing:normal;font:var(--type-details-caption-2-font)}.wishlist-wishlist__content.wishlist-wishlist__content--empty{border:var(--shape-border-width-2) solid var(--color-neutral-400);border-radius:var(--shape-border-radius-2);grid-template-columns:repeat(1,1fr);padding:var(--spacing-xxbig);margin:var(--spacing-xxbig) auto}@media only screen and (max-width: 480px){.wishlist-wishlist__content,.dropin-skeleton{grid-template-columns:repeat(1,1fr)}.dropin-skeleton-row:nth-child(n+2){display:none}}@media only screen and (min-width: 480px) and (max-width: 600px){.wishlist-wishlist__content,.dropin-skeleton{grid-template-columns:repeat(2,1fr)}.dropin-skeleton-row:nth-child(n+3){display:none}}@media only screen and (min-width: 600px){.wishlist-wishlist__content,.dropin-skeleton{grid-template-columns:repeat(2,1fr)}.dropin-skeleton-row:nth-child(n+3){display:none}}@media only screen and (min-width: 768px){.wishlist-wishlist__content,.dropin-skeleton{grid-template-columns:repeat(3,1fr)}.dropin-skeleton-row:nth-child(n){display:block}}.wishlist-product-item{background-color:var(--color-neutral-50);margin-bottom:var(--spacing-small)}.wishlist-product-item__content{display:flex;flex-direction:column;gap:var(--spacing-small)}.wishlist-product-item__content .wishlist-product-item-image{background:var(--color-neutral-200);height:100%;padding:0;width:100%}.wishlist-product-item__content .wishlist-product-item__title{color:var(--color-neutral-800);font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin:0;position:relative}.wishlist-product-item-name{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:85%}a.wishlist-product-item-name:active,a.wishlist-product-item-name:hover,a.wishlist-product-item-name{color:var(--color-neutral-800);cursor:pointer;font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing)}.wishlist-product-item__content .wishlist-product-item-button__remove{position:absolute;right:0;top:-10px}.wishlist-product-item__content .wishlist-product-item-price{display:inline;font:var(--type-body-2-default-font)}.strikeout{text-decoration:line-through}.wishlist-product-item__content .wishlist-product-item-discounted-price{display:inline;margin-left:var(--spacing-xsmall);color:var(--color-alert-800)}.wishlist-product-item-move-to-cart{display:grid;grid-area:product-add-to-cart;justify-content:end}.wishlist-product-item-tax{color:var(--color-neutral-500)}.wishlist-product-item-tax span{margin-right:var(--spacing-xsmall)}.image-carousel{display:flex;flex-direction:column;gap:var(--spacing-medium);padding:var(--spacing-medium)}.image-carousel .image-carousel-image{object-fit:contain;padding:var(--spacing-xxsmall) 0;width:100%}.image-switcher-area{margin-top:var(--spacing-small);text-align:center;width:100%}.image-switcher-area .image-switcher{cursor:pointer;border-radius:50%;display:inline-flex;height:var(--spacing-xsmall);margin:0 var(--spacing-xxsmall);width:var(--spacing-xsmall)}.image-switcher-area .image-switcher-active{background-color:var(--color-neutral-900);border:var(--shape-border-width-1) solid var(--color-brand-700)}.image-switcher-area .image-switcher-inactive{background-color:var(--color-neutral-600);border:var(--shape-border-width-1) solid var(--color-neutral-600)}@media only screen and (max-width: 480px){.image-carousel{gap:var(--spacing-xxsmall)}.image-carousel .image-carousel-image{height:250px}}@media only screen and (min-width: 480px) and (max-width: 600px){.image-carousel{gap:var(--spacing-xsmall)}.image-carousel .image-carousel-image{height:300px}}@media only screen and (min-width: 600px){.image-carousel{gap:var(--spacing-xsmall)}.image-carousel .image-carousel-image{height:300px}}@media only screen and (min-width: 768px){.image-carousel{gap:var(--spacing-small)}.image-carousel .image-carousel-image{height:350px}}@media only screen and (min-width: 1024px){.image-carousel{gap:var(--spacing-medium)}.image-carousel .image-carousel-image{height:400px}}.wishlist-login__sign-in{grid-column-start:2;color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-top:var(--spacing-xxsmall);text-align:center}a.wishlist-login__link{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-left:var(--spacing-xxsmall);text-decoration:underline;text-decoration-thickness:auto;text-underline-offset:auto;color:var(--color-neutral-800)}a.wishlist-login__link:hover{color:var(--color-neutral-800);text-decoration:underline;text-decoration-thickness:auto;text-underline-offset:auto}",{styleId:"Wishlist"});
|
|
4
|
+
import{jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{Render as n}from"@dropins/tools/lib.js";import{useState as d,useEffect as a}from"@dropins/tools/preact-hooks.js";import{UIProvider as c}from"@dropins/tools/components.js";import{events as m}from"@dropins/tools/event-bus.js";const h={EmptyWishlist:{heading:"Your wishlist is empty",message:"Add items by clicking on the heart icon.",cta:"Start shopping"},Wishlist:{heading:"Wishlist {count}",loading:"Loading..."},Alert:{addProduct:{heading:"Added to wishlist",message:"{product} has been added to your wishlist"},removeProduct:{heading:"Removed from wishlist",message:"{product} has been removed from your wishlist"},moveToCart:{heading:"Moved to cart",message:"{product} has been moved to your cart"},viewWishlist:"View wishlist"},Login:{sync:" to sync your saved items across all your devices.",logIn:"Log in"}},u={CartActionButton:"Move To Cart",TrashActionButton:"Remove this product from wishlist"},l={Wishlist:h,ProductItem:u},g={default:l},f=({children:e})=>{const[s,i]=d("en_US");return a(()=>{const t=m.on("locale",r=>{i(r)},{eager:!0});return()=>{t==null||t.off()}},[]),o(c,{lang:s,langDefinitions:g,children:e})},W=new n(o(f,{}));export{W as render};
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
/*! Copyright 2025 Adobe
|
|
2
|
-
All Rights Reserved. */
|
|
3
|
-
import{Initializer as R}from"@dropins/tools/lib.js";import{events as u}from"@dropins/tools/event-bus.js";import{s as r,i as A,f as g,h as T,g as E}from"./removeProductsFromWishlist.js";const S=new R({init:async e=>{const t={isGuestWishlistEnabled:!1,...e};S.config.setConfig(t),P().catch(console.error)},listeners:()=>[u.on("authenticated",e=>{r.authenticated&&!e&&u.emit("wishlist/reset",void 0),e&&!r.authenticated&&(r.authenticated=e,P().catch(console.error))},{eager:!0}),u.on("wishlist/data",e=>{A(e)}),u.on("wishlist/reset",()=>{K().catch(console.error),u.emit("wishlist/data",null)})]}),ee=S.config;function G(e){if(!e)return null;const t=i=>{switch(i){case 1:return"INCLUDING_FPT_AND_DESCRIPTION";case 2:return"EXCLUDING_FPT_INCLUDING_DESCRIPTION_FINAL_PRICE";case 3:return"EXCLUDING_FPT";default:return"INCLUDING_FPT_ONLY"}};return{wishlistIsEnabled:e.storeConfig.magento_wishlist_general_is_enabled,wishlistMultipleListIsEnabled:e.storeConfig.enable_multiple_wishlists,wishlistMaxNumber:e.storeConfig.maximum_number_of_wishlists,fixedProductTaxesEnabled:e.storeConfig.fixed_product_taxes_enable,fixedProductTaxesApply:e.storeConfig.fixed_product_taxes_apply_tax_to_fpt,fixedProductTaxesEnabledDisplayInProductLists:t(e.storeConfig.fixed_product_taxes_display_prices_in_product_lists),fixedProductTaxesEnabledDisplayInSalesModules:t(e.storeConfig.fixed_product_taxes_display_prices_in_sales_modules),fixedProductTaxesEnabledDisplayInProductView:t(e.storeConfig.fixed_product_taxes_display_prices_on_product_view_page)}}function b(e){var t;return e?{name:e.name,sku:e.sku,uid:e.uid,image:v(e),stockStatus:e.stock_status,canonicalUrl:e.canonical_url,urlKey:e.url_key,categories:(t=e.categories)==null?void 0:t.map(i=>i.name),prices:O(e),productAttributes:W(e)}:null}function v(e){var t,i;return{src:(t=e.thumbnail)==null?void 0:t.url,alt:(i=e.thumbnail)==null?void 0:i.label}}function O(e){var t,i,s,n,c,a,_,o,l,d,m,f,p,h,I,y,x,w;return{regularPrice:{currency:(s=(i=(t=e.price_range)==null?void 0:t.minimum_price)==null?void 0:i.regular_price)==null?void 0:s.currency,value:(a=(c=(n=e.price_range)==null?void 0:n.minimum_price)==null?void 0:c.regular_price)==null?void 0:a.value},finalPrice:{currency:(l=(o=(_=e.price_range)==null?void 0:_.minimum_price)==null?void 0:o.final_price)==null?void 0:l.currency,value:(f=(m=(d=e.price_range)==null?void 0:d.minimum_price)==null?void 0:m.final_price)==null?void 0:f.value},discount:{amountOff:(I=(h=(p=e.price_range)==null?void 0:p.minimum_price)==null?void 0:h.discount)==null?void 0:I.amount_off,percentOff:(w=(x=(y=e.price_range)==null?void 0:y.minimum_price)==null?void 0:x.discount)==null?void 0:w.percent_off},fixedProductTaxes:D(e)}}function W(e){var t,i;return(i=(t=e.custom_attributesV2)==null?void 0:t.items)==null?void 0:i.map(s=>{const n=s.code.split("_").map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join(" ");return{...s,code:n}})}function D(e){var t,i,s;return(s=(i=(t=e.price_range)==null?void 0:t.minimum_price)==null?void 0:i.fixed_product_taxes)==null?void 0:s.map(n=>({money:{value:n.amount.value,currency:n.amount.currency},label:n.label}))}function C(e){return e?{id:e.id,updated_at:e.updated_at,sharing_code:e.sharing_code,items_count:e.items_count,items:M(e)}:null}function M(e){var t,i;return(i=(t=e==null?void 0:e.items_v2)==null?void 0:t.items)!=null&&i.length?e.items_v2.items.map(s=>({id:s.id,quantity:s.quantity,description:s.description,added_at:s.added_at,product:b(s.product)})):[]}const F=`
|
|
4
|
-
query STORE_CONFIG_QUERY {
|
|
5
|
-
storeConfig {
|
|
6
|
-
magento_wishlist_general_is_enabled
|
|
7
|
-
enable_multiple_wishlists
|
|
8
|
-
maximum_number_of_wishlists
|
|
9
|
-
fixed_product_taxes_enable
|
|
10
|
-
fixed_product_taxes_apply_tax_to_fpt
|
|
11
|
-
fixed_product_taxes_display_prices_in_product_lists
|
|
12
|
-
fixed_product_taxes_display_prices_in_sales_modules
|
|
13
|
-
fixed_product_taxes_display_prices_on_product_view_page
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
`,U=async()=>g(F,{method:"GET",cache:"force-cache"}).then(({errors:e,data:t})=>e?T(e):G(t)),k=`
|
|
17
|
-
query GET_PRODUCT_BY_SKU($sku: String!) {
|
|
18
|
-
products(filter: { sku: { eq: $sku } }) {
|
|
19
|
-
items {
|
|
20
|
-
sku
|
|
21
|
-
name
|
|
22
|
-
thumbnail {
|
|
23
|
-
label
|
|
24
|
-
url
|
|
25
|
-
}
|
|
26
|
-
price_range {
|
|
27
|
-
minimum_price {
|
|
28
|
-
regular_price {
|
|
29
|
-
currency
|
|
30
|
-
value
|
|
31
|
-
}
|
|
32
|
-
final_price {
|
|
33
|
-
currency
|
|
34
|
-
value
|
|
35
|
-
}
|
|
36
|
-
discount {
|
|
37
|
-
amount_off
|
|
38
|
-
percent_off
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
stock_status
|
|
43
|
-
... on SimpleProduct {
|
|
44
|
-
stock_status
|
|
45
|
-
options {
|
|
46
|
-
uid
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
... on ConfigurableProduct {
|
|
50
|
-
configurable_options {
|
|
51
|
-
uid
|
|
52
|
-
attribute_uid
|
|
53
|
-
attribute_code
|
|
54
|
-
values {
|
|
55
|
-
uid
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
variants {
|
|
59
|
-
product {
|
|
60
|
-
sku
|
|
61
|
-
stock_status
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
... on BundleProduct {
|
|
66
|
-
items {
|
|
67
|
-
uid
|
|
68
|
-
title
|
|
69
|
-
options {
|
|
70
|
-
uid
|
|
71
|
-
label
|
|
72
|
-
quantity
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
`,L=async e=>{if(!e)throw Error("Product SKU is not set");return g(k,{variables:{sku:e}}).then(({errors:t,data:i})=>{var s;return t?T(t):(s=i==null?void 0:i.products)!=null&&s.items?b(i.products.items[0]):null})},$=`
|
|
80
|
-
fragment PRICE_RANGE_FRAGMENT on PriceRange {
|
|
81
|
-
minimum_price {
|
|
82
|
-
regular_price {
|
|
83
|
-
value
|
|
84
|
-
currency
|
|
85
|
-
}
|
|
86
|
-
final_price {
|
|
87
|
-
value
|
|
88
|
-
currency
|
|
89
|
-
}
|
|
90
|
-
discount {
|
|
91
|
-
percent_off
|
|
92
|
-
amount_off
|
|
93
|
-
}
|
|
94
|
-
fixed_product_taxes {
|
|
95
|
-
amount {
|
|
96
|
-
currency
|
|
97
|
-
value
|
|
98
|
-
}
|
|
99
|
-
label
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
maximum_price {
|
|
103
|
-
regular_price {
|
|
104
|
-
value
|
|
105
|
-
currency
|
|
106
|
-
}
|
|
107
|
-
final_price {
|
|
108
|
-
value
|
|
109
|
-
currency
|
|
110
|
-
}
|
|
111
|
-
discount {
|
|
112
|
-
percent_off
|
|
113
|
-
amount_off
|
|
114
|
-
}
|
|
115
|
-
fixed_product_taxes {
|
|
116
|
-
amount {
|
|
117
|
-
currency
|
|
118
|
-
value
|
|
119
|
-
}
|
|
120
|
-
label
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
`,H=`
|
|
125
|
-
fragment PRODUCT_FRAGMENT on ProductInterface {
|
|
126
|
-
name
|
|
127
|
-
sku
|
|
128
|
-
uid
|
|
129
|
-
thumbnail {
|
|
130
|
-
url
|
|
131
|
-
label
|
|
132
|
-
}
|
|
133
|
-
url_key
|
|
134
|
-
categories {
|
|
135
|
-
url_path
|
|
136
|
-
url_key
|
|
137
|
-
name
|
|
138
|
-
}
|
|
139
|
-
stock_status
|
|
140
|
-
canonical_url
|
|
141
|
-
custom_attributesV2(filters: {is_visible_on_front: true}){
|
|
142
|
-
items {
|
|
143
|
-
code
|
|
144
|
-
...on AttributeValue {
|
|
145
|
-
value
|
|
146
|
-
}
|
|
147
|
-
...on AttributeSelectedOptions {
|
|
148
|
-
selected_options {
|
|
149
|
-
value
|
|
150
|
-
label
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
price_range {
|
|
156
|
-
...PRICE_RANGE_FRAGMENT
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
${$}
|
|
161
|
-
`,z=`
|
|
162
|
-
fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {
|
|
163
|
-
type
|
|
164
|
-
customizable_option_uid
|
|
165
|
-
label
|
|
166
|
-
is_required
|
|
167
|
-
values {
|
|
168
|
-
label
|
|
169
|
-
value
|
|
170
|
-
price{
|
|
171
|
-
type
|
|
172
|
-
units
|
|
173
|
-
value
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
`,q=`
|
|
178
|
-
fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
|
|
179
|
-
__typename
|
|
180
|
-
id
|
|
181
|
-
quantity
|
|
182
|
-
description
|
|
183
|
-
added_at
|
|
184
|
-
product {
|
|
185
|
-
...PRODUCT_FRAGMENT
|
|
186
|
-
}
|
|
187
|
-
customizable_options {
|
|
188
|
-
...CUSTOMIZABLE_OPTIONS_FRAGMENT
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
${H}
|
|
193
|
-
${z}
|
|
194
|
-
`,N=`
|
|
195
|
-
fragment WISHLIST_FRAGMENT on Wishlist {
|
|
196
|
-
id
|
|
197
|
-
updated_at
|
|
198
|
-
sharing_code
|
|
199
|
-
items_count
|
|
200
|
-
items_v2 {
|
|
201
|
-
items {
|
|
202
|
-
...WISHLIST_ITEM_FRAGMENT
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
${q}
|
|
208
|
-
`,B=`
|
|
209
|
-
query GET_WISHLISTS_QUERY {
|
|
210
|
-
customer {
|
|
211
|
-
wishlists {
|
|
212
|
-
...WISHLIST_FRAGMENT
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
${N}
|
|
218
|
-
`,Y=async()=>r.authenticated?g(B).then(({errors:e,data:t})=>{var i;return e?T(e):(i=t==null?void 0:t.customer)!=null&&i.wishlists?t.customer.wishlists.map(s=>C(s)):null}):E(),Q=`
|
|
219
|
-
mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(
|
|
220
|
-
$wishlistId: ID!,
|
|
221
|
-
$wishlistItems: [WishlistItemInput!]!,
|
|
222
|
-
) {
|
|
223
|
-
addProductsToWishlist(
|
|
224
|
-
wishlistId: $wishlistId
|
|
225
|
-
wishlistItems: $wishlistItems
|
|
226
|
-
) {
|
|
227
|
-
wishlist {
|
|
228
|
-
...WISHLIST_FRAGMENT
|
|
229
|
-
}
|
|
230
|
-
user_errors {
|
|
231
|
-
code
|
|
232
|
-
message
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
${N}
|
|
237
|
-
`,te=async e=>{var s,n,c;const t=E();let i={id:(t==null?void 0:t.id)??"",items:(t==null?void 0:t.items)??[],updated_at:"",sharing_code:"",items_count:0};if(!e)return null;for(const a of e){if((s=t.items)==null?void 0:s.some(l=>l.product.sku===a.sku))continue;const o=await L(a.sku);o&&(i.items=[...i.items,{product:o}])}if(i.items_count=(n=i.items)==null?void 0:n.length,u.emit("wishlist/data",i),r.authenticated){if(!r.wishlistId)throw u.emit("wishlist/data",t),Error("Wishlist ID is not set");const a={wishlistId:r.wishlistId,wishlistItems:e.map(({sku:m,parentSku:f,quantity:p,optionsUIDs:h,enteredOptions:I})=>({sku:m,parent_sku:f,quantity:p,selected_options:h,entered_options:I}))},{errors:_,data:o}=await g(Q,{variables:a}),l=[...((c=o==null?void 0:o.addProductsToWishlist)==null?void 0:c.user_errors)??[],..._??[]];if(l.length>0)return u.emit("wishlist/data",t),T(l);const d=C(o.addProductsToWishlist.wishlist);u.emit("wishlist/data",d)}return null},K=()=>(r.wishlistId=null,r.authenticated=!1,Promise.resolve(null)),P=async()=>{if(r.initializing)return null;r.initializing=!0,r.config||(r.config=await U());const e=r.authenticated?await V():await Z();return u.emit("wishlist/initialized",e),u.emit("wishlist/data",e),r.initializing=!1,e};async function V(){const e=await Y(),t=e?e[0]:null;return t?(r.wishlistId=t.id,t):null}async function Z(){try{return await E()}catch(e){throw console.error(e),e}}export{q as W,te as a,N as b,ee as c,L as d,Y as e,P as f,U as g,V as h,S as i,Z as j,K as r,C as t};
|