@simpleapps-com/augur-hooks 1.0.8 → 1.0.10

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
- import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, S as SearchSuggestionsResponse, a as SearchSuggestion, A as AugurCallbacks, b as AugurApiClient, c as PersistenceConfig } from './customer-quotes-Bdeo_I1q.cjs';
2
- export { d as AugurHooksProvider, e as BatchQueryConfig, f as executeBatchQuery, g as getBatchInvMastDocKey, h as getBatchInvMastDocOptions, i as getCartPricingQueryOptions, j as getCategoryItemsInfiniteKey, k as getCategoryItemsInfiniteOptions, l as getCustomerInvoiceDetailKey, m as getCustomerInvoicesKey, n as getCustomerOrderDetailKey, o as getCustomerOrdersKey, p as getCustomerQuoteDetailKey, q as getCustomerQuotesKey, r as getInvMastDocKey, s as getInvMastDocOptions, t as getInvMastKey, u as getInvMastOptions, v as getInvMastStockKey, w as getInvMastStockOptions, x as getItemAttributesKey, y as getItemAttributesOptions, z as getItemCategoryKey, C as getItemCategoryOptions, D as getItemDetailsKey, E as getItemDetailsOptions, F as getItemPriceKey, H as getItemPriceOptions, I as getItemSearchInfiniteKey, J as getItemSearchInfiniteOptions, K as getJoomlaContentKey, L as getJoomlaContentListKey, M as getJoomlaContentListOptions, N as getJoomlaContentOptions, O as getJoomlaMenuDocKey, Q as getJoomlaMenuDocOptions, R as getJoomlaMenuKey, T as getJoomlaMenuOptions, U as getProductCategoryKey, V as getProductCategoryOptions, W as getProductSearchKey, X as getProductSearchOptions, Y as getSearchSuggestionsKey, Z as getSearchSuggestionsOptions, _ as useAugurApi, $ as useAugurApiOptional, a0 as useAugurAuth, a1 as useAugurCache, a2 as useAugurOptions, a3 as useAugurSite } from './customer-quotes-Bdeo_I1q.cjs';
1
+ import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, S as SearchSuggestionsResponse, a as SearchSuggestion, A as AugurCallbacks, b as AugurApiClient, c as PersistenceConfig } from './customer-quotes-DIpZNjT1.cjs';
2
+ export { d as AugurHooksProvider, e as BatchQueryConfig, f as executeBatchQuery, g as getBatchInvMastDocKey, h as getBatchInvMastDocOptions, i as getCartPricingQueryOptions, j as getCategoryItemsInfiniteKey, k as getCategoryItemsInfiniteOptions, l as getCustomerInvoiceDetailKey, m as getCustomerInvoicesKey, n as getCustomerOrderDetailKey, o as getCustomerOrdersKey, p as getCustomerQuoteDetailKey, q as getCustomerQuotesKey, r as getInvMastDocKey, s as getInvMastDocOptions, t as getInvMastKey, u as getInvMastOptions, v as getInvMastStockKey, w as getInvMastStockOptions, x as getItemAttributesKey, y as getItemAttributesOptions, z as getItemCategoryKey, C as getItemCategoryOptions, D as getItemDetailsKey, E as getItemDetailsOptions, F as getItemPriceKey, H as getItemPriceOptions, I as getItemSearchInfiniteKey, J as getItemSearchInfiniteOptions, K as getJoomlaContentKey, L as getJoomlaContentListKey, M as getJoomlaContentListOptions, N as getJoomlaContentOptions, O as getJoomlaMenuDocKey, Q as getJoomlaMenuDocOptions, R as getJoomlaMenuKey, T as getJoomlaMenuOptions, U as getProductCategoryKey, V as getProductCategoryOptions, W as getProductSearchKey, X as getProductSearchOptions, Y as getSearchSuggestionsKey, Z as getSearchSuggestionsOptions, _ as getStockKey, $ as getStockOptions, a0 as useAugurApi, a1 as useAugurApiOptional, a2 as useAugurAuth, a3 as useAugurCache, a4 as useAugurOptions, a5 as useAugurSite } from './customer-quotes-DIpZNjT1.cjs';
3
3
  import { InfiniteScrollPage, CacheConfig, AugurAuthContext } from '@simpleapps-com/augur-core';
4
4
  export { AugurAuthContext, AugurSiteConfig, AugurSiteDefaults, AugurSiteFormatting, CacheConfig, CacheProvider, CacheTierConfig, DeepQueryOptions, EdgeCacheValue, InfiniteScrollPage, ProxyMutationOptions, ProxyQueryOptions } from '@simpleapps-com/augur-core';
5
5
  import * as zustand from 'zustand';
6
6
  import * as _simpleapps_com_augur_utils from '@simpleapps-com/augur-utils';
