@behio/storefront-sdk 0.32.0 → 0.34.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-Y7QAB75P.mjs → chunk-5KJDVDUM.mjs} +43 -0
- package/dist/chunk-CZRSJULD.js +118 -0
- package/dist/chunk-QUU76QUB.mjs +118 -0
- package/dist/{chunk-5OFVG2BO.js → chunk-Y4ZCK5HD.js} +43 -0
- package/dist/{client-BOz1trRk.d.mts → client-DdaC0_6x.d.mts} +239 -5
- package/dist/{client-BOz1trRk.d.ts → client-DdaC0_6x.d.ts} +239 -5
- package/dist/index.d.mts +86 -8
- package/dist/index.d.ts +86 -8
- package/dist/index.js +11 -3
- package/dist/index.mjs +10 -2
- 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 +172 -4
- package/dist/react.d.ts +172 -4
- package/dist/react.js +285 -55
- package/dist/react.mjs +325 -95
- package/package.json +1 -1
- package/dist/chunk-JIAOZ5YW.js +0 -40
- package/dist/chunk-ZOZAJG6T.mjs +0 -40
package/dist/react.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var _chunkJIAOZ5YWjs = require('./chunk-JIAOZ5YW.js');
|
|
5
4
|
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkCZRSJULDjs = require('./chunk-CZRSJULD.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunkY4ZCK5HDjs = require('./chunk-Y4ZCK5HD.js');
|
|
8
12
|
|
|
9
13
|
// src/react/provider.tsx
|
|
10
14
|
var _react = require('react');
|
|
@@ -134,7 +138,7 @@ function BehioProvider({
|
|
|
134
138
|
const [activeCurrency, setActiveCurrency] = _react.useState.call(void 0, resolveInitialCurrency);
|
|
135
139
|
const clientRef = _react.useRef.call(void 0, null);
|
|
136
140
|
if (!clientRef.current) {
|
|
137
|
-
clientRef.current = new (0,
|
|
141
|
+
clientRef.current = new (0, _chunkY4ZCK5HDjs.BehioStorefront)({
|
|
138
142
|
apiKey,
|
|
139
143
|
baseUrl,
|
|
140
144
|
...shopDomain ? { shopDomain } : {},
|
|
@@ -885,6 +889,44 @@ function useLoyalty(options) {
|
|
|
885
889
|
return { loyalty: data, isLoading, error, refetch };
|
|
886
890
|
}
|
|
887
891
|
|
|
892
|
+
// src/react/hooks/use-subscriptions.ts
|
|
893
|
+
|
|
894
|
+
var SUBSCRIPTIONS_KEY = ["behio", "subscriptions"];
|
|
895
|
+
function useSubscriptions(options) {
|
|
896
|
+
const { client } = useBehio();
|
|
897
|
+
const qc = _reactquery.useQueryClient.call(void 0, );
|
|
898
|
+
const query = _reactquery.useQuery.call(void 0, {
|
|
899
|
+
queryKey: [...SUBSCRIPTIONS_KEY],
|
|
900
|
+
queryFn: () => unwrap(client.subscriptions.list()),
|
|
901
|
+
enabled: _optionalChain([options, 'optionalAccess', _54 => _54.enabled]) !== false && !!client.getAccessToken()
|
|
902
|
+
});
|
|
903
|
+
const invalidate = () => qc.invalidateQueries({ queryKey: [...SUBSCRIPTIONS_KEY] });
|
|
904
|
+
const pauseMutation = _reactquery.useMutation.call(void 0, {
|
|
905
|
+
mutationFn: (subscriptionId) => unwrap(client.subscriptions.pause(subscriptionId)),
|
|
906
|
+
onSuccess: invalidate
|
|
907
|
+
});
|
|
908
|
+
const resumeMutation = _reactquery.useMutation.call(void 0, {
|
|
909
|
+
mutationFn: (subscriptionId) => unwrap(client.subscriptions.resume(subscriptionId)),
|
|
910
|
+
onSuccess: invalidate
|
|
911
|
+
});
|
|
912
|
+
const cancelMutation = _reactquery.useMutation.call(void 0, {
|
|
913
|
+
mutationFn: (subscriptionId) => unwrap(client.subscriptions.cancel(subscriptionId)),
|
|
914
|
+
onSuccess: invalidate
|
|
915
|
+
});
|
|
916
|
+
return {
|
|
917
|
+
subscriptions: _nullishCoalesce(_optionalChain([query, 'access', _55 => _55.data, 'optionalAccess', _56 => _56.items]), () => ( [])),
|
|
918
|
+
isLoading: query.isLoading,
|
|
919
|
+
error: query.error,
|
|
920
|
+
refetch: query.refetch,
|
|
921
|
+
pause: pauseMutation.mutateAsync,
|
|
922
|
+
resume: resumeMutation.mutateAsync,
|
|
923
|
+
cancel: cancelMutation.mutateAsync,
|
|
924
|
+
isPausing: pauseMutation.isPending,
|
|
925
|
+
isResuming: resumeMutation.isPending,
|
|
926
|
+
isCancelling: cancelMutation.isPending
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
|
|
888
930
|
// src/react/hooks/use-pickup-points.ts
|
|
889
931
|
|
|
890
932
|
function usePickupPoints(input) {
|
|
@@ -902,7 +944,158 @@ function usePickupPoints(input) {
|
|
|
902
944
|
),
|
|
903
945
|
enabled: enabled !== false && !!methodId
|
|
904
946
|
});
|
|
905
|
-
return { pickupPoints: _nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
947
|
+
return { pickupPoints: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _57 => _57.items]), () => ( [])), isLoading, error, refetch };
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
// src/react/hooks/use-shipping-methods.ts
|
|
951
|
+
|
|
952
|
+
function useShippingMethods(options) {
|
|
953
|
+
const { client, currency: activeCurrency } = useBehio();
|
|
954
|
+
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _58 => _58.currency]), () => ( activeCurrency));
|
|
955
|
+
const { country, cartTotal, cartWeightKg } = _nullishCoalesce(options, () => ( {}));
|
|
956
|
+
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
957
|
+
queryKey: [
|
|
958
|
+
"behio",
|
|
959
|
+
"shipping-methods",
|
|
960
|
+
_nullishCoalesce(currency, () => ( "")),
|
|
961
|
+
_nullishCoalesce(country, () => ( "")),
|
|
962
|
+
_nullishCoalesce(cartTotal, () => ( "")),
|
|
963
|
+
_nullishCoalesce(cartWeightKg, () => ( ""))
|
|
964
|
+
],
|
|
965
|
+
queryFn: () => unwrap(client.shipping.listMethods({ currency, country, cartTotal, cartWeightKg })),
|
|
966
|
+
enabled: _optionalChain([options, 'optionalAccess', _59 => _59.enabled]) !== false
|
|
967
|
+
});
|
|
968
|
+
return { methods: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _60 => _60.items]), () => ( [])), isLoading, error, refetch };
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// src/react/hooks/use-shipping-quote.ts
|
|
972
|
+
|
|
973
|
+
function useShippingQuote(options) {
|
|
974
|
+
const { client, currency: activeCurrency } = useBehio();
|
|
975
|
+
const { destinationAddress, items, cartTotal, enabled } = _nullishCoalesce(options, () => ( {}));
|
|
976
|
+
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _61 => _61.currency]), () => ( activeCurrency));
|
|
977
|
+
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
978
|
+
queryKey: [
|
|
979
|
+
"behio",
|
|
980
|
+
"shipping-quote",
|
|
981
|
+
JSON.stringify(_nullishCoalesce(destinationAddress, () => ( null))),
|
|
982
|
+
JSON.stringify(_nullishCoalesce(items, () => ( null))),
|
|
983
|
+
_nullishCoalesce(cartTotal, () => ( "")),
|
|
984
|
+
_nullishCoalesce(currency, () => ( ""))
|
|
985
|
+
],
|
|
986
|
+
queryFn: () => unwrap(
|
|
987
|
+
client.shipping.quote({
|
|
988
|
+
destinationAddress,
|
|
989
|
+
items,
|
|
990
|
+
cartTotal,
|
|
991
|
+
currency
|
|
992
|
+
})
|
|
993
|
+
),
|
|
994
|
+
enabled: enabled !== false && !!_optionalChain([destinationAddress, 'optionalAccess', _62 => _62.country])
|
|
995
|
+
});
|
|
996
|
+
return { quotes: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _63 => _63.items]), () => ( [])), isLoading, error, refetch };
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
// src/react/hooks/use-payment-methods.ts
|
|
1000
|
+
|
|
1001
|
+
function usePaymentMethods(options) {
|
|
1002
|
+
const { client, currency: activeCurrency } = useBehio();
|
|
1003
|
+
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _64 => _64.currency]), () => ( activeCurrency));
|
|
1004
|
+
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
1005
|
+
queryKey: ["behio", "payment-methods", _nullishCoalesce(currency, () => ( ""))],
|
|
1006
|
+
queryFn: () => unwrap(client.catalog.listPaymentMethods({ currency })),
|
|
1007
|
+
enabled: _optionalChain([options, 'optionalAccess', _65 => _65.enabled]) !== false
|
|
1008
|
+
});
|
|
1009
|
+
return { methods: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _66 => _66.items]), () => ( [])), isLoading, error, refetch };
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// src/react/hooks/use-personal-offers.ts
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
function usePersonalOffers(options) {
|
|
1016
|
+
const { client } = useBehio();
|
|
1017
|
+
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
1018
|
+
const [polledVid, setPolledVid] = _react.useState.call(void 0, null);
|
|
1019
|
+
const explicitVid = _optionalChain([options, 'optionalAccess', _67 => _67.visitorId]);
|
|
1020
|
+
_react.useEffect.call(void 0, () => {
|
|
1021
|
+
if (explicitVid) return;
|
|
1022
|
+
const read = () => {
|
|
1023
|
+
const vid = client.getAnalyticsVisitorId();
|
|
1024
|
+
if (vid) setPolledVid(vid);
|
|
1025
|
+
return vid;
|
|
1026
|
+
};
|
|
1027
|
+
if (read()) return;
|
|
1028
|
+
const timer = setInterval(() => {
|
|
1029
|
+
if (read()) clearInterval(timer);
|
|
1030
|
+
}, 3e3);
|
|
1031
|
+
return () => clearInterval(timer);
|
|
1032
|
+
}, [client, explicitVid]);
|
|
1033
|
+
const visitorId = _nullishCoalesce(explicitVid, () => ( polledVid));
|
|
1034
|
+
const queryKey = ["behio", "personal-offers", _nullishCoalesce(visitorId, () => ( ""))];
|
|
1035
|
+
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
1036
|
+
queryKey,
|
|
1037
|
+
queryFn: () => unwrap(client.getPersonalOffers(visitorId)),
|
|
1038
|
+
enabled: _optionalChain([options, 'optionalAccess', _68 => _68.enabled]) !== false && !!visitorId
|
|
1039
|
+
});
|
|
1040
|
+
const claimMutation = _reactquery.useMutation.call(void 0, {
|
|
1041
|
+
mutationFn: ({ offerId, email }) => unwrap(client.claimOfferByEmail(offerId, { visitorId, email })),
|
|
1042
|
+
onSuccess: (result, { offerId }) => {
|
|
1043
|
+
queryClient.setQueryData(
|
|
1044
|
+
queryKey,
|
|
1045
|
+
(prev) => prev ? {
|
|
1046
|
+
items: prev.items.map(
|
|
1047
|
+
(o) => o.id === offerId ? { ...o, code: result.code, status: "CLAIMED" } : o
|
|
1048
|
+
)
|
|
1049
|
+
} : prev
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
const claimByEmail = _react.useCallback.call(void 0,
|
|
1054
|
+
(offerId, email) => claimMutation.mutateAsync({ offerId, email }),
|
|
1055
|
+
[claimMutation]
|
|
1056
|
+
);
|
|
1057
|
+
return {
|
|
1058
|
+
offers: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _69 => _69.items]), () => ( [])),
|
|
1059
|
+
/** Resolved consent-gated visitor id (null before consent). */
|
|
1060
|
+
visitorId: _nullishCoalesce(visitorId, () => ( null)),
|
|
1061
|
+
isLoading,
|
|
1062
|
+
error,
|
|
1063
|
+
refetch,
|
|
1064
|
+
/** E-mail gate: trade an e-mail for the discount code of the given offer. */
|
|
1065
|
+
claimByEmail,
|
|
1066
|
+
isClaiming: claimMutation.isPending,
|
|
1067
|
+
claimError: claimMutation.error
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
// src/react/hooks/use-analytics-events.ts
|
|
1072
|
+
|
|
1073
|
+
function useAnalyticsEvents() {
|
|
1074
|
+
const { client } = useBehio();
|
|
1075
|
+
const track = _react.useCallback.call(void 0,
|
|
1076
|
+
(events, opts) => {
|
|
1077
|
+
const list = Array.isArray(events) ? events : [events];
|
|
1078
|
+
if (list.length === 0) return Promise.resolve();
|
|
1079
|
+
return client.sendAnalyticsEvents({
|
|
1080
|
+
sessionId: _optionalChain([opts, 'optionalAccess', _70 => _70.sessionId]),
|
|
1081
|
+
visitorId: _nullishCoalesce(client.getAnalyticsVisitorId(), () => ( void 0)),
|
|
1082
|
+
events: list.map((e) => ({ ts: Date.now(), ...e }))
|
|
1083
|
+
});
|
|
1084
|
+
},
|
|
1085
|
+
[client]
|
|
1086
|
+
);
|
|
1087
|
+
const trackEvent = _react.useCallback.call(void 0,
|
|
1088
|
+
(name, props) => track({ type: "custom", name, props }),
|
|
1089
|
+
[track]
|
|
1090
|
+
);
|
|
1091
|
+
return {
|
|
1092
|
+
/** Send one or more raw analytics events. */
|
|
1093
|
+
track,
|
|
1094
|
+
/** Convenience: send a named `custom` event with optional props. */
|
|
1095
|
+
trackEvent,
|
|
1096
|
+
/** Consent-gated visitor id, null before analytics consent. */
|
|
1097
|
+
getVisitorId: () => client.getAnalyticsVisitorId()
|
|
1098
|
+
};
|
|
906
1099
|
}
|
|
907
1100
|
|
|
908
1101
|
// src/react/hooks/use-newsletter.ts
|
|
@@ -936,10 +1129,10 @@ function useOrders(options) {
|
|
|
936
1129
|
enabled: enabled !== false && !!client.getAccessToken()
|
|
937
1130
|
});
|
|
938
1131
|
const items = _react.useMemo.call(void 0,
|
|
939
|
-
() => _nullishCoalesce(_optionalChain([infinite, 'access',
|
|
1132
|
+
() => _nullishCoalesce(_optionalChain([infinite, 'access', _71 => _71.data, 'optionalAccess', _72 => _72.pages, 'access', _73 => _73.flatMap, 'call', _74 => _74((p) => p.items)]), () => ( [])),
|
|
940
1133
|
[infinite.data]
|
|
941
1134
|
);
|
|
942
|
-
const lastPage = _optionalChain([infinite, 'access',
|
|
1135
|
+
const lastPage = _optionalChain([infinite, 'access', _75 => _75.data, 'optionalAccess', _76 => _76.pages, 'access', _77 => _77[infinite.data.pages.length - 1]]);
|
|
943
1136
|
const loadMore = _react.useCallback.call(void 0, () => {
|
|
944
1137
|
if (infinite.hasNextPage && !infinite.isFetchingNextPage) {
|
|
945
1138
|
return infinite.fetchNextPage();
|
|
@@ -952,10 +1145,10 @@ function useOrders(options) {
|
|
|
952
1145
|
return {
|
|
953
1146
|
items,
|
|
954
1147
|
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',
|
|
1148
|
+
total: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _78 => _78.total]), () => ( 0)),
|
|
1149
|
+
totalPages: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _79 => _79.totalPages]), () => ( 0)),
|
|
1150
|
+
currentPage: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _80 => _80.page]), () => ( page)),
|
|
1151
|
+
limit: _nullishCoalesce(_nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _81 => _81.limit]), () => ( limit)), () => ( 20)),
|
|
959
1152
|
page,
|
|
960
1153
|
setPage: goToPage,
|
|
961
1154
|
loadMore,
|
|
@@ -984,7 +1177,7 @@ function useOrder(orderNumber, options) {
|
|
|
984
1177
|
} = _reactquery.useQuery.call(void 0, {
|
|
985
1178
|
queryKey: ["behio", "order", orderNumber],
|
|
986
1179
|
queryFn: () => unwrap(client.orders.get(orderNumber)),
|
|
987
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1180
|
+
enabled: _optionalChain([options, 'optionalAccess', _82 => _82.enabled]) !== false && !!orderNumber && !!client.getAccessToken()
|
|
988
1181
|
});
|
|
989
1182
|
const cancelMutation = _reactquery.useMutation.call(void 0, {
|
|
990
1183
|
mutationFn: () => unwrap(client.orders.cancel(orderNumber)),
|
|
@@ -1109,7 +1302,7 @@ function usePages(locale, options) {
|
|
|
1109
1302
|
const result = await unwrap(client.pages.list(locale));
|
|
1110
1303
|
return result.pages;
|
|
1111
1304
|
},
|
|
1112
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1305
|
+
enabled: _optionalChain([options, 'optionalAccess', _83 => _83.enabled]) !== false
|
|
1113
1306
|
});
|
|
1114
1307
|
}
|
|
1115
1308
|
function usePage(slug, locale, options) {
|
|
@@ -1117,7 +1310,7 @@ function usePage(slug, locale, options) {
|
|
|
1117
1310
|
return _reactquery.useQuery.call(void 0, {
|
|
1118
1311
|
queryKey: ["behio", "page", slug, locale],
|
|
1119
1312
|
queryFn: () => unwrap(client.pages.get(slug, locale)),
|
|
1120
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1313
|
+
enabled: _optionalChain([options, 'optionalAccess', _84 => _84.enabled]) !== false && !!slug
|
|
1121
1314
|
});
|
|
1122
1315
|
}
|
|
1123
1316
|
|
|
@@ -1128,7 +1321,7 @@ function useShopInfo(options) {
|
|
|
1128
1321
|
return _reactquery.useQuery.call(void 0, {
|
|
1129
1322
|
queryKey: ["behio", "shop-info"],
|
|
1130
1323
|
queryFn: () => unwrap(client.getShopInfo()),
|
|
1131
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1324
|
+
enabled: _optionalChain([options, 'optionalAccess', _85 => _85.enabled]) !== false
|
|
1132
1325
|
});
|
|
1133
1326
|
}
|
|
1134
1327
|
|
|
@@ -1139,7 +1332,7 @@ function useShopScripts(options) {
|
|
|
1139
1332
|
return _reactquery.useQuery.call(void 0, {
|
|
1140
1333
|
queryKey: ["behio", "shop-scripts"],
|
|
1141
1334
|
queryFn: () => unwrap(client.getShopScripts()),
|
|
1142
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1335
|
+
enabled: _optionalChain([options, 'optionalAccess', _86 => _86.enabled]) !== false
|
|
1143
1336
|
});
|
|
1144
1337
|
}
|
|
1145
1338
|
|
|
@@ -1167,8 +1360,8 @@ function dedupe(values) {
|
|
|
1167
1360
|
function useCurrency() {
|
|
1168
1361
|
const { currency, setCurrency, configuredDefaultCurrency, configuredCurrencies } = useBehio();
|
|
1169
1362
|
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',
|
|
1363
|
+
const defaultCurrency = _nullishCoalesce(configuredDefaultCurrency, () => ( _optionalChain([shop, 'optionalAccess', _87 => _87.defaultCurrency])));
|
|
1364
|
+
const currencies = configuredCurrencies && configuredCurrencies.length > 0 ? dedupe(configuredCurrencies) : dedupe([defaultCurrency, ..._nullishCoalesce(_optionalChain([shop, 'optionalAccess', _88 => _88.supportedCurrencies]), () => ( []))]);
|
|
1172
1365
|
return {
|
|
1173
1366
|
currency,
|
|
1174
1367
|
effectiveCurrency: _nullishCoalesce(currency, () => ( defaultCurrency)),
|
|
@@ -1191,7 +1384,7 @@ function CurrencySwitcher({
|
|
|
1191
1384
|
const { currencies, effectiveCurrency, setCurrency } = useCurrency();
|
|
1192
1385
|
if (currencies.length === 0) return null;
|
|
1193
1386
|
if (currencies.length <= 1 && !showWhenSingle) return null;
|
|
1194
|
-
const label = (code) => _nullishCoalesce(_optionalChain([labels, 'optionalAccess',
|
|
1387
|
+
const label = (code) => _nullishCoalesce(_optionalChain([labels, 'optionalAccess', _89 => _89[code]]), () => ( code));
|
|
1195
1388
|
if (children) {
|
|
1196
1389
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: children({ currencies, value: effectiveCurrency, setCurrency, label }) });
|
|
1197
1390
|
}
|
|
@@ -1308,9 +1501,9 @@ function StorefrontScripts({ visitorId: visitorIdProp } = {}) {
|
|
|
1308
1501
|
}
|
|
1309
1502
|
}, [visitorIdProp]);
|
|
1310
1503
|
const { data: consent } = useCookieConsent(visitorId || void 0);
|
|
1311
|
-
const analyticsOk = Boolean(_optionalChain([consent, 'optionalAccess',
|
|
1504
|
+
const analyticsOk = Boolean(_optionalChain([consent, 'optionalAccess', _90 => _90.analytics]));
|
|
1312
1505
|
const scripts = _react.useMemo.call(void 0,
|
|
1313
|
-
() => (_nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
1506
|
+
() => (_nullishCoalesce(_optionalChain([data, 'optionalAccess', _91 => _91.scripts]), () => ( []))).filter((s) => !s.consentRequired || analyticsOk),
|
|
1314
1507
|
[data, analyticsOk]
|
|
1315
1508
|
);
|
|
1316
1509
|
const signature = _react.useMemo.call(void 0,
|
|
@@ -1375,7 +1568,7 @@ function initTracker(client) {
|
|
|
1375
1568
|
return;
|
|
1376
1569
|
}
|
|
1377
1570
|
const { data } = await client.consent.get(stored);
|
|
1378
|
-
const granted = Boolean(_optionalChain([data, 'optionalAccess',
|
|
1571
|
+
const granted = Boolean(_optionalChain([data, 'optionalAccess', _92 => _92.analytics]));
|
|
1379
1572
|
visitorId = granted ? stored : void 0;
|
|
1380
1573
|
client.setAnalyticsVisitorId(granted ? stored : null);
|
|
1381
1574
|
} catch (e7) {
|
|
@@ -1459,7 +1652,7 @@ function initTracker(client) {
|
|
|
1459
1652
|
};
|
|
1460
1653
|
const onClick = (ev) => {
|
|
1461
1654
|
const target = ev.target;
|
|
1462
|
-
const el = _optionalChain([target, 'optionalAccess',
|
|
1655
|
+
const el = _optionalChain([target, 'optionalAccess', _93 => _93.closest, 'optionalCall', _94 => _94("a,button,[role=button],[data-behio-event]")]);
|
|
1463
1656
|
if (!el) return;
|
|
1464
1657
|
const explicit = _nullishCoalesce(el.getAttribute("data-behio-event"), () => ( void 0));
|
|
1465
1658
|
const text = (_nullishCoalesce(el.textContent, () => ( ""))).trim().replace(/\s+/g, " ").slice(0, 80) || void 0;
|
|
@@ -1473,6 +1666,18 @@ function initTracker(client) {
|
|
|
1473
1666
|
href = void 0;
|
|
1474
1667
|
}
|
|
1475
1668
|
}
|
|
1669
|
+
const dataProps = {};
|
|
1670
|
+
const dataset = el.dataset;
|
|
1671
|
+
if (dataset) {
|
|
1672
|
+
for (const k of Object.keys(dataset)) {
|
|
1673
|
+
if (k.startsWith("behio") && k !== "behioEvent") {
|
|
1674
|
+
const short = k.slice("behio".length);
|
|
1675
|
+
const propKey = short.charAt(0).toLowerCase() + short.slice(1);
|
|
1676
|
+
const v = dataset[k];
|
|
1677
|
+
if (v != null) dataProps[propKey] = String(v).slice(0, 120);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1476
1681
|
enqueue({
|
|
1477
1682
|
type: "custom",
|
|
1478
1683
|
name: explicit || "click",
|
|
@@ -1481,13 +1686,29 @@ function initTracker(client) {
|
|
|
1481
1686
|
props: {
|
|
1482
1687
|
tag: el.tagName.toLowerCase(),
|
|
1483
1688
|
...text ? { text } : {},
|
|
1484
|
-
...href ? { href } : {}
|
|
1689
|
+
...href ? { href } : {},
|
|
1690
|
+
...dataProps
|
|
1485
1691
|
}
|
|
1486
1692
|
});
|
|
1487
1693
|
};
|
|
1488
1694
|
const w = window;
|
|
1489
1695
|
w.__behioEcommerceSink = (event, payload) => {
|
|
1490
1696
|
if (event === "purchase") return;
|
|
1697
|
+
const items = Array.isArray(payload.items) ? payload.items : [];
|
|
1698
|
+
const props = {
|
|
1699
|
+
..._nullishCoalesce(payload.props, () => ( {})),
|
|
1700
|
+
...payload.search_term != null ? { query: payload.search_term } : {},
|
|
1701
|
+
...payload.shipping_tier != null ? { shippingTier: payload.shipping_tier } : {},
|
|
1702
|
+
...payload.payment_type != null ? { paymentType: payload.payment_type } : {},
|
|
1703
|
+
...payload.item_list_id != null ? { listId: payload.item_list_id } : {},
|
|
1704
|
+
...payload.item_list_name != null ? { listName: payload.item_list_name } : {},
|
|
1705
|
+
...items.length > 0 ? {
|
|
1706
|
+
items: items.length,
|
|
1707
|
+
// First item id = the product (view_item/add_to_cart are
|
|
1708
|
+
// single-product in practice) - Behavioral Offers count on it.
|
|
1709
|
+
itemId: _optionalChain([items, 'access', _95 => _95[0], 'optionalAccess', _96 => _96.item_id])
|
|
1710
|
+
} : {}
|
|
1711
|
+
};
|
|
1491
1712
|
enqueue({
|
|
1492
1713
|
type: "ecommerce",
|
|
1493
1714
|
name: event,
|
|
@@ -1495,14 +1716,7 @@ function initTracker(client) {
|
|
|
1495
1716
|
ts: Date.now(),
|
|
1496
1717
|
...payload.value != null ? { value: payload.value } : {},
|
|
1497
1718
|
...payload.currency ? { currency: payload.currency } : {},
|
|
1498
|
-
...
|
|
1499
|
-
props: {
|
|
1500
|
-
items: payload.items.length,
|
|
1501
|
-
// First item id = the product (view_item/add_to_cart are
|
|
1502
|
-
// single-product in practice) - Behavioral Offers count on it.
|
|
1503
|
-
itemId: _optionalChain([payload, 'access', _79 => _79.items, 'access', _80 => _80[0], 'optionalAccess', _81 => _81.item_id])
|
|
1504
|
-
}
|
|
1505
|
-
} : {}
|
|
1719
|
+
...Object.keys(props).length > 0 ? { props } : {}
|
|
1506
1720
|
});
|
|
1507
1721
|
};
|
|
1508
1722
|
const origPush = history.pushState.bind(history);
|
|
@@ -1548,7 +1762,13 @@ function utmFromSearch(search) {
|
|
|
1548
1762
|
return {
|
|
1549
1763
|
utmSource: _nullishCoalesce(p.get("utm_source"), () => ( void 0)),
|
|
1550
1764
|
utmMedium: _nullishCoalesce(p.get("utm_medium"), () => ( void 0)),
|
|
1551
|
-
utmCampaign: _nullishCoalesce(p.get("utm_campaign"), () => ( void 0))
|
|
1765
|
+
utmCampaign: _nullishCoalesce(p.get("utm_campaign"), () => ( void 0)),
|
|
1766
|
+
// Extended attribution: paid-search term/content + click ids. The
|
|
1767
|
+
// backend folds these into event props (raw columns unchanged).
|
|
1768
|
+
utmTerm: _nullishCoalesce(p.get("utm_term"), () => ( void 0)),
|
|
1769
|
+
utmContent: _nullishCoalesce(p.get("utm_content"), () => ( void 0)),
|
|
1770
|
+
gclid: _nullishCoalesce(p.get("gclid"), () => ( void 0)),
|
|
1771
|
+
fbclid: _nullishCoalesce(p.get("fbclid"), () => ( void 0))
|
|
1552
1772
|
};
|
|
1553
1773
|
} catch (e10) {
|
|
1554
1774
|
return {};
|
|
@@ -1562,8 +1782,8 @@ function useBundles(options) {
|
|
|
1562
1782
|
return _reactquery.useQuery.call(void 0, {
|
|
1563
1783
|
queryKey: ["behio", "bundles"],
|
|
1564
1784
|
queryFn: () => unwrap(client.catalog.getBundles()),
|
|
1565
|
-
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1566
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1785
|
+
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _97 => _97.enabled]), () => ( true)),
|
|
1786
|
+
initialData: _optionalChain([options, 'optionalAccess', _98 => _98.initialData])
|
|
1567
1787
|
});
|
|
1568
1788
|
}
|
|
1569
1789
|
function useBundle(slug, options) {
|
|
@@ -1571,8 +1791,8 @@ function useBundle(slug, options) {
|
|
|
1571
1791
|
return _reactquery.useQuery.call(void 0, {
|
|
1572
1792
|
queryKey: ["behio", "bundle", slug],
|
|
1573
1793
|
queryFn: () => unwrap(client.catalog.getBundle(slug)),
|
|
1574
|
-
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1575
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1794
|
+
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _99 => _99.enabled]), () => ( true))),
|
|
1795
|
+
initialData: _optionalChain([options, 'optionalAccess', _100 => _100.initialData])
|
|
1576
1796
|
});
|
|
1577
1797
|
}
|
|
1578
1798
|
|
|
@@ -1581,15 +1801,15 @@ function useBundle(slug, options) {
|
|
|
1581
1801
|
function useProductGroup(slug, options) {
|
|
1582
1802
|
const { client } = useBehio();
|
|
1583
1803
|
return _reactquery.useQuery.call(void 0, {
|
|
1584
|
-
queryKey: ["behio", "product-group", slug, _optionalChain([options, 'optionalAccess',
|
|
1804
|
+
queryKey: ["behio", "product-group", slug, _optionalChain([options, 'optionalAccess', _101 => _101.locale]), _optionalChain([options, 'optionalAccess', _102 => _102.currency])],
|
|
1585
1805
|
queryFn: () => unwrap(
|
|
1586
1806
|
client.catalog.getProductGroup(slug, {
|
|
1587
|
-
locale: _optionalChain([options, 'optionalAccess',
|
|
1588
|
-
currency: _optionalChain([options, 'optionalAccess',
|
|
1807
|
+
locale: _optionalChain([options, 'optionalAccess', _103 => _103.locale]),
|
|
1808
|
+
currency: _optionalChain([options, 'optionalAccess', _104 => _104.currency])
|
|
1589
1809
|
})
|
|
1590
1810
|
),
|
|
1591
|
-
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1592
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1811
|
+
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _105 => _105.enabled]), () => ( true))),
|
|
1812
|
+
initialData: _optionalChain([options, 'optionalAccess', _106 => _106.initialData])
|
|
1593
1813
|
});
|
|
1594
1814
|
}
|
|
1595
1815
|
|
|
@@ -1598,15 +1818,15 @@ function useProductGroup(slug, options) {
|
|
|
1598
1818
|
function useCrossSell(productSlug, options) {
|
|
1599
1819
|
const { client } = useBehio();
|
|
1600
1820
|
return _reactquery.useQuery.call(void 0, {
|
|
1601
|
-
queryKey: ["behio", "cross-sell", productSlug, _optionalChain([options, 'optionalAccess',
|
|
1821
|
+
queryKey: ["behio", "cross-sell", productSlug, _optionalChain([options, 'optionalAccess', _107 => _107.locale]), _optionalChain([options, 'optionalAccess', _108 => _108.currency])],
|
|
1602
1822
|
queryFn: () => unwrap(
|
|
1603
1823
|
client.catalog.getCrossSell(productSlug, {
|
|
1604
|
-
locale: _optionalChain([options, 'optionalAccess',
|
|
1605
|
-
currency: _optionalChain([options, 'optionalAccess',
|
|
1824
|
+
locale: _optionalChain([options, 'optionalAccess', _109 => _109.locale]),
|
|
1825
|
+
currency: _optionalChain([options, 'optionalAccess', _110 => _110.currency])
|
|
1606
1826
|
})
|
|
1607
1827
|
),
|
|
1608
|
-
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1609
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1828
|
+
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _111 => _111.enabled]), () => ( true))),
|
|
1829
|
+
initialData: _optionalChain([options, 'optionalAccess', _112 => _112.initialData])
|
|
1610
1830
|
});
|
|
1611
1831
|
}
|
|
1612
1832
|
|
|
@@ -1617,8 +1837,8 @@ function useProductPromotions(productSlug, options) {
|
|
|
1617
1837
|
return _reactquery.useQuery.call(void 0, {
|
|
1618
1838
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
1619
1839
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
1620
|
-
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1621
|
-
refetchInterval: _optionalChain([options, 'optionalAccess',
|
|
1840
|
+
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _113 => _113.enabled]), () => ( true))),
|
|
1841
|
+
refetchInterval: _optionalChain([options, 'optionalAccess', _114 => _114.refetchIntervalMs])
|
|
1622
1842
|
});
|
|
1623
1843
|
}
|
|
1624
1844
|
|
|
@@ -1626,11 +1846,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
1626
1846
|
|
|
1627
1847
|
function useGiftCardBalance(code, options) {
|
|
1628
1848
|
const { client } = useBehio();
|
|
1629
|
-
const trimmed = _optionalChain([code, 'optionalAccess',
|
|
1849
|
+
const trimmed = _optionalChain([code, 'optionalAccess', _115 => _115.trim, 'call', _116 => _116()]);
|
|
1630
1850
|
return _reactquery.useQuery.call(void 0, {
|
|
1631
1851
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
1632
1852
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
1633
|
-
enabled: Boolean(trimmed && trimmed.length >= 6) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1853
|
+
enabled: Boolean(trimmed && trimmed.length >= 6) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _117 => _117.enabled]), () => ( true)))
|
|
1634
1854
|
});
|
|
1635
1855
|
}
|
|
1636
1856
|
|
|
@@ -1642,7 +1862,7 @@ function useWishlist(options) {
|
|
|
1642
1862
|
const query = _reactquery.useQuery.call(void 0, {
|
|
1643
1863
|
queryKey: ["behio", "wishlist"],
|
|
1644
1864
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
1645
|
-
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1865
|
+
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _118 => _118.enabled]), () => ( true))
|
|
1646
1866
|
});
|
|
1647
1867
|
const addMutation = _reactquery.useMutation.call(void 0, {
|
|
1648
1868
|
mutationFn: (productId) => unwrap(client.wishlist.add(productId)),
|
|
@@ -1674,9 +1894,9 @@ function useIsInWishlist(productId) {
|
|
|
1674
1894
|
function useProductReviews(productId, options) {
|
|
1675
1895
|
const { client } = useBehio();
|
|
1676
1896
|
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',
|
|
1897
|
+
queryKey: ["behio", "reviews", productId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _119 => _119.page]), () => ( 1))],
|
|
1898
|
+
queryFn: () => unwrap(client.reviews.getProductReviews(productId, _optionalChain([options, 'optionalAccess', _120 => _120.page]), _optionalChain([options, 'optionalAccess', _121 => _121.limit]))),
|
|
1899
|
+
enabled: Boolean(productId) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _122 => _122.enabled]), () => ( true)))
|
|
1680
1900
|
});
|
|
1681
1901
|
}
|
|
1682
1902
|
function useSubmitReview() {
|
|
@@ -1796,4 +2016,14 @@ function useNotifyWhenAvailable() {
|
|
|
1796
2016
|
|
|
1797
2017
|
|
|
1798
2018
|
|
|
1799
|
-
|
|
2019
|
+
|
|
2020
|
+
|
|
2021
|
+
|
|
2022
|
+
|
|
2023
|
+
|
|
2024
|
+
|
|
2025
|
+
|
|
2026
|
+
|
|
2027
|
+
|
|
2028
|
+
|
|
2029
|
+
exports.BehioAnalyticsTracker = BehioAnalyticsTracker; exports.BehioProvider = BehioProvider; exports.CurrencySwitcher = CurrencySwitcher; exports.StorefrontScripts = StorefrontScripts; exports.cookieStorage = cookieStorage; exports.createMemoryStorage = createMemoryStorage; exports.detectStorage = detectStorage; exports.formatPrice = _chunkCZRSJULDjs.formatPrice; exports.generateVisitorId = _chunkCZRSJULDjs.generateVisitorId; exports.getStoredVisitorId = _chunkCZRSJULDjs.getStoredVisitorId; exports.grantAnalyticsConsent = _chunkCZRSJULDjs.grantAnalyticsConsent; exports.localStorageAdapter = localStorageAdapter; exports.memoryStorage = memoryStorage; exports.revokeAnalyticsConsent = _chunkCZRSJULDjs.revokeAnalyticsConsent; exports.trackEcommerceEvent = _chunkCZRSJULDjs.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;
|