@sonordev/site-kit 2.5.7 → 2.5.8

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.
@@ -6464,7 +6464,8 @@ function EventsWidget({
6464
6464
  ] })
6465
6465
  ] });
6466
6466
  }
6467
- const displayEvents = effectiveView === "list" || effectiveView === "grid" ? events.slice(0, limit) : events;
6467
+ const groupedList = groupEventsByOffering(events).slice(0, limit);
6468
+ const displayEvents = effectiveView === "grid" ? events.slice(0, limit) : events;
6468
6469
  return /* @__PURE__ */ jsxs("div", { className: `site-kit-events-widget ${className}`, children: [
6469
6470
  (title || subtitle || showViewToggle) && /* @__PURE__ */ jsxs(
6470
6471
  "div",
@@ -6577,16 +6578,31 @@ function EventsWidget({
6577
6578
  }
6578
6579
  ),
6579
6580
  effectiveView === "list" ? /* @__PURE__ */ jsxs("div", { className: `site-kit-events-list ${listClassName}`, children: [
6580
- /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: displayEvents.map((eventItem, index) => {
6581
- const nextSchedule = eventItem.next_schedule || eventItem.schedules?.[0];
6581
+ /* @__PURE__ */ jsx("style", { children: `
6582
+ .sk-date-pills { display: flex; flex-wrap: wrap; gap: 0.375rem; }
6583
+ .sk-date-select-wrap { display: none; }
6584
+ @media (max-width: 640px) {
6585
+ .sk-date-pills { display: none; }
6586
+ .sk-date-select-wrap { display: block; }
6587
+ .site-kit-event-card { flex-direction: column !important; }
6588
+ .site-kit-event-card-image { width: 100% !important; min-width: 0 !important; min-height: 140px !important; }
6589
+ }
6590
+ ` }),
6591
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: groupedList.map(({ event: eventItem, schedules: allSchedules }) => {
6592
+ const schedules = allSchedules.length > 0 ? allSchedules : eventItem.next_schedule ? [eventItem.next_schedule] : [];
6593
+ const isMulti = schedules.length > 1;
6594
+ const primarySchedule = schedules[0] || eventItem.next_schedule || eventItem.schedules?.[0];
6582
6595
  const isFree = !eventItem.price || eventItem.price === 0;
6583
6596
  const imageUrl = eventItem.featured_image_url;
6584
- const uniqueKey = nextSchedule ? `${eventItem.id}-${nextSchedule.id}` : `${eventItem.id}-${index}`;
6597
+ const uniqueKey = eventItem.id;
6585
6598
  return /* @__PURE__ */ jsxs(
6586
6599
  "div",
6587
6600
  {
6588
6601
  className: `site-kit-event-card ${eventCardClassName}`,
6589
- onClick: () => nextSchedule && handleEventClick(eventItem, nextSchedule),
6602
+ onClick: (e) => {
6603
+ if (e.target.closest("[data-sk-date-selector]")) return;
6604
+ if (!isMulti && primarySchedule) handleEventClick(eventItem, primarySchedule);
6605
+ },
6590
6606
  style: {
6591
6607
  display: "flex",
6592
6608
  flexDirection: "row",
@@ -6595,12 +6611,12 @@ function EventsWidget({
6595
6611
  background: "var(--sk-bg)",
6596
6612
  border: "1px solid var(--sk-border)",
6597
6613
  borderRadius: "0.75rem",
6598
- cursor: nextSchedule ? "pointer" : "default",
6614
+ cursor: !isMulti && primarySchedule ? "pointer" : "default",
6599
6615
  transition: "all 150ms",
6600
6616
  overflow: "hidden"
6601
6617
  },
6602
6618
  onMouseEnter: (e) => {
6603
- if (nextSchedule) {
6619
+ if (!isMulti && primarySchedule) {
6604
6620
  e.currentTarget.style.borderColor = "var(--sk-primary)";
6605
6621
  e.currentTarget.style.boxShadow = "0 4px 6px -1px rgba(0, 0, 0, 0.1)";
6606
6622
  }
@@ -6610,7 +6626,7 @@ function EventsWidget({
6610
6626
  e.currentTarget.style.boxShadow = "none";
6611
6627
  },
6612
6628
  children: [
6613
- /* @__PURE__ */ jsxs("div", { style: {
6629
+ /* @__PURE__ */ jsxs("div", { className: "site-kit-event-card-image", style: {
6614
6630
  width: "160px",
6615
6631
  minWidth: "160px",
6616
6632
  flexShrink: 0,
@@ -6670,23 +6686,130 @@ function EventsWidget({
6670
6686
  whiteSpace: "nowrap"
6671
6687
  }, children: isFree ? "Free" : formatPrice(eventItem.price ?? 0, eventItem.currency) })
6672
6688
  ] }),
6673
- nextSchedule && /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "1rem", fontSize: "0.875rem", color: "var(--sk-text-secondary)" }, children: [
6689
+ !isMulti && primarySchedule && /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "1rem", fontSize: "0.875rem", color: "var(--sk-text-secondary)" }, children: [
6674
6690
  /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.375rem" }, children: [
6675
6691
  /* @__PURE__ */ jsx(CalendarIcon, {}),
6676
- formatDate(nextSchedule.starts_at)
6692
+ formatDate(primarySchedule.starts_at)
6677
6693
  ] }),
6678
6694
  /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.375rem" }, children: [
6679
6695
  /* @__PURE__ */ jsx(ClockIcon, {}),
6680
- formatTime(nextSchedule.starts_at)
6696
+ formatTime(primarySchedule.starts_at)
6681
6697
  ] }),
6682
6698
  eventItem.location && /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.375rem" }, children: [
6683
6699
  /* @__PURE__ */ jsx(LocationIcon, {}),
6684
6700
  eventItem.location
6685
6701
  ] }),
6686
- nextSchedule.spots_remaining !== null && nextSchedule.spots_remaining !== void 0 && /* @__PURE__ */ jsx("span", { style: {
6687
- color: nextSchedule.spots_remaining < 5 ? "var(--sk-error)" : "var(--sk-text-secondary)",
6688
- fontWeight: nextSchedule.spots_remaining < 5 ? 500 : 400
6689
- }, children: nextSchedule.spots_remaining === 0 ? "Sold Out" : `${nextSchedule.spots_remaining} spots left` })
6702
+ primarySchedule.spots_remaining !== null && primarySchedule.spots_remaining !== void 0 && /* @__PURE__ */ jsx("span", { style: {
6703
+ color: primarySchedule.spots_remaining < 5 ? "var(--sk-error)" : "var(--sk-text-secondary)",
6704
+ fontWeight: primarySchedule.spots_remaining < 5 ? 500 : 400
6705
+ }, children: primarySchedule.spots_remaining === 0 ? "Sold Out" : `${primarySchedule.spots_remaining} spots left` })
6706
+ ] }),
6707
+ isMulti && /* @__PURE__ */ jsxs("div", { "data-sk-date-selector": true, onClick: (e) => e.stopPropagation(), children: [
6708
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "1rem", fontSize: "0.875rem", color: "var(--sk-text-secondary)", marginBottom: "0.625rem" }, children: [
6709
+ /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.375rem", fontWeight: 500, color: "var(--sk-text-primary)" }, children: [
6710
+ /* @__PURE__ */ jsx(CalendarIcon, {}),
6711
+ schedules.length,
6712
+ " dates available"
6713
+ ] }),
6714
+ eventItem.location && /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.375rem" }, children: [
6715
+ /* @__PURE__ */ jsx(LocationIcon, {}),
6716
+ eventItem.location
6717
+ ] }),
6718
+ /* @__PURE__ */ jsxs("span", { children: [
6719
+ formatDate(schedules[0].starts_at),
6720
+ " \u2013 ",
6721
+ formatDate(schedules[schedules.length - 1].starts_at)
6722
+ ] })
6723
+ ] }),
6724
+ /* @__PURE__ */ jsx("div", { className: "sk-date-pills", children: schedules.map((s) => {
6725
+ const soldOut = s.spots_remaining === 0;
6726
+ const low = !soldOut && s.spots_remaining !== null && s.spots_remaining !== void 0 && s.spots_remaining < 5;
6727
+ return /* @__PURE__ */ jsxs(
6728
+ "button",
6729
+ {
6730
+ type: "button",
6731
+ onClick: () => !soldOut && handleEventClick(eventItem, s),
6732
+ disabled: soldOut,
6733
+ title: `${formatDate(s.starts_at)} \u2022 ${formatTime(s.starts_at)}${soldOut ? " (Sold Out)" : low ? ` (${s.spots_remaining} left)` : ""}`,
6734
+ style: {
6735
+ display: "inline-flex",
6736
+ alignItems: "center",
6737
+ gap: "0.375rem",
6738
+ padding: "0.375rem 0.75rem",
6739
+ borderRadius: "9999px",
6740
+ border: "1px solid var(--sk-border)",
6741
+ background: soldOut ? "var(--sk-surface)" : "var(--sk-bg)",
6742
+ color: soldOut ? "var(--sk-text-secondary)" : "var(--sk-text-primary)",
6743
+ fontSize: "0.8125rem",
6744
+ fontWeight: 500,
6745
+ cursor: soldOut ? "not-allowed" : "pointer",
6746
+ textDecoration: soldOut ? "line-through" : "none",
6747
+ transition: "all 150ms",
6748
+ whiteSpace: "nowrap"
6749
+ },
6750
+ onMouseEnter: (e) => {
6751
+ if (!soldOut) {
6752
+ e.currentTarget.style.background = "var(--sk-primary)";
6753
+ e.currentTarget.style.color = "var(--sk-bg)";
6754
+ e.currentTarget.style.borderColor = "var(--sk-primary)";
6755
+ }
6756
+ },
6757
+ onMouseLeave: (e) => {
6758
+ if (!soldOut) {
6759
+ e.currentTarget.style.background = "var(--sk-bg)";
6760
+ e.currentTarget.style.color = "var(--sk-text-primary)";
6761
+ e.currentTarget.style.borderColor = "var(--sk-border)";
6762
+ }
6763
+ },
6764
+ children: [
6765
+ formatDate(s.starts_at),
6766
+ " \xB7 ",
6767
+ formatTime(s.starts_at),
6768
+ low && /* @__PURE__ */ jsxs("span", { style: { color: "var(--sk-error)", fontWeight: 600, fontSize: "0.75rem" }, children: [
6769
+ s.spots_remaining,
6770
+ " left"
6771
+ ] })
6772
+ ]
6773
+ },
6774
+ s.id
6775
+ );
6776
+ }) }),
6777
+ /* @__PURE__ */ jsx("div", { className: "sk-date-select-wrap", children: /* @__PURE__ */ jsxs(
6778
+ "select",
6779
+ {
6780
+ defaultValue: "",
6781
+ onChange: (e) => {
6782
+ const scheduleId = e.target.value;
6783
+ const s = schedules.find((x) => x.id === scheduleId);
6784
+ if (s) handleEventClick(eventItem, s);
6785
+ e.currentTarget.value = "";
6786
+ },
6787
+ style: {
6788
+ width: "100%",
6789
+ padding: "0.625rem 0.75rem",
6790
+ border: "1px solid var(--sk-border)",
6791
+ borderRadius: "0.5rem",
6792
+ background: "var(--sk-bg)",
6793
+ color: "var(--sk-text-primary)",
6794
+ fontSize: "0.875rem",
6795
+ fontWeight: 500,
6796
+ cursor: "pointer"
6797
+ },
6798
+ children: [
6799
+ /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select a date to register\u2026" }),
6800
+ schedules.map((s) => {
6801
+ const soldOut = s.spots_remaining === 0;
6802
+ const low = !soldOut && s.spots_remaining !== null && s.spots_remaining !== void 0 && s.spots_remaining < 5;
6803
+ return /* @__PURE__ */ jsxs("option", { value: s.id, disabled: soldOut, children: [
6804
+ formatDate(s.starts_at),
6805
+ " \xB7 ",
6806
+ formatTime(s.starts_at),
6807
+ soldOut ? " \u2014 Sold Out" : low ? ` \u2014 ${s.spots_remaining} left` : ""
6808
+ ] }, s.id);
6809
+ })
6810
+ ]
6811
+ }
6812
+ ) })
6690
6813
  ] })
