@shopware/composables 1.10.0 → 1.11.1
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/README.md +11 -30
- package/dist/index.d.mts +26 -9
- package/dist/index.d.ts +26 -9
- package/dist/index.mjs +37 -23
- package/package.json +16 -14
- package/src/cms/useCmsElementConfig.test.ts +8 -0
- package/src/cms/useCmsElementConfig.ts +3 -0
- package/src/cms/useCmsElementImage.test.ts +23 -0
- package/src/cms/useCmsElementProductBox.test.ts +21 -0
- package/src/devtools/plugin.ts +1 -2
- package/src/mocks/Configurator.ts +36 -36
- package/src/useAddToCart/useAddToCart.test.ts +18 -1
- package/src/useAddress/useAddress.test.ts +41 -2
- package/src/useAddress/useAddress.ts +1 -1
- package/src/useCart/useCart.test.ts +30 -0
- package/src/useCartNotification/useCartNotification.test.ts +30 -0
- package/src/useCheckout/useCheckout.test.ts +43 -1
- package/src/useCmsMeta/useCmsMeta.test.ts +26 -0
- package/src/useCountries/useCountries.test.ts +14 -0
- package/src/useLocalWishlist/useLocalWishlist.test.ts +44 -5
- package/src/useLocalWishlist/useLocalWishlist.ts +3 -2
- package/src/useNavigationContext/useNavigationContext.test.ts +25 -24
- package/src/useNavigationSearch/useNavigationSearch.test.ts +95 -2
- package/src/useNavigationSearch/useNavigationSearch.ts +18 -8
- package/src/useNewsletter/useNewsletter.test.ts +20 -1
- package/src/useNewsletter/useNewsletter.ts +7 -4
- package/src/useOrderDetails/useOrderDetails.test.ts +92 -3
- package/src/useOrderDetails/useOrderDetails.ts +7 -3
- package/src/useOrderPayment/useOrderPayment.test.ts +55 -1
- package/src/usePrice/usePrice.test.ts +10 -0
- package/src/usePrice/usePrice.ts +2 -7
- package/src/useProduct/useProduct.test.ts +14 -1
- package/src/useProductAssociations/useProductAssociations.spec.ts +1 -0
- package/src/useProductConfigurator/useProductConfigurator.spec.ts +38 -0
- package/src/useProductConfigurator/useProductConfigurator.ts +1 -1
- package/src/useProductPrice/useProductPrice.test.ts +7 -7
- package/src/useProductPrice/useProductPrice.ts +12 -4
- package/src/useProductReviews/useProductReviews.test.ts +15 -3
- package/src/useSalutations/useSalutations.spec.ts +13 -0
- package/src/useSessionContext/useSessionContext.test.ts +122 -4
- package/src/useSessionContext/useSessionContext.ts +13 -1
- package/src/useSyncWishlist/useSyncWishlist.test.ts +60 -8
- package/src/useUrlResolver/useUrlResolver.test.ts +6 -12
- package/src/useUrlResolver/useUrlResolver.ts +4 -6
- package/src/useUser/useUser.test.ts +107 -15
- package/src/useWishlist/useWishlist.test.ts +124 -26
package/README.md
CHANGED
|
@@ -165,39 +165,20 @@ All composable functions are fully typed with TypeScript and they are registed g
|
|
|
165
165
|
|
|
166
166
|
Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/composables/CHANGELOG.md)
|
|
167
167
|
|
|
168
|
-
### Latest changes: 1.
|
|
168
|
+
### Latest changes: 1.11.1
|
|
169
169
|
|
|
170
|
-
###
|
|
171
|
-
|
|
172
|
-
- [#2098](https://github.com/shopware/frontends/pull/2098) [`a44d871`](https://github.com/shopware/frontends/commit/a44d8712d9ae5ee196c03ac8b894f3d1392d0e68) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Enhanced the `useSyncWishlist` composable by exposing the `limit`, `products`, and `isLoading` properties, allowing better control and monitoring of the wishlist state. Similarly, updated `useWishlist` to also expose `limit`, `products`, and `isLoading` properties for both local and synced wishlists, providing a consistent API and improved state handling for wishlist management.
|
|
173
|
-
|
|
174
|
-
- [#1997](https://github.com/shopware/frontends/pull/1997) [`e43d9b7`](https://github.com/shopware/frontends/commit/e43d9b7f559af21be8b66f2021cea2d14940e4aa) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Added consts `SUBSRIBE_KEY` and `UNSUBSCRIBE_KEY` for newsletter status in useNewsletter composable
|
|
175
|
-
|
|
176
|
-
- [#1974](https://github.com/shopware/frontends/pull/1974) [`7fe2ef9`](https://github.com/shopware/frontends/commit/7fe2ef96a9d9d156683b85d31f0a660458c9fbfd) Thanks [@mkucmus](https://github.com/mkucmus)! - Use proper associations format within `useDefaultOrderAssociations` (no redundant nesting).
|
|
177
|
-
|
|
178
|
-
Returned value is in type of `Schemas["Criteria"]['associations']` now:
|
|
179
|
-
|
|
180
|
-
```ts
|
|
181
|
-
const { loadOrders } = useCustomerOrders();
|
|
182
|
-
|
|
183
|
-
loadOrders({
|
|
184
|
-
// ... other parameters
|
|
185
|
-
associations: useDefaultOrderAssociations(),
|
|
186
|
-
});
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
- [#2176](https://github.com/shopware/frontends/pull/2176) [`c647baf`](https://github.com/shopware/frontends/commit/c647baf93e7174b849f5961ee5803add99d78602) Thanks [@mkucmus](https://github.com/mkucmus)! - - Add `initialListing` parameter to `useListing` composable for SSR data hydration
|
|
190
|
-
- Update `createCategoryListingContext` to accept initial listing data
|
|
191
|
-
- Maintain backward compatibility with existing implementations
|
|
170
|
+
### Patch Changes
|
|
192
171
|
|
|
193
|
-
- [#
|
|
172
|
+
- [#2372](https://github.com/shopware/frontends/pull/2372) [`22fc8a7`](https://github.com/shopware/frontends/commit/22fc8a7301f6a7d2612d907ab73555978b651c00) Thanks [@patzick](https://github.com/patzick)! - Improve technical URL resolution for SSR and CSR page rendering.
|
|
194
173
|
|
|
195
|
-
|
|
174
|
+
This adds helpers to detect and normalize technical Shopware paths and updates
|
|
175
|
+
`useNavigationSearch` to resolve `/navigation/*`, `/detail/*`, and
|
|
176
|
+
`/landingPage/*` routes more reliably, including fallback behavior when no SEO
|
|
177
|
+
mapping row is returned.
|
|
196
178
|
|
|
197
|
-
- [`
|
|
179
|
+
- [#2407](https://github.com/shopware/frontends/pull/2407) [`bea7f58`](https://github.com/shopware/frontends/commit/bea7f5882cb58c6d47c84a82db5c8ecaf9bcf8ef) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Correct `useNewsletter` `subscribeToNewsletter` return type: it now resolves to the Store API response type for `POST /newsletter/subscribe` instead of `void`.
|
|
198
180
|
|
|
199
|
-
- [#
|
|
181
|
+
- [#2435](https://github.com/shopware/frontends/pull/2435) [`b8c0091`](https://github.com/shopware/frontends/commit/b8c00913c3afb5e1e63de9565105f8f8e3bf299f) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Update `useNewsletter` so `newsletterStatus` is set from the subscribe API response, keeping `isNewsletterSubscriber` in sync without an extra status request.
|
|
200
182
|
|
|
201
|
-
- Updated dependencies [[`
|
|
202
|
-
- @shopware/helpers@1.
|
|
203
|
-
- @shopware/api-client@1.4.0
|
|
183
|
+
- Updated dependencies [[`22fc8a7`](https://github.com/shopware/frontends/commit/22fc8a7301f6a7d2612d907ab73555978b651c00)]:
|
|
184
|
+
- @shopware/helpers@1.7.1
|
package/dist/index.d.mts
CHANGED
|
@@ -1374,7 +1374,7 @@ type UseNewsletterReturn = {
|
|
|
1374
1374
|
* Subscribes the user to the newsletter
|
|
1375
1375
|
* @param params {@link operations['subscribeToNewsletter post /newsletter/subscribe']['body']}
|
|
1376
1376
|
*/
|
|
1377
|
-
newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<
|
|
1377
|
+
newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<operations["subscribeToNewsletter post /newsletter/subscribe"]["response"]>;
|
|
1378
1378
|
/**
|
|
1379
1379
|
* Removes the email from the newsletter
|
|
1380
1380
|
* @param email
|
|
@@ -1401,7 +1401,7 @@ type UseNewsletterReturn = {
|
|
|
1401
1401
|
/**
|
|
1402
1402
|
* Subscribe key
|
|
1403
1403
|
*/
|
|
1404
|
-
|
|
1404
|
+
SUBSCRIBE_KEY: string;
|
|
1405
1405
|
/**
|
|
1406
1406
|
* Unsubscribe key
|
|
1407
1407
|
*/
|
|
@@ -1560,9 +1560,9 @@ type UseOrderDetailsReturn = {
|
|
|
1560
1560
|
* Get order documents
|
|
1561
1561
|
* @param {string} documentId
|
|
1562
1562
|
* @param {string} deepLinkCode
|
|
1563
|
-
* @returns
|
|
1563
|
+
* @returns Binary document content (PDF, HTML, or XML)
|
|
1564
1564
|
*/
|
|
1565
|
-
getDocumentFile: (documentId: string, deepLinkCode: string) => Promise<
|
|
1565
|
+
getDocumentFile: (documentId: string, deepLinkCode: string) => Promise<Blob | string>;
|
|
1566
1566
|
/**
|
|
1567
1567
|
* Check if order has documents
|
|
1568
1568
|
*/
|
|
@@ -1721,7 +1721,7 @@ type UseProductConfiguratorReturn = {
|
|
|
1721
1721
|
/**
|
|
1722
1722
|
* Handler for action when the selected option is changed
|
|
1723
1723
|
*/
|
|
1724
|
-
handleChange(attribute: string, option: string, onChangeHandled
|
|
1724
|
+
handleChange(attribute: string, option: string, onChangeHandled?: () => void): Promise<void>;
|
|
1725
1725
|
findVariantForSelectedOptions(options?: {
|
|
1726
1726
|
[key: string]: string;
|
|
1727
1727
|
}): Promise<Schemas["Product"] | undefined>;
|
|
@@ -1761,7 +1761,7 @@ type UseProductPriceReturn = {
|
|
|
1761
1761
|
*/
|
|
1762
1762
|
unitPrice: ComputedRef<number | undefined>;
|
|
1763
1763
|
/**
|
|
1764
|
-
* Can be used if
|
|
1764
|
+
* Can be used if hasListPrice is set to true
|
|
1765
1765
|
*/
|
|
1766
1766
|
referencePrice: ComputedRef<Schemas["CalculatedPrice"]["referencePrice"] | undefined>;
|
|
1767
1767
|
/**
|
|
@@ -1777,7 +1777,13 @@ type UseProductPriceReturn = {
|
|
|
1777
1777
|
*/
|
|
1778
1778
|
tierPrices: ComputedRef<TierPrice[]>;
|
|
1779
1779
|
/**
|
|
1780
|
-
*
|
|
1780
|
+
* Whether the product currently has a list price reduction / discount
|
|
1781
|
+
* (e.g. for strikethrough / discount display, typically based on `listPrice.percentage`).
|
|
1782
|
+
*/
|
|
1783
|
+
hasListPrice: ComputedRef<boolean>;
|
|
1784
|
+
/**
|
|
1785
|
+
* Whether the product currently has a list price reduction / discount.
|
|
1786
|
+
* @deprecated Use `hasListPrice` instead. Will be removed in a future version.
|
|
1781
1787
|
*/
|
|
1782
1788
|
isListPrice: ComputedRef<boolean>;
|
|
1783
1789
|
/**
|
|
@@ -1995,13 +2001,23 @@ type UseSessionContextReturn = {
|
|
|
1995
2001
|
*/
|
|
1996
2002
|
salesChannelCountryId: ComputedRef<string | undefined>;
|
|
1997
2003
|
/**
|
|
1998
|
-
*
|
|
2004
|
+
* @deprecated use salesChannelLanguageId instead
|
|
2005
|
+
* sales channel language id
|
|
1999
2006
|
*/
|
|
2000
2007
|
languageId: ComputedRef<string | undefined>;
|
|
2001
2008
|
/**
|
|
2009
|
+
* sales channel language code
|
|
2010
|
+
*/
|
|
2011
|
+
salesChannelLanguageId: ComputedRef<string | undefined>;
|
|
2012
|
+
/**
|
|
2013
|
+
* @deprecated use currentLanguageId instead
|
|
2002
2014
|
* current language id chain
|
|
2003
2015
|
*/
|
|
2004
2016
|
languageIdChain: ComputedRef<string>;
|
|
2017
|
+
/**
|
|
2018
|
+
* current language code
|
|
2019
|
+
*/
|
|
2020
|
+
currentLanguageId: ComputedRef<string | undefined>;
|
|
2005
2021
|
/**
|
|
2006
2022
|
* current context's customer object
|
|
2007
2023
|
*/
|
|
@@ -2327,4 +2343,5 @@ declare function getDefaultApiParams(): {
|
|
|
2327
2343
|
[composableName: string]: unknown;
|
|
2328
2344
|
};
|
|
2329
2345
|
|
|
2330
|
-
export {
|
|
2346
|
+
export { createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
|
|
2347
|
+
export type { BoxLayout, Breadcrumb, ChangePaymentShippingMethodParams, CmsBlockCategoryNavigation, CmsBlockCenterText, CmsBlockCrossSelling, CmsBlockForm, CmsBlockGalleryBuybox, CmsBlockHtml, CmsBlockImage, CmsBlockImageBubbleRow, CmsBlockImageCover, CmsBlockImageFourColumn, CmsBlockImageGallery, CmsBlockImageGalleryBig, CmsBlockImageHighlightRow, CmsBlockImageSimpleGrid, CmsBlockImageSlider, CmsBlockImageText, CmsBlockImageTextBubble, CmsBlockImageTextCover, CmsBlockImageTextGallery, CmsBlockImageTextRow, CmsBlockImageThreeColumn, CmsBlockImageThreeCover, CmsBlockImageTwoColumn, CmsBlockProductDescriptionReviews, CmsBlockProductHeading, CmsBlockProductListing, CmsBlockProductSlider, CmsBlockProductThreeColumn, CmsBlockSidebarFilter, CmsBlockText, CmsBlockTextHero, CmsBlockTextOnImage, CmsBlockTextTeaser, CmsBlockTextTeaserSection, CmsBlockTextThreeColumn, CmsBlockTextTwoColumn, CmsBlockVimeoVideo, CmsBlockYoutubeVideo, CmsElementBuyBox, CmsElementCategoryNavigation, CmsElementCrossSelling, CmsElementForm, CmsElementHtml, CmsElementImage, CmsElementImageGallery, CmsElementImageSlider, CmsElementManufacturerLogo, CmsElementProductBox, CmsElementProductDescriptionReviews, CmsElementProductListing, CmsElementProductName, CmsElementProductSlider, CmsElementSidebarFilter, CmsElementText, CmsElementVimeoVideo, CmsElementYoutubeVideo, CmsSectionBlock, CmsSectionDefault, CmsSectionSidebar, DisplayMode, ElementConfig, ErrorObjectParam, ImageContainerAttrs, ListingType, Notification, NotificationOptions, Position, RouteObject, ShopwareContext, ShortcutFilterParam, SliderElementConfig, SourceType, UseAddToCartReturn, UseAddressReturn, UseBreadcrumbsReturn, UseCartErrorParamsResolver, UseCartItemReturn, UseCartReturn, UseCategoryReturn, UseCategorySearchReturn, UseCheckoutReturn, UseCmsBlockReturn, UseCmsElementImage, UseCmsMetaReturn, UseCountriesReturn, UseCustomerOrdersReturn, UseCustomerPasswordReturn, UseInternationalizationReturn, UseLandingSearchReturn, UseListingReturn, UseLocalWishlistReturn, UseNavigationContextReturn, UseNavigationReturn, UseNavigationSearchReturn, UseNewsletterReturn, UseNotificationsReturn, UseOrderDetailsReturn, UseOrderPaymentReturn, UsePriceReturn, UseProductAssociationsReturn, UseProductConfiguratorReturn, UseProductPriceReturn, UseProductReturn, UseProductReviewsReturn, UseProductSearchReturn, UseProductSearchSuggestReturn, UseProductWishlistReturn, UseSalutationsReturn, UseSessionContextReturn, UseSyncWishlistReturn, UseUserReturn, UseWishlistReturn, VerticalAlign, useCartNotificationReturn };
|
package/dist/index.d.ts
CHANGED
|
@@ -1374,7 +1374,7 @@ type UseNewsletterReturn = {
|
|
|
1374
1374
|
* Subscribes the user to the newsletter
|
|
1375
1375
|
* @param params {@link operations['subscribeToNewsletter post /newsletter/subscribe']['body']}
|
|
1376
1376
|
*/
|
|
1377
|
-
newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<
|
|
1377
|
+
newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<operations["subscribeToNewsletter post /newsletter/subscribe"]["response"]>;
|
|
1378
1378
|
/**
|
|
1379
1379
|
* Removes the email from the newsletter
|
|
1380
1380
|
* @param email
|
|
@@ -1401,7 +1401,7 @@ type UseNewsletterReturn = {
|
|
|
1401
1401
|
/**
|
|
1402
1402
|
* Subscribe key
|
|
1403
1403
|
*/
|
|
1404
|
-
|
|
1404
|
+
SUBSCRIBE_KEY: string;
|
|
1405
1405
|
/**
|
|
1406
1406
|
* Unsubscribe key
|
|
1407
1407
|
*/
|
|
@@ -1560,9 +1560,9 @@ type UseOrderDetailsReturn = {
|
|
|
1560
1560
|
* Get order documents
|
|
1561
1561
|
* @param {string} documentId
|
|
1562
1562
|
* @param {string} deepLinkCode
|
|
1563
|
-
* @returns
|
|
1563
|
+
* @returns Binary document content (PDF, HTML, or XML)
|
|
1564
1564
|
*/
|
|
1565
|
-
getDocumentFile: (documentId: string, deepLinkCode: string) => Promise<
|
|
1565
|
+
getDocumentFile: (documentId: string, deepLinkCode: string) => Promise<Blob | string>;
|
|
1566
1566
|
/**
|
|
1567
1567
|
* Check if order has documents
|
|
1568
1568
|
*/
|
|
@@ -1721,7 +1721,7 @@ type UseProductConfiguratorReturn = {
|
|
|
1721
1721
|
/**
|
|
1722
1722
|
* Handler for action when the selected option is changed
|
|
1723
1723
|
*/
|
|
1724
|
-
handleChange(attribute: string, option: string, onChangeHandled
|
|
1724
|
+
handleChange(attribute: string, option: string, onChangeHandled?: () => void): Promise<void>;
|
|
1725
1725
|
findVariantForSelectedOptions(options?: {
|
|
1726
1726
|
[key: string]: string;
|
|
1727
1727
|
}): Promise<Schemas["Product"] | undefined>;
|
|
@@ -1761,7 +1761,7 @@ type UseProductPriceReturn = {
|
|
|
1761
1761
|
*/
|
|
1762
1762
|
unitPrice: ComputedRef<number | undefined>;
|
|
1763
1763
|
/**
|
|
1764
|
-
* Can be used if
|
|
1764
|
+
* Can be used if hasListPrice is set to true
|
|
1765
1765
|
*/
|
|
1766
1766
|
referencePrice: ComputedRef<Schemas["CalculatedPrice"]["referencePrice"] | undefined>;
|
|
1767
1767
|
/**
|
|
@@ -1777,7 +1777,13 @@ type UseProductPriceReturn = {
|
|
|
1777
1777
|
*/
|
|
1778
1778
|
tierPrices: ComputedRef<TierPrice[]>;
|
|
1779
1779
|
/**
|
|
1780
|
-
*
|
|
1780
|
+
* Whether the product currently has a list price reduction / discount
|
|
1781
|
+
* (e.g. for strikethrough / discount display, typically based on `listPrice.percentage`).
|
|
1782
|
+
*/
|
|
1783
|
+
hasListPrice: ComputedRef<boolean>;
|
|
1784
|
+
/**
|
|
1785
|
+
* Whether the product currently has a list price reduction / discount.
|
|
1786
|
+
* @deprecated Use `hasListPrice` instead. Will be removed in a future version.
|
|
1781
1787
|
*/
|
|
1782
1788
|
isListPrice: ComputedRef<boolean>;
|
|
1783
1789
|
/**
|
|
@@ -1995,13 +2001,23 @@ type UseSessionContextReturn = {
|
|
|
1995
2001
|
*/
|
|
1996
2002
|
salesChannelCountryId: ComputedRef<string | undefined>;
|
|
1997
2003
|
/**
|
|
1998
|
-
*
|
|
2004
|
+
* @deprecated use salesChannelLanguageId instead
|
|
2005
|
+
* sales channel language id
|
|
1999
2006
|
*/
|
|
2000
2007
|
languageId: ComputedRef<string | undefined>;
|
|
2001
2008
|
/**
|
|
2009
|
+
* sales channel language code
|
|
2010
|
+
*/
|
|
2011
|
+
salesChannelLanguageId: ComputedRef<string | undefined>;
|
|
2012
|
+
/**
|
|
2013
|
+
* @deprecated use currentLanguageId instead
|
|
2002
2014
|
* current language id chain
|
|
2003
2015
|
*/
|
|
2004
2016
|
languageIdChain: ComputedRef<string>;
|
|
2017
|
+
/**
|
|
2018
|
+
* current language code
|
|
2019
|
+
*/
|
|
2020
|
+
currentLanguageId: ComputedRef<string | undefined>;
|
|
2005
2021
|
/**
|
|
2006
2022
|
* current context's customer object
|
|
2007
2023
|
*/
|
|
@@ -2327,4 +2343,5 @@ declare function getDefaultApiParams(): {
|
|
|
2327
2343
|
[composableName: string]: unknown;
|
|
2328
2344
|
};
|
|
2329
2345
|
|
|
2330
|
-
export {
|
|
2346
|
+
export { createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
|
|
2347
|
+
export type { BoxLayout, Breadcrumb, ChangePaymentShippingMethodParams, CmsBlockCategoryNavigation, CmsBlockCenterText, CmsBlockCrossSelling, CmsBlockForm, CmsBlockGalleryBuybox, CmsBlockHtml, CmsBlockImage, CmsBlockImageBubbleRow, CmsBlockImageCover, CmsBlockImageFourColumn, CmsBlockImageGallery, CmsBlockImageGalleryBig, CmsBlockImageHighlightRow, CmsBlockImageSimpleGrid, CmsBlockImageSlider, CmsBlockImageText, CmsBlockImageTextBubble, CmsBlockImageTextCover, CmsBlockImageTextGallery, CmsBlockImageTextRow, CmsBlockImageThreeColumn, CmsBlockImageThreeCover, CmsBlockImageTwoColumn, CmsBlockProductDescriptionReviews, CmsBlockProductHeading, CmsBlockProductListing, CmsBlockProductSlider, CmsBlockProductThreeColumn, CmsBlockSidebarFilter, CmsBlockText, CmsBlockTextHero, CmsBlockTextOnImage, CmsBlockTextTeaser, CmsBlockTextTeaserSection, CmsBlockTextThreeColumn, CmsBlockTextTwoColumn, CmsBlockVimeoVideo, CmsBlockYoutubeVideo, CmsElementBuyBox, CmsElementCategoryNavigation, CmsElementCrossSelling, CmsElementForm, CmsElementHtml, CmsElementImage, CmsElementImageGallery, CmsElementImageSlider, CmsElementManufacturerLogo, CmsElementProductBox, CmsElementProductDescriptionReviews, CmsElementProductListing, CmsElementProductName, CmsElementProductSlider, CmsElementSidebarFilter, CmsElementText, CmsElementVimeoVideo, CmsElementYoutubeVideo, CmsSectionBlock, CmsSectionDefault, CmsSectionSidebar, DisplayMode, ElementConfig, ErrorObjectParam, ImageContainerAttrs, ListingType, Notification, NotificationOptions, Position, RouteObject, ShopwareContext, ShortcutFilterParam, SliderElementConfig, SourceType, UseAddToCartReturn, UseAddressReturn, UseBreadcrumbsReturn, UseCartErrorParamsResolver, UseCartItemReturn, UseCartReturn, UseCategoryReturn, UseCategorySearchReturn, UseCheckoutReturn, UseCmsBlockReturn, UseCmsElementImage, UseCmsMetaReturn, UseCountriesReturn, UseCustomerOrdersReturn, UseCustomerPasswordReturn, UseInternationalizationReturn, UseLandingSearchReturn, UseListingReturn, UseLocalWishlistReturn, UseNavigationContextReturn, UseNavigationReturn, UseNavigationSearchReturn, UseNewsletterReturn, UseNotificationsReturn, UseOrderDetailsReturn, UseOrderPaymentReturn, UsePriceReturn, UseProductAssociationsReturn, UseProductConfiguratorReturn, UseProductPriceReturn, UseProductReturn, UseProductReviewsReturn, UseProductSearchReturn, UseProductSearchSuggestReturn, UseProductWishlistReturn, UseSalutationsReturn, UseSessionContextReturn, UseSyncWishlistReturn, UseUserReturn, UseWishlistReturn, VerticalAlign, useCartNotificationReturn };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { pascalCase } from 'scule';
|
|
2
2
|
import { computed, effectScope, reactive, markRaw, inject, ref, provide, unref, onMounted, watch, resolveComponent } from 'vue';
|
|
3
|
-
import { urlIsAbsolute, relativeUrlSlash, getSrcSetForMedia, getMainImageUrl, getTranslatedProperty, getListingFilters, getProductTierPrices, buildUrlPrefix } from '@shopware/helpers';
|
|
3
|
+
import { urlIsAbsolute, relativeUrlSlash, getSrcSetForMedia, getMainImageUrl, getTranslatedProperty, getListingFilters, isTechnicalPath, normalizePath, getRouteFromPathInfo, getProductTierPrices, buildUrlPrefix } from '@shopware/helpers';
|
|
4
4
|
import { ApiClientError } from '@shopware/api-client';
|
|
5
5
|
import { createSharedComposable, injectLocal, provideLocal, createInjectionState, syncRefs } from '@vueuse/core';
|
|
6
6
|
import { defu } from 'defu';
|
|
@@ -57,6 +57,9 @@ function useCmsElementImage(element) {
|
|
|
57
57
|
|
|
58
58
|
function useCmsElementConfig(element) {
|
|
59
59
|
const getConfigValue = (key) => {
|
|
60
|
+
if (!element?.config) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
60
63
|
return element.config[key]?.source !== "mapped" && element.config[key]?.value;
|
|
61
64
|
};
|
|
62
65
|
return {
|
|
@@ -171,7 +174,7 @@ function useAddress() {
|
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
176
|
return {
|
|
174
|
-
customerAddresses: computed(() => _storeCustomerAddresses.value
|
|
177
|
+
customerAddresses: computed(() => _storeCustomerAddresses.value),
|
|
175
178
|
loadCustomerAddresses,
|
|
176
179
|
createCustomerAddress,
|
|
177
180
|
updateCustomerAddress,
|
|
@@ -1217,8 +1220,10 @@ function useLocalWishlist() {
|
|
|
1217
1220
|
);
|
|
1218
1221
|
};
|
|
1219
1222
|
const getFromStorage = () => {
|
|
1220
|
-
|
|
1223
|
+
try {
|
|
1221
1224
|
return JSON.parse(localStorage.getItem("sw-wishlist-items") ?? "[]");
|
|
1225
|
+
} catch {
|
|
1226
|
+
return void 0;
|
|
1222
1227
|
}
|
|
1223
1228
|
};
|
|
1224
1229
|
async function removeFromWishlist(id) {
|
|
@@ -1315,8 +1320,8 @@ function useNavigationSearch() {
|
|
|
1315
1320
|
foreignKey: categoryId
|
|
1316
1321
|
};
|
|
1317
1322
|
}
|
|
1318
|
-
const isTechnicalUrl =
|
|
1319
|
-
const normalizedPath = isTechnicalUrl ?
|
|
1323
|
+
const isTechnicalUrl = isTechnicalPath(path);
|
|
1324
|
+
const normalizedPath = isTechnicalUrl ? normalizePath(path) : path.substring(1);
|
|
1320
1325
|
const seoResult = await apiClient.invoke("readSeoUrl post /seo-url", {
|
|
1321
1326
|
body: {
|
|
1322
1327
|
filter: [
|
|
@@ -1328,7 +1333,15 @@ function useNavigationSearch() {
|
|
|
1328
1333
|
]
|
|
1329
1334
|
}
|
|
1330
1335
|
});
|
|
1331
|
-
|
|
1336
|
+
const element = seoResult.data.elements?.[0];
|
|
1337
|
+
if (element) {
|
|
1338
|
+
return element;
|
|
1339
|
+
}
|
|
1340
|
+
const fallback = getRouteFromPathInfo(path);
|
|
1341
|
+
if (fallback) {
|
|
1342
|
+
return fallback;
|
|
1343
|
+
}
|
|
1344
|
+
return null;
|
|
1332
1345
|
}
|
|
1333
1346
|
return {
|
|
1334
1347
|
resolvePath
|
|
@@ -1336,7 +1349,7 @@ function useNavigationSearch() {
|
|
|
1336
1349
|
}
|
|
1337
1350
|
|
|
1338
1351
|
function useNewsletter() {
|
|
1339
|
-
const
|
|
1352
|
+
const SUBSCRIBE_KEY = "subscribe";
|
|
1340
1353
|
const UNSUBSCRIBE_KEY = "unsubscribe";
|
|
1341
1354
|
const { apiClient } = useShopwareContext();
|
|
1342
1355
|
const { getStorefrontUrl } = useInternationalization();
|
|
@@ -1351,6 +1364,7 @@ function useNewsletter() {
|
|
|
1351
1364
|
}
|
|
1352
1365
|
}
|
|
1353
1366
|
);
|
|
1367
|
+
newsletterStatus.value = result.data.status;
|
|
1354
1368
|
return result.data;
|
|
1355
1369
|
}
|
|
1356
1370
|
async function newsletterUnsubscribe(email) {
|
|
@@ -1381,7 +1395,7 @@ function useNewsletter() {
|
|
|
1381
1395
|
getNewsletterStatus,
|
|
1382
1396
|
newsletterStatus,
|
|
1383
1397
|
confirmationNeeded,
|
|
1384
|
-
|
|
1398
|
+
SUBSCRIBE_KEY,
|
|
1385
1399
|
UNSUBSCRIBE_KEY
|
|
1386
1400
|
};
|
|
1387
1401
|
}
|
|
@@ -1399,7 +1413,7 @@ function useNotifications() {
|
|
|
1399
1413
|
_notifications.value = [];
|
|
1400
1414
|
}
|
|
1401
1415
|
function geterateId() {
|
|
1402
|
-
return +`${(
|
|
1416
|
+
return +`${( new Date()).getTime()}${Math.random() * 1e3}`;
|
|
1403
1417
|
}
|
|
1404
1418
|
async function pushNotification(message, options) {
|
|
1405
1419
|
const timeout = options.timeout || 2500;
|
|
@@ -1548,7 +1562,8 @@ function useOrderDetails(orderId, associations) {
|
|
|
1548
1562
|
pathParams: {
|
|
1549
1563
|
documentId,
|
|
1550
1564
|
deepLinkCode
|
|
1551
|
-
}
|
|
1565
|
+
},
|
|
1566
|
+
accept: "application/pdf"
|
|
1552
1567
|
}
|
|
1553
1568
|
);
|
|
1554
1569
|
return response.data;
|
|
@@ -1653,12 +1668,8 @@ function useOrderPayment(order) {
|
|
|
1653
1668
|
function _usePrice(params) {
|
|
1654
1669
|
const { sessionContext } = useSessionContext();
|
|
1655
1670
|
const { browserLocale } = useShopwareContext();
|
|
1656
|
-
const
|
|
1657
|
-
const
|
|
1658
|
-
if (params) {
|
|
1659
|
-
currencyCode.value = params.currencyCode;
|
|
1660
|
-
_setLocaleCode(params.localeCode);
|
|
1661
|
-
}
|
|
1671
|
+
const currencyCode = ref(params?.currencyCode ?? "");
|
|
1672
|
+
const currencyLocale = ref(params?.localeCode || browserLocale);
|
|
1662
1673
|
function update(params2) {
|
|
1663
1674
|
_setCurrencyCode(params2.currencyCode);
|
|
1664
1675
|
_setLocaleCode(params2.localeCode);
|
|
@@ -1867,7 +1878,7 @@ function useProductPrice(product) {
|
|
|
1867
1878
|
const price = computed(
|
|
1868
1879
|
() => _price.value
|
|
1869
1880
|
);
|
|
1870
|
-
const
|
|
1881
|
+
const hasListPrice = computed(() => {
|
|
1871
1882
|
return !!_price.value?.listPrice?.percentage;
|
|
1872
1883
|
});
|
|
1873
1884
|
const regulationPrice = computed(
|
|
@@ -1882,7 +1893,9 @@ function useProductPrice(product) {
|
|
|
1882
1893
|
displayFrom,
|
|
1883
1894
|
tierPrices,
|
|
1884
1895
|
referencePrice,
|
|
1885
|
-
|
|
1896
|
+
hasListPrice,
|
|
1897
|
+
/** @deprecated Use hasListPrice instead */
|
|
1898
|
+
isListPrice: hasListPrice,
|
|
1886
1899
|
regulationPrice
|
|
1887
1900
|
};
|
|
1888
1901
|
}
|
|
@@ -2171,6 +2184,8 @@ function useSessionContext(newContext) {
|
|
|
2171
2184
|
setLanguage,
|
|
2172
2185
|
languageId,
|
|
2173
2186
|
languageIdChain,
|
|
2187
|
+
salesChannelLanguageId: languageId,
|
|
2188
|
+
currentLanguageId: languageIdChain,
|
|
2174
2189
|
setCountry,
|
|
2175
2190
|
setContext
|
|
2176
2191
|
};
|
|
@@ -2262,18 +2277,17 @@ function useSyncWishlist() {
|
|
|
2262
2277
|
}
|
|
2263
2278
|
|
|
2264
2279
|
function useUrlResolver() {
|
|
2265
|
-
const
|
|
2280
|
+
const urlPrefix = inject("urlPrefix", "");
|
|
2281
|
+
const getUrlPrefix = () => urlPrefix;
|
|
2266
2282
|
const resolveUrl = (url) => {
|
|
2267
2283
|
if (url.length > 2083) {
|
|
2268
2284
|
throw new Error("URL Input too long");
|
|
2269
2285
|
}
|
|
2270
2286
|
const navigationPattern = /[a-zA-Z0-9]+\/navigation\/[a-zA-Z0-9]+/;
|
|
2271
|
-
const
|
|
2287
|
+
const prefix = getUrlPrefix();
|
|
2272
2288
|
if (navigationPattern.test(url)) {
|
|
2273
2289
|
const newUrl = url.split("/").slice(1);
|
|
2274
|
-
|
|
2275
|
-
return `${buildUrlPrefix(newUrl.join("/"), urlPrefix)}`;
|
|
2276
|
-
}
|
|
2290
|
+
return buildUrlPrefix(newUrl.join("/"), prefix).path;
|
|
2277
2291
|
}
|
|
2278
2292
|
return url;
|
|
2279
2293
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware/composables",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"description": "Shopware Frontends composables for Vue",
|
|
5
5
|
"author": "Shopware",
|
|
6
6
|
"repository": {
|
|
@@ -48,34 +48,36 @@
|
|
|
48
48
|
"src",
|
|
49
49
|
"composables",
|
|
50
50
|
"nuxt.config.ts",
|
|
51
|
-
"types"
|
|
51
|
+
"types",
|
|
52
|
+
"app.config.ts"
|
|
52
53
|
],
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"@vueuse/core": "14.
|
|
55
|
-
"defu": "6.1.
|
|
55
|
+
"@vueuse/core": "14.1.0",
|
|
56
|
+
"defu": "6.1.7",
|
|
56
57
|
"scule": "1.3.0",
|
|
57
|
-
"@shopware/helpers": "1.
|
|
58
|
-
"@shopware/api-client": "1.
|
|
58
|
+
"@shopware/helpers": "1.7.1",
|
|
59
|
+
"@shopware/api-client": "1.5.0"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@biomejs/biome": "1.8.3",
|
|
62
|
-
"@nuxt/kit": "4.
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"
|
|
63
|
+
"@nuxt/kit": "4.4.6",
|
|
64
|
+
"@typescript/native-preview": "7.0.0-dev.20260205.1",
|
|
65
|
+
"@vitest/coverage-v8": "4.1.6",
|
|
66
|
+
"@vue/test-utils": "2.4.10",
|
|
67
|
+
"happy-dom": "20.9.0",
|
|
66
68
|
"typescript": "5.9.3",
|
|
67
69
|
"unbuild": "2.0.0",
|
|
68
|
-
"vitest": "
|
|
69
|
-
"vue": "3.5.
|
|
70
|
+
"vitest": "4.1.6",
|
|
71
|
+
"vue": "3.5.34",
|
|
70
72
|
"tsconfig": "0.0.0"
|
|
71
73
|
},
|
|
72
74
|
"scripts": {
|
|
73
75
|
"build": "unbuild && pnpm build:types",
|
|
74
|
-
"build:types": "
|
|
76
|
+
"build:types": "tsgo",
|
|
75
77
|
"dev": "unbuild --stub",
|
|
76
78
|
"lint": "biome check .",
|
|
77
79
|
"lint:fix": "biome check . --write && pnpm run typecheck",
|
|
78
|
-
"typecheck": "
|
|
80
|
+
"typecheck": "tsgo --noEmit",
|
|
79
81
|
"test": "vitest run",
|
|
80
82
|
"coverage": "vitest run --coverage",
|
|
81
83
|
"test:watch": "vitest"
|
|
@@ -59,6 +59,14 @@ describe("useCmsElementConfig", () => {
|
|
|
59
59
|
expect(getConfigValue("alignment")).toEqual("flex-start");
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
+
it("should return undefined if element config is undefined", () => {
|
|
63
|
+
const { getConfigValue } = useCmsElementConfig({
|
|
64
|
+
config: undefined,
|
|
65
|
+
} as unknown as CmsElementBuyBox);
|
|
66
|
+
|
|
67
|
+
expect(getConfigValue("alignment")).toBeUndefined();
|
|
68
|
+
});
|
|
69
|
+
|
|
62
70
|
it("should return undefined if config value is undefined", () => {
|
|
63
71
|
const { getConfigValue } = useCmsElementConfig({
|
|
64
72
|
config: {
|
|
@@ -18,6 +18,9 @@ export function useCmsElementConfig<
|
|
|
18
18
|
const getConfigValue = <ELEMENT_CONFIG extends keyof T["config"]>(
|
|
19
19
|
key: ELEMENT_CONFIG,
|
|
20
20
|
): (typeof element.config)[ELEMENT_CONFIG]["value"] => {
|
|
21
|
+
if (!element?.config) {
|
|
22
|
+
return undefined as (typeof element.config)[ELEMENT_CONFIG]["value"];
|
|
23
|
+
}
|
|
21
24
|
return (
|
|
22
25
|
element.config[key]?.source !== "mapped" && element.config[key]?.value
|
|
23
26
|
);
|
|
@@ -95,6 +95,29 @@ describe("useCmsElementImage", () => {
|
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
+
it("should return imageContainerAttrs without url", () => {
|
|
99
|
+
const { imageContainerAttrs } = useCmsElementImage({
|
|
100
|
+
data: {
|
|
101
|
+
newTab: false,
|
|
102
|
+
},
|
|
103
|
+
} as CmsElementImage);
|
|
104
|
+
|
|
105
|
+
expect(imageContainerAttrs.value).toEqual({});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("should return imageContainerAttrs with url but no newTab", () => {
|
|
109
|
+
const { imageContainerAttrs } = useCmsElementImage({
|
|
110
|
+
data: {
|
|
111
|
+
url: "https://shopware.com/logo.png",
|
|
112
|
+
newTab: false,
|
|
113
|
+
},
|
|
114
|
+
} as CmsElementImage);
|
|
115
|
+
|
|
116
|
+
expect(imageContainerAttrs.value).toEqual({
|
|
117
|
+
href: "https://shopware.com/logo.png",
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
98
121
|
it("should return imageLink", () => {
|
|
99
122
|
const { imageLink } = useCmsElementImage({
|
|
100
123
|
data: {
|
|
@@ -12,4 +12,25 @@ describe("useCmsElementProductBox", () => {
|
|
|
12
12
|
|
|
13
13
|
expect(vm.product).toEqual(CmsProductBox.data.product);
|
|
14
14
|
});
|
|
15
|
+
|
|
16
|
+
it("should use injected product when provided", () => {
|
|
17
|
+
const injectedProduct = { id: "injected-id", name: "Injected Product" };
|
|
18
|
+
const { vm } = useSetup(
|
|
19
|
+
() =>
|
|
20
|
+
useCmsElementProductBox(
|
|
21
|
+
CmsProductBox as unknown as CmsElementProductBox,
|
|
22
|
+
),
|
|
23
|
+
{ product: injectedProduct } as Parameters<typeof useSetup>[1],
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
expect(vm.product).toEqual(injectedProduct);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should return boxLayout from config", () => {
|
|
30
|
+
const { vm } = useSetup(() =>
|
|
31
|
+
useCmsElementProductBox(CmsProductBox as unknown as CmsElementProductBox),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
expect(vm.boxLayout).toEqual("standard");
|
|
35
|
+
});
|
|
15
36
|
});
|
package/src/devtools/plugin.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// TODO fix types in this plugin
|
|
2
2
|
import { setupDevtoolsPlugin } from "@vue/devtools-api";
|
|
3
|
-
import type { DevtoolsPluginApi } from "@vue/devtools-api";
|
|
4
3
|
import { unref } from "vue";
|
|
5
4
|
import type { App, InjectionKey } from "vue";
|
|
6
5
|
|
|
@@ -15,7 +14,7 @@ export function registerShopwareDevtools(
|
|
|
15
14
|
shopwarePluginInstance: any,
|
|
16
15
|
) {
|
|
17
16
|
// biome-ignore lint: not used plugin for now, ignoring type errors
|
|
18
|
-
let devtoolsApi:
|
|
17
|
+
let devtoolsApi: any;
|
|
19
18
|
let trackId = 0;
|
|
20
19
|
// biome-ignore lint: not used plugin for now, ignoring type errors
|
|
21
20
|
let currentSharedState: any = null;
|