7
- import { TCartLine, TItemsFilters, TPriceData, TInvMastDoc, TCategory, TItemDetails, TAttribute, TJoomlaContent, TJoomlaContentFilters, MenuItem, TMenuFilters, ImageConfig, ImageUrlOptions } from '@simpleapps-com/augur-utils';
8
- export { DerivePriceInput, DerivedPrice } from '@simpleapps-com/augur-utils';
7
+ import { TCartLine, TItemsFilters, TPriceData, TInvMastDoc, TCategory, TItemDetails, TStock, TAttribute, TJoomlaContent, TJoomlaContentFilters, MenuItem, TMenuFilters, ImageConfig, ImageUrlOptions } from '@simpleapps-com/augur-utils';
8
+ export { DerivePriceInput, DerivedPrice, ResolveStockInput, ResolvedStock } from '@simpleapps-com/augur-utils';
9
9
  import * as _tanstack_react_query from '@tanstack/react-query';
10
10
  import { QueryKey } from '@tanstack/react-query';
11
11
  import { ReactNode, createElement } from 'react';
@@ -13,15 +13,23 @@ import { u as useImageWithFallback } from './use-image-with-fallback-DgmtrGZU.cj
13
13
  import * as _tanstack_react_query_persist_client from '@tanstack/react-query-persist-client';
14
14
  import 'react/jsx-runtime';
15
15
 
16
+ /** Internal state shape for the cart Zustand store. */
16
17
  interface CartState {
18
+ /** P21 cart header UID; `undefined` when no cart exists. */
17
19
  cartHdrUid: number | string | undefined;
20
+ /** Current line items in the cart. */
18
21
  cartLines: TCartLine[];
22
+ /** Sum of `quantity` across all cart lines (auto-computed by `setCartLines`). */
19
23
  cartQuantityTotal: number;
24
+ /** Number of distinct line items (auto-computed by `setCartLines`). */
20
25
  cartLineCount: number;
21
26
  setCartHdrUid: (cartHdrUid: number | string | undefined) => void;
27
+ /** Replace all cart lines. Auto-recomputes `cartQuantityTotal` and `cartLineCount`. */
22
28
  setCartLines: (cartLines: TCartLine[]) => void;
29
+ /** Reset the cart to its empty initial state. */
23
30
  clearCart: () => void;
24
31
  }
