@shopware/composables 1.10.0 → 1.11.0

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.
Files changed (44) hide show
  1. package/README.md +7 -28
  2. package/dist/index.d.mts +23 -7
  3. package/dist/index.d.ts +23 -7
  4. package/dist/index.mjs +24 -19
  5. package/package.json +12 -11
  6. package/src/cms/useCmsElementConfig.test.ts +8 -0
  7. package/src/cms/useCmsElementConfig.ts +3 -0
  8. package/src/cms/useCmsElementImage.test.ts +23 -0
  9. package/src/cms/useCmsElementProductBox.test.ts +21 -0
  10. package/src/devtools/plugin.ts +1 -2
  11. package/src/mocks/Configurator.ts +36 -36
  12. package/src/useAddToCart/useAddToCart.test.ts +18 -1
  13. package/src/useAddress/useAddress.test.ts +41 -2
  14. package/src/useAddress/useAddress.ts +1 -1
  15. package/src/useCart/useCart.test.ts +30 -0
  16. package/src/useCartNotification/useCartNotification.test.ts +30 -0
  17. package/src/useCheckout/useCheckout.test.ts +43 -1
  18. package/src/useCmsMeta/useCmsMeta.test.ts +26 -0
  19. package/src/useCountries/useCountries.test.ts +14 -0
  20. package/src/useLocalWishlist/useLocalWishlist.test.ts +44 -5
  21. package/src/useLocalWishlist/useLocalWishlist.ts +3 -2
  22. package/src/useNavigationContext/useNavigationContext.test.ts +25 -24
  23. package/src/useNewsletter/useNewsletter.test.ts +16 -0
  24. package/src/useNewsletter/useNewsletter.ts +3 -3
  25. package/src/useOrderDetails/useOrderDetails.test.ts +92 -3
  26. package/src/useOrderDetails/useOrderDetails.ts +7 -3
  27. package/src/useOrderPayment/useOrderPayment.test.ts +55 -1
  28. package/src/usePrice/usePrice.test.ts +10 -0
  29. package/src/usePrice/usePrice.ts +2 -7
  30. package/src/useProduct/useProduct.test.ts +14 -1
  31. package/src/useProductAssociations/useProductAssociations.spec.ts +1 -0
  32. package/src/useProductConfigurator/useProductConfigurator.spec.ts +38 -0
  33. package/src/useProductConfigurator/useProductConfigurator.ts +1 -1
  34. package/src/useProductPrice/useProductPrice.test.ts +7 -7
  35. package/src/useProductPrice/useProductPrice.ts +12 -4
  36. package/src/useProductReviews/useProductReviews.test.ts +15 -3
  37. package/src/useSalutations/useSalutations.spec.ts +13 -0
  38. package/src/useSessionContext/useSessionContext.test.ts +122 -4
  39. package/src/useSessionContext/useSessionContext.ts +13 -1
  40. package/src/useSyncWishlist/useSyncWishlist.test.ts +60 -8
  41. package/src/useUrlResolver/useUrlResolver.test.ts +6 -12
  42. package/src/useUrlResolver/useUrlResolver.ts +4 -6
  43. package/src/useUser/useUser.test.ts +107 -15
  44. package/src/useWishlist/useWishlist.test.ts +124 -26
package/README.md CHANGED
@@ -165,39 +165,18 @@ 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.10.0
168
+ ### Latest changes: 1.11.0
169
169
 
170
170
  ### Minor Changes
