@atomic-solutions/woocommerce-react 0.1.1 → 0.2.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 +24 -18
- 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 +24 -18
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-BhXGpIcv.d.ts → index-BCMhB3fU.d.ts} +39 -35
- package/dist/{index-CVVP-Gph.d.cts → index-CPpVyoLQ.d.cts} +39 -35
- package/dist/index.cjs +24 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ export { Address, BillingAddress, Cart, CartHeadersAdapter, CartItem, Checkout,
|
|
|
5
5
|
import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig } from './types-BDwpAWoN.cjs';
|
|
6
6
|
export { C as CartCouponAppliedEvent, b as CartCouponRemovedEvent, c as CartCustomerUpdatedEvent, d as CartItemAddedEvent, e as CartItemRemovedEvent, f as CartItemUpdatedEvent, g as CartShippingSelectedEvent, h as CheckoutProcessedEvent, D as DEFAULT_STORE_CONFIG, O as OrderFetchedEvent, i as StoreConfig, j as StoreContextValue, k as StoreFeatures, l as StoreGuardrails, m as StoreTheme, n as WooCommerceEvent, o as WooCommerceEventType, p as createQueryKeys } from './types-BDwpAWoN.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 ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, m as getAllImageUrls, n as getImageUrl, o as getImageUrlOrPlaceholder, p as getPrimaryImage, q as getSizedImageUrl, r as preloadImage, s as preloadImages, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from './index-
|
|
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 ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, m as getAllImageUrls, n as getImageUrl, o as getImageUrlOrPlaceholder, p as getPrimaryImage, q as getSizedImageUrl, r as preloadImage, s as preloadImages, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from './index-CPpVyoLQ.cjs';
|
|
9
9
|
import 'react/jsx-runtime';
|
|
10
10
|
import '@tanstack/react-query';
|
|
11
11
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { Address, BillingAddress, Cart, CartHeadersAdapter, CartItem, Checkout,
|
|
|
5
5
|
import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig } from './types-BDwpAWoN.js';
|
|
6
6
|
export { C as CartCouponAppliedEvent, b as CartCouponRemovedEvent, c as CartCustomerUpdatedEvent, d as CartItemAddedEvent, e as CartItemRemovedEvent, f as CartItemUpdatedEvent, g as CartShippingSelectedEvent, h as CheckoutProcessedEvent, D as DEFAULT_STORE_CONFIG, O as OrderFetchedEvent, i as StoreConfig, j as StoreContextValue, k as StoreFeatures, l as StoreGuardrails, m as StoreTheme, n as WooCommerceEvent, o as WooCommerceEventType, p as createQueryKeys } from './types-BDwpAWoN.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 ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, m as getAllImageUrls, n as getImageUrl, o as getImageUrlOrPlaceholder, p as getPrimaryImage, q as getSizedImageUrl, r as preloadImage, s as preloadImages, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from './index-
|
|
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 ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, m as getAllImageUrls, n as getImageUrl, o as getImageUrlOrPlaceholder, p as getPrimaryImage, q as getSizedImageUrl, r as preloadImage, s as preloadImages, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from './index-BCMhB3fU.js';
|
|
9
9
|
import 'react/jsx-runtime';
|
|
10
10
|
import '@tanstack/react-query';
|
|
11
11
|
|
package/dist/index.js
CHANGED
|
@@ -487,8 +487,7 @@ var useInfiniteWooQuery = ({
|
|
|
487
487
|
queryFn,
|
|
488
488
|
params,
|
|
489
489
|
perPage = 10,
|
|
490
|
-
|
|
491
|
-
enabled
|
|
490
|
+
options
|
|
492
491
|
}) => {
|
|
493
492
|
const query = useInfiniteQuery({
|
|
494
493
|
queryKey,
|
|
@@ -500,8 +499,8 @@ var useInfiniteWooQuery = ({
|
|
|
500
499
|
initialPageParam: 1,
|
|
501
500
|
getNextPageParam: (lastPage) => lastPage.pagination.nextPage,
|
|
502
501
|
getPreviousPageParam: (firstPage) => firstPage.pagination.prevPage,
|
|
503
|
-
staleTime,
|
|
504
|
-
|
|
502
|
+
staleTime: StaleTimes.infinite,
|
|
503
|
+
...options
|
|
505
504
|
});
|
|
506
505
|
const flatData = query.data?.pages.flatMap((page) => page.data) ?? [];
|
|
507
506
|
return {
|
|
@@ -512,41 +511,45 @@ var useInfiniteWooQuery = ({
|
|
|
512
511
|
};
|
|
513
512
|
|
|
514
513
|
// src/hooks/products.ts
|
|
515
|
-
var useProducts = (params) => {
|
|
514
|
+
var useProducts = (params, options) => {
|
|
516
515
|
const client = useWooCommerceClient();
|
|
517
516
|
const queryKeys = useWooCommerceQueryKeys();
|
|
518
517
|
return useQuery({
|
|
519
518
|
queryKey: queryKeys.products.list(params),
|
|
520
519
|
queryFn: () => client.products.list(params),
|
|
521
|
-
staleTime: StaleTimes.products
|
|
520
|
+
staleTime: StaleTimes.products,
|
|
521
|
+
...options
|
|
522
522
|
});
|
|
523
523
|
};
|
|
524
|
-
var useInfiniteProducts = (params) => {
|
|
524
|
+
var useInfiniteProducts = (params, options) => {
|
|
525
525
|
const client = useWooCommerceClient();
|
|
526
526
|
const queryKeys = useWooCommerceQueryKeys();
|
|
527
527
|
return useInfiniteWooQuery({
|
|
528
528
|
queryKey: queryKeys.products.list(params),
|
|
529
529
|
queryFn: (p) => client.products.list({ ...p, page: p.page ?? 1 }),
|
|
530
530
|
params,
|
|
531
|
-
perPage: params?.per_page ?? 10
|
|
531
|
+
perPage: params?.per_page ?? 10,
|
|
532
|
+
options
|
|
532
533
|
});
|
|
533
534
|
};
|
|
534
|
-
var useProduct = (id) => {
|
|
535
|
+
var useProduct = (id, options) => {
|
|
535
536
|
const client = useWooCommerceClient();
|
|
536
537
|
const queryKeys = useWooCommerceQueryKeys();
|
|
537
538
|
return useQuery({
|
|
538
539
|
queryKey: queryKeys.products.detail(id),
|
|
539
540
|
queryFn: () => client.products.get(id),
|
|
540
|
-
staleTime: StaleTimes.product
|
|
541
|
+
staleTime: StaleTimes.product,
|
|
542
|
+
...options
|
|
541
543
|
});
|
|
542
544
|
};
|
|
543
|
-
var useProductCategories = () => {
|
|
545
|
+
var useProductCategories = (options) => {
|
|
544
546
|
const client = useWooCommerceClient();
|
|
545
547
|
const queryKeys = useWooCommerceQueryKeys();
|
|
546
548
|
return useQuery({
|
|
547
549
|
queryKey: queryKeys.products.categories(),
|
|
548
550
|
queryFn: () => client.products.categories(),
|
|
549
|
-
staleTime: StaleTimes.categories
|
|
551
|
+
staleTime: StaleTimes.categories,
|
|
552
|
+
...options
|
|
550
553
|
});
|
|
551
554
|
};
|
|
552
555
|
var groupBy = (fn, list) => {
|
|
@@ -597,13 +600,14 @@ function createErrorEvent(type, error) {
|
|
|
597
600
|
}
|
|
598
601
|
|
|
599
602
|
// src/hooks/cart.ts
|
|
600
|
-
var useCart = () => {
|
|
603
|
+
var useCart = (options) => {
|
|
601
604
|
const client = useWooCommerceClient();
|
|
602
605
|
const queryKeys = useWooCommerceQueryKeys();
|
|
603
606
|
const query = useQuery({
|
|
604
607
|
queryKey: queryKeys.cart.details(),
|
|
605
608
|
queryFn: () => client.cart.get(),
|
|
606
|
-
staleTime: StaleTimes.cart
|
|
609
|
+
staleTime: StaleTimes.cart,
|
|
610
|
+
...options
|
|
607
611
|
});
|
|
608
612
|
const cart = query.data;
|
|
609
613
|
const isInCart = (productId) => {
|
|
@@ -834,13 +838,14 @@ var useSelectShippingRate = () => {
|
|
|
834
838
|
}
|
|
835
839
|
});
|
|
836
840
|
};
|
|
837
|
-
var useCheckout = () => {
|
|
841
|
+
var useCheckout = (options) => {
|
|
838
842
|
const client = useWooCommerceClient();
|
|
839
843
|
const queryKeys = useWooCommerceQueryKeys();
|
|
840
844
|
return useQuery({
|
|
841
845
|
queryKey: queryKeys.checkout.details(),
|
|
842
846
|
queryFn: () => client.checkout.get(),
|
|
843
|
-
staleTime: StaleTimes.checkout
|
|
847
|
+
staleTime: StaleTimes.checkout,
|
|
848
|
+
...options
|
|
844
849
|
});
|
|
845
850
|
};
|
|
846
851
|
var useProcessCheckout = () => {
|
|
@@ -873,13 +878,14 @@ var useProcessCheckout = () => {
|
|
|
873
878
|
}
|
|
874
879
|
});
|
|
875
880
|
};
|
|
876
|
-
var useOrder = (input) => {
|
|
881
|
+
var useOrder = (input, options) => {
|
|
877
882
|
const client = useWooCommerceClient();
|
|
878
883
|
const queryKeys = useWooCommerceQueryKeys();
|
|
879
884
|
return useQuery({
|
|
880
885
|
queryKey: queryKeys.orders.detail(input.id, input.billing_email, input.key),
|
|
881
886
|
queryFn: () => client.orders.get(input),
|
|
882
|
-
staleTime: StaleTimes.orders
|
|
887
|
+
staleTime: StaleTimes.orders,
|
|
888
|
+
...options
|
|
883
889
|
});
|
|
884
890
|
};
|
|
885
891
|
|