@bowlos/reservations 0.21.0 → 0.22.1

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.
@@ -1,8 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { CSSProperties, ReactNode } from 'react';
3
3
  import { U as PricingMode, S as PaymentIntentInfo, l as Customer } from './data-BKlgn8Ln.cjs';
4
- import { c as UseAccountResult } from './react-D2mBw_-l.cjs';
5
- import './errors-IIK7xibp.cjs';
4
+ import { c as UseAccountResult } from './react-Bc_6yi9q.cjs';
5
+ import { g as CatalogItem } from './catalog-D1VoVaNe.cjs';
6
+ export { h as CatalogResult, i as CatalogSection } from './catalog-D1VoVaNe.cjs';
6
7
 
7
8
  /**
8
9
  * Themeable design tokens for the `@bowlos/reservations/components` layer.
@@ -423,81 +424,53 @@ interface FlashSaleIndexProps {
423
424
  */
424
425
  declare function FlashSaleIndex({ brandId, onOpen, labels, className }: FlashSaleIndexProps): react_jsx_runtime.JSX.Element;
425
426
 
426
- /** A selectable offer, tagged by kind so the consumer can route it. */
427
- type CatalogOffer = {
428
- kind: "product";
429
- id: string;
430
- name: string;
431
- attractionName: string;
432
- attractionTypeKey: string;
433
- durationMinutes: number;
434
- pricingMode: string;
435
- } | {
436
- kind: "event";
437
- id: string;
438
- slug: string;
439
- name: string;
440
- date: string;
441
- description: string | null;
442
- purchaseMode: "reservation" | "ticket";
443
- productId: string | null;
444
- pricePlanId: string | null;
445
- priceCents: number | null;
446
- } | {
447
- kind: "package";
448
- id: string;
449
- name: string;
450
- priceCents: number;
451
- description: string | null;
452
- } | {
453
- kind: "membership";
454
- id: string;
455
- name: string;
456
- priceCents: number;
457
- description: string | null;
458
- } | {
459
- kind: "gamecard";
460
- id: string;
461
- name: string;
462
- priceCents: number;
463
- description: string | null;
464
- };
427
+ /**
428
+ * v0.22.0 (BREAKING): `<BookingCatalog>` is now built on the canonical
429
+ * visibility-aware catalog read (`useCatalog` / `listPublicCatalog`) — the
430
+ * same read the white-label web and mobile surfaces consume — so the Center
431
+ * admin's per-surface visibility toggles finally apply to the drop-in.
432
+ *
433
+ * `onSelect` now receives a `CatalogItem` (route by `item.action.type` with
434
+ * the IDs in `item.action.payload`) instead of the old per-kind
435
+ * `CatalogOffer` union. See HEADLESS.md → "The canonical catalog" for the
436
+ * routing table; the drop-in and a headless site now route identically.
437
+ */
465
438
  interface BookingCatalogLabels {
466
439
  heading: string;
467
440
  loading: string;
468
441
  empty: string;
469
- bowling: string;
470
- otherAttractions: string;
471
- events: string;
472
- packages: string;
473
- memberships: string;
474
- gamePasses: string;
475
442
  select: string;
476
- minutesAbbrev: string;
477
- perMonth: string;
478
443
  }
479
444
  interface BookingCatalogProps {
480
- /** Brand (packages + game passes) and Center (products + events + memberships). */
481
445
  brandId: string;
482
446
  centerId: string;
483
447
  /**
484
- * Called when a customer picks an offer. Route by `offer.kind`: a `product`
485
- * → your `<BookingFlow>`; an `event` → its landing page (`offer.slug`) or,
486
- * for reservation-mode events, your booking flow with the event date/window
487
- * preset; a `package` / `membership` / `gamecard` → its buy page.
448
+ * The surface whose admin visibility rules apply. Defaults to
449
+ * "sdk_custom_site" (a center's own SDK-built site).
450
+ */
451
+ surface?: "sdk_custom_site" | "white_label_web" | "mobile_app";
452
+ /**
453
+ * Called when a customer picks an item. Route by `item.action.type`:
454
+ * `book_reservation` → your `<BookingFlow>` (payload.productId);
455
+ * `view_event` / `buy_ticket` → the event landing by payload.slug;
456
+ * `buy_package` / `buy_membership` / `buy_game_pass` → that buy flow
457
+ * (payload.packageId / templateId).
488
458
  */
489
- onSelect: (offer: CatalogOffer) => void;
459
+ onSelect: (item: CatalogItem) => void;
490
460
  labels?: Partial<BookingCatalogLabels>;
461
+ /** Override a section heading by its category key (backend labels are
462
+ * the default), e.g. `{ game_passes: "Punch cards" }`. */
463
+ sectionLabels?: Partial<Record<string, string>>;
491
464
  className?: string;
492
465
  }
