@dropins/storefront-wishlist 3.0.0 → 3.1.0-beta2

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{W as c,t as h,b as m}from"./chunks/mergeWishlists.js";import{a as G,c as H,f as F,h as v,g as L,d as U,i as A,e as M,m as N,r as R}from"./chunks/mergeWishlists.js";import{s as l,g as u,f as a,h as I}from"./chunks/removeProductsFromWishlist.js";import{k as O,e as Q,l as y,c as b,r as C,a as Y,b as x,d as B,j as z}from"./chunks/removeProductsFromWishlist.js";import{events as _}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";const d=`
3
+ import{W as c,t as h,b as m}from"./chunks/mergeWishlists.js";import{a as G,c as H,g as F,d as v,e as L,f as U,i as A,h as M,m as N,r as R}from"./chunks/mergeWishlists.js";import{s as l,g as u,f as a,h as I}from"./chunks/removeProductsFromWishlist.js";import{c as O,a as Q,b as y,d as b,r as C,e as Y,j as x,k as B,l as z}from"./chunks/removeProductsFromWishlist.js";import{events as _}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
  ) {
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{Initializer as y}from"@dropins/tools/lib.js";import{events as r}from"@dropins/tools/event-bus.js";import{j as A,s as e,f as I,h as p,g as h,i as T,k as G}from"./removeProductsFromWishlist.js";const g=new y({init:async t=>{const s={isGuestWishlistEnabled:!1,...t};g.config.setConfig(s),f().catch(console.error)},listeners:()=>[r.on("wishlist/data",t=>{A(t)},{eager:!0}),r.on("authenticated",async t=>{if(e.authenticated&&!t&&r.emit("wishlist/reset",void 0),t&&!e.authenticated){e.authenticated=t;const s=await f().catch(console.error);s&&Z(s)}},{eager:!0}),r.on("wishlist/reset",()=>{B().catch(console.error),r.emit("wishlist/data",null)})]}),V=g.config;function N(t){return t?{wishlistIsEnabled:t.storeConfig.magento_wishlist_general_is_enabled,wishlistMultipleListIsEnabled:t.storeConfig.enable_multiple_wishlists,wishlistMaxNumber:t.storeConfig.maximum_number_of_wishlists}:null}function w(t,s){return t?{id:t.id,updated_at:t.updated_at,sharing_code:t.sharing_code,items_count:t.items_count,items:L(t,s??[])}:null}function L(t,s){var i,a;return(a=(i=t==null?void 0:t.items_v2)==null?void 0:i.items)!=null&&a.length?t.items_v2.items.map(n=>{const l=R(n);return{id:n.id,quantity:n.quantity,description:n.description,added_at:n.added_at,enteredOptions:s,selectedOptions:l,product:{sku:n.product.sku}}}):[]}function R(t){return t.__typename==="ConfigurableWishlistItem"?t.configurable_options?t.configurable_options.map(s=>({uid:s.configurable_product_option_value_uid})):[]:t.__typename==="BundleWishlistItem"?(t.bundle_options??[]).flatMap(i=>i.values??[]).map(i=>({uid:i.uid})):[]}const D=`
3
+ import{Initializer as y}from"@dropins/tools/lib.js";import{events as r}from"@dropins/tools/event-bus.js";import{l as A,s as e,f as I,h as p,g as h,i as T,c as G}from"./removeProductsFromWishlist.js";const g=new y({init:async t=>{const s={isGuestWishlistEnabled:!1,...t};g.config.setConfig(s),f().catch(console.error)},listeners:()=>[r.on("wishlist/data",t=>{A(t)},{eager:!0}),r.on("authenticated",async t=>{if(e.authenticated&&!t&&r.emit("wishlist/reset",void 0),t&&!e.authenticated){e.authenticated=t;const s=await f().catch(console.error);s&&Z(s)}},{eager:!0}),r.on("wishlist/reset",()=>{B().catch(console.error),r.emit("wishlist/data",null)})]}),V=g.config;function N(t){return t?{wishlistIsEnabled:t.storeConfig.magento_wishlist_general_is_enabled,wishlistMultipleListIsEnabled:t.storeConfig.enable_multiple_wishlists,wishlistMaxNumber:t.storeConfig.maximum_number_of_wishlists}:null}function w(t,s){return t?{id:t.id,updated_at:t.updated_at,sharing_code:t.sharing_code,items_count:t.items_count,items:L(t,s??[])}:null}function L(t,s){var i,l;return(l=(i=t==null?void 0:t.items_v2)==null?void 0:i.items)!=null&&l.length?t.items_v2.items.map(n=>{const a=R(n);return{id:n.id,quantity:n.quantity,description:n.description,added_at:n.added_at,enteredOptions:s,selectedOptions:a,product:{sku:n.product.sku}}}):[]}function R(t){return t.__typename==="ConfigurableWishlistItem"?t.configurable_options?t.configurable_options.map(s=>({uid:s.configurable_product_option_value_uid})):[]:t.__typename==="BundleWishlistItem"?(t.bundle_options??[]).flatMap(i=>i.values??[]).map(i=>({uid:i.uid})):[]}const D=`
4
4
  query STORE_CONFIG_QUERY {
5
5
  storeConfig {
6
6
  magento_wishlist_general_is_enabled
@@ -48,7 +48,7 @@ query STORE_CONFIG_QUERY {
48
48
  }
49
49
  quantity
50
50
  }
51
- `,k=`
51
+ `,H=`
52
52
  ... on GiftCardWishlistItem {
53
53
  added_at
54
54
  description
@@ -68,7 +68,7 @@ query STORE_CONFIG_QUERY {
68
68
  sender_name
69
69
  }
70
70
  }
71
- `,H=`
71
+ `,k=`
72
72
  ... on BundleWishlistItem {
73
73
  bundle_options {
74
74
  label
@@ -93,8 +93,8 @@ fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
93
93
  }
94
94
  ${U}
95
95
  ${F}
96
- ${k}
97
96
  ${H}
97
+ ${k}
98
98
  customizable_options {
99
99
  ...CUSTOMIZABLE_OPTIONS_FRAGMENT
100
100
  }
@@ -125,7 +125,7 @@ ${P}
125
125
  }
126
126
 
127
127
  ${S}
128
- `,q=async()=>e.authenticated?I($).then(({errors:t,data:s})=>{var i;return t?p(t):(i=s==null?void 0:s.customer)!=null&&i.wishlists?s.customer.wishlists.map(a=>w(a)):null}):h(),z=`
128
+ `,q=async()=>e.authenticated?I($).then(({errors:t,data:s})=>{var i;return t?p(t):(i=s==null?void 0:s.customer)!=null&&i.wishlists?s.customer.wishlists.map(l=>w(l)):null}):h(),z=`
129
129
  mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(
130
130
  $wishlistId: ID!,
131
131
  $wishlistItems: [WishlistItemInput!]!,
@@ -144,5 +144,5 @@ ${P}
144
144
  }
145
145
  }
146
146
  ${S}
147
- `,x=async t=>{var a,n,l,d,m;if(!t)return null;const s=h();let i={id:(s==null?void 0:s.id)??"",updated_at:"",sharing_code:"",items_count:0,items:(s==null?void 0:s.items)??[]};for(const o of t){if((a=i.items)==null?void 0:a.some(_=>T(_,{sku:o.sku,optionUIDs:o.optionsUIDs})))continue;const c=o.optionsUIDs?(n=o.optionsUIDs)==null?void 0:n.map(_=>({uid:_})):[];i.items=[...i.items,{id:crypto.randomUUID(),quantity:o.quantity,selectedOptions:c,enteredOptions:o.enteredOptions??[],product:{sku:o.sku}}]}if(i.items_count=(l=i.items)==null?void 0:l.length,r.emit("wishlist/data",i),e.authenticated){if(!e.wishlistId)throw r.emit("wishlist/data",s),Error("Wishlist ID is not set");const o={wishlistId:e.wishlistId,wishlistItems:t.map(({sku:W,quantity:b,optionsUIDs:O,enteredOptions:M})=>({sku:W,quantity:b,selected_options:O,entered_options:M}))},{errors:u,data:c}=await I(z,{variables:o}),_=[...((d=c==null?void 0:c.addProductsToWishlist)==null?void 0:d.user_errors)??[],...u??[]];if(_.length>0)return r.emit("wishlist/data",s),p(_);const E=w(c.addProductsToWishlist.wishlist,((m=t[0])==null?void 0:m.enteredOptions)??[]);r.emit("wishlist/data",E)}return null},B=()=>(e.wishlistId=null,e.authenticated=!1,Promise.resolve(null)),f=async()=>{if(e.initializing)return null;e.initializing=!0,e.config||(e.config=await v());const t=e.authenticated?await Q():await Y();return r.emit("wishlist/initialized",t),r.emit("wishlist/data",t),e.initializing=!1,t};async function Q(){const t=await q(),s=t?t[0]:null;return s?(e.wishlistId=s.id,s):null}async function Y(){try{return await h()}catch(t){throw console.error(t),t}}const Z=async t=>{var n;if(!t)return null;const s=h(!0),i=[];if((n=s==null?void 0:s.items)==null||n.forEach(l=>{var o;const d=((o=l.selectedOptions)==null?void 0:o.map(u=>u.uid))||[];if(!t.items.some(u=>T(u,{sku:l.product.sku,optionUIDs:d}))){const u={sku:l.product.sku,quantity:1,optionsUIDs:d,enteredOptions:l.enteredOptions||void 0};i.push(u)}}),i.length===0)return null;const a=await x(i);return G(),a};export{P as W,x as a,S as b,V as c,q as d,f as e,Q as f,v as g,Y as h,g as i,Z as m,B as r,w as t};
147
+ `,x=async t=>{var l,n,a,d,m;if(!t)return null;const s=h();let i={id:(s==null?void 0:s.id)??"",updated_at:"",sharing_code:"",items_count:0,items:(s==null?void 0:s.items)??[]};for(const o of t){if((l=i.items)==null?void 0:l.some(_=>T(_,{sku:o.sku,optionUIDs:o.optionsUIDs})))continue;const c=o.optionsUIDs?(n=o.optionsUIDs)==null?void 0:n.map(_=>({uid:_})):[];i.items=[...i.items,{id:crypto.randomUUID(),quantity:o.quantity,selectedOptions:c,enteredOptions:o.enteredOptions??[],product:{sku:o.sku}}]}if(i.items_count=(a=i.items)==null?void 0:a.length,r.emit("wishlist/data",i),e.authenticated){if(!e.wishlistId)throw r.emit("wishlist/data",s),Error("Wishlist ID is not set");const o={wishlistId:e.wishlistId,wishlistItems:t.map(({sku:W,quantity:b,optionsUIDs:O,enteredOptions:M})=>({sku:W,quantity:b,selected_options:O,entered_options:M}))},{errors:u,data:c}=await I(z,{variables:o}),_=[...((d=c==null?void 0:c.addProductsToWishlist)==null?void 0:d.user_errors)??[],...u??[]];if(_.length>0)return r.emit("wishlist/data",s),p(_);const E=w(c.addProductsToWishlist.wishlist,((m=t[0])==null?void 0:m.enteredOptions)??[]);r.emit("wishlist/data",E)}return null},B=()=>(e.wishlistId=null,e.authenticated=!1,Promise.resolve(null)),f=async()=>{if(e.initializing)return null;e.initializing=!0,e.config||(e.config=await v());const t=e.authenticated?await Q():await Y();return r.emit("wishlist/initialized",t),r.emit("wishlist/data",t),e.initializing=!1,t};async function Q(){const t=await q(),s=t?t[0]:null;return s?(e.wishlistId=s.id,s):null}async function Y(){try{return await h()}catch(t){throw console.error(t),t}}const Z=async t=>{var n;if(!t)return null;const s=h(!0),i=[];if((n=s==null?void 0:s.items)==null||n.forEach(a=>{var o;const d=((o=a.selectedOptions)==null?void 0:o.map(u=>u.uid))||[];if(!t.items.some(u=>T(u,{sku:a.product.sku,optionUIDs:d}))){const u={sku:a.product.sku,quantity:1,optionsUIDs:d,enteredOptions:a.enteredOptions||void 0};i.push(u)}}),i.length===0)return null;const l=await x(i);return G(),l};export{P as W,x as a,S as b,V as c,Y as d,v as e,q as f,Q as g,f as h,g as i,Z as m,B as r,w as t};
148
148
  //# sourceMappingURL=mergeWishlists.js.map
@@ -15,5 +15,5 @@ import{events as d}from"@dropins/tools/event-bus.js";import{FetchGraphQL as S}fr
15
15
  }
