@behio/storefront-sdk 2.29.0 → 2.30.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/index.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  ok,
13
13
  publishCartSummary,
14
14
  toSdkError
15
- } from "./chunk-YDZ2OF4O.mjs";
15
+ } from "./chunk-25UM2XCS.mjs";
16
16
 
17
17
  // src/react/utils/format-price.ts
18
18
  function formatPrice(amount, currency, locale, display) {
@@ -1203,12 +1203,157 @@ function formFieldErrors(err2) {
1203
1203
  }
1204
1204
  return out;
1205
1205
  }
1206
+
1207
+ // src/react/storage.ts
1208
+ var localStorageAdapter = {
1209
+ get(key) {
1210
+ try {
1211
+ return window.localStorage.getItem(key);
1212
+ } catch {
1213
+ return null;
1214
+ }
1215
+ },
1216
+ set(key, value) {
1217
+ try {
1218
+ window.localStorage.setItem(key, value);
1219
+ } catch {
1220
+ }
1221
+ },
1222
+ remove(key) {
1223
+ try {
1224
+ window.localStorage.removeItem(key);
1225
+ } catch {
1226
+ }
1227
+ }
1228
+ };
1229
+ function createMemoryStorage() {
1230
+ const store = /* @__PURE__ */ new Map();
1231
+ return {
1232
+ get(key) {
1233
+ return store.get(key) ?? null;
1234
+ },
1235
+ set(key, value) {
1236
+ store.set(key, value);
1237
+ },
1238
+ remove(key) {
1239
+ store.delete(key);
1240
+ }
1241
+ };
1242
+ }
1243
+ var memoryStorage = createMemoryStorage();
1244
+
1245
+ // src/form-popup.ts
1246
+ function preferenceMemory() {
1247
+ if (typeof window === "undefined") return /* @__PURE__ */ new Map();
1248
+ const browser = window;
1249
+ return browser.__behioFormPreferences ?? (browser.__behioFormPreferences = /* @__PURE__ */ new Map());
1250
+ }
1251
+ var memoryAdapter = { get: (k) => preferenceMemory().get(k) ?? null, set: (k, v) => {
1252
+ preferenceMemory().set(k, v);
1253
+ }, remove: (k) => {
1254
+ preferenceMemory().delete(k);
1255
+ } };
1256
+ var NEWSLETTER_REQUESTED_EVENT = "behio:newsletter-requested";
1257
+ var PREFIX = "behio:forms:";
1258
+ var VISIT_MS = 30 * 60 * 1e3;
1259
+ function sessionAdapter() {
1260
+ return { get: (key) => {
1261
+ try {
1262
+ return sessionStorage.getItem(key) ?? memoryAdapter.get(key);
1263
+ } catch {
1264
+ return memoryAdapter.get(key);
1265
+ }
1266
+ }, set: (key, value) => {
1267
+ memoryAdapter.set(key, value);
1268
+ try {
1269
+ sessionStorage.setItem(key, value);
1270
+ } catch {
1271
+ }
1272
+ }, remove: (key) => {
1273
+ memoryAdapter.remove(key);
1274
+ try {
1275
+ sessionStorage.removeItem(key);
1276
+ } catch {
1277
+ }
1278
+ } };
1279
+ }
1280
+ function markNewsletterRequested() {
1281
+ if (typeof window === "undefined") return;
1282
+ memoryAdapter.set(PREFIX + "newsletter", "1");
1283
+ localStorageAdapter.set(PREFIX + "newsletter", "1");
1284
+ if (typeof window !== "undefined") window.dispatchEvent(new Event(NEWSLETTER_REQUESTED_EVENT));
1285
+ }
1286
+ function newsletterWasRequested() {
1287
+ return memoryAdapter.get(PREFIX + "newsletter") === "1" || localStorageAdapter.get(PREFIX + "newsletter") === "1";
1288
+ }
1289
+ function matchesFormPath(rule, pathname) {
1290
+ return rule.endsWith("*") ? pathname.startsWith(rule.slice(0, -1)) : pathname === rule;
1291
+ }
1292
+ function formPopupRouteAllowed(pathname, placement) {
1293
+ if (/^\/(cart|checkout|account|order|newsletter|login|register|forgot-password|reset-password|verify-email|session)(\/|$)/.test(pathname)) return false;
1294
+ return (!placement.includePaths.length || placement.includePaths.some((rule) => matchesFormPath(rule, pathname))) && !placement.excludePaths.some((rule) => matchesFormPath(rule, pathname));
1295
+ }
1296
+ var FormPopupClock = class {
1297
+ constructor(elapsedMs = 0) {
1298
+ this.since = null;
1299
+ this.elapsedMs = Math.max(0, elapsedMs);
1300
+ }
1301
+ setVisible(visible, now) {
1302
+ if (this.since !== null) this.elapsedMs += Math.max(0, now - this.since);
1303
+ this.since = visible ? now : null;
1304
+ }
1305
+ elapsed(now) {
1306
+ return this.elapsedMs + (this.since === null ? 0 : Math.max(0, now - this.since));
1307
+ }
1308
+ };
1309
+ var FormPopupPreferences = class {
1310
+ constructor(session = sessionAdapter(), persistent = localStorageAdapter, now = () => Date.now()) {
1311
+ this.session = session;
1312
+ this.persistent = persistent;
1313
+ this.now = now;
1314
+ this.shownInVisit = this.number("shown", this.session) > this.now() || this.number("shown", this.persistent) > this.now();
1315
+ }
1316
+ number(key, storage) {
1317
+ const n = Number(storage.get(PREFIX + key));
1318
+ return Number.isFinite(n) && n >= 0 ? n : 0;
1319
+ }
1320
+ visibleMs() {
1321
+ return this.now() - this.number("activity", this.session) < VISIT_MS ? this.number("visible", this.session) : 0;
1322
+ }
1323
+ saveTime(visible) {
1324
+ if (this.shownInVisit) {
1325
+ const until = String(this.now() + VISIT_MS);
1326
+ this.session.set(PREFIX + "shown", until);
1327
+ this.persistent.set(PREFIX + "shown", until);
1328
+ }
1329
+ this.session.set(PREFIX + "visible", String(visible));
1330
+ this.session.set(PREFIX + "activity", String(this.now()));
1331
+ }
1332
+ suppressed(slug, newsletter = false) {
1333
+ return newsletter && newsletterWasRequested() || this.shownInVisit || this.number("shown", this.session) > this.now() || this.number("shown", this.persistent) > this.now() || this.number("dismissed:" + slug, this.persistent) > this.now() || this.number("dismissed:" + slug, this.session) > this.now();
1334
+ }
1335
+ shown() {
1336
+ this.shownInVisit = true;
1337
+ const until = String(this.now() + VISIT_MS);
1338
+ this.session.set(PREFIX + "shown", until);
1339
+ this.persistent.set(PREFIX + "shown", until);
1340
+ }
1341
+ dismiss(slug, days) {
1342
+ const key = PREFIX + "dismissed:" + slug;
1343
+ const until = String(this.now() + days * 864e5);
1344
+ this.session.set(key, until);
1345
+ this.persistent.set(key, until);
1346
+ }
1347
+ };
1206
1348
  export {
1207
1349
  AddressTypes,
1208
1350
  BehioApiError,
1209
1351
  BehioNetworkError,
1210
1352
  BehioStorefront,
1353
+ FormPopupClock,
1354
+ FormPopupPreferences,
1211
1355
  FulfillmentStatuses,
1356
+ NEWSLETTER_REQUESTED_EVENT,
1212
1357
  OrderStatuses,
1213
1358
  PaymentStatuses,
1214
1359
  ProductSort,
@@ -1222,10 +1367,14 @@ export {
1222
1367
  errorParams,
1223
1368
  findVariantByAttributes,
1224
1369
  formFieldErrors,
1370
+ formPopupRouteAllowed,
1225
1371
  formatPrice,
1226
1372
  generateVisitorId,
1227
1373
  getStoredVisitorId,
1228
1374
  grantAnalyticsConsent,
1375
+ markNewsletterRequested,
1376
+ matchesFormPath,
1377
+ newsletterWasRequested,
1229
1378
  ok,
1230
1379
  publishCartSummary,
1231
1380
  resolveVariantContent,
package/dist/next.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { q as BehioStorefrontConfig, B as BehioStorefront } from './client-CAPtdqzd.mjs';
1
+ import { r as BehioStorefrontConfig, B as BehioStorefront } from './client-DtAz0rDJ.mjs';
2
2
 
3
3
  interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
4
4
  /** Override the cart session cookie name (default: "behio_cart_session"). */
package/dist/next.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { q as BehioStorefrontConfig, B as BehioStorefront } from './client-CAPtdqzd.js';
1
+ import { r as BehioStorefrontConfig, B as BehioStorefront } from './client-DtAz0rDJ.js';
2
2
 
3
3
  interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
4
4
  /** Override the cart session cookie name (default: "behio_cart_session"). */
package/dist/next.js CHANGED
@@ -1,6 +1,6 @@
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
- var _chunkSBPQZG4Yjs = require('./chunk-SBPQZG4Y.js');
3
+ var _chunkOUPCGMSRjs = require('./chunk-OUPCGMSR.js');
4
4
 
5
5
  // src/next.ts
6
6
  var _headers = require('next/headers');
@@ -19,7 +19,7 @@ async function getBehio(options = {}) {
19
19
  const locale = _nullishCoalesce(options.locale, () => ( process.env.BEHIO_LOCALE));
20
20
  const currency = _nullishCoalesce(options.currency, () => ( process.env.BEHIO_CURRENCY));
21
21
  const cookieName = _nullishCoalesce(options.cartCookieName, () => ( CART_COOKIE_NAME));
22
- const client = new (0, _chunkSBPQZG4Yjs.BehioStorefront)({
22
+ const client = new (0, _chunkOUPCGMSRjs.BehioStorefront)({
23
23
  apiKey,
24
24
  ...baseUrl ? { baseUrl } : {},
25
25
  ...locale ? { locale } : {},
package/dist/next.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BehioStorefront
3
- } from "./chunk-YDZ2OF4O.mjs";
3
+ } from "./chunk-25UM2XCS.mjs";
4
4
 
5
5
  // src/next.ts
6
6
  import { cookies, headers } from "next/headers";
package/dist/react.d.mts CHANGED
@@ -2553,7 +2553,35 @@ interface StorefrontFaqQuery {
2553
2553
  locale?: string;
2554
2554
  }
2555
2555
  /** Public definition of a form (`GET /forms/{slug}`). */
2556
+ interface StorefrontFormPlacement {
2557
+ key: string;
2558
+ mode: "inline" | "popup";
2559
+ enabled: boolean;
2560
+ delaySeconds: number;
2561
+ dismissDays: number;
2562
+ devices: "all" | "mobile" | "desktop";
2563
+ /** Exact path or prefix ending in *. No regex. */
2564
+ includePaths: string[];
2565
+ excludePaths: string[];
2566
+ }
2567
+ interface StorefrontFormPresentation {
2568
+ purpose: "general" | "newsletter";
2569
+ content: {
2570
+ eyebrow: string;
2571
+ heading: string;
2572
+ body: string;
2573
+ imageUrl: string;
2574
+ imageAlt: string;
2575
+ dismissLabel: string;
2576
+ backgroundColor: string;
2577
+ accentColor: string;
2578
+ };
2579
+ placements: StorefrontFormPlacement[];
2580
+ }
2556
2581
  interface StorefrontForm {
2582
+ /** Published content version. Requires the managed Forms API. */
2583
+ revision: number;
2584
+ presentation: StorefrontFormPresentation;
2557
2585
  slug: string;
2558
2586
  name: string;
2559
2587
  description: string | null;
@@ -2561,6 +2589,8 @@ interface StorefrontForm {
2561
2589
  settings: StorefrontFormSettings;
2562
2590
  }
2563
2591
  interface StorefrontFormSubmitInput {
2592
+ revision?: number;
2593
+ placement?: string;
2564
2594
  /** `{fieldKey: value}`; unknown keys are dropped server-side. */
2565
2595
  data: Record<string, unknown>;
2566
2596
  locale?: string;
@@ -2588,6 +2618,8 @@ interface StorefrontFormFile {
2588
2618
  type: string;
2589
2619
  }
2590
2620
  interface StorefrontFormSubmitResult {
2621
+ confirmationRequired?: boolean;
2622
+ alreadySubscribed?: boolean;
2591
2623
  ok: boolean;
2592
2624
  /** Id of the stored submission (null when the form does not store responses). */
2593
2625
  id: string | null;
@@ -4460,6 +4492,10 @@ declare class BookingsModule {
4460
4492
  declare class FormsModule {
4461
4493
  private client;
4462
4494
  constructor(client: BehioStorefront);
4495
+ /** Only active, published placements. Internal delivery/CRM settings never leave the server. */
4496
+ placements(): Promise<SdkResult<{
4497
+ items: StorefrontForm[];
4498
+ }>>;
4463
4499
  /** Public definition of one form (fields + settings). 404 for an unknown or inactive slug. */
4464
4500
  get(slug: string): Promise<SdkResult<StorefrontForm>>;
4465
4501
  /**
@@ -5554,6 +5590,15 @@ declare function useSiteFormSubmit(slug: string): {
5554
5590
  error: SdkError | null;
5555
5591
  reset: () => void;
5556
5592
  };
5593
+ /** SSR initial data avoids fetching first-render configuration in an effect. */
5594
+ declare function useFormPlacements(options?: {
5595
+ initialData?: {
5596
+ items: StorefrontForm[];
5597
+ };
5598
+ enabled?: boolean;
5599
+ }): _tanstack_react_query.UseQueryResult<NoInfer<{
5600
+ items: StorefrontForm[];
5601
+ }>, Error>;
5557
5602
 
5558
5603
  interface UseBookingsOptions {
5559
5604
  enabled?: boolean;
@@ -6336,7 +6381,7 @@ declare function formatPrice(amount: number, currency: string, locale?: string,
6336
6381
  * Consent stays the script layer's job: this helper never loads anything, it
6337
6382
  * only talks to runtimes that already exist on the page.
6338
6383
  */
6339
- type EcommerceEventName = "view_item" | "view_item_list" | "select_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "add_to_wishlist" | "view_promotion" | "select_promotion" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "search" | "generate_lead" | "purchase" | "variant_selected" | "newsletter_signup";
6384
+ type EcommerceEventName = "view_item" | "view_item_list" | "select_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "add_to_wishlist" | "view_promotion" | "select_promotion" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "search" | "generate_lead" | "purchase" | "variant_selected" | "newsletter_signup" | "newsletter_request" | "form_popup_view";
6340
6385
  type EcommerceItem = {
6341
6386
  item_id: string;
6342
6387
  item_name: string;
@@ -6424,4 +6469,19 @@ declare function revokeAnalyticsConsent(client: BehioStorefront): Promise<SdkRes
6424
6469
  success: boolean;
6425
6470
  }>>;
6426
6471
 
6427
- export { type ActivePromotion, type AddToCartInput, type AnalyticsEventInput, type AuthTokens, BehioAnalyticsTracker, BehioApiError, BehioProvider, type BehioProviderProps, type Blog, type BlogPostDetail, type BlogPostListItem, type BlogPostsPage, type BlogPostsQuery, type BlogSettings, type BlogTag, type Booking, type BookingCategory, type BookingConfig, type BookingCreateInput, type BookingCreated, type BookingLocale, type BookingLocation, type BookingManageSlotsQuery, type BookingService, type BookingSlot, type BookingSlots, type BookingSlotsQuery, type BookingStaff, type BookingStatus, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CheckoutPaymentMethod, type CookieConsent, type CookieConsentInput, type CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, type CustomerAddress, type CustomerProfile, type EcommerceEventName, type EcommerceItem, type EcommercePayload, type Facet, type FacetRange, type FacetValue, type FacetsResponse, type FilterField, type FulfillmentStatus, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type Page, type PageAttachment, type PageDetail, type PaginatedResponse, type PaymentInstrument, type PaymentStatus, type PaymentSwift, type PersonalOffer, type ProductDetail, type ProductLabel, type ProductListItem, type ProductParameter, type ProductParameterGroup, type ProductParametersResponse, type ProductPrice, type ProductReview, type ProductReviewsResponse, type ProductVariant, type ProductsQuery, type QuoteRequest, type RegisterInput, type ReturnRequest, RichText, type RichTextProps, type ShopInfo, type ShopSeo, type SiteFormField, type SiteFormFieldOption, type SiteFormFieldType, type StorageAdapter, type StorefrontForm, type StorefrontFormFieldError, type StorefrontFormFieldErrorCode, type StorefrontFormSettings, type StorefrontFormSubmitInput, type StorefrontFormSubmitResult, StorefrontScripts, type StorefrontScriptsProps, type SubmitQuoteInput, type SubmitReturnInput, type SubmitReviewInput, type SubmitWithdrawalInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseBlogPostOptions, type UseBlogPostsOptions, type UseBlogsOptions, type UseBookingsOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCertificateVerificationOptions, type UseCollectionOptions, type UseCourseCertificatesOptions, type UseCourseOptions, type UseCoursesOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFacetsOptions, type UseFaqOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseLessonCommentsOptions, type UseLessonNoteOptions, type UseLessonQuizOptions, type UseLessonTutorOptions, type UseLoyaltyOptions, type UseMenuOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UsePaymentMethodsOptions, type UsePersonalOffersOptions, type UseProductOptions, type UseProductParametersOptions, type UseProductsOptions, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingQuoteOptions, type UseShopInfoOptions, type UseShopScriptsOptions, type UseShopSeoOptions, type UseSiteFormOptions, type UseSubscriptionsOptions, type UseVisitorMessagesOptions, type VisitorMessage, type WishlistItem, type WithdrawalAcknowledgement, type WithdrawalWindow, cookieStorage, createMemoryStorage, detectStorage, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, localStorageAdapter, memoryStorage, revokeAnalyticsConsent, trackEcommerceEvent, useAddressAutocomplete, useAddresses, useAnalyticsEvents, useAuth, useBehio, useBehioClient, useBlogPost, useBlogPosts, useBlogs, useBookingConfig, useBookingSlots, useBundle, useBundles, useCancelBooking, useCart, useCartCount, useCategories, useCategory, useCertificateVerification, useCheckout, useCheckoutPreview, useCollection, useCollectionItem, useCookieConsent, useCourse, useCourseCertificates, useCourses, useCreateBooking, useCrossSell, useCurrency, useCustomer, useFacets, useFaqGroup, useFaqGroups, useFeatured, useFilters, useGiftCardBalance, useIsInWishlist, useLabels, useLessonComments, useLessonNote, useLessonQuiz, useLessonTutor, useLookupReturnableOrder, useLoyalty, useManagedBooking, useManagedBookingSlots, useMenu, useNewsletterConfirm, useNewsletterSubscribe, useNewsletterUnsubscribe, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, usePaymentMethods, usePersonalOffers, usePickupPoints, useProduct, useProductGroup, useProductParameters, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useRescheduleBooking, useReturnStatus, useSearch, useShippingMethods, useShippingQuote, useShopInfo, useShopScripts, useShopSeo, useSiteForm, useSiteFormSubmit, useSubmitQuote, useSubmitReturn, useSubmitReview, useSubmitWithdrawal, useSubscriptions, useVisitorMessages, useWishlist };
6472
+ type FormPopupOffer = {
6473
+ form: StorefrontForm;
6474
+ placement: StorefrontFormPlacement;
6475
+ };
6476
+ /** One host in the shared shell. Preview never mounts it; no subscription occurs on a timer. */
6477
+ declare function useFormPopup({ forms, locales, pathname }: {
6478
+ forms: StorefrontForm[];
6479
+ locales: string[];
6480
+ pathname: string;
6481
+ }): {
6482
+ active: FormPopupOffer | null;
6483
+ dialog: react.RefObject<HTMLDialogElement | null>;
6484
+ dismiss: () => void;
6485
+ };
6486
+
6487
+ export { type ActivePromotion, type AddToCartInput, type AnalyticsEventInput, type AuthTokens, BehioAnalyticsTracker, BehioApiError, BehioProvider, type BehioProviderProps, type Blog, type BlogPostDetail, type BlogPostListItem, type BlogPostsPage, type BlogPostsQuery, type BlogSettings, type BlogTag, type Booking, type BookingCategory, type BookingConfig, type BookingCreateInput, type BookingCreated, type BookingLocale, type BookingLocation, type BookingManageSlotsQuery, type BookingService, type BookingSlot, type BookingSlots, type BookingSlotsQuery, type BookingStaff, type BookingStatus, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CheckoutPaymentMethod, type CookieConsent, type CookieConsentInput, type CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, type CustomerAddress, type CustomerProfile, type EcommerceEventName, type EcommerceItem, type EcommercePayload, type Facet, type FacetRange, type FacetValue, type FacetsResponse, type FilterField, type FormPopupOffer, type FulfillmentStatus, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type Page, type PageAttachment, type PageDetail, type PaginatedResponse, type PaymentInstrument, type PaymentStatus, type PaymentSwift, type PersonalOffer, type ProductDetail, type ProductLabel, type ProductListItem, type ProductParameter, type ProductParameterGroup, type ProductParametersResponse, type ProductPrice, type ProductReview, type ProductReviewsResponse, type ProductVariant, type ProductsQuery, type QuoteRequest, type RegisterInput, type ReturnRequest, RichText, type RichTextProps, type ShopInfo, type ShopSeo, type SiteFormField, type SiteFormFieldOption, type SiteFormFieldType, type StorageAdapter, type StorefrontForm, type StorefrontFormFieldError, type StorefrontFormFieldErrorCode, type StorefrontFormSettings, type StorefrontFormSubmitInput, type StorefrontFormSubmitResult, StorefrontScripts, type StorefrontScriptsProps, type SubmitQuoteInput, type SubmitReturnInput, type SubmitReviewInput, type SubmitWithdrawalInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseBlogPostOptions, type UseBlogPostsOptions, type UseBlogsOptions, type UseBookingsOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCertificateVerificationOptions, type UseCollectionOptions, type UseCourseCertificatesOptions, type UseCourseOptions, type UseCoursesOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFacetsOptions, type UseFaqOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseLessonCommentsOptions, type UseLessonNoteOptions, type UseLessonQuizOptions, type UseLessonTutorOptions, type UseLoyaltyOptions, type UseMenuOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UsePaymentMethodsOptions, type UsePersonalOffersOptions, type UseProductOptions, type UseProductParametersOptions, type UseProductsOptions, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingQuoteOptions, type UseShopInfoOptions, type UseShopScriptsOptions, type UseShopSeoOptions, type UseSiteFormOptions, type UseSubscriptionsOptions, type UseVisitorMessagesOptions, type VisitorMessage, type WishlistItem, type WithdrawalAcknowledgement, type WithdrawalWindow, cookieStorage, createMemoryStorage, detectStorage, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, localStorageAdapter, memoryStorage, revokeAnalyticsConsent, trackEcommerceEvent, useAddressAutocomplete, useAddresses, useAnalyticsEvents, useAuth, useBehio, useBehioClient, useBlogPost, useBlogPosts, useBlogs, useBookingConfig, useBookingSlots, useBundle, useBundles, useCancelBooking, useCart, useCartCount, useCategories, useCategory, useCertificateVerification, useCheckout, useCheckoutPreview, useCollection, useCollectionItem, useCookieConsent, useCourse, useCourseCertificates, useCourses, useCreateBooking, useCrossSell, useCurrency, useCustomer, useFacets, useFaqGroup, useFaqGroups, useFeatured, useFilters, useFormPlacements, useFormPopup, useGiftCardBalance, useIsInWishlist, useLabels, useLessonComments, useLessonNote, useLessonQuiz, useLessonTutor, useLookupReturnableOrder, useLoyalty, useManagedBooking, useManagedBookingSlots, useMenu, useNewsletterConfirm, useNewsletterSubscribe, useNewsletterUnsubscribe, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, usePaymentMethods, usePersonalOffers, usePickupPoints, useProduct, useProductGroup, useProductParameters, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useRescheduleBooking, useReturnStatus, useSearch, useShippingMethods, useShippingQuote, useShopInfo, useShopScripts, useShopSeo, useSiteForm, useSiteFormSubmit, useSubmitQuote, useSubmitReturn, useSubmitReview, useSubmitWithdrawal, useSubscriptions, useVisitorMessages, useWishlist };
package/dist/react.d.ts CHANGED
@@ -2553,7 +2553,35 @@ interface StorefrontFaqQuery {
2553
2553
  locale?: string;
2554
2554
  }
2555
2555
  /** Public definition of a form (`GET /forms/{slug}`). */
2556
+ interface StorefrontFormPlacement {
2557
+ key: string;
2558
+ mode: "inline" | "popup";
2559
+ enabled: boolean;
2560
+ delaySeconds: number;
2561
+ dismissDays: number;
2562
+ devices: "all" | "mobile" | "desktop";
2563
+ /** Exact path or prefix ending in *. No regex. */
2564
+ includePaths: string[];
2565
+ excludePaths: string[];
2566
+ }
2567
+ interface StorefrontFormPresentation {
2568
+ purpose: "general" | "newsletter";
2569
+ content: {
2570
+ eyebrow: string;
2571
+ heading: string;
2572
+ body: string;
2573
+ imageUrl: string;
2574
+ imageAlt: string;
2575
+ dismissLabel: string;
2576
+ backgroundColor: string;
2577
+ accentColor: string;
2578
+ };
2579
+ placements: StorefrontFormPlacement[];
2580
+ }
2556
2581
  interface StorefrontForm {
2582
+ /** Published content version. Requires the managed Forms API. */
2583
+ revision: number;
2584
+ presentation: StorefrontFormPresentation;
2557
2585
  slug: string;
2558
2586
  name: string;
2559
2587
  description: string | null;
@@ -2561,6 +2589,8 @@ interface StorefrontForm {
2561
2589
  settings: StorefrontFormSettings;
2562
2590
  }
2563
2591
  interface StorefrontFormSubmitInput {
2592
+ revision?: number;
2593
+ placement?: string;
2564
2594
  /** `{fieldKey: value}`; unknown keys are dropped server-side. */
2565
2595
  data: Record<string, unknown>;
2566
2596
  locale?: string;
@@ -2588,6 +2618,8 @@ interface StorefrontFormFile {
2588
2618
  type: string;
2589
2619
  }
2590
2620
  interface StorefrontFormSubmitResult {
2621
+ confirmationRequired?: boolean;
2622
+ alreadySubscribed?: boolean;
2591
2623
  ok: boolean;
2592
2624
  /** Id of the stored submission (null when the form does not store responses). */
2593
2625
  id: string | null;
@@ -4460,6 +4492,10 @@ declare class BookingsModule {
4460
4492
  declare class FormsModule {
4461
4493
  private client;
4462
4494
  constructor(client: BehioStorefront);
4495
+ /** Only active, published placements. Internal delivery/CRM settings never leave the server. */
4496
+ placements(): Promise<SdkResult<{
4497
+ items: StorefrontForm[];
4498
+ }>>;
4463
4499
  /** Public definition of one form (fields + settings). 404 for an unknown or inactive slug. */
4464
4500
  get(slug: string): Promise<SdkResult<StorefrontForm>>;
4465
4501
  /**
@@ -5554,6 +5590,15 @@ declare function useSiteFormSubmit(slug: string): {
5554
5590
  error: SdkError | null;
5555
5591
  reset: () => void;
5556
5592
  };
5593
+ /** SSR initial data avoids fetching first-render configuration in an effect. */
5594
+ declare function useFormPlacements(options?: {
5595
+ initialData?: {
5596
+ items: StorefrontForm[];
5597
+ };
5598
+ enabled?: boolean;
5599
+ }): _tanstack_react_query.UseQueryResult<NoInfer<{
5600
+ items: StorefrontForm[];
5601
+ }>, Error>;
5557
5602
 
5558
5603
  interface UseBookingsOptions {
5559
5604
  enabled?: boolean;
@@ -6336,7 +6381,7 @@ declare function formatPrice(amount: number, currency: string, locale?: string,
6336
6381
  * Consent stays the script layer's job: this helper never loads anything, it
6337
6382
  * only talks to runtimes that already exist on the page.
6338
6383
  */
6339
- type EcommerceEventName = "view_item" | "view_item_list" | "select_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "add_to_wishlist" | "view_promotion" | "select_promotion" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "search" | "generate_lead" | "purchase" | "variant_selected" | "newsletter_signup";
6384
+ type EcommerceEventName = "view_item" | "view_item_list" | "select_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "add_to_wishlist" | "view_promotion" | "select_promotion" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "search" | "generate_lead" | "purchase" | "variant_selected" | "newsletter_signup" | "newsletter_request" | "form_popup_view";
6340
6385
  type EcommerceItem = {
6341
6386
  item_id: string;
6342
6387
  item_name: string;
@@ -6424,4 +6469,19 @@ declare function revokeAnalyticsConsent(client: BehioStorefront): Promise<SdkRes
6424
6469
  success: boolean;
6425
6470
  }>>;
6426
6471
 
6427
- export { type ActivePromotion, type AddToCartInput, type AnalyticsEventInput, type AuthTokens, BehioAnalyticsTracker, BehioApiError, BehioProvider, type BehioProviderProps, type Blog, type BlogPostDetail, type BlogPostListItem, type BlogPostsPage, type BlogPostsQuery, type BlogSettings, type BlogTag, type Booking, type BookingCategory, type BookingConfig, type BookingCreateInput, type BookingCreated, type BookingLocale, type BookingLocation, type BookingManageSlotsQuery, type BookingService, type BookingSlot, type BookingSlots, type BookingSlotsQuery, type BookingStaff, type BookingStatus, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CheckoutPaymentMethod, type CookieConsent, type CookieConsentInput, type CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, type CustomerAddress, type CustomerProfile, type EcommerceEventName, type EcommerceItem, type EcommercePayload, type Facet, type FacetRange, type FacetValue, type FacetsResponse, type FilterField, type FulfillmentStatus, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type Page, type PageAttachment, type PageDetail, type PaginatedResponse, type PaymentInstrument, type PaymentStatus, type PaymentSwift, type PersonalOffer, type ProductDetail, type ProductLabel, type ProductListItem, type ProductParameter, type ProductParameterGroup, type ProductParametersResponse, type ProductPrice, type ProductReview, type ProductReviewsResponse, type ProductVariant, type ProductsQuery, type QuoteRequest, type RegisterInput, type ReturnRequest, RichText, type RichTextProps, type ShopInfo, type ShopSeo, type SiteFormField, type SiteFormFieldOption, type SiteFormFieldType, type StorageAdapter, type StorefrontForm, type StorefrontFormFieldError, type StorefrontFormFieldErrorCode, type StorefrontFormSettings, type StorefrontFormSubmitInput, type StorefrontFormSubmitResult, StorefrontScripts, type StorefrontScriptsProps, type SubmitQuoteInput, type SubmitReturnInput, type SubmitReviewInput, type SubmitWithdrawalInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseBlogPostOptions, type UseBlogPostsOptions, type UseBlogsOptions, type UseBookingsOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCertificateVerificationOptions, type UseCollectionOptions, type UseCourseCertificatesOptions, type UseCourseOptions, type UseCoursesOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFacetsOptions, type UseFaqOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseLessonCommentsOptions, type UseLessonNoteOptions, type UseLessonQuizOptions, type UseLessonTutorOptions, type UseLoyaltyOptions, type UseMenuOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UsePaymentMethodsOptions, type UsePersonalOffersOptions, type UseProductOptions, type UseProductParametersOptions, type UseProductsOptions, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingQuoteOptions, type UseShopInfoOptions, type UseShopScriptsOptions, type UseShopSeoOptions, type UseSiteFormOptions, type UseSubscriptionsOptions, type UseVisitorMessagesOptions, type VisitorMessage, type WishlistItem, type WithdrawalAcknowledgement, type WithdrawalWindow, cookieStorage, createMemoryStorage, detectStorage, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, localStorageAdapter, memoryStorage, revokeAnalyticsConsent, trackEcommerceEvent, useAddressAutocomplete, useAddresses, useAnalyticsEvents, useAuth, useBehio, useBehioClient, useBlogPost, useBlogPosts, useBlogs, useBookingConfig, useBookingSlots, useBundle, useBundles, useCancelBooking, useCart, useCartCount, useCategories, useCategory, useCertificateVerification, useCheckout, useCheckoutPreview, useCollection, useCollectionItem, useCookieConsent, useCourse, useCourseCertificates, useCourses, useCreateBooking, useCrossSell, useCurrency, useCustomer, useFacets, useFaqGroup, useFaqGroups, useFeatured, useFilters, useGiftCardBalance, useIsInWishlist, useLabels, useLessonComments, useLessonNote, useLessonQuiz, useLessonTutor, useLookupReturnableOrder, useLoyalty, useManagedBooking, useManagedBookingSlots, useMenu, useNewsletterConfirm, useNewsletterSubscribe, useNewsletterUnsubscribe, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, usePaymentMethods, usePersonalOffers, usePickupPoints, useProduct, useProductGroup, useProductParameters, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useRescheduleBooking, useReturnStatus, useSearch, useShippingMethods, useShippingQuote, useShopInfo, useShopScripts, useShopSeo, useSiteForm, useSiteFormSubmit, useSubmitQuote, useSubmitReturn, useSubmitReview, useSubmitWithdrawal, useSubscriptions, useVisitorMessages, useWishlist };
6472
+ type FormPopupOffer = {
6473
+ form: StorefrontForm;
6474
+ placement: StorefrontFormPlacement;
6475
+ };
6476
+ /** One host in the shared shell. Preview never mounts it; no subscription occurs on a timer. */
6477
+ declare function useFormPopup({ forms, locales, pathname }: {
6478
+ forms: StorefrontForm[];
6479
+ locales: string[];
6480
+ pathname: string;
6481
+ }): {
6482
+ active: FormPopupOffer | null;
6483
+ dialog: react.RefObject<HTMLDialogElement | null>;
6484
+ dismiss: () => void;
6485
+ };
6486
+
6487
+ export { type ActivePromotion, type AddToCartInput, type AnalyticsEventInput, type AuthTokens, BehioAnalyticsTracker, BehioApiError, BehioProvider, type BehioProviderProps, type Blog, type BlogPostDetail, type BlogPostListItem, type BlogPostsPage, type BlogPostsQuery, type BlogSettings, type BlogTag, type Booking, type BookingCategory, type BookingConfig, type BookingCreateInput, type BookingCreated, type BookingLocale, type BookingLocation, type BookingManageSlotsQuery, type BookingService, type BookingSlot, type BookingSlots, type BookingSlotsQuery, type BookingStaff, type BookingStatus, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CheckoutPaymentMethod, type CookieConsent, type CookieConsentInput, type CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, type CustomerAddress, type CustomerProfile, type EcommerceEventName, type EcommerceItem, type EcommercePayload, type Facet, type FacetRange, type FacetValue, type FacetsResponse, type FilterField, type FormPopupOffer, type FulfillmentStatus, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type Page, type PageAttachment, type PageDetail, type PaginatedResponse, type PaymentInstrument, type PaymentStatus, type PaymentSwift, type PersonalOffer, type ProductDetail, type ProductLabel, type ProductListItem, type ProductParameter, type ProductParameterGroup, type ProductParametersResponse, type ProductPrice, type ProductReview, type ProductReviewsResponse, type ProductVariant, type ProductsQuery, type QuoteRequest, type RegisterInput, type ReturnRequest, RichText, type RichTextProps, type ShopInfo, type ShopSeo, type SiteFormField, type SiteFormFieldOption, type SiteFormFieldType, type StorageAdapter, type StorefrontForm, type StorefrontFormFieldError, type StorefrontFormFieldErrorCode, type StorefrontFormSettings, type StorefrontFormSubmitInput, type StorefrontFormSubmitResult, StorefrontScripts, type StorefrontScriptsProps, type SubmitQuoteInput, type SubmitReturnInput, type SubmitReviewInput, type SubmitWithdrawalInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseBlogPostOptions, type UseBlogPostsOptions, type UseBlogsOptions, type UseBookingsOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCertificateVerificationOptions, type UseCollectionOptions, type UseCourseCertificatesOptions, type UseCourseOptions, type UseCoursesOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFacetsOptions, type UseFaqOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseLessonCommentsOptions, type UseLessonNoteOptions, type UseLessonQuizOptions, type UseLessonTutorOptions, type UseLoyaltyOptions, type UseMenuOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UsePaymentMethodsOptions, type UsePersonalOffersOptions, type UseProductOptions, type UseProductParametersOptions, type UseProductsOptions, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingQuoteOptions, type UseShopInfoOptions, type UseShopScriptsOptions, type UseShopSeoOptions, type UseSiteFormOptions, type UseSubscriptionsOptions, type UseVisitorMessagesOptions, type VisitorMessage, type WishlistItem, type WithdrawalAcknowledgement, type WithdrawalWindow, cookieStorage, createMemoryStorage, detectStorage, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, localStorageAdapter, memoryStorage, revokeAnalyticsConsent, trackEcommerceEvent, useAddressAutocomplete, useAddresses, useAnalyticsEvents, useAuth, useBehio, useBehioClient, useBlogPost, useBlogPosts, useBlogs, useBookingConfig, useBookingSlots, useBundle, useBundles, useCancelBooking, useCart, useCartCount, useCategories, useCategory, useCertificateVerification, useCheckout, useCheckoutPreview, useCollection, useCollectionItem, useCookieConsent, useCourse, useCourseCertificates, useCourses, useCreateBooking, useCrossSell, useCurrency, useCustomer, useFacets, useFaqGroup, useFaqGroups, useFeatured, useFilters, useFormPlacements, useFormPopup, useGiftCardBalance, useIsInWishlist, useLabels, useLessonComments, useLessonNote, useLessonQuiz, useLessonTutor, useLookupReturnableOrder, useLoyalty, useManagedBooking, useManagedBookingSlots, useMenu, useNewsletterConfirm, useNewsletterSubscribe, useNewsletterUnsubscribe, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, usePaymentMethods, usePersonalOffers, usePickupPoints, useProduct, useProductGroup, useProductParameters, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useRescheduleBooking, useReturnStatus, useSearch, useShippingMethods, useShippingQuote, useShopInfo, useShopScripts, useShopSeo, useSiteForm, useSiteFormSubmit, useSubmitQuote, useSubmitReturn, useSubmitReview, useSubmitWithdrawal, useSubscriptions, useVisitorMessages, useWishlist };