@shopware/composables 1.9.1 → 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.
- package/README.md +12 -5
- package/dist/index.d.mts +116 -34
- package/dist/index.d.ts +116 -34
- package/dist/index.mjs +117 -74
- package/package.json +13 -12
- package/src/cms/cmsAssociations.ts +5 -1
- package/src/cms/useCmsElementConfig.test.ts +8 -0
- package/src/cms/useCmsElementConfig.ts +4 -1
- 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/types/cmsBlockTypes.ts +2 -0
- package/src/types/cmsElementTypes.ts +24 -18
- 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 +42 -0
- package/src/useCart/useCart.ts +17 -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/useCustomerOrders/useCustomerOrders.ts +1 -1
- package/src/useDefaultOrderAssociations/useDefaultOrderAssociations.test.ts +19 -21
- package/src/useDefaultOrderAssociations/useDefaultOrderAssociations.ts +23 -30
- package/src/useLandingSearch/useLandingSearch.test.ts +1 -1
- package/src/useLandingSearch/useLandingSearch.ts +1 -1
- package/src/useListing/useListing.test.ts +73 -0
- package/src/useListing/useListing.ts +10 -3
- 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/useNewsletter/useNewsletter.test.ts +16 -0
- package/src/useNewsletter/useNewsletter.ts +13 -0
- package/src/useOrderDetails/useOrderDetails.test.ts +92 -3
- package/src/useOrderDetails/useOrderDetails.ts +12 -14
- package/src/useOrderPayment/useOrderPayment.test.ts +55 -1
- package/src/useOrderPayment/useOrderPayment.ts +1 -0
- 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/useProductWishlist/useProductWishlist.ts +2 -2
- package/src/useSalutations/useSalutations.spec.ts +13 -0
- package/src/useSessionContext/useSessionContext.test.ts +122 -4
- package/src/useSessionContext/useSessionContext.ts +14 -2
- package/src/useSyncWishlist/useSyncWishlist.test.ts +94 -25
- package/src/useSyncWishlist/useSyncWishlist.ts +27 -8
- package/src/useUrlResolver/useUrlResolver.test.ts +6 -12
- package/src/useUrlResolver/useUrlResolver.ts +4 -6
- package/src/useUser/useUser.test.ts +233 -18
- package/src/useUser/useUser.ts +6 -1
- package/src/useWishlist/useWishlist.test.ts +133 -26
- package/src/useWishlist/useWishlist.ts +22 -6
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,
|
|
@@ -292,6 +295,17 @@ function useCartFunction() {
|
|
|
292
295
|
setCartErrors(data);
|
|
293
296
|
return data;
|
|
294
297
|
}
|
|
298
|
+
async function removeItemById(id) {
|
|
299
|
+
const { data } = await apiClient.invoke(
|
|
300
|
+
"removeLineItem post /checkout/cart/line-item/delete",
|
|
301
|
+
{
|
|
302
|
+
body: { ids: [id] }
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
_storeCart.value = data;
|
|
306
|
+
setCartErrors(data);
|
|
307
|
+
return data;
|
|
308
|
+
}
|
|
295
309
|
async function changeProductQuantity(params) {
|
|
296
310
|
const { data } = await apiClient.invoke(
|
|
297
311
|
"updateLineItem patch /checkout/cart/line-item",
|
|
@@ -388,6 +402,7 @@ function useCartFunction() {
|
|
|
388
402
|
count,
|
|
389
403
|
refreshCart,
|
|
390
404
|
removeItem,
|
|
405
|
+
removeItemById,
|
|
391
406
|
totalPrice,
|
|
392
407
|
shippingTotal,
|
|
393
408
|
subtotal,
|
|
@@ -475,7 +490,11 @@ function useCategory(category) {
|
|
|
475
490
|
|
|
476
491
|
const cmsAssociations = {
|
|
477
492
|
associations: {
|
|
478
|
-
media: {
|
|
493
|
+
media: {
|
|
494
|
+
associations: {
|
|
495
|
+
media: {}
|
|
496
|
+
}
|
|
497
|
+
},
|
|
479
498
|
cmsPage: {
|
|
480
499
|
associations: {
|
|
481
500
|
sections: {
|
|
@@ -786,31 +805,29 @@ function useCustomerPassword() {
|
|
|
786
805
|
|
|
787
806
|
function useDefaultOrderAssociations() {
|
|
788
807
|
const orderAssociations = {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
media: {}
|
|
797
|
-
}
|
|
808
|
+
stateMachineState: {},
|
|
809
|
+
lineItems: {
|
|
810
|
+
associations: {
|
|
811
|
+
cover: {},
|
|
812
|
+
downloads: {
|
|
813
|
+
associations: {
|
|
814
|
+
media: {}
|
|
798
815
|
}
|
|
799
816
|
}
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
817
|
+
}
|
|
818
|
+
},
|
|
819
|
+
addresses: {},
|
|
820
|
+
deliveries: {
|
|
821
|
+
associations: {
|
|
822
|
+
shippingMethod: {},
|
|
823
|
+
shippingOrderAddress: {},
|
|
824
|
+
stateMachineState: {}
|
|
825
|
+
}
|
|
826
|
+
},
|
|
827
|
+
transactions: {
|
|
828
|
+
associations: {
|
|
829
|
+
paymentMethod: {},
|
|
830
|
+
stateMachineState: {}
|
|
814
831
|
}
|
|
815
832
|
}
|
|
816
833
|
};
|
|
@@ -880,7 +897,7 @@ function useInternationalization(pathResolver) {
|
|
|
880
897
|
function useLandingSearch() {
|
|
881
898
|
const { apiClient } = useShopwareContext();
|
|
882
899
|
const search = async (navigationId, options) => {
|
|
883
|
-
const associations = options?.withCmsAssociations ? cmsAssociations : {};
|
|
900
|
+
const associations = options?.withCmsAssociations ? cmsAssociations.associations : {};
|
|
884
901
|
const result = await apiClient.invoke(
|
|
885
902
|
"readLandingPage post /landing-page/{landingPageId}",
|
|
886
903
|
{
|
|
@@ -960,13 +977,17 @@ function useListing(params) {
|
|
|
960
977
|
return createListingComposable({
|
|
961
978
|
listingKey: listingType,
|
|
962
979
|
searchMethod,
|
|
963
|
-
searchDefaults: params?.defaultSearchCriteria || {}
|
|
980
|
+
searchDefaults: params?.defaultSearchCriteria || {},
|
|
964
981
|
//getDefaults(),
|
|
982
|
+
initialListing: params?.initialListing
|
|
965
983
|
});
|
|
966
984
|
}
|
|
967
985
|
const [_createCategoryListingContext, _categoryListingContext] = createInjectionState(
|
|
968
|
-
() => {
|
|
969
|
-
return useListing({
|
|
986
|
+
(initialListing) => {
|
|
987
|
+
return useListing({
|
|
988
|
+
listingType: "categoryListing",
|
|
989
|
+
initialListing
|
|
990
|
+
});
|
|
970
991
|
},
|
|
971
992
|
{
|
|
972
993
|
injectionKey: "categoryListing"
|
|
@@ -988,17 +1009,18 @@ const useProductSearchListing = createSharedComposable(
|
|
|
988
1009
|
function createListingComposable({
|
|
989
1010
|
searchMethod,
|
|
990
1011
|
searchDefaults,
|
|
991
|
-
listingKey
|
|
1012
|
+
listingKey,
|
|
1013
|
+
initialListing
|
|
992
1014
|
}) {
|
|
993
1015
|
const loading = ref(false);
|
|
994
1016
|
const loadingMore = ref(false);
|
|
995
|
-
const _storeInitialListing = inject(`useListingInitial-${listingKey}`, ref(null));
|
|
1017
|
+
const _storeInitialListing = inject(`useListingInitial-${listingKey}`, ref(initialListing ?? null));
|
|
996
1018
|
provide(`useListingInitial-${listingKey}`, _storeInitialListing);
|
|
997
1019
|
const _storeAppliedListing = inject(`useListingApplied-${listingKey}`, ref(null));
|
|
998
1020
|
provide(`useListingApplied-${listingKey}`, _storeAppliedListing);
|
|
999
1021
|
const getInitialListing = computed(() => _storeInitialListing.value);
|
|
1000
|
-
const setInitialListing = async (
|
|
1001
|
-
_storeInitialListing.value =
|
|
1022
|
+
const setInitialListing = async (initialListing2) => {
|
|
1023
|
+
_storeInitialListing.value = initialListing2;
|
|
1002
1024
|
_storeAppliedListing.value = null;
|
|
1003
1025
|
};
|
|
1004
1026
|
const initSearch = async (criteria) => {
|
|
@@ -1198,8 +1220,10 @@ function useLocalWishlist() {
|
|
|
1198
1220
|
);
|
|
1199
1221
|
};
|
|
1200
1222
|
const getFromStorage = () => {
|
|
1201
|
-
|
|
1223
|
+
try {
|
|
1202
1224
|
return JSON.parse(localStorage.getItem("sw-wishlist-items") ?? "[]");
|
|
1225
|
+
} catch {
|
|
1226
|
+
return void 0;
|
|
1203
1227
|
}
|
|
1204
1228
|
};
|
|
1205
1229
|
async function removeFromWishlist(id) {
|
|
@@ -1317,6 +1341,8 @@ function useNavigationSearch() {
|
|
|
1317
1341
|
}
|
|
1318
1342
|
|
|
1319
1343
|
function useNewsletter() {
|
|
1344
|
+
const SUBSCRIBE_KEY = "subscribe";
|
|
1345
|
+
const UNSUBSCRIBE_KEY = "unsubscribe";
|
|
1320
1346
|
const { apiClient } = useShopwareContext();
|
|
1321
1347
|
const { getStorefrontUrl } = useInternationalization();
|
|
1322
1348
|
const newsletterStatus = ref("undefined");
|
|
@@ -1359,7 +1385,9 @@ function useNewsletter() {
|
|
|
1359
1385
|
isNewsletterSubscriber,
|
|
1360
1386
|
getNewsletterStatus,
|
|
1361
1387
|
newsletterStatus,
|
|
1362
|
-
confirmationNeeded
|
|
1388
|
+
confirmationNeeded,
|
|
1389
|
+
SUBSCRIBE_KEY,
|
|
1390
|
+
UNSUBSCRIBE_KEY
|
|
1363
1391
|
};
|
|
1364
1392
|
}
|
|
1365
1393
|
|
|
@@ -1376,7 +1404,7 @@ function useNotifications() {
|
|
|
1376
1404
|
_notifications.value = [];
|
|
1377
1405
|
}
|
|
1378
1406
|
function geterateId() {
|
|
1379
|
-
return +`${(
|
|
1407
|
+
return +`${( new Date()).getTime()}${Math.random() * 1e3}`;
|
|
1380
1408
|
}
|
|
1381
1409
|
async function pushNotification(message, options) {
|
|
1382
1410
|
const timeout = options.timeout || 2500;
|
|
@@ -1453,14 +1481,8 @@ function useOrderDetails(orderId, associations) {
|
|
|
1453
1481
|
associations ? associations : {}
|
|
1454
1482
|
);
|
|
1455
1483
|
const params = {
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
type: "equals",
|
|
1459
|
-
field: "id",
|
|
1460
|
-
value: orderId
|
|
1461
|
-
}
|
|
1462
|
-
],
|
|
1463
|
-
associations: mergedAssociations.associations,
|
|
1484
|
+
ids: [orderId],
|
|
1485
|
+
associations: mergedAssociations,
|
|
1464
1486
|
checkPromotion: true
|
|
1465
1487
|
};
|
|
1466
1488
|
const orderDetailsResponse = await apiClient.invoke(
|
|
@@ -1531,7 +1553,8 @@ function useOrderDetails(orderId, associations) {
|
|
|
1531
1553
|
pathParams: {
|
|
1532
1554
|
documentId,
|
|
1533
1555
|
deepLinkCode
|
|
1534
|
-
}
|
|
1556
|
+
},
|
|
1557
|
+
accept: "application/pdf"
|
|
1535
1558
|
}
|
|
1536
1559
|
);
|
|
1537
1560
|
return response.data;
|
|
@@ -1585,7 +1608,10 @@ function useOrderPayment(order) {
|
|
|
1585
1608
|
const paymentUrl = ref();
|
|
1586
1609
|
const state = computed(() => activeTransaction.value?.stateMachineState);
|
|
1587
1610
|
const isAsynchronous = computed(
|
|
1588
|
-
() =>
|
|
1611
|
+
() => (
|
|
1612
|
+
// @ts-expect-error TODO: [MAJOR] Removed since 6.7
|
|
1613
|
+
activeTransaction.value?.paymentMethod?.asynchronous && activeTransaction.value?.paymentMethod?.afterOrderEnabled
|
|
1614
|
+
)
|
|
1589
1615
|
);
|
|
1590
1616
|
async function handlePayment(finishUrl, errorUrl) {
|
|
1591
1617
|
if (!order.value) {
|
|
@@ -1633,12 +1659,8 @@ function useOrderPayment(order) {
|
|
|
1633
1659
|
function _usePrice(params) {
|
|
1634
1660
|
const { sessionContext } = useSessionContext();
|
|
1635
1661
|
const { browserLocale } = useShopwareContext();
|
|
1636
|
-
const
|
|
1637
|
-
const
|
|
1638
|
-
if (params) {
|
|
1639
|
-
currencyCode.value = params.currencyCode;
|
|
1640
|
-
_setLocaleCode(params.localeCode);
|
|
1641
|
-
}
|
|
1662
|
+
const currencyCode = ref(params?.currencyCode ?? "");
|
|
1663
|
+
const currencyLocale = ref(params?.localeCode || browserLocale);
|
|
1642
1664
|
function update(params2) {
|
|
1643
1665
|
_setCurrencyCode(params2.currencyCode);
|
|
1644
1666
|
_setLocaleCode(params2.localeCode);
|
|
@@ -1847,7 +1869,7 @@ function useProductPrice(product) {
|
|
|
1847
1869
|
const price = computed(
|
|
1848
1870
|
() => _price.value
|
|
1849
1871
|
);
|
|
1850
|
-
const
|
|
1872
|
+
const hasListPrice = computed(() => {
|
|
1851
1873
|
return !!_price.value?.listPrice?.percentage;
|
|
1852
1874
|
});
|
|
1853
1875
|
const regulationPrice = computed(
|
|
@@ -1862,7 +1884,9 @@ function useProductPrice(product) {
|
|
|
1862
1884
|
displayFrom,
|
|
1863
1885
|
tierPrices,
|
|
1864
1886
|
referencePrice,
|
|
1865
|
-
|
|
1887
|
+
hasListPrice,
|
|
1888
|
+
/** @deprecated Use hasListPrice instead */
|
|
1889
|
+
isListPrice: hasListPrice,
|
|
1866
1890
|
regulationPrice
|
|
1867
1891
|
};
|
|
1868
1892
|
}
|
|
@@ -2151,6 +2175,8 @@ function useSessionContext(newContext) {
|
|
|
2151
2175
|
setLanguage,
|
|
2152
2176
|
languageId,
|
|
2153
2177
|
languageIdChain,
|
|
2178
|
+
salesChannelLanguageId: languageId,
|
|
2179
|
+
currentLanguageId: languageIdChain,
|
|
2154
2180
|
setCountry,
|
|
2155
2181
|
setContext
|
|
2156
2182
|
};
|
|
@@ -2171,8 +2197,11 @@ function useShopwareContext() {
|
|
|
2171
2197
|
}
|
|
2172
2198
|
|
|
2173
2199
|
const _wishlistItems = ref([]);
|
|
2200
|
+
const _wishlistProducts = ref([]);
|
|
2174
2201
|
const _currentPage = ref(1);
|
|
2202
|
+
const _limit = ref(15);
|
|
2175
2203
|
const totalWishlistItemsCount = ref(0);
|
|
2204
|
+
const isLoading = ref(false);
|
|
2176
2205
|
function useSyncWishlist() {
|
|
2177
2206
|
const { apiClient } = useShopwareContext();
|
|
2178
2207
|
async function addToWishlistSync(id) {
|
|
@@ -2200,13 +2229,15 @@ function useSyncWishlist() {
|
|
|
2200
2229
|
_wishlistItems.value = [
|
|
2201
2230
|
...response.data.products.elements.map((element) => element.id)
|
|
2202
2231
|
];
|
|
2232
|
+
_wishlistProducts.value = response.data.products.elements;
|
|
2203
2233
|
totalWishlistItemsCount.value = response.data.products.total ?? 0;
|
|
2204
2234
|
_currentPage.value = response.data.products.page ?? 1;
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2235
|
+
_limit.value = response.data.products.limit ?? 15;
|
|
2236
|
+
} catch (error) {
|
|
2237
|
+
console.error("[useSyncWishlist][getWishlistProducts][error]:", error);
|
|
2238
|
+
_wishlistItems.value = [];
|
|
2239
|
+
_wishlistProducts.value = [];
|
|
2240
|
+
totalWishlistItemsCount.value = 0;
|
|
2210
2241
|
}
|
|
2211
2242
|
}
|
|
2212
2243
|
async function mergeWishlistProducts(productIds) {
|
|
@@ -2220,30 +2251,34 @@ function useSyncWishlist() {
|
|
|
2220
2251
|
const items = computed(() => _wishlistItems.value);
|
|
2221
2252
|
const count = computed(() => totalWishlistItemsCount.value);
|
|
2222
2253
|
const currentPage = computed(() => _currentPage.value);
|
|
2254
|
+
const products = computed(() => _wishlistProducts.value);
|
|
2255
|
+
const limit = computed(() => _limit.value);
|
|
2223
2256
|
return {
|
|
2224
2257
|
getWishlistProducts,
|
|
2225
2258
|
addToWishlistSync,
|
|
2226
2259
|
removeFromWishlistSync,
|
|
2227
2260
|
mergeWishlistProducts,
|
|
2261
|
+
products,
|
|
2228
2262
|
items,
|
|
2229
2263
|
count,
|
|
2230
|
-
currentPage
|
|
2264
|
+
currentPage,
|
|
2265
|
+
isLoading,
|
|
2266
|
+
limit
|
|
2231
2267
|
};
|
|
2232
2268
|
}
|
|
2233
2269
|
|
|
2234
2270
|
function useUrlResolver() {
|
|
2235
|
-
const
|
|
2271
|
+
const urlPrefix = inject("urlPrefix", "");
|
|
2272
|
+
const getUrlPrefix = () => urlPrefix;
|
|
2236
2273
|
const resolveUrl = (url) => {
|
|
2237
2274
|
if (url.length > 2083) {
|
|
2238
2275
|
throw new Error("URL Input too long");
|
|
2239
2276
|
}
|
|
2240
2277
|
const navigationPattern = /[a-zA-Z0-9]+\/navigation\/[a-zA-Z0-9]+/;
|
|
2241
|
-
const
|
|
2278
|
+
const prefix = getUrlPrefix();
|
|
2242
2279
|
if (navigationPattern.test(url)) {
|
|
2243
2280
|
const newUrl = url.split("/").slice(1);
|
|
2244
|
-
|
|
2245
|
-
return `${buildUrlPrefix(newUrl.join("/"), urlPrefix)}`;
|
|
2246
|
-
}
|
|
2281
|
+
return buildUrlPrefix(newUrl.join("/"), prefix).path;
|
|
2247
2282
|
}
|
|
2248
2283
|
return url;
|
|
2249
2284
|
};
|
|
@@ -2263,7 +2298,8 @@ function useUser() {
|
|
|
2263
2298
|
const { getStorefrontUrl } = useInternationalization();
|
|
2264
2299
|
const { refreshCart } = useCart();
|
|
2265
2300
|
const userDefaultPaymentMethod = computed(
|
|
2266
|
-
() => user.value?.
|
|
2301
|
+
() => user.value?.lastPaymentMethod?.translated || // @ts-expect-error TODO: [MAJOR] Removed since 6.7
|
|
2302
|
+
user.value?.defaultPaymentMethod?.translated || null
|
|
2267
2303
|
);
|
|
2268
2304
|
const userDefaultBillingAddress = computed(
|
|
2269
2305
|
() => user.value?.defaultBillingAddress || null
|
|
@@ -2366,6 +2402,7 @@ function useUser() {
|
|
|
2366
2402
|
}
|
|
2367
2403
|
async function setDefaultPaymentMethod(paymentMethodId) {
|
|
2368
2404
|
await apiClient.invoke(
|
|
2405
|
+
// @ts-expect-error TODO: [MAJOR] Removed since 6.7
|
|
2369
2406
|
"changePaymentMethod post /account/change-payment-method/{paymentMethodId}",
|
|
2370
2407
|
{
|
|
2371
2408
|
pathParams: { paymentMethodId }
|
|
@@ -2425,19 +2462,23 @@ function useWishlist() {
|
|
|
2425
2462
|
mergeWishlistProducts: mergeWishlistProductsSync,
|
|
2426
2463
|
removeFromWishlistSync,
|
|
2427
2464
|
count: countSync,
|
|
2428
|
-
currentPage
|
|
2465
|
+
currentPage,
|
|
2466
|
+
products,
|
|
2467
|
+
limit: limitSync
|
|
2429
2468
|
} = useSyncWishlist();
|
|
2430
2469
|
const limit = ref(15);
|
|
2431
2470
|
const getWishlistProducts = async (query) => {
|
|
2432
|
-
|
|
2471
|
+
let wishlistQuery = {
|
|
2472
|
+
limit: limit.value
|
|
2473
|
+
};
|
|
2433
2474
|
if (query) {
|
|
2434
|
-
defu(
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2475
|
+
wishlistQuery = defu(query, wishlistQuery);
|
|
2476
|
+
if (query.limit) {
|
|
2477
|
+
limit.value = query.limit;
|
|
2478
|
+
}
|
|
2438
2479
|
}
|
|
2439
2480
|
if (canSyncWishlist.value) {
|
|
2440
|
-
await getWishlistProductsSync(
|
|
2481
|
+
await getWishlistProductsSync(wishlistQuery);
|
|
2441
2482
|
} else {
|
|
2442
2483
|
getWishlistProductsLocal();
|
|
2443
2484
|
}
|
|
@@ -2475,7 +2516,9 @@ function useWishlist() {
|
|
|
2475
2516
|
currentPage,
|
|
2476
2517
|
totalPagesCount,
|
|
2477
2518
|
count,
|
|
2478
|
-
canSyncWishlist
|
|
2519
|
+
canSyncWishlist,
|
|
2520
|
+
products,
|
|
2521
|
+
limit: limitSync
|
|
2479
2522
|
};
|
|
2480
2523
|
}
|
|
2481
2524
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware/composables",
|
|
3
|
-
"version": "1.
|
|
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": "
|
|
54
|
+
"@vueuse/core": "14.1.0",
|
|
55
55
|
"defu": "6.1.4",
|
|
56
56
|
"scule": "1.3.0",
|
|
57
|
-
"@shopware/helpers": "1.
|
|
58
|
-
"@shopware/api-client": "1.
|
|
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": "
|
|
63
|
-
"@
|
|
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": "
|
|
66
|
-
"typescript": "5.
|
|
66
|
+
"happy-dom": "20.8.9",
|
|
67
|
+
"typescript": "5.9.3",
|
|
67
68
|
"unbuild": "2.0.0",
|
|
68
|
-
"vitest": "
|
|
69
|
-
"vue": "3.5.
|
|
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": "
|
|
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": "
|
|
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: {
|
|
@@ -7,7 +7,7 @@ import type { ElementConfig } from "../types";
|
|
|
7
7
|
* @category CMS (Shopping Experiences)
|
|
8
8
|
*/
|
|
9
9
|
export function useCmsElementConfig<
|
|
10
|
-
T extends Schemas["CmsSlot"] & {
|
|
10
|
+
T extends Omit<Schemas["CmsSlot"], "config"> & {
|
|
11
11
|
config: T["config"] extends {
|
|
12
12
|
[key in infer X extends keyof T["config"]]: ElementConfig<unknown>;
|
|
13
13
|
}
|
|
@@ -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;
|