493
466
  /**
494
- * The categorized catalog of everything a Center sells online — Bowling, Other
495
- * attractions, Events, Packages, Memberships, Game passes — each offer under its
496
- * heading. Picking one hands off via `onSelect`. No prices cross the wire for
497
- * gated surfaces; this only lists public offers. Must render inside a
498
- * `<BowlosProvider>`; theme with `<BowlosTheme>`.
467
+ * The categorized catalog of everything a Center sells online, exactly as the
468
+ * Center admin's Public Catalog page configured it for this surface. Picking
469
+ * an item hands off via `onSelect`. Indicative prices only (`priceLabel`);
470
+ * binding prices come from the per-category previews after login. Must render
471
+ * inside a `<BowlosProvider>`; theme with `<BowlosTheme>`.
499
472
  */
500
- declare function BookingCatalog({ brandId, centerId, onSelect, labels, className }: BookingCatalogProps): react_jsx_runtime.JSX.Element;
473
+ declare function BookingCatalog({ brandId, centerId, surface, onSelect, labels, sectionLabels, className, }: BookingCatalogProps): react_jsx_runtime.JSX.Element;
501
474
 
502
475
  /**
503
476
  * Shared primitives for the `@bowlos/reservations/components` layer.
@@ -514,4 +487,4 @@ declare function formatCents(cents: number): string;
514
487
  /** A min–max money range, collapsing to one value when they're equal. */
515
488
  declare function formatCentsRange(minCents: number, maxCents: number): string;
516
489
 
517
- export { AccountDashboard, type AccountDashboardLabels, type AccountDashboardProps, AccountMenu, type AccountMenuLabels, type AccountMenuProps, type AccountSection, AuthForm, AuthGate, type AuthGateLabels, type AuthGateProps, type AuthGateRenderContext, BOWLOS_DEFAULT_THEME, BookingCatalog, type BookingCatalogLabels, type BookingCatalogProps, BookingFlow, type BookingFlowLabels, type BookingFlowProps, BowlosTheme, type BowlosThemeTokens, type CatalogOffer, type FlashBrand, FlashSale, FlashSaleIndex, type FlashSaleIndexItem, type FlashSaleIndexLabels, type FlashSaleIndexProps, type FlashSaleIndexView, type FlashSaleItem, type FlashSaleLabels, type FlashSaleProps, type FlashSaleView, type MyCreditEntry, type MyCredits, type MyLoyalty, type MyMembershipSummary, type MyPass, type MyReservationSummary, formatCents, formatCentsRange };
490
+ export { AccountDashboard, type AccountDashboardLabels, type AccountDashboardProps, AccountMenu, type AccountMenuLabels, type AccountMenuProps, type AccountSection, AuthForm, AuthGate, type AuthGateLabels, type AuthGateProps, type AuthGateRenderContext, BOWLOS_DEFAULT_THEME, BookingCatalog, type BookingCatalogLabels, type BookingCatalogProps, BookingFlow, type BookingFlowLabels, type BookingFlowProps, BowlosTheme, type BowlosThemeTokens, CatalogItem, type FlashBrand, FlashSale, FlashSaleIndex, type FlashSaleIndexItem, type FlashSaleIndexLabels, type FlashSaleIndexProps, type FlashSaleIndexView, type FlashSaleItem, type FlashSaleLabels, type FlashSaleProps, type FlashSaleView, type MyCreditEntry, type MyCredits, type MyLoyalty, type MyMembershipSummary, type MyPass, type MyReservationSummary, formatCents, formatCentsRange };
@@ -1,8 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { CSSProperties, ReactNode } from 'react';
3
3
  import { U as PricingMode, S as PaymentIntentInfo, l as Customer } from './data-BKlgn8Ln.js';
