@behio/storefront-sdk 0.31.1 → 0.33.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/dist/{chunk-O7HDB5R4.mjs → chunk-5KJDVDUM.mjs} +78 -0
- package/dist/{chunk-NG46DR3A.js → chunk-Y4ZCK5HD.js} +78 -0
- package/dist/{client-D1GZSa-N.d.mts → client-BQlF_Vn9.d.mts} +377 -6
- package/dist/{client-D1GZSa-N.d.ts → client-BQlF_Vn9.d.ts} +377 -6
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/next.d.mts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/next.mjs +1 -1
- package/dist/react.d.mts +171 -3
- package/dist/react.d.ts +171 -3
- package/dist/react.js +240 -45
- package/dist/react.mjs +279 -84
- package/package.json +3 -3
package/dist/react.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var _chunkJIAOZ5YWjs = require('./chunk-JIAOZ5YW.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkY4ZCK5HDjs = require('./chunk-Y4ZCK5HD.js');
|
|
8
8
|
|
|
9
9
|
// src/react/provider.tsx
|
|
10
10
|
var _react = require('react');
|
|
@@ -134,7 +134,7 @@ function BehioProvider({
|
|
|
134
134
|
const [activeCurrency, setActiveCurrency] = _react.useState.call(void 0, resolveInitialCurrency);
|
|
135
135
|
const clientRef = _react.useRef.call(void 0, null);
|
|
136
136
|
if (!clientRef.current) {
|
|
137
|
-
clientRef.current = new (0,
|
|
137
|
+
clientRef.current = new (0, _chunkY4ZCK5HDjs.BehioStorefront)({
|
|
138
138
|
apiKey,
|
|
139
139
|
baseUrl,
|
|
140
140
|
...shopDomain ? { shopDomain } : {},
|
|
@@ -885,6 +885,44 @@ function useLoyalty(options) {
|
|
|
885
885
|
return { loyalty: data, isLoading, error, refetch };
|
|
886
886
|
}
|
|
887
887
|
|
|
888
|
+
// src/react/hooks/use-subscriptions.ts
|
|
889
|
+
|
|
890
|
+
var SUBSCRIPTIONS_KEY = ["behio", "subscriptions"];
|
|
891
|
+
function useSubscriptions(options) {
|
|
892
|
+
const { client } = useBehio();
|
|
893
|
+
const qc = _reactquery.useQueryClient.call(void 0, );
|
|
894
|
+
const query = _reactquery.useQuery.call(void 0, {
|
|
895
|
+
queryKey: [...SUBSCRIPTIONS_KEY],
|
|
896
|
+
queryFn: () => unwrap(client.subscriptions.list()),
|
|
897
|
+
enabled: _optionalChain([options, 'optionalAccess', _54 => _54.enabled]) !== false && !!client.getAccessToken()
|
|
898
|
+
});
|
|
899
|
+
const invalidate = () => qc.invalidateQueries({ queryKey: [...SUBSCRIPTIONS_KEY] });
|
|
900
|
+
const pauseMutation = _reactquery.useMutation.call(void 0, {
|
|
901
|
+
mutationFn: (subscriptionId) => unwrap(client.subscriptions.pause(subscriptionId)),
|
|
902
|
+
onSuccess: invalidate
|
|
903
|
+
});
|
|
904
|
+
const resumeMutation = _reactquery.useMutation.call(void 0, {
|
|
905
|
+
mutationFn: (subscriptionId) => unwrap(client.subscriptions.resume(subscriptionId)),
|
|
906
|
+
onSuccess: invalidate
|
|
907
|
+
});
|
|
908
|
+
const cancelMutation = _reactquery.useMutation.call(void 0, {
|
|
909
|
+
mutationFn: (subscriptionId) => unwrap(client.subscriptions.cancel(subscriptionId)),
|
|
910
|
+
onSuccess: invalidate
|
|
911
|
+
});
|
|
912
|
+
return {
|
|
913
|
+
subscriptions: _nullishCoalesce(_optionalChain([query, 'access', _55 => _55.data, 'optionalAccess', _56 => _56.items]), () => ( [])),
|
|
914
|
+
isLoading: query.isLoading,
|
|
915
|
+
error: query.error,
|
|
916
|
+
refetch: query.refetch,
|
|
917
|
+
pause: pauseMutation.mutateAsync,
|
|
918
|
+
resume: resumeMutation.mutateAsync,
|
|
919
|
+
cancel: cancelMutation.mutateAsync,
|
|
920
|
+
isPausing: pauseMutation.isPending,
|
|
921
|
+
isResuming: resumeMutation.isPending,
|
|
922
|
+
isCancelling: cancelMutation.isPending
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
|
|
888
926
|
// src/react/hooks/use-pickup-points.ts
|
|
889
927
|
|
|
890
928
|
function usePickupPoints(input) {
|
|
@@ -902,7 +940,158 @@ function usePickupPoints(input) {
|
|
|
902
940
|
),
|
|
903
941
|
enabled: enabled !== false && !!methodId
|
|
904
942
|
});
|
|
905
|
-
return { pickupPoints: _nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
943
|
+
return { pickupPoints: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _57 => _57.items]), () => ( [])), isLoading, error, refetch };
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
// src/react/hooks/use-shipping-methods.ts
|
|
947
|
+
|
|
948
|
+
function useShippingMethods(options) {
|
|
949
|
+
const { client, currency: activeCurrency } = useBehio();
|
|
950
|
+
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _58 => _58.currency]), () => ( activeCurrency));
|
|
951
|
+
const { country, cartTotal, cartWeightKg } = _nullishCoalesce(options, () => ( {}));
|
|
952
|
+
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
953
|
+
queryKey: [
|
|
954
|
+
"behio",
|
|
955
|
+
"shipping-methods",
|
|
956
|
+
_nullishCoalesce(currency, () => ( "")),
|
|
957
|
+
_nullishCoalesce(country, () => ( "")),
|
|
958
|
+
_nullishCoalesce(cartTotal, () => ( "")),
|
|
959
|
+
_nullishCoalesce(cartWeightKg, () => ( ""))
|
|
960
|
+
],
|
|
961
|
+
queryFn: () => unwrap(client.shipping.listMethods({ currency, country, cartTotal, cartWeightKg })),
|
|
962
|
+
enabled: _optionalChain([options, 'optionalAccess', _59 => _59.enabled]) !== false
|
|
963
|
+
});
|
|
964
|
+
return { methods: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _60 => _60.items]), () => ( [])), isLoading, error, refetch };
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// src/react/hooks/use-shipping-quote.ts
|
|
968
|
+
|
|
969
|
+
function useShippingQuote(options) {
|
|
970
|
+
const { client, currency: activeCurrency } = useBehio();
|
|
971
|
+
const { destinationAddress, items, cartTotal, enabled } = _nullishCoalesce(options, () => ( {}));
|
|
972
|
+
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _61 => _61.currency]), () => ( activeCurrency));
|
|
973
|
+
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
974
|
+
queryKey: [
|
|
975
|
+
"behio",
|
|
976
|
+
"shipping-quote",
|
|
977
|
+
JSON.stringify(_nullishCoalesce(destinationAddress, () => ( null))),
|
|
978
|
+
JSON.stringify(_nullishCoalesce(items, () => ( null))),
|
|
979
|
+
_nullishCoalesce(cartTotal, () => ( "")),
|
|
980
|
+
_nullishCoalesce(currency, () => ( ""))
|
|
981
|
+
],
|
|
982
|
+
queryFn: () => unwrap(
|
|
983
|
+
client.shipping.quote({
|
|
984
|
+
destinationAddress,
|
|
985
|
+
items,
|
|
986
|
+
cartTotal,
|
|
987
|
+
currency
|
|
988
|
+
})
|
|
989
|
+
),
|
|
990
|
+
enabled: enabled !== false && !!_optionalChain([destinationAddress, 'optionalAccess', _62 => _62.country])
|
|
991
|
+
});
|
|
992
|
+
return { quotes: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _63 => _63.items]), () => ( [])), isLoading, error, refetch };
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
// src/react/hooks/use-payment-methods.ts
|
|
996
|
+
|
|
997
|
+
function usePaymentMethods(options) {
|
|
998
|
+
const { client, currency: activeCurrency } = useBehio();
|
|
999
|
+
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _64 => _64.currency]), () => ( activeCurrency));
|
|
1000
|
+
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
1001
|
+
queryKey: ["behio", "payment-methods", _nullishCoalesce(currency, () => ( ""))],
|
|
1002
|
+
queryFn: () => unwrap(client.catalog.listPaymentMethods({ currency })),
|
|
1003
|
+
enabled: _optionalChain([options, 'optionalAccess', _65 => _65.enabled]) !== false
|
|
1004
|
+
});
|
|
1005
|
+
return { methods: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _66 => _66.items]), () => ( [])), isLoading, error, refetch };
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
// src/react/hooks/use-personal-offers.ts
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
function usePersonalOffers(options) {
|
|
1012
|
+
const { client } = useBehio();
|
|
1013
|
+
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
1014
|
+
const [polledVid, setPolledVid] = _react.useState.call(void 0, null);
|
|
1015
|
+
const explicitVid = _optionalChain([options, 'optionalAccess', _67 => _67.visitorId]);
|
|
1016
|
+
_react.useEffect.call(void 0, () => {
|
|
1017
|
+
if (explicitVid) return;
|
|
1018
|
+
const read = () => {
|
|
1019
|
+
const vid = client.getAnalyticsVisitorId();
|
|
1020
|
+
if (vid) setPolledVid(vid);
|
|
1021
|
+
return vid;
|
|
1022
|
+
};
|
|
1023
|
+
if (read()) return;
|
|
1024
|
+
const timer = setInterval(() => {
|
|
1025
|
+
if (read()) clearInterval(timer);
|
|
1026
|
+
}, 3e3);
|
|
1027
|
+
return () => clearInterval(timer);
|
|
1028
|
+
}, [client, explicitVid]);
|
|
1029
|
+
const visitorId = _nullishCoalesce(explicitVid, () => ( polledVid));
|
|
1030
|
+
const queryKey = ["behio", "personal-offers", _nullishCoalesce(visitorId, () => ( ""))];
|
|
1031
|
+
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
1032
|
+
queryKey,
|
|
1033
|
+
queryFn: () => unwrap(client.getPersonalOffers(visitorId)),
|
|
1034
|
+
enabled: _optionalChain([options, 'optionalAccess', _68 => _68.enabled]) !== false && !!visitorId
|
|
1035
|
+
});
|
|
1036
|
+
const claimMutation = _reactquery.useMutation.call(void 0, {
|
|
1037
|
+
mutationFn: ({ offerId, email }) => unwrap(client.claimOfferByEmail(offerId, { visitorId, email })),
|
|
1038
|
+
onSuccess: (result, { offerId }) => {
|
|
1039
|
+
queryClient.setQueryData(
|
|
1040
|
+
queryKey,
|
|
1041
|
+
(prev) => prev ? {
|
|
1042
|
+
items: prev.items.map(
|
|
1043
|
+
(o) => o.id === offerId ? { ...o, code: result.code, status: "CLAIMED" } : o
|
|
1044
|
+
)
|
|
1045
|
+
} : prev
|
|
1046
|
+
);
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
const claimByEmail = _react.useCallback.call(void 0,
|
|
1050
|
+
(offerId, email) => claimMutation.mutateAsync({ offerId, email }),
|
|
1051
|
+
[claimMutation]
|
|
1052
|
+
);
|
|
1053
|
+
return {
|
|
1054
|
+
offers: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _69 => _69.items]), () => ( [])),
|
|
1055
|
+
/** Resolved consent-gated visitor id (null before consent). */
|
|
1056
|
+
visitorId: _nullishCoalesce(visitorId, () => ( null)),
|
|
1057
|
+
isLoading,
|
|
1058
|
+
error,
|
|
1059
|
+
refetch,
|
|
1060
|
+
/** E-mail gate: trade an e-mail for the discount code of the given offer. */
|
|
1061
|
+
claimByEmail,
|
|
1062
|
+
isClaiming: claimMutation.isPending,
|
|
1063
|
+
claimError: claimMutation.error
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
// src/react/hooks/use-analytics-events.ts
|
|
1068
|
+
|
|
1069
|
+
function useAnalyticsEvents() {
|
|
1070
|
+
const { client } = useBehio();
|
|
1071
|
+
const track = _react.useCallback.call(void 0,
|
|
1072
|
+
(events, opts) => {
|
|
1073
|
+
const list = Array.isArray(events) ? events : [events];
|
|
1074
|
+
if (list.length === 0) return Promise.resolve();
|
|
1075
|
+
return client.sendAnalyticsEvents({
|
|
1076
|
+
sessionId: _optionalChain([opts, 'optionalAccess', _70 => _70.sessionId]),
|
|
1077
|
+
visitorId: _nullishCoalesce(client.getAnalyticsVisitorId(), () => ( void 0)),
|
|
1078
|
+
events: list.map((e) => ({ ts: Date.now(), ...e }))
|
|
1079
|
+
});
|
|
1080
|
+
},
|
|
1081
|
+
[client]
|
|
1082
|
+
);
|
|
1083
|
+
const trackEvent = _react.useCallback.call(void 0,
|
|
1084
|
+
(name, props) => track({ type: "custom", name, props }),
|
|
1085
|
+
[track]
|
|
1086
|
+
);
|
|
1087
|
+
return {
|
|
1088
|
+
/** Send one or more raw analytics events. */
|
|
1089
|
+
track,
|
|
1090
|
+
/** Convenience: send a named `custom` event with optional props. */
|
|
1091
|
+
trackEvent,
|
|
1092
|
+
/** Consent-gated visitor id, null before analytics consent. */
|
|
1093
|
+
getVisitorId: () => client.getAnalyticsVisitorId()
|
|
1094
|
+
};
|
|
906
1095
|
}
|
|
907
1096
|
|
|
908
1097
|
// src/react/hooks/use-newsletter.ts
|
|
@@ -936,10 +1125,10 @@ function useOrders(options) {
|
|
|
936
1125
|
enabled: enabled !== false && !!client.getAccessToken()
|
|
937
1126
|
});
|
|
938
1127
|
const items = _react.useMemo.call(void 0,
|
|
939
|
-
() => _nullishCoalesce(_optionalChain([infinite, 'access',
|
|
1128
|
+
() => _nullishCoalesce(_optionalChain([infinite, 'access', _71 => _71.data, 'optionalAccess', _72 => _72.pages, 'access', _73 => _73.flatMap, 'call', _74 => _74((p) => p.items)]), () => ( [])),
|
|
940
1129
|
[infinite.data]
|
|
941
1130
|
);
|
|
942
|
-
const lastPage = _optionalChain([infinite, 'access',
|
|
1131
|
+
const lastPage = _optionalChain([infinite, 'access', _75 => _75.data, 'optionalAccess', _76 => _76.pages, 'access', _77 => _77[infinite.data.pages.length - 1]]);
|
|
943
1132
|
const loadMore = _react.useCallback.call(void 0, () => {
|
|
944
1133
|
if (infinite.hasNextPage && !infinite.isFetchingNextPage) {
|
|
945
1134
|
return infinite.fetchNextPage();
|
|
@@ -952,10 +1141,10 @@ function useOrders(options) {
|
|
|
952
1141
|
return {
|
|
953
1142
|
items,
|
|
954
1143
|
data: infinite.data,
|
|
955
|
-
total: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess',
|
|
956
|
-
totalPages: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess',
|
|
957
|
-
currentPage: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess',
|
|
958
|
-
limit: _nullishCoalesce(_nullishCoalesce(_optionalChain([lastPage, 'optionalAccess',
|
|
1144
|
+
total: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _78 => _78.total]), () => ( 0)),
|
|
1145
|
+
totalPages: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _79 => _79.totalPages]), () => ( 0)),
|
|
1146
|
+
currentPage: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _80 => _80.page]), () => ( page)),
|
|
1147
|
+
limit: _nullishCoalesce(_nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _81 => _81.limit]), () => ( limit)), () => ( 20)),
|
|
959
1148
|
page,
|
|
960
1149
|
setPage: goToPage,
|
|
961
1150
|
loadMore,
|
|
@@ -984,7 +1173,7 @@ function useOrder(orderNumber, options) {
|
|
|
984
1173
|
} = _reactquery.useQuery.call(void 0, {
|
|
985
1174
|
queryKey: ["behio", "order", orderNumber],
|
|
986
1175
|
queryFn: () => unwrap(client.orders.get(orderNumber)),
|
|
987
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1176
|
+
enabled: _optionalChain([options, 'optionalAccess', _82 => _82.enabled]) !== false && !!orderNumber && !!client.getAccessToken()
|
|
988
1177
|
});
|
|
989
1178
|
const cancelMutation = _reactquery.useMutation.call(void 0, {
|
|
990
1179
|
mutationFn: () => unwrap(client.orders.cancel(orderNumber)),
|
|
@@ -1109,7 +1298,7 @@ function usePages(locale, options) {
|
|
|
1109
1298
|
const result = await unwrap(client.pages.list(locale));
|
|
1110
1299
|
return result.pages;
|
|
1111
1300
|
},
|
|
1112
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1301
|
+
enabled: _optionalChain([options, 'optionalAccess', _83 => _83.enabled]) !== false
|
|
1113
1302
|
});
|
|
1114
1303
|
}
|
|
1115
1304
|
function usePage(slug, locale, options) {
|
|
@@ -1117,7 +1306,7 @@ function usePage(slug, locale, options) {
|
|
|
1117
1306
|
return _reactquery.useQuery.call(void 0, {
|
|
1118
1307
|
queryKey: ["behio", "page", slug, locale],
|
|
1119
1308
|
queryFn: () => unwrap(client.pages.get(slug, locale)),
|
|
1120
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1309
|
+
enabled: _optionalChain([options, 'optionalAccess', _84 => _84.enabled]) !== false && !!slug
|
|
1121
1310
|
});
|
|
1122
1311
|
}
|
|
1123
1312
|
|
|
@@ -1128,7 +1317,7 @@ function useShopInfo(options) {
|
|
|
1128
1317
|
return _reactquery.useQuery.call(void 0, {
|
|
1129
1318
|
queryKey: ["behio", "shop-info"],
|
|
1130
1319
|
queryFn: () => unwrap(client.getShopInfo()),
|
|
1131
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1320
|
+
enabled: _optionalChain([options, 'optionalAccess', _85 => _85.enabled]) !== false
|
|
1132
1321
|
});
|
|
1133
1322
|
}
|
|
1134
1323
|
|
|
@@ -1139,7 +1328,7 @@ function useShopScripts(options) {
|
|
|
1139
1328
|
return _reactquery.useQuery.call(void 0, {
|
|
1140
1329
|
queryKey: ["behio", "shop-scripts"],
|
|
1141
1330
|
queryFn: () => unwrap(client.getShopScripts()),
|
|
1142
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1331
|
+
enabled: _optionalChain([options, 'optionalAccess', _86 => _86.enabled]) !== false
|
|
1143
1332
|
});
|
|
1144
1333
|
}
|
|
1145
1334
|
|
|
@@ -1167,8 +1356,8 @@ function dedupe(values) {
|
|
|
1167
1356
|
function useCurrency() {
|
|
1168
1357
|
const { currency, setCurrency, configuredDefaultCurrency, configuredCurrencies } = useBehio();
|
|
1169
1358
|
const { data: shop, isLoading } = useShopInfo();
|
|
1170
|
-
const defaultCurrency = _nullishCoalesce(configuredDefaultCurrency, () => ( _optionalChain([shop, 'optionalAccess',
|
|
1171
|
-
const currencies = configuredCurrencies && configuredCurrencies.length > 0 ? dedupe(configuredCurrencies) : dedupe([defaultCurrency, ..._nullishCoalesce(_optionalChain([shop, 'optionalAccess',
|
|
1359
|
+
const defaultCurrency = _nullishCoalesce(configuredDefaultCurrency, () => ( _optionalChain([shop, 'optionalAccess', _87 => _87.defaultCurrency])));
|
|
1360
|
+
const currencies = configuredCurrencies && configuredCurrencies.length > 0 ? dedupe(configuredCurrencies) : dedupe([defaultCurrency, ..._nullishCoalesce(_optionalChain([shop, 'optionalAccess', _88 => _88.supportedCurrencies]), () => ( []))]);
|
|
1172
1361
|
return {
|
|
1173
1362
|
currency,
|
|
1174
1363
|
effectiveCurrency: _nullishCoalesce(currency, () => ( defaultCurrency)),
|
|
@@ -1191,7 +1380,7 @@ function CurrencySwitcher({
|
|
|
1191
1380
|
const { currencies, effectiveCurrency, setCurrency } = useCurrency();
|
|
1192
1381
|
if (currencies.length === 0) return null;
|
|
1193
1382
|
if (currencies.length <= 1 && !showWhenSingle) return null;
|
|
1194
|
-
const label = (code) => _nullishCoalesce(_optionalChain([labels, 'optionalAccess',
|
|
1383
|
+
const label = (code) => _nullishCoalesce(_optionalChain([labels, 'optionalAccess', _89 => _89[code]]), () => ( code));
|
|
1195
1384
|
if (children) {
|
|
1196
1385
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: children({ currencies, value: effectiveCurrency, setCurrency, label }) });
|
|
1197
1386
|
}
|
|
@@ -1308,9 +1497,9 @@ function StorefrontScripts({ visitorId: visitorIdProp } = {}) {
|
|
|
1308
1497
|
}
|
|
1309
1498
|
}, [visitorIdProp]);
|
|
1310
1499
|
const { data: consent } = useCookieConsent(visitorId || void 0);
|
|
1311
|
-
const analyticsOk = Boolean(_optionalChain([consent, 'optionalAccess',
|
|
1500
|
+
const analyticsOk = Boolean(_optionalChain([consent, 'optionalAccess', _90 => _90.analytics]));
|
|
1312
1501
|
const scripts = _react.useMemo.call(void 0,
|
|
1313
|
-
() => (_nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
1502
|
+
() => (_nullishCoalesce(_optionalChain([data, 'optionalAccess', _91 => _91.scripts]), () => ( []))).filter((s) => !s.consentRequired || analyticsOk),
|
|
1314
1503
|
[data, analyticsOk]
|
|
1315
1504
|
);
|
|
1316
1505
|
const signature = _react.useMemo.call(void 0,
|
|
@@ -1375,7 +1564,7 @@ function initTracker(client) {
|
|
|
1375
1564
|
return;
|
|
1376
1565
|
}
|
|
1377
1566
|
const { data } = await client.consent.get(stored);
|
|
1378
|
-
const granted = Boolean(_optionalChain([data, 'optionalAccess',
|
|
1567
|
+
const granted = Boolean(_optionalChain([data, 'optionalAccess', _92 => _92.analytics]));
|
|
1379
1568
|
visitorId = granted ? stored : void 0;
|
|
1380
1569
|
client.setAnalyticsVisitorId(granted ? stored : null);
|
|
1381
1570
|
} catch (e7) {
|
|
@@ -1459,7 +1648,7 @@ function initTracker(client) {
|
|
|
1459
1648
|
};
|
|
1460
1649
|
const onClick = (ev) => {
|
|
1461
1650
|
const target = ev.target;
|
|
1462
|
-
const el = _optionalChain([target, 'optionalAccess',
|
|
1651
|
+
const el = _optionalChain([target, 'optionalAccess', _93 => _93.closest, 'optionalCall', _94 => _94("a,button,[role=button],[data-behio-event]")]);
|
|
1463
1652
|
if (!el) return;
|
|
1464
1653
|
const explicit = _nullishCoalesce(el.getAttribute("data-behio-event"), () => ( void 0));
|
|
1465
1654
|
const text = (_nullishCoalesce(el.textContent, () => ( ""))).trim().replace(/\s+/g, " ").slice(0, 80) || void 0;
|
|
@@ -1500,7 +1689,7 @@ function initTracker(client) {
|
|
|
1500
1689
|
items: payload.items.length,
|
|
1501
1690
|
// First item id = the product (view_item/add_to_cart are
|
|
1502
1691
|
// single-product in practice) - Behavioral Offers count on it.
|
|
1503
|
-
itemId: _optionalChain([payload, 'access',
|
|
1692
|
+
itemId: _optionalChain([payload, 'access', _95 => _95.items, 'access', _96 => _96[0], 'optionalAccess', _97 => _97.item_id])
|
|
1504
1693
|
}
|
|
1505
1694
|
} : {}
|
|
1506
1695
|
});
|
|
@@ -1562,8 +1751,8 @@ function useBundles(options) {
|
|
|
1562
1751
|
return _reactquery.useQuery.call(void 0, {
|
|
1563
1752
|
queryKey: ["behio", "bundles"],
|
|
1564
1753
|
queryFn: () => unwrap(client.catalog.getBundles()),
|
|
1565
|
-
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1566
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1754
|
+
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _98 => _98.enabled]), () => ( true)),
|
|
1755
|
+
initialData: _optionalChain([options, 'optionalAccess', _99 => _99.initialData])
|
|
1567
1756
|
});
|
|
1568
1757
|
}
|
|
1569
1758
|
function useBundle(slug, options) {
|
|
@@ -1571,8 +1760,8 @@ function useBundle(slug, options) {
|
|
|
1571
1760
|
return _reactquery.useQuery.call(void 0, {
|
|
1572
1761
|
queryKey: ["behio", "bundle", slug],
|
|
1573
1762
|
queryFn: () => unwrap(client.catalog.getBundle(slug)),
|
|
1574
|
-
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1575
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1763
|
+
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _100 => _100.enabled]), () => ( true))),
|
|
1764
|
+
initialData: _optionalChain([options, 'optionalAccess', _101 => _101.initialData])
|
|
1576
1765
|
});
|
|
1577
1766
|
}
|
|
1578
1767
|
|
|
@@ -1581,15 +1770,15 @@ function useBundle(slug, options) {
|
|
|
1581
1770
|
function useProductGroup(slug, options) {
|
|
1582
1771
|
const { client } = useBehio();
|
|
1583
1772
|
return _reactquery.useQuery.call(void 0, {
|
|
1584
|
-
queryKey: ["behio", "product-group", slug, _optionalChain([options, 'optionalAccess',
|
|
1773
|
+
queryKey: ["behio", "product-group", slug, _optionalChain([options, 'optionalAccess', _102 => _102.locale]), _optionalChain([options, 'optionalAccess', _103 => _103.currency])],
|
|
1585
1774
|
queryFn: () => unwrap(
|
|
1586
1775
|
client.catalog.getProductGroup(slug, {
|
|
1587
|
-
locale: _optionalChain([options, 'optionalAccess',
|
|
1588
|
-
currency: _optionalChain([options, 'optionalAccess',
|
|
1776
|
+
locale: _optionalChain([options, 'optionalAccess', _104 => _104.locale]),
|
|
1777
|
+
currency: _optionalChain([options, 'optionalAccess', _105 => _105.currency])
|
|
1589
1778
|
})
|
|
1590
1779
|
),
|
|
1591
|
-
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1592
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1780
|
+
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _106 => _106.enabled]), () => ( true))),
|
|
1781
|
+
initialData: _optionalChain([options, 'optionalAccess', _107 => _107.initialData])
|
|
1593
1782
|
});
|
|
1594
1783
|
}
|
|
1595
1784
|
|
|
@@ -1598,15 +1787,15 @@ function useProductGroup(slug, options) {
|
|
|
1598
1787
|
function useCrossSell(productSlug, options) {
|
|
1599
1788
|
const { client } = useBehio();
|
|
1600
1789
|
return _reactquery.useQuery.call(void 0, {
|
|
1601
|
-
queryKey: ["behio", "cross-sell", productSlug, _optionalChain([options, 'optionalAccess',
|
|
1790
|
+
queryKey: ["behio", "cross-sell", productSlug, _optionalChain([options, 'optionalAccess', _108 => _108.locale]), _optionalChain([options, 'optionalAccess', _109 => _109.currency])],
|
|
1602
1791
|
queryFn: () => unwrap(
|
|
1603
1792
|
client.catalog.getCrossSell(productSlug, {
|
|
1604
|
-
locale: _optionalChain([options, 'optionalAccess',
|
|
1605
|
-
currency: _optionalChain([options, 'optionalAccess',
|
|
1793
|
+
locale: _optionalChain([options, 'optionalAccess', _110 => _110.locale]),
|
|
1794
|
+
currency: _optionalChain([options, 'optionalAccess', _111 => _111.currency])
|
|
1606
1795
|
})
|
|
1607
1796
|
),
|
|
1608
|
-
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1609
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1797
|
+
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _112 => _112.enabled]), () => ( true))),
|
|
1798
|
+
initialData: _optionalChain([options, 'optionalAccess', _113 => _113.initialData])
|
|
1610
1799
|
});
|
|
1611
1800
|
}
|
|
1612
1801
|
|
|
@@ -1617,8 +1806,8 @@ function useProductPromotions(productSlug, options) {
|
|
|
1617
1806
|
return _reactquery.useQuery.call(void 0, {
|
|
1618
1807
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
1619
1808
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
1620
|
-
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1621
|
-
refetchInterval: _optionalChain([options, 'optionalAccess',
|
|
1809
|
+
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _114 => _114.enabled]), () => ( true))),
|
|
1810
|
+
refetchInterval: _optionalChain([options, 'optionalAccess', _115 => _115.refetchIntervalMs])
|
|
1622
1811
|
});
|
|
1623
1812
|
}
|
|
1624
1813
|
|
|
@@ -1626,11 +1815,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
1626
1815
|
|
|
1627
1816
|
function useGiftCardBalance(code, options) {
|
|
1628
1817
|
const { client } = useBehio();
|
|
1629
|
-
const trimmed = _optionalChain([code, 'optionalAccess',
|
|
1818
|
+
const trimmed = _optionalChain([code, 'optionalAccess', _116 => _116.trim, 'call', _117 => _117()]);
|
|
1630
1819
|
return _reactquery.useQuery.call(void 0, {
|
|
1631
1820
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
1632
1821
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
1633
|
-
enabled: Boolean(trimmed && trimmed.length >= 6) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1822
|
+
enabled: Boolean(trimmed && trimmed.length >= 6) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _118 => _118.enabled]), () => ( true)))
|
|
1634
1823
|
});
|
|
1635
1824
|
}
|
|
1636
1825
|
|
|
@@ -1642,7 +1831,7 @@ function useWishlist(options) {
|
|
|
1642
1831
|
const query = _reactquery.useQuery.call(void 0, {
|
|
1643
1832
|
queryKey: ["behio", "wishlist"],
|
|
1644
1833
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
1645
|
-
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1834
|
+
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _119 => _119.enabled]), () => ( true))
|
|
1646
1835
|
});
|
|
1647
1836
|
const addMutation = _reactquery.useMutation.call(void 0, {
|
|
1648
1837
|
mutationFn: (productId) => unwrap(client.wishlist.add(productId)),
|
|
@@ -1674,9 +1863,9 @@ function useIsInWishlist(productId) {
|
|
|
1674
1863
|
function useProductReviews(productId, options) {
|
|
1675
1864
|
const { client } = useBehio();
|
|
1676
1865
|
return _reactquery.useQuery.call(void 0, {
|
|
1677
|
-
queryKey: ["behio", "reviews", productId, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1678
|
-
queryFn: () => unwrap(client.reviews.getProductReviews(productId, _optionalChain([options, 'optionalAccess',
|
|
1679
|
-
enabled: Boolean(productId) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1866
|
+
queryKey: ["behio", "reviews", productId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _120 => _120.page]), () => ( 1))],
|
|
1867
|
+
queryFn: () => unwrap(client.reviews.getProductReviews(productId, _optionalChain([options, 'optionalAccess', _121 => _121.page]), _optionalChain([options, 'optionalAccess', _122 => _122.limit]))),
|
|
1868
|
+
enabled: Boolean(productId) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _123 => _123.enabled]), () => ( true)))
|
|
1680
1869
|
});
|
|
1681
1870
|
}
|
|
1682
1871
|
function useSubmitReview() {
|
|
@@ -1796,4 +1985,10 @@ function useNotifyWhenAvailable() {
|
|
|
1796
1985
|
|
|
1797
1986
|
|
|
1798
1987
|
|
|
1799
|
-
|
|
1988
|
+
|
|
1989
|
+
|
|
1990
|
+
|
|
1991
|
+
|
|
1992
|
+
|
|
1993
|
+
|
|
1994
|
+
exports.BehioAnalyticsTracker = BehioAnalyticsTracker; exports.BehioProvider = BehioProvider; exports.CurrencySwitcher = CurrencySwitcher; exports.StorefrontScripts = StorefrontScripts; exports.cookieStorage = cookieStorage; exports.createMemoryStorage = createMemoryStorage; exports.detectStorage = detectStorage; exports.formatPrice = _chunkJIAOZ5YWjs.formatPrice; exports.localStorageAdapter = localStorageAdapter; exports.memoryStorage = memoryStorage; exports.trackEcommerceEvent = _chunkJIAOZ5YWjs.trackEcommerceEvent; exports.useAddressAutocomplete = useAddressAutocomplete; exports.useAddresses = useAddresses; exports.useAnalyticsEvents = useAnalyticsEvents; exports.useAuth = useAuth; exports.useBehio = useBehio; exports.useBehioClient = useBehioClient; exports.useBundle = useBundle; exports.useBundles = useBundles; exports.useCart = useCart; exports.useCartCount = useCartCount; exports.useCategories = useCategories; exports.useCategory = useCategory; exports.useCheckout = useCheckout; exports.useCookieConsent = useCookieConsent; exports.useCrossSell = useCrossSell; exports.useCurrency = useCurrency; exports.useCustomer = useCustomer; exports.useFeatured = useFeatured; exports.useFilters = useFilters; exports.useGiftCardBalance = useGiftCardBalance; exports.useIsInWishlist = useIsInWishlist; exports.useLabels = useLabels; exports.useLookupReturnableOrder = useLookupReturnableOrder; exports.useLoyalty = useLoyalty; exports.useMenu = useMenu; exports.useNewsletterSubscribe = useNewsletterSubscribe; exports.useNewsletterUnsubscribe = useNewsletterUnsubscribe; exports.useNotifyWhenAvailable = useNotifyWhenAvailable; exports.useOrder = useOrder; exports.useOrderAccess = useOrderAccess; exports.useOrders = useOrders; exports.usePage = usePage; exports.usePages = usePages; exports.usePaymentMethods = usePaymentMethods; exports.usePersonalOffers = usePersonalOffers; exports.usePickupPoints = usePickupPoints; exports.useProduct = useProduct; exports.useProductGroup = useProductGroup; exports.useProductPromotions = useProductPromotions; exports.useProductReviews = useProductReviews; exports.useProducts = useProducts; exports.useQuoteStatus = useQuoteStatus; exports.useReturnStatus = useReturnStatus; exports.useSearch = useSearch; exports.useShippingMethods = useShippingMethods; exports.useShippingQuote = useShippingQuote; exports.useShopInfo = useShopInfo; exports.useShopScripts = useShopScripts; exports.useShopSeo = useShopSeo; exports.useSubmitQuote = useSubmitQuote; exports.useSubmitReturn = useSubmitReturn; exports.useSubmitReview = useSubmitReview; exports.useSubscriptions = useSubscriptions; exports.useWishlist = useWishlist;
|