@konfiqo/storefront-react 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -1
- package/dist/index.cjs +111 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -2
- package/dist/index.d.ts +43 -2
- package/dist/index.js +103 -36
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, HTMLAttributes, ComponentType } from 'react';
|
|
3
|
-
import { Cart, AnyStorefrontError, CheckoutResult, CartIdStorage, StorefrontClientOptions, StorefrontClient, CategoryList, Product, ProductListQuery, ProductPage, Store, AddLineInput, UpdateLineInput, CustomerInput, AddressInput, RequestOptions, ShippingOptionList, Account, Order, PaymentPresentation, ClosedCheckoutPage, ContentNode, CookieCategory, CookieInfo, AdPixels } from '@konfiqo/storefront-sdk';
|
|
3
|
+
import { Cart, AnyStorefrontError, CheckoutResult, CartIdStorage, StorefrontClientOptions, StorefrontClient, CategoryList, Product, ProductListQuery, ProductPage, Store, AddLineInput, UpdateLineInput, CustomerInput, AddressInput, RequestOptions, ShippingOptionList, Account, Order, CreateReturnInput, OrderReturn, StorefrontError, PaymentPresentation, ClosedCheckoutPage, ContentNode, CookieCategory, CookieInfo, AdPixels } from '@konfiqo/storefront-sdk';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* An error a hook reports: a {@link StorefrontError} (narrow with
|
|
@@ -142,6 +142,13 @@ interface UseCartResult extends CartSnapshot {
|
|
|
142
142
|
setAddress(input: AddressInput): Promise<Cart>;
|
|
143
143
|
/** Selects a shipping option. */
|
|
144
144
|
setShippingOption(optionId: string): Promise<Cart>;
|
|
145
|
+
/**
|
|
146
|
+
* Enters a coupon code (one per cart). Rejects with `coupon_invalid`
|
|
147
|
+
* (`details.reason` `unknown` or `used_up`) and keeps the cart as it was.
|
|
148
|
+
*/
|
|
149
|
+
applyCode(code: string): Promise<Cart>;
|
|
150
|
+
/** Removes the cart's coupon code. */
|
|
151
|
+
removeCode(): Promise<Cart>;
|
|
145
152
|
/** The shipping options of the cart (`{ items: [] }` without a cart). */
|
|
146
153
|
shippingOptions(options?: RequestOptions): Promise<ShippingOptionList>;
|
|
147
154
|
/** Reads the cart again (a cart whose payment failed comes back `open`). */
|
|
@@ -276,6 +283,40 @@ interface UseOrderResult {
|
|
|
276
283
|
*/
|
|
277
284
|
declare function useOrder(orderId: string | null | undefined, token: string | null | undefined, options?: UseOrderOptions): UseOrderResult;
|
|
278
285
|
|
|
286
|
+
/** Options of {@link useReturnActions}. */
|
|
287
|
+
interface UseReturnActionsOptions {
|
|
288
|
+
/**
|
|
289
|
+
* Called after a return was opened or cancelled, e.g. to read the order
|
|
290
|
+
* again (`refetch()` of `useOrder`).
|
|
291
|
+
*/
|
|
292
|
+
onDone?: () => void;
|
|
293
|
+
}
|
|
294
|
+
/** What {@link useReturnActions} returns. */
|
|
295
|
+
interface UseReturnActionsResult {
|
|
296
|
+
/**
|
|
297
|
+
* Opens a return (`orders.createReturn`). Resolves with the return, or
|
|
298
|
+
* rejects with the error (also in `error`). A call while another action
|
|
299
|
+
* is in flight returns that action's promise, so a double click sends one
|
|
300
|
+
* request.
|
|
301
|
+
*/
|
|
302
|
+
create(input: CreateReturnInput): Promise<OrderReturn>;
|
|
303
|
+
/** Cancels a `requested` or `approved` return (`orders.cancelReturn`). */
|
|
304
|
+
cancel(returnId: string): Promise<OrderReturn>;
|
|
305
|
+
/** An action is in flight. */
|
|
306
|
+
pending: boolean;
|
|
307
|
+
/**
|
|
308
|
+
* The last action's error, or null. Cleared when the next action starts.
|
|
309
|
+
* Switch on `error.code`: `return_not_allowed` carries `details.reason`.
|
|
310
|
+
*/
|
|
311
|
+
error: StorefrontError | null;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Opens and cancels returns of one order for the buyer holding its token
|
|
315
|
+
* (the same `orderId` and `token` as `useOrder`). Like `useOrder`, it never
|
|
316
|
+
* logs the token or puts it anywhere but the request.
|
|
317
|
+
*/
|
|
318
|
+
declare function useReturnActions(orderId: string, token: string, opts?: UseReturnActionsOptions): UseReturnActionsResult;
|
|
319
|
+
|
|
279
320
|
/** Props of {@link PaymentForm}. */
|
|
280
321
|
interface PaymentFormProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onError'> {
|
|
281
322
|
/**
|
|
@@ -610,4 +651,4 @@ interface AdPixelsLoaderProps {
|
|
|
610
651
|
*/
|
|
611
652
|
declare function AdPixelsLoader({ pixels, hostOnly, currency, pathname, }: AdPixelsLoaderProps): null;
|
|
612
653
|
|
|
613
|
-
export { AdPixelsLoader, type AdPixelsLoaderProps, type AnalyticsEventType, type AnalyticsExtra, AnalyticsTracker, type AnalyticsTrackerProps, type CartSnapshot, type CheckoutCallOptions, CheckoutChallenge, type CheckoutChallengeHandle, type CheckoutChallengeProps, type CheckoutSnapshot, type ClientConfig, ConsentProvider, type ConsentProviderProps, type ConsentRecord, type ConsentState, Content, type ContentComponents, type ContentProps, OPTIONAL_CATEGORIES, ORDER_POLL_MAX_MS, ORDER_POLL_MIN_MS, type OptionalCookieCategory, PaymentForm, type PaymentFormProps, type PixelEvent, type ResourceResult, type StoredConsent, type StorefrontHookError, StorefrontProvider, type StorefrontProviderProps, type UseAccountResult, type UseCartResult, type UseCheckoutResult, type UseOrderOptions, type UseOrderResult, configureAnalytics, configurePixels, defaultCartStorage, firePixel, isDeadCartError, isOrderSettled, onSecretPage, orderPollDelay, recordConsent, renderContent, resetAnalytics, resetPixels, scrubbedLocation, track, useAccount, useCart, useCartStorage, useCategories, useCheckout, useConsent, useOrder, useProduct, useProducts, useStore, useStorefrontClient };
|
|
654
|
+
export { AdPixelsLoader, type AdPixelsLoaderProps, type AnalyticsEventType, type AnalyticsExtra, AnalyticsTracker, type AnalyticsTrackerProps, type CartSnapshot, type CheckoutCallOptions, CheckoutChallenge, type CheckoutChallengeHandle, type CheckoutChallengeProps, type CheckoutSnapshot, type ClientConfig, ConsentProvider, type ConsentProviderProps, type ConsentRecord, type ConsentState, Content, type ContentComponents, type ContentProps, OPTIONAL_CATEGORIES, ORDER_POLL_MAX_MS, ORDER_POLL_MIN_MS, type OptionalCookieCategory, PaymentForm, type PaymentFormProps, type PixelEvent, type ResourceResult, type StoredConsent, type StorefrontHookError, StorefrontProvider, type StorefrontProviderProps, type UseAccountResult, type UseCartResult, type UseCheckoutResult, type UseOrderOptions, type UseOrderResult, type UseReturnActionsOptions, type UseReturnActionsResult, configureAnalytics, configurePixels, defaultCartStorage, firePixel, isDeadCartError, isOrderSettled, onSecretPage, orderPollDelay, recordConsent, renderContent, resetAnalytics, resetPixels, scrubbedLocation, track, useAccount, useCart, useCartStorage, useCategories, useCheckout, useConsent, useOrder, useProduct, useProducts, useReturnActions, useStore, useStorefrontClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, HTMLAttributes, ComponentType } from 'react';
|
|
3
|
-
import { Cart, AnyStorefrontError, CheckoutResult, CartIdStorage, StorefrontClientOptions, StorefrontClient, CategoryList, Product, ProductListQuery, ProductPage, Store, AddLineInput, UpdateLineInput, CustomerInput, AddressInput, RequestOptions, ShippingOptionList, Account, Order, PaymentPresentation, ClosedCheckoutPage, ContentNode, CookieCategory, CookieInfo, AdPixels } from '@konfiqo/storefront-sdk';
|
|
3
|
+
import { Cart, AnyStorefrontError, CheckoutResult, CartIdStorage, StorefrontClientOptions, StorefrontClient, CategoryList, Product, ProductListQuery, ProductPage, Store, AddLineInput, UpdateLineInput, CustomerInput, AddressInput, RequestOptions, ShippingOptionList, Account, Order, CreateReturnInput, OrderReturn, StorefrontError, PaymentPresentation, ClosedCheckoutPage, ContentNode, CookieCategory, CookieInfo, AdPixels } from '@konfiqo/storefront-sdk';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* An error a hook reports: a {@link StorefrontError} (narrow with
|
|
@@ -142,6 +142,13 @@ interface UseCartResult extends CartSnapshot {
|
|
|
142
142
|
setAddress(input: AddressInput): Promise<Cart>;
|
|
143
143
|
/** Selects a shipping option. */
|
|
144
144
|
setShippingOption(optionId: string): Promise<Cart>;
|
|
145
|
+
/**
|
|
146
|
+
* Enters a coupon code (one per cart). Rejects with `coupon_invalid`
|
|
147
|
+
* (`details.reason` `unknown` or `used_up`) and keeps the cart as it was.
|
|
148
|
+
*/
|
|
149
|
+
applyCode(code: string): Promise<Cart>;
|
|
150
|
+
/** Removes the cart's coupon code. */
|
|
151
|
+
removeCode(): Promise<Cart>;
|
|
145
152
|
/** The shipping options of the cart (`{ items: [] }` without a cart). */
|
|
146
153
|
shippingOptions(options?: RequestOptions): Promise<ShippingOptionList>;
|
|
147
154
|
/** Reads the cart again (a cart whose payment failed comes back `open`). */
|
|
@@ -276,6 +283,40 @@ interface UseOrderResult {
|
|
|
276
283
|
*/
|
|
277
284
|
declare function useOrder(orderId: string | null | undefined, token: string | null | undefined, options?: UseOrderOptions): UseOrderResult;
|
|
278
285
|
|
|
286
|
+
/** Options of {@link useReturnActions}. */
|
|
287
|
+
interface UseReturnActionsOptions {
|
|
288
|
+
/**
|
|
289
|
+
* Called after a return was opened or cancelled, e.g. to read the order
|
|
290
|
+
* again (`refetch()` of `useOrder`).
|
|
291
|
+
*/
|
|
292
|
+
onDone?: () => void;
|
|
293
|
+
}
|
|
294
|
+
/** What {@link useReturnActions} returns. */
|
|
295
|
+
interface UseReturnActionsResult {
|
|
296
|
+
/**
|
|
297
|
+
* Opens a return (`orders.createReturn`). Resolves with the return, or
|
|
298
|
+
* rejects with the error (also in `error`). A call while another action
|
|
299
|
+
* is in flight returns that action's promise, so a double click sends one
|
|
300
|
+
* request.
|
|
301
|
+
*/
|
|
302
|
+
create(input: CreateReturnInput): Promise<OrderReturn>;
|
|
303
|
+
/** Cancels a `requested` or `approved` return (`orders.cancelReturn`). */
|
|
304
|
+
cancel(returnId: string): Promise<OrderReturn>;
|
|
305
|
+
/** An action is in flight. */
|
|
306
|
+
pending: boolean;
|
|
307
|
+
/**
|
|
308
|
+
* The last action's error, or null. Cleared when the next action starts.
|
|
309
|
+
* Switch on `error.code`: `return_not_allowed` carries `details.reason`.
|
|
310
|
+
*/
|
|
311
|
+
error: StorefrontError | null;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Opens and cancels returns of one order for the buyer holding its token
|
|
315
|
+
* (the same `orderId` and `token` as `useOrder`). Like `useOrder`, it never
|
|
316
|
+
* logs the token or puts it anywhere but the request.
|
|
317
|
+
*/
|
|
318
|
+
declare function useReturnActions(orderId: string, token: string, opts?: UseReturnActionsOptions): UseReturnActionsResult;
|
|
319
|
+
|
|
279
320
|
/** Props of {@link PaymentForm}. */
|
|
280
321
|
interface PaymentFormProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onError'> {
|
|
281
322
|
/**
|
|
@@ -610,4 +651,4 @@ interface AdPixelsLoaderProps {
|
|
|
610
651
|
*/
|
|
611
652
|
declare function AdPixelsLoader({ pixels, hostOnly, currency, pathname, }: AdPixelsLoaderProps): null;
|
|
612
653
|
|
|
613
|
-
export { AdPixelsLoader, type AdPixelsLoaderProps, type AnalyticsEventType, type AnalyticsExtra, AnalyticsTracker, type AnalyticsTrackerProps, type CartSnapshot, type CheckoutCallOptions, CheckoutChallenge, type CheckoutChallengeHandle, type CheckoutChallengeProps, type CheckoutSnapshot, type ClientConfig, ConsentProvider, type ConsentProviderProps, type ConsentRecord, type ConsentState, Content, type ContentComponents, type ContentProps, OPTIONAL_CATEGORIES, ORDER_POLL_MAX_MS, ORDER_POLL_MIN_MS, type OptionalCookieCategory, PaymentForm, type PaymentFormProps, type PixelEvent, type ResourceResult, type StoredConsent, type StorefrontHookError, StorefrontProvider, type StorefrontProviderProps, type UseAccountResult, type UseCartResult, type UseCheckoutResult, type UseOrderOptions, type UseOrderResult, configureAnalytics, configurePixels, defaultCartStorage, firePixel, isDeadCartError, isOrderSettled, onSecretPage, orderPollDelay, recordConsent, renderContent, resetAnalytics, resetPixels, scrubbedLocation, track, useAccount, useCart, useCartStorage, useCategories, useCheckout, useConsent, useOrder, useProduct, useProducts, useStore, useStorefrontClient };
|
|
654
|
+
export { AdPixelsLoader, type AdPixelsLoaderProps, type AnalyticsEventType, type AnalyticsExtra, AnalyticsTracker, type AnalyticsTrackerProps, type CartSnapshot, type CheckoutCallOptions, CheckoutChallenge, type CheckoutChallengeHandle, type CheckoutChallengeProps, type CheckoutSnapshot, type ClientConfig, ConsentProvider, type ConsentProviderProps, type ConsentRecord, type ConsentState, Content, type ContentComponents, type ContentProps, OPTIONAL_CATEGORIES, ORDER_POLL_MAX_MS, ORDER_POLL_MIN_MS, type OptionalCookieCategory, PaymentForm, type PaymentFormProps, type PixelEvent, type ResourceResult, type StoredConsent, type StorefrontHookError, StorefrontProvider, type StorefrontProviderProps, type UseAccountResult, type UseCartResult, type UseCheckoutResult, type UseOrderOptions, type UseOrderResult, type UseReturnActionsOptions, type UseReturnActionsResult, configureAnalytics, configurePixels, defaultCartStorage, firePixel, isDeadCartError, isOrderSettled, onSecretPage, orderPollDelay, recordConsent, renderContent, resetAnalytics, resetPixels, scrubbedLocation, track, useAccount, useCart, useCartStorage, useCategories, useCheckout, useConsent, useOrder, useProduct, useProducts, useReturnActions, useStore, useStorefrontClient };
|
package/dist/index.js
CHANGED
|
@@ -239,6 +239,8 @@ var CartStore = class {
|
|
|
239
239
|
setCustomer = (input) => this.write((id) => this.client.carts.setCustomer(id, input));
|
|
240
240
|
setAddress = (input) => this.write((id) => this.client.carts.setAddress(id, input));
|
|
241
241
|
setShippingOption = (optionId) => this.write((id) => this.client.carts.setShippingOption(id, optionId));
|
|
242
|
+
applyCode = (code) => this.write((id) => this.client.carts.applyCode(id, code));
|
|
243
|
+
removeCode = () => this.write((id) => this.client.carts.removeCode(id));
|
|
242
244
|
/** The shipping options of the cart (empty when there is no cart yet). */
|
|
243
245
|
shippingOptions = async (options) => {
|
|
244
246
|
const id = this.currentId();
|
|
@@ -603,6 +605,8 @@ function useCart() {
|
|
|
603
605
|
setCustomer: store.setCustomer,
|
|
604
606
|
setAddress: store.setAddress,
|
|
605
607
|
setShippingOption: store.setShippingOption,
|
|
608
|
+
applyCode: store.applyCode,
|
|
609
|
+
removeCode: store.removeCode,
|
|
606
610
|
shippingOptions: store.shippingOptions,
|
|
607
611
|
refresh: store.refresh,
|
|
608
612
|
reset: store.reset
|
|
@@ -792,8 +796,70 @@ function useOrder(orderId, token, options = {}) {
|
|
|
792
796
|
};
|
|
793
797
|
}
|
|
794
798
|
|
|
799
|
+
// src/use-return-actions.ts
|
|
800
|
+
import { useCallback as useCallback5, useEffect as useEffect7, useRef as useRef4, useState as useState4 } from "react";
|
|
801
|
+
import {
|
|
802
|
+
StorefrontError as StorefrontError2,
|
|
803
|
+
isStorefrontError as isStorefrontError4
|
|
804
|
+
} from "@konfiqo/storefront-sdk";
|
|
805
|
+
var asStorefrontError = (e) => isStorefrontError4(e) ? e : new StorefrontError2(
|
|
806
|
+
"network_error",
|
|
807
|
+
0,
|
|
808
|
+
e instanceof Error ? e.message : "Return request failed",
|
|
809
|
+
void 0,
|
|
810
|
+
{ cause: e }
|
|
811
|
+
);
|
|
812
|
+
function useReturnActions(orderId, token, opts = {}) {
|
|
813
|
+
const { client } = useStorefrontContext();
|
|
814
|
+
const [pending, setPending] = useState4(false);
|
|
815
|
+
const [error, setError] = useState4(null);
|
|
816
|
+
const inFlight = useRef4(null);
|
|
817
|
+
const alive = useRef4(true);
|
|
818
|
+
const onDone = useRef4(opts.onDone);
|
|
819
|
+
onDone.current = opts.onDone;
|
|
820
|
+
useEffect7(() => {
|
|
821
|
+
alive.current = true;
|
|
822
|
+
return () => {
|
|
823
|
+
alive.current = false;
|
|
824
|
+
};
|
|
825
|
+
}, []);
|
|
826
|
+
const run = useCallback5((action) => {
|
|
827
|
+
if (inFlight.current) return inFlight.current;
|
|
828
|
+
setPending(true);
|
|
829
|
+
setError(null);
|
|
830
|
+
const p = action().then(
|
|
831
|
+
(result) => {
|
|
832
|
+
inFlight.current = null;
|
|
833
|
+
if (alive.current) setPending(false);
|
|
834
|
+
onDone.current?.();
|
|
835
|
+
return result;
|
|
836
|
+
},
|
|
837
|
+
(e) => {
|
|
838
|
+
inFlight.current = null;
|
|
839
|
+
const err = asStorefrontError(e);
|
|
840
|
+
if (alive.current) {
|
|
841
|
+
setPending(false);
|
|
842
|
+
setError(err);
|
|
843
|
+
}
|
|
844
|
+
throw err;
|
|
845
|
+
}
|
|
846
|
+
);
|
|
847
|
+
inFlight.current = p;
|
|
848
|
+
return p;
|
|
849
|
+
}, []);
|
|
850
|
+
const create = useCallback5(
|
|
851
|
+
(input) => run(() => client.orders.createReturn(orderId, token, input)),
|
|
852
|
+
[client, orderId, token, run]
|
|
853
|
+
);
|
|
854
|
+
const cancel = useCallback5(
|
|
855
|
+
(returnId) => run(() => client.orders.cancelReturn(orderId, returnId, token)),
|
|
856
|
+
[client, orderId, token, run]
|
|
857
|
+
);
|
|
858
|
+
return { create, cancel, pending, error };
|
|
859
|
+
}
|
|
860
|
+
|
|
795
861
|
// src/payment-form.tsx
|
|
796
|
-
import { useEffect as
|
|
862
|
+
import { useEffect as useEffect8, useRef as useRef5 } from "react";
|
|
797
863
|
import {
|
|
798
864
|
mountPayment
|
|
799
865
|
} from "@konfiqo/storefront-sdk";
|
|
@@ -806,14 +872,14 @@ function PaymentForm({
|
|
|
806
872
|
onError,
|
|
807
873
|
...divProps
|
|
808
874
|
}) {
|
|
809
|
-
const ref =
|
|
810
|
-
const callbacks =
|
|
811
|
-
|
|
875
|
+
const ref = useRef5(null);
|
|
876
|
+
const callbacks = useRef5({ onClosed, onUnsupported, onError });
|
|
877
|
+
useEffect8(() => {
|
|
812
878
|
callbacks.current = { onClosed, onUnsupported, onError };
|
|
813
879
|
});
|
|
814
|
-
const pending =
|
|
815
|
-
const navigated =
|
|
816
|
-
|
|
880
|
+
const pending = useRef5(null);
|
|
881
|
+
const navigated = useRef5(null);
|
|
882
|
+
useEffect8(() => {
|
|
817
883
|
const element = ref.current;
|
|
818
884
|
if (!element) return;
|
|
819
885
|
const prev = pending.current;
|
|
@@ -860,20 +926,20 @@ function PaymentForm({
|
|
|
860
926
|
// src/checkout-challenge.tsx
|
|
861
927
|
import {
|
|
862
928
|
forwardRef,
|
|
863
|
-
useEffect as
|
|
929
|
+
useEffect as useEffect9,
|
|
864
930
|
useImperativeHandle,
|
|
865
|
-
useRef as
|
|
931
|
+
useRef as useRef6
|
|
866
932
|
} from "react";
|
|
867
933
|
import { renderTurnstile } from "@konfiqo/storefront-sdk";
|
|
868
934
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
869
935
|
var CheckoutChallenge = forwardRef(function CheckoutChallenge2({ siteKey, onToken, onExpired, onError, ...divProps }, handle) {
|
|
870
|
-
const ref =
|
|
871
|
-
const widget =
|
|
872
|
-
const callbacks =
|
|
873
|
-
|
|
936
|
+
const ref = useRef6(null);
|
|
937
|
+
const widget = useRef6(null);
|
|
938
|
+
const callbacks = useRef6({ onToken, onExpired, onError });
|
|
939
|
+
useEffect9(() => {
|
|
874
940
|
callbacks.current = { onToken, onExpired, onError };
|
|
875
941
|
});
|
|
876
|
-
|
|
942
|
+
useEffect9(() => {
|
|
877
943
|
const element = ref.current;
|
|
878
944
|
if (!element || !siteKey) return;
|
|
879
945
|
let active = true;
|
|
@@ -913,8 +979,8 @@ var CheckoutChallenge = forwardRef(function CheckoutChallenge2({ siteKey, onToke
|
|
|
913
979
|
};
|
|
914
980
|
useImperativeHandle(handle, () => ({ reset }), []);
|
|
915
981
|
const attempts = useCheckoutAttempts();
|
|
916
|
-
const seen =
|
|
917
|
-
|
|
982
|
+
const seen = useRef6(attempts);
|
|
983
|
+
useEffect9(() => {
|
|
918
984
|
if (attempts === seen.current) return;
|
|
919
985
|
seen.current = attempts;
|
|
920
986
|
reset();
|
|
@@ -925,7 +991,7 @@ var CheckoutChallenge = forwardRef(function CheckoutChallenge2({ siteKey, onToke
|
|
|
925
991
|
// src/content.tsx
|
|
926
992
|
import Markdoc from "@markdoc/markdoc";
|
|
927
993
|
import * as React from "react";
|
|
928
|
-
import { useEffect as
|
|
994
|
+
import { useEffect as useEffect10 } from "react";
|
|
929
995
|
import { formatMoney } from "@konfiqo/storefront-sdk";
|
|
930
996
|
import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
931
997
|
var HTML_TAGS = new Set(
|
|
@@ -1088,7 +1154,7 @@ function Content({ contentKey, components }) {
|
|
|
1088
1154
|
client,
|
|
1089
1155
|
(signal) => client.getContent(contentKey, { signal })
|
|
1090
1156
|
);
|
|
1091
|
-
|
|
1157
|
+
useEffect10(() => {
|
|
1092
1158
|
if (error && typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
|
|
1093
1159
|
console.warn(
|
|
1094
1160
|
`<Content contentKey="${contentKey}">: ${error.message || "could not be read"}`
|
|
@@ -1102,13 +1168,13 @@ function Content({ contentKey, components }) {
|
|
|
1102
1168
|
// src/consent-provider.tsx
|
|
1103
1169
|
import {
|
|
1104
1170
|
createContext as createContext2,
|
|
1105
|
-
useCallback as
|
|
1171
|
+
useCallback as useCallback6,
|
|
1106
1172
|
useContext as useContext2,
|
|
1107
|
-
useEffect as
|
|
1173
|
+
useEffect as useEffect11,
|
|
1108
1174
|
useInsertionEffect,
|
|
1109
1175
|
useMemo as useMemo3,
|
|
1110
|
-
useRef as
|
|
1111
|
-
useState as
|
|
1176
|
+
useRef as useRef7,
|
|
1177
|
+
useState as useState5,
|
|
1112
1178
|
useSyncExternalStore as useSyncExternalStore3
|
|
1113
1179
|
} from "react";
|
|
1114
1180
|
|
|
@@ -1206,10 +1272,10 @@ function ConsentProvider({
|
|
|
1206
1272
|
rawConsent,
|
|
1207
1273
|
serverSnapshot
|
|
1208
1274
|
);
|
|
1209
|
-
const [panelOpen, setPanelOpen] =
|
|
1210
|
-
const [decidedVersion, setDecidedVersion] =
|
|
1211
|
-
const opener =
|
|
1212
|
-
const onDecisionRef =
|
|
1275
|
+
const [panelOpen, setPanelOpen] = useState5(false);
|
|
1276
|
+
const [decidedVersion, setDecidedVersion] = useState5(null);
|
|
1277
|
+
const opener = useRef7(null);
|
|
1278
|
+
const onDecisionRef = useRef7(onDecision);
|
|
1213
1279
|
useInsertionEffect(() => {
|
|
1214
1280
|
onDecisionRef.current = onDecision;
|
|
1215
1281
|
});
|
|
@@ -1224,8 +1290,8 @@ function ConsentProvider({
|
|
|
1224
1290
|
);
|
|
1225
1291
|
const known = raw !== void 0;
|
|
1226
1292
|
const showBar = needed && known && !stored && decidedVersion !== version;
|
|
1227
|
-
const restorePending =
|
|
1228
|
-
|
|
1293
|
+
const restorePending = useRef7(false);
|
|
1294
|
+
useEffect11(() => {
|
|
1229
1295
|
if (panelOpen || !restorePending.current) return;
|
|
1230
1296
|
restorePending.current = false;
|
|
1231
1297
|
const target = opener.current;
|
|
@@ -1233,16 +1299,16 @@ function ConsentProvider({
|
|
|
1233
1299
|
if (target?.isConnected) target.focus();
|
|
1234
1300
|
else document.getElementById("main")?.focus({ preventScroll: true });
|
|
1235
1301
|
}, [panelOpen, showBar]);
|
|
1236
|
-
const open =
|
|
1302
|
+
const open = useCallback6((from) => {
|
|
1237
1303
|
const active = from ?? document.activeElement;
|
|
1238
1304
|
opener.current = active instanceof HTMLElement && active !== document.body ? active : null;
|
|
1239
1305
|
setPanelOpen(true);
|
|
1240
1306
|
}, []);
|
|
1241
|
-
const close =
|
|
1307
|
+
const close = useCallback6(() => {
|
|
1242
1308
|
if (panelOpen) restorePending.current = true;
|
|
1243
1309
|
setPanelOpen(false);
|
|
1244
1310
|
}, [panelOpen]);
|
|
1245
|
-
const decide =
|
|
1311
|
+
const decide = useCallback6(
|
|
1246
1312
|
(granted2) => {
|
|
1247
1313
|
const allowed = categories.filter((c) => granted2.includes(c));
|
|
1248
1314
|
const consentId = writeConsent(version, allowed);
|
|
@@ -1420,14 +1486,14 @@ function recordConsent(record) {
|
|
|
1420
1486
|
}
|
|
1421
1487
|
|
|
1422
1488
|
// src/analytics-tracker.tsx
|
|
1423
|
-
import { useEffect as
|
|
1489
|
+
import { useEffect as useEffect12 } from "react";
|
|
1424
1490
|
function AnalyticsTracker({
|
|
1425
1491
|
baseUrl,
|
|
1426
1492
|
publishableKey,
|
|
1427
1493
|
pathname
|
|
1428
1494
|
}) {
|
|
1429
1495
|
configureAnalytics({ baseUrl, publishableKey });
|
|
1430
|
-
|
|
1496
|
+
useEffect12(() => {
|
|
1431
1497
|
track("page_view");
|
|
1432
1498
|
}, [pathname]);
|
|
1433
1499
|
return null;
|
|
@@ -1904,7 +1970,7 @@ function google(rawGtag, g, e) {
|
|
|
1904
1970
|
}
|
|
1905
1971
|
|
|
1906
1972
|
// src/ad-pixels-loader.tsx
|
|
1907
|
-
import { useEffect as
|
|
1973
|
+
import { useEffect as useEffect13 } from "react";
|
|
1908
1974
|
function AdPixelsLoader({
|
|
1909
1975
|
pixels: pixels2,
|
|
1910
1976
|
hostOnly = false,
|
|
@@ -1913,11 +1979,11 @@ function AdPixelsLoader({
|
|
|
1913
1979
|
}) {
|
|
1914
1980
|
const { stored, known } = useConsent();
|
|
1915
1981
|
const granted2 = stored?.granted.includes("marketing") ?? false;
|
|
1916
|
-
|
|
1982
|
+
useEffect13(() => {
|
|
1917
1983
|
if (!known) return;
|
|
1918
1984
|
configurePixels(pixels2, granted2, { hostOnly, currency: currency2 });
|
|
1919
1985
|
}, [pixels2, granted2, known, hostOnly, currency2]);
|
|
1920
|
-
|
|
1986
|
+
useEffect13(() => {
|
|
1921
1987
|
if (granted2) firePixel({ name: "page_view" });
|
|
1922
1988
|
}, [granted2, pathname]);
|
|
1923
1989
|
return null;
|
|
@@ -1956,6 +2022,7 @@ export {
|
|
|
1956
2022
|
useOrder,
|
|
1957
2023
|
useProduct,
|
|
1958
2024
|
useProducts,
|
|
2025
|
+
useReturnActions,
|
|
1959
2026
|
useStore,
|
|
1960
2027
|
useStorefrontClient
|
|
1961
2028
|
};
|