@atomic-solutions/woocommerce-react 0.6.1 → 0.7.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/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as react from 'react';
2
2
  import react__default from 'react';
3
3
  import { WooCommerceClient } from '@atomic-solutions/woocommerce-api-client';
4
- export { Address, AddressFormMessages, AddressFormValues, BillingAddress, BillingAddressFormValues, Cart, CartHeadersAdapter, CartItem, Checkout, OrderStatus, Product, ProductCategory, ProductImage, ProductParams, StoreApiOrder, addressSchema, checkoutSchema, makeAddressFormSchema, makeBillingAddressFormSchema } from '@atomic-solutions/woocommerce-api-client';
5
- import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig, b as WooCommerceEventType } from './types-Dnq60zh-.cjs';
6
- export { C as CartCouponAppliedEvent, c as CartCouponRemovedEvent, d as CartCustomerUpdatedEvent, e as CartItemAddedEvent, f as CartItemRemovedEvent, g as CartItemUpdatedEvent, h as CartShippingSelectedEvent, i as CheckoutProcessedEvent, D as DEFAULT_STORE_CONFIG, O as OrderFetchedEvent, j as StoreConfig, k as StoreContextValue, l as StoreFeatures, m as StoreGuardrails, n as StoreTheme, o as WooCommerceEvent, p as createQueryKeys } from './types-Dnq60zh-.cjs';
4
+ export { Address, AddressFormMessages, AddressFormValues, BillingAddress, BillingAddressFormValues, Cart, CartHeadersAdapter, CartItem, Checkout, OrderStatus, Product, ProductCategory, ProductImage, ProductParams, ProductTag, ProductTagsParams, StoreApiOrder, addressSchema, checkoutSchema, makeAddressFormSchema, makeBillingAddressFormSchema } from '@atomic-solutions/woocommerce-api-client';
5
+ import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig, b as WooCommerceEventType } from './types-4MW3Y__g.cjs';
6
+ export { C as CartCouponAppliedEvent, c as CartCouponRemovedEvent, d as CartCustomerUpdatedEvent, e as CartItemAddedEvent, f as CartItemRemovedEvent, g as CartItemUpdatedEvent, h as CartShippingSelectedEvent, i as CheckoutProcessedEvent, D as DEFAULT_STORE_CONFIG, O as OrderFetchedEvent, j as StoreConfig, k as StoreContextValue, l as StoreFeatures, m as StoreGuardrails, n as StoreTheme, o as WooCommerceEvent, p as createQueryKeys } from './types-4MW3Y__g.cjs';
7
7
  export { WooCommerceStoreContext, WooCommerceStoreProvider, WooCommerceStoreProviderProps } from './provider/index.cjs';
