@bowlos/reservations 0.23.0 → 0.24.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.
@@ -1,9 +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 { d as UseAccountResult } from './react--BT8olOw.cjs';
5
- import { g as CatalogItem } from './catalog-D1VoVaNe.cjs';
6
- export { h as CatalogResult, i as CatalogSection } from './catalog-D1VoVaNe.cjs';
4
+ import { d as UseAccountResult } from './react--584Q9zx.cjs';
5
+ import { g as CatalogItem } from './catalog-I7Lpar3V.cjs';
6
+ export { h as CatalogResult, i as CatalogSection } from './catalog-I7Lpar3V.cjs';
7
7
 
8
8
  /**
9
9
  * Themeable design tokens for the `@bowlos/reservations/components` layer.
@@ -425,42 +425,48 @@ interface FlashSaleIndexProps {
425
425
  declare function FlashSaleIndex({ brandId, onOpen, labels, className }: FlashSaleIndexProps): react_jsx_runtime.JSX.Element;
426
426
 
427
427
  /**
428
- * v0.22.0 (BREAKING): `<BookingCatalog>` is now built on the canonical
428
+ * v0.22.0 (BREAKING): `<BookingCatalog>` is built on the canonical
429
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.
430
+ * same read the white-label web and mobile surfaces consume.
432
431
  *
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.
432
+ * v0.24.0: date-first booking. The catalog read returns the Center's
433
+ * `bookingEntryDefault`; this component opens on it and shows a "by activity /
434
+ * by date" toggle the customer can flip. Date-first lists what's bookable on a
435
+ * chosen day (per-product availability via the existing `availableStartTimes`
436
+ * read) + the events section + an "any day" strip (memberships / game passes /
437
+ * packages). Headless sites build the same from `useCatalog` + `useStartTimes`
438
+ * — see HEADLESS.md → "Date-first booking".
439
+ *
440
+ * `onSelect` receives a `CatalogItem` (route by `item.action.type` with the IDs
441
+ * in `item.action.payload`); the drop-in and a headless site route identically.
437
442
  */
438
443
  interface BookingCatalogLabels {
439
444
  heading: string;
440
445
  loading: string;
441
446
  empty: string;
442
447
  select: string;
448
+ byActivity: string;
449
+ byDate: string;
450
+ pickDay: string;
451
+ bookableOnPrefix: string;
452
+ events: string;
453
+ anyDay: string;
454
+ noTimesThatDay: string;
455
+ nothingThatDay: string;
456
+ checking: string;
443
457
  }
458
+ type EntryMode = "product_first" | "date_first";
444
459
  interface BookingCatalogProps {
445
460
  brandId: string;
446
461
  centerId: string;
447
- /**
448
- * The surface whose admin visibility rules apply. Defaults to
449
- * "sdk_custom_site" (a center's own SDK-built site).
450
- */
451
462
  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).
458
- */
459
463
  onSelect: (item: CatalogItem) => void;
460
464
  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
465
  sectionLabels?: Partial<Record<string, string>>;
466
+ /** Force the entry point, ignoring the Center default. */
467
+ defaultEntry?: EntryMode;
468
+ /** Show the by-activity / by-date toggle (default true). */
469
+ showEntryToggle?: boolean;
464
470
  className?: string;
465
471
  }
466
472
  /**
@@ -470,7 +476,7 @@ interface BookingCatalogProps {
470
476
  * binding prices come from the per-category previews after login. Must render
471
477
  * inside a `<BowlosProvider>`; theme with `<BowlosTheme>`.
472
478
  */
473
- declare function BookingCatalog({ brandId, centerId, surface, onSelect, labels, sectionLabels, className, }: BookingCatalogProps): react_jsx_runtime.JSX.Element;
479
+ declare function BookingCatalog({ brandId, centerId, surface, onSelect, labels, sectionLabels, defaultEntry, showEntryToggle, className, }: BookingCatalogProps): react_jsx_runtime.JSX.Element;
474
480
 
