@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeWishlists.js","sources":["/@dropins/storefront-wishlist/src/api/initialize/initialize.ts","/@dropins/storefront-wishlist/src/data/transforms/transform-store-config.ts","/@dropins/storefront-wishlist/src/data/transforms/transform-wishlist.ts","/@dropins/storefront-wishlist/src/api/getStoreConfig/graphql/StoreConfigQuery.ts","/@dropins/storefront-wishlist/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-wishlist/src/api/graphql/CustomizableOptionsFragment.graphql.ts","/@dropins/storefront-wishlist/src/api/graphql/WishlistItemFragment.graphql.ts","/@dropins/storefront-wishlist/src/api/graphql/WishlistFragment.graphql.ts","/@dropins/storefront-wishlist/src/api/getWishlists/graphql/getWishlists.graphql.ts","/@dropins/storefront-wishlist/src/api/getWishlists/getWishlists.ts","/@dropins/storefront-wishlist/src/api/addProductsToWishlist/graphql/addProductsToWishlistMutation.ts","/@dropins/storefront-wishlist/src/api/addProductsToWishlist/addProductsToWishlist.ts","/@dropins/storefront-wishlist/src/api/resetWishlist/resetWishlist.ts","/@dropins/storefront-wishlist/src/api/initializeWishlist/initializeWishlist.ts","/@dropins/storefront-wishlist/src/api/mergeWishlists/mergeWishlists.ts"],"sourcesContent":["import { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/wishlist/lib/state';\nimport {\n initializeWishlist,\n resetWishlist,\n mergeWishlists,\n} from '@/wishlist/api';\nimport { setPersistedWishlistData } from '@/wishlist/lib/persisted-data';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n isGuestWishlistEnabled?: boolean;\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = { isGuestWishlistEnabled: false, ...config };\n\n initialize.config.setConfig(defaultConfig);\n initializeWishlist().catch(console.error);\n },\n\n listeners: () => [\n events.on(\n 'wishlist/data',\n (payload) => {\n setPersistedWishlistData(payload);\n },\n { eager: true }\n ),\n events.on(\n 'authenticated',\n async (authenticated) => {\n if (state.authenticated && !authenticated) {\n // Reset wishlist if the user is no longer authenticated\n events.emit('wishlist/reset', undefined);\n }\n // Login event occurred\n if (authenticated && !state.authenticated) {\n state.authenticated = authenticated;\n const wishlist = await initializeWishlist().catch(console.error);\n if (wishlist) {\n mergeWishlists(wishlist);\n }\n }\n },\n { eager: true }\n ),\n events.on('wishlist/reset', () => {\n resetWishlist().catch(console.error);\n events.emit('wishlist/data', null);\n }),\n ],\n});\n\nexport const config = initialize.config;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 { StoreConfigModel } from '@/wishlist/data/models';\n\nexport function transformStoreConfig(data: any): StoreConfigModel | null {\n if (!data) return null;\n\n return {\n wishlistIsEnabled: data.storeConfig.magento_wishlist_general_is_enabled,\n wishlistMultipleListIsEnabled: data.storeConfig.enable_multiple_wishlists,\n wishlistMaxNumber: data.storeConfig.maximum_number_of_wishlists,\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 *******************************************************************/\nimport { Wishlist, Item, Option } from '@/wishlist/data/models/wishlist';\n\nexport function transformWishlist(\n data: any,\n enteredOptions?: { uid: string; value: string }[]\n): Wishlist | null {\n if (!data) return null;\n\n return {\n id: data.id,\n updated_at: data.updated_at,\n sharing_code: data.sharing_code,\n items_count: data.items_count,\n items: transformItems(data, enteredOptions ?? []),\n };\n}\n\nfunction transformItems(\n data: any,\n enteredOptions: { uid: string; value: string }[]\n): Item[] {\n if (!data?.items_v2?.items?.length) return [];\n\n return data.items_v2.items.map((item: any) => {\n const selectedOptions = getSelectedOptions(item);\n return {\n id: item.id,\n quantity: item.quantity,\n description: item.description,\n added_at: item.added_at,\n enteredOptions,\n selectedOptions,\n product: { sku: item.product.sku },\n };\n });\n}\n\nfunction getSelectedOptions(item: Item): Option[] {\n if (item.__typename === 'ConfigurableWishlistItem') {\n return item.configurable_options\n ? item.configurable_options.map((option: any) => ({\n uid: option.configurable_product_option_value_uid,\n }))\n : [];\n }\n return [];\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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\nexport 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`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 { StoreConfigModel } from '@/wishlist/data/models';\nimport { transformStoreConfig } from '@/wishlist/data/transforms';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\n\nimport { STORE_CONFIG_QUERY } from './graphql/StoreConfigQuery';\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel | null> => {\n return fetchGraphQl(STORE_CONFIG_QUERY, {\n method: 'GET',\n cache: 'force-cache',\n }).then(({ errors, data }) => {\n if (errors) return handleFetchError(errors);\n\n return transformStoreConfig(data);\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\nexport const CUSTOMIZABLE_OPTIONS_FRAGMENT = `\n fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {\n type\n customizable_option_uid\n label\n is_required\n values {\n label\n value\n price{\n type\n units\n value\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 { CUSTOMIZABLE_OPTIONS_FRAGMENT } from './CustomizableOptionsFragment.graphql';\n\nconst CONFIGURABLE_WISHLIST_ITEM_FRAGMENT = `\n ... on ConfigurableWishlistItem {\n configurable_options {\n option_label\n value_label\n configurable_product_option_value_uid\n configurable_product_option_uid\n }\n configured_variant {\n canonical_url\n }\n }\n`;\n\nconst DOWNLOADABLE_WISHLIST_ITEM_FRAGMENT = `\n ... on DownloadableWishlistItem {\n added_at\n description\n links_v2 {\n sample_url\n sort_order\n title\n uid\n }\n quantity\n }\n`;\n\nconst GIFT_CARD_WISHLIST_ITEM_FRAGMENT = `\n ... on GiftCardWishlistItem {\n added_at\n description\n gift_card_options {\n amount {\n value\n currency\n }\n custom_giftcard_amount {\n value\n currency\n }\n message\n recipient_email\n recipient_name\n sender_email\n sender_name\n }\n }\n`;\n\nconst BUNDLE_WISHLIST_ITEM_FRAGMENT = `\n ... on BundleWishlistItem {\n bundle_options {\n label\n type\n uid\n values {\n uid\n label\n quantity\n }\n }\n }\n`;\n\nexport const WISHLIST_ITEM_FRAGMENT = `\nfragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {\n __typename\n id\n quantity\n description\n added_at\n product {\n sku\n }\n ${CONFIGURABLE_WISHLIST_ITEM_FRAGMENT}\n ${DOWNLOADABLE_WISHLIST_ITEM_FRAGMENT}\n ${GIFT_CARD_WISHLIST_ITEM_FRAGMENT}\n ${BUNDLE_WISHLIST_ITEM_FRAGMENT}\n customizable_options {\n ...CUSTOMIZABLE_OPTIONS_FRAGMENT\n }\n }\n \n ${CUSTOMIZABLE_OPTIONS_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 { WISHLIST_ITEM_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const WISHLIST_FRAGMENT = `\nfragment WISHLIST_FRAGMENT on Wishlist {\n id\n updated_at\n sharing_code\n items_count\n items_v2 {\n items {\n ...WISHLIST_ITEM_FRAGMENT\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 { WISHLIST_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const GET_WISHLISTS_QUERY = `\n query GET_WISHLISTS_QUERY {\n customer {\n wishlists {\n ...WISHLIST_FRAGMENT\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 { GET_WISHLISTS_QUERY } from '@/wishlist/api/getWishlists/graphql/getWishlists.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';\n\nexport const getWishlists = async (): 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 return fetchGraphQl(GET_WISHLISTS_QUERY).then(({ errors, data }) => {\n if (errors) return handleFetchError(errors);\n\n if (!data?.customer?.wishlists) {\n return null;\n }\n\n return data.customer.wishlists.map((wishlist: any) =>\n transformWishlist(wishlist)\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 { WISHLIST_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const ADD_PRODUCTS_TO_WISHLIST_MUTATION = `\n mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(\n $wishlistId: ID!, \n $wishlistItems: [WishlistItemInput!]!,\n ) {\n addProductsToWishlist(\n wishlistId: $wishlistId\n wishlistItems: $wishlistItems\n ) {\n wishlist {\n ...WISHLIST_FRAGMENT\n }\n user_errors {\n code\n message\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, getPersistedWishlistData } from '@/wishlist/api';\nimport { state } from '@/wishlist/lib/state';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\nimport { ADD_PRODUCTS_TO_WISHLIST_MUTATION } from './graphql/addProductsToWishlistMutation';\nimport { Wishlist } from '@/wishlist/data/models/wishlist';\nimport { transformWishlist } from '@/wishlist/data/transforms';\nimport { events } from '@adobe-commerce/event-bus';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport const addProductsToWishlist = async (\n items: [\n {\n sku: string;\n quantity: number;\n optionsUIDs?: string[]; // should be the options available for the product\n enteredOptions?: { uid: string; value: string }[]; // refer to both selected and entered options\n }\n ]\n): Promise<Wishlist | null> => {\n if (!items) return null;\n\n const wishlist = getPersistedWishlistData();\n let updatedWishlist = {\n id: wishlist?.id ?? '',\n updated_at: '',\n sharing_code: '',\n items_count: 0,\n items: wishlist?.items ?? [],\n };\n\n for (const item of items) {\n const skuExists = updatedWishlist.items?.some((wishlistItem: any) =>\n isMatchingWishlistItem(wishlistItem, {\n sku: item.sku,\n optionUIDs: item.optionsUIDs,\n })\n );\n\n if (skuExists) {\n continue;\n }\n\n const selectedOptions: { uid: string }[] = item.optionsUIDs\n ? item.optionsUIDs?.map((option: any) => ({\n uid: option,\n }))\n : [];\n\n updatedWishlist.items = [\n ...updatedWishlist.items,\n {\n id: crypto.randomUUID(),\n quantity: item.quantity,\n selectedOptions,\n enteredOptions: item.enteredOptions ?? [],\n product: { sku: item.sku },\n },\n ];\n }\n\n updatedWishlist.items_count = updatedWishlist.items?.length;\n events.emit('wishlist/data', updatedWishlist);\n\n if (state.authenticated) {\n if (!state.wishlistId) {\n events.emit('wishlist/data', wishlist);\n throw Error('Wishlist ID is not set');\n }\n\n const variables = {\n wishlistId: state.wishlistId,\n wishlistItems: items.map(\n ({ sku, quantity, optionsUIDs, enteredOptions }) => ({\n sku,\n quantity,\n selected_options: optionsUIDs,\n entered_options: enteredOptions,\n })\n ),\n };\n\n const { errors, data }: { errors: any; data: any } = await fetchGraphQl(\n ADD_PRODUCTS_TO_WISHLIST_MUTATION,\n { variables }\n );\n\n const _errors = [\n ...(data?.addProductsToWishlist?.user_errors ?? []),\n ...(errors ?? []),\n ];\n\n // if saving item to wishlist for logged user failed, we need to restore original wishlist in storage:\n if (_errors.length > 0) {\n events.emit('wishlist/data', wishlist);\n return handleFetchError(_errors);\n }\n\n const updatedWishlist = transformWishlist(\n data.addProductsToWishlist.wishlist,\n items[0]?.enteredOptions ?? []\n );\n events.emit('wishlist/data', updatedWishlist);\n }\n\n return null;\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 { state } from '@/wishlist/lib/state';\nimport { Wishlist } from '@/wishlist/data/models';\n\nexport const resetWishlist = (): Promise<Wishlist | null> => {\n state.wishlistId = null;\n state.authenticated = false;\n\n return Promise.resolve(null);\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 { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/wishlist/lib/state';\nimport { getStoreConfig, getWishlists } from '@/wishlist/api';\nimport { getPersistedWishlistData } from '@/wishlist/lib/persisted-data';\nimport { Wishlist } from '@/wishlist/data/models';\n\nexport const initializeWishlist = async (): Promise<Wishlist | null> => {\n if (state.initializing) return null;\n\n state.initializing = true;\n\n // set config\n if (!state.config) {\n state.config = await getStoreConfig();\n }\n\n const payload = state.authenticated\n ? await getDefaultWishlist()\n : await getGuestWishlist();\n\n events.emit('wishlist/initialized', payload);\n events.emit('wishlist/data', payload);\n\n state.initializing = false;\n\n return payload;\n};\n\nexport async function getDefaultWishlist() {\n const wishlists = await getWishlists();\n const wishlist = wishlists ? wishlists[0] : null;\n if (!wishlist) return null;\n\n state.wishlistId = wishlist.id;\n\n return wishlist;\n}\n\nexport async function getGuestWishlist() {\n try {\n return await getPersistedWishlistData();\n } catch (error) {\n console.error(error);\n throw error;\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, Item } from '@/wishlist/data/models';\nimport { addProductsToWishlist } from '@/wishlist/api';\nimport {\n getPersistedWishlistData,\n clearPersistedLocalStorage,\n} from '@/wishlist/lib/persisted-data';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport const mergeWishlists = async (\n wishlist: Wishlist\n): Promise<Wishlist | null> => {\n if (!wishlist) {\n return null;\n }\n\n const guestWishlist: {\n id?: string;\n items?: Item[];\n } = getPersistedWishlistData(true);\n const itemsToMerge: any[] = [];\n\n guestWishlist?.items?.forEach((item: any) => {\n const optionUIDs =\n item.selectedOptions?.map((option: any) => option.uid) || [];\n\n const exists = wishlist.items.some((wishlistItem: any) =>\n isMatchingWishlistItem(wishlistItem, {\n sku: item.product.sku,\n optionUIDs,\n })\n );\n\n if (!exists) {\n const mergeItem = {\n sku: item.product.sku,\n quantity: 1,\n optionsUIDs: optionUIDs,\n enteredOptions: item.enteredOptions || undefined,\n };\n\n itemsToMerge.push(mergeItem);\n }\n });\n\n if (itemsToMerge.length === 0) {\n return null;\n }\n\n const result = await addProductsToWishlist(itemsToMerge);\n clearPersistedLocalStorage();\n return result;\n};\n"],"names":["initialize","Initializer","config","defaultConfig","initializeWishlist","events","payload","setPersistedWishlistData","authenticated","state","wishlist","mergeWishlists","resetWishlist","transformStoreConfig","data","transformWishlist","enteredOptions","transformItems","_b","_a","item","selectedOptions","getSelectedOptions","option","STORE_CONFIG_QUERY","getStoreConfig","fetchGraphQl","errors","handleFetchError","CUSTOMIZABLE_OPTIONS_FRAGMENT","CONFIGURABLE_WISHLIST_ITEM_FRAGMENT","DOWNLOADABLE_WISHLIST_ITEM_FRAGMENT","GIFT_CARD_WISHLIST_ITEM_FRAGMENT","BUNDLE_WISHLIST_ITEM_FRAGMENT","WISHLIST_ITEM_FRAGMENT","WISHLIST_FRAGMENT","GET_WISHLISTS_QUERY","getWishlists","getPersistedWishlistData","ADD_PRODUCTS_TO_WISHLIST_MUTATION","addProductsToWishlist","items","updatedWishlist","wishlistItem","isMatchingWishlistItem","_c","variables","sku","quantity","optionsUIDs","_errors","_d","_e","getDefaultWishlist","getGuestWishlist","wishlists","error","guestWishlist","itemsToMerge","optionUIDs","mergeItem","result","clearPersistedLocalStorage"],"mappings":"uMAgBa,MAAAA,EAAa,IAAIC,EAAyB,CACrD,KAAM,MAAOC,GAAW,CACtB,MAAMC,EAAgB,CAAE,uBAAwB,GAAO,GAAGD,CAAO,EAEtDF,EAAA,OAAO,UAAUG,CAAa,EACtBC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-bus.js";import{FetchGraphQL as S}from"@dropins/tools/fetch-graphql.js";function g(s){const e=document.cookie.split(";");for(const t of e)if(t.trim().startsWith(`${s}=`))return t.trim().substring(s.length+1);return null}const f={wishlistId:null,authenticated:!1,isLoading:!0},n=new Proxy(f,{set(s,e,t){if(s[e]=t,e==="wishlistId"){if(t===n.wishlistId)return!0;if(t===null)return document.cookie="DROPIN__WISHLIST__WISHLIST-ID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/",!0;const r=new Date;r.setDate(r.getDate()+30),document.cookie=`DROPIN__WISHLIST__WISHLIST-ID=${t}; expires=${r.toUTCString()}; path=/`}return Reflect.set(s,e,t)},get(s,e){return e==="wishlistId"?g("DROPIN__WISHLIST__WISHLIST-ID"):s[e]}});function u(s,e){var o;if(s.product.sku!==e.sku)return!1;const t=((o=s.selectedOptions)==null?void 0:o.map(i=>i.uid).filter(i=>!!i).sort())||[],r=(e.optionUIDs||[]).filter(i=>!!i).sort();return JSON.stringify(t)===JSON.stringify(r)}const c="DROPIN__WISHLIST__WISHLIST__DATA";function E(s){const e=n.authenticated?sessionStorage:localStorage;if(s)try{e.setItem(c,JSON.stringify(s))}catch(t){
|
|
3
|
+
import{events as d}from"@dropins/tools/event-bus.js";import{FetchGraphQL as S}from"@dropins/tools/fetch-graphql.js";function g(s){const e=document.cookie.split(";");for(const t of e)if(t.trim().startsWith(`${s}=`))return t.trim().substring(s.length+1);return null}const f={wishlistId:null,authenticated:!1,isLoading:!0},n=new Proxy(f,{set(s,e,t){if(s[e]=t,e==="wishlistId"){if(t===n.wishlistId)return!0;if(t===null)return document.cookie="DROPIN__WISHLIST__WISHLIST-ID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/",!0;const r=new Date;r.setDate(r.getDate()+30),document.cookie=`DROPIN__WISHLIST__WISHLIST-ID=${t}; expires=${r.toUTCString()}; path=/`}return Reflect.set(s,e,t)},get(s,e){return e==="wishlistId"?g("DROPIN__WISHLIST__WISHLIST-ID"):s[e]}});function u(s,e){var o;if(s.product.sku!==e.sku)return!1;const t=((o=s.selectedOptions)==null?void 0:o.map(i=>i.uid).filter(i=>!!i).sort())||[],r=(e.optionUIDs||[]).filter(i=>!!i).sort();return JSON.stringify(t)===JSON.stringify(r)}const c="DROPIN__WISHLIST__WISHLIST__DATA";function E(s){const e=n.authenticated?sessionStorage:localStorage;if(s)try{e.setItem(c,JSON.stringify(s))}catch(t){_(t)?console.error("Storage quota exceeded:",t):console.error("Error saving wishlist:",t)}else e.removeItem(c)}const _=s=>s instanceof DOMException&&s.name==="QuotaExceededError";function p(s=!1){const e=n.authenticated&&!s?sessionStorage:localStorage;try{const t=e.getItem(c);return t?JSON.parse(t):{id:"",items:[]}}catch(t){return console.error("Error retrieving wishlist:",t),{id:"",items:[]}}}function H(){localStorage.removeItem(c)}function L(s,e=[]){var o;const t=n.authenticated?sessionStorage:localStorage,r=t.getItem(c)?JSON.parse(String(t.getItem(c))):{items:[]};return(o=r==null?void 0:r.items)==null?void 0:o.find(i=>u(i,{sku:s,optionUIDs:e}))}const{setEndpoint:P,setFetchGraphQlHeader:F,removeFetchGraphQlHeader:R,setFetchGraphQlHeaders:M,fetchGraphQl:w,getConfig:N}=new S().getMethods(),D=s=>{const e=s.map(t=>t.message).join(" ");throw Error(e)},O=`
|
|
4
4
|
mutation REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION(
|
|
5
5
|
$wishlistId: ID!,
|
|
6
6
|
$wishlistItemsIds: [ID!]!,
|
|
@@ -15,4 +15,5 @@ import{events as d}from"@dropins/tools/event-bus.js";import{FetchGraphQL as S}fr
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
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};
|
|
19
|
+
//# sourceMappingURL=removeProductsFromWishlist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeProductsFromWishlist.js","sources":["/@dropins/storefront-wishlist/src/lib/cookies.ts","/@dropins/storefront-wishlist/src/lib/state.ts","/@dropins/storefront-wishlist/src/lib/wishlist-item-comparator.ts","/@dropins/storefront-wishlist/src/lib/persisted-data.ts","/@dropins/storefront-wishlist/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-wishlist/src/lib/fetch-error.ts","/@dropins/storefront-wishlist/src/api/removeProductsFromWishlist/graphql/removeProductsFromWishlistMutation.ts","/@dropins/storefront-wishlist/src/api/removeProductsFromWishlist/removeProductsFromWishlist.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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\nexport function getCookie(cookieName: string) {\n // Split the cookie string into an array of individual cookies\n const cookies = document.cookie.split(';');\n\n // Loop through the cookies to find the one with the specified name\n for (const cookie of cookies) {\n // Check if this cookie starts with the name you're looking for\n if (cookie.trim().startsWith(`${cookieName}=`)) {\n // Extract and return the cookie's value\n return cookie.trim().substring(cookieName.length + 1);\n }\n }\n\n // If the cookie is not found, return null\n return null;\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 { StoreConfigModel } from '@/wishlist/data/models/store-config';\nimport { getCookie } from '@/wishlist/lib/cookies';\n\ntype State = {\n wishlistId: string | null;\n initializing?: boolean;\n isLoading?: boolean;\n locale?: string;\n config?: StoreConfigModel | null;\n authenticated: boolean;\n currentPage?: number;\n pageSize?: number;\n};\n\nconst _state: State = (() => {\n return {\n wishlistId: null,\n authenticated: false,\n isLoading: true,\n };\n})();\n\n// Proxy state to allow reactivity\nexport const state = new Proxy(_state, {\n set(target, key, value) {\n // @ts-ignore\n target[key] = value;\n\n if (key === 'wishlistId') {\n // only update cookie if value has changed\n if (value === state.wishlistId) return true;\n\n if (value === null) {\n // remove cookie\n document.cookie = `DROPIN__WISHLIST__WISHLIST-ID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;\n return true;\n }\n\n // set expiration date\n const expires = new Date();\n expires.setDate(expires.getDate() + 30);\n // set cookie\n document.cookie = `DROPIN__WISHLIST__WISHLIST-ID=${value}; expires=${expires.toUTCString()}; path=/`;\n }\n\n return Reflect.set(target, key, value);\n },\n get(target, key) {\n if (key === 'wishlistId') {\n // get value from cookie\n return getCookie('DROPIN__WISHLIST__WISHLIST-ID');\n }\n\n return target[key as keyof State];\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 { Item } from '@/wishlist/data/models/wishlist';\n\ninterface ProductLike {\n sku: string;\n optionUIDs?: string[];\n}\n\n/**\n * Helper function to compare wishlist items by their SKU and selected options\n */\nexport function isMatchingWishlistItem(\n wishlistItem: Item,\n product: ProductLike\n): boolean {\n // Compare SKUs first for early return\n if (wishlistItem.product.sku !== product.sku) {\n return false;\n }\n\n // Compare selected options\n const wishlistItemOptions =\n wishlistItem.selectedOptions\n ?.map((option: any) => option.uid)\n .filter((uid: any) => !!uid)\n .sort() || [];\n const productOptionUIDs = (product.optionUIDs || [])\n .filter((uid: any) => !!uid)\n .sort();\n\n // If options match (or both are empty), items are considered matching\n return (\n JSON.stringify(wishlistItemOptions) === JSON.stringify(productOptionUIDs)\n );\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 } from '@/wishlist/data/models';\nimport { state } from '@/wishlist/lib/state';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nconst WISHLIST_KEY = 'DROPIN__WISHLIST__WISHLIST__DATA';\n\nexport function setPersistedWishlistData(data: Wishlist | null) {\n const $storage = state.authenticated ? sessionStorage : localStorage;\n if (data) {\n try {\n $storage.setItem(WISHLIST_KEY, JSON.stringify(data));\n } catch (error) {\n if (isQuotaExceededError(error)) {\n console.error('Storage quota exceeded:', error);\n } else {\n console.error('Error saving wishlist:', error);\n }\n }\n } else {\n $storage.removeItem(WISHLIST_KEY);\n }\n}\n\nconst isQuotaExceededError = (error: unknown) => {\n //https://mmazzarolo.com/blog/2022-06-25-local-storage-status/\n return error instanceof DOMException && error.name === 'QuotaExceededError';\n};\n\nexport function getPersistedWishlistData(\n guest: boolean = false\n): Wishlist | {} {\n const $storage =\n state.authenticated && !guest ? sessionStorage : localStorage;\n try {\n const wishlist = $storage.getItem(WISHLIST_KEY);\n return wishlist ? JSON.parse(wishlist) : { id: '', items: [] };\n } catch (error) {\n console.error('Error retrieving wishlist:', error);\n return { id: '', items: [] };\n }\n}\n\nexport function clearPersistedLocalStorage() {\n localStorage.removeItem(WISHLIST_KEY);\n}\n\nexport function getWishlistItemFromStorage(\n productSku: string,\n optionUIDs: string[] = []\n) {\n const storage = state.authenticated ? sessionStorage : localStorage;\n const wishlist = storage.getItem(WISHLIST_KEY)\n ? JSON.parse(String(storage.getItem(WISHLIST_KEY)))\n : { id: '', items: [] };\n\n return wishlist?.items?.find((item: any) =>\n isMatchingWishlistItem(item, {\n sku: productSku,\n optionUIDs,\n })\n );\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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\n/** Actions */\nexport const handleFetchError = (errors: Array<{ message: string }>) => {\n const errorMessage = errors.map((e: any) => e.message).join(' ');\n\n throw Error(errorMessage);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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\nexport const REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION = `\n mutation REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION(\n $wishlistId: ID!, \n $wishlistItemsIds: [ID!]!,\n ) {\n removeProductsFromWishlist(\n wishlistId: $wishlistId\n wishlistItemsIds: $wishlistItemsIds\n ) {\n user_errors {\n code\n message\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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';\nimport { REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION } from './graphql/removeProductsFromWishlistMutation';\nimport { Item, Wishlist } from '@/wishlist/data/models/wishlist';\nimport { events } from '@adobe-commerce/event-bus';\nimport { getPersistedWishlistData } from '@/wishlist/lib/persisted-data';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport const removeProductsFromWishlist = async (\n items: Array<Item>\n): Promise<Wishlist | null> => {\n const wishlist = getPersistedWishlistData();\n const updatedWishlist = {\n ...wishlist,\n items: wishlist.items?.filter((wishlistItem: any) => {\n return !items.some((item) =>\n isMatchingWishlistItem(wishlistItem, {\n sku: item.product.sku,\n optionUIDs: item.selectedOptions?.map((option: any) => option.uid),\n })\n );\n }),\n };\n\n if (state.authenticated) {\n if (!state.wishlistId) {\n throw Error('Wishlist ID is not set');\n }\n\n const itemIds = items.map((item) => item.id);\n const { errors, data } = await fetchGraphQl(\n REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION,\n {\n variables: { wishlistId: state.wishlistId, wishlistItemsIds: itemIds },\n }\n );\n\n const _errors = [\n ...(data?.removeProductsFromWishlist?.user_errors ?? []),\n ...(errors ?? []),\n ];\n\n // restore wishlist if removing item failed:\n if (_errors.length > 0) {\n events.emit('wishlist/data', wishlist);\n return handleFetchError(_errors);\n }\n }\n\n updatedWishlist.items_count = updatedWishlist.items?.length;\n events.emit('wishlist/data', updatedWishlist);\n\n return null;\n};\n"],"names":["getCookie","cookieName","cookies","cookie","_state","state","target","key","value","expires","isMatchingWishlistItem","wishlistItem","product","wishlistItemOptions","_a","option","uid","productOptionUIDs","WISHLIST_KEY","setPersistedWishlistData","data","$storage","error","isQuotaExceededError","getPersistedWishlistData","guest","wishlist","clearPersistedLocalStorage","getWishlistItemFromStorage","productSku","optionUIDs","storage","item","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","handleFetchError","errors","errorMessage","e","REMOVE_PRODUCTS_FRO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import {
|
|
2
|
+
import { FunctionComponent, JSX } from 'preact';
|
|
3
|
+
import { ImageNodeRenderProps } from '@dropins/tools/types/elsie/src/components';
|
|
4
4
|
import { Item, Product } from '../../data/models';
|
|
5
5
|
|
|
6
6
|
export interface ProductItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -8,11 +8,6 @@ export interface ProductItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
8
8
|
item?: Item;
|
|
9
9
|
onCartActionButtonClick?: () => boolean;
|
|
10
10
|
onTrashButtonClick?: () => boolean;
|
|
11
|
-
fixedProductTaxesEnabled: boolean;
|
|
12
|
-
fixedProductTaxesApply: boolean;
|
|
13
|
-
fixedProductTaxesEnabledDisplayInProductLists?: string;
|
|
14
|
-
fixedProductTaxesEnabledDisplayInSalesModules?: string;
|
|
15
|
-
fixedProductTaxesEnabledDisplayInProductView?: string;
|
|
16
11
|
routeProdDetailPage: (product: Product) => string;
|
|
17
12
|
imageNode?: (props: {
|
|
18
13
|
defaultImageProps: ImageNodeRenderProps;
|
package/components/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'preact/compat';
|
|
2
|
-
import { Container, SlotProps } from '
|
|
2
|
+
import { Container, SlotProps } from '@dropins/tools/types/elsie/src/lib';
|
|
3
3
|
import { Item, Product } from '../../data/models';
|
|
4
|
-
import { ImageProps } from '
|
|
4
|
+
import { ImageProps } from '@dropins/tools/types/elsie/src/components';
|
|
5
5
|
|
|
6
6
|
export interface WishlistProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
7
|
routeEmptyWishlistCTA?: () => string;
|
|
@@ -11,6 +11,8 @@ export interface WishlistProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
quantity: number;
|
|
12
12
|
}[]) => Promise<any>;
|
|
13
13
|
routeProdDetailPage: (product: Product) => string;
|
|
14
|
+
getProductData?: (sku: string) => Promise<Product | null>;
|
|
15
|
+
getRefinedProduct?: (sku: string, optionUIDs: string[], anchorOptions?: string[], raw?: boolean) => Promise<Product | null>;
|
|
14
16
|
slots?: {
|
|
15
17
|
image?: SlotProps<{
|
|
16
18
|
defaultImageProps: ImageProps;
|
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
|
|
3
|
+
import{jsx as i,jsxs as o,Fragment as F}from"@dropins/tools/preact-jsx-runtime.js";import{useState as f,useCallback as A,useEffect as B,useMemo as E,Fragment as R}from"@dropins/tools/preact-compat.js";import{classes as I,Slot as V,VComponent as Y}from"@dropins/tools/lib.js";import{IllustratedMessage as q,Button as G,Icon as J,SkeletonRow as K,Skeleton as O}from"@dropins/tools/components.js";import{W as Q}from"../chunks/WishlistItem.js";import{events as H}from"@dropins/tools/event-bus.js";import{s as $}from"../chunks/removeProductsFromWishlist.js";import{useText as z,Text as j}from"@dropins/tools/i18n.js";import{W as U}from"../chunks/WishlistAlert.js";import{S as X}from"../chunks/Heart.js";import"../chunks/Trash.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/HeartFilled.js";const Z=({className:r,children:t,ctaLinkURL:e,...m})=>{const h=z({emptyWishlist:"Wishlist.EmptyWishlist.heading",message:"Wishlist.EmptyWishlist.message",cta:"Wishlist.EmptyWishlist.cta"});return i("div",{...m,className:I(["wishlist-empty-wishlist",r]),children:i(q,{className:I(["wishlist-empty-wishlist__wrapper",r]),"data-testid":"wishlist-empty-wishlist",heading:h.emptyWishlist,icon:i(J,{className:"wishlist-empty-wishlist__icon",source:X}),message:i("p",{children:h.message}),action:e?i(G,{"data-testid":"wishlist-empty-wishlist-button",size:"medium",variant:"primary",type:"submit",href:e,children:h.cta},"routeHome"):void 0})})},b=()=>i(K,{children:`
|
|
4
4
|
<svg
|
|
5
5
|
width="100%"
|
|
6
6
|
height="100%"
|
|
@@ -14,4 +14,5 @@ import{jsx as i,jsxs as a,Fragment as b}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
|
-
`}),
|
|
17
|
+
`}),C=()=>o(O,{"data-testid":"wishlist-loader",children:[i(b,{}),i(b,{}),i(b,{})]}),mi=({routeEmptyWishlistCTA:r,routeToWishlist:t,moveProdToCart:e,routeProdDetailPage:m,getProductData:h,getRefinedProduct:_,slots:W,...x})=>{const[g,S]=f(null),[y,n]=f($.authenticated),[k,p]=f($.isLoading),v=l=>n(l),[w,c]=f(null),N=A(l=>{const{action:d,item:a}=l;c(i(U,{action:d,item:a,routeToWishlist:t}))},[t]);return B(()=>{const l=H.on("authenticated",v),d=H.on("wishlist/alert",s=>N(s)),a=H.on("wishlist/data",s=>{S(s),p(!1)},{eager:!0});return()=>{l==null||l.off(),a==null||a.off(),d==null||d.off()}},[N]),i(T,{...x,wishlistData:g,wishlistAlert:w,routeEmptyWishlistCTA:r,moveProdToCart:e,getProductData:h,getRefinedProduct:_,isLoggedIn:y,isLoading:k,routeProdDetailPage:m,slots:W})},T=({className:r,wishlistData:t,wishlistAlert:e,isLoggedIn:m,isLoading:h,moveProdToCart:_,getProductData:W,getRefinedProduct:x,routeEmptyWishlistCTA:g,onLoginClick:S,routeProdDetailPage:y,slots:n,...k})=>{const[p,v]=f(e),w=z({wishlistHeading:"Wishlist.Wishlist.heading",wishlistLoadingHeading:"Wishlist.Wishlist.loading"}),c=E(()=>{var s;return((s=t==null?void 0:t.items)==null?void 0:s.length)>0?t.items.map(u=>i(Q,{item:u,getProductData:W,getRefinedProduct:x,moveProdToCart:_,routeProdDetailPage:y,imageNode:n!=null&&n.image?({defaultImageProps:L})=>i(V,{name:"image",slot:n.image,context:{defaultImageProps:L,item:u}}):void 0},u.id)):null},[t,_,W,x,y,n==null?void 0:n.image]);B(()=>{if(e){v(e);const s=setTimeout(()=>{v(null)},5e3);return()=>clearTimeout(s)}},[e]);const N=E(()=>p?i(Y,{node:p,className:"wishlist-wishlist__alert"}):null,[p]),l=()=>o(F,{children:[i("div",{className:"wishlist-wishlist__heading","data-testid":"wishlist-heading-wrapper",children:i("h1",{className:"wishlist-wishlist__heading-text","data-testid":"loader-wishlist-heading",children:w.wishlistLoadingHeading})}),i(C,{})]}),d=()=>c?o(F,{children:[a,i("div",{className:"wishlist-wishlist__content",children:c})]}):i("div",{className:I(["wishlist-wishlist__content","wishlist-wishlist__content--empty"]),children:o("div",{children:[i(Z,{"data-testid":"empty-wishlist",ctaLinkURL:g==null?void 0:g()}),!m&&i(P,{onLoginClick:S})]})}),a=E(()=>{var s;return c?i("div",{className:"wishlist-wishlist__heading","data-testid":"wishlist-heading-wrapper",children:i("h1",{className:"wishlist-wishlist__heading-text","data-testid":"default-wishlist-heading",children:(s=w.wishlistHeading)==null?void 0:s.split(" {count}").map((u,L)=>{var M;return o(R,{children:[u,L===0&&i("span",{className:"wishlist-wishlist__heading-count","data-testid":"wishlist-heading-count",children:`${t==null?void 0:t.items_count} products`})]},((M=t==null?void 0:t.id)==null?void 0:M.toString())+L)})})}):null},[w,c,t]);return o("div",{...k,className:I(["wishlist-wishlist",r]),children:[N,h?l():d()]})},P=({onLoginClick:r})=>o("div",{className:"wishlist-login__sign-in",children:[i("a",{"data-testid":"log-in-link",className:"wishlist-login__link",href:"",rel:"noreferrer",onClick:r,role:"button",children:i(j,{id:"Wishlist.Login.logIn"})}),i(j,{id:"Wishlist.Login.sync"})]});export{mi as Wishlist,mi as default};
|
|
18
|
+
//# sourceMappingURL=Wishlist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wishlist.js","sources":["/@dropins/storefront-wishlist/src/components/EmptyWishlist/EmptyWishlist.tsx","/@dropins/storefront-wishlist/src/components/Wishlist/WishlistItemSkeleton.tsx","/@dropins/storefront-wishlist/src/components/Wishlist/WishlistSkeleton.tsx","/@dropins/storefront-wishlist/src/containers/Wishlist/Wishlist.tsx","/@dropins/storefront-wishlist/src/components/Wishlist/Wishlist.tsx","/@dropins/storefront-wishlist/src/components/Login/Login.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 { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Button, Icon, IllustratedMessage } from '@adobe-commerce/elsie/components';\nimport { Heart } from '@adobe-commerce/elsie/icons';\n\nimport '@/wishlist/components/EmptyWishlist/EmptyWishlist.css';\n\nexport interface EmptyWishlistProps extends HTMLAttributes<HTMLDivElement> {\n ctaLinkURL?: string;\n}\n\nexport const EmptyWishlist: FunctionComponent<EmptyWishlistProps> = ({\n className,\n children,\n ctaLinkURL,\n ...props\n}) => {\n const labels = useText({\n emptyWishlist: 'Wishlist.EmptyWishlist.heading',\n message: 'Wishlist.EmptyWishlist.message',\n cta: 'Wishlist.EmptyWishlist.cta',\n });\n\n return (\n <div {...props} className={classes(['wishlist-empty-wishlist', className])}>\n <IllustratedMessage\n className={classes(['wishlist-empty-wishlist__wrapper', className])}\n data-testid=\"wishlist-empty-wishlist\"\n heading={labels.emptyWishlist}\n icon={<Icon className=\"wishlist-empty-wishlist__icon\" source={Heart} />}\n message={<p>{labels.message}</p>}\n action={\n ctaLinkURL ? (\n <Button\n data-testid=\"wishlist-empty-wishlist-button\"\n size=\"medium\"\n variant=\"primary\"\n key=\"routeHome\"\n type=\"submit\"\n href={ctaLinkURL}\n >\n {labels.cta}\n </Button>\n ) : undefined\n }\n />\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 { SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const WishlistItemSkeleton: FunctionComponent = () => {\n return (\n <SkeletonRow>{`\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox=\"0 0 288 658\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n preserveAspectRatio=\"xMinYMin meet\"\n >\n <rect x=\"6\" y=\"24\" width=\"282px\" height=\"480\" rx=\"8\" fill=\"#E8E8E8\" />\n <rect x=\"6\" y=\"522\" width=\"280\" height=\"22\" rx=\"4\" fill=\"#E8E8E8\" />\n <rect x=\"6\" y=\"556\" width=\"132\" height=\"22\" rx=\"4\" fill=\"#E8E8E8\" />\n <rect x=\"6\" y=\"592\" width=\"280\" height=\"48\" rx=\"24\" fill=\"#D9D9D9\" />\n </svg>\n `}</SkeletonRow>\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 { Skeleton } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\nimport { WishlistItemSkeleton } from '@/wishlist/components/Wishlist/WishlistItemSkeleton';\n\nexport const WishlistSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"wishlist-loader\">\n <WishlistItemSkeleton />\n <WishlistItemSkeleton />\n <WishlistItemSkeleton />\n </Skeleton>\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 useCallback,\n useEffect,\n useState,\n} from 'preact/compat';\nimport { Container, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { Wishlist as WishlistComponent } from '@/wishlist/components';\nimport { events, WishlistActionPayload } from '@adobe-commerce/event-bus';\nimport {\n Item,\n Product,\n Wishlist as WishlistModel,\n} from '@/wishlist/data/models';\nimport { state } from '@/wishlist/lib/state';\nimport { WishlistAlert } from '@/wishlist/containers/WishlistAlert';\nimport { ImageProps } from '@adobe-commerce/elsie/components';\n\nexport interface WishlistProps extends HTMLAttributes<HTMLDivElement> {\n routeEmptyWishlistCTA?: () => string;\n routeToWishlist?: string;\n moveProdToCart: (\n products: { sku: string; quantity: number }[]\n ) => Promise<any>;\n routeProdDetailPage: (product: Product) => string;\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 slots?: {\n image?: SlotProps<{\n defaultImageProps: ImageProps;\n item: Item;\n }>;\n };\n}\n\nexport const Wishlist: Container<WishlistProps> = ({\n routeEmptyWishlistCTA,\n routeToWishlist,\n moveProdToCart,\n routeProdDetailPage,\n getProductData,\n getRefinedProduct,\n slots,\n ...props\n}: WishlistProps) => {\n const [wishlistData, setWishlistData] = useState<WishlistModel | null>(null);\n const [isLoggedIn, setIsLoggedIn] = useState(state.authenticated);\n const [isLoading, setIsLoading] = useState(state.isLoading);\n\n const handleAuthentication = (authenticated: boolean) =>\n setIsLoggedIn(authenticated);\n\n const [wishlistAlert, setWishlistAlert] = useState<Element | null>(null);\n const handleWishlistAlert = useCallback(\n (payload: WishlistActionPayload) => {\n const { action, item } = payload;\n setWishlistAlert(\n <WishlistAlert\n action={action}\n item={item}\n routeToWishlist={routeToWishlist}\n />\n );\n },\n [routeToWishlist]\n );\n\n useEffect(() => {\n const authEvent = events.on('authenticated', handleAuthentication);\n const updateEvent = events.on('wishlist/alert', (payload) =>\n handleWishlistAlert(payload)\n );\n const dataEvent = events.on(\n 'wishlist/data',\n (payload) => {\n setWishlistData(payload as WishlistModel);\n setIsLoading(false);\n },\n { eager: true }\n );\n return () => {\n authEvent?.off();\n dataEvent?.off();\n updateEvent?.off();\n };\n }, [handleWishlistAlert]);\n\n return (\n <WishlistComponent\n {...props}\n wishlistData={wishlistData}\n wishlistAlert={wishlistAlert}\n routeEmptyWishlistCTA={routeEmptyWishlistCTA}\n moveProdToCart={moveProdToCart}\n getProductData={getProductData}\n getRefinedProduct={getRefinedProduct}\n isLoggedIn={isLoggedIn}\n isLoading={isLoading}\n routeProdDetailPage={routeProdDetailPage}\n slots={slots}\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 { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes, useState, useEffect, useMemo } from 'preact/compat';\nimport {\n VComponent,\n classes,\n Slot,\n SlotProps,\n} from '@adobe-commerce/elsie/lib';\nimport { WishlistSkeleton } from '@/wishlist/components/Wishlist/WishlistSkeleton';\nimport '@/wishlist/components/Wishlist/Wishlist.css';\nimport {\n Product,\n Wishlist as WishlistModel,\n Item,\n} from '@/wishlist/data/models';\nimport { WishlistItem, WishlistAlert } from '@/wishlist/containers';\nimport { Fragment } from 'react';\nimport { EmptyWishlist, Login } from '@/wishlist/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { ImageProps } from '@adobe-commerce/elsie/components';\n\nexport interface WishlistProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n wishlistData: WishlistModel;\n wishlistAlert: WishlistAlert | null;\n isLoggedIn: boolean;\n isLoading: boolean;\n moveProdToCart: (\n products: { sku: string; quantity: number }[]\n ) => Promise<any>;\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 routeEmptyWishlistCTA?: () => string;\n onLoginClick?: () => void;\n routeProdDetailPage: (product: Product) => string;\n slots?: {\n image?: SlotProps<{\n defaultImageProps: ImageProps;\n item: Item;\n }>;\n };\n}\n\nexport const Wishlist: FunctionComponent<WishlistProps> = ({\n className,\n wishlistData,\n wishlistAlert,\n isLoggedIn,\n isLoading,\n moveProdToCart,\n getProductData,\n getRefinedProduct,\n routeEmptyWishlistCTA,\n onLoginClick,\n routeProdDetailPage,\n slots,\n ...props\n}) => {\n const [alert, setAlert] = useState<VNode | null>(wishlistAlert);\n\n const dictionary = useText({\n wishlistHeading: 'Wishlist.Wishlist.heading',\n wishlistLoadingHeading: 'Wishlist.Wishlist.loading',\n });\n\n const products = useMemo(() => {\n return wishlistData?.items?.length > 0\n ? wishlistData.items.map((item: Item) => (\n <WishlistItem\n key={item.id}\n item={item}\n getProductData={getProductData}\n getRefinedProduct={getRefinedProduct}\n moveProdToCart={moveProdToCart}\n routeProdDetailPage={routeProdDetailPage}\n imageNode={\n slots?.image\n ? ({ defaultImageProps }) => (\n <Slot\n name=\"image\"\n slot={slots.image}\n context={{\n defaultImageProps,\n item,\n }}\n />\n )\n : undefined\n }\n />\n ))\n : null;\n }, [wishlistData, moveProdToCart, getProductData, getRefinedProduct, routeProdDetailPage, slots?.image]);\n\n useEffect(() => {\n if (wishlistAlert) {\n setAlert(wishlistAlert);\n\n const timer = setTimeout(() => {\n setAlert(null);\n }, 5000);\n\n return () => clearTimeout(timer);\n }\n }, [wishlistAlert]);\n\n const renderAlert = useMemo(\n () =>\n alert ? (\n <VComponent node={alert} className=\"wishlist-wishlist__alert\" />\n ) : null,\n [alert]\n );\n\n const renderLoader = () => {\n return (\n <>\n <div\n className=\"wishlist-wishlist__heading\"\n data-testid=\"wishlist-heading-wrapper\"\n >\n <h1\n className=\"wishlist-wishlist__heading-text\"\n data-testid=\"loader-wishlist-heading\"\n >\n {dictionary.wishlistLoadingHeading}\n </h1>\n </div>\n <WishlistSkeleton />\n </>\n );\n };\n\n const renderWishlist = () => {\n return products ? (\n <>\n {renderHeading}\n <div className=\"wishlist-wishlist__content\">{products}</div>\n </>\n ) : (\n <div\n className={classes([\n 'wishlist-wishlist__content',\n 'wishlist-wishlist__content--empty',\n ])}\n >\n <div>\n <EmptyWishlist\n data-testid=\"empty-wishlist\"\n ctaLinkURL={routeEmptyWishlistCTA?.()}\n />\n {!isLoggedIn && <Login onLoginClick={onLoginClick} />}\n </div>\n </div>\n );\n };\n\n const renderHeading = useMemo(() => {\n if (!products) return null;\n\n return (\n <div\n className=\"wishlist-wishlist__heading\"\n data-testid=\"wishlist-heading-wrapper\"\n >\n <h1\n className=\"wishlist-wishlist__heading-text\"\n data-testid=\"default-wishlist-heading\"\n >\n {dictionary.wishlistHeading\n ?.split(' {count}')\n .map((title: string, index: number) => (\n <Fragment key={wishlistData?.id?.toString() + index}>\n {title}\n {index === 0 && (\n <span\n className=\"wishlist-wishlist__heading-count\"\n data-testid=\"wishlist-heading-count\"\n >\n {`${wishlistData?.items_count} products`}\n </span>\n )}\n </Fragment>\n ))}\n </h1>\n </div>\n );\n }, [dictionary, products, wishlistData]);\n\n return (\n <div {...props} className={classes(['wishlist-wishlist', className])}>\n {renderAlert}\n {isLoading ? renderLoader() : renderWishlist()}\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 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 { Text } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\nimport '@/wishlist/components/Login/Login.css';\n\nexport interface LoginProps {\n onLoginClick?: () => void;\n}\n\nexport const Login: FunctionComponent<LoginProps> = ({ onLoginClick }) => {\n return (\n <div className=\"wishlist-login__sign-in\">\n <a\n data-testid=\"log-in-link\"\n className=\"wishlist-login__link\"\n href=\"\"\n rel=\"noreferrer\"\n onClick={onLoginClick}\n role=\"button\"\n >\n <Text id=\"Wishlist.Login.logIn\" />\n </a>\n <Text id=\"Wishlist.Login.sync\" />\n </div>\n );\n};\n"],"names":["EmptyWishlist","className","children","ctaLinkURL","props","labels","useText","jsx","classes","IllustratedMessage","Icon","Heart","Button","WishlistItemSkeleton","SkeletonRow","WishlistSkeleton","jsxs","Skeleton","Wishlist","routeEmptyWishlistCTA","routeToWishlist","moveProdToCart","routeProdDetailPage","getProductData","getRefinedProduct","slots","wishlistData","setWishlistData","useState","isLoggedIn","setIsLoggedIn","state","isLoading","setIsLoading","handleAuthentication","authenticated","wishlistAlert","setWishlistAlert","handleWishlistAlert","useCallback","payload","action","item","WishlistAlert","useEffect","authEvent","events","updateEvent","dataEvent","WishlistComponent","onLoginClick","alert","setAlert","dictionary","products","useMemo","_a","WishlistItem","defaultImageProps","Slot","timer","renderAlert","VComponent","renderLoader","Fragment","renderWishlist","renderHeading","Login","title","index","Text"],"mappings":"8xBA8BO,MAAMA,EAAuD,CAAC,CACnE,UAAAC,EACA,SAAAC,EACA,WAAAC,EACA,GAAGC,CACL,IAAM,CACJ,MAAMC,EAASC,EAAQ,CACrB,cAAe,iCACf,QAAS,iCACT,IAAK,4BAAA,CACN,EAGC,OAAAC,EAAC,MAAK,CAAA,GAAGH,EAAO,UAAWI,EAAQ,CAAC,0BAA2BP,CAAS,CAAC,EACvE,SAAAM,EAACE,EAAA,CACC,UAAWD,EAAQ,CAAC,mCAAoCP,CAAS,CAAC,EAClE,cAAY,0BACZ,QAASI,EAAO,cAChB,KAAOE,EAAAG,EAAA,CAAK,UAAU,gCAAgC,OAAQC,EAAO,EACrE,QAASJ,EAAC,IAAG,CAAA,SAAAF,EAAO,QAAQ,EAC5B,OACEF,EACEI,EAACK,EAAA,CACC,cAAY,iCACZ,KAAK,SACL,QAAQ,UAER,KAAK,SACL,KAAMT,EAEL,SAAOE,EAAA,GAAA,EAJJ,WAAA,EAMJ,MAAA,CAAA,EAGV,CAEJ,EC/CaQ,EAA0C,MAElDC,EAAa,CAAA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAcZ,ECfOC,EAAsC,IAE/CC,EAACC,EAAS,CAAA,cAAY,kBACpB,SAAA,CAAAV,EAACM,EAAqB,EAAA,IACrBA,EAAqB,EAAA,IACrBA,EAAqB,CAAA,CAAA,CAAA,EACxB,EC8BSK,GAAqC,CAAC,CACjD,sBAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,oBAAAC,EACA,eAAAC,EACA,kBAAAC,EACA,MAAAC,EACA,GAAGrB,CACL,IAAqB,CACnB,KAAM,CAACsB,E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BAAuB,CAAA,CAAA,CAClC,EACA/D,EAAC+D,EAAK,CAAA,GAAG,qBAAsB,CAAA,CAAA,EACjC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
import{W as e,W as l}from"../chunks/WishlistAlert.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-compat.js";import"../chunks/Trash.js";import"../chunks/HeartFilled.js";import"@dropins/tools/i18n.js";export{e as WishlistAlert,l as default};
|
|
4
|
+
//# sourceMappingURL=WishlistAlert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WishlistAlert.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'preact/compat';
|
|
2
|
-
import { Container } from '
|
|
2
|
+
import { Container } from '@dropins/tools/types/elsie/src/lib';
|
|
3
3
|
import { Item, Product } from '../../data/models';
|
|
4
|
-
import { ImageNodeRenderProps } from '
|
|
4
|
+
import { ImageNodeRenderProps } from '@dropins/tools/types/elsie/src/components';
|
|
5
5
|
import { JSX } from 'preact';
|
|
6
6
|
|
|
7
7
|
export interface WishlistItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
-
|
|
8
|
+
item: Item;
|
|
9
|
+
getProductData?: (sku: string) => Promise<Product | null>;
|
|
10
|
+
getRefinedProduct?: (sku: string, optionUIDs: string[], anchorOptions?: string[], raw?: boolean) => Promise<Product | null>;
|
|
9
11
|
moveProdToCart: (products: {
|
|
10
12
|
sku: string;
|
|
11
13
|
quantity: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{W as l,W as d}from"../chunks/WishlistItem.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/
|
|
3
|
+
import{W as l,W as d}from"../chunks/WishlistItem.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../chunks/removeProductsFromWishlist.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/Trash.js";import"@dropins/tools/i18n.js";export{l as WishlistItem,d as default};
|
|
4
|
+
//# sourceMappingURL=WishlistItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WishlistItem.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as
|
|
3
|
+
import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{useState as h,useCallback as E,useEffect as v}from"@dropins/tools/preact-compat.js";import{Button as F,Icon as I}from"@dropins/tools/components.js";import{events as a}from"@dropins/tools/event-bus.js";import{s as P,g as j,i as x,r as A}from"../chunks/removeProductsFromWishlist.js";import{c as M,a as R}from"../chunks/mergeWishlists.js";import{S as q}from"../chunks/HeartFilled.js";import{S as H}from"../chunks/Heart.js";import{useText as N}from"@dropins/tools/i18n.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const $=({product:i,iconWishlisted:W,iconToWishlist:g,size:d,variant:D,disabled:u,labelToWishlist:U,labelWishlisted:k,onClick:w,removeProdFromCart:f})=>{const[O,b]=h(P.authenticated),[n,o]=h(!1),[L,S]=h(null),{isGuestWishlistEnabled:T}=M.getConfig(),c=N({addToWishlist:"Wishlist.Wishlist.ariaLabelAddToWishlist",removeFromWishlist:"Wishlist.Wishlist.ariaLabelRemoveFromWishlist"}),l=E(()=>{var t;const e=j(),s=(t=e==null?void 0:e.items)==null?void 0:t.find(m=>x(m,{sku:i.topLevelSku??i.sku,optionUIDs:i.optionUIDs??(i.selectedOptionsUIDs?Object.values(i.selectedOptionsUIDs):void 0)}));S(s??null),o(!!s)},[i.topLevelSku,i.sku,i.optionUIDs,i.selectedOptionsUIDs]);v(()=>{l()},[l]),v(()=>{const e=m=>b(m),s=a.on("authenticated",e),t=a.on("wishlist/data",l);return()=>{s==null||s.off(),t==null||t.off()}},[l]);const y=async()=>{var e;if(n){try{await A([L])}catch{return a.emit("wishlist/alert",{action:"removeError",item:{product:i}}),null}o(!1),a.emit("wishlist/alert",{action:"remove",item:{product:i}})}else{try{await R([{sku:i.topLevelSku??i.sku,quantity:1,optionsUIDs:i.optionUIDs??(i.selectedOptionsUIDs?Object.values(i.selectedOptionsUIDs):void 0),enteredOptions:(e=i.options)!=null&&e.items?i.options.items.filter(s=>s.selected).map(s=>({uid:s.uid,value:s.value})):void 0}])}catch{return a.emit("wishlist/alert",{action:"addError",item:{product:i}}),null}o(!0),a.emit("wishlist/alert",{action:"add",item:{product:i}}),f&&await f([{uid:i.uid,quantity:0}])}};if(!O&&!T)return null;const C=n?c.removeFromWishlist.replace("{PRODUCT_NAME}",i==null?void 0:i.name):c.addToWishlist.replace("{PRODUCT_NAME}",i==null?void 0:i.name);return r(F,{active:n,"aria-label":C,"data-testid":"wishlist-toggle",size:d??"medium",variant:D??"tertiary",disabled:u,icon:r(I,{source:g??H}),activeIcon:r(I,{source:W??q}),onClick:w??y,children:U,activeChildren:k})};export{$ as WishlistToggle,$ as default};
|
|
4
|
+
//# sourceMappingURL=WishlistToggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WishlistToggle.js","sources":["/@dropins/storefront-wishlist/src/containers/WishlistToggle/WishlistToggle.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 {\n useState,\n HTMLAttributes,\n useEffect,\n useCallback,\n} from 'preact/compat';\nimport { Button, Icon } from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { Heart, HeartFilled } from '@adobe-commerce/elsie/icons';\nimport { state } from '@/wishlist/lib/state';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nimport {\n addProductsToWishlist,\n removeProductsFromWishlist,\n config,\n} from '@/wishlist/api';\nimport { Product } from '@/wishlist/data/models';\nimport { getPersistedWishlistData } from '@/wishlist/lib/persisted-data';\nimport { VNode } from 'preact';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport interface WishlistToggleProps extends HTMLAttributes<HTMLDivElement> {\n product: Product;\n iconWishlisted?: VNode<HTMLAttributes<SVGSVGElement>>;\n iconToWishlist?: VNode<HTMLAttributes<SVGSVGElement>>;\n size?: 'medium' | 'large';\n variant?: 'primary' | 'secondary' | 'tertiary';\n disabled?: boolean;\n labelToWishlist?: string;\n labelWishlisted?: string;\n onClick?: () => void;\n removeProdFromCart?: (\n product: { uid: string; quantity: number }[]\n ) => Promise<any>;\n}\n\nexport const WishlistToggle: Container<WishlistToggleProps> = ({\n product,\n iconWishlisted,\n iconToWishlist,\n size,\n variant,\n disabled,\n labelToWishlist,\n labelWishlisted,\n onClick,\n removeProdFromCart,\n}: WishlistToggleProps) => {\n const [isLoggedIn, setIsLoggedIn] = useState(state.authenticated);\n const [isWishlisted, setIsWishlisted] = useState(false);\n const [wishlistItem, setWishlistItem] = useState(null);\n const { isGuestWishlistEnabled } = config.getConfig();\n\n const dictionary = useText({\n addToWishlist: 'Wishlist.Wishlist.ariaLabelAddToWishlist',\n removeFromWishlist: 'Wishlist.Wishlist.ariaLabelRemoveFromWishlist',\n });\n\n const handleWishlistData = useCallback(() => {\n const updatedWishlist = getPersistedWishlistData();\n const item = updatedWishlist?.items?.find((item: any) =>\n isMatchingWishlistItem(item, {\n sku: product.topLevelSku ?? product.sku,\n optionUIDs:\n product.optionUIDs ??\n (product.selectedOptionsUIDs\n ? Object.values(product.selectedOptionsUIDs)\n : undefined),\n })\n );\n\n setWishlistItem(item ?? null);\n setIsWishlisted(!!item);\n }, [\n product.topLevelSku,\n product.sku,\n product.optionUIDs,\n product.selectedOptionsUIDs,\n ]);\n\n useEffect(() => {\n handleWishlistData();\n }, [handleWishlistData]);\n\n useEffect(() => {\n const handleAuthentication = (authenticated: boolean) =>\n setIsLoggedIn(authenticated);\n\n const onAuthenticated = events.on('authenticated', handleAuthentication);\n const onWishlistData = events.on('wishlist/data', handleWishlistData);\n\n return () => {\n onAuthenticated?.off();\n onWishlistData?.off();\n };\n }, [handleWishlistData]);\n\n const handleClick = async () => {\n if (isWishlisted) {\n try {\n await removeProductsFromWishlist([wishlistItem]);\n } catch (error) {\n events.emit('wishlist/alert', {\n action: 'removeError',\n item: { product },\n });\n return null;\n }\n\n setIsWishlisted(false);\n events.emit('wishlist/alert', {\n action: 'remove',\n item: { product },\n });\n } else {\n try {\n await addProductsToWishlist([\n {\n sku: product.topLevelSku ?? product.sku,\n quantity: 1,\n optionsUIDs:\n product.optionUIDs ??\n (product.selectedOptionsUIDs\n ? Object.values(product.selectedOptionsUIDs)\n : undefined),\n enteredOptions: product.options?.items\n ? product.options.items\n .filter((option: any) => option.selected)\n .map((option: any) => ({\n uid: option.uid,\n value: option.value,\n }))\n : undefined,\n },\n ]);\n } catch (error) {\n events.emit('wishlist/alert', {\n action: 'addError',\n item: { product },\n });\n return null;\n }\n\n setIsWishlisted(true);\n events.emit('wishlist/alert', {\n action: 'add',\n item: { product },\n });\n if (removeProdFromCart) {\n await removeProdFromCart([\n {\n uid: product.uid,\n quantity: 0,\n },\n ]);\n }\n }\n };\n\n if (!isLoggedIn && !isGuestWishlistEnabled) {\n return null;\n }\n\n const ariaLabel: string = isWishlisted\n ? dictionary['removeFromWishlist'].replace('{PRODUCT_NAME}', product?.name)\n : dictionary['addToWishlist'].replace('{PRODUCT_NAME}', product?.name);\n\n return (\n <Button\n active={isWishlisted}\n aria-label={ariaLabel}\n data-testid=\"wishlist-toggle\"\n size={size ?? 'medium'}\n variant={variant ?? 'tertiary'}\n disabled={disabled}\n icon={<Icon source={iconToWishlist ?? Heart} />}\n activeIcon={<Icon source={iconWishlisted ?? HeartFilled} />}\n onClick={onClick ?? handleClick}\n children={labelToWishlist}\n activeChildren={labelWishlisted}\n />\n );\n};\n"],"names":["WishlistToggle","product","iconWishlisted","iconToWishlist","size","variant","disabled","labelToWishlist","labelWishlisted","onClick","removeProdFromCart","isLoggedIn","setIsLoggedIn","useState","state","isWishlisted","setIsWishlisted","wishlistItem","setWishlistItem","isGuestWishlistEnabled","config","dictionary","useText","handleWishlistData","useCallback","updatedWishlist","getPersistedWishlistData","item","_a","isMatchingWishlistItem","useEffect","handleAuthentication","authenticated","onAuthenticated","events","onWishlistData","handleClick","removeProductsFromWishlist","addProductsToWishlist","option","ariaLabel","jsx","Button","Icon","Heart","HeartFilled"],"mappings":"8lBAuDO,MAAMA,EAAiD,CAAC,CAC7D,QAAAC,EACA,eAAAC,EACA,eAAAC,EACA,KAAAC,EACA,QAAAC,EACA,SAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,QAAAC,EACA,mBAAAC,CACF,IAA2B,CACzB,KAAM,CAACC,EAAYC,CAAa,EAAIC,EAASC,EAAM,aAAa,EAC1D,CAACC,EAAcC,CAAe,EAAIH,EAAS,EAAK,EAChD,CAACI,EAAcC,CAAe,EAAIL,EAAS,IAAI,EAC/C,CAAE,uBAAAM,CAAA,EAA2BC,EAAO,UAAU,EAE9CC,EAAaC,EAAQ,CACzB,cAAe,2CACf,mBAAoB,+CAAA,CACrB,EAEKC,EAAqBC,EAAY,IAAM,OAC3C,MAAMC,EAAkBC,EAAyB,EAC3CC,GAAOC,EAAAH,GAA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GAAgBA,EAAO,QAAQ,EACvC,IAAKA,IAAiB,CACrB,IAAKA,EAAO,IACZ,MAAOA,EAAO,OACd,EACJ,MAAA,CACN,CACD,OACa,CACd,OAAAL,EAAO,KAAK,iBAAkB,CAC5B,OAAQ,WACR,KAAM,CAAE,QAAAjC,CAAQ,CAAA,CACjB,EACM,IAAA,CAGTe,EAAgB,EAAI,EACpBkB,EAAO,KAAK,iBAAkB,CAC5B,OAAQ,MACR,KAAM,CAAE,QAAAjC,CAAQ,CAAA,CACjB,EACGS,GACF,MAAMA,EAAmB,CACvB,CACE,IAAKT,EAAQ,IACb,SAAU,CAAA,CACZ,CACD,CACH,CAEJ,EAEI,GAAA,CAACU,GAAc,CAACQ,EACX,OAAA,KAGT,MAAMqB,EAAoBzB,EACtBM,EAAW,mBAAsB,QAAQ,iBAAkBpB,GAAA,YAAAA,EAAS,IAAI,EACxEoB,EAAW,cAAiB,QAAQ,iBAAkBpB,GAAA,YAAAA,EAAS,IAAI,EAGrE,OAAAwC,EAACC,EAAA,CACC,OAAQ3B,EACR,aAAYyB,EACZ,cAAY,kBACZ,KAAMpC,GAAQ,SACd,QAASC,GAAW,WACpB,SAAAC,EACA,KAAMmC,EAACE,EAAK,CAAA,OAAQxC,GAAkByC,EAAO,EAC7C,WAAYH,EAACE,EAAK,CAAA,OAAQzC,GAAkB2C,EAAa,EACzD,QAASpC,GAAW2B,EACpB,SAAU7B,EACV,eAAgBC,CAAA,CAClB,CAEJ"}
|
package/data/models/product.d.ts
CHANGED
|
@@ -14,60 +14,77 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
+
/**
|
|
18
|
+
* Product data model is based on PDP. For further details see:
|
|
19
|
+
*
|
|
20
|
+
* https://github.com/adobe-commerce/storefront-pdp/blob/develop/src/data/models/product-model.ts
|
|
21
|
+
* https://github.com/adobe-commerce/storefront-pdp/blob/develop/src/data/models/acdl-models.ts
|
|
22
|
+
*/
|
|
17
23
|
export interface Product {
|
|
18
|
-
type: string;
|
|
19
24
|
name: string;
|
|
20
25
|
sku: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
isBundle: boolean;
|
|
27
|
+
addToCartAllowed: boolean;
|
|
28
|
+
inStock: boolean | null;
|
|
29
|
+
shortDescription?: string;
|
|
30
|
+
metaDescription?: string;
|
|
31
|
+
metaKeyword?: string;
|
|
32
|
+
metaTitle?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
images?: Image[];
|
|
35
|
+
prices: Prices;
|
|
36
|
+
attributes?: Attribute[];
|
|
37
|
+
options?: Option[];
|
|
38
|
+
optionUIDs?: string[];
|
|
39
|
+
url?: string;
|
|
40
|
+
urlKey?: string;
|
|
41
|
+
externalId?: string;
|
|
42
|
+
externalParentId?: string;
|
|
43
|
+
variantSku?: string;
|
|
44
|
+
productType?: ProductType | undefined;
|
|
31
45
|
}
|
|
32
|
-
export interface
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
percentOff: number;
|
|
38
|
-
};
|
|
39
|
-
fixedProductTaxes: FixedProductTaxesProps[];
|
|
46
|
+
export interface Image {
|
|
47
|
+
url: string;
|
|
48
|
+
label: string;
|
|
49
|
+
width?: number;
|
|
50
|
+
height?: number;
|
|
40
51
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
currency
|
|
52
|
+
interface Price {
|
|
53
|
+
amount?: number;
|
|
54
|
+
currency?: string;
|
|
55
|
+
maximumAmount?: number;
|
|
56
|
+
minimumAmount?: number;
|
|
57
|
+
variant?: 'default' | 'strikethrough';
|
|
44
58
|
}
|
|
45
|
-
interface
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
export interface Prices {
|
|
60
|
+
regular: Price;
|
|
61
|
+
final: Price;
|
|
62
|
+
visible: boolean;
|
|
48
63
|
}
|
|
49
|
-
interface
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
export interface Option {
|
|
65
|
+
id: string;
|
|
66
|
+
type: 'text' | 'image' | 'color' | 'dropdown';
|
|
67
|
+
typename: 'ProductViewOptionValueProduct' | 'ProductViewOptionValueSwatch' | 'ProductViewOptionValueConfiguration';
|
|
68
|
+
label: string;
|
|
69
|
+
required: boolean;
|
|
70
|
+
multiple: boolean;
|
|
71
|
+
items: OptionValue[];
|
|
52
72
|
}
|
|
53
|
-
interface
|
|
54
|
-
|
|
73
|
+
interface OptionValue {
|
|
74
|
+
id: string;
|
|
55
75
|
label: string;
|
|
76
|
+
inStock: boolean;
|
|
77
|
+
value: string;
|
|
78
|
+
selected: boolean;
|
|
79
|
+
product?: any;
|
|
56
80
|
}
|
|
57
81
|
interface Attribute {
|
|
58
|
-
|
|
59
|
-
value
|
|
60
|
-
selected_options?: AttributeOption[];
|
|
82
|
+
label: string;
|
|
83
|
+
value: string;
|
|
61
84
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
attributeUid?: string;
|
|
66
|
-
required: boolean;
|
|
67
|
-
values: [{
|
|
68
|
-
uid: string;
|
|
69
|
-
label: string;
|
|
70
|
-
}];
|
|
85
|
+
export declare enum ProductType {
|
|
86
|
+
ComplexProduct = "complex",
|
|
87
|
+
SimpleProduct = "simple"
|
|
71
88
|
}
|
|
72
89
|
export {};
|
|
73
90
|
//# sourceMappingURL=product.d.ts.map
|
|
@@ -18,10 +18,5 @@ export interface StoreConfigModel {
|
|
|
18
18
|
wishlistIsEnabled: boolean;
|
|
19
19
|
wishlistMaxNumber: number;
|
|
20
20
|
wishlistMultipleListIsEnabled: boolean;
|
|
21
|
-
fixedProductTaxesEnabled: boolean;
|
|
22
|
-
fixedProductTaxesApply: boolean;
|
|
23
|
-
fixedProductTaxesEnabledDisplayInProductLists: string;
|
|
24
|
-
fixedProductTaxesEnabledDisplayInSalesModules: string;
|
|
25
|
-
fixedProductTaxesEnabledDisplayInProductView: string;
|
|
26
21
|
}
|
|
27
22
|
//# sourceMappingURL=store-config.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SelectedCustomizableOption } from './selected-customizable-option';
|
|
2
|
-
import { Product } from './product';
|
|
3
2
|
|
|
4
3
|
export interface Wishlist {
|
|
5
4
|
id: string;
|
|
@@ -13,17 +12,16 @@ export interface Item {
|
|
|
13
12
|
quantity: number;
|
|
14
13
|
description: string;
|
|
15
14
|
added_at: string;
|
|
16
|
-
selectedOptions:
|
|
15
|
+
selectedOptions: {
|
|
16
|
+
uid: string;
|
|
17
|
+
}[];
|
|
17
18
|
enteredOptions?: {
|
|
18
19
|
uid: string;
|
|
19
20
|
value: string;
|
|
20
21
|
}[];
|
|
21
|
-
product:
|
|
22
|
+
product: {
|
|
23
|
+
sku: string;
|
|
24
|
+
};
|
|
22
25
|
customizableOptions: SelectedCustomizableOption[];
|
|
23
26
|
}
|
|
24
|
-
export interface ConfigurableOption {
|
|
25
|
-
uid: string;
|
|
26
|
-
label: string;
|
|
27
|
-
value: string;
|
|
28
|
-
}
|
|
29
27
|
//# sourceMappingURL=wishlist.d.ts.map
|