171
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
192
-
193
- - [#1959](https://github.com/shopware/frontends/pull/1959) [`c77daa6`](https://github.com/shopware/frontends/commit/c77daa6a11e96c7f3688b16f7da010b54c7f5e8b) Thanks [@patzick](https://github.com/patzick)! - Updated default types to Shopware 6.7
172
+ - [#2318](https://github.com/shopware/frontends/pull/2318) [`b40305f`](https://github.com/shopware/frontends/commit/b40305f9e2ec51f29c279650e411bb773438faed) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - `useProductPrice` now returns `hasListPrice` (boolean indicating whether the product has a list price set). `isListPrice` is deprecated and aliased to `hasListPrice`; use `hasListPrice` in new code.
194
173
 
195
174
  ### Patch Changes
196
175
 
197
- - [`87771c3`](https://github.com/shopware/frontends/commit/87771c3b7a4521fcdba43cb4c967b61f5db01b3e) Thanks [@mkucmus](https://github.com/mkucmus)! - add nested media entity association explicitly
176
+ - [#2275](https://github.com/shopware/frontends/pull/2275) [`432dd24`](https://github.com/shopware/frontends/commit/432dd246571dfa8c149293da97d5bb16f505e54c) Thanks [@mkucmus](https://github.com/mkucmus)! - Guard against undefined config in `useCmsElementConfig`.
198
177
 
199
- - [#1985](https://github.com/shopware/frontends/pull/1985) [`2cbda25`](https://github.com/shopware/frontends/commit/2cbda257a1056454e12f2fba9052f83eecb6d986) Thanks [@mkucmus](https://github.com/mkucmus)! - Change `isInWishlist` property type to `ComputedRef` within `useProductWishlist` composable.
178
+ - [#2263](https://github.com/shopware/frontends/pull/2263) [`b5f7e2a`](https://github.com/shopware/frontends/commit/b5f7e2a20c9dfdde1690e9006252d847f732bc0a) Thanks [@mkucmus](https://github.com/mkucmus)! - Fixed `getDocumentFile` return type in `useOrderDetails` to correctly return `Blob | string` instead of `Document` schema.
200
179
 
201
- - Updated dependencies [[`22ff62e`](https://github.com/shopware/frontends/commit/22ff62e354f024599d64ea8096af57695248851c), [`2cbda25`](https://github.com/shopware/frontends/commit/2cbda257a1056454e12f2fba9052f83eecb6d986), [`70dcf95`](https://github.com/shopware/frontends/commit/70dcf95d4370c63964d877a5cab113a53f93ca19), [`56cd178`](https://github.com/shopware/frontends/commit/56cd178e25fe2399b7170ccac3044e980621f041), [`e1fae3e`](https://github.com/shopware/frontends/commit/e1fae3eb6430e5c8e133456fbaf7f215f80c36f6), [`c647baf`](https://github.com/shopware/frontends/commit/c647baf93e7174b849f5961ee5803add99d78602), [`c77daa6`](https://github.com/shopware/frontends/commit/c77daa6a11e96c7f3688b16f7da010b54c7f5e8b)]:
202
- - @shopware/helpers@1.6.0
203
- - @shopware/api-client@1.4.0
180
+ - Updated dependencies [[`9604f22`](https://github.com/shopware/frontends/commit/9604f22678150d04c3c3156fd8ee2ce440c8c8bf), [`b5f7e2a`](https://github.com/shopware/frontends/commit/b5f7e2a20c9dfdde1690e9006252d847f732bc0a), [`9604f22`](https://github.com/shopware/frontends/commit/9604f22678150d04c3c3156fd8ee2ce440c8c8bf), [`a871c7b`](https://github.com/shopware/frontends/commit/a871c7b6256b75c2e40d93fc0354ba1971420062), [`c9bde38`](https://github.com/shopware/frontends/commit/c9bde38d497d5c6c2fbd97700a362eb44ce8881f)]:
181
+ - @shopware/api-client@1.5.0
182
+ - @shopware/helpers@1.7.0
package/dist/index.d.mts CHANGED
@@ -1401,7 +1401,7 @@ type UseNewsletterReturn = {
1401
1401
  /**
1402
1402
  * Subscribe key
1403
1403
  */
1404
- SUBSRIBE_KEY: string;
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<Schemas["Document"]>;
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: () => void): Promise<void>;
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 isListPrice is set to true
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
- * determines whether a discount price is set
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
- * current language id
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
  */
package/dist/index.d.ts CHANGED
@@ -1401,7 +1401,7 @@ type UseNewsletterReturn = {
1401
1401
  /**
1402
1402
  * Subscribe key
1403
1403
  */
1404
- SUBSRIBE_KEY: string;
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<Schemas["Document"]>;
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: () => void): Promise<void>;
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 isListPrice is set to true
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
- * determines whether a discount price is set
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
- * current language id
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
  */
package/dist/index.mjs CHANGED
@@ -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
- if (typeof window !== "undefined" && localStorage) {
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) {
@@ -1336,7 +1341,7 @@ function useNavigationSearch() {
1336
1341
  }
1337
1342
 
1338
1343
  function useNewsletter() {
1339
- const SUBSRIBE_KEY = "subscribe";
1344
+ const SUBSCRIBE_KEY = "subscribe";
1340
1345
  const UNSUBSCRIBE_KEY = "unsubscribe";
1341
1346
  const { apiClient } = useShopwareContext();
1342
1347
  const { getStorefrontUrl } = useInternationalization();
@@ -1381,7 +1386,7 @@ function useNewsletter() {
1381
1386
  getNewsletterStatus,
1382
1387
  newsletterStatus,
1383
1388
  confirmationNeeded,
1384
- SUBSRIBE_KEY,
1389
+ SUBSCRIBE_KEY,
1385
1390
  UNSUBSCRIBE_KEY
1386
1391
  };
1387
1392
  }
@@ -1399,7 +1404,7 @@ function useNotifications() {
1399
1404
  _notifications.value = [];
1400
1405
  }
1401
1406
  function geterateId() {
1402
- return +`${(/* @__PURE__ */ new Date()).getTime()}${Math.random() * 1e3}`;
1407
+ return +`${( new Date()).getTime()}${Math.random() * 1e3}`;
1403
1408
  }
1404
1409
  async function pushNotification(message, options) {
1405
1410
  const timeout = options.timeout || 2500;
@@ -1548,7 +1553,8 @@ function useOrderDetails(orderId, associations) {
1548
1553
  pathParams: {
1549
1554
  documentId,
1550
1555
  deepLinkCode
1551
- }
1556
+ },
1557
+ accept: "application/pdf"
1552
1558
  }
1553
1559
  );
1554
1560
  return response.data;
@@ -1653,12 +1659,8 @@ function useOrderPayment(order) {
1653
1659
  function _usePrice(params) {
1654
1660
  const { sessionContext } = useSessionContext();
1655
1661
  const { browserLocale } = useShopwareContext();
1656
- const currencyLocale = ref(browserLocale);
1657
- const currencyCode = ref("");
1658
- if (params) {
1659
- currencyCode.value = params.currencyCode;
1660
- _setLocaleCode(params.localeCode);
1661
- }
1662
+ const currencyCode = ref(params?.currencyCode ?? "");
1663
+ const currencyLocale = ref(params?.localeCode || browserLocale);
1662
1664
  function update(params2) {
1663
1665
  _setCurrencyCode(params2.currencyCode);
1664
1666
  _setLocaleCode(params2.localeCode);
@@ -1867,7 +1869,7 @@ function useProductPrice(product) {
1867
1869
  const price = computed(
1868
1870
  () => _price.value
1869
1871
  );
1870
- const isListPrice = computed(() => {
1872
+ const hasListPrice = computed(() => {
1871
1873
  return !!_price.value?.listPrice?.percentage;
1872
1874
  });
1873
1875
  const regulationPrice = computed(
@@ -1882,7 +1884,9 @@ function useProductPrice(product) {
1882
1884
  displayFrom,
1883
1885
  tierPrices,
1884
1886
  referencePrice,
1885
- isListPrice,
1887
+ hasListPrice,
1888
+ /** @deprecated Use hasListPrice instead */
1889
+ isListPrice: hasListPrice,
1886
1890
  regulationPrice
1887
1891
  };
1888
1892
  }
@@ -2171,6 +2175,8 @@ function useSessionContext(newContext) {
2171
2175
  setLanguage,
2172
2176
  languageId,
2173
2177
  languageIdChain,
2178
+ salesChannelLanguageId: languageId,
2179
+ currentLanguageId: languageIdChain,
2174
2180
  setCountry,
2175
2181
  setContext
2176
2182
  };
@@ -2262,18 +2268,17 @@ function useSyncWishlist() {
2262
2268
  }
2263
2269
 
2264
2270
  function useUrlResolver() {
2265
- const getUrlPrefix = () => inject("urlPrefix", "");
2271
+ const urlPrefix = inject("urlPrefix", "");
2272
+ const getUrlPrefix = () => urlPrefix;
2266
2273
  const resolveUrl = (url) => {
2267
2274
  if (url.length > 2083) {
2268
2275
  throw new Error("URL Input too long");
2269
2276
  }
2270
2277
  const navigationPattern = /[a-zA-Z0-9]+\/navigation\/[a-zA-Z0-9]+/;
2271
- const urlPrefix = getUrlPrefix();
2278
+ const prefix = getUrlPrefix();
2272
2279
  if (navigationPattern.test(url)) {
2273
2280
  const newUrl = url.split("/").slice(1);
2274
- if (newUrl.length > 0) {
2275
- return `${buildUrlPrefix(newUrl.join("/"), urlPrefix)}`;
2276
- }
2281
+ return buildUrlPrefix(newUrl.join("/"), prefix).path;
2277
2282
  }
2278
2283
  return url;
2279
2284
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware/composables",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "Shopware Frontends composables for Vue",
5
5
  "author": "Shopware",
6
6
  "repository": {
@@ -51,31 +51,32 @@
51
51
  "types"
52
52
  ],
53
53
  "dependencies": {
54
- "@vueuse/core": "14.0.0",
54
+ "@vueuse/core": "14.1.0",
55
55
  "defu": "6.1.4",
56
56
  "scule": "1.3.0",
57
- "@shopware/helpers": "1.6.0",
58
- "@shopware/api-client": "1.4.0"
57
+ "@shopware/helpers": "1.7.0",
58
+ "@shopware/api-client": "1.5.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@biomejs/biome": "1.8.3",
62
- "@nuxt/kit": "4.2.1",
63
- "@vitest/coverage-v8": "3.2.4",
62
+ "@nuxt/kit": "4.2.2",
63
+ "@typescript/native-preview": "7.0.0-dev.20260111.1",
64
+ "@vitest/coverage-v8": "4.0.18",
64
65
  "@vue/test-utils": "2.4.6",
65
- "happy-dom": "20.0.10",
66
+ "happy-dom": "20.8.9",
66
67
  "typescript": "5.9.3",
67
68
  "unbuild": "2.0.0",
68
- "vitest": "3.2.4",
69
- "vue": "3.5.24",
69
+ "vitest": "4.0.18",
70
+ "vue": "3.5.27",
70
71
  "tsconfig": "0.0.0"
71
72
  },
72
73
  "scripts": {
73
74
  "build": "unbuild && pnpm build:types",
74
- "build:types": "npx -p typescript tsc",
75
+ "build:types": "tsgo",
75
76
  "dev": "unbuild --stub",
76
77
  "lint": "biome check .",
77
78
  "lint:fix": "biome check . --write && pnpm run typecheck",
78
- "typecheck": "tsc --noEmit",
79
+ "typecheck": "tsgo --noEmit",
79
80
  "test": "vitest run",
80
81
  "coverage": "vitest run --coverage",
81
82
  "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
  });
@@ -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: DevtoolsPluginApi<any>;
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;
@@ -2,16 +2,16 @@ const Configurator = [
2
2
  {
3
3
  translated: {
4
4
  name: "Colour",
5
- description: null,
5
+ description: undefined,
6
6
  position: 1,
7
7
  customFields: {},
8
8
  },
9
9
  createdAt: "2020-08-06T06:26:29.726+00:00",
10
- updatedAt: null,
10
+ updatedAt: undefined,
11
11
  name: "Colour",
12
12
  displayType: "text",
13
13
  sortingType: "alphanumeric",
14
- description: null,
14
+ description: undefined,
15
15
  position: 1,
16
16
  filterable: true,
17
17
  visibleOnProductDetailPage: true,
@@ -23,47 +23,47 @@ const Configurator = [
23
23
  groupId: "15de997512de4e229d2db1b72aca16f5",
24
24
  name: "red",
25
25
  position: 13,
26
- colorHexCode: null,
27
- mediaId: null,
28
- group: null,
29
- media: null,
30
- customFields: null,
26
+ colorHexCode: undefined,
27
+ mediaId: undefined,
28
+ group: undefined,
29
+ media: undefined,
30
+ customFields: undefined,
31
31
  id: "cc02c6cf39ad43d5856a25f8928490bf",
32
32
  apiAlias: "property_group_option",
33
33
  },
34
34
  {
35
35
  translated: { name: "blue", position: 17, customFields: {} },
36
36
  createdAt: "2020-08-06T06:26:29.667+00:00",
37
- updatedAt: null,
37
+ updatedAt: undefined,
38
38
  groupId: "15de997512de4e229d2db1b72aca16f5",
39
39
  name: "blue",
40
40
  position: 17,
41
- colorHexCode: null,
42
- mediaId: null,
43
- group: null,
44
- media: null,
45
- customFields: null,
41
+ colorHexCode: undefined,
42
+ mediaId: undefined,
43
+ group: undefined,
44
+ media: undefined,
45
+ customFields: undefined,
46
46
  id: "862a4c3c1326423a874b25b6d9ae2101",
47
47
  apiAlias: "property_group_option",
48
48
  },
49
49
  ],
50
- customFields: null,
50
+ customFields: undefined,
51
51
  id: "15de997512de4e229d2db1b72aca16f5",
52
52
  apiAlias: "property_group",
53
53
  },
54
54
  {
55
55
  translated: {
56
56
  name: "Size",
57
- description: null,
57
+ description: undefined,
58
58
  position: 1,
59
59
  customFields: {},
60
60
  },
61
61
  createdAt: "2020-08-06T06:26:29.930+00:00",
62
- updatedAt: null,
62
+ updatedAt: undefined,
63
63
  name: "Size",
64
64
  displayType: "text",
65
65
  sortingType: "alphanumeric",
66
- description: null,
66
+ description: undefined,
67
67
  position: 1,
68
68
  filterable: true,
69
69
  visibleOnProductDetailPage: true,
@@ -75,46 +75,46 @@ const Configurator = [
75
75
  groupId: "6d71c64e67d64876b9c7fbb97fcba3c6",
76
76
  name: "L",
77
77
  position: 24,
78
- colorHexCode: null,
79
- mediaId: null,
80
- group: null,
81
- media: null,
82
- customFields: null,
78
+ colorHexCode: undefined,
79
+ mediaId: undefined,
80
+ group: undefined,
81
+ media: undefined,
82
+ customFields: undefined,
83
83
  id: "f13d254355cc41e28637e3428e23f279",
84
84
  apiAlias: "property_group_option",
85
85
  },
86
86
  {
87
87
  translated: { name: "M", position: 23, customFields: {} },
88
88
  createdAt: "2020-08-06T06:26:29.877+00:00",
89
- updatedAt: null,
89
+ updatedAt: undefined,
90
90
  groupId: "6d71c64e67d64876b9c7fbb97fcba3c6",
91
91
  name: "M",
92
92
  position: 23,
93
- colorHexCode: null,
94
- mediaId: null,
95
- group: null,
96
- media: null,
97
- customFields: null,
93
+ colorHexCode: undefined,
94
+ mediaId: undefined,
95
+ group: undefined,
96
+ media: undefined,
97
+ customFields: undefined,
98
98
  id: "24495f5441004fb9bcde8e1645714063",
99
99
  apiAlias: "property_group_option",
100
100
  },
101
101
  {
102
102
  translated: { name: "S", position: 22, customFields: {} },
103
103
  createdAt: "2020-08-06T06:26:29.923+00:00",
104
- updatedAt: null,
104
+ updatedAt: undefined,
105
105
  groupId: "6d71c64e67d64876b9c7fbb97fcba3c6",
106
106
  name: "S",
107
107
  position: 22,
108
- colorHexCode: null,
109
- mediaId: null,
110
- group: null,
111
- media: null,
112
- customFields: null,
108
+ colorHexCode: undefined,
109
+ mediaId: undefined,
110
+ group: undefined,
111
+ media: undefined,
112
+ customFields: undefined,
113
113
  id: "dcd3a971b122413785ed56a5782ed5b7",
114
114
  apiAlias: "property_group_option",
115
115
  },
116
116
  ],
117
- customFields: null,
117
+ customFields: undefined,
118
118
  id: "6d71c64e67d64876b9c7fbb97fcba3c6",
119
119
  apiAlias: "property_group",
120
120
  },