@simpleapps-com/augur-hooks 1.0.7 → 1.0.9

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-G2WMZu_X.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 } from './customer-quotes-G2WMZu_X.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
- export { AugurAuthContext, CacheConfig, CacheProvider, CacheTierConfig, DeepQueryOptions, EdgeCacheValue, InfiniteScrollPage, ProxyMutationOptions, ProxyQueryOptions } from '@simpleapps-com/augur-core';
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,12 +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
- * Wraps Intl.NumberFormat with configurable locale/currency.
119
+ * Reads defaults from site config when params are omitted.
120
+ *
121
+ * Supports both the new options-object signature and the legacy positional
122
+ * `(locale?, currency?)` signature for backwards compatibility.
82
123
  */
83
- declare function useFormatPrice(locale?: string, currency?: string): {
84
- formatPrice: (price: number) => string;
124
+ declare function useFormatPrice(optionsOrLocale?: UseFormatPriceOptions | string, legacyCurrency?: string): {
125
+ formatPrice: (price: number, callOptions?: FormatPriceCallOptions) => string;
85
126
  };
86
127
 
87
128
  interface UseItemPriceOptions {
@@ -101,7 +142,7 @@ interface UseItemPriceOptions {
101
142
  * });
102
143
  * ```
103
144
  */
104
- 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): {
105
146
  derived: _simpleapps_com_augur_utils.DerivedPrice | null;
106
147
  data: TPriceData;
107
148
  error: Error;
@@ -329,6 +370,36 @@ declare function useInvMastStock(invMastUid: number | string, options?: UseInvMa
329
370
  error: Error | null;
330
371
  };
331
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
+
332
403
  interface UseBatchInvMastDocOptions {
333
404
  enabled?: boolean;
334
405
  includePricing?: "Y" | "N";
@@ -706,7 +777,7 @@ interface UseCustomerOrdersOptions {
706
777
  queryFn?: () => Promise<CustomerListResult$2>;
707
778
  }
708
779
  /** @deprecated Use `useQuery(q.customers.customer.orders.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
709
- 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): {
710
781
  orders: unknown[];
711
782
  total: number;
712
783
  isLoading: boolean;
@@ -717,7 +788,7 @@ interface UseOrderDetailOptions {
717
788
  queryFn?: () => Promise<unknown>;
718
789
  }
719
790
  /** @deprecated Use `useQuery(q.customers.customer.orders.get(custId, orderNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
720
- 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): {
721
792
  order: {} | null;
722
793
  isLoading: boolean;
723
794
  error: Error | null;
@@ -732,7 +803,7 @@ interface UseCustomerInvoicesOptions {
732
803
  queryFn?: () => Promise<CustomerListResult$1>;
733
804
  }
734
805
  /** @deprecated Use `useQuery(q.customers.customer.invoices.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
735
- 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): {
736
807
  invoices: unknown[];
737
808
  total: number;
738
809
  isLoading: boolean;
@@ -743,7 +814,7 @@ interface UseInvoiceDetailOptions {
743
814
  queryFn?: () => Promise<unknown>;
744
815
  }
745
816
  /** @deprecated Use `useQuery(q.customers.customer.invoices.get(custId, invoiceNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
746
- 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): {
747
818
  invoice: {} | null;
748
819
  isLoading: boolean;
749
820
  error: Error | null;
@@ -758,7 +829,7 @@ interface UseCustomerQuotesOptions {
758
829
  queryFn?: () => Promise<CustomerListResult>;
759
830
  }
760
831
  /** @deprecated Use `useQuery(q.customers.customer.quotes.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
761
- 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): {
762
833
  quotes: unknown[];
763
834
  total: number;
764
835
  isLoading: boolean;
@@ -769,7 +840,7 @@ interface UseQuoteDetailOptions {
769
840
  queryFn?: () => Promise<unknown>;
770
841
  }
771
842
  /** @deprecated Use `useQuery(q.customers.customer.quotes.get(custId, quoteNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
772
- 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): {
773
844
  quote: {} | null;
774
845
  isLoading: boolean;
775
846
  error: Error | null;
@@ -911,4 +982,4 @@ declare function useAugurPersistence(config: PersistenceConfig): {
911
982
  };
912
983
  };
913
984
 
914
- 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-G2WMZu_X.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 } from './customer-quotes-G2WMZu_X.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
- export { AugurAuthContext, CacheConfig, CacheProvider, CacheTierConfig, DeepQueryOptions, EdgeCacheValue, InfiniteScrollPage, ProxyMutationOptions, ProxyQueryOptions } from '@simpleapps-com/augur-core';
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,12 +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
- * Wraps Intl.NumberFormat with configurable locale/currency.
119
+ * Reads defaults from site config when params are omitted.
120
+ *
121
+ * Supports both the new options-object signature and the legacy positional
122
+ * `(locale?, currency?)` signature for backwards compatibility.
82
123
  */
83
- declare function useFormatPrice(locale?: string, currency?: string): {
84
- formatPrice: (price: number) => string;
124
+ declare function useFormatPrice(optionsOrLocale?: UseFormatPriceOptions | string, legacyCurrency?: string): {
125
+ formatPrice: (price: number, callOptions?: FormatPriceCallOptions) => string;
85
126
  };
86
127
 
87
128
  interface UseItemPriceOptions {
@@ -101,7 +142,7 @@ interface UseItemPriceOptions {
101
142
  * });
102
143
  * ```
103
144
  */
104
- 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): {
105
146
  derived: _simpleapps_com_augur_utils.DerivedPrice | null;
106
147
  data: TPriceData;
107
148
  error: Error;
@@ -329,6 +370,36 @@ declare function useInvMastStock(invMastUid: number | string, options?: UseInvMa
329
370
  error: Error | null;
330
371
  };
331
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
+
332
403
  interface UseBatchInvMastDocOptions {
333
404
  enabled?: boolean;
334
405
  includePricing?: "Y" | "N";
@@ -706,7 +777,7 @@ interface UseCustomerOrdersOptions {
706
777
  queryFn?: () => Promise<CustomerListResult$2>;
707
778
  }
708
779
  /** @deprecated Use `useQuery(q.customers.customer.orders.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
709
- 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): {
710
781
  orders: unknown[];
711
782
  total: number;
712
783
  isLoading: boolean;
@@ -717,7 +788,7 @@ interface UseOrderDetailOptions {
717
788
  queryFn?: () => Promise<unknown>;
718
789
  }
719
790
  /** @deprecated Use `useQuery(q.customers.customer.orders.get(custId, orderNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
720
- 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): {
721
792
  order: {} | null;
722
793
  isLoading: boolean;
723
794
  error: Error | null;
@@ -732,7 +803,7 @@ interface UseCustomerInvoicesOptions {
732
803
  queryFn?: () => Promise<CustomerListResult$1>;
733
804
  }
734
805
  /** @deprecated Use `useQuery(q.customers.customer.invoices.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
735
- 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): {
736
807
  invoices: unknown[];
737
808
  total: number;
738
809
  isLoading: boolean;
@@ -743,7 +814,7 @@ interface UseInvoiceDetailOptions {
743
814
  queryFn?: () => Promise<unknown>;
744
815
  }
745
816
  /** @deprecated Use `useQuery(q.customers.customer.invoices.get(custId, invoiceNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
746
- 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): {
747
818
  invoice: {} | null;
748
819
  isLoading: boolean;
749
820
  error: Error | null;
@@ -758,7 +829,7 @@ interface UseCustomerQuotesOptions {
758
829
  queryFn?: () => Promise<CustomerListResult>;
759
830
  }
760
831
  /** @deprecated Use `useQuery(q.customers.customer.quotes.list(custId))` with `useAugurOptions()` instead. Will be removed in the next major version. */
761
- 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): {
762
833
  quotes: unknown[];
763
834
  total: number;
764
835
  isLoading: boolean;
@@ -769,7 +840,7 @@ interface UseQuoteDetailOptions {
769
840
  queryFn?: () => Promise<unknown>;
770
841
  }
771
842
  /** @deprecated Use `useQuery(q.customers.customer.quotes.get(custId, quoteNo))` with `useAugurOptions()` instead. Will be removed in the next major version. */
772
- 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): {
773
844
  quote: {} | null;
774
845
  isLoading: boolean;
775
846
  error: Error | null;
@@ -911,4 +982,4 @@ declare function useAugurPersistence(config: PersistenceConfig): {
911
982
  };
912
983
  };
913
984
 
914
- 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 };