@atomic-solutions/woocommerce-react 0.1.0 → 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/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as react from 'react';
2
2
  import react__default from 'react';
3
- import { WooCommerceClient } from '@atomic-solutions/woocommerce-utils';
4
- export { Address, BillingAddress, Cart, CartHeadersAdapter, CartItem, Checkout, Product, ProductCategory, ProductImage, ProductParams, StoreApiOrder, addressSchema, checkoutSchema } from '@atomic-solutions/woocommerce-utils';
5
- import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig } from './types-wgwJGLQ-.cjs';
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-wgwJGLQ-.cjs';
3
+ import { WooCommerceClient } from '@atomic-solutions/woocommerce-api-client';
4
+ export { Address, BillingAddress, Cart, CartHeadersAdapter, CartItem, Checkout, Product, ProductCategory, ProductImage, ProductParams, StoreApiOrder, addressSchema, checkoutSchema } from '@atomic-solutions/woocommerce-api-client';
5
+ import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig } from './types-BDwpAWoN.cjs';
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-DKVISMaw.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-CPpVyoLQ.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
- import { WooCommerceClient } from '@atomic-solutions/woocommerce-utils';
4
- export { Address, BillingAddress, Cart, CartHeadersAdapter, CartItem, Checkout, Product, ProductCategory, ProductImage, ProductParams, StoreApiOrder, addressSchema, checkoutSchema } from '@atomic-solutions/woocommerce-utils';
5
- import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig } from './types-wgwJGLQ-.js';
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-wgwJGLQ-.js';
3
+ import { WooCommerceClient } from '@atomic-solutions/woocommerce-api-client';
4
+ export { Address, BillingAddress, Cart, CartHeadersAdapter, CartItem, Checkout, Product, ProductCategory, ProductImage, ProductParams, StoreApiOrder, addressSchema, checkoutSchema } from '@atomic-solutions/woocommerce-api-client';
5
+ import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig } from './types-BDwpAWoN.js';
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-BVhiD2zV.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-BCMhB3fU.js';
9
9
  import 'react/jsx-runtime';
10
10
  import '@tanstack/react-query';
11
11
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createContext, useMemo, useState, useEffect, useRef, useCallback, useContext } from 'react';
2
2
  import { jsx, Fragment } from 'react/jsx-runtime';
3
- import { createClient, WooCommerceApiError } from '@atomic-solutions/woocommerce-utils';
4
- export { addressSchema, checkoutSchema } from '@atomic-solutions/woocommerce-utils';
3
+ import { createClient, WooCommerceApiError } from '@atomic-solutions/woocommerce-api-client';
4
+ export { addressSchema, checkoutSchema } from '@atomic-solutions/woocommerce-api-client';
5
5
  import { useQuery, useQueryClient, useMutation, useInfiniteQuery } from '@tanstack/react-query';
6
6
 
7
7
  // src/provider/WooCommerceProvider.tsx
@@ -487,8 +487,7 @@ var useInfiniteWooQuery = ({
487
487
  queryFn,
488
488
  params,
489
489
  perPage = 10,
490
- staleTime = StaleTimes.infinite,
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
- enabled
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