@atomic-solutions/woocommerce-react 0.6.2 → 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.
@@ -1,4 +1,4 @@
1
- export { A as AppliedCoupon, C as CartTotals, aj as InfiniteQueryOptions, ak as MutationOptions, 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, al as QueryOptions, R as ReorderInputItem, j as ReorderItemView, k as ReorderUnavailableReason, S as ShippingRate, 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, E as getOrderStatusLabel, 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';
2
- export { Q as QueryKeys, p as createQueryKeys } from '../types-Dnq60zh-.cjs';
1
+ export { A as AppliedCoupon, C as CartTotals, ak as InfiniteQueryOptions, al as MutationOptions, 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, am as QueryOptions, R as ReorderInputItem, j as ReorderItemView, k as ReorderUnavailableReason, S as ShippingRate, 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, E as getOrderStatusLabel, 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';
2
+ export { Q as QueryKeys, p as createQueryKeys } from '../types-4MW3Y__g.cjs';
3
3
  export { OrderStatus } from '@atomic-solutions/woocommerce-api-client';
4
4
  import '@tanstack/react-query';
@@ -1,4 +1,4 @@
1
- export { A as AppliedCoupon, C as CartTotals, aj as InfiniteQueryOptions, ak as MutationOptions, 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, al as QueryOptions, R as ReorderInputItem, j as ReorderItemView, k as ReorderUnavailableReason, S as ShippingRate, 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, E as getOrderStatusLabel, 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';
2
- export { Q as QueryKeys, p as createQueryKeys } from '../types-Dnq60zh-.js';
1
+ export { A as AppliedCoupon, C as CartTotals, ak as InfiniteQueryOptions, al as MutationOptions, 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, am as QueryOptions, R as ReorderInputItem, j as ReorderItemView, k as ReorderUnavailableReason, S as ShippingRate, 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, E as getOrderStatusLabel, 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';
2
+ export { Q as QueryKeys, p as createQueryKeys } from '../types-4MW3Y__g.js';
3
3
  export { OrderStatus } from '@atomic-solutions/woocommerce-api-client';
4
4
  import '@tanstack/react-query';
@@ -40,6 +40,8 @@ var StaleTimes = {
40
40
  product: STALE_TIME_SHORT,
41
41
  /** Product categories - always fresh */
42
42
  categories: STALE_TIME_NONE,
43
+ /** Product tags - names rarely change, 1 hour */
44
+ tags: STALE_TIME_LONG,
43
45
  /** Orders - always fresh */
44
46
  orders: STALE_TIME_NONE,
45
47
  /** Default for infinite queries - 1 hour */
@@ -137,6 +139,16 @@ var processCategoriesToTree = (data) => {
137
139
  });
138
140
  return rootCategories?.map(processCategory) ?? [];
139
141
  };
142
+ var useProductTags = (params, options) => {
143
+ const client = useWooCommerceClient();
144
+ const queryKeys = useWooCommerceQueryKeys();
145
+ return useQuery({
146
+ queryKey: queryKeys.products.tags(params),
147
+ queryFn: () => client.products.tags(params),
148
+ staleTime: StaleTimes.tags,
149
+ ...options
150
+ });
151
+ };
140
152
  var useProductCategoryTree = () => {
141
153
  const query = useProductCategories();
142
154
  const flatData = query.data ?? [];
@@ -461,7 +473,9 @@ var createQueryKeys = (prefix = ["woocommerce"]) => ({
461
473
  list: (params) => [...prefix, "products", "list", params],
462
474
  details: () => [...prefix, "products", "detail"],
463
475
  detail: (id) => [...prefix, "products", "detail", id],
464
- categories: () => [...prefix, "products", "categories"]
476
+ categories: () => [...prefix, "products", "categories"],
477
+ // Params are in the key, so each set of tag ids is cached apart.
478
+ tags: (params) => [...prefix, "products", "tags", params]
465
479
  },
466
480
  // Cart
467
481
  cart: {
@@ -1222,6 +1236,8 @@ function useOrderView(input, options = {}) {
1222
1236
  const storeContext = useContext(WooCommerceStoreContext);
1223
1237
  const storeConfig = storeContext?.config;
1224
1238
  const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
1239
+ const { imageSize = "thumbnail" } = options;
1240
+ const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
1225
1241
  const { data: rawOrder, isLoading, error } = useOrder(input);
1226
1242
  const order = useMemo(() => {
1227
1243
  if (!rawOrder) return void 0;
@@ -1232,7 +1248,7 @@ function useOrderView(input, options = {}) {
1232
1248
  quantity: item.quantity,
1233
1249
  price: formatStoreApiPriceIntl(item.prices.price, currencyCode, localeTag),
1234
1250
  total: formatStoreApiPriceIntl(item.totals.line_total, currencyCode, localeTag),
1235
- imageUrl: item.images?.[0]?.src
1251
+ imageUrl: getProcessedImageUrl(item.images)
1236
1252
  }));
1237
1253
  const status = rawOrder.status;
1238
1254
  return {
@@ -1247,7 +1263,7 @@ function useOrderView(input, options = {}) {
1247
1263
  paymentMethod: rawOrder.payment_method ?? "",
1248
1264
  raw: rawOrder
1249
1265
  };
1250
- }, [rawOrder, localeTag]);
1266
+ }, [rawOrder, localeTag, getProcessedImageUrl]);
1251
1267
  return {
1252
1268
  order,
1253
1269
  isLoading,
@@ -1255,6 +1271,6 @@ function useOrderView(input, options = {}) {
1255
1271
  };
1256
1272
  }
1257
1273
 
1258
- export { createQueryKeys, getOrderStatusLabel, 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 };
1274
+ export { createQueryKeys, getOrderStatusLabel, 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 };
1259
1275
  //# sourceMappingURL=index.js.map
1260
1276
  //# sourceMappingURL=index.js.map