8
- export { A as AppliedCoupon, C as CartTotals, I as ImageSize, P as PLACEHOLDER_IMAGE_URL, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedOrderDetails, e as ProcessedOrderLineItem, f as ProcessedProduct, g as ProcessedProductDetails, h as ProductCartState, i as ProductCategoryTreeNode, R as ReorderInputItem, j as ReorderItemView, k as ReorderUnavailableReason, S as ShippingRate, l as StockDisplayConfig, m as StockStatus, U as UnavailableReason, n as UseCartViewOptions, o as UseCartViewReturn, p as UseOrderViewOptions, q as UseOrderViewReturn, r as UseProductViewOptions, s as UseProductViewReturn, t as UseProductsFeedOptions, u as UseProductsFeedReturn, v as UseReorderViewOptions, w as UseReorderViewReturn, x as canAddToCart, y as getAllImageUrls, z as getImageUrl, B as getImageUrlOrPlaceholder, D as getMaxAddToCartQuantity, E as getOrderStatusLabel, F as getPrimaryImage, G as getSizedImageUrl, H as getStockSeverity, J as getStockStatusText, K as isLowStock, L as isPurchasable, M as preloadImage, N as preloadImages, O as unavailableReason, Q as useAddManyToCart, T as useAddToCart, V as useApplyCoupon, W as useCart, X as useCartView, Y as useCheckout, Z as useInfiniteProducts, _ as useOrder, $ as useOrderView, a0 as useProcessCheckout, a1 as useProduct, a2 as useProductCategories, a3 as useProductCategoryTree, a4 as useProductView, a5 as useProducts, a6 as useProductsFeed, a7 as useRemoveCoupon, a8 as useRemoveFromCart, a9 as useReorderView, aa as useSelectShippingRate, ab as useStore, ac as useStoreFeatures, ad as useStoreLocale, ae as useStoreTheme, af as useUpdateCartItem, ag as useUpdateCustomer, ah as useWooCommerceClient, ai as useWooCommerceQueryKeys } from './index-DEvJWFSF.cjs';
8
+ export { A as AppliedCoupon, C as CartTotals, I as ImageSize, P as PLACEHOLDER_IMAGE_URL, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedOrderDetails, e as ProcessedOrderLineItem, f as ProcessedProduct, g as ProcessedProductDetails, h as ProductCartState, i as ProductCategoryTreeNode, R as ReorderInputItem, j as ReorderItemView, k as ReorderUnavailableReason, S as ShippingRate, l as StockDisplayConfig, m as StockStatus, U as UnavailableReason, n as UseCartViewOptions, o as UseCartViewReturn, p as UseOrderViewOptions, q as UseOrderViewReturn, r as UseProductViewOptions, s as UseProductViewReturn, t as UseProductsFeedOptions, u as UseProductsFeedReturn, v as UseReorderViewOptions, w as UseReorderViewReturn, x as canAddToCart, y as getAllImageUrls, z as getImageUrl, B as getImageUrlOrPlaceholder, D as getMaxAddToCartQuantity, E as getOrderStatusLabel, F as getPrimaryImage, G as getSizedImageUrl, H as getStockSeverity, J as getStockStatusText, K as isLowStock, L as isPurchasable, M as preloadImage, N as preloadImages, O as unavailableReason, Q as useAddManyToCart, T as useAddToCart, V as useApplyCoupon, W as useCart, X as useCartView, Y as useCheckout, Z as useInfiniteProducts, _ as useOrder, $ as useOrderView, a0 as useProcessCheckout, a1 as useProduct, a2 as useProductCategories, a3 as useProductCategoryTree, a4 as useProductTags, a5 as useProductView, a6 as useProducts, a7 as useProductsFeed, a8 as useRemoveCoupon, a9 as useRemoveFromCart, aa as useReorderView, ab as useSelectShippingRate, ac as useStore, ad as useStoreFeatures, ae as useStoreLocale, af as useStoreTheme, ag as useUpdateCartItem, ah as useUpdateCustomer, ai as useWooCommerceClient, aj as useWooCommerceQueryKeys } from './index-UkshfFwm.cjs';
9
9
  import 'react/jsx-runtime';
10
10
  import '@tanstack/react-query';
11
11
 
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as react from 'react';
2
2
  import react__default from 'react';
3
3
  import { WooCommerceClient } from '@atomic-solutions/woocommerce-api-client';
4
- export { Address, AddressFormMessages, AddressFormValues, BillingAddress, BillingAddressFormValues, Cart, CartHeadersAdapter, CartItem, Checkout, OrderStatus, Product, ProductCategory, ProductImage, ProductParams, StoreApiOrder, addressSchema, checkoutSchema, makeAddressFormSchema, makeBillingAddressFormSchema } from '@atomic-solutions/woocommerce-api-client';
5
- import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig, b as WooCommerceEventType } from './types-Dnq60zh-.js';
6
- export { C as CartCouponAppliedEvent, c as CartCouponRemovedEvent, d as CartCustomerUpdatedEvent, e as CartItemAddedEvent, f as CartItemRemovedEvent, g as CartItemUpdatedEvent, h as CartShippingSelectedEvent, i as CheckoutProcessedEvent, D as DEFAULT_STORE_CONFIG, O as OrderFetchedEvent, j as StoreConfig, k as StoreContextValue, l as StoreFeatures, m as StoreGuardrails, n as StoreTheme, o as WooCommerceEvent, p as createQueryKeys } from './types-Dnq60zh-.js';
4
+ export { Address, AddressFormMessages, AddressFormValues, BillingAddress, BillingAddressFormValues, Cart, CartHeadersAdapter, CartItem, Checkout, OrderStatus, Product, ProductCategory, ProductImage, ProductParams, ProductTag, ProductTagsParams, StoreApiOrder, addressSchema, checkoutSchema, makeAddressFormSchema, makeBillingAddressFormSchema } from '@atomic-solutions/woocommerce-api-client';
5
+ import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig, b as WooCommerceEventType } from './types-4MW3Y__g.js';
6
+ export { C as CartCouponAppliedEvent, c as CartCouponRemovedEvent, d as CartCustomerUpdatedEvent, e as CartItemAddedEvent, f as CartItemRemovedEvent, g as CartItemUpdatedEvent, h as CartShippingSelectedEvent, i as CheckoutProcessedEvent, D as DEFAULT_STORE_CONFIG, O as OrderFetchedEvent, j as StoreConfig, k as StoreContextValue, l as StoreFeatures, m as StoreGuardrails, n as StoreTheme, o as WooCommerceEvent, p as createQueryKeys } from './types-4MW3Y__g.js';
7
7
  export { WooCommerceStoreContext, WooCommerceStoreProvider, WooCommerceStoreProviderProps } from './provider/index.js';
