@konfiqo/storefront-react 0.8.0 → 0.9.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 +107 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -2
- package/dist/index.d.ts +36 -2
- package/dist/index.js +99 -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
|
|
@@ -276,6 +276,40 @@ interface UseOrderResult {
|
|
|
276
276
|
*/
|
|
277
277
|
declare function useOrder(orderId: string | null | undefined, token: string | null | undefined, options?: UseOrderOptions): UseOrderResult;
|
|
278
278
|
|
|
279
|
+
/** Options of {@link useReturnActions}. */
|
|
280
|
+
interface UseReturnActionsOptions {
|
|
281
|
+
/**
|
|
282
|
+
* Called after a return was opened or cancelled, e.g. to read the order
|
|
283
|
+
* again (`refetch()` of `useOrder`).
|
|
284
|
+
*/
|
|
285
|
+
onDone?: () => void;
|
|
286
|
+
}
|
|
287
|
+
/** What {@link useReturnActions} returns. */
|
|
288
|
+
interface UseReturnActionsResult {
|
|
289
|
+
/**
|
|
290
|
+
* Opens a return (`orders.createReturn`). Resolves with the return, or
|
|
291
|
+
* rejects with the error (also in `error`). A call while another action
|
|
292
|
+
* is in flight returns that action's promise, so a double click sends one
|
|
293
|
+
* request.
|
|
294
|
+
*/
|
|
295
|
+
create(input: CreateReturnInput): Promise<OrderReturn>;
|
|
296
|
+
/** Cancels a `requested` or `approved` return (`orders.cancelReturn`). */
|
|
297
|
+
cancel(returnId: string): Promise<OrderReturn>;
|
|
298
|
+
/** An action is in flight. */
|
|
299
|
+
pending: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* The last action's error, or null. Cleared when the next action starts.
|
|
302
|
+
* Switch on `error.code`: `return_not_allowed` carries `details.reason`.
|
|
303
|
+
*/
|
|
304
|
+
error: StorefrontError | null;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Opens and cancels returns of one order for the buyer holding its token
|
|
308
|
+
* (the same `orderId` and `token` as `useOrder`). Like `useOrder`, it never
|
|
309
|
+
* logs the token or puts it anywhere but the request.
|
|
310
|
+
*/
|
|
311
|
+
declare function useReturnActions(orderId: string, token: string, opts?: UseReturnActionsOptions): UseReturnActionsResult;
|
|
312
|
+
|
|
279
313
|
/** Props of {@link PaymentForm}. */
|
|
280
314
|
interface PaymentFormProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onError'> {
|
|
281
315
|
/**
|
|
@@ -610,4 +644,4 @@ interface AdPixelsLoaderProps {
|
|
|
610
644
|
*/
|
|
611
645
|
declare function AdPixelsLoader({ pixels, hostOnly, currency, pathname, }: AdPixelsLoaderProps): null;
|
|
612
646
|
|
|
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 };
|
|
647
|
+
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
|
|
@@ -276,6 +276,40 @@ interface UseOrderResult {
|
|
|
276
276
|
*/
|
|
277
277
|
declare function useOrder(orderId: string | null | undefined, token: string | null | undefined, options?: UseOrderOptions): UseOrderResult;
|
|
278
278
|
|
|
279
|
+
/** Options of {@link useReturnActions}. */
|
|
280
|
+
interface UseReturnActionsOptions {
|
|
281
|
+
/**
|
|
282
|
+
* Called after a return was opened or cancelled, e.g. to read the order
|
|
283
|
+
* again (`refetch()` of `useOrder`).
|
|
284
|
+
*/
|
|
285
|
+
onDone?: () => void;
|
|
286
|
+
}
|
|
287
|
+
/** What {@link useReturnActions} returns. */
|
|
288
|
+
interface UseReturnActionsResult {
|
|
289
|
+
/**
|
|
290
|
+
* Opens a return (`orders.createReturn`). Resolves with the return, or
|
|
291
|
+
* rejects with the error (also in `error`). A call while another action
|
|
292
|
+
* is in flight returns that action's promise, so a double click sends one
|
|
293
|
+
* request.
|
|
294
|
+
*/
|
|
295
|
+
create(input: CreateReturnInput): Promise<OrderReturn>;
|
|
296
|
+
/** Cancels a `requested` or `approved` return (`orders.cancelReturn`). */
|
|
297
|
+
cancel(returnId: string): Promise<OrderReturn>;
|
|
298
|
+
/** An action is in flight. */
|
|
299
|
+
pending: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* The last action's error, or null. Cleared when the next action starts.
|
|
302
|
+
* Switch on `error.code`: `return_not_allowed` carries `details.reason`.
|
|
303
|
+
*/
|
|
304
|
+
error: StorefrontError | null;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Opens and cancels returns of one order for the buyer holding its token
|
|
308
|
+
* (the same `orderId` and `token` as `useOrder`). Like `useOrder`, it never
|
|
309
|
+
* logs the token or puts it anywhere but the request.
|
|
310
|
+
*/
|
|
311
|
+
declare function useReturnActions(orderId: string, token: string, opts?: UseReturnActionsOptions): UseReturnActionsResult;
|
|
312
|
+
|
|
279
313
|
/** Props of {@link PaymentForm}. */
|
|
280
314
|
interface PaymentFormProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onError'> {
|
|
281
315
|
/**
|
|
@@ -610,4 +644,4 @@ interface AdPixelsLoaderProps {
|
|
|
610
644
|
*/
|
|
611
645
|
declare function AdPixelsLoader({ pixels, hostOnly, currency, pathname, }: AdPixelsLoaderProps): null;
|
|
612
646
|
|
|
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 };
|
|
647
|
+
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
|
@@ -792,8 +792,70 @@ function useOrder(orderId, token, options = {}) {
|
|
|
792
792
|
};
|
|
793
793
|
}
|
|
794
794
|
|
|
795
|
+
// src/use-return-actions.ts
|
|
796
|
+
import { useCallback as useCallback5, useEffect as useEffect7, useRef as useRef4, useState as useState4 } from "react";
|
|
797
|
+
import {
|
|
798
|
+
StorefrontError as StorefrontError2,
|
|
799
|
+
isStorefrontError as isStorefrontError4
|
|
800
|
+
} from "@konfiqo/storefront-sdk";
|
|
801
|
+
var asStorefrontError = (e) => isStorefrontError4(e) ? e : new StorefrontError2(
|
|
802
|
+
"network_error",
|
|
803
|
+
0,
|
|
804
|
+
e instanceof Error ? e.message : "Return request failed",
|
|
805
|
+
void 0,
|
|
806
|
+
{ cause: e }
|
|
807
|
+
);
|
|
808
|
+
function useReturnActions(orderId, token, opts = {}) {
|
|
809
|
+
const { client } = useStorefrontContext();
|
|
810
|
+
const [pending, setPending] = useState4(false);
|
|
811
|
+
const [error, setError] = useState4(null);
|
|
812
|
+
const inFlight = useRef4(null);
|
|
813
|
+
const alive = useRef4(true);
|
|
814
|
+
const onDone = useRef4(opts.onDone);
|
|
815
|
+
onDone.current = opts.onDone;
|
|
816
|
+
useEffect7(() => {
|
|
817
|
+
alive.current = true;
|
|
818
|
+
return () => {
|
|
819
|
+
alive.current = false;
|
|
820
|
+
};
|
|
821
|
+
}, []);
|
|
822
|
+
const run = useCallback5((action) => {
|
|
823
|
+
if (inFlight.current) return inFlight.current;
|
|
824
|
+
setPending(true);
|
|
825
|
+
setError(null);
|
|
826
|
+
const p = action().then(
|
|
827
|
+
(result) => {
|
|
828
|
+
inFlight.current = null;
|
|
829
|
+
if (alive.current) setPending(false);
|
|
830
|
+
onDone.current?.();
|
|
831
|
+
return result;
|
|
832
|
+
},
|
|
833
|
+
(e) => {
|
|
834
|
+
inFlight.current = null;
|
|
835
|
+
const err = asStorefrontError(e);
|
|
836
|
+
if (alive.current) {
|
|
837
|
+
setPending(false);
|
|
838
|
+
setError(err);
|
|
839
|
+
}
|
|
840
|
+
throw err;
|
|
841
|
+
}
|
|
842
|
+
);
|
|
843
|
+
inFlight.current = p;
|
|
844
|
+
return p;
|
|
845
|
+
}, []);
|
|
846
|
+
const create = useCallback5(
|
|
847
|
+
(input) => run(() => client.orders.createReturn(orderId, token, input)),
|
|
848
|
+
[client, orderId, token, run]
|
|
849
|
+
);
|
|
850
|
+
const cancel = useCallback5(
|
|
851
|
+
(returnId) => run(() => client.orders.cancelReturn(orderId, returnId, token)),
|
|
852
|
+
[client, orderId, token, run]
|
|
853
|
+
);
|
|
854
|
+
return { create, cancel, pending, error };
|
|
855
|
+
}
|
|
856
|
+
|
|
795
857
|
// src/payment-form.tsx
|
|
796
|
-
import { useEffect as
|
|
858
|
+
import { useEffect as useEffect8, useRef as useRef5 } from "react";
|
|
797
859
|
import {
|
|
798
860
|
mountPayment
|
|
799
861
|
} from "@konfiqo/storefront-sdk";
|
|
@@ -806,14 +868,14 @@ function PaymentForm({
|
|
|
806
868
|
onError,
|
|
807
869
|
...divProps
|
|
808
870
|
}) {
|
|
809
|
-
const ref =
|
|
810
|
-
const callbacks =
|
|
811
|
-
|
|
871
|
+
const ref = useRef5(null);
|
|
872
|
+
const callbacks = useRef5({ onClosed, onUnsupported, onError });
|
|
873
|
+
useEffect8(() => {
|
|
812
874
|
callbacks.current = { onClosed, onUnsupported, onError };
|
|
813
875
|
});
|
|
814
|
-
const pending =
|
|
815
|
-
const navigated =
|
|
816
|
-
|
|
876
|
+
const pending = useRef5(null);
|
|
877
|
+
const navigated = useRef5(null);
|
|
878
|
+
useEffect8(() => {
|
|
817
879
|
const element = ref.current;
|
|
818
880
|
if (!element) return;
|
|
819
881
|
const prev = pending.current;
|
|
@@ -860,20 +922,20 @@ function PaymentForm({
|
|
|
860
922
|
// src/checkout-challenge.tsx
|
|
861
923
|
import {
|
|
862
924
|
forwardRef,
|
|
863
|
-
useEffect as
|
|
925
|
+
useEffect as useEffect9,
|
|
864
926
|
useImperativeHandle,
|
|
865
|
-
useRef as
|
|
927
|
+
useRef as useRef6
|
|
866
928
|
} from "react";
|
|
867
929
|
import { renderTurnstile } from "@konfiqo/storefront-sdk";
|
|
868
930
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
869
931
|
var CheckoutChallenge = forwardRef(function CheckoutChallenge2({ siteKey, onToken, onExpired, onError, ...divProps }, handle) {
|
|
870
|
-
const ref =
|
|
871
|
-
const widget =
|
|
872
|
-
const callbacks =
|
|
873
|
-
|
|
932
|
+
const ref = useRef6(null);
|
|
933
|
+
const widget = useRef6(null);
|
|
934
|
+
const callbacks = useRef6({ onToken, onExpired, onError });
|
|
935
|
+
useEffect9(() => {
|
|
874
936
|
callbacks.current = { onToken, onExpired, onError };
|
|
875
937
|
});
|
|
876
|
-
|
|
938
|
+
useEffect9(() => {
|
|
877
939
|
const element = ref.current;
|
|
878
940
|
if (!element || !siteKey) return;
|
|
879
941
|
let active = true;
|
|
@@ -913,8 +975,8 @@ var CheckoutChallenge = forwardRef(function CheckoutChallenge2({ siteKey, onToke
|
|
|
913
975
|
};
|
|
914
976
|
useImperativeHandle(handle, () => ({ reset }), []);
|
|
915
977
|
const attempts = useCheckoutAttempts();
|
|
916
|
-
const seen =
|
|
917
|
-
|
|
978
|
+
const seen = useRef6(attempts);
|
|
979
|
+
useEffect9(() => {
|
|
918
980
|
if (attempts === seen.current) return;
|
|
919
981
|
seen.current = attempts;
|
|
920
982
|
reset();
|
|
@@ -925,7 +987,7 @@ var CheckoutChallenge = forwardRef(function CheckoutChallenge2({ siteKey, onToke
|
|
|
925
987
|
// src/content.tsx
|
|
926
988
|
import Markdoc from "@markdoc/markdoc";
|
|
927
989
|
import * as React from "react";
|
|
928
|
-
import { useEffect as
|
|
990
|
+
import { useEffect as useEffect10 } from "react";
|
|
929
991
|
import { formatMoney } from "@konfiqo/storefront-sdk";
|
|
930
992
|
import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
931
993
|
var HTML_TAGS = new Set(
|
|
@@ -1088,7 +1150,7 @@ function Content({ contentKey, components }) {
|
|
|
1088
1150
|
client,
|
|
1089
1151
|
(signal) => client.getContent(contentKey, { signal })
|
|
1090
1152
|
);
|
|
1091
|
-
|
|
1153
|
+
useEffect10(() => {
|
|
1092
1154
|
if (error && typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
|
|
1093
1155
|
console.warn(
|
|
1094
1156
|
`<Content contentKey="${contentKey}">: ${error.message || "could not be read"}`
|
|
@@ -1102,13 +1164,13 @@ function Content({ contentKey, components }) {
|
|
|
1102
1164
|
// src/consent-provider.tsx
|
|
1103
1165
|
import {
|
|
1104
1166
|
createContext as createContext2,
|
|
1105
|
-
useCallback as
|
|
1167
|
+
useCallback as useCallback6,
|
|
1106
1168
|
useContext as useContext2,
|
|
1107
|
-
useEffect as
|
|
1169
|
+
useEffect as useEffect11,
|
|
1108
1170
|
useInsertionEffect,
|
|
1109
1171
|
useMemo as useMemo3,
|
|
1110
|
-
useRef as
|
|
1111
|
-
useState as
|
|
1172
|
+
useRef as useRef7,
|
|
1173
|
+
useState as useState5,
|
|
1112
1174
|
useSyncExternalStore as useSyncExternalStore3
|
|
1113
1175
|
} from "react";
|
|
1114
1176
|
|
|
@@ -1206,10 +1268,10 @@ function ConsentProvider({
|
|
|
1206
1268
|
rawConsent,
|
|
1207
1269
|
serverSnapshot
|
|
1208
1270
|
);
|
|
1209
|
-
const [panelOpen, setPanelOpen] =
|
|
1210
|
-
const [decidedVersion, setDecidedVersion] =
|
|
1211
|
-
const opener =
|
|
1212
|
-
const onDecisionRef =
|
|
1271
|
+
const [panelOpen, setPanelOpen] = useState5(false);
|
|
1272
|
+
const [decidedVersion, setDecidedVersion] = useState5(null);
|
|
1273
|
+
const opener = useRef7(null);
|
|
1274
|
+
const onDecisionRef = useRef7(onDecision);
|
|
1213
1275
|
useInsertionEffect(() => {
|
|
1214
1276
|
onDecisionRef.current = onDecision;
|
|
1215
1277
|
});
|
|
@@ -1224,8 +1286,8 @@ function ConsentProvider({
|
|
|
1224
1286
|
);
|
|
1225
1287
|
const known = raw !== void 0;
|
|
1226
1288
|
const showBar = needed && known && !stored && decidedVersion !== version;
|
|
1227
|
-
const restorePending =
|
|
1228
|
-
|
|
1289
|
+
const restorePending = useRef7(false);
|
|
1290
|
+
useEffect11(() => {
|
|
1229
1291
|
if (panelOpen || !restorePending.current) return;
|
|
1230
1292
|
restorePending.current = false;
|
|
1231
1293
|
const target = opener.current;
|
|
@@ -1233,16 +1295,16 @@ function ConsentProvider({
|
|
|
1233
1295
|
if (target?.isConnected) target.focus();
|
|
1234
1296
|
else document.getElementById("main")?.focus({ preventScroll: true });
|
|
1235
1297
|
}, [panelOpen, showBar]);
|
|
1236
|
-
const open =
|
|
1298
|
+
const open = useCallback6((from) => {
|
|
1237
1299
|
const active = from ?? document.activeElement;
|
|
1238
1300
|
opener.current = active instanceof HTMLElement && active !== document.body ? active : null;
|
|
1239
1301
|
setPanelOpen(true);
|
|
1240
1302
|
}, []);
|
|
1241
|
-
const close =
|
|
1303
|
+
const close = useCallback6(() => {
|
|
1242
1304
|
if (panelOpen) restorePending.current = true;
|
|
1243
1305
|
setPanelOpen(false);
|
|
1244
1306
|
}, [panelOpen]);
|
|
1245
|
-
const decide =
|
|
1307
|
+
const decide = useCallback6(
|
|
1246
1308
|
(granted2) => {
|
|
1247
1309
|
const allowed = categories.filter((c) => granted2.includes(c));
|
|
1248
1310
|
const consentId = writeConsent(version, allowed);
|
|
@@ -1420,14 +1482,14 @@ function recordConsent(record) {
|
|
|
1420
1482
|
}
|
|
1421
1483
|
|
|
1422
1484
|
// src/analytics-tracker.tsx
|
|
1423
|
-
import { useEffect as
|
|
1485
|
+
import { useEffect as useEffect12 } from "react";
|
|
1424
1486
|
function AnalyticsTracker({
|
|
1425
1487
|
baseUrl,
|
|
1426
1488
|
publishableKey,
|
|
1427
1489
|
pathname
|
|
1428
1490
|
}) {
|
|
1429
1491
|
configureAnalytics({ baseUrl, publishableKey });
|
|
1430
|
-
|
|
1492
|
+
useEffect12(() => {
|
|
1431
1493
|
track("page_view");
|
|
1432
1494
|
}, [pathname]);
|
|
1433
1495
|
return null;
|
|
@@ -1904,7 +1966,7 @@ function google(rawGtag, g, e) {
|
|
|
1904
1966
|
}
|
|
1905
1967
|
|
|
1906
1968
|
// src/ad-pixels-loader.tsx
|
|
1907
|
-
import { useEffect as
|
|
1969
|
+
import { useEffect as useEffect13 } from "react";
|
|
1908
1970
|
function AdPixelsLoader({
|
|
1909
1971
|
pixels: pixels2,
|
|
1910
1972
|
hostOnly = false,
|
|
@@ -1913,11 +1975,11 @@ function AdPixelsLoader({
|
|
|
1913
1975
|
}) {
|
|
1914
1976
|
const { stored, known } = useConsent();
|
|
1915
1977
|
const granted2 = stored?.granted.includes("marketing") ?? false;
|
|
1916
|
-
|
|
1978
|
+
useEffect13(() => {
|
|
1917
1979
|
if (!known) return;
|
|
1918
1980
|
configurePixels(pixels2, granted2, { hostOnly, currency: currency2 });
|
|
1919
1981
|
}, [pixels2, granted2, known, hostOnly, currency2]);
|
|
1920
|
-
|
|
1982
|
+
useEffect13(() => {
|
|
1921
1983
|
if (granted2) firePixel({ name: "page_view" });
|
|
1922
1984
|
}, [granted2, pathname]);
|
|
1923
1985
|
return null;
|
|
@@ -1956,6 +2018,7 @@ export {
|
|
|
1956
2018
|
useOrder,
|
|
1957
2019
|
useProduct,
|
|
1958
2020
|
useProducts,
|
|
2021
|
+
useReturnActions,
|
|
1959
2022
|
useStore,
|
|
1960
2023
|
useStorefrontClient
|
|
1961
2024
|
};
|