@simpleapps-com/augur-hooks 2026.11.6 → 2026.11.8
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/README.md +4 -1
- package/dist/checkout/create-checkout-provider.d.ts.map +1 -1
- package/dist/checkout/index.cjs +35 -32
- package/dist/checkout/index.cjs.map +1 -1
- package/dist/checkout/index.js +16 -13
- package/dist/checkout/index.js.map +1 -1
- package/dist/{chunk-V3VBNWLM.js → chunk-2VK2LDMV.js} +8 -3
- package/dist/{chunk-V3VBNWLM.js.map → chunk-2VK2LDMV.js.map} +1 -1
- package/dist/{chunk-4PTXISXM.cjs → chunk-F6GCIDES.cjs} +9 -4
- package/dist/chunk-F6GCIDES.cjs.map +1 -0
- package/dist/hooks/use-cart-pricing.d.ts.map +1 -1
- package/dist/hooks/use-payment-flow.d.ts.map +1 -1
- package/dist/index.cjs +81 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -21
- package/dist/index.js.map +1 -1
- package/dist/rules.d.ts +8 -0
- package/dist/rules.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/chunk-4PTXISXM.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -43,7 +43,7 @@ var _chunkWJ4D5OCQcjs = require('./chunk-WJ4D5OCQ.cjs');
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _chunkF6GCIDEScjs = require('./chunk-F6GCIDES.cjs');
|
|
47
47
|
|
|
48
48
|
// src/provider.tsx
|
|
49
49
|
var _react = require('react');
|
|
@@ -60,7 +60,7 @@ var AugurOptionsContext = _react.createContext.call(void 0, null);
|
|
|
60
60
|
var AugurSiteContext = _react.createContext.call(void 0, void 0);
|
|
61
61
|
function AugurHooksProvider({ api, auth, cache, site, children }) {
|
|
62
62
|
const proxyConfig = cache ? { cache: { static: cache.static, semiStatic: cache.semiStatic } } : void 0;
|
|
63
|
-
const proxyConfigRef =
|
|
63
|
+
const proxyConfigRef = _chunkF6GCIDEScjs.useLatest.call(void 0, proxyConfig);
|
|
64
64
|
const options = _react.useMemo.call(void 0, () => {
|
|
65
65
|
const config = proxyConfigRef.current;
|
|
66
66
|
if (api) return _augurcore.createOptionsProxy.call(void 0, api, config);
|
|
@@ -169,7 +169,7 @@ function useFormatPrice(optionsOrLocale, legacyCurrency) {
|
|
|
169
169
|
} = resolveFormatting(opts, _optionalChain([site, 'optionalAccess', _ => _.formatting]));
|
|
170
170
|
const formatPrice = (price, callOptions) => {
|
|
171
171
|
const effectiveValue = _augurutils.cleanMoney.call(void 0, price * (_nullishCoalesce(_optionalChain([callOptions, 'optionalAccess', _2 => _2.quantity]), () => ( 1))));
|
|
172
|
-
if (
|
|
172
|
+
if (_chunkF6GCIDEScjs.zeroLabelShown.call(void 0, effectiveValue === 0, zeroLabel !== void 0)) {
|
|
173
173
|
return zeroLabel;
|
|
174
174
|
}
|
|
175
175
|
const precision = _nullishCoalesce(_optionalChain([callOptions, 'optionalAccess', _3 => _3.precision]), () => ( basePrecision));
|
|
@@ -194,9 +194,9 @@ function useStock(invMastUid, options = {}) {
|
|
|
194
194
|
const query = _reactquery.useQuery.call(void 0, {
|
|
195
195
|
...proxyOpts,
|
|
196
196
|
...resolvedQueryFn ? { queryFn: resolvedQueryFn } : {},
|
|
197
|
-
enabled:
|
|
197
|
+
enabled: _chunkF6GCIDEScjs.stockEnabled.call(void 0, options.enabled, !!invMastUid),
|
|
198
198
|
retry: 3,
|
|
199
|
-
retryDelay:
|
|
199
|
+
retryDelay: _chunkF6GCIDEScjs.stockRetryDelay
|
|
200
200
|
});
|
|
201
201
|
const stockData = _nullishCoalesce(query.data, () => ( null));
|
|
202
202
|
const resolved = _react.useMemo.call(void 0,
|
|
@@ -226,19 +226,19 @@ function cartUidOf(cartHdrUid) {
|
|
|
226
226
|
return num === void 0 || Number.isNaN(num) ? void 0 : num;
|
|
227
227
|
}
|
|
228
228
|
function requireCartUid(cartHdrUid) {
|
|
229
|
-
const uid =
|
|
229
|
+
const uid = _chunkF6GCIDEScjs.requiredCartUid.call(void 0, cartUidOf(cartHdrUid));
|
|
230
230
|
if (uid === null) throw new Error("Cart UID is not set");
|
|
231
231
|
return uid;
|
|
232
232
|
}
|
|
233
233
|
function liveCart() {
|
|
234
|
-
const { cartHdrUid, cartLines } =
|
|
234
|
+
const { cartHdrUid, cartLines } = _chunkF6GCIDEScjs.useCartStore.getState();
|
|
235
235
|
return { uid: requireCartUid(cartHdrUid), lines: cartLines };
|
|
236
236
|
}
|
|
237
237
|
function buildOptimisticAdd(cartLines, item, cartHdrUid, itemId) {
|
|
238
|
-
const existingIndex =
|
|
238
|
+
const existingIndex = _chunkF6GCIDEScjs.indexOfUidFrom.call(void 0, uidsOf(cartLines), item.invMastUid, 0);
|
|
239
239
|
if (existingIndex >= 0) {
|
|
240
240
|
return cartLines.map(
|
|
241
|
-
(line, index) => index === existingIndex ? { ...line, quantity:
|
|
241
|
+
(line, index) => index === existingIndex ? { ...line, quantity: _chunkF6GCIDEScjs.qtyOrZero.call(void 0, line.quantity) + item.quantity } : line
|
|
242
242
|
);
|
|
243
243
|
}
|
|
244
244
|
return [
|
|
@@ -259,28 +259,28 @@ function buildOptimisticAdd(cartLines, item, cartHdrUid, itemId) {
|
|
|
259
259
|
];
|
|
260
260
|
}
|
|
261
261
|
function reverseAdd(cartLines, invMastUid, quantity) {
|
|
262
|
-
const index =
|
|
262
|
+
const index = _chunkF6GCIDEScjs.indexOfUidFrom.call(void 0, uidsOf(cartLines), invMastUid, 0);
|
|
263
263
|
if (index < 0) return cartLines;
|
|
264
264
|
const line = cartLines[index];
|
|
265
|
-
if (!
|
|
265
|
+
if (!_chunkF6GCIDEScjs.keepsAfterReverse.call(void 0, line.quantity, quantity)) {
|
|
266
266
|
return [...cartLines.slice(0, index), ...cartLines.slice(index + 1)];
|
|
267
267
|
}
|
|
268
268
|
return cartLines.map(
|
|
269
|
-
(l, i) => i === index ? { ...l, quantity:
|
|
269
|
+
(l, i) => i === index ? { ...l, quantity: _chunkF6GCIDEScjs.qtyOrZero.call(void 0, l.quantity) - quantity } : l
|
|
270
270
|
);
|
|
271
271
|
}
|
|
272
272
|
function targetOf(cartLines, invMastUid, unitOfMeasure) {
|
|
273
|
-
const first =
|
|
273
|
+
const first = _chunkF6GCIDEScjs.indexOfUidFrom.call(void 0, uidsOf(cartLines), invMastUid, 0);
|
|
274
274
|
if (first < 0) return null;
|
|
275
275
|
const unit = _nullishCoalesce(unitOfMeasure, () => ( unitOf(cartLines[first])));
|
|
276
|
-
if (
|
|
276
|
+
if (_chunkF6GCIDEScjs.indexOfUnitFrom.call(void 0, uidsOf(cartLines), unitsOf(cartLines), invMastUid, unit, 0) < 0) return null;
|
|
277
277
|
return { invMastUid, unit };
|
|
278
278
|
}
|
|
279
279
|
function isTarget(line, target) {
|
|
280
|
-
return
|
|
280
|
+
return _chunkF6GCIDEScjs.indexOfUnitFrom.call(void 0, [line.invMastUid], [unitOf(line)], target.invMastUid, target.unit, 0) === 0;
|
|
281
281
|
}
|
|
282
282
|
function targetLine(cartLines, target) {
|
|
283
|
-
const index =
|
|
283
|
+
const index = _chunkF6GCIDEScjs.indexOfUnitFrom.call(void 0,
|
|
284
284
|
uidsOf(cartLines),
|
|
285
285
|
unitsOf(cartLines),
|
|
286
286
|
target.invMastUid,
|
|
@@ -295,7 +295,7 @@ function reverseQuantity(cartLines, target, previousQuantity) {
|
|
|
295
295
|
);
|
|
296
296
|
}
|
|
297
297
|
function restoreRemoved(cartLines, target, removedLine) {
|
|
298
|
-
if (
|
|
298
|
+
if (_chunkF6GCIDEScjs.indexOfUnitFrom.call(void 0, uidsOf(cartLines), unitsOf(cartLines), target.invMastUid, target.unit, 0) >= 0) {
|
|
299
299
|
return cartLines;
|
|
300
300
|
}
|
|
301
301
|
return [...cartLines, removedLine];
|
|
@@ -303,14 +303,14 @@ function restoreRemoved(cartLines, target, removedLine) {
|
|
|
303
303
|
function mergeRestore(cartLines, snapshot) {
|
|
304
304
|
const merged = [...cartLines];
|
|
305
305
|
for (const line of snapshot) {
|
|
306
|
-
if (!
|
|
306
|
+
if (!_chunkF6GCIDEScjs.hasNumberFrom.call(void 0, uidsOf(merged), line.invMastUid, 0)) merged.push(line);
|
|
307
307
|
}
|
|
308
308
|
return merged;
|
|
309
309
|
}
|
|
310
310
|
function sentLine(line, quantity) {
|
|
311
311
|
const { unitPrice, ...rest } = line;
|
|
312
312
|
const sent = { ...rest, quantity, lineNo: 0 };
|
|
313
|
-
if (
|
|
313
|
+
if (_chunkF6GCIDEScjs.sendsPrice.call(void 0, unitPrice)) sent.unitPrice = unitPrice;
|
|
314
314
|
return sent;
|
|
315
315
|
}
|
|
316
316
|
function uidsOf(cartLines) {
|
|
@@ -323,15 +323,15 @@ function unitsOf(cartLines) {
|
|
|
323
323
|
return cartLines.map(unitOf);
|
|
324
324
|
}
|
|
325
325
|
function sendToast(notify, kind, showToast, message) {
|
|
326
|
-
if (
|
|
326
|
+
if (_chunkF6GCIDEScjs.toastShown.call(void 0, showToast, message !== void 0)) _optionalChain([notify, 'optionalAccess', _4 => _4[kind], 'optionalCall', _5 => _5(message)]);
|
|
327
327
|
}
|
|
328
328
|
async function settleCartOp(op, options, notify, invalidate) {
|
|
329
|
-
const { endCartOp } =
|
|
329
|
+
const { endCartOp } = _chunkF6GCIDEScjs.useCartStore.getState();
|
|
330
330
|
try {
|
|
331
331
|
const success = await op.call();
|
|
332
332
|
if (!success) throw new Error(op.failure);
|
|
333
333
|
} catch (error) {
|
|
334
|
-
if (
|
|
334
|
+
if (_chunkF6GCIDEScjs.rollsBack.call(void 0, cartUidOf(_chunkF6GCIDEScjs.useCartStore.getState().cartHdrUid), op.cartUid)) op.rollback();
|
|
335
335
|
endCartOp();
|
|
336
336
|
invalidate();
|
|
337
337
|
sendToast(notify, "error", op.showToast, op.errorMessage);
|
|
@@ -346,9 +346,9 @@ async function settleCartOp(op, options, notify, invalidate) {
|
|
|
346
346
|
}
|
|
347
347
|
function useCartActions(callbacks) {
|
|
348
348
|
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
349
|
-
const cartHdrUid =
|
|
350
|
-
const cartLines =
|
|
351
|
-
const setCartLines =
|
|
349
|
+
const cartHdrUid = _chunkF6GCIDEScjs.useCartHdrUid.call(void 0, );
|
|
350
|
+
const cartLines = _chunkF6GCIDEScjs.useCartLines.call(void 0, );
|
|
351
|
+
const setCartLines = _chunkF6GCIDEScjs.useSetCartLines.call(void 0, );
|
|
352
352
|
const notify = callbacks.toast;
|
|
353
353
|
const invalidateCartCache = _react.useCallback.call(void 0, () => {
|
|
354
354
|
void queryClient.invalidateQueries({ queryKey: ["cartLines"] });
|
|
@@ -360,13 +360,13 @@ function useCartActions(callbacks) {
|
|
|
360
360
|
async (item, options = {}) => {
|
|
361
361
|
const { showToast = true, itemId = "" } = options;
|
|
362
362
|
const quantity = Number.isFinite(item.quantity) ? item.quantity : null;
|
|
363
|
-
if (!
|
|
363
|
+
if (!_chunkF6GCIDEScjs.addAccepted.call(void 0, item.unitOfMeasure, quantity)) {
|
|
364
364
|
sendToast(notify, "error", showToast, "Choose a quantity and a unit of measure.");
|
|
365
365
|
_optionalChain([options, 'access', _10 => _10.onError, 'optionalCall', _11 => _11(new Error("Quantity and unit of measure are required"))]);
|
|
366
366
|
return false;
|
|
367
367
|
}
|
|
368
368
|
const { uid, lines: liveLines } = liveCart();
|
|
369
|
-
|
|
369
|
+
_chunkF6GCIDEScjs.useCartStore.getState().beginCartOp();
|
|
370
370
|
setCartLines(buildOptimisticAdd(liveLines, item, uid, itemId));
|
|
371
371
|
return settleCartOp(
|
|
372
372
|
{
|
|
@@ -384,7 +384,7 @@ function useCartActions(callbacks) {
|
|
|
384
384
|
errorMessage: "Failed to add item to cart. Please try again.",
|
|
385
385
|
showToast,
|
|
386
386
|
rollback: () => setCartLines(
|
|
387
|
-
reverseAdd(
|
|
387
|
+
reverseAdd(_chunkF6GCIDEScjs.useCartStore.getState().cartLines, item.invMastUid, item.quantity)
|
|
388
388
|
)
|
|
389
389
|
},
|
|
390
390
|
options,
|
|
@@ -407,7 +407,7 @@ function useCartActions(callbacks) {
|
|
|
407
407
|
if (target === null) return true;
|
|
408
408
|
const line = targetLine(liveLines, target);
|
|
409
409
|
const previousQuantity = line.quantity;
|
|
410
|
-
|
|
410
|
+
_chunkF6GCIDEScjs.useCartStore.getState().beginCartOp();
|
|
411
411
|
setCartLines(
|
|
412
412
|
liveLines.map((l) => isTarget(l, target) ? { ...l, quantity: newQuantity } : l)
|
|
413
413
|
);
|
|
@@ -419,7 +419,7 @@ function useCartActions(callbacks) {
|
|
|
419
419
|
errorMessage: "Failed to update quantity. Please try again.",
|
|
420
420
|
showToast,
|
|
421
421
|
rollback: () => setCartLines(
|
|
422
|
-
reverseQuantity(
|
|
422
|
+
reverseQuantity(_chunkF6GCIDEScjs.useCartStore.getState().cartLines, target, previousQuantity)
|
|
423
423
|
)
|
|
424
424
|
},
|
|
425
425
|
options,
|
|
@@ -436,7 +436,7 @@ function useCartActions(callbacks) {
|
|
|
436
436
|
const target = targetOf(liveLines, invMastUid, unitOfMeasure);
|
|
437
437
|
if (target === null) return true;
|
|
438
438
|
const removedLine = targetLine(liveLines, target);
|
|
439
|
-
|
|
439
|
+
_chunkF6GCIDEScjs.useCartStore.getState().beginCartOp();
|
|
440
440
|
setCartLines(liveLines.filter((l) => !isTarget(l, target)));
|
|
441
441
|
return settleCartOp(
|
|
442
442
|
{
|
|
@@ -446,7 +446,7 @@ function useCartActions(callbacks) {
|
|
|
446
446
|
infoMessage: `${itemId || "Item"} removed from cart`,
|
|
447
447
|
errorMessage: "Failed to remove item. Please try again.",
|
|
448
448
|
showToast,
|
|
449
|
-
rollback: () => setCartLines(restoreRemoved(
|
|
449
|
+
rollback: () => setCartLines(restoreRemoved(_chunkF6GCIDEScjs.useCartStore.getState().cartLines, target, removedLine))
|
|
450
450
|
},
|
|
451
451
|
options,
|
|
452
452
|
notify,
|
|
@@ -459,7 +459,7 @@ function useCartActions(callbacks) {
|
|
|
459
459
|
async (options = {}) => {
|
|
460
460
|
const { showToast = true } = options;
|
|
461
461
|
const { uid, lines: snapshot } = liveCart();
|
|
462
|
-
|
|
462
|
+
_chunkF6GCIDEScjs.useCartStore.getState().beginCartOp();
|
|
463
463
|
setCartLines([]);
|
|
464
464
|
return settleCartOp(
|
|
465
465
|
{
|
|
@@ -469,7 +469,7 @@ function useCartActions(callbacks) {
|
|
|
469
469
|
infoMessage: "Cart cleared",
|
|
470
470
|
errorMessage: "Failed to clear cart. Please try again.",
|
|
471
471
|
showToast,
|
|
472
|
-
rollback: () => setCartLines(mergeRestore(
|
|
472
|
+
rollback: () => setCartLines(mergeRestore(_chunkF6GCIDEScjs.useCartStore.getState().cartLines, snapshot))
|
|
473
473
|
},
|
|
474
474
|
options,
|
|
475
475
|
notify,
|
|
@@ -511,14 +511,14 @@ function useModalLifecycle(isOpen, onClose) {
|
|
|
511
511
|
setIsClient(true);
|
|
512
512
|
}, []);
|
|
513
513
|
_react.useEffect.call(void 0, () => {
|
|
514
|
-
document.body.style.overflow =
|
|
514
|
+
document.body.style.overflow = _chunkF6GCIDEScjs.bodyOverflow.call(void 0, isOpen);
|
|
515
515
|
return () => {
|
|
516
516
|
document.body.style.overflow = "auto";
|
|
517
517
|
};
|
|
518
518
|
}, [isOpen]);
|
|
519
519
|
_react.useEffect.call(void 0, () => {
|
|
520
520
|
const handleEscape = (e) => {
|
|
521
|
-
if (
|
|
521
|
+
if (_chunkF6GCIDEScjs.closesOnKey.call(void 0, e.key, isOpen)) onClose();
|
|
522
522
|
};
|
|
523
523
|
document.addEventListener("keydown", handleEscape);
|
|
524
524
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
@@ -548,10 +548,10 @@ function useCartInitialization(session, callbacks) {
|
|
|
548
548
|
const saveCartToken = _nullishCoalesce(callbacks.saveCartToken, () => ( defaultSaveCartToken));
|
|
549
549
|
const generateCartToken = _nullishCoalesce(callbacks.generateCartToken, () => ( defaultGenerateCartToken));
|
|
550
550
|
const auth = useAugurAuth();
|
|
551
|
-
const cartHdrUid =
|
|
552
|
-
const setCartHdrUid =
|
|
553
|
-
const setCartLines =
|
|
554
|
-
const clearCart =
|
|
551
|
+
const cartHdrUid = _chunkF6GCIDEScjs.useCartHdrUid.call(void 0, );
|
|
552
|
+
const setCartHdrUid = _chunkF6GCIDEScjs.useSetCartHdrUid.call(void 0, );
|
|
553
|
+
const setCartLines = _chunkF6GCIDEScjs.useSetCartLines.call(void 0, );
|
|
554
|
+
const clearCart = _chunkF6GCIDEScjs.useClearCart.call(void 0, );
|
|
555
555
|
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
556
556
|
const effectiveStatus = session.status;
|
|
557
557
|
const effectiveUserId = _nullishCoalesce(session.userId, () => ( _optionalChain([auth, 'optionalAccess', _17 => _17.userId])));
|
|
@@ -578,7 +578,7 @@ function useCartInitialization(session, callbacks) {
|
|
|
578
578
|
}
|
|
579
579
|
}, [effectiveSession.status, clearCart, queryClient]);
|
|
580
580
|
_react.useEffect.call(void 0, () => {
|
|
581
|
-
const step =
|
|
581
|
+
const step = _chunkF6GCIDEScjs.initStepOf.call(void 0,
|
|
582
582
|
effectiveSession.status === "loading",
|
|
583
583
|
effectiveSession.status === "authenticated",
|
|
584
584
|
!!effectiveSession.cartHdrUid,
|
|
@@ -604,10 +604,10 @@ function useCartInitialization(session, callbacks) {
|
|
|
604
604
|
try {
|
|
605
605
|
const cartHdr = await callbacks.cartHdrLookup(lookupUserId, cartToken);
|
|
606
606
|
if (cartHdr && cartHdr.cartHdrUid !== 0) {
|
|
607
|
-
const stillApplies =
|
|
607
|
+
const stillApplies = _chunkF6GCIDEScjs.acceptsLookup.call(void 0,
|
|
608
608
|
forUser,
|
|
609
609
|
statusRef.current === "authenticated",
|
|
610
|
-
!!
|
|
610
|
+
!!_chunkF6GCIDEScjs.useCartStore.getState().cartHdrUid
|
|
611
611
|
);
|
|
612
612
|
if (stillApplies) {
|
|
613
613
|
saveCartToken(cartToken);
|
|
@@ -646,7 +646,7 @@ function useCartInitialization(session, callbacks) {
|
|
|
646
646
|
structuralSharing: false
|
|
647
647
|
});
|
|
648
648
|
_react.useEffect.call(void 0, () => {
|
|
649
|
-
if (cartLinesData &&
|
|
649
|
+
if (cartLinesData && _chunkF6GCIDEScjs.cartIdle.call(void 0, _chunkF6GCIDEScjs.useCartStore.getState().pendingCartOps)) {
|
|
650
650
|
setCartLines(cartLinesData);
|
|
651
651
|
}
|
|
652
652
|
}, [cartLinesData, setCartLines]);
|
|
@@ -669,6 +669,7 @@ function useCartInitialization(session, callbacks) {
|
|
|
669
669
|
|
|
670
670
|
|
|
671
671
|
|
|
672
|
+
|
|
672
673
|
function derivedOrRefused(priceData, quantity) {
|
|
673
674
|
try {
|
|
674
675
|
return _augurutils.derivePrice.call(void 0, { priceData, quantity });
|
|
@@ -681,43 +682,46 @@ function deriveLineUnitPrice(priceData, quantity) {
|
|
|
681
682
|
const hasQuantity = typeof quantity === "number" && Number.isFinite(quantity);
|
|
682
683
|
const derived = hasQuantity ? derivedOrRefused(priceData, quantity) : null;
|
|
683
684
|
const priced = _optionalChain([derived, 'optionalAccess', _19 => _19.state]) === "priced";
|
|
684
|
-
return
|
|
685
|
+
return _chunkF6GCIDEScjs.lineUnitPrice.call(void 0, hasQuantity, priced, priced ? derived.unitPrice : 0);
|
|
685
686
|
}
|
|
686
687
|
function lineTotal(unitPrice, quantity) {
|
|
687
688
|
return Number.isFinite(quantity) ? _augurutils.cleanMoney.call(void 0, unitPrice * quantity) : 0;
|
|
688
689
|
}
|
|
690
|
+
function keyedPriceQuery(itemId, customerId, quantity, unitOfMeasure, enabled, priceFn) {
|
|
691
|
+
return _reactquery.queryOptions.call(void 0, {
|
|
692
|
+
queryKey: ["price", _optionalChain([itemId, 'optionalAccess', _20 => _20.toUpperCase, 'call', _21 => _21()]) || "", customerId, quantity, _nullishCoalesce(unitOfMeasure, () => ( ""))],
|
|
693
|
+
queryFn: priceFn && customerId !== null ? () => priceFn(itemId, customerId, quantity, unitOfMeasure) : _reactquery.skipToken,
|
|
694
|
+
refetchOnReconnect: true,
|
|
695
|
+
refetchOnWindowFocus: false,
|
|
696
|
+
meta: { persist: true },
|
|
697
|
+
enabled
|
|
698
|
+
});
|
|
699
|
+
}
|
|
689
700
|
function useCartPricing(options = {}) {
|
|
690
701
|
const proxy = useAugurOptions();
|
|
691
702
|
const auth = useAugurAuth();
|
|
692
703
|
const site = useAugurSite();
|
|
693
|
-
const cartLines =
|
|
694
|
-
const customerId =
|
|
704
|
+
const cartLines = _chunkF6GCIDEScjs.useCartLines.call(void 0, );
|
|
705
|
+
const customerId = _augurutils.resolveAddressId.call(void 0,
|
|
706
|
+
options.customerId,
|
|
707
|
+
_optionalChain([auth, 'optionalAccess', _22 => _22.customerId]),
|
|
708
|
+
_optionalChain([site, 'optionalAccess', _23 => _23.defaults, 'optionalAccess', _24 => _24.customerId])
|
|
709
|
+
);
|
|
695
710
|
const priceFn = options.queryFn;
|
|
696
|
-
const runs = cartLines.map(
|
|
711
|
+
const runs = cartLines.map(
|
|
712
|
+
(line) => _augurutils.priceQueryRuns.call(void 0, customerId !== null, !!line.itemId, line.quantity)
|
|
713
|
+
);
|
|
697
714
|
const priceQueries = _reactquery.useQueries.call(void 0, {
|
|
698
715
|
queries: cartLines.map((line, index) => {
|
|
699
716
|
const quantity = _nullishCoalesce(line.quantity, () => ( 0));
|
|
700
717
|
const enabled = runs[index] === true;
|
|
701
718
|
const unitOfMeasure = _nullishCoalesce(_augurutils.priceQueryUnit.call(void 0, line.unitOfMeasure), () => ( void 0));
|
|
702
|
-
if (priceFn) {
|
|
703
|
-
return
|
|
704
|
-
queryKey: [
|
|
705
|
-
"price",
|
|
706
|
-
_optionalChain([line, 'access', _23 => _23.itemId, 'optionalAccess', _24 => _24.toUpperCase, 'call', _25 => _25()]) || "",
|
|
707
|
-
customerId,
|
|
708
|
-
quantity,
|
|
709
|
-
_nullishCoalesce(unitOfMeasure, () => ( ""))
|
|
710
|
-
],
|
|
711
|
-
queryFn: () => priceFn(line.itemId, customerId, quantity, unitOfMeasure),
|
|
712
|
-
refetchOnReconnect: true,
|
|
713
|
-
refetchOnWindowFocus: false,
|
|
714
|
-
meta: { persist: true },
|
|
715
|
-
enabled
|
|
716
|
-
};
|
|
719
|
+
if (priceFn || customerId === null) {
|
|
720
|
+
return keyedPriceQuery(line.itemId, customerId, quantity, unitOfMeasure, enabled, priceFn);
|
|
717
721
|
}
|
|
718
722
|
const proxyOpts = proxy.pricing.priceEngine.list({
|
|
719
|
-
itemId: _optionalChain([line, 'access',
|
|
720
|
-
customerId
|
|
723
|
+
itemId: _optionalChain([line, 'access', _25 => _25.itemId, 'optionalAccess', _26 => _26.toUpperCase, 'call', _27 => _27()]) || "",
|
|
724
|
+
customerId,
|
|
721
725
|
quantity,
|
|
722
726
|
unitOfMeasure
|
|
723
727
|
});
|
|
@@ -732,7 +736,7 @@ function useCartPricing(options = {}) {
|
|
|
732
736
|
});
|
|
733
737
|
const linePrices = _react.useMemo.call(void 0,
|
|
734
738
|
() => cartLines.map((line, index) => {
|
|
735
|
-
const priceData = _optionalChain([priceQueries, 'access',
|
|
739
|
+
const priceData = _optionalChain([priceQueries, 'access', _28 => _28[index], 'optionalAccess', _29 => _29.data]);
|
|
736
740
|
if (!priceData) return null;
|
|
737
741
|
return {
|
|
738
742
|
unitPrice: deriveLineUnitPrice(priceData, line.quantity),
|
|
@@ -741,7 +745,7 @@ function useCartPricing(options = {}) {
|
|
|
741
745
|
}),
|
|
742
746
|
[cartLines, priceQueries]
|
|
743
747
|
);
|
|
744
|
-
const lineUnitPrices = _react.useMemo.call(void 0, () => linePrices.map((p) => _nullishCoalesce(_optionalChain([p, 'optionalAccess',
|
|
748
|
+
const lineUnitPrices = _react.useMemo.call(void 0, () => linePrices.map((p) => _nullishCoalesce(_optionalChain([p, 'optionalAccess', _30 => _30.unitPrice]), () => ( 0))), [linePrices]);
|
|
745
749
|
const prices = _react.useMemo.call(void 0, () => {
|
|
746
750
|
const map = {};
|
|
747
751
|
cartLines.forEach((line, index) => {
|
|
@@ -752,7 +756,7 @@ function useCartPricing(options = {}) {
|
|
|
752
756
|
}, [cartLines, linePrices]);
|
|
753
757
|
const getUnitPrice = _react.useMemo.call(void 0, () => {
|
|
754
758
|
return (itemId) => {
|
|
755
|
-
return _nullishCoalesce(_optionalChain([prices, 'access',
|
|
759
|
+
return _nullishCoalesce(_optionalChain([prices, 'access', _31 => _31[_optionalChain([itemId, 'optionalAccess', _32 => _32.toUpperCase, 'call', _33 => _33()])], 'optionalAccess', _34 => _34.unitPrice]), () => ( 0));
|
|
756
760
|
};
|
|
757
761
|
}, [prices]);
|
|
758
762
|
const getItemTotal = _react.useMemo.call(void 0, () => {
|
|
@@ -764,7 +768,7 @@ function useCartPricing(options = {}) {
|
|
|
764
768
|
return (index) => _augurutils.linePriceAt.call(void 0, lineUnitPrices, index);
|
|
765
769
|
}, [lineUnitPrices]);
|
|
766
770
|
const getLineTotal = _react.useMemo.call(void 0, () => {
|
|
767
|
-
return (index) => lineTotal(_augurutils.linePriceAt.call(void 0, lineUnitPrices, index), _nullishCoalesce(_optionalChain([cartLines, 'access',
|
|
771
|
+
return (index) => lineTotal(_augurutils.linePriceAt.call(void 0, lineUnitPrices, index), _nullishCoalesce(_optionalChain([cartLines, 'access', _35 => _35[index], 'optionalAccess', _36 => _36.quantity]), () => ( null)));
|
|
768
772
|
}, [cartLines, lineUnitPrices]);
|
|
769
773
|
const subtotal = _react.useMemo.call(void 0, () => {
|
|
770
774
|
return cartLines.reduce(
|
|
@@ -857,7 +861,7 @@ function deserialize(data) {
|
|
|
857
861
|
|
|
858
862
|
// src/persistence/apply-limits.ts
|
|
859
863
|
function applyLimits(data, limits) {
|
|
860
|
-
const queries = _optionalChain([data, 'access',
|
|
864
|
+
const queries = _optionalChain([data, 'access', _37 => _37.clientState, 'optionalAccess', _38 => _38.queries]);
|
|
861
865
|
if (!queries || Object.keys(limits).length === 0) return data;
|
|
862
866
|
const entries = queries;
|
|
863
867
|
const unlimited = [];
|
|
@@ -941,7 +945,7 @@ function createPersister(config) {
|
|
|
941
945
|
var CHECK_INTERVAL = _augurutils.toMillis.call(void 0, _augurutils.minutes.call(void 0, 5));
|
|
942
946
|
function useStorageMonitor(config) {
|
|
943
947
|
const { key, limits = {}, maxStorageMB = 3 } = config;
|
|
944
|
-
const limitKeysRef =
|
|
948
|
+
const limitKeysRef = _chunkF6GCIDEScjs.useLatest.call(void 0, Object.keys(limits));
|
|
945
949
|
const limitCount = limitKeysRef.current.length;
|
|
946
950
|
_react.useEffect.call(void 0, () => {
|
|
947
951
|
const limitKeys = limitKeysRef.current;
|
|
@@ -959,7 +963,7 @@ function useStorageMonitor(config) {
|
|
|
959
963
|
const raw = storage.getItem(key);
|
|
960
964
|
if (!raw) return;
|
|
961
965
|
const parsed = JSON.parse(raw);
|
|
962
|
-
if (!_optionalChain([parsed, 'access',
|
|
966
|
+
if (!_optionalChain([parsed, 'access', _39 => _39.clientState, 'optionalAccess', _40 => _40.queries])) return;
|
|
963
967
|
parsed.clientState.queries = parsed.clientState.queries.filter(
|
|
964
968
|
(q) => {
|
|
965
969
|
if (!Array.isArray(q.queryKey)) return true;
|
|
@@ -987,14 +991,14 @@ function useAugurPersistence(config) {
|
|
|
987
991
|
setIsMounted(true);
|
|
988
992
|
}, []);
|
|
989
993
|
useStorageMonitor(config);
|
|
990
|
-
const isDev = typeof process !== "undefined" && _optionalChain([process, 'access',
|
|
994
|
+
const isDev = typeof process !== "undefined" && _optionalChain([process, 'access', _41 => _41.env, 'optionalAccess', _42 => _42["NODE_ENV"]]) === "development";
|
|
991
995
|
const { persistableKeys } = config;
|
|
992
996
|
const dehydrateOptions = _react.useMemo.call(void 0,
|
|
993
997
|
() => ({
|
|
994
998
|
shouldDehydrateQuery: (query) => {
|
|
995
999
|
const key = query.queryKey;
|
|
996
1000
|
const hasHead = Array.isArray(key) && key.length > 0;
|
|
997
|
-
return
|
|
1001
|
+
return _chunkF6GCIDEScjs.shouldPersistOf.call(void 0,
|
|
998
1002
|
hasHead,
|
|
999
1003
|
query.state.status === "success",
|
|
1000
1004
|
hasHead && persistableKeys.includes(key[0])
|
|
@@ -1015,11 +1019,11 @@ function useAugurPersistence(config) {
|
|
|
1015
1019
|
|
|
1016
1020
|
function keyPathOf(key) {
|
|
1017
1021
|
const segments = _nullishCoalesce(key, () => ( []));
|
|
1018
|
-
const n =
|
|
1022
|
+
const n = _chunkF6GCIDEScjs.leadingTextsFrom.call(void 0,
|
|
1019
1023
|
segments.map((s) => typeof s === "string"),
|
|
1020
1024
|
0
|
|
1021
1025
|
);
|
|
1022
|
-
return
|
|
1026
|
+
return _chunkF6GCIDEScjs.keyPathFrom.call(void 0, segments, n);
|
|
1023
1027
|
}
|
|
1024
1028
|
function clearUserReadsOnWrite(queryClient, mutationKey) {
|
|
1025
1029
|
const writePath = keyPathOf(mutationKey);
|
|
@@ -1072,5 +1076,5 @@ function userWriteClearing(getQueryClient) {
|
|
|
1072
1076
|
|
|
1073
1077
|
|
|
1074
1078
|
|
|
1075
|
-
exports.AugurHooksProvider = AugurHooksProvider; exports.clearCheckoutPersistence =
|
|
1079
|
+
exports.AugurHooksProvider = AugurHooksProvider; exports.clearCheckoutPersistence = _chunkF6GCIDEScjs.clearCheckoutPersistence; exports.clearFromSession = _chunkF6GCIDEScjs.clearFromSession; exports.clearUserReadsOnWrite = clearUserReadsOnWrite; exports.determineOrderReadiness = _chunkF6GCIDEScjs.determineOrderReadiness; exports.executeBatchQuery = _chunkWJ4D5OCQcjs.executeBatchQuery; exports.getRegisteredQueryAction = _chunkWJ4D5OCQcjs.getRegisteredQueryAction; exports.keyPathOf = keyPathOf; exports.loadFromSession = _chunkF6GCIDEScjs.loadFromSession; exports.registerQueryAction = _chunkWJ4D5OCQcjs.registerQueryAction; exports.saveToSession = _chunkF6GCIDEScjs.saveToSession; exports.useAugurApi = useAugurApi; exports.useAugurApiOptional = useAugurApiOptional; exports.useAugurAuth = useAugurAuth; exports.useAugurCache = useAugurCache; exports.useAugurOptions = useAugurOptions; exports.useAugurPersistence = useAugurPersistence; exports.useAugurSite = useAugurSite; exports.useCartActions = useCartActions; exports.useCartHdrUid = _chunkF6GCIDEScjs.useCartHdrUid; exports.useCartInitialization = useCartInitialization; exports.useCartLineCount = _chunkF6GCIDEScjs.useCartLineCount; exports.useCartLines = _chunkF6GCIDEScjs.useCartLines; exports.useCartPricing = useCartPricing; exports.useCartQuantityTotal = _chunkF6GCIDEScjs.useCartQuantityTotal; exports.useCartStore = _chunkF6GCIDEScjs.useCartStore; exports.useCheckoutPersistence = _chunkF6GCIDEScjs.useCheckoutPersistence; exports.useClearCart = _chunkF6GCIDEScjs.useClearCart; exports.useDebounce = useDebounce; exports.useFormatPrice = useFormatPrice; exports.useItemFiltersStore = useItemFiltersStore; exports.useModalLifecycle = useModalLifecycle; exports.useOrderReadiness = _chunkF6GCIDEScjs.useOrderReadiness; exports.usePaginationPrefetch = usePaginationPrefetch; exports.usePaymentFlow = _chunkF6GCIDEScjs.usePaymentFlow; exports.useSetCartHdrUid = _chunkF6GCIDEScjs.useSetCartHdrUid; exports.useSetCartLines = _chunkF6GCIDEScjs.useSetCartLines; exports.useStock = useStock; exports.userWriteClearing = userWriteClearing;
|
|
1076
1080
|
//# sourceMappingURL=index.cjs.map
|