@dropins/storefront-wishlist 1.0.2-beta1 → 2.0.0-beta1
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/getStoreConfig/graphql/StoreConfigQuery.d.ts +1 -1
- package/api/index.d.ts +0 -1
- package/api/initialize/initialize.d.ts +3 -3
- package/api.js +4 -3
- package/api.js.map +1 -0
- package/chunks/Heart.js +1 -0
- package/chunks/Heart.js.map +1 -0
- package/chunks/HeartFilled.js +1 -0
- package/chunks/HeartFilled.js.map +1 -0
- package/chunks/Trash.js +1 -0
- package/chunks/Trash.js.map +1 -0
- package/chunks/WishlistAlert.js +1 -0
- package/chunks/WishlistAlert.js.map +1 -0
- package/chunks/WishlistItem.js +2 -1
- package/chunks/WishlistItem.js.map +1 -0
- package/chunks/mergeWishlists.js +21 -198
- package/chunks/mergeWishlists.js.map +1 -0
- package/chunks/removeProductsFromWishlist.js +3 -2
- package/chunks/removeProductsFromWishlist.js.map +1 -0
- package/components/ProductItem/ProductItem.d.ts +2 -7
- package/components/index.d.ts +0 -1
- package/containers/Wishlist/Wishlist.d.ts +4 -2
- package/containers/Wishlist.js +3 -2
- package/containers/Wishlist.js.map +1 -0
- package/containers/WishlistAlert.js +1 -0
- package/containers/WishlistAlert.js.map +1 -0
- package/containers/WishlistItem/WishlistItem.d.ts +5 -3
- package/containers/WishlistItem.js +2 -1
- package/containers/WishlistItem.js.map +1 -0
- package/containers/WishlistToggle/WishlistToggle.d.ts +1 -1
- package/containers/WishlistToggle.js +2 -1
- package/containers/WishlistToggle.js.map +1 -0
- package/data/models/product.d.ts +59 -42
- package/data/models/store-config.d.ts +0 -5
- package/data/models/wishlist.d.ts +6 -8
- package/data/transforms/__fixtures__/productData.d.ts +147 -3
- package/data/transforms/__fixtures__/wishlistData.d.ts +2 -4
- package/data/transforms/index.d.ts +0 -1
- package/lib/persisted-data.d.ts +1 -4
- package/package.json +1 -1
- package/render/render.d.ts +1 -1
- package/render.js +2 -1
- package/render.js.map +1 -0
- package/api/getProductBySku/getProductBySku.d.ts +0 -6
- package/api/getProductBySku/graphql/getProductBySku.graphql.d.ts +0 -18
- package/api/getProductBySku/graphql/index.d.ts +0 -18
- package/api/getProductBySku/index.d.ts +0 -18
- package/api/graphql/PriceRangeFragment.graphql.d.ts +0 -18
- package/api/graphql/ProductFragment.graphql.d.ts +0 -18
- package/components/ImageCarousel/ImageCarousel.d.ts +0 -17
- package/components/TaxDetails/TaxDetails.d.ts +0 -9
- package/components/TaxDetails/index.d.ts +0 -19
- package/data/transforms/transform-product.d.ts +0 -4
|
@@ -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 STORE_CONFIG_QUERY = "\nquery STORE_CONFIG_QUERY {\n storeConfig {\n magento_wishlist_general_is_enabled\n enable_multiple_wishlists\n maximum_number_of_wishlists\n
|
|
17
|
+
export declare const STORE_CONFIG_QUERY = "\nquery STORE_CONFIG_QUERY {\n storeConfig {\n magento_wishlist_general_is_enabled\n enable_multiple_wishlists\n maximum_number_of_wishlists\n }\n}\n";
|
|
18
18
|
//# sourceMappingURL=StoreConfigQuery.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ export * from './initialize';
|
|
|
18
18
|
export * from './fetch-graphql';
|
|
19
19
|
export * from './getStoreConfig';
|
|
20
20
|
export * from './localStorage';
|
|
21
|
-
export * from './getProductBySku';
|
|
22
21
|
export * from './getWishlistById';
|
|
23
22
|
export * from './getWishlists';
|
|
24
23
|
export * from './addProductsToWishlist';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Initializer } from '
|
|
2
|
-
import { Lang } from '
|
|
1
|
+
import { Initializer } from '@dropins/tools/types/elsie/src/lib';
|
|
2
|
+
import { Lang } from '@dropins/tools/types/elsie/src/i18n';
|
|
3
3
|
|
|
4
4
|
type ConfigProps = {
|
|
5
5
|
langDefinitions?: Lang;
|
|
6
6
|
isGuestWishlistEnabled?: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare const initialize: Initializer<ConfigProps>;
|
|
9
|
-
export declare const config: import('
|
|
9
|
+
export declare const config: import('@dropins/tools/types/elsie/src/lib').Config<ConfigProps>;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=initialize.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 c}from"./chunks/mergeWishlists.js";import{a as G,c as H,
|
|
3
|
+
import{W as _,t as h,b as c}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 m,f as n,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 z,j as B}from"./chunks/removeProductsFromWishlist.js";import{events as u}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 c}from"./chunks/mergeWishlists.js";import{a as G,c as
|
|
|
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 m();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 u.emit("wishlist/data",i),i})},W=`
|
|
29
29
|
mutation UPDATE_PRODUCTS_IN_WISHLIST_MUTATION(
|
|
30
30
|
$wishlistId: ID!,
|
|
31
31
|
$wishlistItems: [WishlistItemUpdateInput!]!,
|
|
@@ -45,4 +45,5 @@ ${_}
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
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,
|
|
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,m as getPersistedWishlistData,L as getStoreConfig,w as getWishlistById,y as getWishlistItemFromStorage,U as getWishlists,A as initialize,M as initializeWishlist,N as mergeWishlists,b as removeFetchGraphQlHeader,C as removeProductsFromWishlist,R as resetWishlist,Y as setEndpoint,x as setFetchGraphQlHeader,z as setFetchGraphQlHeaders,B as setPersistedWishlistData,E as updateProductsInWishlist};
|
|
49
|
+
//# sourceMappingURL=api.js.map
|
package/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sources":["/@dropins/storefront-wishlist/src/api/getWishlistById/graphql/getWishlistById.graphql.ts","/@dropins/storefront-wishlist/src/api/getWishlistById/getWishlistById.ts","/@dropins/storefront-wishlist/src/api/updateProductsInWishlist/graphql/updateProductsInWishlistMutation.ts","/@dropins/storefront-wishlist/src/api/updateProductsInWishlist/updateProductsInWishlist.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_ITEM_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const GET_WISHLIST_BY_ID_QUERY = `\n query GET_WISHLIST_BY_ID_QUERY(\n $wishlistId: ID!,\n ) {\n customer {\n wishlist_v2(id: $wishlistId) {\n id\n updated_at\n sharing_code\n items_count\n items_v2 {\n items {\n ...WISHLIST_ITEM_FRAGMENT\n }\n page_info {\n page_size\n current_page\n total_pages\n }\n }\n }\n }\n }\n\n${WISHLIST_ITEM_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GET_WISHLIST_BY_ID_QUERY } from '@/wishlist/api/getWishlistById/graphql/getWishlistById.graphql';\nimport { Wishlist } from '@/wishlist/data/models';\nimport { transformWishlist } from '@/wishlist/data/transforms';\nimport { state } from '@/wishlist/lib/state';\nimport { fetchGraphQl, getPersistedWishlistData } from '@/wishlist/api';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const getWishlistById = async (\n wishlistId: string,\n currentPage: number,\n pageSize: number\n): Promise<void | Wishlist | null> => {\n // When the user is not authenticated, we just have a single wishlist\n // There is no necessity to check any IDs\n if (!state.authenticated) {\n return getPersistedWishlistData();\n }\n\n if (!wishlistId) {\n throw Error('Wishlist ID is not set');\n }\n\n // @ts-ignore\n return fetchGraphQl(GET_WISHLIST_BY_ID_QUERY, {\n variables: {\n wishlistId,\n currentPage,\n pageSize,\n },\n }).then(({ errors, data }) => {\n if (errors) return handleFetchError(errors);\n\n if (!data?.customer?.wishlist_v2) {\n return null;\n }\n\n const payload = transformWishlist(data.customer.wishlist_v2);\n events.emit('wishlist/data', payload);\n return payload;\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_FRAGMENT } from '@/wishlist/api/graphql/WishlistFragment.graphql';\n\nexport const UPDATE_PRODUCTS_IN_WISHLIST_MUTATION = `\n mutation UPDATE_PRODUCTS_IN_WISHLIST_MUTATION(\n $wishlistId: ID!, \n $wishlistItems: [WishlistItemUpdateInput!]!,\n ) {\n updateProductsInWishlist(\n wishlistId: $wishlistId\n wishlistItems: $wishlistItems\n ) {\n wishlist {\n ...WISHLIST_FRAGMENT\n }\n user_errors {\n code\n message\n }\n }\n }\n \n ${WISHLIST_FRAGMENT} \n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/wishlist/api';\nimport { state } from '@/wishlist/lib/state';\nimport { handleFetchError } from '@/wishlist//lib/fetch-error';\n\nimport { UPDATE_PRODUCTS_IN_WISHLIST_MUTATION } from './graphql/updateProductsInWishlistMutation';\nimport { Wishlist } from '@/wishlist/data/models/wishlist';\nimport { transformWishlist } from '@/wishlist/data/transforms';\n\nexport const updateProductsInWishlist = async (\n items: {\n wishlistItemId: string;\n quantity: number;\n description: string;\n selectedOptions?: string[];\n enteredOptions?: { uid: string; value: string }[];\n }[]\n): Promise<Wishlist | null> => {\n const wishlistId = state.wishlistId;\n\n if (!wishlistId) {\n throw Error('Wishlist ID is not set');\n }\n\n return fetchGraphQl(UPDATE_PRODUCTS_IN_WISHLIST_MUTATION, {\n variables: {\n wishlistId,\n wishlistItems: items.map(\n ({\n wishlistItemId,\n quantity,\n description,\n selectedOptions: selected_options,\n enteredOptions: entered_options,\n }) => ({\n wishlistItemId,\n quantity,\n description,\n selected_options,\n entered_options,\n })\n ),\n },\n }).then(({ errors, data }) => {\n // handle errors\n const _errors = [\n ...(data?.updateProductsInWishlist?.user_errors ?? []),\n ...(errors ?? []),\n ];\n\n if (_errors.length > 0) return handleFetchError(_errors);\n\n return transformWishlist(data.updateProductsInWishlist.wishlist);\n });\n};\n"],"names":["GET_WISHLIST_BY_ID_QUERY","WISHLIST_ITEM_FRAGMENT","getWishlistById","wishlistId","currentPage","pageSize","state","getPersistedWishlistData","fetchGraphQl","errors","data","handleFetchError","_a","payload","transformWishlist","events","UPDATE_PRODUCTS_IN_WISHLIST_MUTATION","WISHLIST_FRAGMENT","updateProductsInWishlist","items","wishlistItemId","quantity","description","selected_options","entered_options","_errors"],"mappings":"yeAmBO,MAAMA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwBtCC,CAAsB;AAAA,EClBXC,EAAkB,MAC7BC,EACAC,EACAC,IACoC,CAGhC,GAAA,CAACC,EAAM,cACT,OAAOC,EAAyB,EAGlC,GAAI,CAACJ,EACH,MAAM,MAAM,wBAAwB,EAItC,OAAOK,EAAaR,EAA0B,CAC5C,UAAW,CACT,WAAAG,EACA,YAAAC,EACA,SAAAC,CAAA,CAEH,CAAA,EAAE,KAAK,CAAC,CAAE,OAAAI,EAAQ,KAAAC,KAAW,OACxB,GAAAD,EAAe,OAAAE,EAAiBF,CAAM,EAEtC,GAAA,GAACG,EAAAF,GAAA,YAAAA,EAAM,WAAN,MAAAE,EAAgB,aACZ,OAAA,KAGT,MAAMC,EAAUC,EAAkBJ,EAAK,SAAS,WAAW,EACpD,OAAAK,EAAA,KAAK,gBAAiBF,CAAO,EAC7BA,CAAA,CACR,CACH,ECvCaG,EAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAmB/CC,CAAiB;AAAA,ECbTC,EAA2B,MACtCC,GAO6B,CAC7B,MAAMhB,EAAaG,EAAM,WAEzB,GAAI,CAACH,EACH,MAAM,MAAM,wBAAwB,EAGtC,OAAOK,EAAaQ,EAAsC,CACxD,UAAW,CACT,WAAAb,EACA,cAAegB,EAAM,IACnB,CAAC,CACC,eAAAC,EACA,SAAAC,EACA,YAAAC,EACA,gBAAiBC,EACjB,eAAgBC,CAAA,KACX,CACL,eAAAJ,EACA,SAAAC,EACA,YAAAC,EACA,iBAAAC,EACA,gBAAAC,CACF,EAAA,CACF,CAEH,CAAA,EAAE,KAAK,CAAC,CAAE,OAAAf,EAAQ,KAAAC,KAAW,OAE5B,MAAMe,EAAU,CACd,KAAIb,EAAAF,GAAA,YAAAA,EAAM,2BAAN,YAAAE,EAAgC,cAAe,CAAC,EACpD,GAAIH,GAAU,CAAA,CAChB,EAEA,OAAIgB,EAAQ,OAAS,EAAUd,EAAiBc,CAAO,EAEhDX,EAAkBJ,EAAK,yBAAyB,QAAQ,CAAA,CAChE,CACH"}
|
package/chunks/Heart.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
import*as e from"@dropins/tools/preact-compat.js";const o=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.734 5.4175C17.8557 3.5275 14.7987 3.5275 12.9105 5.4175L11.9814 6.3475L11.0523 5.4175C9.15407 3.5475 6.09699 3.5775 4.22878 5.4875C2.39054 7.3675 2.39054 10.3675 4.22878 12.2475L5.15789 13.1775L11.9814 20.0075L18.8048 13.1775L19.734 12.2475C21.6221 10.3675 21.6221 7.3075 19.734 5.4175Z",stroke:"currentColor"}));export{o as S};
|
|
4
|
+
//# sourceMappingURL=Heart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Heart.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Heart.svg"],"sourcesContent":["import * as React from \"react\";\nconst SvgHeart = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M19.734 5.4175C17.8557 3.5275 14.7987 3.5275 12.9105 5.4175L11.9814 6.3475L11.0523 5.4175C9.15407 3.5475 6.09699 3.5775 4.22878 5.4875C2.39054 7.3675 2.39054 10.3675 4.22878 12.2475L5.15789 13.1775L11.9814 20.0075L18.8048 13.1775L19.734 12.2475C21.6221 10.3675 21.6221 7.3075 19.734 5.4175Z\", stroke: \"currentColor\" }));\nexport default SvgHeart;\n"],"names":["SvgHeart","props","React"],"mappings":"kDACK,MAACA,EAAYC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAO,EAAkBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,qSAAsS,OAAQ,cAAc,CAAE,CAAC","x_google_ignoreList":[0]}
|
package/chunks/HeartFilled.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
import*as e from"@dropins/tools/preact-compat.js";const r=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12,20.75h0c-.2,0-.39-.08-.53-.22L3.71,12.77c-2.12-2.16-2.12-5.66,0-7.82,1.04-1.06,2.44-1.66,3.93-1.67h.06c1.47,0,2.85,.57,3.9,1.6l.4,.4,.4-.4c1.05-1.05,2.45-1.63,3.94-1.63h0c1.49,0,2.89,.58,3.94,1.63,.02,.02,.03,.03,.05,.05,1.02,1.05,1.59,2.43,1.59,3.9s-.58,2.89-1.63,3.94l-7.76,7.76c-.14,.14-.33,.22-.53,.22Z",stroke:"currentColor"}));export{r as S};
|
|
4
|
+
//# sourceMappingURL=HeartFilled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeartFilled.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/HeartFilled.svg"],"sourcesContent":["import * as React from \"react\";\nconst SvgHeartFilled = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"currentColor\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M12,20.75h0c-.2,0-.39-.08-.53-.22L3.71,12.77c-2.12-2.16-2.12-5.66,0-7.82,1.04-1.06,2.44-1.66,3.93-1.67h.06c1.47,0,2.85,.57,3.9,1.6l.4,.4,.4-.4c1.05-1.05,2.45-1.63,3.94-1.63h0c1.49,0,2.89,.58,3.94,1.63,.02,.02,.03,.03,.05,.05,1.02,1.05,1.59,2.43,1.59,3.9s-.58,2.89-1.63,3.94l-7.76,7.76c-.14,.14-.33,.22-.53,.22Z\", stroke: \"currentColor\" }));\nexport default SvgHeartFilled;\n"],"names":["SvgHeartFilled","props","React"],"mappings":"kDACK,MAACA,EAAkBC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,eAAgB,MAAO,6BAA8B,GAAGD,CAAO,EAAkBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,yTAA0T,OAAQ,cAAc,CAAE,CAAC","x_google_ignoreList":[0]}
|
package/chunks/Trash.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
import*as e from"@dropins/tools/preact-compat.js";const r=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("g",{clipPath:"url(#clip0_102_196)"},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z",stroke:"currentColor",strokeLinejoin:"round"}),e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),e.createElement("defs",null,e.createElement("clipPath",{id:"clip0_102_196"},e.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),o=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",...t},e.createElement("path",{d:"M1 5H23",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),e.createElement("path",{d:"M17.3674 22H6.63446C5.67952 22 4.88992 21.2688 4.8379 20.3338L4 5H20L19.1621 20.3338C19.1119 21.2688 18.3223 22 17.3655 22H17.3674Z",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),e.createElement("path",{d:"M9.87189 2H14.1281C14.6085 2 15 2.39766 15 2.88889V5H9V2.88889C9 2.39912 9.39006 2 9.87189 2Z",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),e.createElement("path",{d:"M8.87402 8.58057L9.39348 17.682",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),e.createElement("path",{d:"M14.6673 8.58057L14.146 17.682",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}));export{r as S,o as a};
|
|
4
|
+
//# sourceMappingURL=Trash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Trash.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Cart.svg","../../node_modules/@adobe-commerce/elsie/src/icons/Trash.svg"],"sourcesContent":["import * as React from \"react\";\nconst SvgCart = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"g\", { clipPath: \"url(#clip0_102_196)\" }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z\", stroke: \"currentColor\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M5.25 6.37L20.89 8.06L20.14 14.8H6.19\", stroke: \"currentColor\", strokeLinejoin: \"round\" })), /* @__PURE__ */ React.createElement(\"defs\", null, /* @__PURE__ */ React.createElement(\"clipPath\", { id: \"clip0_102_196\" }, /* @__PURE__ */ React.createElement(\"rect\", { vectorEffect: \"non-scaling-stroke\", width: 19.29, height: 19.5, fill: \"white\", transform: \"translate(2.3501 2.25)\" }))));\nexport default SvgCart;\n","import * as React from \"react\";\nconst SvgTrash = (props) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { d: \"M1 5H23\", stroke: \"currentColor\", strokeWidth: 1.5, strokeMiterlimit: 10 }), /* @__PURE__ */ React.createElement(\"path\", { d: \"M17.3674 22H6.63446C5.67952 22 4.88992 21.2688 4.8379 20.3338L4 5H20L19.1621 20.3338C19.1119 21.2688 18.3223 22 17.3655 22H17.3674Z\", stroke: \"currentColor\", strokeWidth: 1.5, strokeMiterlimit: 10 }), /* @__PURE__ */ React.createElement(\"path\", { d: \"M9.87189 2H14.1281C14.6085 2 15 2.39766 15 2.88889V5H9V2.88889C9 2.39912 9.39006 2 9.87189 2Z\", stroke: \"currentColor\", strokeWidth: 1.5, strokeMiterlimit: 10 }), /* @__PURE__ */ React.createElement(\"path\", { d: \"M8.87402 8.58057L9.39348 17.682\", stroke: \"currentColor\", strokeWidth: 1.5, strokeMiterlimit: 10 }), /* @__PURE__ */ React.createElement(\"path\", { d: \"M14.6673 8.58057L14.146 17.682\", stroke: \"currentColor\", strokeWidth: 1.5, strokeMiterlimit: 10 }));\nexport default SvgTrash;\n"],"names":["SvgCart","props","React","SvgTrash"],"mappings":"kDACK,MAACA,EAAWC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAO,EAAkBC,EAAM,cAAc,IAAK,CAAE,SAAU,qBAAqB,EAAoBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,oZAAqZ,OAAQ,eAAgB,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,wCAAyC,OAAQ,eAAgB,eAAgB,OAAS,CAAA,CAAC,EAAmBA,EAAM,cAAc,OAAQ,KAAsBA,EAAM,cAAc,WAAY,CAAE,GAAI,eAAe,EAAoBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,MAAO,MAAO,OAAQ,KAAM,KAAM,QAAS,UAAW,wBAA0B,CAAA,CAAC,CAAC,CAAC,ECA7uCC,EAAYF,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,6BAA8B,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,GAAGD,CAAK,EAAoBC,EAAM,cAAc,OAAQ,CAAE,EAAG,UAAW,OAAQ,eAAgB,YAAa,IAAK,iBAAkB,EAAI,CAAA,EAAmBA,EAAM,cAAc,OAAQ,CAAE,EAAG,sIAAuI,OAAQ,eAAgB,YAAa,IAAK,iBAAkB,EAAE,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,EAAG,gGAAiG,OAAQ,eAAgB,YAAa,IAAK,iBAAkB,EAAE,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,EAAG,kCAAmC,OAAQ,eAAgB,YAAa,IAAK,iBAAkB,EAAI,CAAA,EAAmBA,EAAM,cAAc,OAAQ,CAAE,EAAG,iCAAkC,OAAQ,eAAgB,YAAa,IAAK,iBAAkB,GAAI,CAAC","x_google_ignoreList":[0,1]}
|
package/chunks/WishlistAlert.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import{InLineAlert as m,Icon as g}from"@dropins/tools/components.js";import*as r from"@dropins/tools/preact-compat.js";import{S as h,a as v}from"./Trash.js";import{S as p}from"./HeartFilled.js";import{useText as E}from"@dropins/tools/i18n.js";const n=e=>r.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("g",{clipPath:"url(#clip0_841_1324)"},r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),r.createElement("defs",null,r.createElement("clipPath",{id:"clip0_841_1324"},r.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),H=({action:e,item:i,routeToWishlist:t})=>{const s=E({addHeading:"Wishlist.Alert.addProduct.heading",addMessage:"Wishlist.Alert.addProduct.message",removeHeading:"Wishlist.Alert.removeProduct.heading",removeMessage:"Wishlist.Alert.removeProduct.message",moveHeading:"Wishlist.Alert.moveToCart.heading",moveMessage:"Wishlist.Alert.moveToCart.message",viewWishlist:"Wishlist.Alert.viewWishlist",addErrorHeading:"Wishlist.Alert.addError.heading",addErrorMessage:"Wishlist.Alert.addError.message",removeErrorHeading:"Wishlist.Alert.removeError.heading",removeErrorMessage:"Wishlist.Alert.removeError.message"});if(!e)return null;const l=s[`${e}Heading`],o=s[`${e}Message`],d={add:p,remove:v,move:h,addError:n,removeError:n},c=t?location.href.includes(t):!1;return a(m,{"data-testid":"wishlist-alert",heading:l,description:i?o.replace("{product}",i.product.name):o,type:e==="addError"||e==="removeError"?"warning":"success",icon:a(g,{source:d[e],size:"16"}),actionButtonPosition:"top",additionalActions:!c&&t?[{label:s.viewWishlist,onClick:()=>{location.href=t}}]:void 0})};export{H as W};
|
|
4
|
+
//# sourceMappingURL=WishlistAlert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WishlistAlert.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Warning.svg","/@dropins/storefront-wishlist/src/containers/WishlistAlert/WishlistAlert.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgWarning = (props) => /* @__PURE__ */ React.createElement(\"svg\", { id: \"Icon_Warning_Base\", width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"g\", { clipPath: \"url(#clip0_841_1324)\" }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\" })), /* @__PURE__ */ React.createElement(\"defs\", null, /* @__PURE__ */ React.createElement(\"clipPath\", { id: \"clip0_841_1324\" }, /* @__PURE__ */ React.createElement(\"rect\", { width: 24, height: 21, fill: \"white\", transform: \"translate(0 1.5)\" }))));\nexport default SvgWarning;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { Icon, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Cart, HeartFilled, Trash, Warning } from '@adobe-commerce/elsie/icons';\n\nexport interface WishlistAlertProps extends HTMLAttributes<HTMLDivElement> {\n action: 'add' | 'remove' | 'move' | 'addError' | 'removeError';\n item?: { product: { name: string } };\n routeToWishlist?: string;\n}\n\nexport const WishlistAlert: FunctionComponent<WishlistAlertProps> = ({\n action,\n item,\n routeToWishlist,\n}) => {\n const dictionary = useText({\n addHeading: 'Wishlist.Alert.addProduct.heading',\n addMessage: 'Wishlist.Alert.addProduct.message',\n removeHeading: 'Wishlist.Alert.removeProduct.heading',\n removeMessage: 'Wishlist.Alert.removeProduct.message',\n moveHeading: 'Wishlist.Alert.moveToCart.heading',\n moveMessage: 'Wishlist.Alert.moveToCart.message',\n viewWishlist: 'Wishlist.Alert.viewWishlist',\n addErrorHeading: 'Wishlist.Alert.addError.heading',\n addErrorMessage: 'Wishlist.Alert.addError.message',\n removeErrorHeading: 'Wishlist.Alert.removeError.heading',\n removeErrorMessage: 'Wishlist.Alert.removeError.message',\n });\n\n if (!action) {\n return null;\n }\n\n const heading = dictionary[`${action}Heading`];\n const message = dictionary[`${action}Message`];\n const iconMap = {\n add: HeartFilled,\n remove: Trash,\n move: Cart,\n addError: Warning,\n removeError: Warning,\n };\n\n const isWishlistPage = routeToWishlist\n ? location.href.includes(routeToWishlist)\n : false;\n\n return (\n <InLineAlert\n data-testid=\"wishlist-alert\"\n heading={heading}\n description={\n item ? message.replace('{product}', item.product.name) : message\n }\n type={\n action === 'addError' || action === 'removeError'\n ? 'warning'\n : 'success'\n }\n icon={<Icon source={iconMap[action]} size=\"16\" />}\n actionButtonPosition=\"top\"\n additionalActions={\n !isWishlistPage && routeToWishlist\n ? [\n {\n label: dictionary.viewWishlist,\n onClick: () => {\n location.href = routeToWishlist;\n },\n },\n ]\n : undefined\n }\n />\n );\n};\n"],"names":["SvgWarning","props","React","WishlistAlert","action","item","routeToWishlist","dictionary","useText","heading","message","iconMap","HeartFilled","Trash","Cart","Warning","isWishlistPage","jsx","InLineAlert","Icon"],"mappings":"8SACA,MAAMA,EAAcC,GAA0BC,EAAM,cAAc,MAAO,CAAE,GAAI,oBAAqB,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAO,EAAkBC,EAAM,cAAc,IAAK,CAAE,SAAU,wBAA0CA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,6DAA8D,OAAQ,eAAgB,cAA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em.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as
|
|
3
|
+
import{jsx as s,jsxs as w,Fragment as B}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as ut,useState as pt,useEffect as vt,useCallback as at}from"@dropins/tools/preact-compat.js";import{classes as v}from"@dropins/tools/lib.js";import{Button as x,Icon as dt,Price as I,Image as yt}from"@dropins/tools/components.js";import{events as lt}from"@dropins/tools/event-bus.js";import{r as bt}from"./removeProductsFromWishlist.js";import{a as Nt,S as At}from"./Trash.js";import{useText as It}from"@dropins/tools/i18n.js";const xt=({className:r,item:t,onCartActionButtonClick:c,onTrashButtonClick:a,routeProdDetailPage:p,imageNode:y,...o})=>{var _,z,k,g,S,q,P;const u=It({cartActionBtn:"ProductItem.CartActionButton",trashActionBtn:"ProductItem.TrashActionButton",customizeActionBtn:"ProductItem.CustomizeActionButton"}),n=((k=(z=(_=t.product)==null?void 0:_.prices)==null?void 0:z.final)==null?void 0:k.amount)<((q=(S=(g=t.product)==null?void 0:g.prices)==null?void 0:S.regular)==null?void 0:q.amount),m=()=>{var e;return s("a",{className:"wishlist-product-item-image","data-testid":"wishlist-product-item-image",href:p(t.product),children:s(Bt,{images:((e=t.product)==null?void 0:e.images)??[],imageNode:y})})},d=()=>{var e,i,h,A,F,W,C,M,T,$,j,E,U,V,Y,G,H,J,K,L,Q,R,X,Z,D,tt,rt,et,st,ct,ot,it,nt;return((h=(i=(e=t.product)==null?void 0:e.prices)==null?void 0:i.final)==null?void 0:h.amount)===void 0&&((W=(F=(A=t.product)==null?void 0:A.prices)==null?void 0:F.final)==null?void 0:W.maximumAmount)!==void 0&&((T=(M=(C=t.product)==null?void 0:C.prices)==null?void 0:M.final)==null?void 0:T.maximumAmount)>0?w(B,{children:[s(I,{className:"wishlist-product-item-price","data-testid":"wishlist-product-item-price",amount:(E=(j=($=t.product)==null?void 0:$.prices)==null?void 0:j.final)==null?void 0:E.minimumAmount,currency:(Y=(V=(U=t.product)==null?void 0:U.prices)==null?void 0:V.final)==null?void 0:Y.currency}),"-",s(I,{className:"wishlist-product-item-price","data-testid":"wishlist-product-item-price",amount:(J=(H=(G=t.product)==null?void 0:G.prices)==null?void 0:H.final)==null?void 0:J.maximumAmount,currency:(Q=(L=(K=t.product)==null?void 0:K.prices)==null?void 0:L.final)==null?void 0:Q.currency})]}):w(B,{children:[s(I,{className:v(["wishlist-product-item-price",n?"strikethrough":""]),"data-testid":"wishlist-product-item-price",amount:(Z=(X=(R=t.product)==null?void 0:R.prices)==null?void 0:X.regular)==null?void 0:Z.amount,currency:(rt=(tt=(D=t.product)==null?void 0:D.prices)==null?void 0:tt.regular)==null?void 0:rt.currency}),n&&s(I,{className:"wishlist-product-item-discounted-price","data-testid":"wishlist-product-item-discounted-price",amount:(ct=(st=(et=t.product)==null?void 0:et.prices)==null?void 0:st.final)==null?void 0:ct.amount,currency:(nt=(it=(ot=t.product)==null?void 0:ot.prices)==null?void 0:it.final)==null?void 0:nt.currency})]})},l=()=>s(x,{"data-testid":"wishlist-product-item-remove-button",className:"wishlist-product-item-button__remove",variant:"tertiary",onClick:()=>a==null?void 0:a(),icon:s(dt,{source:Nt,size:"24",stroke:"2",viewBox:"0 0 24 24","aria-label":u.trashActionBtn})}),N=()=>f()?ft():wt(),f=()=>{var e;return((e=t.product)==null?void 0:e.productType)==="complex"?mt():!0},b=ut(()=>{var e;return((e=t.selectedOptions)==null?void 0:e.map(i=>i.uid))||[]},[t.selectedOptions]),O=ut(()=>{const e=t.product.options||[],i=e.filter(h=>h.required);return i.length===0?e:i},[t.product.options]),mt=()=>O.every(e=>{var i;return(i=e.items)==null?void 0:i.some(h=>b.includes(h.id))}),ht=()=>b.length===0?null:s("div",{className:"wishlist-product-item-options",children:O.map(e=>{var h;const i=(h=e.items)==null?void 0:h.find(A=>b.includes(A.id));return i?w("div",{className:"wishlist-product-item-option",children:[w("span",{className:"wishlist-product-item-option__attribute",children:[e.id,":"]})," ",s("span",{className:"wishlist-product-item-option__label",children:i.label})]},e.type):null})}),ft=()=>{var e;return s(x,{"data-testid":"wishlist-product-item-move-to-cart-button",size:"medium",type:"submit",icon:s(dt,{source:At}),disabled:!((e=t.product)!=null&&e.inStock),"aria-label":u.cartActionBtn,onClick:()=>c==null?void 0:c(),children:u.cartActionBtn})},wt=()=>s(x,{"data-testid":"wishlist-product-item-customize-button",size:"medium",type:"submit","aria-label":u.customizeActionBtn,href:p(t.product),children:u.customizeActionBtn});return s("div",{...o,className:v(["wishlist-product-item",r]),children:w("div",{className:"wishlist-product-item__content",children:[m(),w("div",{className:"wishlist-product-item__title","data-testid":"wishlist-product-item-header",children:[s("a",{className:"wishlist-product-item-name","data-testid":"wishlist-product-item-name",href:p(t.product),children:(P=t.product)==null?void 0:P.name}),l(),d()]}),ht(),N()]})})},Bt=({className:r,children:t,images:c,imageNode:a,...p})=>{const[y,o]=pt(0);return w(B,{children:[s("div",{...p,className:v(["image-carousel",r]),children:s("div",{className:v(["overflow-hidden relative max-w-[200px]",r]),children:c==null?void 0:c.map((u,n)=>{const m={className:v(["image-carousel-image",r]),src:u.url,alt:u.label};return n!==y?null:typeof a=="function"?a({defaultImageProps:m}):a||s(yt,{...m})})})}),(c==null?void 0:c.length)>1&&s("div",{className:v(["absolute","image-switcher-area"]),children:c==null?void 0:c.map((u,n)=>s("span",{className:v(["image-switcher",y===n?"image-switcher-active":"image-switcher-inactive"]),onClick:m=>{o(n),m.preventDefault(),m.stopPropagation()}},n))})]})},Ft=({item:r,getProductData:t,getRefinedProduct:c,moveProdToCart:a,routeProdDetailPage:p,imageNode:y})=>{const[o,u]=pt(null);vt(()=>{let d=!1;async function l(){var N;try{let f;c&&((N=r==null?void 0:r.selectedOptions)==null?void 0:N.length)>0?f=await c(r.product.sku,r.selectedOptions.map(b=>b.uid)):f=t?await t(r==null?void 0:r.product.sku):r==null?void 0:r.product,d||u(f)}catch(f){d||console.error("Failed to fetch product data:",f)}}return l(),()=>{d=!0}},[r,t,c]);const n=at(async(d=!0)=>{try{return await bt([r]),console.log(`Product ${o==null?void 0:o.sku} removed from wishlist!`),d&<.emit("wishlist/alert",{action:"remove",item:{...r,product:o}}),!0}catch(l){return console.error(`Product ${o.sku} could not be removed from wishlist`,l),!1}},[r,o]),m=at(async()=>{var d;try{return await a([{sku:o.sku,quantity:1,optionsUIDs:(d=r.selectedOptions)==null?void 0:d.map(l=>l.uid),enteredOptions:r.enteredOptions}]),console.log(`Product ${o.sku} successfully moved to cart 🛒`),lt.emit("wishlist/alert",{action:"move",item:{...r,product:o}}),await n(!1)}catch(l){return console.error("Could not move product to cart: ",l),l.toString().includes("You need to choose options for your item.")&&window.location.replace(p(o)),!1}},[o,r,a,p,n]);return!o||!r?null:s(xt,{item:{...r,product:o},onCartActionButtonClick:m,onTrashButtonClick:n,routeProdDetailPage:p,imageNode:y})};export{Ft as W};
|
|
4
|
+
//# sourceMappingURL=WishlistItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WishlistItem.js","sources":["/@dropins/storefront-wishlist/src/components/ProductItem/ProductItem.tsx","/@dropins/storefront-wishlist/src/components/ImageCarousel/ImageCarousel.tsx","/@dropins/storefront-wishlist/src/containers/WishlistItem/WishlistItem.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { HTMLAttributes, useMemo } from 'preact/compat';\nimport { FunctionComponent, JSX } from 'preact';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport {\n Button,\n Icon,\n ImageNodeRenderProps,\n Price,\n} from '@adobe-commerce/elsie/components';\nimport { ImageCarousel } from '@/wishlist/components';\nimport { Item, Product } from '@/wishlist/data/models';\nimport { Cart, Trash } from '@adobe-commerce/elsie/icons';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nimport '@/wishlist/components/ProductItem/ProductItem.css';\n\nexport interface ProductItemProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n item?: Item;\n onCartActionButtonClick?: () => boolean;\n onTrashButtonClick?: () => boolean;\n routeProdDetailPage: (product: Product) => string;\n imageNode?: (props: {\n defaultImageProps: ImageNodeRenderProps;\n }) => JSX.Element;\n}\n\nexport const ProductItem: FunctionComponent<ProductItemProps> = ({\n className,\n item,\n onCartActionButtonClick,\n onTrashButtonClick,\n routeProdDetailPage,\n imageNode,\n ...props\n}) => {\n const labels = useText({\n cartActionBtn: 'ProductItem.CartActionButton',\n trashActionBtn: 'ProductItem.TrashActionButton',\n customizeActionBtn: 'ProductItem.CustomizeActionButton',\n });\n\n const discounted =\n item.product?.prices?.final?.amount < item.product?.prices?.regular?.amount;\n\n const renderImage = () => {\n return (\n <a\n className=\"wishlist-product-item-image\"\n data-testid=\"wishlist-product-item-image\"\n href={routeProdDetailPage(item.product)}\n >\n <ImageCarousel\n images={item.product?.images ?? []}\n imageNode={imageNode}\n />\n </a>\n );\n };\n\n const renderPrices = () => {\n if (\n item.product?.prices?.final?.amount === undefined &&\n item.product?.prices?.final?.maximumAmount !== undefined &&\n item.product?.prices?.final?.maximumAmount > 0\n ) {\n return (\n <>\n <Price\n className=\"wishlist-product-item-price\"\n data-testid=\"wishlist-product-item-price\"\n amount={item.product?.prices?.final?.minimumAmount}\n currency={item.product?.prices?.final?.currency}\n />\n -\n <Price\n className=\"wishlist-product-item-price\"\n data-testid=\"wishlist-product-item-price\"\n amount={item.product?.prices?.final?.maximumAmount}\n currency={item.product?.prices?.final?.currency}\n />\n </>\n );\n }\n return (\n <>\n <Price\n className={classes([\n 'wishlist-product-item-price',\n discounted ? 'strikethrough' : '',\n ])}\n data-testid=\"wishlist-product-item-price\"\n amount={item.product?.prices?.regular?.amount}\n currency={item.product?.prices?.regular?.currency}\n />\n\n {discounted && (\n <Price\n className=\"wishlist-product-item-discounted-price\"\n data-testid=\"wishlist-product-item-discounted-price\"\n amount={item.product?.prices?.final?.amount}\n currency={item.product?.prices?.final?.currency}\n />\n )}\n </>\n );\n };\n\n const renderTrashButton = () => {\n return (\n <Button\n data-testid=\"wishlist-product-item-remove-button\"\n className=\"wishlist-product-item-button__remove\"\n variant=\"tertiary\"\n onClick={() => onTrashButtonClick?.()}\n icon={\n <Icon\n source={Trash}\n size=\"24\"\n stroke=\"2\"\n viewBox=\"0 0 24 24\"\n aria-label={labels.trashActionBtn}\n />\n }\n />\n );\n };\n\n const renderMainActionButton = () => {\n return isProductReady()\n ? renderMoveToCartButton()\n : renderCustomizeButton();\n };\n\n const isProductReady = () => {\n if (item.product?.productType === 'complex') {\n return areAllRequiredOptionsIncluded();\n }\n return true;\n };\n\n const selectedOptions = useMemo(\n () => item.selectedOptions?.map((opt: any) => opt.uid) || [],\n [item.selectedOptions]\n );\n\n const requiredOptions = useMemo(() => {\n const options = item.product.options || [];\n const required = options.filter((option: any) => option.required);\n return required.length === 0 ? options : required;\n }, [item.product.options]);\n\n const areAllRequiredOptionsIncluded = (): boolean => {\n return requiredOptions.every((option: any) =>\n option.items?.some((item: any) => selectedOptions.includes(item.id))\n );\n };\n\n const renderOptions = () => {\n if (selectedOptions.length === 0) return null;\n\n return (\n <div className=\"wishlist-product-item-options\">\n {requiredOptions.map((option: any) => {\n const selectedValue = option.items?.find((item: any) =>\n selectedOptions.includes(item.id)\n );\n return selectedValue ? (\n <div key={option.type} className=\"wishlist-product-item-option\">\n <span className=\"wishlist-product-item-option__attribute\">\n {option.id}:\n </span>\n \n <span className=\"wishlist-product-item-option__label\">\n {selectedValue.label}\n </span>\n </div>\n ) : null;\n })}\n </div>\n );\n };\n\n const renderMoveToCartButton = () => {\n return (\n <Button\n data-testid=\"wishlist-product-item-move-to-cart-button\"\n size=\"medium\"\n type=\"submit\"\n icon={<Icon source={Cart} />}\n disabled={!item.product?.inStock}\n aria-label={labels.cartActionBtn}\n onClick={() => onCartActionButtonClick?.()}\n >\n {labels.cartActionBtn}\n </Button>\n );\n };\n\n const renderCustomizeButton = () => {\n return (\n <Button\n data-testid=\"wishlist-product-item-customize-button\"\n size=\"medium\"\n type=\"submit\"\n aria-label={labels.customizeActionBtn}\n href={routeProdDetailPage(item.product)}\n >\n {labels.customizeActionBtn}\n </Button>\n );\n };\n\n return (\n <div {...props} className={classes(['wishlist-product-item', className])}>\n <div className=\"wishlist-product-item__content\">\n {renderImage()}\n <div\n className=\"wishlist-product-item__title\"\n data-testid=\"wishlist-product-item-header\"\n >\n <a\n className=\"wishlist-product-item-name\"\n data-testid=\"wishlist-product-item-name\"\n href={routeProdDetailPage(item.product)}\n >\n {item.product?.name}\n </a>\n\n {renderTrashButton()}\n {renderPrices()}\n </div>\n {renderOptions()}\n {renderMainActionButton()}\n </div>\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent, JSX } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { Image, ImageNodeRenderProps } from '@adobe-commerce/elsie/components';\nimport { useState } from 'react';\n\nimport '@/wishlist/components/ImageCarousel/ImageCarousel.css';\n\nexport interface ImageCarouselProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n children?: any;\n images: Image[];\n imageNode?: (props: {\n defaultImageProps: ImageNodeRenderProps;\n }) => JSX.Element;\n}\n\nexport const ImageCarousel: FunctionComponent<ImageCarouselProps> = ({\n className,\n children,\n images,\n imageNode,\n ...props\n}) => {\n const [carouselIndex, setCarouselIndex] = useState(0);\n\n return (\n <>\n <div {...props} className={classes(['image-carousel', className])}>\n <div\n className={classes([\n 'overflow-hidden relative max-w-[200px]',\n className,\n ])}\n >\n {images?.map(\n (image: ImageCarouselProps['images'][0], index: number) => {\n const defaultProps = {\n className: classes(['image-carousel-image', className]),\n src: image.url,\n alt: image.label,\n } as const;\n\n if (index !== carouselIndex) {\n return null;\n }\n\n return typeof imageNode === 'function'\n ? imageNode({\n defaultImageProps: defaultProps,\n })\n : imageNode || <Image {...defaultProps} />;\n }\n )}\n </div>\n </div>\n {images?.length > 1 && (\n <div className={classes(['absolute', 'image-switcher-area'])}>\n {images?.map(\n (_image: ImageCarouselProps['images'][0], index: number) => {\n return (\n <span\n className={classes([\n 'image-switcher',\n carouselIndex === index\n ? 'image-switcher-active'\n : 'image-switcher-inactive',\n ])}\n key={index}\n onClick={(event: MouseEvent | TouchEvent) => {\n setCarouselIndex(index);\n event.preventDefault(); // prevent navigate on click since ImageCarousel is wrapped in a link\n event.stopPropagation();\n }}\n />\n );\n }\n )}\n </div>\n )}\n </>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n HTMLAttributes,\n useEffect,\n useState,\n useCallback,\n} from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { ProductItem } from '@/wishlist/components';\nimport { Item, Product } from '@/wishlist/data/models';\nimport { removeProductsFromWishlist } from '@/wishlist/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ImageNodeRenderProps } from '@adobe-commerce/elsie/components';\nimport { JSX } from 'preact';\n\nexport interface WishlistItemProps extends HTMLAttributes<HTMLDivElement> {\n item: Item;\n getProductData?: (sku: string) => Promise<Product | null>;\n getRefinedProduct?: (\n sku: string,\n optionUIDs: string[],\n anchorOptions?: string[],\n raw?: boolean\n ) => Promise<Product | null>;\n moveProdToCart: (\n products: {\n sku: string;\n quantity: number;\n optionsUIDs?: [];\n enteredOptions?: [];\n }[]\n ) => Promise<any>;\n routeProdDetailPage: (product: Product) => string;\n imageNode?: (props: {\n defaultImageProps: ImageNodeRenderProps;\n }) => JSX.Element;\n}\n\nexport const WishlistItem: Container<WishlistItemProps> = ({\n item,\n getProductData,\n getRefinedProduct,\n moveProdToCart,\n routeProdDetailPage,\n imageNode,\n}: WishlistItemProps) => {\n const [productData, setProductData] = useState<Product | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n\n async function fetchProductData() {\n try {\n let data: Product | null;\n if (getRefinedProduct && item?.selectedOptions?.length > 0) {\n data = await getRefinedProduct(\n item.product.sku,\n item.selectedOptions.map((option: { uid: any }) => option.uid)\n );\n } else {\n data = getProductData\n ? await getProductData(item?.product.sku)\n : item?.product;\n }\n if (!cancelled) setProductData(data);\n } catch (err) {\n if (!cancelled) {\n console.error('Failed to fetch product data:', err);\n }\n }\n }\n\n fetchProductData();\n\n return () => {\n cancelled = true;\n };\n }, [item, getProductData, getRefinedProduct]);\n\n /**\n * Removes product from wishlist\n */\n const removeProductFromWishlist = useCallback(\n async (showAlert: boolean = true): Promise<boolean> => {\n try {\n await removeProductsFromWishlist([item]);\n console.log(`Product ${productData?.sku} removed from wishlist!`);\n if (showAlert) {\n events.emit('wishlist/alert', {\n action: 'remove',\n item: { ...item, product: productData },\n });\n }\n return true;\n } catch (error) {\n console.error(\n `Product ${productData.sku} could not be removed from wishlist`,\n error\n );\n return false;\n }\n },\n [item, productData]\n );\n\n /**\n * Moves product to cart\n */\n const moveProductToCart = useCallback(async (): Promise<boolean> => {\n try {\n await moveProdToCart([\n {\n sku: productData.sku,\n quantity: 1,\n optionsUIDs: item.selectedOptions?.map(\n (option: { uid: any }) => option.uid\n ),\n enteredOptions: item.enteredOptions,\n },\n ]);\n console.log(`Product ${productData.sku} successfully moved to cart 🛒`);\n events.emit('wishlist/alert', {\n action: 'move',\n item: { ...item, product: productData },\n });\n return await removeProductFromWishlist(false);\n } catch (error) {\n console.error('Could not move product to cart: ', error);\n if (\n error.toString().includes('You need to choose options for your item.')\n ) {\n window.location.replace(routeProdDetailPage(productData));\n }\n return false;\n }\n }, [\n productData,\n item,\n moveProdToCart,\n routeProdDetailPage,\n removeProductFromWishlist,\n ]);\n\n if (!productData || !item) return null;\n\n return (\n <ProductItem\n item={{ ...item, product: productData }}\n onCartActionButtonClick={moveProductToCart}\n onTrashButtonClick={removeProductFromWishlist}\n routeProdDetailPage={routeProdDetailPage}\n imageNode={imageNode}\n />\n );\n};\n"],"names":["ProductItem","className","item","onCartActionButtonClick","onTrashButtonClick","routeProdDetailPage","imageNode","props","labels","useText","discounted","_c","_b","_a","_f","_e","_d","renderImage","jsx","ImageCarousel","renderPrices","_i","_h","_g","jsxs","Fragment","Price","_l","_k","_j","_o","_n","_m","_r","_q","_p","_u","_t","_s","classes","_x","_w","_v","_A","_z","_y","_D","_C","_B","_G","_F","_E","renderTrashButton","Button","Icon","Trash","renderMainActionButton","isProductReady","renderMoveToCartButton","renderCustomizeButton","areAllRequiredOptionsIncluded","selectedOptions","useMemo","opt","requiredOptions","options","required","option","renderOptions","selectedValue","Cart","children","images","carouselIndex","setCarouselIndex","useState","image","index","defaultProps","Image","_image","event","WishlistItem","getProductData","getRefinedProduct","moveProdToCart","productData","setProductData","useEffect","cancelled","fetchProductData","data","err","removeProductFromWishlist","useCallback","showAlert","removeProductsFromWishlist","events","error","moveProductToCart"],"mappings":"4gBA4CO,MAAMA,GAAmD,CAAC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
|
All Rights Reserved. */
|
|
3
|
-
import{Initializer as
|
|
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 f,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),p().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 p().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})):[]:[]}const D=`
|
|
4
4
|
query STORE_CONFIG_QUERY {
|
|
5
5
|
storeConfig {
|
|
6
6
|
magento_wishlist_general_is_enabled
|
|
7
7
|
enable_multiple_wishlists
|
|
8
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
9
|
}
|
|
15
10
|
}
|
|
16
|
-
`,
|
|
17
|
-
fragment PRICE_RANGE_FRAGMENT on PriceRange {
|
|
18
|
-
minimum_price {
|
|
19
|
-
regular_price {
|
|
20
|
-
value
|
|
21
|
-
currency
|
|
22
|
-
}
|
|
23
|
-
final_price {
|
|
24
|
-
value
|
|
25
|
-
currency
|
|
26
|
-
}
|
|
27
|
-
discount {
|
|
28
|
-
percent_off
|
|
29
|
-
amount_off
|
|
30
|
-
}
|
|
31
|
-
fixed_product_taxes {
|
|
32
|
-
amount {
|
|
33
|
-
currency
|
|
34
|
-
value
|
|
35
|
-
}
|
|
36
|
-
label
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
maximum_price {
|
|
40
|
-
regular_price {
|
|
41
|
-
value
|
|
42
|
-
currency
|
|
43
|
-
}
|
|
44
|
-
final_price {
|
|
45
|
-
value
|
|
46
|
-
currency
|
|
47
|
-
}
|
|
48
|
-
discount {
|
|
49
|
-
percent_off
|
|
50
|
-
amount_off
|
|
51
|
-
}
|
|
52
|
-
fixed_product_taxes {
|
|
53
|
-
amount {
|
|
54
|
-
currency
|
|
55
|
-
value
|
|
56
|
-
}
|
|
57
|
-
label
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
`,z=`
|
|
62
|
-
... on SimpleProduct {
|
|
63
|
-
options {
|
|
64
|
-
uid
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
`,Y=`
|
|
68
|
-
... on ConfigurableProduct {
|
|
69
|
-
configurable_options {
|
|
70
|
-
uid
|
|
71
|
-
attribute_uid
|
|
72
|
-
attribute_code
|
|
73
|
-
values {
|
|
74
|
-
uid
|
|
75
|
-
label
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
variants {
|
|
79
|
-
attributes {
|
|
80
|
-
code
|
|
81
|
-
uid
|
|
82
|
-
label
|
|
83
|
-
}
|
|
84
|
-
product {
|
|
85
|
-
sku
|
|
86
|
-
stock_status
|
|
87
|
-
image {
|
|
88
|
-
label
|
|
89
|
-
url
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
`,Q=`
|
|
95
|
-
... on DownloadableProduct {
|
|
96
|
-
image {
|
|
97
|
-
label
|
|
98
|
-
url
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
`,K=`
|
|
102
|
-
... on GiftCardProduct {
|
|
103
|
-
giftcard_type
|
|
104
|
-
giftcard_amounts {
|
|
105
|
-
uid
|
|
106
|
-
website_id
|
|
107
|
-
value
|
|
108
|
-
attribute_id
|
|
109
|
-
website_value
|
|
110
|
-
}
|
|
111
|
-
gift_card_options {
|
|
112
|
-
title
|
|
113
|
-
required
|
|
114
|
-
uid
|
|
115
|
-
... on CustomizableFieldOption {
|
|
116
|
-
value: value {
|
|
117
|
-
uid
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
`,j=`
|
|
123
|
-
... on BundleProduct {
|
|
124
|
-
items {
|
|
125
|
-
uid
|
|
126
|
-
required
|
|
127
|
-
title
|
|
128
|
-
options {
|
|
129
|
-
uid
|
|
130
|
-
label
|
|
131
|
-
quantity
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
`,x=`
|
|
136
|
-
fragment PRODUCT_FRAGMENT on ProductInterface {
|
|
137
|
-
__typename
|
|
138
|
-
uid
|
|
139
|
-
sku
|
|
140
|
-
name
|
|
141
|
-
thumbnail {
|
|
142
|
-
url
|
|
143
|
-
label
|
|
144
|
-
}
|
|
145
|
-
url_key
|
|
146
|
-
categories {
|
|
147
|
-
url_path
|
|
148
|
-
url_key
|
|
149
|
-
name
|
|
150
|
-
}
|
|
151
|
-
stock_status
|
|
152
|
-
canonical_url
|
|
153
|
-
custom_attributesV2(filters: {is_visible_on_front: true}){
|
|
154
|
-
items {
|
|
155
|
-
code
|
|
156
|
-
...on AttributeValue {
|
|
157
|
-
value
|
|
158
|
-
}
|
|
159
|
-
...on AttributeSelectedOptions {
|
|
160
|
-
selected_options {
|
|
161
|
-
value
|
|
162
|
-
label
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
price_range {
|
|
168
|
-
...PRICE_RANGE_FRAGMENT
|
|
169
|
-
}
|
|
170
|
-
${z}
|
|
171
|
-
${Y}
|
|
172
|
-
${Q}
|
|
173
|
-
${K}
|
|
174
|
-
${j}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
${B}
|
|
178
|
-
`,V=`
|
|
179
|
-
query GET_PRODUCT_BY_SKU($sku: String!) {
|
|
180
|
-
products(filter: { sku: { eq: $sku } }) {
|
|
181
|
-
items {
|
|
182
|
-
...PRODUCT_FRAGMENT
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
${x}
|
|
188
|
-
`,Z=async(e,t)=>{if(!e)throw Error("Product SKU is not set");return T(V,{variables:{sku:e}}).then(({errors:i,data:s})=>{var n;return i?b(i):(n=s==null?void 0:s.products)!=null&&n.items?w(s.products.items[0],t??[]):null})},X=`
|
|
11
|
+
`,C=async()=>I(D,{method:"GET",cache:"force-cache"}).then(({errors:t,data:s})=>t?f(t):N(s)),U=`
|
|
189
12
|
fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {
|
|
190
13
|
type
|
|
191
14
|
customizable_option_uid
|
|
@@ -201,7 +24,7 @@ ${x}
|
|
|
201
24
|
}
|
|
202
25
|
}
|
|
203
26
|
}
|
|
204
|
-
`,
|
|
27
|
+
`,v=`
|
|
205
28
|
... on ConfigurableWishlistItem {
|
|
206
29
|
configurable_options {
|
|
207
30
|
option_label
|
|
@@ -213,7 +36,7 @@ ${x}
|
|
|
213
36
|
canonical_url
|
|
214
37
|
}
|
|
215
38
|
}
|
|
216
|
-
`,
|
|
39
|
+
`,F=`
|
|
217
40
|
... on DownloadableWishlistItem {
|
|
218
41
|
added_at
|
|
219
42
|
description
|
|
@@ -225,7 +48,7 @@ ${x}
|
|
|
225
48
|
}
|
|
226
49
|
quantity
|
|
227
50
|
}
|
|
228
|
-
`,
|
|
51
|
+
`,k=`
|
|
229
52
|
... on GiftCardWishlistItem {
|
|
230
53
|
added_at
|
|
231
54
|
description
|
|
@@ -245,7 +68,7 @@ ${x}
|
|
|
245
68
|
sender_name
|
|
246
69
|
}
|
|
247
70
|
}
|
|
248
|
-
`,
|
|
71
|
+
`,H=`
|
|
249
72
|
... on BundleWishlistItem {
|
|
250
73
|
bundle_options {
|
|
251
74
|
label
|
|
@@ -258,7 +81,7 @@ ${x}
|
|
|
258
81
|
}
|
|
259
82
|
}
|
|
260
83
|
}
|
|
261
|
-
`,
|
|
84
|
+
`,P=`
|
|
262
85
|
fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
|
|
263
86
|
__typename
|
|
264
87
|
id
|
|
@@ -266,20 +89,19 @@ fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
|
|
|
266
89
|
description
|
|
267
90
|
added_at
|
|
268
91
|
product {
|
|
269
|
-
|
|
92
|
+
sku
|
|
270
93
|
}
|
|
271
|
-
${
|
|
272
|
-
${
|
|
273
|
-
${
|
|
274
|
-
${
|
|
94
|
+
${v}
|
|
95
|
+
${F}
|
|
96
|
+
${k}
|
|
97
|
+
${H}
|
|
275
98
|
customizable_options {
|
|
276
99
|
...CUSTOMIZABLE_OPTIONS_FRAGMENT
|
|
277
100
|
}
|
|
278
101
|
}
|
|
279
102
|
|
|
280
|
-
${
|
|
281
|
-
|
|
282
|
-
`,A=`
|
|
103
|
+
${U}
|
|
104
|
+
`,S=`
|
|
283
105
|
fragment WISHLIST_FRAGMENT on Wishlist {
|
|
284
106
|
id
|
|
285
107
|
updated_at
|
|
@@ -292,8 +114,8 @@ fragment WISHLIST_FRAGMENT on Wishlist {
|
|
|
292
114
|
}
|
|
293
115
|
}
|
|
294
116
|
|
|
295
|
-
${
|
|
296
|
-
|
|
117
|
+
${P}
|
|
118
|
+
`,$=`
|
|
297
119
|
query GET_WISHLISTS_QUERY {
|
|
298
120
|
customer {
|
|
299
121
|
wishlists {
|
|
@@ -302,8 +124,8 @@ ${se}
|
|
|
302
124
|
}
|
|
303
125
|
}
|
|
304
126
|
|
|
305
|
-
${
|
|
306
|
-
`,
|
|
127
|
+
${S}
|
|
128
|
+
`,q=async()=>e.authenticated?I($).then(({errors:t,data:s})=>{var i;return t?f(t):(i=s==null?void 0:s.customer)!=null&&i.wishlists?s.customer.wishlists.map(a=>w(a)):null}):h(),z=`
|
|
307
129
|
mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(
|
|
308
130
|
$wishlistId: ID!,
|
|
309
131
|
$wishlistItems: [WishlistItemInput!]!,
|
|
@@ -321,5 +143,6 @@ ${se}
|
|
|
321
143
|
}
|
|
322
144
|
}
|
|
323
145
|
}
|
|
324
|
-
${
|
|
325
|
-
`,
|
|
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:O,optionsUIDs:b,enteredOptions:M})=>({sku:W,quantity:O,selected_options:b,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),f(_);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)),p=async()=>{if(e.initializing)return null;e.initializing=!0,e.config||(e.config=await C());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,p as e,Q as f,C as g,Y as h,g as i,Z as m,B as r,w as t};
|
|
148
|
+
//# sourceMappingURL=mergeWishlists.js.map
|