475
481
  /**
476
482
  * Shared primitives for the `@bowlos/reservations/components` layer.
@@ -1,9 +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 { d as UseAccountResult } from './react-BvuU4nzT.js';
5
- import { g as CatalogItem } from './catalog-BxyPJdBL.js';
6
- export { h as CatalogResult, i as CatalogSection } from './catalog-BxyPJdBL.js';
4
+ import { d as UseAccountResult } from './react-C0c5k3Tt.js';
5
+ import { g as CatalogItem } from './catalog-BPh01sfG.js';
6
+ export { h as CatalogResult, i as CatalogSection } from './catalog-BPh01sfG.js';
7
7
 
8
8
  /**
9
9
  * Themeable design tokens for the `@bowlos/reservations/components` layer.
@@ -425,42 +425,48 @@ interface FlashSaleIndexProps {
425
425
  declare function FlashSaleIndex({ brandId, onOpen, labels, className }: FlashSaleIndexProps): react_jsx_runtime.JSX.Element;
426
426
 
427
427
  /**
428
- * v0.22.0 (BREAKING): `<BookingCatalog>` is now built on the canonical
428
+ * v0.22.0 (BREAKING): `<BookingCatalog>` is built on the canonical
429
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.
430
+ * same read the white-label web and mobile surfaces consume.
432
431
  *
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.
432
+ * v0.24.0: date-first booking. The catalog read returns the Center's
433
+ * `bookingEntryDefault`; this component opens on it and shows a "by activity /
434
+ * by date" toggle the customer can flip. Date-first lists what's bookable on a
435
+ * chosen day (per-product availability via the existing `availableStartTimes`
436
+ * read) + the events section + an "any day" strip (memberships / game passes /
437
+ * packages). Headless sites build the same from `useCatalog` + `useStartTimes`
438
+ * — see HEADLESS.md → "Date-first booking".
439
+ *
440
+ * `onSelect` receives a `CatalogItem` (route by `item.action.type` with the IDs
441
+ * in `item.action.payload`); the drop-in and a headless site route identically.
437
442
  */
438
443
  interface BookingCatalogLabels {
439
444
  heading: string;
440
445
  loading: string;
441
446
  empty: string;
442
447
  select: string;
448
+ byActivity: string;
449
+ byDate: string;
450
+ pickDay: string;
451
+ bookableOnPrefix: string;
452
+ events: string;
453
+ anyDay: string;
454
+ noTimesThatDay: string;
455
+ nothingThatDay: string;
456
+ checking: string;
443
457
  }
458
+ type EntryMode = "product_first" | "date_first";
444
459
  interface BookingCatalogProps {
445
460
  brandId: string;
446
461
  centerId: string;
447
- /**
448
- * The surface whose admin visibility rules apply. Defaults to
449
- * "sdk_custom_site" (a center's own SDK-built site).
450
- */
451
462
  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).
458
- */
459
463
  onSelect: (item: CatalogItem) => void;
460
464
  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
465
  sectionLabels?: Partial<Record<string, string>>;
466
+ /** Force the entry point, ignoring the Center default. */
467
+ defaultEntry?: EntryMode;
468
+ /** Show the by-activity / by-date toggle (default true). */
469
+ showEntryToggle?: boolean;
464
470
  className?: string;
465
471
  }
466
472
  /**
@@ -470,7 +476,7 @@ interface BookingCatalogProps {
470
476
  * binding prices come from the per-category previews after login. Must render
471
477
  * inside a `<BowlosProvider>`; theme with `<BowlosTheme>`.
472
478
  */
473
- declare function BookingCatalog({ brandId, centerId, surface, onSelect, labels, sectionLabels, className, }: BookingCatalogProps): react_jsx_runtime.JSX.Element;
479
+ declare function BookingCatalog({ brandId, centerId, surface, onSelect, labels, sectionLabels, defaultEntry, showEntryToggle, className, }: BookingCatalogProps): react_jsx_runtime.JSX.Element;
474
480
 