32
+ /** Zustand store for cart state. Prefer the individual selector hooks below for optimal re-renders. */
25
33
  declare const useCartStore: zustand.UseBoundStore<Omit<zustand.StoreApi<CartState>, "setState" | "devtools"> & {
26
34
  setState(partial: CartState | Partial<CartState> | ((state: CartState) => CartState | Partial<CartState>), replace?: false | undefined, action?: (string | {
27
35
  [x: string]: unknown;
@@ -39,19 +47,31 @@ declare const useCartStore: zustand.UseBoundStore<Omit<zustand.StoreApi<CartStat
39
47
  cleanup: () => void;
40
48
  };
41
49
  }>;
50
+ /** Select the current cart header UID. */
42
51
  declare const useCartHdrUid: () => string | number | undefined;
52
+ /** Select the current cart line items array. */
43
53
  declare const useCartLines: () => TCartLine[];
54
+ /** Select the total quantity summed across all cart lines. */
44
55
  declare const useCartQuantityTotal: () => number;
56
+ /** Select the number of distinct line items in the cart. */
45
57
  declare const useCartLineCount: () => number;
58
+ /** Get the `setCartHdrUid` action (stable reference). */
46
59
  declare const useSetCartHdrUid: () => (cartHdrUid: number | string | undefined) => void;
60
+ /** Get the `setCartLines` action (stable reference). Also recomputes totals. */
47
61
  declare const useSetCartLines: () => (cartLines: TCartLine[]) => void;
62
+ /** Get the `clearCart` action (stable reference). */
48
63
  declare const useClearCart: () => () => void;
49
64
 
65
+ /** Zustand state shape for item list filtering, sorting, and pagination. */
50
66
  interface ItemsFiltersState {
67
+ /** Snapshot of the initial defaults; useful for "reset filters" UIs. */
51
68
  initialFiltersState: TItemsFilters;
69
+ /** Current active filter/sort/pagination state. */
52
70
  itemsFilters: TItemsFilters;
71
+ /** Replace the entire filter state. */
53
72
  setItemsFilters: (itemFilters: TItemsFilters) => void;
54
73
  }
74
+ /** Zustand store for item list filters, sorting, and pagination state. */
55
75
  declare const useItemFiltersStore: zustand.UseBoundStore<Omit<zustand.StoreApi<ItemsFiltersState>, "setState" | "devtools"> & {
56
76
  setState(partial: ItemsFiltersState | Partial<ItemsFiltersState> | ((state: ItemsFiltersState) => ItemsFiltersState | Partial<ItemsFiltersState>), replace?: false | undefined, action?: (string | {
57
77
  [x: string]: unknown;
@@ -76,13 +96,33 @@ declare const useItemFiltersStore: zustand.UseBoundStore<Omit<zustand.StoreApi<I
76
96
  */
77
97
  declare function useDebounce<T>(value: T, delay?: number): T;
78
98
 
99
+ /** Options for configuring the useFormatPrice hook. */
100
+ interface UseFormatPriceOptions {
101
+ /** BCP 47 locale tag. Overrides site.formatting.locale. */
102
+ locale?: string;
103
+ /** ISO 4217 currency code. Overrides site.formatting.currency. */
104
+ currency?: string;
105
+ /** Decimal digits. Overrides site.formatting.precision. */
106
+ precision?: number;
107
+ /** Label returned when the effective value is 0 (e.g. "Call for Price"). */
108
+ zeroLabel?: string;
109
+ }
110
+ /** Per-call options passed to the returned formatPrice function. */
111
+ interface FormatPriceCallOptions {
112
+ /** Override decimal digits for this call only. */
113
+ precision?: number;
114
+ /** Multiply the value by this quantity before formatting. */
115
+ quantity?: number;
116
+ }
79
117
  /**
80
118
  * Hook that returns a price formatter.
81
119
  * Reads defaults from site config when params are omitted.
82
- * Explicit params override site config.
120
+ *
121
+ * Supports both the new options-object signature and the legacy positional
122
+ * `(locale?, currency?)` signature for backwards compatibility.
83
123
  */
84
- declare function useFormatPrice(locale?: string, currency?: string): {
85
- formatPrice: (price: number) => string;
124
+ declare function useFormatPrice(optionsOrLocale?: UseFormatPriceOptions | string, legacyCurrency?: string): {
125
+ formatPrice: (price: number, callOptions?: FormatPriceCallOptions) => string;
86
126
  };
87
127
 
88
128
  interface UseItemPriceOptions {
@@ -102,7 +142,7 @@ interface UseItemPriceOptions {
102
142
  * });
103
143
  * ```
104
144
  */
105
- declare function useItemPrice(itemId: string | undefined, customerId: string | number | undefined, quantity?: number, options?: UseItemPriceOptions): {
145
+ declare function useItemPrice(itemId: string | undefined, customerId?: string | number, quantity?: number, options?: UseItemPriceOptions): {
106
146
  derived: _simpleapps_com_augur_utils.DerivedPrice | null;
107
147
  data: TPriceData;
108
148
  error: Error;
@@ -330,6 +370,36 @@ declare function useInvMastStock(invMastUid: number | string, options?: UseInvMa
330
370
  error: Error | null;
331
371
  };
332
372
 
373
+ interface UseStockOptions {
374
+ enabled?: boolean;
375
+ /** Override the default queryFn (e.g. with a cached server action). */
376
+ queryFn?: () => Promise<TStock>;
377
+ /** Company key to extract stock for a specific company. */
378
+ companyKey?: string;
379
+ /** Whether to round the quantity. */
380
+ round?: boolean;
381
+ /** Threshold below which stock is considered "low". */
382
+ lowStockThreshold?: number;
383
+ /** Whether to include the quantity in the resolved output. */
384
+ showQuantity?: boolean;
385
+ }
386
+ /**
387
+ * Fetches full TStock data and resolves it into a normalized stock object.
388
+ *
389
+ * Pass `options.queryFn` to override with a cached server action:
390
+ * ```ts
391
+ * useStock(invMastUid, {
392
+ * queryFn: () => getStockCached(invMastUid),
393
+ * });
394
+ * ```
395
+ */
396
+ declare function useStock(invMastUid: number | string, options?: UseStockOptions): {
397
+ stock: TStock | null;
398
+ resolved: _simpleapps_com_augur_utils.ResolvedStock | null;
399
+ loading: boolean;
400
+ error: Error | null;
401
+ };
402
+
333
403
  interface UseBatchInvMastDocOptions {
334
404
  enabled?: boolean;
335
405
  includePricing?: "Y" | "N";
@@ -707,7 +777,7 @@ interface UseCustomerOrdersOptions {
707
777
  queryFn?: () => Promise<CustomerListResult$2>;
708
778
  }
709
779
  /** @deprecated Use `useQuery(q.customers.customer.orders.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
710
- declare function useCustomerOrders(customerId: number | string | undefined, params?: Record<string, unknown>, options?: UseCustomerOrdersOptions): {
780
+ declare function useCustomerOrders(customerId?: number | string, params?: Record<string, unknown>, options?: UseCustomerOrdersOptions): {
711
781
  orders: unknown[];
712
782
  total: number;
713
783
  isLoading: boolean;
@@ -718,7 +788,7 @@ interface UseOrderDetailOptions {
718
788
  queryFn?: () => Promise<unknown>;
719
789
  }
720
790
  /** @deprecated Use `useQuery(q.customers.customer.orders.get(custId, orderNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
721
- declare function useOrderDetail(customerId: number | string | undefined, orderId: number | string | undefined, options?: UseOrderDetailOptions): {
791
+ declare function useOrderDetail(customerId?: number | string, orderId?: number | string, options?: UseOrderDetailOptions): {
722
792
  order: {} | null;
723
793
  isLoading: boolean;
724
794
  error: Error | null;
@@ -733,7 +803,7 @@ interface UseCustomerInvoicesOptions {
733
803
  queryFn?: () => Promise<CustomerListResult$1>;
734
804
  }
735
805
  /** @deprecated Use `useQuery(q.customers.customer.invoices.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
736
- declare function useCustomerInvoices(customerId: number | string | undefined, params?: Record<string, unknown>, options?: UseCustomerInvoicesOptions): {
806
+ declare function useCustomerInvoices(customerId?: number | string, params?: Record<string, unknown>, options?: UseCustomerInvoicesOptions): {
737
807
  invoices: unknown[];
738
808
  total: number;
739
809
  isLoading: boolean;
@@ -744,7 +814,7 @@ interface UseInvoiceDetailOptions {
744
814
  queryFn?: () => Promise<unknown>;
745
815
  }
746
816
  /** @deprecated Use `useQuery(q.customers.customer.invoices.get(custId, invoiceNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
747
- declare function useInvoiceDetail(customerId: number | string | undefined, invoiceNo: number | string | undefined, options?: UseInvoiceDetailOptions): {
817
+ declare function useInvoiceDetail(customerId?: number | string, invoiceNo?: number | string, options?: UseInvoiceDetailOptions): {
748
818
  invoice: {} | null;
749
819
  isLoading: boolean;
750
820
  error: Error | null;
@@ -759,7 +829,7 @@ interface UseCustomerQuotesOptions {
759
829
  queryFn?: () => Promise<CustomerListResult>;
760
830
  }
761
831
  /** @deprecated Use `useQuery(q.customers.customer.quotes.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
762
- declare function useCustomerQuotes(customerId: number | string | undefined, params?: Record<string, unknown>, options?: UseCustomerQuotesOptions): {
832
+ declare function useCustomerQuotes(customerId?: number | string, params?: Record<string, unknown>, options?: UseCustomerQuotesOptions): {
763
833
  quotes: unknown[];
764
834
  total: number;
765
835
  isLoading: boolean;
@@ -770,7 +840,7 @@ interface UseQuoteDetailOptions {
770
840
  queryFn?: () => Promise<unknown>;
771
841
  }
772
842
  /** @deprecated Use `useQuery(q.customers.customer.quotes.get(custId, quoteNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
773
- declare function useQuoteDetail(customerId: number | string | undefined, quoteNo: number | string | undefined, options?: UseQuoteDetailOptions): {
843
+ declare function useQuoteDetail(customerId?: number | string, quoteNo?: number | string, options?: UseQuoteDetailOptions): {
774
844
  quote: {} | null;
775
845
  isLoading: boolean;
776
846
  error: Error | null;
@@ -912,4 +982,4 @@ declare function useAugurPersistence(config: PersistenceConfig): {
912
982
  };
913
983
  };
914
984
 
915
- export { AugurApiClient, AugurCallbacks, BatchInvMastDocParam, type CartActionCallbacks, type CartInitCallbacks, type CartPriceData, type CartPricingResult, type CartSessionInfo, type CreateSiteHooksConfig, GetItemCategoryApiOptions, PageData, PersistenceConfig, SearchSuggestion, SearchSuggestionsResponse, createSiteHooks, useAugurPersistence, useBatchInvMastDoc, useCartActions, useCartHdrUid, useCartInitialization, useCartLineCount, useCartLines, useCartPricing, useCartQuantityTotal, useCartStore, useCategoryItemsInfinite, useClearCart, useCustomerInvoices, useCustomerOrders, useCustomerQuotes, useDebounce, useFormatPrice, useInvMast, useInvMastDoc, useInvMastStock, useInvoiceDetail, useItemAttributes, useItemCategory, useItemDetails, useItemFiltersStore, useItemPrice, useItemSearchInfinite, useJoomlaContent, useJoomlaContentList, useJoomlaMenu, useJoomlaMenuDoc, useOrderDetail, usePaginationPrefetch, useProductCategory, useProductSearch, useQuoteDetail, useSearchSuggestions, useSetCartHdrUid, useSetCartLines };
985
+ export { AugurApiClient, AugurCallbacks, BatchInvMastDocParam, type CartActionCallbacks, type CartInitCallbacks, type CartPriceData, type CartPricingResult, type CartSessionInfo, type CreateSiteHooksConfig, type FormatPriceCallOptions, GetItemCategoryApiOptions, PageData, PersistenceConfig, SearchSuggestion, SearchSuggestionsResponse, type UseFormatPriceOptions, type UseStockOptions, createSiteHooks, useAugurPersistence, useBatchInvMastDoc, useCartActions, useCartHdrUid, useCartInitialization, useCartLineCount, useCartLines, useCartPricing, useCartQuantityTotal, useCartStore, useCategoryItemsInfinite, useClearCart, useCustomerInvoices, useCustomerOrders, useCustomerQuotes, useDebounce, useFormatPrice, useInvMast, useInvMastDoc, useInvMastStock, useInvoiceDetail, useItemAttributes, useItemCategory, useItemDetails, useItemFiltersStore, useItemPrice, useItemSearchInfinite, useJoomlaContent, useJoomlaContentList, useJoomlaMenu, useJoomlaMenuDoc, useOrderDetail, usePaginationPrefetch, useProductCategory, useProductSearch, useQuoteDetail, useSearchSuggestions, useSetCartHdrUid, useSetCartLines, useStock };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, S as SearchSuggestionsResponse, a as SearchSuggestion, A as AugurCallbacks, b as AugurApiClient, c as PersistenceConfig } from './customer-quotes-Bdeo_I1q.js';
2
- export { d as AugurHooksProvider, e as BatchQueryConfig, f as executeBatchQuery, g as getBatchInvMastDocKey, h as getBatchInvMastDocOptions, i as getCartPricingQueryOptions, j as getCategoryItemsInfiniteKey, k as getCategoryItemsInfiniteOptions, l as getCustomerInvoiceDetailKey, m as getCustomerInvoicesKey, n as getCustomerOrderDetailKey, o as getCustomerOrdersKey, p as getCustomerQuoteDetailKey, q as getCustomerQuotesKey, r as getInvMastDocKey, s as getInvMastDocOptions, t as getInvMastKey, u as getInvMastOptions, v as getInvMastStockKey, w as getInvMastStockOptions, x as getItemAttributesKey, y as getItemAttributesOptions, z as getItemCategoryKey, C as getItemCategoryOptions, D as getItemDetailsKey, E as getItemDetailsOptions, F as getItemPriceKey, H as getItemPriceOptions, I as getItemSearchInfiniteKey, J as getItemSearchInfiniteOptions, K as getJoomlaContentKey, L as getJoomlaContentListKey, M as getJoomlaContentListOptions, N as getJoomlaContentOptions, O as getJoomlaMenuDocKey, Q as getJoomlaMenuDocOptions, R as getJoomlaMenuKey, T as getJoomlaMenuOptions, U as getProductCategoryKey, V as getProductCategoryOptions, W as getProductSearchKey, X as getProductSearchOptions, Y as getSearchSuggestionsKey, Z as getSearchSuggestionsOptions, _ as useAugurApi, $ as useAugurApiOptional, a0 as useAugurAuth, a1 as useAugurCache, a2 as useAugurOptions, a3 as useAugurSite } from './customer-quotes-Bdeo_I1q.js';
1
+ import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, S as SearchSuggestionsResponse, a as SearchSuggestion, A as AugurCallbacks, b as AugurApiClient, c as PersistenceConfig } from './customer-quotes-DIpZNjT1.js';
2
+ export { d as AugurHooksProvider, e as BatchQueryConfig, f as executeBatchQuery, g as getBatchInvMastDocKey, h as getBatchInvMastDocOptions, i as getCartPricingQueryOptions, j as getCategoryItemsInfiniteKey, k as getCategoryItemsInfiniteOptions, l as getCustomerInvoiceDetailKey, m as getCustomerInvoicesKey, n as getCustomerOrderDetailKey, o as getCustomerOrdersKey, p as getCustomerQuoteDetailKey, q as getCustomerQuotesKey, r as getInvMastDocKey, s as getInvMastDocOptions, t as getInvMastKey, u as getInvMastOptions, v as getInvMastStockKey, w as getInvMastStockOptions, x as getItemAttributesKey, y as getItemAttributesOptions, z as getItemCategoryKey, C as getItemCategoryOptions, D as getItemDetailsKey, E as getItemDetailsOptions, F as getItemPriceKey, H as getItemPriceOptions, I as getItemSearchInfiniteKey, J as getItemSearchInfiniteOptions, K as getJoomlaContentKey, L as getJoomlaContentListKey, M as getJoomlaContentListOptions, N as getJoomlaContentOptions, O as getJoomlaMenuDocKey, Q as getJoomlaMenuDocOptions, R as getJoomlaMenuKey, T as getJoomlaMenuOptions, U as getProductCategoryKey, V as getProductCategoryOptions, W as getProductSearchKey, X as getProductSearchOptions, Y as getSearchSuggestionsKey, Z as getSearchSuggestionsOptions, _ as getStockKey, $ as getStockOptions, a0 as useAugurApi, a1 as useAugurApiOptional, a2 as useAugurAuth, a3 as useAugurCache, a4 as useAugurOptions, a5 as useAugurSite } from './customer-quotes-DIpZNjT1.js';
3
3
  import { InfiniteScrollPage, CacheConfig, AugurAuthContext } from '@simpleapps-com/augur-core';
4
4
  export { AugurAuthContext, AugurSiteConfig, AugurSiteDefaults, AugurSiteFormatting, CacheConfig, CacheProvider, CacheTierConfig, DeepQueryOptions, EdgeCacheValue, InfiniteScrollPage, ProxyMutationOptions, ProxyQueryOptions } from '@simpleapps-com/augur-core';
5
5
  import * as zustand from 'zustand';
6
6
  import * as _simpleapps_com_augur_utils from '@simpleapps-com/augur-utils';
7
- import { TCartLine, TItemsFilters, TPriceData, TInvMastDoc, TCategory, TItemDetails, TAttribute, TJoomlaContent, TJoomlaContentFilters, MenuItem, TMenuFilters, ImageConfig, ImageUrlOptions } from '@simpleapps-com/augur-utils';
8
- export { DerivePriceInput, DerivedPrice } from '@simpleapps-com/augur-utils';
7
+ import { TCartLine, TItemsFilters, TPriceData, TInvMastDoc, TCategory, TItemDetails, TStock, TAttribute, TJoomlaContent, TJoomlaContentFilters, MenuItem, TMenuFilters, ImageConfig, ImageUrlOptions } from '@simpleapps-com/augur-utils';
8
+ export { DerivePriceInput, DerivedPrice, ResolveStockInput, ResolvedStock } from '@simpleapps-com/augur-utils';
9
9
  import * as _tanstack_react_query from '@tanstack/react-query';
10
10
  import { QueryKey } from '@tanstack/react-query';
11
11
  import { ReactNode, createElement } from 'react';
@@ -13,15 +13,23 @@ import { u as useImageWithFallback } from './use-image-with-fallback-DgmtrGZU.js
13
13
  import * as _tanstack_react_query_persist_client from '@tanstack/react-query-persist-client';
14
14
  import 'react/jsx-runtime';
15
15
 
16
+ /** Internal state shape for the cart Zustand store. */
16
17
  interface CartState {
18
+ /** P21 cart header UID; `undefined` when no cart exists. */
17
19
  cartHdrUid: number | string | undefined;
20
+ /** Current line items in the cart. */
18
21
  cartLines: TCartLine[];
22
+ /** Sum of `quantity` across all cart lines (auto-computed by `setCartLines`). */
19
23
  cartQuantityTotal: number;
24
+ /** Number of distinct line items (auto-computed by `setCartLines`). */
20
25
  cartLineCount: number;
21
26
  setCartHdrUid: (cartHdrUid: number | string | undefined) => void;
27
+ /** Replace all cart lines. Auto-recomputes `cartQuantityTotal` and `cartLineCount`. */
22
28
  setCartLines: (cartLines: TCartLine[]) => void;
29
+ /** Reset the cart to its empty initial state. */
23
30
  clearCart: () => void;
24
31
  }
32
+ /** Zustand store for cart state. Prefer the individual selector hooks below for optimal re-renders. */
25
33
  declare const useCartStore: zustand.UseBoundStore<Omit<zustand.StoreApi<CartState>, "setState" | "devtools"> & {
26
34
  setState(partial: CartState | Partial<CartState> | ((state: CartState) => CartState | Partial<CartState>), replace?: false | undefined, action?: (string | {
27
35
  [x: string]: unknown;
@@ -39,19 +47,31 @@ declare const useCartStore: zustand.UseBoundStore<Omit<zustand.StoreApi<CartStat
39
47
  cleanup: () => void;
40
48
  };
41
49
  }>;
50
+ /** Select the current cart header UID. */
42
51
  declare const useCartHdrUid: () => string | number | undefined;
52
+ /** Select the current cart line items array. */
43
53
  declare const useCartLines: () => TCartLine[];
54
+ /** Select the total quantity summed across all cart lines. */
44
55
  declare const useCartQuantityTotal: () => number;
56
+ /** Select the number of distinct line items in the cart. */
45
57
  declare const useCartLineCount: () => number;
58
+ /** Get the `setCartHdrUid` action (stable reference). */
46
59
  declare const useSetCartHdrUid: () => (cartHdrUid: number | string | undefined) => void;
60
+ /** Get the `setCartLines` action (stable reference). Also recomputes totals. */
47
61
  declare const useSetCartLines: () => (cartLines: TCartLine[]) => void;
62
+ /** Get the `clearCart` action (stable reference). */
48
63
  declare const useClearCart: () => () => void;
49
64
 
65
+ /** Zustand state shape for item list filtering, sorting, and pagination. */
50
66
  interface ItemsFiltersState {
67
+ /** Snapshot of the initial defaults; useful for "reset filters" UIs. */
51
68
  initialFiltersState: TItemsFilters;
69
+ /** Current active filter/sort/pagination state. */
52
70
  itemsFilters: TItemsFilters;
71
+ /** Replace the entire filter state. */
53
72
  setItemsFilters: (itemFilters: TItemsFilters) => void;
54
73
  }
74
+ /** Zustand store for item list filters, sorting, and pagination state. */
55
75
  declare const useItemFiltersStore: zustand.UseBoundStore<Omit<zustand.StoreApi<ItemsFiltersState>, "setState" | "devtools"> & {
56
76
  setState(partial: ItemsFiltersState | Partial<ItemsFiltersState> | ((state: ItemsFiltersState) => ItemsFiltersState | Partial<ItemsFiltersState>), replace?: false | undefined, action?: (string | {
57
77
  [x: string]: unknown;
@@ -76,13 +96,33 @@ declare const useItemFiltersStore: zustand.UseBoundStore<Omit<zustand.StoreApi<I
76
96
  */
77
97
  declare function useDebounce<T>(value: T, delay?: number): T;
78
98
 
99
+ /** Options for configuring the useFormatPrice hook. */
100
+ interface UseFormatPriceOptions {
101
+ /** BCP 47 locale tag. Overrides site.formatting.locale. */
102
+ locale?: string;
103
+ /** ISO 4217 currency code. Overrides site.formatting.currency. */
104
+ currency?: string;
105
+ /** Decimal digits. Overrides site.formatting.precision. */
106
+ precision?: number;
107
+ /** Label returned when the effective value is 0 (e.g. "Call for Price"). */
108
+ zeroLabel?: string;
109
+ }
110
+ /** Per-call options passed to the returned formatPrice function. */
111
+ interface FormatPriceCallOptions {
112
+ /** Override decimal digits for this call only. */
113
+ precision?: number;
114
+ /** Multiply the value by this quantity before formatting. */
115
+ quantity?: number;
116
+ }
79
117
  /**
80
118
  * Hook that returns a price formatter.
81
119
  * Reads defaults from site config when params are omitted.
82
- * Explicit params override site config.
120
+ *
121
+ * Supports both the new options-object signature and the legacy positional
122
+ * `(locale?, currency?)` signature for backwards compatibility.
83
123
  */
84
- declare function useFormatPrice(locale?: string, currency?: string): {
85
- formatPrice: (price: number) => string;
124
+ declare function useFormatPrice(optionsOrLocale?: UseFormatPriceOptions | string, legacyCurrency?: string): {
125
+ formatPrice: (price: number, callOptions?: FormatPriceCallOptions) => string;
86
126
  };
87
127
 
88
128
  interface UseItemPriceOptions {
@@ -102,7 +142,7 @@ interface UseItemPriceOptions {
102
142
  * });
103
143
  * ```
104
144
  */
105
- declare function useItemPrice(itemId: string | undefined, customerId: string | number | undefined, quantity?: number, options?: UseItemPriceOptions): {
145
+ declare function useItemPrice(itemId: string | undefined, customerId?: string | number, quantity?: number, options?: UseItemPriceOptions): {
106
146
  derived: _simpleapps_com_augur_utils.DerivedPrice | null;
107
147
  data: TPriceData;
108
148
  error: Error;
@@ -330,6 +370,36 @@ declare function useInvMastStock(invMastUid: number | string, options?: UseInvMa
330
370
  error: Error | null;
331
371
  };
332
372
 
373
+ interface UseStockOptions {
374
+ enabled?: boolean;
375
+ /** Override the default queryFn (e.g. with a cached server action). */
376
+ queryFn?: () => Promise<TStock>;
377
+ /** Company key to extract stock for a specific company. */
378
+ companyKey?: string;
379
+ /** Whether to round the quantity. */
380
+ round?: boolean;
381
+ /** Threshold below which stock is considered "low". */
382
+ lowStockThreshold?: number;
383
+ /** Whether to include the quantity in the resolved output. */
384
+ showQuantity?: boolean;
385
+ }
386
+ /**
387
+ * Fetches full TStock data and resolves it into a normalized stock object.
388
+ *
389
+ * Pass `options.queryFn` to override with a cached server action:
390
+ * ```ts
391
+ * useStock(invMastUid, {
392
+ * queryFn: () => getStockCached(invMastUid),
393
+ * });
394
+ * ```
395
+ */
396
+ declare function useStock(invMastUid: number | string, options?: UseStockOptions): {
397
+ stock: TStock | null;
398
+ resolved: _simpleapps_com_augur_utils.ResolvedStock | null;
399
+ loading: boolean;
400
+ error: Error | null;
401
+ };
402
+
333
403
  interface UseBatchInvMastDocOptions {
334
404
  enabled?: boolean;
335
405
  includePricing?: "Y" | "N";
@@ -707,7 +777,7 @@ interface UseCustomerOrdersOptions {
707
777
  queryFn?: () => Promise<CustomerListResult$2>;
708
778
  }
709
779
  /** @deprecated Use `useQuery(q.customers.customer.orders.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
710
- declare function useCustomerOrders(customerId: number | string | undefined, params?: Record<string, unknown>, options?: UseCustomerOrdersOptions): {
780
+ declare function useCustomerOrders(customerId?: number | string, params?: Record<string, unknown>, options?: UseCustomerOrdersOptions): {
711
781
  orders: unknown[];
712
782
  total: number;
713
783
  isLoading: boolean;
@@ -718,7 +788,7 @@ interface UseOrderDetailOptions {
718
788
  queryFn?: () => Promise<unknown>;
719
789
  }
720
790
  /** @deprecated Use `useQuery(q.customers.customer.orders.get(custId, orderNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
721
- declare function useOrderDetail(customerId: number | string | undefined, orderId: number | string | undefined, options?: UseOrderDetailOptions): {
791
+ declare function useOrderDetail(customerId?: number | string, orderId?: number | string, options?: UseOrderDetailOptions): {
722
792
  order: {} | null;
723
793
  isLoading: boolean;
724
794
  error: Error | null;
@@ -733,7 +803,7 @@ interface UseCustomerInvoicesOptions {
733
803
  queryFn?: () => Promise<CustomerListResult$1>;
734
804
  }
735
805
  /** @deprecated Use `useQuery(q.customers.customer.invoices.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
736
- declare function useCustomerInvoices(customerId: number | string | undefined, params?: Record<string, unknown>, options?: UseCustomerInvoicesOptions): {
806
+ declare function useCustomerInvoices(customerId?: number | string, params?: Record<string, unknown>, options?: UseCustomerInvoicesOptions): {
737
807
  invoices: unknown[];
738
808
  total: number;
739
809
  isLoading: boolean;
@@ -744,7 +814,7 @@ interface UseInvoiceDetailOptions {
744
814
  queryFn?: () => Promise<unknown>;
745
815
  }
746
816
  /** @deprecated Use `useQuery(q.customers.customer.invoices.get(custId, invoiceNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
747
- declare function useInvoiceDetail(customerId: number | string | undefined, invoiceNo: number | string | undefined, options?: UseInvoiceDetailOptions): {
817
+ declare function useInvoiceDetail(customerId?: number | string, invoiceNo?: number | string, options?: UseInvoiceDetailOptions): {
748
818
  invoice: {} | null;
749
819
  isLoading: boolean;
750
820
  error: Error | null;
@@ -759,7 +829,7 @@ interface UseCustomerQuotesOptions {
759
829
  queryFn?: () => Promise<CustomerListResult>;
760
830
  }
761
831
  /** @deprecated Use `useQuery(q.customers.customer.quotes.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
762
- declare function useCustomerQuotes(customerId: number | string | undefined, params?: Record<string, unknown>, options?: UseCustomerQuotesOptions): {
832
+ declare function useCustomerQuotes(customerId?: number | string, params?: Record<string, unknown>, options?: UseCustomerQuotesOptions): {
763
833
  quotes: unknown[];
764
834
  total: number;
765
835
  isLoading: boolean;
@@ -770,7 +840,7 @@ interface UseQuoteDetailOptions {
770
840
  queryFn?: () => Promise<unknown>;
771
841
  }
772
842
  /** @deprecated Use `useQuery(q.customers.customer.quotes.get(custId, quoteNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
773
- declare function useQuoteDetail(customerId: number | string | undefined, quoteNo: number | string | undefined, options?: UseQuoteDetailOptions): {
843
+ declare function useQuoteDetail(customerId?: number | string, quoteNo?: number | string, options?: UseQuoteDetailOptions): {
774
844
  quote: {} | null;
775
845
  isLoading: boolean;
776
846
  error: Error | null;
@@ -912,4 +982,4 @@ declare function useAugurPersistence(config: PersistenceConfig): {
912
982
  };
913
983
  };
914
984
 
915
- export { AugurApiClient, AugurCallbacks, BatchInvMastDocParam, type CartActionCallbacks, type CartInitCallbacks, type CartPriceData, type CartPricingResult, type CartSessionInfo, type CreateSiteHooksConfig, GetItemCategoryApiOptions, PageData, PersistenceConfig, SearchSuggestion, SearchSuggestionsResponse, createSiteHooks, useAugurPersistence, useBatchInvMastDoc, useCartActions, useCartHdrUid, useCartInitialization, useCartLineCount, useCartLines, useCartPricing, useCartQuantityTotal, useCartStore, useCategoryItemsInfinite, useClearCart, useCustomerInvoices, useCustomerOrders, useCustomerQuotes, useDebounce, useFormatPrice, useInvMast, useInvMastDoc, useInvMastStock, useInvoiceDetail, useItemAttributes, useItemCategory, useItemDetails, useItemFiltersStore, useItemPrice, useItemSearchInfinite, useJoomlaContent, useJoomlaContentList, useJoomlaMenu, useJoomlaMenuDoc, useOrderDetail, usePaginationPrefetch, useProductCategory, useProductSearch, useQuoteDetail, useSearchSuggestions, useSetCartHdrUid, useSetCartLines };
985
+ export { AugurApiClient, AugurCallbacks, BatchInvMastDocParam, type CartActionCallbacks, type CartInitCallbacks, type CartPriceData, type CartPricingResult, type CartSessionInfo, type CreateSiteHooksConfig, type FormatPriceCallOptions, GetItemCategoryApiOptions, PageData, PersistenceConfig, SearchSuggestion, SearchSuggestionsResponse, type UseFormatPriceOptions, type UseStockOptions, createSiteHooks, useAugurPersistence, useBatchInvMastDoc, useCartActions, useCartHdrUid, useCartInitialization, useCartLineCount, useCartLines, useCartPricing, useCartQuantityTotal, useCartStore, useCategoryItemsInfinite, useClearCart, useCustomerInvoices, useCustomerOrders, useCustomerQuotes, useDebounce, useFormatPrice, useInvMast, useInvMastDoc, useInvMastStock, useInvoiceDetail, useItemAttributes, useItemCategory, useItemDetails, useItemFiltersStore, useItemPrice, useItemSearchInfinite, useJoomlaContent, useJoomlaContentList, useJoomlaMenu, useJoomlaMenuDoc, useOrderDetail, usePaginationPrefetch, useProductCategory, useProductSearch, useQuoteDetail, useSearchSuggestions, useSetCartHdrUid, useSetCartLines, useStock };