4
- import { c as UseAccountResult } from './react-BI2RKM5p.js';
5
- import './errors-IIK7xibp.js';
4
+ import { c as UseAccountResult } from './react-B1uSOozS.js';
5
+ import { g as CatalogItem } from './catalog-BxyPJdBL.js';
6
+ export { h as CatalogResult, i as CatalogSection } from './catalog-BxyPJdBL.js';
6
7
 
7
8
  /**
8
9
  * Themeable design tokens for the `@bowlos/reservations/components` layer.
@@ -423,81 +424,53 @@ interface FlashSaleIndexProps {
423
424
  */
424
425
  declare function FlashSaleIndex({ brandId, onOpen, labels, className }: FlashSaleIndexProps): react_jsx_runtime.JSX.Element;
425
426
 
426
- /** A selectable offer, tagged by kind so the consumer can route it. */
427
- type CatalogOffer = {
428
- kind: "product";
429
- id: string;
430
- name: string;
431
- attractionName: string;
432
- attractionTypeKey: string;
433
- durationMinutes: number;
434
- pricingMode: string;
435
- } | {
436
- kind: "event";
437
- id: string;
438
- slug: string;
439
- name: string;
440
- date: string;
441
- description: string | null;
442
- purchaseMode: "reservation" | "ticket";
443
- productId: string | null;
444
- pricePlanId: string | null;
445
- priceCents: number | null;
446
- } | {
447
- kind: "package";
448
- id: string;
449
- name: string;
450
- priceCents: number;
451
- description: string | null;
452
- } | {
453
- kind: "membership";
454
- id: string;
455
- name: string;
456
- priceCents: number;
457
- description: string | null;
458
- } | {
459
- kind: "gamecard";
460
- id: string;
461
- name: string;
462
- priceCents: number;
463
- description: string | null;
464
- };
427
+ /**
428
+ * v0.22.0 (BREAKING): `<BookingCatalog>` is now built on the canonical
429
+ * visibility-aware catalog read (`useCatalog` / `listPublicCatalog`) — the
430
+ * same read the white-label web and mobile surfaces consume — so the Center
431
+ * admin's per-surface visibility toggles finally apply to the drop-in.
432
+ *
433
+ * `onSelect` now receives a `CatalogItem` (route by `item.action.type` with
434
+ * the IDs in `item.action.payload`) instead of the old per-kind
435
+ * `CatalogOffer` union. See HEADLESS.md → "The canonical catalog" for the
436
+ * routing table; the drop-in and a headless site now route identically.
437
+ */
465
438
  interface BookingCatalogLabels {
466
439
  heading: string;
467
440
  loading: string;
468
441
  empty: string;
469
- bowling: string;
470
- otherAttractions: string;
471
- events: string;
472
- packages: string;
473
- memberships: string;
474
- gamePasses: string;
475
442
  select: string;
476
- minutesAbbrev: string;
477
- perMonth: string;
478
443
  }