475
481
  /**
476
482
  * Shared primitives for the `@bowlos/reservations/components` layer.
@@ -827,8 +827,18 @@ 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
- select: "Select"
830
+ select: "Select",
831
+ byActivity: "Browse by activity",
832
+ byDate: "Browse by date",
833
+ pickDay: "Pick a day",
834
+ bookableOnPrefix: "Bookable on ",
835
+ events: "Events",
836
+ anyDay: "Available any day",
837
+ noTimesThatDay: "No times this day",
838
+ nothingThatDay: "Nothing date-specific that day \u2014 try another date or see what's available any day.",
839
+ checking: "Checking\u2026"
831
840
  };
841
+ var DATE_BOUND_KEYS = ["bowling", "other_attractions"];
832
842
  function BookingCatalog({
833
843
  brandId,
834
844
  centerId,
@@ -836,44 +846,150 @@ function BookingCatalog({
836
846
  onSelect,
837
847
  labels,
838
848
  sectionLabels,
849
+ defaultEntry,
850
+ showEntryToggle = true,
839
851
  className
840
852
  }) {
841
853
  const t = { ...DEFAULT_LABELS7, ...labels };
842
854
  const s = styles();
843
855
  const catalog = useCatalog({ brandId, centerId, surface });
844
- const sections = (catalog.data?.sections ?? []).filter(
845
- (sec) => sec.items.length > 0
846
- );
856
+ const [modeOverride, setModeOverride] = useState(null);
857
+ const [date, setDate] = useState(null);
858
+ const sections = (catalog.data?.sections ?? []).filter((sec) => sec.items.length > 0);
859
+ const mode = modeOverride ?? defaultEntry ?? catalog.data?.bookingEntryDefault ?? "product_first";
860
+ const today = catalog.data?.todayISO ?? browserTodayISO();
861
+ const effDate = date ?? today;
862
+ const renderItemRow = (item, meta, disabled) => /* @__PURE__ */ jsxs("div", { style: { ...s.listItem, opacity: 1 }, children: [
863
+ /* @__PURE__ */ jsxs("div", { children: [
864
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: item.title }),
865
+ /* @__PURE__ */ jsx("p", { style: s.listMeta, children: item.priceLabel ?? item.subtitle ?? "" })
866
+ ] }),
867
+ /* @__PURE__ */ jsx("button", { type: "button", style: s.primaryBtn, onClick: () => onSelect(item), children: t.select })
868
+ ] }, item.id);
847
869
  let body;
848
870
  if (catalog.loading && !catalog.data) {
849
871
  body = /* @__PURE__ */ jsx("p", { style: s.muted, children: t.loading });
850
872
  } else if (sections.length === 0) {
851
873
  body = /* @__PURE__ */ jsx("p", { style: s.muted, children: t.empty });
852
- } else {
853
- body = sections.map((sec) => /* @__PURE__ */ jsxs("section", { style: { marginTop: "0.5rem" }, 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: [
856
- /* @__PURE__ */ jsxs("div", { children: [
857
- /* @__PURE__ */ jsx("p", { style: s.listTitle, children: item.title }),
858
- /* @__PURE__ */ jsx("p", { style: s.listMeta, children: item.priceLabel ?? item.subtitle ?? "" })
859
- ] }),
874
+ } else if (mode === "date_first") {
875
+ const productItems = sections.filter((sec) => DATE_BOUND_KEYS.includes(sec.key)).flatMap((sec) => sec.items).filter((i) => i.action.type === "book_reservation");
876
+ const eventItems = sections.find((sec) => sec.key === "events")?.items ?? [];
877
+ const anytimeItems = sections.filter((sec) => !DATE_BOUND_KEYS.includes(sec.key) && sec.key !== "events").flatMap((sec) => sec.items);
878
+ body = /* @__PURE__ */ jsxs(Fragment, { children: [
879
+ /* @__PURE__ */ jsxs("label", { style: { display: "flex", flexDirection: "column", gap: "0.25rem", maxWidth: "16rem" }, children: [
880
+ /* @__PURE__ */ jsx("span", { style: s.listMeta, children: t.pickDay }),
860
881
  /* @__PURE__ */ jsx(
861
- "button",
882
+ "input",
862
883
  {
863
- type: "button",
864
- style: s.primaryBtn,
865
- onClick: () => onSelect(item),
866
- children: t.select
884
+ type: "date",
885
+ value: effDate,
886
+ min: today,
887
+ onChange: (e) => setDate(e.target.value || today),
888
+ style: s.input
867
889
  }
868
890
  )
869
- ] }, item.id))
891
+ ] }),
892
+ /* @__PURE__ */ jsxs("section", { style: { marginTop: "0.75rem" }, children: [
893
+ /* @__PURE__ */ jsxs("h4", { style: s.sectionTitle, children: [
894
+ t.bookableOnPrefix,
895
+ formatDay(effDate)
896
+ ] }),
897
+ productItems.length === 0 ? /* @__PURE__ */ jsx("p", { style: s.muted, children: t.nothingThatDay }) : productItems.map((item) => /* @__PURE__ */ jsx(
898
+ ProductDateRow,
899
+ {
900
+ item,
901
+ dateISO: effDate,
902
+ onSelect,
903
+ labels: t,
904
+ s
905
+ },
906
+ item.id
907
+ ))
908
+ ] }),
909
+ eventItems.length > 0 && /* @__PURE__ */ jsxs("section", { style: { marginTop: "0.5rem" }, children: [
910
+ /* @__PURE__ */ jsx("h4", { style: s.sectionTitle, children: t.events }),
911
+ eventItems.map((item) => renderItemRow(item))
912
+ ] }),
913
+ anytimeItems.length > 0 && /* @__PURE__ */ jsxs("section", { style: { marginTop: "0.5rem" }, children: [
914
+ /* @__PURE__ */ jsx("h4", { style: s.sectionTitle, children: t.anyDay }),
915
+ anytimeItems.map((item) => renderItemRow(item))
916
+ ] })
917
+ ] });
918
+ } else {
919
+ body = sections.map((sec) => /* @__PURE__ */ jsxs("section", { style: { marginTop: "0.5rem" }, children: [
920
+ /* @__PURE__ */ jsx("h4", { style: s.sectionTitle, children: sectionLabels?.[sec.key] ?? sec.label }),
921
+ sec.items.map((item) => renderItemRow(item))
870
922
  ] }, sec.key));
871
923
  }
