@behio/storefront-sdk 0.37.0 → 0.38.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-QKEW2EU5.js → chunk-FOUBL2EQ.js} +24 -1
- package/dist/{chunk-5C6MNGGB.mjs → chunk-MF5LMHZ4.mjs} +24 -1
- package/dist/{client-BgYibdTK.d.mts → client-Cb_eHKm9.d.mts} +82 -2
- package/dist/{client-BgYibdTK.d.ts → client-Cb_eHKm9.d.ts} +82 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- 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 +37 -3
- package/dist/react.d.ts +37 -3
- package/dist/react.js +98 -60
- package/dist/react.mjs +114 -76
- package/package.json +2 -2
package/dist/react.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
var _chunkCZRSJULDjs = require('./chunk-CZRSJULD.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkFOUBL2EQjs = require('./chunk-FOUBL2EQ.js');
|
|
12
12
|
|
|
13
13
|
// src/react/provider.tsx
|
|
14
14
|
var _react = require('react');
|
|
@@ -138,7 +138,7 @@ function BehioProvider({
|
|
|
138
138
|
const [activeCurrency, setActiveCurrency] = _react.useState.call(void 0, resolveInitialCurrency);
|
|
139
139
|
const clientRef = _react.useRef.call(void 0, null);
|
|
140
140
|
if (!clientRef.current) {
|
|
141
|
-
clientRef.current = new (0,
|
|
141
|
+
clientRef.current = new (0, _chunkFOUBL2EQjs.BehioStorefront)({
|
|
142
142
|
apiKey,
|
|
143
143
|
baseUrl,
|
|
144
144
|
...shopDomain ? { shopDomain } : {},
|
|
@@ -900,6 +900,42 @@ function useLoyalty(options) {
|
|
|
900
900
|
return { loyalty: data, isLoading, error, refetch };
|
|
901
901
|
}
|
|
902
902
|
|
|
903
|
+
// src/react/hooks/use-courses.ts
|
|
904
|
+
|
|
905
|
+
var COURSES_KEY = ["behio", "courses"];
|
|
906
|
+
function useCourses(options) {
|
|
907
|
+
const { client } = useBehio();
|
|
908
|
+
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
909
|
+
queryKey: [...COURSES_KEY],
|
|
910
|
+
queryFn: () => unwrap(client.customer.getCourses()),
|
|
911
|
+
enabled: _optionalChain([options, 'optionalAccess', _55 => _55.enabled]) !== false && !!client.getAccessToken()
|
|
912
|
+
});
|
|
913
|
+
return { courses: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _56 => _56.items]), () => ( [])), isLoading, error, refetch };
|
|
914
|
+
}
|
|
915
|
+
function useCourse(courseId, options) {
|
|
916
|
+
const { client } = useBehio();
|
|
917
|
+
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
918
|
+
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
919
|
+
queryKey: [...COURSES_KEY, courseId],
|
|
920
|
+
queryFn: () => unwrap(client.customer.getCourse(courseId)),
|
|
921
|
+
enabled: _optionalChain([options, 'optionalAccess', _57 => _57.enabled]) !== false && !!courseId && !!client.getAccessToken()
|
|
922
|
+
});
|
|
923
|
+
const complete = _reactquery.useMutation.call(void 0, {
|
|
924
|
+
mutationFn: ({ lessonId }) => unwrap(client.customer.completeLesson(courseId, lessonId)),
|
|
925
|
+
onSuccess: () => {
|
|
926
|
+
void queryClient.invalidateQueries({ queryKey: [...COURSES_KEY] });
|
|
927
|
+
}
|
|
928
|
+
});
|
|
929
|
+
return {
|
|
930
|
+
course: data,
|
|
931
|
+
isLoading,
|
|
932
|
+
error,
|
|
933
|
+
refetch,
|
|
934
|
+
completeLesson: (lessonId) => complete.mutateAsync({ lessonId }),
|
|
935
|
+
isCompleting: complete.isPending
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
|
|
903
939
|
// src/react/hooks/use-subscriptions.ts
|
|
904
940
|
|
|
905
941
|
var SUBSCRIPTIONS_KEY = ["behio", "subscriptions"];
|
|
@@ -909,7 +945,7 @@ function useSubscriptions(options) {
|
|
|
909
945
|
const query = _reactquery.useQuery.call(void 0, {
|
|
910
946
|
queryKey: [...SUBSCRIPTIONS_KEY],
|
|
911
947
|
queryFn: () => unwrap(client.subscriptions.list()),
|
|
912
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
948
|
+
enabled: _optionalChain([options, 'optionalAccess', _58 => _58.enabled]) !== false && !!client.getAccessToken()
|
|
913
949
|
});
|
|
914
950
|
const invalidate = () => qc.invalidateQueries({ queryKey: [...SUBSCRIPTIONS_KEY] });
|
|
915
951
|
const pauseMutation = _reactquery.useMutation.call(void 0, {
|
|
@@ -925,7 +961,7 @@ function useSubscriptions(options) {
|
|
|
925
961
|
onSuccess: invalidate
|
|
926
962
|
});
|
|
927
963
|
return {
|
|
928
|
-
subscriptions: _nullishCoalesce(_optionalChain([query, 'access',
|
|
964
|
+
subscriptions: _nullishCoalesce(_optionalChain([query, 'access', _59 => _59.data, 'optionalAccess', _60 => _60.items]), () => ( [])),
|
|
929
965
|
isLoading: query.isLoading,
|
|
930
966
|
error: query.error,
|
|
931
967
|
refetch: query.refetch,
|
|
@@ -955,14 +991,14 @@ function usePickupPoints(input) {
|
|
|
955
991
|
),
|
|
956
992
|
enabled: enabled !== false && !!methodId
|
|
957
993
|
});
|
|
958
|
-
return { pickupPoints: _nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
994
|
+
return { pickupPoints: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _61 => _61.items]), () => ( [])), isLoading, error, refetch };
|
|
959
995
|
}
|
|
960
996
|
|
|
961
997
|
// src/react/hooks/use-shipping-methods.ts
|
|
962
998
|
|
|
963
999
|
function useShippingMethods(options) {
|
|
964
1000
|
const { client, currency: activeCurrency } = useBehio();
|
|
965
|
-
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1001
|
+
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _62 => _62.currency]), () => ( activeCurrency));
|
|
966
1002
|
const { country, cartTotal, cartWeightKg } = _nullishCoalesce(options, () => ( {}));
|
|
967
1003
|
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
968
1004
|
queryKey: [
|
|
@@ -974,9 +1010,9 @@ function useShippingMethods(options) {
|
|
|
974
1010
|
_nullishCoalesce(cartWeightKg, () => ( ""))
|
|
975
1011
|
],
|
|
976
1012
|
queryFn: () => unwrap(client.shipping.listMethods({ currency, country, cartTotal, cartWeightKg })),
|
|
977
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1013
|
+
enabled: _optionalChain([options, 'optionalAccess', _63 => _63.enabled]) !== false
|
|
978
1014
|
});
|
|
979
|
-
return { methods: _nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
1015
|
+
return { methods: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _64 => _64.items]), () => ( [])), isLoading, error, refetch };
|
|
980
1016
|
}
|
|
981
1017
|
|
|
982
1018
|
// src/react/hooks/use-shipping-quote.ts
|
|
@@ -984,7 +1020,7 @@ function useShippingMethods(options) {
|
|
|
984
1020
|
function useShippingQuote(options) {
|
|
985
1021
|
const { client, currency: activeCurrency } = useBehio();
|
|
986
1022
|
const { destinationAddress, items, cartTotal, enabled } = _nullishCoalesce(options, () => ( {}));
|
|
987
|
-
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1023
|
+
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _65 => _65.currency]), () => ( activeCurrency));
|
|
988
1024
|
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
989
1025
|
queryKey: [
|
|
990
1026
|
"behio",
|
|
@@ -1002,22 +1038,22 @@ function useShippingQuote(options) {
|
|
|
1002
1038
|
currency
|
|
1003
1039
|
})
|
|
1004
1040
|
),
|
|
1005
|
-
enabled: enabled !== false && !!_optionalChain([destinationAddress, 'optionalAccess',
|
|
1041
|
+
enabled: enabled !== false && !!_optionalChain([destinationAddress, 'optionalAccess', _66 => _66.country])
|
|
1006
1042
|
});
|
|
1007
|
-
return { quotes: _nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
1043
|
+
return { quotes: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _67 => _67.items]), () => ( [])), isLoading, error, refetch };
|
|
1008
1044
|
}
|
|
1009
1045
|
|
|
1010
1046
|
// src/react/hooks/use-payment-methods.ts
|
|
1011
1047
|
|
|
1012
1048
|
function usePaymentMethods(options) {
|
|
1013
1049
|
const { client, currency: activeCurrency } = useBehio();
|
|
1014
|
-
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1050
|
+
const currency = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _68 => _68.currency]), () => ( activeCurrency));
|
|
1015
1051
|
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
1016
1052
|
queryKey: ["behio", "payment-methods", _nullishCoalesce(currency, () => ( ""))],
|
|
1017
1053
|
queryFn: () => unwrap(client.catalog.listPaymentMethods({ currency })),
|
|
1018
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1054
|
+
enabled: _optionalChain([options, 'optionalAccess', _69 => _69.enabled]) !== false
|
|
1019
1055
|
});
|
|
1020
|
-
return { methods: _nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
1056
|
+
return { methods: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _70 => _70.items]), () => ( [])), isLoading, error, refetch };
|
|
1021
1057
|
}
|
|
1022
1058
|
|
|
1023
1059
|
// src/react/hooks/use-personal-offers.ts
|
|
@@ -1027,7 +1063,7 @@ function usePersonalOffers(options) {
|
|
|
1027
1063
|
const { client } = useBehio();
|
|
1028
1064
|
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
1029
1065
|
const [polledVid, setPolledVid] = _react.useState.call(void 0, null);
|
|
1030
|
-
const explicitVid = _optionalChain([options, 'optionalAccess',
|
|
1066
|
+
const explicitVid = _optionalChain([options, 'optionalAccess', _71 => _71.visitorId]);
|
|
1031
1067
|
_react.useEffect.call(void 0, () => {
|
|
1032
1068
|
if (explicitVid) return;
|
|
1033
1069
|
const read = () => {
|
|
@@ -1046,7 +1082,7 @@ function usePersonalOffers(options) {
|
|
|
1046
1082
|
const { data, isLoading, error, refetch } = _reactquery.useQuery.call(void 0, {
|
|
1047
1083
|
queryKey,
|
|
1048
1084
|
queryFn: () => unwrap(client.getPersonalOffers(visitorId)),
|
|
1049
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1085
|
+
enabled: _optionalChain([options, 'optionalAccess', _72 => _72.enabled]) !== false && !!visitorId
|
|
1050
1086
|
});
|
|
1051
1087
|
const claimMutation = _reactquery.useMutation.call(void 0, {
|
|
1052
1088
|
mutationFn: ({ offerId, email }) => unwrap(client.claimOfferByEmail(offerId, { visitorId, email })),
|
|
@@ -1066,7 +1102,7 @@ function usePersonalOffers(options) {
|
|
|
1066
1102
|
[claimMutation]
|
|
1067
1103
|
);
|
|
1068
1104
|
return {
|
|
1069
|
-
offers: _nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
1105
|
+
offers: _nullishCoalesce(_optionalChain([data, 'optionalAccess', _73 => _73.items]), () => ( [])),
|
|
1070
1106
|
/** Resolved consent-gated visitor id (null before consent). */
|
|
1071
1107
|
visitorId: _nullishCoalesce(visitorId, () => ( null)),
|
|
1072
1108
|
isLoading,
|
|
@@ -1088,7 +1124,7 @@ function useAnalyticsEvents() {
|
|
|
1088
1124
|
const list = Array.isArray(events) ? events : [events];
|
|
1089
1125
|
if (list.length === 0) return Promise.resolve();
|
|
1090
1126
|
return client.sendAnalyticsEvents({
|
|
1091
|
-
sessionId: _optionalChain([opts, 'optionalAccess',
|
|
1127
|
+
sessionId: _optionalChain([opts, 'optionalAccess', _74 => _74.sessionId]),
|
|
1092
1128
|
visitorId: _nullishCoalesce(client.getAnalyticsVisitorId(), () => ( void 0)),
|
|
1093
1129
|
events: list.map((e) => ({ ts: Date.now(), ...e }))
|
|
1094
1130
|
});
|
|
@@ -1140,10 +1176,10 @@ function useOrders(options) {
|
|
|
1140
1176
|
enabled: enabled !== false && !!client.getAccessToken()
|
|
1141
1177
|
});
|
|
1142
1178
|
const items = _react.useMemo.call(void 0,
|
|
1143
|
-
() => _nullishCoalesce(_optionalChain([infinite, 'access',
|
|
1179
|
+
() => _nullishCoalesce(_optionalChain([infinite, 'access', _75 => _75.data, 'optionalAccess', _76 => _76.pages, 'access', _77 => _77.flatMap, 'call', _78 => _78((p) => p.items)]), () => ( [])),
|
|
1144
1180
|
[infinite.data]
|
|
1145
1181
|
);
|
|
1146
|
-
const lastPage = _optionalChain([infinite, 'access',
|
|
1182
|
+
const lastPage = _optionalChain([infinite, 'access', _79 => _79.data, 'optionalAccess', _80 => _80.pages, 'access', _81 => _81[infinite.data.pages.length - 1]]);
|
|
1147
1183
|
const loadMore = _react.useCallback.call(void 0, () => {
|
|
1148
1184
|
if (infinite.hasNextPage && !infinite.isFetchingNextPage) {
|
|
1149
1185
|
return infinite.fetchNextPage();
|
|
@@ -1156,10 +1192,10 @@ function useOrders(options) {
|
|
|
1156
1192
|
return {
|
|
1157
1193
|
items,
|
|
1158
1194
|
data: infinite.data,
|
|
1159
|
-
total: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess',
|
|
1160
|
-
totalPages: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess',
|
|
1161
|
-
currentPage: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess',
|
|
1162
|
-
limit: _nullishCoalesce(_nullishCoalesce(_optionalChain([lastPage, 'optionalAccess',
|
|
1195
|
+
total: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _82 => _82.total]), () => ( 0)),
|
|
1196
|
+
totalPages: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _83 => _83.totalPages]), () => ( 0)),
|
|
1197
|
+
currentPage: _nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _84 => _84.page]), () => ( page)),
|
|
1198
|
+
limit: _nullishCoalesce(_nullishCoalesce(_optionalChain([lastPage, 'optionalAccess', _85 => _85.limit]), () => ( limit)), () => ( 20)),
|
|
1163
1199
|
page,
|
|
1164
1200
|
setPage: goToPage,
|
|
1165
1201
|
loadMore,
|
|
@@ -1188,7 +1224,7 @@ function useOrder(orderNumber, options) {
|
|
|
1188
1224
|
} = _reactquery.useQuery.call(void 0, {
|
|
1189
1225
|
queryKey: ["behio", "order", orderNumber],
|
|
1190
1226
|
queryFn: () => unwrap(client.orders.get(orderNumber)),
|
|
1191
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1227
|
+
enabled: _optionalChain([options, 'optionalAccess', _86 => _86.enabled]) !== false && !!orderNumber && !!client.getAccessToken()
|
|
1192
1228
|
});
|
|
1193
1229
|
const cancelMutation = _reactquery.useMutation.call(void 0, {
|
|
1194
1230
|
mutationFn: () => unwrap(client.orders.cancel(orderNumber)),
|
|
@@ -1313,7 +1349,7 @@ function usePages(locale, options) {
|
|
|
1313
1349
|
const result = await unwrap(client.pages.list(locale));
|
|
1314
1350
|
return result.pages;
|
|
1315
1351
|
},
|
|
1316
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1352
|
+
enabled: _optionalChain([options, 'optionalAccess', _87 => _87.enabled]) !== false
|
|
1317
1353
|
});
|
|
1318
1354
|
}
|
|
1319
1355
|
function usePage(slug, locale, options) {
|
|
@@ -1321,7 +1357,7 @@ function usePage(slug, locale, options) {
|
|
|
1321
1357
|
return _reactquery.useQuery.call(void 0, {
|
|
1322
1358
|
queryKey: ["behio", "page", slug, locale],
|
|
1323
1359
|
queryFn: () => unwrap(client.pages.get(slug, locale)),
|
|
1324
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1360
|
+
enabled: _optionalChain([options, 'optionalAccess', _88 => _88.enabled]) !== false && !!slug
|
|
1325
1361
|
});
|
|
1326
1362
|
}
|
|
1327
1363
|
|
|
@@ -1332,7 +1368,7 @@ function useShopInfo(options) {
|
|
|
1332
1368
|
return _reactquery.useQuery.call(void 0, {
|
|
1333
1369
|
queryKey: ["behio", "shop-info"],
|
|
1334
1370
|
queryFn: () => unwrap(client.getShopInfo()),
|
|
1335
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1371
|
+
enabled: _optionalChain([options, 'optionalAccess', _89 => _89.enabled]) !== false
|
|
1336
1372
|
});
|
|
1337
1373
|
}
|
|
1338
1374
|
|
|
@@ -1343,7 +1379,7 @@ function useShopScripts(options) {
|
|
|
1343
1379
|
return _reactquery.useQuery.call(void 0, {
|
|
1344
1380
|
queryKey: ["behio", "shop-scripts"],
|
|
1345
1381
|
queryFn: () => unwrap(client.getShopScripts()),
|
|
1346
|
-
enabled: _optionalChain([options, 'optionalAccess',
|
|
1382
|
+
enabled: _optionalChain([options, 'optionalAccess', _90 => _90.enabled]) !== false
|
|
1347
1383
|
});
|
|
1348
1384
|
}
|
|
1349
1385
|
|
|
@@ -1371,8 +1407,8 @@ function dedupe(values) {
|
|
|
1371
1407
|
function useCurrency() {
|
|
1372
1408
|
const { currency, setCurrency, configuredDefaultCurrency, configuredCurrencies } = useBehio();
|
|
1373
1409
|
const { data: shop, isLoading } = useShopInfo();
|
|
1374
|
-
const defaultCurrency = _nullishCoalesce(configuredDefaultCurrency, () => ( _optionalChain([shop, 'optionalAccess',
|
|
1375
|
-
const currencies = configuredCurrencies && configuredCurrencies.length > 0 ? dedupe(configuredCurrencies) : dedupe([defaultCurrency, ..._nullishCoalesce(_optionalChain([shop, 'optionalAccess',
|
|
1410
|
+
const defaultCurrency = _nullishCoalesce(configuredDefaultCurrency, () => ( _optionalChain([shop, 'optionalAccess', _91 => _91.defaultCurrency])));
|
|
1411
|
+
const currencies = configuredCurrencies && configuredCurrencies.length > 0 ? dedupe(configuredCurrencies) : dedupe([defaultCurrency, ..._nullishCoalesce(_optionalChain([shop, 'optionalAccess', _92 => _92.supportedCurrencies]), () => ( []))]);
|
|
1376
1412
|
return {
|
|
1377
1413
|
currency,
|
|
1378
1414
|
effectiveCurrency: _nullishCoalesce(currency, () => ( defaultCurrency)),
|
|
@@ -1395,7 +1431,7 @@ function CurrencySwitcher({
|
|
|
1395
1431
|
const { currencies, effectiveCurrency, setCurrency } = useCurrency();
|
|
1396
1432
|
if (currencies.length === 0) return null;
|
|
1397
1433
|
if (currencies.length <= 1 && !showWhenSingle) return null;
|
|
1398
|
-
const label = (code) => _nullishCoalesce(_optionalChain([labels, 'optionalAccess',
|
|
1434
|
+
const label = (code) => _nullishCoalesce(_optionalChain([labels, 'optionalAccess', _93 => _93[code]]), () => ( code));
|
|
1399
1435
|
if (children) {
|
|
1400
1436
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: children({ currencies, value: effectiveCurrency, setCurrency, label }) });
|
|
1401
1437
|
}
|
|
@@ -1512,9 +1548,9 @@ function StorefrontScripts({ visitorId: visitorIdProp } = {}) {
|
|
|
1512
1548
|
}
|
|
1513
1549
|
}, [visitorIdProp]);
|
|
1514
1550
|
const { data: consent } = useCookieConsent(visitorId || void 0);
|
|
1515
|
-
const analyticsOk = Boolean(_optionalChain([consent, 'optionalAccess',
|
|
1551
|
+
const analyticsOk = Boolean(_optionalChain([consent, 'optionalAccess', _94 => _94.analytics]));
|
|
1516
1552
|
const scripts = _react.useMemo.call(void 0,
|
|
1517
|
-
() => (_nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
1553
|
+
() => (_nullishCoalesce(_optionalChain([data, 'optionalAccess', _95 => _95.scripts]), () => ( []))).filter((s) => !s.consentRequired || analyticsOk),
|
|
1518
1554
|
[data, analyticsOk]
|
|
1519
1555
|
);
|
|
1520
1556
|
const signature = _react.useMemo.call(void 0,
|
|
@@ -1579,7 +1615,7 @@ function initTracker(client) {
|
|
|
1579
1615
|
return;
|
|
1580
1616
|
}
|
|
1581
1617
|
const { data } = await client.consent.get(stored);
|
|
1582
|
-
const granted = Boolean(_optionalChain([data, 'optionalAccess',
|
|
1618
|
+
const granted = Boolean(_optionalChain([data, 'optionalAccess', _96 => _96.analytics]));
|
|
1583
1619
|
visitorId = granted ? stored : void 0;
|
|
1584
1620
|
client.setAnalyticsVisitorId(granted ? stored : null);
|
|
1585
1621
|
} catch (e7) {
|
|
@@ -1663,7 +1699,7 @@ function initTracker(client) {
|
|
|
1663
1699
|
};
|
|
1664
1700
|
const onClick = (ev) => {
|
|
1665
1701
|
const target = ev.target;
|
|
1666
|
-
const el = _optionalChain([target, 'optionalAccess',
|
|
1702
|
+
const el = _optionalChain([target, 'optionalAccess', _97 => _97.closest, 'optionalCall', _98 => _98("a,button,[role=button],[data-behio-event]")]);
|
|
1667
1703
|
if (!el) return;
|
|
1668
1704
|
const explicit = _nullishCoalesce(el.getAttribute("data-behio-event"), () => ( void 0));
|
|
1669
1705
|
const text = (_nullishCoalesce(el.textContent, () => ( ""))).trim().replace(/\s+/g, " ").slice(0, 80) || void 0;
|
|
@@ -1717,7 +1753,7 @@ function initTracker(client) {
|
|
|
1717
1753
|
items: items.length,
|
|
1718
1754
|
// First item id = the product (view_item/add_to_cart are
|
|
1719
1755
|
// single-product in practice) - Behavioral Offers count on it.
|
|
1720
|
-
itemId: _optionalChain([items, 'access',
|
|
1756
|
+
itemId: _optionalChain([items, 'access', _99 => _99[0], 'optionalAccess', _100 => _100.item_id])
|
|
1721
1757
|
} : {}
|
|
1722
1758
|
};
|
|
1723
1759
|
enqueue({
|
|
@@ -1793,8 +1829,8 @@ function useBundles(options) {
|
|
|
1793
1829
|
return _reactquery.useQuery.call(void 0, {
|
|
1794
1830
|
queryKey: ["behio", "bundles"],
|
|
1795
1831
|
queryFn: () => unwrap(client.catalog.getBundles()),
|
|
1796
|
-
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1797
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1832
|
+
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _101 => _101.enabled]), () => ( true)),
|
|
1833
|
+
initialData: _optionalChain([options, 'optionalAccess', _102 => _102.initialData])
|
|
1798
1834
|
});
|
|
1799
1835
|
}
|
|
1800
1836
|
function useBundle(slug, options) {
|
|
@@ -1802,8 +1838,8 @@ function useBundle(slug, options) {
|
|
|
1802
1838
|
return _reactquery.useQuery.call(void 0, {
|
|
1803
1839
|
queryKey: ["behio", "bundle", slug],
|
|
1804
1840
|
queryFn: () => unwrap(client.catalog.getBundle(slug)),
|
|
1805
|
-
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1806
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1841
|
+
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _103 => _103.enabled]), () => ( true))),
|
|
1842
|
+
initialData: _optionalChain([options, 'optionalAccess', _104 => _104.initialData])
|
|
1807
1843
|
});
|
|
1808
1844
|
}
|
|
1809
1845
|
|
|
@@ -1812,15 +1848,15 @@ function useBundle(slug, options) {
|
|
|
1812
1848
|
function useProductGroup(slug, options) {
|
|
1813
1849
|
const { client } = useBehio();
|
|
1814
1850
|
return _reactquery.useQuery.call(void 0, {
|
|
1815
|
-
queryKey: ["behio", "product-group", slug, _optionalChain([options, 'optionalAccess',
|
|
1851
|
+
queryKey: ["behio", "product-group", slug, _optionalChain([options, 'optionalAccess', _105 => _105.locale]), _optionalChain([options, 'optionalAccess', _106 => _106.currency])],
|
|
1816
1852
|
queryFn: () => unwrap(
|
|
1817
1853
|
client.catalog.getProductGroup(slug, {
|
|
1818
|
-
locale: _optionalChain([options, 'optionalAccess',
|
|
1819
|
-
currency: _optionalChain([options, 'optionalAccess',
|
|
1854
|
+
locale: _optionalChain([options, 'optionalAccess', _107 => _107.locale]),
|
|
1855
|
+
currency: _optionalChain([options, 'optionalAccess', _108 => _108.currency])
|
|
1820
1856
|
})
|
|
1821
1857
|
),
|
|
1822
|
-
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1823
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1858
|
+
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _109 => _109.enabled]), () => ( true))),
|
|
1859
|
+
initialData: _optionalChain([options, 'optionalAccess', _110 => _110.initialData])
|
|
1824
1860
|
});
|
|
1825
1861
|
}
|
|
1826
1862
|
|
|
@@ -1829,15 +1865,15 @@ function useProductGroup(slug, options) {
|
|
|
1829
1865
|
function useCrossSell(productSlug, options) {
|
|
1830
1866
|
const { client } = useBehio();
|
|
1831
1867
|
return _reactquery.useQuery.call(void 0, {
|
|
1832
|
-
queryKey: ["behio", "cross-sell", productSlug, _optionalChain([options, 'optionalAccess',
|
|
1868
|
+
queryKey: ["behio", "cross-sell", productSlug, _optionalChain([options, 'optionalAccess', _111 => _111.locale]), _optionalChain([options, 'optionalAccess', _112 => _112.currency])],
|
|
1833
1869
|
queryFn: () => unwrap(
|
|
1834
1870
|
client.catalog.getCrossSell(productSlug, {
|
|
1835
|
-
locale: _optionalChain([options, 'optionalAccess',
|
|
1836
|
-
currency: _optionalChain([options, 'optionalAccess',
|
|
1871
|
+
locale: _optionalChain([options, 'optionalAccess', _113 => _113.locale]),
|
|
1872
|
+
currency: _optionalChain([options, 'optionalAccess', _114 => _114.currency])
|
|
1837
1873
|
})
|
|
1838
1874
|
),
|
|
1839
|
-
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1840
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1875
|
+
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _115 => _115.enabled]), () => ( true))),
|
|
1876
|
+
initialData: _optionalChain([options, 'optionalAccess', _116 => _116.initialData])
|
|
1841
1877
|
});
|
|
1842
1878
|
}
|
|
1843
1879
|
|
|
@@ -1848,8 +1884,8 @@ function useProductPromotions(productSlug, options) {
|
|
|
1848
1884
|
return _reactquery.useQuery.call(void 0, {
|
|
1849
1885
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
1850
1886
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
1851
|
-
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1852
|
-
refetchInterval: _optionalChain([options, 'optionalAccess',
|
|
1887
|
+
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _117 => _117.enabled]), () => ( true))),
|
|
1888
|
+
refetchInterval: _optionalChain([options, 'optionalAccess', _118 => _118.refetchIntervalMs])
|
|
1853
1889
|
});
|
|
1854
1890
|
}
|
|
1855
1891
|
|
|
@@ -1857,11 +1893,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
1857
1893
|
|
|
1858
1894
|
function useGiftCardBalance(code, options) {
|
|
1859
1895
|
const { client } = useBehio();
|
|
1860
|
-
const trimmed = _optionalChain([code, 'optionalAccess',
|
|
1896
|
+
const trimmed = _optionalChain([code, 'optionalAccess', _119 => _119.trim, 'call', _120 => _120()]);
|
|
1861
1897
|
return _reactquery.useQuery.call(void 0, {
|
|
1862
1898
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
1863
1899
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
1864
|
-
enabled: Boolean(trimmed && trimmed.length >= 6) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1900
|
+
enabled: Boolean(trimmed && trimmed.length >= 6) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _121 => _121.enabled]), () => ( true)))
|
|
1865
1901
|
});
|
|
1866
1902
|
}
|
|
1867
1903
|
|
|
@@ -1873,7 +1909,7 @@ function useWishlist(options) {
|
|
|
1873
1909
|
const query = _reactquery.useQuery.call(void 0, {
|
|
1874
1910
|
queryKey: ["behio", "wishlist"],
|
|
1875
1911
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
1876
|
-
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1912
|
+
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _122 => _122.enabled]), () => ( true))
|
|
1877
1913
|
});
|
|
1878
1914
|
const addMutation = _reactquery.useMutation.call(void 0, {
|
|
1879
1915
|
mutationFn: (productId) => unwrap(client.wishlist.add(productId)),
|
|
@@ -1905,9 +1941,9 @@ function useIsInWishlist(productId) {
|
|
|
1905
1941
|
function useProductReviews(productId, options) {
|
|
1906
1942
|
const { client } = useBehio();
|
|
1907
1943
|
return _reactquery.useQuery.call(void 0, {
|
|
1908
|
-
queryKey: ["behio", "reviews", productId, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1909
|
-
queryFn: () => unwrap(client.reviews.getProductReviews(productId, _optionalChain([options, 'optionalAccess',
|
|
1910
|
-
enabled: Boolean(productId) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1944
|
+
queryKey: ["behio", "reviews", productId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _123 => _123.page]), () => ( 1))],
|
|
1945
|
+
queryFn: () => unwrap(client.reviews.getProductReviews(productId, _optionalChain([options, 'optionalAccess', _124 => _124.page]), _optionalChain([options, 'optionalAccess', _125 => _125.limit]))),
|
|
1946
|
+
enabled: Boolean(productId) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _126 => _126.enabled]), () => ( true)))
|
|
1911
1947
|
});
|
|
1912
1948
|
}
|
|
1913
1949
|
function useSubmitReview() {
|
|
@@ -2038,4 +2074,6 @@ function useNotifyWhenAvailable() {
|
|
|
2038
2074
|
|
|
2039
2075
|
|
|
2040
2076
|
|
|
2041
|
-
|
|
2077
|
+
|
|
2078
|
+
|
|
2079
|
+
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.useCourse = useCourse; exports.useCourses = useCourses; exports.useCrossSell = useCrossSell; exports.useCurrency = useCurrency; exports.useCustomer = useCustomer; exports.useFacets = useFacets; 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;
|