8
- export { A as AppliedCoupon, C as CartTotals, I as ImageSize, P as PLACEHOLDER_IMAGE_URL, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedOrderDetails, e as ProcessedOrderLineItem, f as ProcessedProduct, g as ProcessedProductDetails, h as ProductCartState, i as ProductCategoryTreeNode, R as ReorderInputItem, j as ReorderItemView, k as ReorderUnavailableReason, S as ShippingRate, l as StockDisplayConfig, m as StockStatus, U as UnavailableReason, n as UseCartViewOptions, o as UseCartViewReturn, p as UseOrderViewOptions, q as UseOrderViewReturn, r as UseProductViewOptions, s as UseProductViewReturn, t as UseProductsFeedOptions, u as UseProductsFeedReturn, v as UseReorderViewOptions, w as UseReorderViewReturn, x as canAddToCart, y as getAllImageUrls, z as getImageUrl, B as getImageUrlOrPlaceholder, D as getMaxAddToCartQuantity, E as getOrderStatusLabel, F as getPrimaryImage, G as getSizedImageUrl, H as getStockSeverity, J as getStockStatusText, K as isLowStock, L as isPurchasable, M as preloadImage, N as preloadImages, O as unavailableReason, Q as useAddManyToCart, T as useAddToCart, V as useApplyCoupon, W as useCart, X as useCartView, Y as useCheckout, Z as useInfiniteProducts, _ as useOrder, $ as useOrderView, a0 as useProcessCheckout, a1 as useProduct, a2 as useProductCategories, a3 as useProductCategoryTree, a4 as useProductView, a5 as useProducts, a6 as useProductsFeed, a7 as useRemoveCoupon, a8 as useRemoveFromCart, a9 as useReorderView, aa as useSelectShippingRate, ab as useStore, ac as useStoreFeatures, ad as useStoreLocale, ae as useStoreTheme, af as useUpdateCartItem, ag as useUpdateCustomer, ah as useWooCommerceClient, ai as useWooCommerceQueryKeys } from './index-Dmlapl9c.js';
8
+ export { A as AppliedCoupon, C as CartTotals, I as ImageSize, P as PLACEHOLDER_IMAGE_URL, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedOrderDetails, e as ProcessedOrderLineItem, f as ProcessedProduct, g as ProcessedProductDetails, h as ProductCartState, i as ProductCategoryTreeNode, R as ReorderInputItem, j as ReorderItemView, k as ReorderUnavailableReason, S as ShippingRate, l as StockDisplayConfig, m as StockStatus, U as UnavailableReason, n as UseCartViewOptions, o as UseCartViewReturn, p as UseOrderViewOptions, q as UseOrderViewReturn, r as UseProductViewOptions, s as UseProductViewReturn, t as UseProductsFeedOptions, u as UseProductsFeedReturn, v as UseReorderViewOptions, w as UseReorderViewReturn, x as canAddToCart, y as getAllImageUrls, z as getImageUrl, B as getImageUrlOrPlaceholder, D as getMaxAddToCartQuantity, E as getOrderStatusLabel, F as getPrimaryImage, G as getSizedImageUrl, H as getStockSeverity, J as getStockStatusText, K as isLowStock, L as isPurchasable, M as preloadImage, N as preloadImages, O as unavailableReason, Q as useAddManyToCart, T as useAddToCart, V as useApplyCoupon, W as useCart, X as useCartView, Y as useCheckout, Z as useInfiniteProducts, _ as useOrder, $ as useOrderView, a0 as useProcessCheckout, a1 as useProduct, a2 as useProductCategories, a3 as useProductCategoryTree, a4 as useProductTags, a5 as useProductView, a6 as useProducts, a7 as useProductsFeed, a8 as useRemoveCoupon, a9 as useRemoveFromCart, aa as useReorderView, ab as useSelectShippingRate, ac as useStore, ad as useStoreFeatures, ae as useStoreLocale, af as useStoreTheme, ag as useUpdateCartItem, ah as useUpdateCustomer, ai as useWooCommerceClient, aj as useWooCommerceQueryKeys } from './index-BmWcF7aq.js';
9
9
  import 'react/jsx-runtime';