16
16
  }
17
17
  }
18
- `,x=async s=>{var r,o,i;const e=p(),t={...e,items:(r=e.items)==null?void 0:r.filter(h=>!s.some(l=>{var a;return u(h,{sku:l.product.sku,optionUIDs:(a=l.selectedOptions)==null?void 0:a.map(I=>I.uid)})}))};if(n.authenticated){if(!n.wishlistId)throw Error("Wishlist ID is not set");const h=s.map(m=>m.id),{errors:l,data:a}=await w(O,{variables:{wishlistId:n.wishlistId,wishlistItemsIds:h}}),I=[...((o=a==null?void 0:a.removeProductsFromWishlist)==null?void 0:o.user_errors)??[],...l??[]];if(I.length>0)return d.emit("wishlist/data",e),D(I)}return t.items_count=(i=t.items)==null?void 0:i.length,d.emit("wishlist/data",t),null};export{P as a,F as b,R as c,M as d,N as e,w as f,p as g,D as h,u as i,E as j,H as k,L as l,x as r,n as s};
18
+ `,x=async s=>{var r,o,i;const e=p(),t={...e,items:(r=e.items)==null?void 0:r.filter(h=>!s.some(l=>{var a;return u(h,{sku:l.product.sku,optionUIDs:(a=l.selectedOptions)==null?void 0:a.map(I=>I.uid)})}))};if(n.authenticated){if(!n.wishlistId)throw Error("Wishlist ID is not set");const h=s.map(m=>m.id),{errors:l,data:a}=await w(O,{variables:{wishlistId:n.wishlistId,wishlistItemsIds:h}}),I=[...((o=a==null?void 0:a.removeProductsFromWishlist)==null?void 0:o.user_errors)??[],...l??[]];if(I.length>0)return d.emit("wishlist/data",e),D(I)}return t.items_count=(i=t.items)==null?void 0:i.length,d.emit("wishlist/data",t),null};export{N as a,L as b,H as c,R as d,P as e,w as f,p as g,D as h,u as i,F as j,M as k,E as l,x as r,n as s};
19
19
  //# sourceMappingURL=removeProductsFromWishlist.js.map
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-wishlist", "version": "3.0.0", "@dropins/tools": "~1.6.0", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/storefront-wishlist", "version": "3.1.0-beta2", "@dropins/tools": "~1.7.0-beta3", "license": "SEE LICENSE IN LICENSE.md"}