479
444
  interface BookingCatalogProps {
480
- /** Brand (packages + game passes) and Center (products + events + memberships). */
481
445
  brandId: string;
482
446
  centerId: string;
483
447
  /**
484
- * Called when a customer picks an offer. Route by `offer.kind`: a `product`
485
- * → your `<BookingFlow>`; an `event` → its landing page (`offer.slug`) or,
486
- * for reservation-mode events, your booking flow with the event date/window
487
- * preset; a `package` / `membership` / `gamecard` → its buy page.
448
+ * The surface whose admin visibility rules apply. Defaults to
449
+ * "sdk_custom_site" (a center's own SDK-built site).
450
+ */
451
+ surface?: "sdk_custom_site" | "white_label_web" | "mobile_app";
452
+ /**
453
+ * Called when a customer picks an item. Route by `item.action.type`:
454
+ * `book_reservation` → your `<BookingFlow>` (payload.productId);
455
+ * `view_event` / `buy_ticket` → the event landing by payload.slug;
456
+ * `buy_package` / `buy_membership` / `buy_game_pass` → that buy flow
457
+ * (payload.packageId / templateId).
488
458
  */
489
- onSelect: (offer: CatalogOffer) => void;
459
+ onSelect: (item: CatalogItem) => void;
490
460
  labels?: Partial<BookingCatalogLabels>;
461
+ /** Override a section heading by its category key (backend labels are
462
+ * the default), e.g. `{ game_passes: "Punch cards" }`. */
463
+ sectionLabels?: Partial<Record<string, string>>;
491
464
  className?: string;
492
465
  }
493
466
  /**
494
- * The categorized catalog of everything a Center sells online — Bowling, Other
495
- * attractions, Events, Packages, Memberships, Game passes — each offer under its
496
- * heading. Picking one hands off via `onSelect`. No prices cross the wire for
497
- * gated surfaces; this only lists public offers. Must render inside a
498
- * `<BowlosProvider>`; theme with `<BowlosTheme>`.
467
+ * The categorized catalog of everything a Center sells online, exactly as the
468
+ * Center admin's Public Catalog page configured it for this surface. Picking
469
+ * an item hands off via `onSelect`. Indicative prices only (`priceLabel`);
470
+ * binding prices come from the per-category previews after login. Must render
471
+ * inside a `<BowlosProvider>`; theme with `<BowlosTheme>`.
499
472
  */
500
- declare function BookingCatalog({ brandId, centerId, onSelect, labels, className }: BookingCatalogProps): react_jsx_runtime.JSX.Element;
473
+ declare function BookingCatalog({ brandId, centerId, surface, onSelect, labels, sectionLabels, className, }: BookingCatalogProps): react_jsx_runtime.JSX.Element;
501
474
 
502
475
  /**
503
476
  * Shared primitives for the `@bowlos/reservations/components` layer.
@@ -514,4 +487,4 @@ declare function formatCents(cents: number): string;
514
487
  /** A min–max money range, collapsing to one value when they're equal. */
515
488
  declare function formatCentsRange(minCents: number, maxCents: number): string;
516
489
 
517
- export { AccountDashboard, type AccountDashboardLabels, type AccountDashboardProps, AccountMenu, type AccountMenuLabels, type AccountMenuProps, type AccountSection, AuthForm, AuthGate, type AuthGateLabels, type AuthGateProps, type AuthGateRenderContext, BOWLOS_DEFAULT_THEME, BookingCatalog, type BookingCatalogLabels, type BookingCatalogProps, BookingFlow, type BookingFlowLabels, type BookingFlowProps, BowlosTheme, type BowlosThemeTokens, type CatalogOffer, type FlashBrand, FlashSale, FlashSaleIndex, type FlashSaleIndexItem, type FlashSaleIndexLabels, type FlashSaleIndexProps, type FlashSaleIndexView, type FlashSaleItem, type FlashSaleLabels, type FlashSaleProps, type FlashSaleView, type MyCreditEntry, type MyCredits, type MyLoyalty, type MyMembershipSummary, type MyPass, type MyReservationSummary, formatCents, formatCentsRange };
490
+ export { AccountDashboard, type AccountDashboardLabels, type AccountDashboardProps, AccountMenu, type AccountMenuLabels, type AccountMenuProps, type AccountSection, AuthForm, AuthGate, type AuthGateLabels, type AuthGateProps, type AuthGateRenderContext, BOWLOS_DEFAULT_THEME, BookingCatalog, type BookingCatalogLabels, type BookingCatalogProps, BookingFlow, type BookingFlowLabels, type BookingFlowProps, BowlosTheme, type BowlosThemeTokens, CatalogItem, type FlashBrand, FlashSale, FlashSaleIndex, type FlashSaleIndexItem, type FlashSaleIndexLabels, type FlashSaleIndexProps, type FlashSaleIndexView, type FlashSaleItem, type FlashSaleLabels, type FlashSaleProps, type FlashSaleView, type MyCreditEntry, type MyCredits, type MyLoyalty, type MyMembershipSummary, type MyPass, type MyReservationSummary, formatCents, formatCentsRange };
@@ -1,4 +1,4 @@
1
- import { useAccount, useAvailability, useBookingPreview, useAddons, useStartTimes, useBookingFlow, useMyReservations, useMyMemberships, useMyLoyalty, useMyCredits, useMyPasses, useFlashSale, useFlashSales, useProducts, useEventOffers, usePackages, usePublicMemberships, useGameCards } from './chunk-FV6SROO2.js';
1
+ import { useAccount, useAvailability, useBookingPreview, useAddons, useStartTimes, useBookingFlow, useMyReservations, useMyMemberships, useMyLoyalty, useMyCredits, useMyPasses, useFlashSale, useFlashSales, useCatalog } from './chunk-FV6SROO2.js';
2
2
  import { availableUnitCount } from './chunk-S5T4OCBY.js';