10
10
  import '@tanstack/react-query';
11
11
 
package/dist/index.js CHANGED
@@ -477,6 +477,8 @@ var StaleTimes = {
477
477
  product: STALE_TIME_SHORT,
478
478
  /** Product categories - always fresh */
479
479
  categories: STALE_TIME_NONE,
480
+ /** Product tags - names rarely change, 1 hour */
481
+ tags: STALE_TIME_LONG,
480
482
  /** Orders - always fresh */
481
483
  orders: STALE_TIME_NONE,
482
484
  /** Default for infinite queries - 1 hour */
@@ -574,6 +576,16 @@ var processCategoriesToTree = (data) => {
574
576
  });
575
577
  return rootCategories?.map(processCategory) ?? [];
576
578
  };
579
+ var useProductTags = (params, options) => {
580
+ const client = useWooCommerceClient();
581
+ const queryKeys = useWooCommerceQueryKeys();
582
+ return useQuery({
583
+ queryKey: queryKeys.products.tags(params),
584
+ queryFn: () => client.products.tags(params),
585
+ staleTime: StaleTimes.tags,
586
+ ...options
587
+ });
588
+ };
577
589
  var useProductCategoryTree = () => {
578
590
  const query = useProductCategories();
579
591
  const flatData = query.data ?? [];
@@ -894,7 +906,9 @@ var createQueryKeys = (prefix = ["woocommerce"]) => ({
894
906
  list: (params) => [...prefix, "products", "list", params],
895
907
  details: () => [...prefix, "products", "detail"],
896
908
  detail: (id) => [...prefix, "products", "detail", id],
897
- categories: () => [...prefix, "products", "categories"]
909
+ categories: () => [...prefix, "products", "categories"],
910
+ // Params are in the key, so each set of tag ids is cached apart.
911
+ tags: (params) => [...prefix, "products", "tags", params]
898
912
  },
899
913
  // Cart
900
914
  cart: {
@@ -978,64 +992,6 @@ function useStoreTheme(options = {}) {
978
992
  };
979
993
  }
980
994
 
981
- // src/utils/image.ts
982
- var SIZE_SUFFIXES = {
983
- thumbnail: "-150x150",
984
- medium: "-300x300",
985
- large: "-1024x1024",
986
- full: ""
987
- };
988
- function getPrimaryImage(images) {
989
- if (!images || images.length === 0) {
990
- return void 0;
991
- }
992
- return images[0];
993
- }
994
- function getImageUrl(images, size = "full", fallback) {
995
- const primary = getPrimaryImage(images);
996
- if (!primary) {
997
- return fallback;
998
- }
999
- return getSizedImageUrl(primary.src, size);
1000
- }
1001
- function getSizedImageUrl(url, size = "full") {
1002
- if (!url || size === "full") {
1003
- return url;
1004
- }
1005
- const hasSize = Object.values(SIZE_SUFFIXES).some((suffix2) => suffix2 && url.includes(suffix2));
1006
- if (hasSize) {
1007
- let result = url;
1008
- Object.values(SIZE_SUFFIXES).forEach((suffix2) => {
1009
- if (suffix2) {
1010
- result = result.replace(suffix2, SIZE_SUFFIXES[size]);
1011
- }
1012
- });
1013
- return result;
1014
- }
1015
- const suffix = SIZE_SUFFIXES[size];
1016
- const lastDot = url.lastIndexOf(".");
1017
- if (lastDot === -1) {
1018
- return url;
1019
- }
1020
- return `${url.slice(0, lastDot)}${suffix}${url.slice(lastDot)}`;
1021
- }
1022
- function getAllImageUrls(images, size = "full") {
1023
- if (!images || images.length === 0) {
1024
- return [];
1025
- }
1026
- return images.map((img) => getSizedImageUrl(img.src, size));
1027
- }
1028
- var PLACEHOLDER_IMAGE_URL = "https://via.placeholder.com/300x300.png?text=No+Image";
1029
- function getImageUrlOrPlaceholder(images, size = "medium") {
1030
- return getImageUrl(images, size, PLACEHOLDER_IMAGE_URL) ?? PLACEHOLDER_IMAGE_URL;
1031
- }
1032
- async function preloadImage(_url) {
1033
- return Promise.resolve();
1034
- }
1035
- async function preloadImages(urls) {
1036
- await Promise.all(urls.map(preloadImage));
1037
- }
1038
-
1039
995
  // src/utils/price.ts
1040
996
  var DEFAULT_LOCALE = {
1041
997
  localeTag: "en-US",
@@ -1181,14 +1137,84 @@ function parseWooCommercePrice(priceString) {
1181
1137
  return parseFloat(cleaned.replace(/,/g, ""));
1182
1138
  }
1183
1139
 
1140
+ // src/utils/image.ts
1141
+ var SIZE_SUFFIXES = {
1142
+ thumbnail: "-150x150",
1143
+ medium: "-300x300",
1144
+ large: "-1024x1024",
1145
+ full: ""
1146
+ };
1147
+ function getPrimaryImage(images) {
1148
+ if (!images || images.length === 0) {
1149
+ return void 0;
1150
+ }
1151
+ return images[0];
1152
+ }
1153
+ function getImageUrl(images, size = "full", fallback) {
1154
+ const primary = getPrimaryImage(images);
1155
+ if (!primary) {
1156
+ return fallback;
1157
+ }
1158
+ return getSizedImageUrl(primary.src, size);
1159
+ }
1160
+ function getSizedImageUrl(url, size = "full") {
1161
+ if (!url || size === "full") {
1162
+ return url;
1163
+ }
1164
+ const hasSize = Object.values(SIZE_SUFFIXES).some((suffix2) => suffix2 && url.includes(suffix2));
1165
+ if (hasSize) {
1166
+ let result = url;
1167
+ Object.values(SIZE_SUFFIXES).forEach((suffix2) => {
1168
+ if (suffix2) {
1169
+ result = result.replace(suffix2, SIZE_SUFFIXES[size]);
1170
+ }
1171
+ });
1172
+ return result;
1173
+ }
1174
+ const suffix = SIZE_SUFFIXES[size];
1175
+ const lastDot = url.lastIndexOf(".");
1176
+ if (lastDot === -1) {
1177
+ return url;
1178
+ }
1179
+ return `${url.slice(0, lastDot)}${suffix}${url.slice(lastDot)}`;
1180
+ }
1181
+ function getAllImageUrls(images, size = "full") {
1182
+ if (!images || images.length === 0) {
1183
+ return [];
1184
+ }
1185
+ return images.map((img) => getSizedImageUrl(img.src, size));
1186
+ }
1187
+ var PLACEHOLDER_IMAGE_URL = "https://via.placeholder.com/300x300.png?text=No+Image";
1188
+ function getImageUrlOrPlaceholder(images, size = "medium") {
1189
+ return getImageUrl(images, size, PLACEHOLDER_IMAGE_URL) ?? PLACEHOLDER_IMAGE_URL;
1190
+ }
1191
+ async function preloadImage(_url) {
1192
+ return Promise.resolve();
1193
+ }
1194
+ async function preloadImages(urls) {
1195
+ await Promise.all(urls.map(preloadImage));
1196
+ }
1197
+
1198
+ // src/hooks/useProcessedImageUrl.ts
1199
+ var useProcessedImageUrl = (imageSize, fallbackOverride) => {
1200
+ const config = useContext(WooCommerceStoreContext)?.config;
1201
+ const transformer = config?.imageUrlTransformer;
1202
+ const fallbackImageUrl = fallbackOverride ?? config?.fallbackImageUrl;
1203
+ return useCallback(
1204
+ (images) => {
1205
+ const baseUrl = getImageUrl(images, imageSize, fallbackImageUrl);
1206
+ return baseUrl && transformer ? transformer(baseUrl, imageSize) : baseUrl;
1207
+ },
1208
+ [imageSize, fallbackImageUrl, transformer]
1209
+ );
1210
+ };
1211
+
1184
1212
  // src/hooks/useProductsFeed.ts
1185
1213
  function useProductsFeed(options = {}) {
1186
1214
  const { params, imageSize = "medium" } = options;
1187
1215
  const storeContext = useContext(WooCommerceStoreContext);
1188
1216
  const storeConfig = storeContext?.config;
1189
1217
  const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
1190
- const fallbackImageUrl = options.fallbackImageUrl ?? storeConfig?.fallbackImageUrl;
1191
- const imageUrlTransformer = storeConfig?.imageUrlTransformer;
1192
1218
  const {
1193
1219
  data: productsData,
1194
1220
  isLoading,
@@ -1200,16 +1226,7 @@ function useProductsFeed(options = {}) {
1200
1226
  isRefetching
1201
1227
  } = useInfiniteProducts(params);
1202
1228
  const { treeData: categoryTree = [], findById } = useProductCategoryTree();
1203
- const getProcessedImageUrl = useCallback(
1204
- (images) => {
1205
- const baseUrl = getImageUrl(images, imageSize, fallbackImageUrl);
1206
- if (baseUrl && imageUrlTransformer) {
1207
- return imageUrlTransformer(baseUrl, imageSize);
1208
- }
1209
- return baseUrl;
1210
- },
1211
- [imageSize, fallbackImageUrl, imageUrlTransformer]
1212
- );
1229
+ const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
1213
1230
  const products = useMemo(() => {
1214
1231
  if (!productsData) return [];
1215
1232
  const productList = Array.isArray(productsData) ? productsData : [];
@@ -1347,7 +1364,6 @@ function useProductView(options) {
1347
1364
  const storeContext = useContext(WooCommerceStoreContext);
1348
1365
  const storeConfig = storeContext?.config;
1349
1366
  const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
1350
- const fallbackImageUrl = options.fallbackImageUrl ?? storeConfig?.fallbackImageUrl;
1351
1367
  const imageUrlTransformer = storeConfig?.imageUrlTransformer;
1352
1368
  const [draftQuantity, setDraftQuantity] = useState(1);
1353
1369
  const { data: productData, isLoading, error, refetch } = useProduct(productId);
@@ -1355,6 +1371,7 @@ function useProductView(options) {
1355
1371
  const addToCartMutation = useAddToCart();
1356
1372
  const removeFromCartMutation = useRemoveFromCart();
1357
1373
  const updateCartMutation = useUpdateCartItem();
1374
+ const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
1358
1375
  const processImageUrl = useCallback(
1359
1376
  (url) => {
1360
1377
  if (!url) return url;
@@ -1370,7 +1387,6 @@ function useProductView(options) {
1370
1387
  const currencyCode = productData.prices?.currency_code;
1371
1388
  const stockStatus = productData.is_on_backorder ? "onbackorder" : productData.is_in_stock ? "instock" : "outofstock";
1372
1389
  const lowStockRemaining = productData.low_stock_remaining;
1373
- const baseImageUrl = getImageUrl(productData.images, imageSize, fallbackImageUrl);
1374
1390
  const baseImageUrls = getAllImageUrls(productData.images, imageSize);
1375
1391
  return {
1376
1392
  id: productData.id,
@@ -1380,7 +1396,7 @@ function useProductView(options) {
1380
1396
  description: productData.description,
1381
1397
  shortDescription: productData.short_description,
1382
1398
  sku: productData.sku,
1383
- imageUrl: processImageUrl(baseImageUrl),
1399
+ imageUrl: getProcessedImageUrl(productData.images),
1384
1400
  imageUrls: baseImageUrls.map((url) => processImageUrl(url) ?? url),
1385
1401
  price: formatStoreApiPriceIntl(productData.prices?.price, currencyCode, localeTag),
1386
1402
  regularPrice: formatStoreApiPriceIntl(
@@ -1410,7 +1426,7 @@ function useProductView(options) {
1410
1426
  minQuantity: productData.add_to_cart?.minimum ?? 1,
1411
1427
  raw: productData
1412
1428
  };
1413
- }, [productData, localeTag, fallbackImageUrl, imageSize, lowStockThreshold, processImageUrl]);
1429
+ }, [productData, localeTag, imageSize, lowStockThreshold, getProcessedImageUrl, processImageUrl]);
1414
1430
  const cartItem = useMemo(() => {
1415
1431
  return cartData?.items.find((item) => item.id === productId);
1416
1432
  }, [cartData?.items, productId]);
@@ -1493,24 +1509,13 @@ function useCartView(options = {}) {
1493
1509
  const storeContext = useContext(WooCommerceStoreContext);
1494
1510
  const storeConfig = storeContext?.config;
1495
1511
  const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
1496
- const fallbackImageUrl = options.fallbackImageUrl ?? storeConfig?.fallbackImageUrl;
1497
- const imageUrlTransformer = storeConfig?.imageUrlTransformer;
1498
1512
  const { data: cartData, isLoading, error, refetch } = useCart();
1499
1513
  const updateItemMutation = useUpdateCartItem();
1500
1514
  const removeItemMutation = useRemoveFromCart();
1501
1515
  const applyCouponMutation = useApplyCoupon();
1502
1516
  const removeCouponMutation = useRemoveCoupon();
1503
1517
  const selectShippingMutation = useSelectShippingRate();
1504
- const getProcessedImageUrl = useCallback(
1505
- (images) => {
1506
- const baseUrl = getImageUrl(images, imageSize, fallbackImageUrl);
1507
- if (baseUrl && imageUrlTransformer) {
1508
- return imageUrlTransformer(baseUrl, imageSize);
1509
- }
1510
- return baseUrl;
1511
- },
1512
- [imageSize, fallbackImageUrl, imageUrlTransformer]
1513
- );
1518
+ const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
1514
1519
  const items = useMemo(() => {
1515
1520
  if (!cartData?.items) return [];
1516
1521
  const currencyCode = cartData.totals.currency_code;
@@ -1656,8 +1661,6 @@ function useReorderView(items, options = {}) {
1656
1661
  const storeContext = useContext(WooCommerceStoreContext);
1657
1662
  const storeConfig = storeContext?.config;
1658
1663
  const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
1659
- const fallbackImageUrl = options.fallbackImageUrl ?? storeConfig?.fallbackImageUrl;
1660
- const imageUrlTransformer = storeConfig?.imageUrlTransformer;
1661
1664
  const productIds = useMemo(() => [...new Set(items.map((item) => item.productId))], [items]);
1662
1665
  const {
1663
1666
  data: productsPage,
@@ -1668,16 +1671,7 @@ function useReorderView(items, options = {}) {
1668
1671
  { enabled: productIds.length > 0 }
1669
1672
  );
1670
1673
  const { data: cart } = useCart();
1671
- const getProcessedImageUrl = useCallback(
1672
- (images) => {
1673
- const baseUrl = getImageUrl(images, imageSize, fallbackImageUrl);
1674
- if (baseUrl && imageUrlTransformer) {
1675
- return imageUrlTransformer(baseUrl, imageSize);
1676
- }
1677
- return baseUrl;
1678
- },
1679
- [imageSize, fallbackImageUrl, imageUrlTransformer]
1680
- );
1674
+ const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
1681
1675
  const views = useMemo(() => {
1682
1676
  const products = new Map((productsPage?.data ?? []).map((product) => [product.id, product]));
1683
1677
  return items.map((item) => {
@@ -1759,6 +1753,8 @@ function useOrderView(input, options = {}) {
1759
1753
  const storeContext = useContext(WooCommerceStoreContext);
1760
1754
  const storeConfig = storeContext?.config;
1761
1755
  const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
1756
+ const { imageSize = "thumbnail" } = options;
1757
+ const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
1762
1758
  const { data: rawOrder, isLoading, error } = useOrder(input);
1763
1759
  const order = useMemo(() => {
1764
1760
  if (!rawOrder) return void 0;
@@ -1769,7 +1765,7 @@ function useOrderView(input, options = {}) {
1769
1765
  quantity: item.quantity,
1770
1766
  price: formatStoreApiPriceIntl(item.prices.price, currencyCode, localeTag),
1771
1767
  total: formatStoreApiPriceIntl(item.totals.line_total, currencyCode, localeTag),
1772
- imageUrl: item.images?.[0]?.src
1768
+ imageUrl: getProcessedImageUrl(item.images)
1773
1769
  }));
1774
1770
  const status = rawOrder.status;
1775
1771
  return {
@@ -1784,7 +1780,7 @@ function useOrderView(input, options = {}) {
1784
1780
  paymentMethod: rawOrder.payment_method ?? "",
1785
1781
  raw: rawOrder
1786
1782
  };
1787
- }, [rawOrder, localeTag]);
1783
+ }, [rawOrder, localeTag, getProcessedImageUrl]);
1788
1784
  return {
1789
1785
  order,
1790
1786
  isLoading,
@@ -1859,6 +1855,6 @@ function createAnalyticsHandler(provider) {
1859
1855
  };
1860
1856
  }
1861
1857
 
1862
- export { DEFAULT_STORE_CONFIG, PLACEHOLDER_IMAGE_URL, RateLimiter, WooCommerceContext, WooCommerceProvider, WooCommerceStoreContext, WooCommerceStoreProvider, calculateDiscount, canAddToCart, composeHandlers, configureGlobalRateLimiter, createAnalyticsHandler, createQueryKeys, formatDiscountBadge, formatPrice, formatPriceRange, formatStoreApiPrice, formatStoreApiPriceIntl, getAllImageUrls, getBaseUrl, getCurrencySymbol, getGlobalRateLimiter, getImageUrl, getImageUrlOrPlaceholder, getMaxAddToCartQuantity, getOrderStatusLabel, getPrimaryImage, getSizedImageUrl, getStockSeverity, getStockStatusText, isLowStock, isPurchasable, isValidStoreUrlFormat, normalizeStoreUrl, parseWooCommercePrice, preloadImage, preloadImages, resetGlobalRateLimiter, unavailableReason, useAddManyToCart, useAddToCart, useApplyCoupon, useCart, useCartView, useCheckout, useInfiniteProducts, useOrder, useOrderView, useProcessCheckout, useProduct, useProductCategories, useProductCategoryTree, useProductView, useProducts, useProductsFeed, useRemoveCoupon, useRemoveFromCart, useReorderView, useSelectShippingRate, useStore, useStoreFeatures, useStoreLocale, useStoreTheme, useUpdateCartItem, useUpdateCustomer, useWooCommerceClient, useWooCommerceQueryKeys, validateWooCommerceStore };
1858
+ export { DEFAULT_STORE_CONFIG, PLACEHOLDER_IMAGE_URL, RateLimiter, WooCommerceContext, WooCommerceProvider, WooCommerceStoreContext, WooCommerceStoreProvider, calculateDiscount, canAddToCart, composeHandlers, configureGlobalRateLimiter, createAnalyticsHandler, createQueryKeys, formatDiscountBadge, formatPrice, formatPriceRange, formatStoreApiPrice, formatStoreApiPriceIntl, getAllImageUrls, getBaseUrl, getCurrencySymbol, getGlobalRateLimiter, getImageUrl, getImageUrlOrPlaceholder, getMaxAddToCartQuantity, getOrderStatusLabel, getPrimaryImage, getSizedImageUrl, getStockSeverity, getStockStatusText, isLowStock, isPurchasable, isValidStoreUrlFormat, normalizeStoreUrl, parseWooCommercePrice, preloadImage, preloadImages, resetGlobalRateLimiter, unavailableReason, useAddManyToCart, useAddToCart, useApplyCoupon, useCart, useCartView, useCheckout, useInfiniteProducts, useOrder, useOrderView, useProcessCheckout, useProduct, useProductCategories, useProductCategoryTree, useProductTags, useProductView, useProducts, useProductsFeed, useRemoveCoupon, useRemoveFromCart, useReorderView, useSelectShippingRate, useStore, useStoreFeatures, useStoreLocale, useStoreTheme, useUpdateCartItem, useUpdateCustomer, useWooCommerceClient, useWooCommerceQueryKeys, validateWooCommerceStore };
1863
1859
  //# sourceMappingURL=index.js.map
1864
1860
  //# sourceMappingURL=index.js.map