@dropins/storefront-wishlist 0.2.3-alpha → 0.2.4-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/chunks/WishlistItem.js +1 -1
- package/chunks/mergeWishlists.js +30 -30
- package/containers/Wishlist.js +2 -2
- package/data/models/product.d.ts +5 -1
- package/data/models/wishlist.d.ts +2 -2
- package/i18n/en_US.json.d.ts +2 -1
- package/package.json +1 -1
- package/render.js +1 -1
package/chunks/WishlistItem.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as t,Fragment as
|
|
3
|
+
import{jsx as t,Fragment as g,jsxs as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as w}from"@dropins/tools/lib.js";import{Price as _,Button as T,Icon as R,Image as j}from"@dropins/tools/components.js";import{useState as V}from"@dropins/tools/preact-compat.js";import{s as y,r as K}from"./removeProductsFromWishlist.js";import{events as U}from"@dropins/tools/event-bus.js";import{a as X,S as Y}from"./Trash.js";import{useText as H}from"@dropins/tools/i18n.js";const J=({taxes:r,displayMode:e})=>t(g,{children:r.map((o,c)=>N("div",{"data-testid":`wishlist-product-item-tax-${c}`,className:"wishlist-product-item-tax",children:[t("span",{className:"wishlist-product-item-tax-label",children:o.label}),t(_,{className:"wishlist-product-item-tax-price",amount:o.money.value,currency:o.money.currency}),t("span",{className:"wishlist-product-item-tax-display-mode",children:e==="INCLUDING_FPT_AND_DESCRIPTION"?"incl.":"excl."})]},c))}),Q=({className:r,item:e,onCartActionButtonClick:o,onTrashButtonClick:c,fixedProductTaxesEnabled:P,fixedProductTaxesEnabledDisplayInProductLists:n,routeProdDetailPage:d,...i})=>{var A,C,B,O,S,E,z;const u=H({cartActionBtn:"ProductItem.CartActionButton",trashActionBtn:"ProductItem.TrashActionButton",customizeActionBtn:"ProductItem.CustomizeActionButton"}),v=((B=(C=(A=e.product)==null?void 0:A.prices)==null?void 0:C.discount)==null?void 0:B.amountOff)!==0||((E=(S=(O=e.product)==null?void 0:O.prices)==null?void 0:S.discount)==null?void 0:E.percentOff)!==0,f=()=>{var s;return t("a",{className:"wishlist-product-item-image","data-testid":"wishlist-product-item-image",href:d(e.product),children:t(Z,{images:(s=e.product)!=null&&s.image?[e.product.image]:[]})})},a=()=>{var s,l,h,p,I,m,x,b,F,G;return N(g,{children:[t(_,{className:w(["wishlist-product-item-price",v?"strikeout":""]),"data-testid":"wishlist-product-item-price",amount:(l=(s=e.product)==null?void 0:s.prices)==null?void 0:l.regularPrice.value,currency:(p=(h=e.product)==null?void 0:h.prices)==null?void 0:p.regularPrice.currency}),v&&t(_,{className:"wishlist-product-item-discounted-price","data-testid":"wishlist-product-item-discounted-price",amount:(m=(I=e.product)==null?void 0:I.prices)==null?void 0:m.finalPrice.value,currency:(b=(x=e.product)==null?void 0:x.prices)==null?void 0:b.finalPrice.currency}),P&&(n==="INCLUDING_FPT_AND_DESCRIPTION"||n==="EXCLUDING_FPT_INCLUDING_DESCRIPTION_FINAL_PRICE")&&((G=(F=e.product)==null?void 0:F.prices)==null?void 0:G.fixedProductTaxes)&&t(J,{taxes:e.product.prices.fixedProductTaxes,displayMode:n})]})},k=()=>t(T,{"data-testid":"wishlist-product-item-remove-button",className:"wishlist-product-item-button__remove",variant:"tertiary",onClick:()=>c==null?void 0:c(),icon:t(R,{source:X,size:"24",stroke:"2",viewBox:"0 0 24 24","aria-label":u.trashActionBtn})}),L=()=>M()?W():$(),M=()=>{var s,l,h,p;return((s=e.product)==null?void 0:s.type)==="ConfigurableProduct"?q(e):((l=e.product)==null?void 0:l.type)!=="GiftCardProduct"&&((h=e.product)==null?void 0:h.type)!=="BundleProduct"&&((p=e.product)==null?void 0:p.type)!=="GroupedProduct"},q=s=>{var p,I;const l=((p=s.product.options)==null?void 0:p.filter(m=>m.required))||[];if(l.length===0)return!0;const h=((I=s.selectedOptions)==null?void 0:I.map(m=>m.uid))||[];return l.every(m=>{var x;return(x=m.values)==null?void 0:x.some(b=>h.includes(b.uid))})},W=()=>{var s;return t(T,{"data-testid":"wishlist-product-item-move-to-cart-button",size:"medium",type:"submit",icon:t(R,{source:Y}),disabled:((s=e.product)==null?void 0:s.stockStatus)!=="IN_STOCK","aria-label":u.cartActionBtn,onClick:()=>o==null?void 0:o(),children:u.cartActionBtn})},$=()=>t(T,{"data-testid":"wishlist-product-item-customize-button",size:"medium",type:"submit","aria-label":u.customizeActionBtn,href:d(e.product),children:u.customizeActionBtn});return t("div",{...i,className:w(["wishlist-product-item",r]),children:N("div",{className:"wishlist-product-item__content",children:[f(),N("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(e.product),children:(z=e.product)==null?void 0:z.name}),k(),a()]}),L()]})})},Z=({className:r,children:e,images:o,...c})=>{const[P,n]=V(0);return N(g,{children:[t("div",{...c,className:w(["image-carousel",r]),children:t("div",{className:w(["overflow-hidden relative max-w-[200px]",r]),children:o==null?void 0:o.map((d,i)=>i===P&&t(j,{className:"image-carousel-image",alt:d.alt,src:d.src}))})}),(o==null?void 0:o.length)>1&&t("div",{className:w(["absolute","image-switcher-area"]),children:o==null?void 0:o.map((d,i)=>t("span",{className:w(["image-switcher",P===i?"image-switcher-active":"image-switcher-inactive"]),onClick:u=>{n(i),u.stopPropagation()}},i))})]})},ie=({initialData:r=null,moveProdToCart:e,routeProdDetailPage:o})=>{var n,d,i,u,v;if(!(r!=null&&r.product))return null;const c=async(f=!0)=>{try{return await K([r]),console.log(`Product ${r.product.sku} removed from wishlist!`),f&&U.emit("wishlist/alert",{action:"remove",item:r}),!0}catch(a){return console.error(`Product ${r.product.sku} could not be removed from wishlist`,a),!1}};return t(Q,{item:r,onCartActionButtonClick:async()=>{var f;try{return await e([{sku:r.product.sku,quantity:1,optionsUIDs:(f=r.selectedOptions)==null?void 0:f.map(a=>a.uid),enteredOptions:r.enteredOptions}]),console.log(`Product ${r.product.sku} successfully moved to cart 🛒`),U.emit("wishlist/alert",{action:"move",item:r}),await c(!1)}catch(a){return console.error("Could not move product to cart: ",a),a.toString().includes("You need to choose options for your item.")&&window.location.replace(o(r.product)),!1}},onTrashButtonClick:c,fixedProductTaxesEnabled:((n=y.config)==null?void 0:n.fixedProductTaxesEnabled)??!1,fixedProductTaxesApply:((d=y.config)==null?void 0:d.fixedProductTaxesApply)??!1,fixedProductTaxesEnabledDisplayInProductLists:(i=y.config)==null?void 0:i.fixedProductTaxesEnabledDisplayInProductLists,fixedProductTaxesEnabledDisplayInProductView:(u=y.config)==null?void 0:u.fixedProductTaxesEnabledDisplayInProductView,fixedProductTaxesEnabledDisplayInSalesModules:(v=y.config)==null?void 0:v.fixedProductTaxesEnabledDisplayInSalesModules,routeProdDetailPage:o})};export{ie as W};
|
package/chunks/mergeWishlists.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{Initializer as
|
|
3
|
+
import{Initializer as A}from"@dropins/tools/lib.js";import{events as _}from"@dropins/tools/event-bus.js";import{s as o,j as D,f as E,h as b,g as y,i as R,k as G}from"./removeProductsFromWishlist.js";const C=new A({init:async e=>{const t={isGuestWishlistEnabled:!1,...e};C.config.setConfig(t),S().catch(console.error)},listeners:()=>[_.on("authenticated",async e=>{if(o.authenticated&&!e&&_.emit("wishlist/reset",void 0),e&&!o.authenticated){o.authenticated=e;const t=await S().catch(console.error);t&&le(t)}},{eager:!0}),_.on("wishlist/data",e=>{D(e)}),_.on("wishlist/reset",()=>{ae().catch(console.error),_.emit("wishlist/data",null)})]}),fe=C.config;function v(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 N(e){var t;return e?{type:e.__typename,name:e.name,sku:e.sku,uid:e.uid,image:M(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:W(e),productAttributes:F(e),options:U(e)}:null}function U(e){var t,i;return e.__typename==="ConfigurableProduct"?e.configurable_options?(t=e.configurable_options)==null?void 0:t.map(s=>{var n;return{uid:s.uid,attributeUid:s.attribute_uid,attributeCode:s.attribute_code,values:(n=s.values)==null?void 0:n.map(r=>({uid:r.uid})),required:!0}}):[]:e.__typename==="GiftCardProduct"?e.gift_card_options?(i=e.gift_card_options)==null?void 0:i.map(s=>({uid:s.uid,required:s.required,title:s.title})):[]:[]}function M(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,n,r,a,p,u,c,l,d,m,f,I,g,h,T,P;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:((a=(r=(n=e.price_range)==null?void 0:n.minimum_price)==null?void 0:r.regular_price)==null?void 0:a.value)??0},finalPrice:{currency:((c=(u=(p=e.price_range)==null?void 0:p.minimum_price)==null?void 0:u.final_price)==null?void 0:c.currency)??"USD",value:((m=(d=(l=e.price_range)==null?void 0:l.minimum_price)==null?void 0:d.final_price)==null?void 0:m.value)??0},discount:{amountOff:((g=(I=(f=e.price_range)==null?void 0:f.minimum_price)==null?void 0:I.discount)==null?void 0:g.amount_off)??0,percentOff:((P=(T=(h=e.price_range)==null?void 0:h.minimum_price)==null?void 0:T.discount)==null?void 0:P.percent_off)??0},fixedProductTaxes:L(e)}}function F(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(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ");return{...s,code:n}})}function L(e){var t,i,s,n,r;return(i=(t=e.price_range)==null?void 0:t.minimum_price)!=null&&i.fixed_product_taxes?(r=(n=(s=e.price_range)==null?void 0:s.minimum_price)==null?void 0:n.fixed_product_taxes)==null?void 0:r.map(a=>({money:{value:a.amount.value,currency:a.amount.currency},label:a.label})):[]}function w(e,t){return e?{id:e.id,updated_at:e.updated_at,sharing_code:e.sharing_code,items_count:e.items_count,items:k(e,t??[])}:null}function k(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(n=>({id:n.id,quantity:n.quantity,description:n.description,added_at:n.added_at,enteredOptions:t,selectedOptions:$(n),product:N(n.product)})):[]}function $(e){return e.product.__typename==="ConfigurableProduct"?e.configurable_options?e.configurable_options.map(t=>({value:t.value_label,label:t.option_label,uid:t.configurable_product_option_value_uid})):[]:[]}const q=`
|
|
4
4
|
query STORE_CONFIG_QUERY {
|
|
5
5
|
storeConfig {
|
|
6
6
|
magento_wishlist_general_is_enabled
|
|
@@ -13,7 +13,7 @@ query STORE_CONFIG_QUERY {
|
|
|
13
13
|
fixed_product_taxes_display_prices_on_product_view_page
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
`,H=async()=>E(q,{method:"GET",cache:"force-cache"}).then(({errors:e,data:t})=>e?b(e):v(t)),B=`
|
|
17
17
|
fragment PRICE_RANGE_FRAGMENT on PriceRange {
|
|
18
18
|
minimum_price {
|
|
19
19
|
regular_price {
|
|
@@ -58,7 +58,7 @@ query STORE_CONFIG_QUERY {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
`,
|
|
61
|
+
`,x=`
|
|
62
62
|
fragment PRODUCT_FRAGMENT on ProductInterface {
|
|
63
63
|
__typename
|
|
64
64
|
uid
|
|
@@ -95,14 +95,14 @@ query STORE_CONFIG_QUERY {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
${
|
|
99
|
-
`,
|
|
98
|
+
${B}
|
|
99
|
+
`,z=`
|
|
100
100
|
... on SimpleProduct {
|
|
101
101
|
options {
|
|
102
102
|
uid
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
`,
|
|
105
|
+
`,Y=`
|
|
106
106
|
... on ConfigurableProduct {
|
|
107
107
|
configurable_options {
|
|
108
108
|
uid
|
|
@@ -119,14 +119,14 @@ ${q}
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
`,
|
|
122
|
+
`,Q=`
|
|
123
123
|
... on DownloadableProduct {
|
|
124
124
|
image {
|
|
125
125
|
label
|
|
126
126
|
url
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
`,
|
|
129
|
+
`,K=`
|
|
130
130
|
... on GiftCardProduct {
|
|
131
131
|
giftcard_type
|
|
132
132
|
giftcard_amounts {
|
|
@@ -147,7 +147,7 @@ ${q}
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
`,
|
|
150
|
+
`,V=`
|
|
151
151
|
... on BundleProduct {
|
|
152
152
|
items {
|
|
153
153
|
uid
|
|
@@ -160,22 +160,22 @@ ${q}
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
`,
|
|
163
|
+
`,j=`
|
|
164
164
|
query GET_PRODUCT_BY_SKU($sku: String!) {
|
|
165
165
|
products(filter: { sku: { eq: $sku } }) {
|
|
166
166
|
items {
|
|
167
167
|
...PRODUCT_FRAGMENT
|
|
168
|
-
${H}
|
|
169
|
-
${B}
|
|
170
168
|
${z}
|
|
171
169
|
${Y}
|
|
172
170
|
${Q}
|
|
171
|
+
${K}
|
|
172
|
+
${V}
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
${
|
|
178
|
-
`,
|
|
177
|
+
${x}
|
|
178
|
+
`,Z=async e=>{if(!e)throw Error("Product SKU is not set");return E(j,{variables:{sku:e}}).then(({errors:t,data:i})=>{var s;return t?b(t):(s=i==null?void 0:i.products)!=null&&s.items?N(i.products.items[0]):null})},X=`
|
|
179
179
|
fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {
|
|
180
180
|
type
|
|
181
181
|
customizable_option_uid
|
|
@@ -191,7 +191,7 @@ ${C}
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
`,
|
|
194
|
+
`,J=`
|
|
195
195
|
... on ConfigurableWishlistItem {
|
|
196
196
|
configurable_options {
|
|
197
197
|
option_label
|
|
@@ -203,7 +203,7 @@ ${C}
|
|
|
203
203
|
canonical_url
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
`,
|
|
206
|
+
`,ee=`
|
|
207
207
|
... on DownloadableWishlistItem {
|
|
208
208
|
added_at
|
|
209
209
|
description
|
|
@@ -215,7 +215,7 @@ ${C}
|
|
|
215
215
|
}
|
|
216
216
|
quantity
|
|
217
217
|
}
|
|
218
|
-
`,
|
|
218
|
+
`,te=`
|
|
219
219
|
... on GiftCardWishlistItem {
|
|
220
220
|
added_at
|
|
221
221
|
description
|
|
@@ -235,7 +235,7 @@ ${C}
|
|
|
235
235
|
sender_name
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
`,
|
|
238
|
+
`,ie=`
|
|
239
239
|
... on BundleWishlistItem {
|
|
240
240
|
bundle_options {
|
|
241
241
|
label
|
|
@@ -248,7 +248,7 @@ ${C}
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
`,
|
|
251
|
+
`,se=`
|
|
252
252
|
fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
|
|
253
253
|
__typename
|
|
254
254
|
id
|
|
@@ -258,18 +258,18 @@ fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
|
|
|
258
258
|
product {
|
|
259
259
|
...PRODUCT_FRAGMENT
|
|
260
260
|
}
|
|
261
|
-
${Z}
|
|
262
|
-
${X}
|
|
263
261
|
${J}
|
|
264
262
|
${ee}
|
|
263
|
+
${te}
|
|
264
|
+
${ie}
|
|
265
265
|
customizable_options {
|
|
266
266
|
...CUSTOMIZABLE_OPTIONS_FRAGMENT
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
${
|
|
271
|
-
${
|
|
272
|
-
`,
|
|
270
|
+
${x}
|
|
271
|
+
${X}
|
|
272
|
+
`,O=`
|
|
273
273
|
fragment WISHLIST_FRAGMENT on Wishlist {
|
|
274
274
|
id
|
|
275
275
|
updated_at
|
|
@@ -282,8 +282,8 @@ fragment WISHLIST_FRAGMENT on Wishlist {
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
${
|
|
286
|
-
`,
|
|
285
|
+
${se}
|
|
286
|
+
`,ne=`
|
|
287
287
|
query GET_WISHLISTS_QUERY {
|
|
288
288
|
customer {
|
|
289
289
|
wishlists {
|
|
@@ -292,8 +292,8 @@ ${te}
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
${
|
|
296
|
-
`,
|
|
295
|
+
${O}
|
|
296
|
+
`,re=async()=>o.authenticated?E(ne).then(({errors:e,data:t})=>{var i;return e?b(e):(i=t==null?void 0:t.customer)!=null&&i.wishlists?t.customer.wishlists.map(s=>w(s)):null}):y(),oe=`
|
|
297
297
|
mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(
|
|
298
298
|
$wishlistId: ID!,
|
|
299
299
|
$wishlistItems: [WishlistItemInput!]!,
|
|
@@ -311,5 +311,5 @@ ${te}
|
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
${
|
|
315
|
-
`,
|
|
314
|
+
${O}
|
|
315
|
+
`,ue=async e=>{var s,n,r,a,p;if(!e)return null;const t=y();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 u of e){if((s=t.items)==null?void 0:s.some(d=>R(d,{sku:u.sku,optionUIDs:u.optionsUIDs})))continue;const l=await Z(u.sku);l&&(i.items=[...i.items,{quantity:u.quantity,selectedOptions:u.optionsUIDs?(n=u.optionsUIDs)==null?void 0:n.map(d=>({uid:d})):[],enteredOptions:[],product:l}])}if(i.items_count=(r=i.items)==null?void 0:r.length,_.emit("wishlist/data",i),o.authenticated){if(!o.wishlistId)throw _.emit("wishlist/data",t),Error("Wishlist ID is not set");const u={wishlistId:o.wishlistId,wishlistItems:e.map(({sku:f,parentSku:I,quantity:g,optionsUIDs:h,enteredOptions:T})=>({sku:f,parent_sku:I,quantity:g,selected_options:h,entered_options:T}))},{errors:c,data:l}=await E(oe,{variables:u}),d=[...((a=l==null?void 0:l.addProductsToWishlist)==null?void 0:a.user_errors)??[],...c??[]];if(d.length>0)return _.emit("wishlist/data",t),b(d);const m=w(l.addProductsToWishlist.wishlist,((p=e[0])==null?void 0:p.enteredOptions)??[]);_.emit("wishlist/data",m)}return null},ae=()=>(o.wishlistId=null,o.authenticated=!1,Promise.resolve(null)),S=async()=>{if(o.initializing)return null;o.initializing=!0,o.config||(o.config=await H());const e=o.authenticated?await ce():await _e();return _.emit("wishlist/initialized",e),_.emit("wishlist/data",e),o.initializing=!1,e};async function ce(){const e=await re(),t=e?e[0]:null;return t?(o.wishlistId=t.id,t):null}async function _e(){try{return await y()}catch(e){throw console.error(e),e}}const le=async e=>{var n;if(!e)return null;const t=y(!0),i=[];if((n=t==null?void 0:t.items)==null||n.forEach(r=>{var u;const a=((u=r.selectedOptions)==null?void 0:u.map(c=>c.uid))||[];if(!e.items.some(c=>R(c,{sku:r.product.sku,optionUIDs:a}))){const c={sku:r.product.sku,quantity:1,optionsUIDs:a,enteredOptions:r.enteredOptions||void 0};i.push(c)}}),i.length===0)return null;const s=await ue(i);return G(),s};export{se as W,ue as a,O as b,fe as c,Z as d,re as e,S as f,H as g,ce as h,C as i,_e as j,le as m,ae as r,w as t};
|
package/containers/Wishlist.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as i,jsxs as d,Fragment as H}from"@dropins/tools/preact-jsx-runtime.js";import{useState as
|
|
3
|
+
import{jsx as i,jsxs as d,Fragment as H}from"@dropins/tools/preact-jsx-runtime.js";import{useState as u,useCallback as j,useEffect as F,useMemo as k,Fragment as B}from"@dropins/tools/preact-compat.js";import{classes as v,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:v(["wishlist-empty-wishlist",l]),children:i(z,{className:v(["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
4
|
<svg
|
|
5
5
|
width="100%"
|
|
6
6
|
height="100%"
|
|
@@ -14,4 +14,4 @@ import{jsx as i,jsxs as d,Fragment as H}from"@dropins/tools/preact-jsx-runtime.j
|
|
|
14
14
|
<rect x="6" y="556" width="132" height="22" rx="4" fill="#E8E8E8" />
|
|
15
15
|
<rect x="6" y="592" width="280" height="48" rx="24" fill="#D9D9D9" />
|
|
16
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]=
|
|
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]=u(null),[N,_]=u(b.authenticated),[L,g]=u(b.isLoading),W=n=>_(n),[p,a]=u(null),x=j(n=>{const{action:o,item:h}=n;a(i(J,{action:o,item:h}))},[s]);return F(()=>{const n=I.on("authenticated",W),o=I.on("wishlist/alert",t=>x(t)),h=I.on("wishlist/data",t=>{m(t),g(!1)});return()=>{n==null||n.off(),h==null||h.off(),o==null||o.off()}},[x]),i(U,{...r,wishlistData:f,wishlistAlert:p,routeEmptyWishlistCTA:l,moveProdToCart:e,isLoggedIn:N,isLoading:L,routeProdDetailPage:c})},U=({className:l,wishlistData:s,wishlistAlert:e,isLoggedIn:c,isLoading:r,moveProdToCart:f,routeEmptyWishlistCTA:m,onLoginClick:N,routeProdDetailPage:_,...L})=>{const[g,W]=u(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(y=>{var w;return i(G,{initialData:y,moveProdToCart:f,routeProdDetailPage:_},(w=y.product)==null?void 0:w.sku)}):null},[s,f,_]);F(()=>{if(e){W(e);const t=setTimeout(()=>{W(null)},5e3);return()=>clearTimeout(t)}},[e]);const x=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:v(["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:N})]})}),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((y,w)=>{var E;return d(B,{children:[y,w===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())+w)})})}):null},[p,a,s]);return d("div",{...L,className:v(["wishlist-wishlist",l]),children:[x,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};
|
package/data/models/product.d.ts
CHANGED
|
@@ -60,8 +60,12 @@ interface Attribute {
|
|
|
60
60
|
}
|
|
61
61
|
interface Option {
|
|
62
62
|
uid: string;
|
|
63
|
+
attributeCode?: string;
|
|
64
|
+
attributeUid?: string;
|
|
63
65
|
required: boolean;
|
|
64
|
-
|
|
66
|
+
values: [{
|
|
67
|
+
uid: string;
|
|
68
|
+
}];
|
|
65
69
|
}
|
|
66
70
|
export {};
|
|
67
71
|
//# sourceMappingURL=product.d.ts.map
|
|
@@ -22,8 +22,8 @@ export interface Item {
|
|
|
22
22
|
customizableOptions: SelectedCustomizableOption[];
|
|
23
23
|
}
|
|
24
24
|
export interface ConfigurableOption {
|
|
25
|
-
value: string;
|
|
26
|
-
label: string;
|
|
27
25
|
uid: string;
|
|
26
|
+
label: string;
|
|
27
|
+
value: string;
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=wishlist.d.ts.map
|
package/i18n/en_US.json.d.ts
CHANGED
|
@@ -31,7 +31,8 @@ declare const _default: {
|
|
|
31
31
|
},
|
|
32
32
|
"ProductItem": {
|
|
33
33
|
"CartActionButton": "Move To Cart",
|
|
34
|
-
"TrashActionButton": "Remove this product from wishlist"
|
|
34
|
+
"TrashActionButton": "Remove this product from wishlist",
|
|
35
|
+
"CustomizeActionButton": "Customize"
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-wishlist", "version": "0.2.
|
|
1
|
+
{"name": "@dropins/storefront-wishlist", "version": "0.2.4-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
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})},
|
|
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",CustomizeActionButton:"Customize"},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})},P=new n(o(f,{}));export{P as render};
|