@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.
- package/dist/hooks/index.cjs +20 -3
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +20 -4
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-Dmlapl9c.d.ts → index-BmWcF7aq.d.ts} +12 -5
- package/dist/{index-DEvJWFSF.d.cts → index-UkshfFwm.d.cts} +12 -5
- package/dist/index.cjs +20 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/provider/index.d.cts +2 -2
- package/dist/provider/index.d.ts +2 -2
- package/dist/{types-Dnq60zh-.d.cts → types-4MW3Y__g.d.cts} +2 -1
- package/dist/{types-Dnq60zh-.d.ts → types-4MW3Y__g.d.ts} +2 -1
- package/package.json +2 -2
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-
|
|
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-
|
|
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
|
|
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-
|
|
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-
|
|
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
|
|
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: {
|
|
@@ -1739,6 +1753,8 @@ function useOrderView(input, options = {}) {
|
|
|
1739
1753
|
const storeContext = useContext(WooCommerceStoreContext);
|
|
1740
1754
|
const storeConfig = storeContext?.config;
|
|
1741
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);
|
|
1742
1758
|
const { data: rawOrder, isLoading, error } = useOrder(input);
|
|
1743
1759
|
const order = useMemo(() => {
|
|
1744
1760
|
if (!rawOrder) return void 0;
|
|
@@ -1749,7 +1765,7 @@ function useOrderView(input, options = {}) {
|
|
|
1749
1765
|
quantity: item.quantity,
|
|
1750
1766
|
price: formatStoreApiPriceIntl(item.prices.price, currencyCode, localeTag),
|
|
1751
1767
|
total: formatStoreApiPriceIntl(item.totals.line_total, currencyCode, localeTag),
|
|
1752
|
-
imageUrl: item.images
|
|
1768
|
+
imageUrl: getProcessedImageUrl(item.images)
|
|
1753
1769
|
}));
|
|
1754
1770
|
const status = rawOrder.status;
|
|
1755
1771
|
return {
|
|
@@ -1764,7 +1780,7 @@ function useOrderView(input, options = {}) {
|
|
|
1764
1780
|
paymentMethod: rawOrder.payment_method ?? "",
|
|
1765
1781
|
raw: rawOrder
|
|
1766
1782
|
};
|
|
1767
|
-
}, [rawOrder, localeTag]);
|
|
1783
|
+
}, [rawOrder, localeTag, getProcessedImageUrl]);
|
|
1768
1784
|
return {
|
|
1769
1785
|
order,
|
|
1770
1786
|
isLoading,
|
|
@@ -1839,6 +1855,6 @@ function createAnalyticsHandler(provider) {
|
|
|
1839
1855
|
};
|
|
1840
1856
|
}
|
|
1841
1857
|
|
|
1842
|
-
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 };
|
|
1843
1859
|
//# sourceMappingURL=index.js.map
|
|
1844
1860
|
//# sourceMappingURL=index.js.map
|