@behio/storefront-sdk 2.19.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -1
- package/dist/{chunk-NBYEO5KC.js → chunk-L7IIU5MZ.js} +26 -5
- package/dist/{chunk-N6YG4AJ4.mjs → chunk-VHHDIU6J.mjs} +21 -0
- package/dist/{client-CeIGiIf2.d.mts → client-C5ODb5cR.d.mts} +76 -2
- package/dist/{client-CeIGiIf2.d.ts → client-C5ODb5cR.d.ts} +76 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- 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 +121 -2
- package/dist/react.d.ts +121 -2
- package/dist/react.js +100 -44
- package/dist/react.mjs +83 -30
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(react_exports, {
|
|
|
24
24
|
BehioAnalyticsTracker: () => BehioAnalyticsTracker,
|
|
25
25
|
BehioProvider: () => BehioProvider,
|
|
26
26
|
CurrencySwitcher: () => CurrencySwitcher,
|
|
27
|
+
RichText: () => RichText,
|
|
27
28
|
StorefrontScripts: () => StorefrontScripts,
|
|
28
29
|
cookieStorage: () => cookieStorage,
|
|
29
30
|
createMemoryStorage: () => createMemoryStorage,
|
|
@@ -64,6 +65,8 @@ __export(react_exports, {
|
|
|
64
65
|
useCurrency: () => useCurrency,
|
|
65
66
|
useCustomer: () => useCustomer,
|
|
66
67
|
useFacets: () => useFacets,
|
|
68
|
+
useFaqGroup: () => useFaqGroup,
|
|
69
|
+
useFaqGroups: () => useFaqGroups,
|
|
67
70
|
useFeatured: () => useFeatured,
|
|
68
71
|
useFilters: () => useFilters,
|
|
69
72
|
useGiftCardBalance: () => useGiftCardBalance,
|
|
@@ -284,6 +287,7 @@ var BehioStorefront = class {
|
|
|
284
287
|
this.blog = new BlogModule(this);
|
|
285
288
|
this.forms = new FormsModule(this);
|
|
286
289
|
this.collections = new CollectionsModule(this);
|
|
290
|
+
this.faq = new FaqModule(this);
|
|
287
291
|
this.wishlist = new WishlistModule(this);
|
|
288
292
|
this.reviews = new ReviewsModule(this);
|
|
289
293
|
this.returns = new ReturnsModule(this);
|
|
@@ -1940,6 +1944,26 @@ var CollectionsModule = class {
|
|
|
1940
1944
|
);
|
|
1941
1945
|
}
|
|
1942
1946
|
};
|
|
1947
|
+
var FaqModule = class {
|
|
1948
|
+
constructor(client) {
|
|
1949
|
+
this.client = client;
|
|
1950
|
+
}
|
|
1951
|
+
/** FAQ groups of the site in the admin order with the number of visible questions. */
|
|
1952
|
+
async list(query) {
|
|
1953
|
+
return this.client.request("GET", "/faq", {
|
|
1954
|
+
query: { locale: query?.locale }
|
|
1955
|
+
});
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* One group by its slug or id with its visible questions. 404
|
|
1959
|
+
* `be.faq.groupNotFound` for an unknown group.
|
|
1960
|
+
*/
|
|
1961
|
+
async get(group, query) {
|
|
1962
|
+
return this.client.request("GET", `/faq/${encodeURIComponent(group)}`, {
|
|
1963
|
+
query: { locale: query?.locale }
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1966
|
+
};
|
|
1943
1967
|
var FormsModule = class {
|
|
1944
1968
|
constructor(client) {
|
|
1945
1969
|
this.client = client;
|
|
@@ -4115,9 +4139,28 @@ function useCollectionItem(slug, itemSlugOrId, options) {
|
|
|
4115
4139
|
});
|
|
4116
4140
|
}
|
|
4117
4141
|
|
|
4142
|
+
// src/react/hooks/use-faq.ts
|
|
4143
|
+
var import_react_query38 = require("@tanstack/react-query");
|
|
4144
|
+
function useFaqGroups(query, options) {
|
|
4145
|
+
const { client } = useBehio();
|
|
4146
|
+
return (0, import_react_query38.useQuery)({
|
|
4147
|
+
queryKey: ["behio", "faq", query?.locale],
|
|
4148
|
+
queryFn: () => unwrap(client.faq.list(query)),
|
|
4149
|
+
enabled: options?.enabled !== false
|
|
4150
|
+
});
|
|
4151
|
+
}
|
|
4152
|
+
function useFaqGroup(group, query, options) {
|
|
4153
|
+
const { client } = useBehio();
|
|
4154
|
+
return (0, import_react_query38.useQuery)({
|
|
4155
|
+
queryKey: ["behio", "faq", group, query?.locale],
|
|
4156
|
+
queryFn: () => unwrap(client.faq.get(group, query)),
|
|
4157
|
+
enabled: options?.enabled !== false && !!group
|
|
4158
|
+
});
|
|
4159
|
+
}
|
|
4160
|
+
|
|
4118
4161
|
// src/react/hooks/use-site-form.ts
|
|
4119
4162
|
var import_react17 = require("react");
|
|
4120
|
-
var
|
|
4163
|
+
var import_react_query39 = require("@tanstack/react-query");
|
|
4121
4164
|
|
|
4122
4165
|
// src/errors.ts
|
|
4123
4166
|
function bodyOf(err) {
|
|
@@ -4168,7 +4211,7 @@ function formFieldErrors(err) {
|
|
|
4168
4211
|
// src/react/hooks/use-site-form.ts
|
|
4169
4212
|
function useSiteForm(slug, options) {
|
|
4170
4213
|
const { client } = useBehio();
|
|
4171
|
-
return (0,
|
|
4214
|
+
return (0, import_react_query39.useQuery)({
|
|
4172
4215
|
queryKey: ["behio", "form", slug],
|
|
4173
4216
|
queryFn: () => unwrap(client.forms.get(slug)),
|
|
4174
4217
|
enabled: options?.enabled !== false && !!slug
|
|
@@ -4176,7 +4219,7 @@ function useSiteForm(slug, options) {
|
|
|
4176
4219
|
}
|
|
4177
4220
|
function useSiteFormSubmit(slug) {
|
|
4178
4221
|
const { client } = useBehio();
|
|
4179
|
-
const mutation = (0,
|
|
4222
|
+
const mutation = (0, import_react_query39.useMutation)({
|
|
4180
4223
|
mutationFn: (input) => unwrap(client.forms.submit(slug, input))
|
|
4181
4224
|
});
|
|
4182
4225
|
const sdkError = mutation.error instanceof UnwrappedError ? mutation.error.sdkError : null;
|
|
@@ -4212,10 +4255,10 @@ function useSiteFormSubmit(slug) {
|
|
|
4212
4255
|
}
|
|
4213
4256
|
|
|
4214
4257
|
// src/react/hooks/use-shop-info.ts
|
|
4215
|
-
var
|
|
4258
|
+
var import_react_query40 = require("@tanstack/react-query");
|
|
4216
4259
|
function useShopInfo(options) {
|
|
4217
4260
|
const { client } = useBehio();
|
|
4218
|
-
return (0,
|
|
4261
|
+
return (0, import_react_query40.useQuery)({
|
|
4219
4262
|
queryKey: ["behio", "shop-info"],
|
|
4220
4263
|
queryFn: () => unwrap(client.getShopInfo()),
|
|
4221
4264
|
enabled: options?.enabled !== false
|
|
@@ -4223,10 +4266,10 @@ function useShopInfo(options) {
|
|
|
4223
4266
|
}
|
|
4224
4267
|
|
|
4225
4268
|
// src/react/hooks/use-shop-scripts.ts
|
|
4226
|
-
var
|
|
4269
|
+
var import_react_query41 = require("@tanstack/react-query");
|
|
4227
4270
|
function useShopScripts(options) {
|
|
4228
4271
|
const { client } = useBehio();
|
|
4229
|
-
return (0,
|
|
4272
|
+
return (0, import_react_query41.useQuery)({
|
|
4230
4273
|
queryKey: ["behio", "shop-scripts"],
|
|
4231
4274
|
queryFn: () => unwrap(client.getShopScripts()),
|
|
4232
4275
|
enabled: options?.enabled !== false,
|
|
@@ -4235,11 +4278,11 @@ function useShopScripts(options) {
|
|
|
4235
4278
|
}
|
|
4236
4279
|
|
|
4237
4280
|
// src/react/hooks/use-shop-seo.ts
|
|
4238
|
-
var
|
|
4281
|
+
var import_react_query42 = require("@tanstack/react-query");
|
|
4239
4282
|
function useShopSeo(options) {
|
|
4240
4283
|
const { client } = useBehio();
|
|
4241
4284
|
const { locale, initialData, enabled = true } = options ?? {};
|
|
4242
|
-
return (0,
|
|
4285
|
+
return (0, import_react_query42.useQuery)({
|
|
4243
4286
|
queryKey: ["behio", "shop-seo", locale ?? "_default"],
|
|
4244
4287
|
queryFn: () => unwrap(client.getShopSeo(locale)),
|
|
4245
4288
|
initialData,
|
|
@@ -4302,20 +4345,20 @@ function CurrencySwitcher({
|
|
|
4302
4345
|
var import_react18 = require("react");
|
|
4303
4346
|
|
|
4304
4347
|
// src/react/hooks/use-consent.ts
|
|
4305
|
-
var
|
|
4348
|
+
var import_react_query43 = require("@tanstack/react-query");
|
|
4306
4349
|
function useCookieConsent(visitorId) {
|
|
4307
4350
|
const { client } = useBehio();
|
|
4308
|
-
const qc = (0,
|
|
4309
|
-
const query = (0,
|
|
4351
|
+
const qc = (0, import_react_query43.useQueryClient)();
|
|
4352
|
+
const query = (0, import_react_query43.useQuery)({
|
|
4310
4353
|
queryKey: ["behio", "consent", visitorId],
|
|
4311
4354
|
queryFn: () => unwrap(client.consent.get(visitorId)),
|
|
4312
4355
|
enabled: Boolean(visitorId)
|
|
4313
4356
|
});
|
|
4314
|
-
const recordMutation = (0,
|
|
4357
|
+
const recordMutation = (0, import_react_query43.useMutation)({
|
|
4315
4358
|
mutationFn: (input) => unwrap(client.consent.record(input)),
|
|
4316
4359
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
4317
4360
|
});
|
|
4318
|
-
const revokeMutation = (0,
|
|
4361
|
+
const revokeMutation = (0, import_react_query43.useMutation)({
|
|
4319
4362
|
mutationFn: () => unwrap(client.consent.revoke(visitorId)),
|
|
4320
4363
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
4321
4364
|
});
|
|
@@ -4683,12 +4726,22 @@ function utmFromSearch(search) {
|
|
|
4683
4726
|
}
|
|
4684
4727
|
}
|
|
4685
4728
|
|
|
4729
|
+
// src/react/components/rich-text.tsx
|
|
4730
|
+
var import_react20 = require("react");
|
|
4731
|
+
function RichText({ html, className, as = "div" }) {
|
|
4732
|
+
if (!html) return null;
|
|
4733
|
+
return (0, import_react20.createElement)(as, {
|
|
4734
|
+
className: className ? `behio-rich-text ${className}` : "behio-rich-text",
|
|
4735
|
+
dangerouslySetInnerHTML: { __html: html }
|
|
4736
|
+
});
|
|
4737
|
+
}
|
|
4738
|
+
|
|
4686
4739
|
// src/react/hooks/use-bundles.ts
|
|
4687
|
-
var
|
|
4740
|
+
var import_react_query44 = require("@tanstack/react-query");
|
|
4688
4741
|
function useBundles(options) {
|
|
4689
4742
|
const { client, sessionRestored } = useBehio();
|
|
4690
4743
|
const query = { locale: options?.locale ?? client.getLocale(), currency: options?.currency ?? client.getCurrency(), country: options?.country ?? client.getCountry() };
|
|
4691
|
-
return (0,
|
|
4744
|
+
return (0, import_react_query44.useQuery)({
|
|
4692
4745
|
queryKey: ["behio", "bundles", query],
|
|
4693
4746
|
queryFn: () => unwrap(client.catalog.getBundles(query)),
|
|
4694
4747
|
enabled: sessionRestored && (options?.enabled ?? true),
|
|
@@ -4698,7 +4751,7 @@ function useBundles(options) {
|
|
|
4698
4751
|
function useBundle(slug, options) {
|
|
4699
4752
|
const { client, sessionRestored } = useBehio();
|
|
4700
4753
|
const query = { locale: options?.locale ?? client.getLocale(), currency: options?.currency ?? client.getCurrency(), country: options?.country ?? client.getCountry() };
|
|
4701
|
-
return (0,
|
|
4754
|
+
return (0, import_react_query44.useQuery)({
|
|
4702
4755
|
queryKey: ["behio", "bundle", slug, query],
|
|
4703
4756
|
queryFn: () => unwrap(client.catalog.getBundle(slug, query)),
|
|
4704
4757
|
enabled: sessionRestored && Boolean(slug) && (options?.enabled ?? true),
|
|
@@ -4707,10 +4760,10 @@ function useBundle(slug, options) {
|
|
|
4707
4760
|
}
|
|
4708
4761
|
|
|
4709
4762
|
// src/react/hooks/use-product-group.ts
|
|
4710
|
-
var
|
|
4763
|
+
var import_react_query45 = require("@tanstack/react-query");
|
|
4711
4764
|
function useProductGroup(slug, options) {
|
|
4712
4765
|
const { client } = useBehio();
|
|
4713
|
-
return (0,
|
|
4766
|
+
return (0, import_react_query45.useQuery)({
|
|
4714
4767
|
queryKey: ["behio", "product-group", slug, options?.locale, options?.currency],
|
|
4715
4768
|
queryFn: () => unwrap(
|
|
4716
4769
|
client.catalog.getProductGroup(slug, {
|
|
@@ -4724,10 +4777,10 @@ function useProductGroup(slug, options) {
|
|
|
4724
4777
|
}
|
|
4725
4778
|
|
|
4726
4779
|
// src/react/hooks/use-cross-sell.ts
|
|
4727
|
-
var
|
|
4780
|
+
var import_react_query46 = require("@tanstack/react-query");
|
|
4728
4781
|
function useCrossSell(productSlug, options) {
|
|
4729
4782
|
const { client } = useBehio();
|
|
4730
|
-
return (0,
|
|
4783
|
+
return (0, import_react_query46.useQuery)({
|
|
4731
4784
|
queryKey: ["behio", "cross-sell", productSlug, options?.locale, options?.currency],
|
|
4732
4785
|
queryFn: () => unwrap(
|
|
4733
4786
|
client.catalog.getCrossSell(productSlug, {
|
|
@@ -4741,10 +4794,10 @@ function useCrossSell(productSlug, options) {
|
|
|
4741
4794
|
}
|
|
4742
4795
|
|
|
4743
4796
|
// src/react/hooks/use-product-promotions.ts
|
|
4744
|
-
var
|
|
4797
|
+
var import_react_query47 = require("@tanstack/react-query");
|
|
4745
4798
|
function useProductPromotions(productSlug, options) {
|
|
4746
4799
|
const { client } = useBehio();
|
|
4747
|
-
return (0,
|
|
4800
|
+
return (0, import_react_query47.useQuery)({
|
|
4748
4801
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
4749
4802
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
4750
4803
|
enabled: Boolean(productSlug) && (options?.enabled ?? true),
|
|
@@ -4753,11 +4806,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
4753
4806
|
}
|
|
4754
4807
|
|
|
4755
4808
|
// src/react/hooks/use-gift-card.ts
|
|
4756
|
-
var
|
|
4809
|
+
var import_react_query48 = require("@tanstack/react-query");
|
|
4757
4810
|
function useGiftCardBalance(code, options) {
|
|
4758
4811
|
const { client } = useBehio();
|
|
4759
4812
|
const trimmed = code?.trim();
|
|
4760
|
-
return (0,
|
|
4813
|
+
return (0, import_react_query48.useQuery)({
|
|
4761
4814
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
4762
4815
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
4763
4816
|
enabled: Boolean(trimmed && trimmed.length >= 6) && (options?.enabled ?? true)
|
|
@@ -4765,20 +4818,20 @@ function useGiftCardBalance(code, options) {
|
|
|
4765
4818
|
}
|
|
4766
4819
|
|
|
4767
4820
|
// src/react/hooks/use-wishlist.ts
|
|
4768
|
-
var
|
|
4821
|
+
var import_react_query49 = require("@tanstack/react-query");
|
|
4769
4822
|
function useWishlist(options) {
|
|
4770
4823
|
const { client } = useBehio();
|
|
4771
|
-
const qc = (0,
|
|
4772
|
-
const query = (0,
|
|
4824
|
+
const qc = (0, import_react_query49.useQueryClient)();
|
|
4825
|
+
const query = (0, import_react_query49.useQuery)({
|
|
4773
4826
|
queryKey: ["behio", "wishlist"],
|
|
4774
4827
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
4775
4828
|
enabled: options?.enabled ?? true
|
|
4776
4829
|
});
|
|
4777
|
-
const addMutation = (0,
|
|
4830
|
+
const addMutation = (0, import_react_query49.useMutation)({
|
|
4778
4831
|
mutationFn: (productId) => unwrap(client.wishlist.add(productId)),
|
|
4779
4832
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "wishlist"] })
|
|
4780
4833
|
});
|
|
4781
|
-
const removeMutation = (0,
|
|
4834
|
+
const removeMutation = (0, import_react_query49.useMutation)({
|
|
4782
4835
|
mutationFn: (productId) => unwrap(client.wishlist.remove(productId)),
|
|
4783
4836
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "wishlist"] })
|
|
4784
4837
|
});
|
|
@@ -4792,7 +4845,7 @@ function useWishlist(options) {
|
|
|
4792
4845
|
}
|
|
4793
4846
|
function useIsInWishlist(productId) {
|
|
4794
4847
|
const { client } = useBehio();
|
|
4795
|
-
return (0,
|
|
4848
|
+
return (0, import_react_query49.useQuery)({
|
|
4796
4849
|
queryKey: ["behio", "wishlist-check", productId],
|
|
4797
4850
|
queryFn: () => unwrap(client.wishlist.isInWishlist(productId)),
|
|
4798
4851
|
enabled: Boolean(productId)
|
|
@@ -4800,10 +4853,10 @@ function useIsInWishlist(productId) {
|
|
|
4800
4853
|
}
|
|
4801
4854
|
|
|
4802
4855
|
// src/react/hooks/use-reviews.ts
|
|
4803
|
-
var
|
|
4856
|
+
var import_react_query50 = require("@tanstack/react-query");
|
|
4804
4857
|
function useProductReviews(productId, options) {
|
|
4805
4858
|
const { client } = useBehio();
|
|
4806
|
-
return (0,
|
|
4859
|
+
return (0, import_react_query50.useQuery)({
|
|
4807
4860
|
queryKey: ["behio", "reviews", productId, options?.page ?? 1, options?.limit ?? 20],
|
|
4808
4861
|
queryFn: () => unwrap(client.reviews.getProductReviews(productId, options?.page, options?.limit)),
|
|
4809
4862
|
initialData: options?.initialData,
|
|
@@ -4813,30 +4866,30 @@ function useProductReviews(productId, options) {
|
|
|
4813
4866
|
}
|
|
4814
4867
|
function useSubmitReview() {
|
|
4815
4868
|
const { client } = useBehio();
|
|
4816
|
-
const qc = (0,
|
|
4817
|
-
return (0,
|
|
4869
|
+
const qc = (0, import_react_query50.useQueryClient)();
|
|
4870
|
+
return (0, import_react_query50.useMutation)({
|
|
4818
4871
|
mutationFn: (input) => unwrap(client.reviews.submit(input)),
|
|
4819
4872
|
onSuccess: (_, input) => qc.invalidateQueries({ queryKey: ["behio", "reviews", input.productId] })
|
|
4820
4873
|
});
|
|
4821
4874
|
}
|
|
4822
4875
|
|
|
4823
4876
|
// src/react/hooks/use-returns.ts
|
|
4824
|
-
var
|
|
4877
|
+
var import_react_query51 = require("@tanstack/react-query");
|
|
4825
4878
|
function useLookupReturnableOrder() {
|
|
4826
4879
|
const { client } = useBehio();
|
|
4827
|
-
return (0,
|
|
4880
|
+
return (0, import_react_query51.useMutation)({
|
|
4828
4881
|
mutationFn: ({ orderNumber, email }) => unwrap(client.returns.lookupOrder(orderNumber, email))
|
|
4829
4882
|
});
|
|
4830
4883
|
}
|
|
4831
4884
|
function useSubmitReturn() {
|
|
4832
4885
|
const { client } = useBehio();
|
|
4833
|
-
return (0,
|
|
4886
|
+
return (0, import_react_query51.useMutation)({
|
|
4834
4887
|
mutationFn: (input) => unwrap(client.returns.submit(input))
|
|
4835
4888
|
});
|
|
4836
4889
|
}
|
|
4837
4890
|
function useReturnStatus(returnId, email) {
|
|
4838
4891
|
const { client } = useBehio();
|
|
4839
|
-
return (0,
|
|
4892
|
+
return (0, import_react_query51.useQuery)({
|
|
4840
4893
|
queryKey: ["behio", "return-status", returnId],
|
|
4841
4894
|
queryFn: () => unwrap(client.returns.getStatus(returnId, email)),
|
|
4842
4895
|
enabled: Boolean(returnId && email)
|
|
@@ -4844,16 +4897,16 @@ function useReturnStatus(returnId, email) {
|
|
|
4844
4897
|
}
|
|
4845
4898
|
|
|
4846
4899
|
// src/react/hooks/use-quotes.ts
|
|
4847
|
-
var
|
|
4900
|
+
var import_react_query52 = require("@tanstack/react-query");
|
|
4848
4901
|
function useSubmitQuote() {
|
|
4849
4902
|
const { client } = useBehio();
|
|
4850
|
-
return (0,
|
|
4903
|
+
return (0, import_react_query52.useMutation)({
|
|
4851
4904
|
mutationFn: (input) => unwrap(client.quotes.submit(input))
|
|
4852
4905
|
});
|
|
4853
4906
|
}
|
|
4854
4907
|
function useQuoteStatus(quoteId, email) {
|
|
4855
4908
|
const { client } = useBehio();
|
|
4856
|
-
return (0,
|
|
4909
|
+
return (0, import_react_query52.useQuery)({
|
|
4857
4910
|
queryKey: ["behio", "quote-status", quoteId],
|
|
4858
4911
|
queryFn: () => unwrap(client.quotes.getStatus(quoteId, email)),
|
|
4859
4912
|
enabled: Boolean(quoteId && email)
|
|
@@ -4861,10 +4914,10 @@ function useQuoteStatus(quoteId, email) {
|
|
|
4861
4914
|
}
|
|
4862
4915
|
|
|
4863
4916
|
// src/react/hooks/use-back-in-stock.ts
|
|
4864
|
-
var
|
|
4917
|
+
var import_react_query53 = require("@tanstack/react-query");
|
|
4865
4918
|
function useNotifyWhenAvailable() {
|
|
4866
4919
|
const { client } = useBehio();
|
|
4867
|
-
return (0,
|
|
4920
|
+
return (0, import_react_query53.useMutation)({
|
|
4868
4921
|
mutationFn: ({ productId, email }) => unwrap(client.catalog.notifyWhenAvailable(productId, email))
|
|
4869
4922
|
});
|
|
4870
4923
|
}
|
|
@@ -4991,6 +5044,7 @@ async function revokeAnalyticsConsent(client) {
|
|
|
4991
5044
|
BehioAnalyticsTracker,
|
|
4992
5045
|
BehioProvider,
|
|
4993
5046
|
CurrencySwitcher,
|
|
5047
|
+
RichText,
|
|
4994
5048
|
StorefrontScripts,
|
|
4995
5049
|
cookieStorage,
|
|
4996
5050
|
createMemoryStorage,
|
|
@@ -5031,6 +5085,8 @@ async function revokeAnalyticsConsent(client) {
|
|
|
5031
5085
|
useCurrency,
|
|
5032
5086
|
useCustomer,
|
|
5033
5087
|
useFacets,
|
|
5088
|
+
useFaqGroup,
|
|
5089
|
+
useFaqGroups,
|
|
5034
5090
|
useFeatured,
|
|
5035
5091
|
useFilters,
|
|
5036
5092
|
useGiftCardBalance,
|
package/dist/react.mjs
CHANGED
|
@@ -172,6 +172,7 @@ var BehioStorefront = class {
|
|
|
172
172
|
this.blog = new BlogModule(this);
|
|
173
173
|
this.forms = new FormsModule(this);
|
|
174
174
|
this.collections = new CollectionsModule(this);
|
|
175
|
+
this.faq = new FaqModule(this);
|
|
175
176
|
this.wishlist = new WishlistModule(this);
|
|
176
177
|
this.reviews = new ReviewsModule(this);
|
|
177
178
|
this.returns = new ReturnsModule(this);
|
|
@@ -1828,6 +1829,26 @@ var CollectionsModule = class {
|
|
|
1828
1829
|
);
|
|
1829
1830
|
}
|
|
1830
1831
|
};
|
|
1832
|
+
var FaqModule = class {
|
|
1833
|
+
constructor(client) {
|
|
1834
|
+
this.client = client;
|
|
1835
|
+
}
|
|
1836
|
+
/** FAQ groups of the site in the admin order with the number of visible questions. */
|
|
1837
|
+
async list(query) {
|
|
1838
|
+
return this.client.request("GET", "/faq", {
|
|
1839
|
+
query: { locale: query?.locale }
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* One group by its slug or id with its visible questions. 404
|
|
1844
|
+
* `be.faq.groupNotFound` for an unknown group.
|
|
1845
|
+
*/
|
|
1846
|
+
async get(group, query) {
|
|
1847
|
+
return this.client.request("GET", `/faq/${encodeURIComponent(group)}`, {
|
|
1848
|
+
query: { locale: query?.locale }
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
};
|
|
1831
1852
|
var FormsModule = class {
|
|
1832
1853
|
constructor(client) {
|
|
1833
1854
|
this.client = client;
|
|
@@ -4003,9 +4024,28 @@ function useCollectionItem(slug, itemSlugOrId, options) {
|
|
|
4003
4024
|
});
|
|
4004
4025
|
}
|
|
4005
4026
|
|
|
4027
|
+
// src/react/hooks/use-faq.ts
|
|
4028
|
+
import { useQuery as useQuery32 } from "@tanstack/react-query";
|
|
4029
|
+
function useFaqGroups(query, options) {
|
|
4030
|
+
const { client } = useBehio();
|
|
4031
|
+
return useQuery32({
|
|
4032
|
+
queryKey: ["behio", "faq", query?.locale],
|
|
4033
|
+
queryFn: () => unwrap(client.faq.list(query)),
|
|
4034
|
+
enabled: options?.enabled !== false
|
|
4035
|
+
});
|
|
4036
|
+
}
|
|
4037
|
+
function useFaqGroup(group, query, options) {
|
|
4038
|
+
const { client } = useBehio();
|
|
4039
|
+
return useQuery32({
|
|
4040
|
+
queryKey: ["behio", "faq", group, query?.locale],
|
|
4041
|
+
queryFn: () => unwrap(client.faq.get(group, query)),
|
|
4042
|
+
enabled: options?.enabled !== false && !!group
|
|
4043
|
+
});
|
|
4044
|
+
}
|
|
4045
|
+
|
|
4006
4046
|
// src/react/hooks/use-site-form.ts
|
|
4007
4047
|
import { useCallback as useCallback15, useMemo as useMemo4 } from "react";
|
|
4008
|
-
import { useMutation as useMutation15, useQuery as
|
|
4048
|
+
import { useMutation as useMutation15, useQuery as useQuery33 } from "@tanstack/react-query";
|
|
4009
4049
|
|
|
4010
4050
|
// src/errors.ts
|
|
4011
4051
|
function bodyOf(err) {
|
|
@@ -4056,7 +4096,7 @@ function formFieldErrors(err) {
|
|
|
4056
4096
|
// src/react/hooks/use-site-form.ts
|
|
4057
4097
|
function useSiteForm(slug, options) {
|
|
4058
4098
|
const { client } = useBehio();
|
|
4059
|
-
return
|
|
4099
|
+
return useQuery33({
|
|
4060
4100
|
queryKey: ["behio", "form", slug],
|
|
4061
4101
|
queryFn: () => unwrap(client.forms.get(slug)),
|
|
4062
4102
|
enabled: options?.enabled !== false && !!slug
|
|
@@ -4100,10 +4140,10 @@ function useSiteFormSubmit(slug) {
|
|
|
4100
4140
|
}
|
|
4101
4141
|
|
|
4102
4142
|
// src/react/hooks/use-shop-info.ts
|
|
4103
|
-
import { useQuery as
|
|
4143
|
+
import { useQuery as useQuery34 } from "@tanstack/react-query";
|
|
4104
4144
|
function useShopInfo(options) {
|
|
4105
4145
|
const { client } = useBehio();
|
|
4106
|
-
return
|
|
4146
|
+
return useQuery34({
|
|
4107
4147
|
queryKey: ["behio", "shop-info"],
|
|
4108
4148
|
queryFn: () => unwrap(client.getShopInfo()),
|
|
4109
4149
|
enabled: options?.enabled !== false
|
|
@@ -4111,10 +4151,10 @@ function useShopInfo(options) {
|
|
|
4111
4151
|
}
|
|
4112
4152
|
|
|
4113
4153
|
// src/react/hooks/use-shop-scripts.ts
|
|
4114
|
-
import { useQuery as
|
|
4154
|
+
import { useQuery as useQuery35 } from "@tanstack/react-query";
|
|
4115
4155
|
function useShopScripts(options) {
|
|
4116
4156
|
const { client } = useBehio();
|
|
4117
|
-
return
|
|
4157
|
+
return useQuery35({
|
|
4118
4158
|
queryKey: ["behio", "shop-scripts"],
|
|
4119
4159
|
queryFn: () => unwrap(client.getShopScripts()),
|
|
4120
4160
|
enabled: options?.enabled !== false,
|
|
@@ -4123,11 +4163,11 @@ function useShopScripts(options) {
|
|
|
4123
4163
|
}
|
|
4124
4164
|
|
|
4125
4165
|
// src/react/hooks/use-shop-seo.ts
|
|
4126
|
-
import { useQuery as
|
|
4166
|
+
import { useQuery as useQuery36 } from "@tanstack/react-query";
|
|
4127
4167
|
function useShopSeo(options) {
|
|
4128
4168
|
const { client } = useBehio();
|
|
4129
4169
|
const { locale, initialData, enabled = true } = options ?? {};
|
|
4130
|
-
return
|
|
4170
|
+
return useQuery36({
|
|
4131
4171
|
queryKey: ["behio", "shop-seo", locale ?? "_default"],
|
|
4132
4172
|
queryFn: () => unwrap(client.getShopSeo(locale)),
|
|
4133
4173
|
initialData,
|
|
@@ -4190,11 +4230,11 @@ function CurrencySwitcher({
|
|
|
4190
4230
|
import { useEffect as useEffect7, useMemo as useMemo5, useRef as useRef4, useState as useState10 } from "react";
|
|
4191
4231
|
|
|
4192
4232
|
// src/react/hooks/use-consent.ts
|
|
4193
|
-
import { useQuery as
|
|
4233
|
+
import { useQuery as useQuery37, useMutation as useMutation16, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
|
|
4194
4234
|
function useCookieConsent(visitorId) {
|
|
4195
4235
|
const { client } = useBehio();
|
|
4196
4236
|
const qc = useQueryClient16();
|
|
4197
|
-
const query =
|
|
4237
|
+
const query = useQuery37({
|
|
4198
4238
|
queryKey: ["behio", "consent", visitorId],
|
|
4199
4239
|
queryFn: () => unwrap(client.consent.get(visitorId)),
|
|
4200
4240
|
enabled: Boolean(visitorId)
|
|
@@ -4571,12 +4611,22 @@ function utmFromSearch(search) {
|
|
|
4571
4611
|
}
|
|
4572
4612
|
}
|
|
4573
4613
|
|
|
4614
|
+
// src/react/components/rich-text.tsx
|
|
4615
|
+
import { createElement } from "react";
|
|
4616
|
+
function RichText({ html, className, as = "div" }) {
|
|
4617
|
+
if (!html) return null;
|
|
4618
|
+
return createElement(as, {
|
|
4619
|
+
className: className ? `behio-rich-text ${className}` : "behio-rich-text",
|
|
4620
|
+
dangerouslySetInnerHTML: { __html: html }
|
|
4621
|
+
});
|
|
4622
|
+
}
|
|
4623
|
+
|
|
4574
4624
|
// src/react/hooks/use-bundles.ts
|
|
4575
|
-
import { useQuery as
|
|
4625
|
+
import { useQuery as useQuery38 } from "@tanstack/react-query";
|
|
4576
4626
|
function useBundles(options) {
|
|
4577
4627
|
const { client, sessionRestored } = useBehio();
|
|
4578
4628
|
const query = { locale: options?.locale ?? client.getLocale(), currency: options?.currency ?? client.getCurrency(), country: options?.country ?? client.getCountry() };
|
|
4579
|
-
return
|
|
4629
|
+
return useQuery38({
|
|
4580
4630
|
queryKey: ["behio", "bundles", query],
|
|
4581
4631
|
queryFn: () => unwrap(client.catalog.getBundles(query)),
|
|
4582
4632
|
enabled: sessionRestored && (options?.enabled ?? true),
|
|
@@ -4586,7 +4636,7 @@ function useBundles(options) {
|
|
|
4586
4636
|
function useBundle(slug, options) {
|
|
4587
4637
|
const { client, sessionRestored } = useBehio();
|
|
4588
4638
|
const query = { locale: options?.locale ?? client.getLocale(), currency: options?.currency ?? client.getCurrency(), country: options?.country ?? client.getCountry() };
|
|
4589
|
-
return
|
|
4639
|
+
return useQuery38({
|
|
4590
4640
|
queryKey: ["behio", "bundle", slug, query],
|
|
4591
4641
|
queryFn: () => unwrap(client.catalog.getBundle(slug, query)),
|
|
4592
4642
|
enabled: sessionRestored && Boolean(slug) && (options?.enabled ?? true),
|
|
@@ -4595,10 +4645,10 @@ function useBundle(slug, options) {
|
|
|
4595
4645
|
}
|
|
4596
4646
|
|
|
4597
4647
|
// src/react/hooks/use-product-group.ts
|
|
4598
|
-
import { useQuery as
|
|
4648
|
+
import { useQuery as useQuery39 } from "@tanstack/react-query";
|
|
4599
4649
|
function useProductGroup(slug, options) {
|
|
4600
4650
|
const { client } = useBehio();
|
|
4601
|
-
return
|
|
4651
|
+
return useQuery39({
|
|
4602
4652
|
queryKey: ["behio", "product-group", slug, options?.locale, options?.currency],
|
|
4603
4653
|
queryFn: () => unwrap(
|
|
4604
4654
|
client.catalog.getProductGroup(slug, {
|
|
@@ -4612,10 +4662,10 @@ function useProductGroup(slug, options) {
|
|
|
4612
4662
|
}
|
|
4613
4663
|
|
|
4614
4664
|
// src/react/hooks/use-cross-sell.ts
|
|
4615
|
-
import { useQuery as
|
|
4665
|
+
import { useQuery as useQuery40 } from "@tanstack/react-query";
|
|
4616
4666
|
function useCrossSell(productSlug, options) {
|
|
4617
4667
|
const { client } = useBehio();
|
|
4618
|
-
return
|
|
4668
|
+
return useQuery40({
|
|
4619
4669
|
queryKey: ["behio", "cross-sell", productSlug, options?.locale, options?.currency],
|
|
4620
4670
|
queryFn: () => unwrap(
|
|
4621
4671
|
client.catalog.getCrossSell(productSlug, {
|
|
@@ -4629,10 +4679,10 @@ function useCrossSell(productSlug, options) {
|
|
|
4629
4679
|
}
|
|
4630
4680
|
|
|
4631
4681
|
// src/react/hooks/use-product-promotions.ts
|
|
4632
|
-
import { useQuery as
|
|
4682
|
+
import { useQuery as useQuery41 } from "@tanstack/react-query";
|
|
4633
4683
|
function useProductPromotions(productSlug, options) {
|
|
4634
4684
|
const { client } = useBehio();
|
|
4635
|
-
return
|
|
4685
|
+
return useQuery41({
|
|
4636
4686
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
4637
4687
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
4638
4688
|
enabled: Boolean(productSlug) && (options?.enabled ?? true),
|
|
@@ -4641,11 +4691,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
4641
4691
|
}
|
|
4642
4692
|
|
|
4643
4693
|
// src/react/hooks/use-gift-card.ts
|
|
4644
|
-
import { useQuery as
|
|
4694
|
+
import { useQuery as useQuery42 } from "@tanstack/react-query";
|
|
4645
4695
|
function useGiftCardBalance(code, options) {
|
|
4646
4696
|
const { client } = useBehio();
|
|
4647
4697
|
const trimmed = code?.trim();
|
|
4648
|
-
return
|
|
4698
|
+
return useQuery42({
|
|
4649
4699
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
4650
4700
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
4651
4701
|
enabled: Boolean(trimmed && trimmed.length >= 6) && (options?.enabled ?? true)
|
|
@@ -4653,11 +4703,11 @@ function useGiftCardBalance(code, options) {
|
|
|
4653
4703
|
}
|
|
4654
4704
|
|
|
4655
4705
|
// src/react/hooks/use-wishlist.ts
|
|
4656
|
-
import { useQuery as
|
|
4706
|
+
import { useQuery as useQuery43, useMutation as useMutation17, useQueryClient as useQueryClient17 } from "@tanstack/react-query";
|
|
4657
4707
|
function useWishlist(options) {
|
|
4658
4708
|
const { client } = useBehio();
|
|
4659
4709
|
const qc = useQueryClient17();
|
|
4660
|
-
const query =
|
|
4710
|
+
const query = useQuery43({
|
|
4661
4711
|
queryKey: ["behio", "wishlist"],
|
|
4662
4712
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
4663
4713
|
enabled: options?.enabled ?? true
|
|
@@ -4680,7 +4730,7 @@ function useWishlist(options) {
|
|
|
4680
4730
|
}
|
|
4681
4731
|
function useIsInWishlist(productId) {
|
|
4682
4732
|
const { client } = useBehio();
|
|
4683
|
-
return
|
|
4733
|
+
return useQuery43({
|
|
4684
4734
|
queryKey: ["behio", "wishlist-check", productId],
|
|
4685
4735
|
queryFn: () => unwrap(client.wishlist.isInWishlist(productId)),
|
|
4686
4736
|
enabled: Boolean(productId)
|
|
@@ -4688,10 +4738,10 @@ function useIsInWishlist(productId) {
|
|
|
4688
4738
|
}
|
|
4689
4739
|
|
|
4690
4740
|
// src/react/hooks/use-reviews.ts
|
|
4691
|
-
import { useQuery as
|
|
4741
|
+
import { useQuery as useQuery44, useMutation as useMutation18, useQueryClient as useQueryClient18 } from "@tanstack/react-query";
|
|
4692
4742
|
function useProductReviews(productId, options) {
|
|
4693
4743
|
const { client } = useBehio();
|
|
4694
|
-
return
|
|
4744
|
+
return useQuery44({
|
|
4695
4745
|
queryKey: ["behio", "reviews", productId, options?.page ?? 1, options?.limit ?? 20],
|
|
4696
4746
|
queryFn: () => unwrap(client.reviews.getProductReviews(productId, options?.page, options?.limit)),
|
|
4697
4747
|
initialData: options?.initialData,
|
|
@@ -4709,7 +4759,7 @@ function useSubmitReview() {
|
|
|
4709
4759
|
}
|
|
4710
4760
|
|
|
4711
4761
|
// src/react/hooks/use-returns.ts
|
|
4712
|
-
import { useQuery as
|
|
4762
|
+
import { useQuery as useQuery45, useMutation as useMutation19 } from "@tanstack/react-query";
|
|
4713
4763
|
function useLookupReturnableOrder() {
|
|
4714
4764
|
const { client } = useBehio();
|
|
4715
4765
|
return useMutation19({
|
|
@@ -4724,7 +4774,7 @@ function useSubmitReturn() {
|
|
|
4724
4774
|
}
|
|
4725
4775
|
function useReturnStatus(returnId, email) {
|
|
4726
4776
|
const { client } = useBehio();
|
|
4727
|
-
return
|
|
4777
|
+
return useQuery45({
|
|
4728
4778
|
queryKey: ["behio", "return-status", returnId],
|
|
4729
4779
|
queryFn: () => unwrap(client.returns.getStatus(returnId, email)),
|
|
4730
4780
|
enabled: Boolean(returnId && email)
|
|
@@ -4732,7 +4782,7 @@ function useReturnStatus(returnId, email) {
|
|
|
4732
4782
|
}
|
|
4733
4783
|
|
|
4734
4784
|
// src/react/hooks/use-quotes.ts
|
|
4735
|
-
import { useMutation as useMutation20, useQuery as
|
|
4785
|
+
import { useMutation as useMutation20, useQuery as useQuery46 } from "@tanstack/react-query";
|
|
4736
4786
|
function useSubmitQuote() {
|
|
4737
4787
|
const { client } = useBehio();
|
|
4738
4788
|
return useMutation20({
|
|
@@ -4741,7 +4791,7 @@ function useSubmitQuote() {
|
|
|
4741
4791
|
}
|
|
4742
4792
|
function useQuoteStatus(quoteId, email) {
|
|
4743
4793
|
const { client } = useBehio();
|
|
4744
|
-
return
|
|
4794
|
+
return useQuery46({
|
|
4745
4795
|
queryKey: ["behio", "quote-status", quoteId],
|
|
4746
4796
|
queryFn: () => unwrap(client.quotes.getStatus(quoteId, email)),
|
|
4747
4797
|
enabled: Boolean(quoteId && email)
|
|
@@ -4878,6 +4928,7 @@ export {
|
|
|
4878
4928
|
BehioAnalyticsTracker,
|
|
4879
4929
|
BehioProvider,
|
|
4880
4930
|
CurrencySwitcher,
|
|
4931
|
+
RichText,
|
|
4881
4932
|
StorefrontScripts,
|
|
4882
4933
|
cookieStorage,
|
|
4883
4934
|
createMemoryStorage,
|
|
@@ -4918,6 +4969,8 @@ export {
|
|
|
4918
4969
|
useCurrency,
|
|
4919
4970
|
useCustomer,
|
|
4920
4971
|
useFacets,
|
|
4972
|
+
useFaqGroup,
|
|
4973
|
+
useFaqGroups,
|
|
4921
4974
|
useFeatured,
|
|
4922
4975
|
useFilters,
|
|
4923
4976
|
useGiftCardBalance,
|