@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.
@@ -1,4 +1,4 @@
1
- export { A as AppliedCoupon, C as CartTotals, 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, 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-CVVP-Gph.cjs';
1
+ export { A as AppliedCoupon, C as CartTotals, Y as InfiniteQueryOptions, Z as MutationOptions, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, _ as QueryOptions, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, 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';
2
2
  export { Q as QueryKeys, p as createQueryKeys } from '../types-BDwpAWoN.cjs';
3
- import '@atomic-solutions/woocommerce-api-client';
4
3
  import '@tanstack/react-query';
4
+ import '@atomic-solutions/woocommerce-api-client';
@@ -1,4 +1,4 @@
1
- export { A as AppliedCoupon, C as CartTotals, 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, 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-BhXGpIcv.js';
1
+ export { A as AppliedCoupon, C as CartTotals, Y as InfiniteQueryOptions, Z as MutationOptions, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, _ as QueryOptions, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, 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';
2
2
  export { Q as QueryKeys, p as createQueryKeys } from '../types-BDwpAWoN.js';
3
- import '@atomic-solutions/woocommerce-api-client';
4
3
  import '@tanstack/react-query';
4
+ import '@atomic-solutions/woocommerce-api-client';
@@ -50,8 +50,7 @@ var useInfiniteWooQuery = ({
50
50
  queryFn,
51
51
  params,
52
52
  perPage = 10,
53
- staleTime = StaleTimes.infinite,
54
- enabled
53
+ options
55
54
  }) => {
56
55
  const query = useInfiniteQuery({
57
56
  queryKey,
@@ -63,8 +62,8 @@ var useInfiniteWooQuery = ({
63
62
  initialPageParam: 1,
64
63
  getNextPageParam: (lastPage) => lastPage.pagination.nextPage,
65
64
  getPreviousPageParam: (firstPage) => firstPage.pagination.prevPage,
66
- staleTime,
67
- enabled
65
+ staleTime: StaleTimes.infinite,
66
+ ...options
68
67
  });
69
68
  const flatData = query.data?.pages.flatMap((page) => page.data) ?? [];
70
69
  return {
@@ -75,41 +74,45 @@ var useInfiniteWooQuery = ({
75
74
  };
76
75
 
77
76
  // src/hooks/products.ts
78
- var useProducts = (params) => {
77
+ var useProducts = (params, options) => {
79
78
  const client = useWooCommerceClient();
80
79
  const queryKeys = useWooCommerceQueryKeys();
81
80
  return useQuery({
82
81
  queryKey: queryKeys.products.list(params),
83
82
  queryFn: () => client.products.list(params),
84
- staleTime: StaleTimes.products
83
+ staleTime: StaleTimes.products,
84
+ ...options
85
85
  });
86
86
  };
87
- var useInfiniteProducts = (params) => {
87
+ var useInfiniteProducts = (params, options) => {
88
88
  const client = useWooCommerceClient();
89
89
  const queryKeys = useWooCommerceQueryKeys();
90
90
  return useInfiniteWooQuery({
91
91
  queryKey: queryKeys.products.list(params),
92
92
  queryFn: (p) => client.products.list({ ...p, page: p.page ?? 1 }),
93
93
  params,
94
- perPage: params?.per_page ?? 10
94
+ perPage: params?.per_page ?? 10,
95
+ options
95
96
  });
96
97
  };
97
- var useProduct = (id) => {
98
+ var useProduct = (id, options) => {
98
99
  const client = useWooCommerceClient();
99
100
  const queryKeys = useWooCommerceQueryKeys();
100
101
  return useQuery({
101
102
  queryKey: queryKeys.products.detail(id),
102
103
  queryFn: () => client.products.get(id),
103
- staleTime: StaleTimes.product
104
+ staleTime: StaleTimes.product,
105
+ ...options
104
106
  });
105
107
  };
106
- var useProductCategories = () => {
108
+ var useProductCategories = (options) => {
107
109
  const client = useWooCommerceClient();
108
110
  const queryKeys = useWooCommerceQueryKeys();
109
111
  return useQuery({
110
112
  queryKey: queryKeys.products.categories(),
111
113
  queryFn: () => client.products.categories(),
112
- staleTime: StaleTimes.categories
114
+ staleTime: StaleTimes.categories,
115
+ ...options
113
116
  });
114
117
  };
115
118
  var groupBy = (fn, list) => {
@@ -164,13 +167,14 @@ function createErrorEvent(type, error) {
164
167
  }
165
168
 
166
169
  // src/hooks/cart.ts
167
- var useCart = () => {
170
+ var useCart = (options) => {
168
171
  const client = useWooCommerceClient();
169
172
  const queryKeys = useWooCommerceQueryKeys();
170
173
  const query = useQuery({
171
174
  queryKey: queryKeys.cart.details(),
172
175
  queryFn: () => client.cart.get(),
173
- staleTime: StaleTimes.cart
176
+ staleTime: StaleTimes.cart,
177
+ ...options
174
178
  });
175
179
  const cart = query.data;
176
180
  const isInCart = (productId) => {
@@ -401,13 +405,14 @@ var useSelectShippingRate = () => {
401
405
  }
402
406
  });
403
407
  };
404
- var useCheckout = () => {
408
+ var useCheckout = (options) => {
405
409
  const client = useWooCommerceClient();
406
410
  const queryKeys = useWooCommerceQueryKeys();
407
411
  return useQuery({
408
412
  queryKey: queryKeys.checkout.details(),
409
413
  queryFn: () => client.checkout.get(),
410
- staleTime: StaleTimes.checkout
414
+ staleTime: StaleTimes.checkout,
415
+ ...options
411
416
  });
412
417
  };
413
418
  var useProcessCheckout = () => {
@@ -440,13 +445,14 @@ var useProcessCheckout = () => {
440
445
  }
441
446
  });
442
447
  };
443
- var useOrder = (input) => {
448
+ var useOrder = (input, options) => {
444
449
  const client = useWooCommerceClient();
445
450
  const queryKeys = useWooCommerceQueryKeys();
446
451
  return useQuery({
447
452
  queryKey: queryKeys.orders.detail(input.id, input.billing_email, input.key),
448
453
  queryFn: () => client.orders.get(input),
449
- staleTime: StaleTimes.orders
454
+ staleTime: StaleTimes.orders,
455
+ ...options
450
456
  });
451
457
  };
452
458