6691
6814
  ] })
6692
6815
  ]
@@ -6694,7 +6817,7 @@ function EventsWidget({
6694
6817
  uniqueKey
6695
6818
  );
6696
6819
  }) }),
6697
- showViewAll && events.length > limit && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginTop: "1.5rem" }, children: /* @__PURE__ */ jsx(
6820
+ showViewAll && groupedList.length >= limit && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginTop: "1.5rem" }, children: /* @__PURE__ */ jsx(
6698
6821
  "a",
6699
6822
  {
6700
6823
  href: viewAllUrl,
@@ -6844,7 +6967,36 @@ function getApiKey2() {
6844
6967
  }
6845
6968
  return "";
6846
6969
  }
6970
+ function groupEventsByOffering(events) {
6971
+ const groups = /* @__PURE__ */ new Map();
6972
+ for (const ev of events) {
6973
+ const incoming = (ev.schedules || []).filter(Boolean);
6974
+ const existing = groups.get(ev.id);
6975
+ if (existing) {
6976
+ for (const s of incoming) {
6977
+ if (!existing.schedules.some((x) => x.id === s.id)) {
6978
+ existing.schedules.push(s);
6979
+ }
6980
+ }
6981
+ } else {
6982
+ groups.set(ev.id, { event: ev, schedules: [...incoming] });
6983
+ }
6984
+ }
6985
+ for (const g of groups.values()) {
6986
+ g.schedules.sort(
6987
+ (a, b) => new Date(a.starts_at).getTime() - new Date(b.starts_at).getTime()
6988
+ );
6989
+ }
6990
+ return Array.from(groups.values()).sort((a, b) => {
6991
+ const aFirst = a.schedules[0]?.starts_at;
6992
+ const bFirst = b.schedules[0]?.starts_at;
6993
+ if (!aFirst && !bFirst) return 0;
6994
+ if (!aFirst) return 1;
6995
+ if (!bFirst) return -1;
6996
+ return new Date(aFirst).getTime() - new Date(bFirst).getTime();
6997
+ });
6998
+ }
6847
6999
 
6848
7000
  export { CalendarView, CheckoutForm, EventCalendar, EventEmbed, EventModal, EventTile, EventsWidget, OfferingCard, OfferingList, ProductDetail, ProductEmbed, ProductGrid, ProductPage, RegistrationForm, SizeChart, UpcomingEvents, createCheckoutSession, createPaymentIntent, fetchActiveProcessor, fetchCategories, fetchLatestOffering, fetchNextEvent, fetchOffering, fetchOfferings, fetchProcessorConfig, fetchProductBySlug, fetchProducts, fetchProductsPublic, fetchServices, fetchShippingRates, fetchUpcomingEvents, formatDate, formatDateRange, formatDateTime, formatPrice, formatTime, getOfferingUrl, getRelativeTimeUntil, getSpotsRemaining, isEventSoldOut, registerForEvent, useEventModal, validateAddress, validateDiscountCode };
6849
- //# sourceMappingURL=chunk-WET5VJRP.mjs.map
6850
- //# sourceMappingURL=chunk-WET5VJRP.mjs.map
7001
+ //# sourceMappingURL=chunk-GGK5XOY5.mjs.map
7002
+ //# sourceMappingURL=chunk-GGK5XOY5.mjs.map