872
924
  return /* @__PURE__ */ jsxs("div", { className, style: s.card, children: [
873
925
  /* @__PURE__ */ jsx("h3", { style: s.heading, children: t.heading }),
926
+ showEntryToggle && catalog.data && /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "0.5rem", marginBottom: "0.5rem" }, children: [
927
+ /* @__PURE__ */ jsx(EntryButton, { active: mode === "product_first", onClick: () => setModeOverride("product_first"), s, children: t.byActivity }),
928
+ /* @__PURE__ */ jsx(EntryButton, { active: mode === "date_first", onClick: () => setModeOverride("date_first"), s, children: t.byDate })
929
+ ] }),
874
930
  body
875
931
  ] });
876
932
  }
933
+ function EntryButton({
934
+ active,
935
+ onClick,
936
+ s,
937
+ children
938
+ }) {
939
+ return /* @__PURE__ */ jsx(
940
+ "button",
941
+ {
942
+ type: "button",
943
+ onClick,
944
+ "aria-pressed": active,
945
+ style: {
946
+ ...s.primaryBtn,
947
+ opacity: active ? 1 : 0.5,
948
+ cursor: "pointer"
949
+ },
950
+ children
951
+ }
952
+ );
953
+ }
954
+ function ProductDateRow({
955
+ item,
956
+ dateISO,
957
+ onSelect,
958
+ labels,
959
+ s
960
+ }) {
961
+ const productId = item.action.type === "book_reservation" ? item.action.payload.productId : "";
962
+ const times = useStartTimes(
963
+ { productId, dateISO },
964
+ { enabled: productId !== "" }
965
+ );
966
+ const loading = times.loading && times.data === null;
967
+ const available = (times.data?.length ?? 0) > 0;
968
+ const meta = loading ? labels.checking : available ? item.priceLabel ?? "See times & pricing" : labels.noTimesThatDay;
969
+ return /* @__PURE__ */ jsxs("div", { style: { ...s.listItem, opacity: !loading && !available ? 0.55 : 1 }, children: [
970
+ /* @__PURE__ */ jsxs("div", { children: [
971
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: item.title }),
972
+ /* @__PURE__ */ jsx("p", { style: s.listMeta, children: meta })
973
+ ] }),
974
+ available && /* @__PURE__ */ jsx("button", { type: "button", style: s.primaryBtn, onClick: () => onSelect(item), children: labels.select })
975
+ ] });
976
+ }
977
+ function browserTodayISO() {
978
+ const d = /* @__PURE__ */ new Date();
979
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(
980
+ d.getDate()
981
+ ).padStart(2, "0")}`;
982
+ }
983
+ function formatDay(iso) {
984
+ const [y, m, d] = iso.split("-").map(Number);
985
+ if (!y || !m || !d) return iso;
986
+ return new Date(Date.UTC(y, m - 1, d)).toLocaleDateString(void 0, {
987
+ weekday: "long",
988
+ month: "long",
989
+ day: "numeric",
990
+ timeZone: "UTC"
991
+ });
992
+ }
877
993
 
878
994
  export { AccountDashboard, AccountMenu, AuthForm, AuthGate, BookingCatalog, BookingFlow, FlashSale, FlashSaleIndex };
879
995
  //# sourceMappingURL=components.js.map