3
3
  import { styles, formatCents, formatMinuteLabel, token, minutesToTime, useCountdown, formatCentsRange } from './chunk-Y3YSDO3H.js';
4
4
  export { BOWLOS_DEFAULT_THEME, BowlosTheme, formatCents, formatCentsRange } from './chunk-Y3YSDO3H.js';
@@ -827,105 +827,53 @@ var DEFAULT_LABELS7 = {
827
827
  heading: "What would you like to book?",
828
828
  loading: "Loading\u2026",
829
829
  empty: "Nothing is available to book online right now.",
830
- bowling: "Bowling",
831
- otherAttractions: "Other attractions",
832
- events: "Events",
833
- packages: "Packages",
834
- memberships: "Memberships",
835
- gamePasses: "Game passes",
836
- select: "Select",
837
- minutesAbbrev: "min",
838
- perMonth: "/mo"
830
+ select: "Select"
839
831
  };
840
- function BookingCatalog({ brandId, centerId, onSelect, labels, className }) {
832
+ function BookingCatalog({
833
+ brandId,
834
+ centerId,
835
+ surface = "sdk_custom_site",
836
+ onSelect,
837
+ labels,
838
+ sectionLabels,
839
+ className
840
+ }) {
841
841
  const t = { ...DEFAULT_LABELS7, ...labels };
842
842
  const s = styles();
843
- const products = useProducts({ centerId });
844
- const events = useEventOffers({ centerId });
845
- const packages = usePackages({ brandId, centerId });
846
- const memberships = usePublicMemberships({ centerId });
847
- const gameCards = useGameCards({ brandId, centerId });
848
- const reads = [products, events, packages, memberships, gameCards];
849
- const anyLoading = reads.some((r) => r.loading && !r.data);
850
- const productRows = products.data ?? [];
851
- const bowling = productRows.filter((p) => p.attractionTypeKey === "bowling").map((p) => ({ kind: "product", ...p }));
852
- const other = productRows.filter((p) => p.attractionTypeKey !== "bowling").map((p) => ({ kind: "product", ...p }));
853
- const eventOffers = (events.data ?? []).map((e) => ({
854
- kind: "event",
855
- id: e.id,
856
- slug: e.slug,
857
- name: e.title,
858
- date: e.date,
859
- description: e.subtitle ?? e.description,
860
- purchaseMode: e.purchaseMode,
861
- productId: e.productId,
862
- pricePlanId: e.pricePlanId,
863
- priceCents: e.priceCents
864
- }));
865
- const packageOffers = (packages.data ?? []).map((p) => ({
866
- kind: "package",
867
- id: p.id,
868
- name: p.name,
869
- priceCents: p.basePriceCents,
870
- description: p.description
871
- }));
872
- const membershipOffers = (memberships.data ?? []).map((m) => ({
873
- kind: "membership",
874
- id: m.id,
875
- name: m.name,
876
- priceCents: m.recurringPriceCents,
877
- description: m.description
878
- }));
879
- const gameCardOffers = (gameCards.data ?? []).map((g) => ({
880
- kind: "gamecard",
881
- id: g.id,
882
- name: g.name,
883
- priceCents: g.priceCents,
884
- description: g.description
885
- }));
886
- const sections = [
887
- { title: t.bowling, offers: bowling },
888
- { title: t.otherAttractions, offers: other },
889
- { title: t.events, offers: eventOffers },
890
- { title: t.packages, offers: packageOffers },
891
- { title: t.memberships, offers: membershipOffers },
892
- { title: t.gamePasses, offers: gameCardOffers }
893
- ].filter((sec) => sec.offers.length > 0);
843
+ const catalog = useCatalog({ brandId, centerId, surface });
844
+ const sections = (catalog.data?.sections ?? []).filter(
845
+ (sec) => sec.items.length > 0
846
+ );
894
847
  let body;
895
- if (anyLoading) {
848
+ if (catalog.loading && !catalog.data) {
896
849
  body = /* @__PURE__ */ jsx("p", { style: s.muted, children: t.loading });
897
850
  } else if (sections.length === 0) {
898
851
  body = /* @__PURE__ */ jsx("p", { style: s.muted, children: t.empty });
899
852
  } else {
900
853
  body = sections.map((sec) => /* @__PURE__ */ jsxs("section", { style: { marginTop: "0.5rem" }, children: [
901
- /* @__PURE__ */ jsx("h4", { style: s.sectionTitle, children: sec.title }),
902
- sec.offers.map((offer) => /* @__PURE__ */ jsxs("div", { style: s.listItem, children: [
854
+ /* @__PURE__ */ jsx("h4", { style: s.sectionTitle, children: sectionLabels?.[sec.key] ?? sec.label }),
855
+ sec.items.map((item) => /* @__PURE__ */ jsxs("div", { style: s.listItem, children: [
903
856
  /* @__PURE__ */ jsxs("div", { children: [
904
- /* @__PURE__ */ jsx("p", { style: s.listTitle, children: offer.name }),
905
- /* @__PURE__ */ jsx("p", { style: s.listMeta, children: subtitle(offer, t) })
857
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: item.title }),
858
+ /* @__PURE__ */ jsx("p", { style: s.listMeta, children: item.priceLabel ?? item.subtitle ?? "" })
906
859
  ] }),
907
- /* @__PURE__ */ jsx("button", { type: "button", style: s.primaryBtn, onClick: () => onSelect(offer), children: t.select })
908
- ] }, `${offer.kind}:${offer.id}`))
909
- ] }, sec.title));
860
+ /* @__PURE__ */ jsx(
861
+ "button",
862
+ {
863
+ type: "button",
864
+ style: s.primaryBtn,
865
+ onClick: () => onSelect(item),
866
+ children: t.select
867
+ }
868
+ )
869
+ ] }, item.id))
870
+ ] }, sec.key));
910
871
  }
911
872
  return /* @__PURE__ */ jsxs("div", { className, style: s.card, children: [
912
873
  /* @__PURE__ */ jsx("h3", { style: s.heading, children: t.heading }),
913
874
  body
914
875
  ] });
915
876
  }
916
- function subtitle(offer, t) {
917
- switch (offer.kind) {
918
- case "product":
919
- return `${offer.attractionName} \xB7 ${offer.durationMinutes} ${t.minutesAbbrev}`;
920
- case "event":
921
- return offer.priceCents !== null ? `${offer.date} \xB7 ${formatCents(offer.priceCents)}` : offer.date;
922
- case "membership":
923
- return `${formatCents(offer.priceCents)}${t.perMonth}`;
924
- case "package":
925
- case "gamecard":
926
- return formatCents(offer.priceCents);
927
- }
928
- }
929
877
 
930
878
  export { AccountDashboard, AccountMenu, AuthForm, AuthGate, BookingCatalog, BookingFlow, FlashSale, FlashSaleIndex };
931
879
  //# sourceMappingURL=components.js.map