@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
2
|
import { UseQueryOptions, UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
|
|
3
3
|
import * as _atomic_solutions_woocommerce_api_client from '@atomic-solutions/woocommerce-api-client';
|
|
4
|
-
import { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
|
|
5
|
-
import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-
|
|
4
|
+
import { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, ProductTagsParams, ProductTag, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
|
|
5
|
+
import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-4MW3Y__g.js';
|
|
6
6
|
|
|
7
7
|
type QueryOptions<TData, TError = Error> = Omit<UseQueryOptions<TData, TError>, 'queryKey' | 'queryFn'>;
|
|
8
8
|
type MutationOptions<TData, TError = Error, TVariables = unknown> = Omit<UseMutationOptions<TData, TError, TVariables>, 'mutationFn'>;
|
|
@@ -2933,6 +2933,11 @@ declare const useProductCategories: (options?: QueryOptions<ProductCategory[]>)
|
|
|
2933
2933
|
count: number;
|
|
2934
2934
|
menu_order?: number | undefined;
|
|
2935
2935
|
}[], Error>;
|
|
2936
|
+
declare const useProductTags: (params?: ProductTagsParams, options?: QueryOptions<ProductTag[]>) => _tanstack_react_query.UseQueryResult<{
|
|
2937
|
+
id: number;
|
|
2938
|
+
name: string;
|
|
2939
|
+
slug: string;
|
|
2940
|
+
}[], Error>;
|
|
2936
2941
|
declare const useProductCategoryTree: () => {
|
|
2937
2942
|
data: {
|
|
2938
2943
|
id: number;
|
|
@@ -8333,7 +8338,7 @@ declare const useCheckout: (options?: QueryOptions<Checkout>) => _tanstack_react
|
|
|
8333
8338
|
payment_status: string;
|
|
8334
8339
|
payment_details: unknown[];
|
|
8335
8340
|
redirect_url: string;
|
|
8336
|
-
};
|
|
8341
|
+
} | null;
|
|
8337
8342
|
}, Error>;
|
|
8338
8343
|
declare const useProcessCheckout: () => _tanstack_react_query.UseMutationResult<{
|
|
8339
8344
|
status: string;
|
|
@@ -8371,7 +8376,7 @@ declare const useProcessCheckout: () => _tanstack_react_query.UseMutationResult<
|
|
|
8371
8376
|
payment_status: string;
|
|
8372
8377
|
payment_details: unknown[];
|
|
8373
8378
|
redirect_url: string;
|
|
8374
|
-
};
|
|
8379
|
+
} | null;
|
|
8375
8380
|
}, Error, {
|
|
8376
8381
|
payment_method: string;
|
|
8377
8382
|
extensions?: Record<string, unknown> | undefined;
|
|
@@ -8807,6 +8812,8 @@ interface ProcessedOrderDetails {
|
|
|
8807
8812
|
}
|
|
8808
8813
|
interface UseOrderViewOptions {
|
|
8809
8814
|
localeTag?: string;
|
|
8815
|
+
fallbackImageUrl?: string;
|
|
8816
|
+
imageSize?: ImageSize;
|
|
8810
8817
|
}
|
|
8811
8818
|
interface UseOrderViewReturn {
|
|
8812
8819
|
order: ProcessedOrderDetails | undefined;
|
|
@@ -8815,4 +8822,4 @@ interface UseOrderViewReturn {
|
|
|
8815
8822
|
}
|
|
8816
8823
|
declare function useOrderView(input: GetOrderInput, options?: UseOrderViewOptions): UseOrderViewReturn;
|
|
8817
8824
|
|
|
8818
|
-
export { useOrderView as $, type AppliedCoupon as A, getImageUrlOrPlaceholder as B, type CartTotals as C, getMaxAddToCartQuantity as D, getOrderStatusLabel as E, getPrimaryImage as F, getSizedImageUrl as G, getStockSeverity as H, type ImageSize as I, getStockStatusText as J, isLowStock as K, isPurchasable as L, preloadImage as M, preloadImages as N, unavailableReason as O, PLACEHOLDER_IMAGE_URL as P, useAddManyToCart as Q, type ReorderInputItem as R, type ShippingRate as S, useAddToCart as T, type UnavailableReason as U, useApplyCoupon as V, useCart as W, useCartView as X, useCheckout as Y, useInfiniteProducts as Z, useOrder as _, type PaymentMethod as a, useProcessCheckout as a0, useProduct as a1, useProductCategories as a2, useProductCategoryTree as a3,
|
|
8825
|
+
export { useOrderView as $, type AppliedCoupon as A, getImageUrlOrPlaceholder as B, type CartTotals as C, getMaxAddToCartQuantity as D, getOrderStatusLabel as E, getPrimaryImage as F, getSizedImageUrl as G, getStockSeverity as H, type ImageSize as I, getStockStatusText as J, isLowStock as K, isPurchasable as L, preloadImage as M, preloadImages as N, unavailableReason as O, PLACEHOLDER_IMAGE_URL as P, useAddManyToCart as Q, type ReorderInputItem as R, type ShippingRate as S, useAddToCart as T, type UnavailableReason as U, useApplyCoupon as V, useCart as W, useCartView as X, useCheckout as Y, useInfiniteProducts as Z, useOrder as _, type PaymentMethod as a, useProcessCheckout as a0, useProduct as a1, useProductCategories as a2, useProductCategoryTree as a3, useProductTags as a4, useProductView as a5, useProducts as a6, useProductsFeed as a7, useRemoveCoupon as a8, useRemoveFromCart as a9, useReorderView as aa, useSelectShippingRate as ab, useStore as ac, useStoreFeatures as ad, useStoreLocale as ae, useStoreTheme as af, useUpdateCartItem as ag, useUpdateCustomer as ah, useWooCommerceClient as ai, useWooCommerceQueryKeys as aj, type InfiniteQueryOptions as ak, type MutationOptions as al, type QueryOptions as am, type ProcessedCartItem as b, type ProcessedCategory as c, type ProcessedOrderDetails as d, type ProcessedOrderLineItem as e, type ProcessedProduct as f, type ProcessedProductDetails as g, type ProductCartState as h, type ProductCategoryTreeNode as i, type ReorderItemView as j, type ReorderUnavailableReason as k, type StockDisplayConfig as l, type StockStatus as m, type UseCartViewOptions as n, type UseCartViewReturn as o, type UseOrderViewOptions as p, type UseOrderViewReturn as q, type UseProductViewOptions as r, type UseProductViewReturn as s, type UseProductsFeedOptions as t, type UseProductsFeedReturn as u, type UseReorderViewOptions as v, type UseReorderViewReturn as w, canAddToCart as x, getAllImageUrls as y, getImageUrl as z };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
2
|
import { UseQueryOptions, UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
|
|
3
3
|
import * as _atomic_solutions_woocommerce_api_client from '@atomic-solutions/woocommerce-api-client';
|
|
4
|
-
import { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
|
|
5
|
-
import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-
|
|
4
|
+
import { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, ProductTagsParams, ProductTag, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
|
|
5
|
+
import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-4MW3Y__g.cjs';
|
|
6
6
|
|
|
7
7
|
type QueryOptions<TData, TError = Error> = Omit<UseQueryOptions<TData, TError>, 'queryKey' | 'queryFn'>;
|
|
8
8
|
type MutationOptions<TData, TError = Error, TVariables = unknown> = Omit<UseMutationOptions<TData, TError, TVariables>, 'mutationFn'>;
|
|
@@ -2933,6 +2933,11 @@ declare const useProductCategories: (options?: QueryOptions<ProductCategory[]>)
|
|
|
2933
2933
|
count: number;
|
|
2934
2934
|
menu_order?: number | undefined;
|
|
2935
2935
|
}[], Error>;
|
|
2936
|
+
declare const useProductTags: (params?: ProductTagsParams, options?: QueryOptions<ProductTag[]>) => _tanstack_react_query.UseQueryResult<{
|
|
2937
|
+
id: number;
|
|
2938
|
+
name: string;
|
|
2939
|
+
slug: string;
|
|
2940
|
+
}[], Error>;
|
|
2936
2941
|
declare const useProductCategoryTree: () => {
|
|
2937
2942
|
data: {
|
|
2938
2943
|
id: number;
|
|
@@ -8333,7 +8338,7 @@ declare const useCheckout: (options?: QueryOptions<Checkout>) => _tanstack_react
|
|
|
8333
8338
|
payment_status: string;
|
|
8334
8339
|
payment_details: unknown[];
|
|
8335
8340
|
redirect_url: string;
|
|
8336
|
-
};
|
|
8341
|
+
} | null;
|
|
8337
8342
|
}, Error>;
|
|
8338
8343
|
declare const useProcessCheckout: () => _tanstack_react_query.UseMutationResult<{
|
|
8339
8344
|
status: string;
|
|
@@ -8371,7 +8376,7 @@ declare const useProcessCheckout: () => _tanstack_react_query.UseMutationResult<
|
|
|
8371
8376
|
payment_status: string;
|
|
8372
8377
|
payment_details: unknown[];
|
|
8373
8378
|
redirect_url: string;
|
|
8374
|
-
};
|
|
8379
|
+
} | null;
|
|
8375
8380
|
}, Error, {
|
|
8376
8381
|
payment_method: string;
|
|
8377
8382
|
extensions?: Record<string, unknown> | undefined;
|
|
@@ -8807,6 +8812,8 @@ interface ProcessedOrderDetails {
|
|
|
8807
8812
|
}
|
|
8808
8813
|
interface UseOrderViewOptions {
|
|
8809
8814
|
localeTag?: string;
|
|
8815
|
+
fallbackImageUrl?: string;
|
|
8816
|
+
imageSize?: ImageSize;
|
|
8810
8817
|
}
|
|
8811
8818
|
interface UseOrderViewReturn {
|
|
8812
8819
|
order: ProcessedOrderDetails | undefined;
|
|
@@ -8815,4 +8822,4 @@ interface UseOrderViewReturn {
|
|
|
8815
8822
|
}
|
|
8816
8823
|
declare function useOrderView(input: GetOrderInput, options?: UseOrderViewOptions): UseOrderViewReturn;
|
|
8817
8824
|
|
|
8818
|
-
export { useOrderView as $, type AppliedCoupon as A, getImageUrlOrPlaceholder as B, type CartTotals as C, getMaxAddToCartQuantity as D, getOrderStatusLabel as E, getPrimaryImage as F, getSizedImageUrl as G, getStockSeverity as H, type ImageSize as I, getStockStatusText as J, isLowStock as K, isPurchasable as L, preloadImage as M, preloadImages as N, unavailableReason as O, PLACEHOLDER_IMAGE_URL as P, useAddManyToCart as Q, type ReorderInputItem as R, type ShippingRate as S, useAddToCart as T, type UnavailableReason as U, useApplyCoupon as V, useCart as W, useCartView as X, useCheckout as Y, useInfiniteProducts as Z, useOrder as _, type PaymentMethod as a, useProcessCheckout as a0, useProduct as a1, useProductCategories as a2, useProductCategoryTree as a3,
|
|
8825
|
+
export { useOrderView as $, type AppliedCoupon as A, getImageUrlOrPlaceholder as B, type CartTotals as C, getMaxAddToCartQuantity as D, getOrderStatusLabel as E, getPrimaryImage as F, getSizedImageUrl as G, getStockSeverity as H, type ImageSize as I, getStockStatusText as J, isLowStock as K, isPurchasable as L, preloadImage as M, preloadImages as N, unavailableReason as O, PLACEHOLDER_IMAGE_URL as P, useAddManyToCart as Q, type ReorderInputItem as R, type ShippingRate as S, useAddToCart as T, type UnavailableReason as U, useApplyCoupon as V, useCart as W, useCartView as X, useCheckout as Y, useInfiniteProducts as Z, useOrder as _, type PaymentMethod as a, useProcessCheckout as a0, useProduct as a1, useProductCategories as a2, useProductCategoryTree as a3, useProductTags as a4, useProductView as a5, useProducts as a6, useProductsFeed as a7, useRemoveCoupon as a8, useRemoveFromCart as a9, useReorderView as aa, useSelectShippingRate as ab, useStore as ac, useStoreFeatures as ad, useStoreLocale as ae, useStoreTheme as af, useUpdateCartItem as ag, useUpdateCustomer as ah, useWooCommerceClient as ai, useWooCommerceQueryKeys as aj, type InfiniteQueryOptions as ak, type MutationOptions as al, type QueryOptions as am, type ProcessedCartItem as b, type ProcessedCategory as c, type ProcessedOrderDetails as d, type ProcessedOrderLineItem as e, type ProcessedProduct as f, type ProcessedProductDetails as g, type ProductCartState as h, type ProductCategoryTreeNode as i, type ReorderItemView as j, type ReorderUnavailableReason as k, type StockDisplayConfig as l, type StockStatus as m, type UseCartViewOptions as n, type UseCartViewReturn as o, type UseOrderViewOptions as p, type UseOrderViewReturn as q, type UseProductViewOptions as r, type UseProductViewReturn as s, type UseProductsFeedOptions as t, type UseProductsFeedReturn as u, type UseReorderViewOptions as v, type UseReorderViewReturn as w, canAddToCart as x, getAllImageUrls as y, getImageUrl as z };
|
package/dist/index.cjs
CHANGED
|
@@ -478,6 +478,8 @@ var StaleTimes = {
|
|
|
478
478
|
product: STALE_TIME_SHORT,
|
|
479
479
|
/** Product categories - always fresh */
|
|
480
480
|
categories: STALE_TIME_NONE,
|
|
481
|
+
/** Product tags - names rarely change, 1 hour */
|
|
482
|
+
tags: STALE_TIME_LONG,
|
|
481
483
|
/** Orders - always fresh */
|
|
482
484
|
orders: STALE_TIME_NONE,
|
|
483
485
|
/** Default for infinite queries - 1 hour */
|
|
@@ -575,6 +577,16 @@ var processCategoriesToTree = (data) => {
|
|
|
575
577
|
});
|
|
576
578
|
return rootCategories?.map(processCategory) ?? [];
|
|
577
579
|
};
|
|
580
|
+
var useProductTags = (params, options) => {
|
|
581
|
+
const client = useWooCommerceClient();
|
|
582
|
+
const queryKeys = useWooCommerceQueryKeys();
|
|
583
|
+
return reactQuery.useQuery({
|
|
584
|
+
queryKey: queryKeys.products.tags(params),
|
|
585
|
+
queryFn: () => client.products.tags(params),
|
|
586
|
+
staleTime: StaleTimes.tags,
|
|
587
|
+
...options
|
|
588
|
+
});
|
|
589
|
+
};
|
|
578
590
|
var useProductCategoryTree = () => {
|
|
579
591
|
const query = useProductCategories();
|
|
580
592
|
const flatData = query.data ?? [];
|
|
@@ -895,7 +907,9 @@ var createQueryKeys = (prefix = ["woocommerce"]) => ({
|
|
|
895
907
|
list: (params) => [...prefix, "products", "list", params],
|
|
896
908
|
details: () => [...prefix, "products", "detail"],
|
|
897
909
|
detail: (id) => [...prefix, "products", "detail", id],
|
|
898
|
-
categories: () => [...prefix, "products", "categories"]
|
|
910
|
+
categories: () => [...prefix, "products", "categories"],
|
|
911
|
+
// Params are in the key, so each set of tag ids is cached apart.
|
|
912
|
+
tags: (params) => [...prefix, "products", "tags", params]
|
|
899
913
|
},
|
|
900
914
|
// Cart
|
|
901
915
|
cart: {
|
|
@@ -1740,6 +1754,8 @@ function useOrderView(input, options = {}) {
|
|
|
1740
1754
|
const storeContext = react.useContext(WooCommerceStoreContext);
|
|
1741
1755
|
const storeConfig = storeContext?.config;
|
|
1742
1756
|
const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
|
|
1757
|
+
const { imageSize = "thumbnail" } = options;
|
|
1758
|
+
const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
|
|
1743
1759
|
const { data: rawOrder, isLoading, error } = useOrder(input);
|
|
1744
1760
|
const order = react.useMemo(() => {
|
|
1745
1761
|
if (!rawOrder) return void 0;
|
|
@@ -1750,7 +1766,7 @@ function useOrderView(input, options = {}) {
|
|
|
1750
1766
|
quantity: item.quantity,
|
|
1751
1767
|
price: formatStoreApiPriceIntl(item.prices.price, currencyCode, localeTag),
|
|
1752
1768
|
total: formatStoreApiPriceIntl(item.totals.line_total, currencyCode, localeTag),
|
|
1753
|
-
imageUrl: item.images
|
|
1769
|
+
imageUrl: getProcessedImageUrl(item.images)
|
|
1754
1770
|
}));
|
|
1755
1771
|
const status = rawOrder.status;
|
|
1756
1772
|
return {
|
|
@@ -1765,7 +1781,7 @@ function useOrderView(input, options = {}) {
|
|
|
1765
1781
|
paymentMethod: rawOrder.payment_method ?? "",
|
|
1766
1782
|
raw: rawOrder
|
|
1767
1783
|
};
|
|
1768
|
-
}, [rawOrder, localeTag]);
|
|
1784
|
+
}, [rawOrder, localeTag, getProcessedImageUrl]);
|
|
1769
1785
|
return {
|
|
1770
1786
|
order,
|
|
1771
1787
|
isLoading,
|
|
@@ -1908,6 +1924,7 @@ exports.useProcessCheckout = useProcessCheckout;
|
|
|
1908
1924
|
exports.useProduct = useProduct;
|
|
1909
1925
|
exports.useProductCategories = useProductCategories;
|
|
1910
1926
|
exports.useProductCategoryTree = useProductCategoryTree;
|
|
1927
|
+
exports.useProductTags = useProductTags;
|
|
1911
1928
|
exports.useProductView = useProductView;
|
|
1912
1929
|
exports.useProducts = useProducts;
|
|
1913
1930
|
exports.useProductsFeed = useProductsFeed;
|