@atomic-solutions/woocommerce-react 0.6.2 → 0.8.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 +35 -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 +34 -4
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-Dmlapl9c.d.ts → index-C6OkRa8P.d.ts} +202 -5
- package/dist/{index-DEvJWFSF.d.cts → index-DtuDPfTl.d.cts} +202 -5
- package/dist/index.cjs +35 -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 +34 -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-DABmdACe.d.cts} +3 -1
- package/dist/{types-Dnq60zh-.d.ts → types-DABmdACe.d.ts} +3 -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-DABmdACe.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-DABmdACe.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 useUpdateCartExtensions, ah as useUpdateCartItem, ai as useUpdateCustomer, aj as useWooCommerceClient, ak as useWooCommerceQueryKeys } from './index-DtuDPfTl.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-DABmdACe.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-DABmdACe.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 useUpdateCartExtensions, ah as useUpdateCartItem, ai as useUpdateCustomer, aj as useWooCommerceClient, ak as useWooCommerceQueryKeys } from './index-C6OkRa8P.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 ?? [];
|
|
@@ -788,6 +800,19 @@ var useRemoveCoupon = () => {
|
|
|
788
800
|
}
|
|
789
801
|
});
|
|
790
802
|
};
|
|
803
|
+
var useUpdateCartExtensions = () => {
|
|
804
|
+
const client = useWooCommerceClient();
|
|
805
|
+
const queryKeys = useWooCommerceQueryKeys();
|
|
806
|
+
const queryClient = useQueryClient();
|
|
807
|
+
return useMutation({
|
|
808
|
+
mutationKey: queryKeys.cart.mutations.updateExtensions(),
|
|
809
|
+
mutationFn: (input) => client.cart.updateExtensions(input),
|
|
810
|
+
onSuccess: (cart) => {
|
|
811
|
+
queryClient.setQueryData(queryKeys.cart.details(), cart);
|
|
812
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.cart.all });
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
};
|
|
791
816
|
var useUpdateCustomer = () => {
|
|
792
817
|
const client = useWooCommerceClient();
|
|
793
818
|
const queryKeys = useWooCommerceQueryKeys();
|
|
@@ -894,7 +919,9 @@ var createQueryKeys = (prefix = ["woocommerce"]) => ({
|
|
|
894
919
|
list: (params) => [...prefix, "products", "list", params],
|
|
895
920
|
details: () => [...prefix, "products", "detail"],
|
|
896
921
|
detail: (id) => [...prefix, "products", "detail", id],
|
|
897
|
-
categories: () => [...prefix, "products", "categories"]
|
|
922
|
+
categories: () => [...prefix, "products", "categories"],
|
|
923
|
+
// Params are in the key, so each set of tag ids is cached apart.
|
|
924
|
+
tags: (params) => [...prefix, "products", "tags", params]
|
|
898
925
|
},
|
|
899
926
|
// Cart
|
|
900
927
|
cart: {
|
|
@@ -908,6 +935,7 @@ var createQueryKeys = (prefix = ["woocommerce"]) => ({
|
|
|
908
935
|
removeItem: () => [...prefix, "cart", "mutation", "removeItem"],
|
|
909
936
|
applyCoupon: () => [...prefix, "cart", "mutation", "applyCoupon"],
|
|
910
937
|
removeCoupon: () => [...prefix, "cart", "mutation", "removeCoupon"],
|
|
938
|
+
updateExtensions: () => [...prefix, "cart", "mutation", "updateExtensions"],
|
|
911
939
|
updateCustomer: () => [...prefix, "cart", "mutation", "updateCustomer"],
|
|
912
940
|
selectShippingRate: () => [...prefix, "cart", "mutation", "selectShippingRate"]
|
|
913
941
|
}
|
|
@@ -1739,6 +1767,8 @@ function useOrderView(input, options = {}) {
|
|
|
1739
1767
|
const storeContext = useContext(WooCommerceStoreContext);
|
|
1740
1768
|
const storeConfig = storeContext?.config;
|
|
1741
1769
|
const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
|
|
1770
|
+
const { imageSize = "thumbnail" } = options;
|
|
1771
|
+
const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
|
|
1742
1772
|
const { data: rawOrder, isLoading, error } = useOrder(input);
|
|
1743
1773
|
const order = useMemo(() => {
|
|
1744
1774
|
if (!rawOrder) return void 0;
|
|
@@ -1749,7 +1779,7 @@ function useOrderView(input, options = {}) {
|
|
|
1749
1779
|
quantity: item.quantity,
|
|
1750
1780
|
price: formatStoreApiPriceIntl(item.prices.price, currencyCode, localeTag),
|
|
1751
1781
|
total: formatStoreApiPriceIntl(item.totals.line_total, currencyCode, localeTag),
|
|
1752
|
-
imageUrl: item.images
|
|
1782
|
+
imageUrl: getProcessedImageUrl(item.images)
|
|
1753
1783
|
}));
|
|
1754
1784
|
const status = rawOrder.status;
|
|
1755
1785
|
return {
|
|
@@ -1764,7 +1794,7 @@ function useOrderView(input, options = {}) {
|
|
|
1764
1794
|
paymentMethod: rawOrder.payment_method ?? "",
|
|
1765
1795
|
raw: rawOrder
|
|
1766
1796
|
};
|
|
1767
|
-
}, [rawOrder, localeTag]);
|
|
1797
|
+
}, [rawOrder, localeTag, getProcessedImageUrl]);
|
|
1768
1798
|
return {
|
|
1769
1799
|
order,
|
|
1770
1800
|
isLoading,
|
|
@@ -1839,6 +1869,6 @@ function createAnalyticsHandler(provider) {
|
|
|
1839
1869
|
};
|
|
1840
1870
|
}
|
|
1841
1871
|
|
|
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 };
|
|
1872
|
+
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, useUpdateCartExtensions, useUpdateCartItem, useUpdateCustomer, useWooCommerceClient, useWooCommerceQueryKeys, validateWooCommerceStore };
|
|
1843
1873
|
//# sourceMappingURL=index.js.map
|
|
1844
1874
|
//# sourceMappingURL=index.js.map
|