@sonordev/site-kit 2.5.7 → 2.5.9

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.
@@ -6470,7 +6470,8 @@ function EventsWidget({
6470
6470
  ] })
6471
6471
  ] });
6472
6472
  }
6473
- const displayEvents = effectiveView === "list" || effectiveView === "grid" ? events.slice(0, limit) : events;
6473
+ const groupedList = groupEventsByOffering(events).slice(0, limit);
6474
+ const displayEvents = effectiveView === "grid" ? events.slice(0, limit) : events;
6474
6475
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `site-kit-events-widget ${className}`, children: [
6475
6476
  (title || subtitle || showViewToggle) && /* @__PURE__ */ jsxRuntime.jsxs(
6476
6477
  "div",
@@ -6583,16 +6584,31 @@ function EventsWidget({
6583
6584
  }
6584
6585
  ),
6585
6586
  effectiveView === "list" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `site-kit-events-list ${listClassName}`, children: [
6586
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: displayEvents.map((eventItem, index) => {
6587
- const nextSchedule = eventItem.next_schedule || eventItem.schedules?.[0];
6587
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
6588
+ .sk-date-pills { display: flex; flex-wrap: wrap; gap: 0.375rem; }
6589
+ .sk-date-select-wrap { display: none; }
6590
+ @media (max-width: 640px) {
6591
+ .sk-date-pills { display: none; }
6592
+ .sk-date-select-wrap { display: block; }
6593
+ .site-kit-event-card { flex-direction: column !important; }
6594
+ .site-kit-event-card-image { width: 100% !important; min-width: 0 !important; min-height: 140px !important; }
6595
+ }
6596
+ ` }),
6597
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: groupedList.map(({ event: eventItem, schedules: allSchedules }) => {
6598
+ const schedules = allSchedules.length > 0 ? allSchedules : eventItem.next_schedule ? [eventItem.next_schedule] : [];
6599
+ const isMulti = schedules.length > 1;
6600
+ const primarySchedule = schedules[0] || eventItem.next_schedule || eventItem.schedules?.[0];
6588
6601
  const isFree = !eventItem.price || eventItem.price === 0;
6589
6602
  const imageUrl = eventItem.featured_image_url;
6590
- const uniqueKey = nextSchedule ? `${eventItem.id}-${nextSchedule.id}` : `${eventItem.id}-${index}`;
6603
+ const uniqueKey = eventItem.id;
6591
6604
  return /* @__PURE__ */ jsxRuntime.jsxs(
6592
6605
  "div",
6593
6606
  {
6594
6607
  className: `site-kit-event-card ${eventCardClassName}`,
6595
- onClick: () => nextSchedule && handleEventClick(eventItem, nextSchedule),
6608
+ onClick: (e) => {
6609
+ if (e.target.closest("[data-sk-date-selector]")) return;
6610
+ if (!isMulti && primarySchedule) handleEventClick(eventItem, primarySchedule);
6611
+ },
6596
6612
  style: {
6597
6613
  display: "flex",
6598
6614
  flexDirection: "row",
@@ -6601,12 +6617,12 @@ function EventsWidget({
6601
6617
  background: "var(--sk-bg)",
6602
6618
  border: "1px solid var(--sk-border)",
6603
6619
  borderRadius: "0.75rem",
6604
- cursor: nextSchedule ? "pointer" : "default",
6620
+ cursor: !isMulti && primarySchedule ? "pointer" : "default",
6605
6621
  transition: "all 150ms",
6606
6622
  overflow: "hidden"
6607
6623
  },
6608
6624
  onMouseEnter: (e) => {
6609
- if (nextSchedule) {
6625
+ if (!isMulti && primarySchedule) {
6610
6626
  e.currentTarget.style.borderColor = "var(--sk-primary)";
6611
6627
  e.currentTarget.style.boxShadow = "0 4px 6px -1px rgba(0, 0, 0, 0.1)";
6612
6628
  }
@@ -6616,7 +6632,7 @@ function EventsWidget({
6616
6632
  e.currentTarget.style.boxShadow = "none";
6617
6633
  },
6618
6634
  children: [
6619
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
6635
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "site-kit-event-card-image", style: {
6620
6636
  width: "160px",
6621
6637
  minWidth: "160px",
6622
6638
  flexShrink: 0,
@@ -6676,23 +6692,142 @@ function EventsWidget({
6676
6692
  whiteSpace: "nowrap"
6677
6693
  }, children: isFree ? "Free" : formatPrice(eventItem.price ?? 0, eventItem.currency) })
6678
6694
  ] }),
6679
- nextSchedule && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "1rem", fontSize: "0.875rem", color: "var(--sk-text-secondary)" }, children: [
6695
+ !isMulti && primarySchedule && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "1rem", fontSize: "0.875rem", color: "var(--sk-text-secondary)" }, children: [
6680
6696
  /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.375rem" }, children: [
6681
6697
  /* @__PURE__ */ jsxRuntime.jsx(CalendarIcon, {}),
6682
- formatDate(nextSchedule.starts_at)
6698
+ formatDate(primarySchedule.starts_at)
6683
6699
  ] }),
6684
6700
  /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.375rem" }, children: [
6685
6701
  /* @__PURE__ */ jsxRuntime.jsx(ClockIcon, {}),
6686
- formatTime(nextSchedule.starts_at)
6702
+ formatTime(primarySchedule.starts_at)
6687
6703
  ] }),
6688
6704
  eventItem.location && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.375rem" }, children: [
6689
6705
  /* @__PURE__ */ jsxRuntime.jsx(LocationIcon, {}),
6690
6706
  eventItem.location
6691
6707
  ] }),
6692
- nextSchedule.spots_remaining !== null && nextSchedule.spots_remaining !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
6693
- color: nextSchedule.spots_remaining < 5 ? "var(--sk-error)" : "var(--sk-text-secondary)",
6694
- fontWeight: nextSchedule.spots_remaining < 5 ? 500 : 400
6695
- }, children: nextSchedule.spots_remaining === 0 ? "Sold Out" : `${nextSchedule.spots_remaining} spots left` })
6708
+ primarySchedule.spots_remaining !== null && primarySchedule.spots_remaining !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
6709
+ color: primarySchedule.spots_remaining < 5 ? "var(--sk-error)" : "var(--sk-text-secondary)",
6710
+ fontWeight: primarySchedule.spots_remaining < 5 ? 500 : 400
6711
+ }, children: primarySchedule.spots_remaining === 0 ? "Sold Out" : `${primarySchedule.spots_remaining} spots left` })
6712
+ ] }),
6713
+ isMulti && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-sk-date-selector": true, onClick: (e) => e.stopPropagation(), children: [
6714
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "1rem", fontSize: "0.875rem", color: "var(--sk-text-secondary)", marginBottom: "0.625rem" }, children: [
6715
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.375rem", fontWeight: 500, color: "var(--sk-text-primary)" }, children: [
6716
+ /* @__PURE__ */ jsxRuntime.jsx(CalendarIcon, {}),
6717
+ schedules.length,
6718
+ " dates available"
6719
+ ] }),
6720
+ eventItem.location && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: "0.375rem" }, children: [
6721
+ /* @__PURE__ */ jsxRuntime.jsx(LocationIcon, {}),
6722
+ eventItem.location
6723
+ ] }),
6724
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6725
+ formatDate(schedules[0].starts_at),
6726
+ " \u2013 ",
6727
+ formatDate(schedules[schedules.length - 1].starts_at)
6728
+ ] })
6729
+ ] }),
6730
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sk-date-pills", children: schedules.map((s) => {
6731
+ const soldOut = s.spots_remaining === 0;
6732
+ const low = !soldOut && s.spots_remaining !== null && s.spots_remaining !== void 0 && s.spots_remaining < 5;
6733
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6734
+ "button",
6735
+ {
6736
+ type: "button",
6737
+ onClick: () => !soldOut && handleEventClick(eventItem, s),
6738
+ disabled: soldOut,
6739
+ title: `${formatDate(s.starts_at)} \u2022 ${formatTime(s.starts_at)}${soldOut ? " (Sold Out)" : low ? ` (${s.spots_remaining} left)` : ""}`,
6740
+ style: {
6741
+ display: "inline-flex",
6742
+ alignItems: "center",
6743
+ gap: "0.375rem",
6744
+ padding: "0.5rem 0.875rem",
6745
+ borderRadius: "9999px",
6746
+ border: "1.5px solid var(--sk-primary)",
6747
+ background: soldOut ? "var(--sk-surface)" : "var(--sk-bg)",
6748
+ color: soldOut ? "var(--sk-text-secondary)" : "var(--sk-primary)",
6749
+ fontSize: "0.8125rem",
6750
+ fontWeight: 600,
6751
+ letterSpacing: "0.01em",
6752
+ cursor: soldOut ? "not-allowed" : "pointer",
6753
+ textDecoration: soldOut ? "line-through" : "none",
6754
+ transition: "all 150ms ease",
6755
+ whiteSpace: "nowrap",
6756
+ boxShadow: soldOut ? "none" : "0 1px 2px rgba(0,0,0,0.04)"
6757
+ },
6758
+ onMouseEnter: (e) => {
6759
+ if (!soldOut) {
6760
+ e.currentTarget.style.background = "var(--sk-primary)";
6761
+ e.currentTarget.style.color = "var(--sk-bg)";
6762
+ e.currentTarget.style.transform = "translateY(-1px)";
6763
+ e.currentTarget.style.boxShadow = "0 4px 10px -2px rgba(0,0,0,0.15)";
6764
+ }
6765
+ },
6766
+ onMouseLeave: (e) => {
6767
+ if (!soldOut) {
6768
+ e.currentTarget.style.background = "var(--sk-bg)";
6769
+ e.currentTarget.style.color = "var(--sk-primary)";
6770
+ e.currentTarget.style.transform = "none";
6771
+ e.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.04)";
6772
+ }
6773
+ },
6774
+ children: [
6775
+ formatDate(s.starts_at),
6776
+ " \xB7 ",
6777
+ formatTime(s.starts_at),
6778
+ low && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: {
6779
+ marginLeft: "0.125rem",
6780
+ padding: "0.0625rem 0.375rem",
6781
+ borderRadius: "9999px",
6782
+ background: "var(--sk-error)",
6783
+ color: "var(--sk-bg)",
6784
+ fontWeight: 700,
6785
+ fontSize: "0.6875rem"
6786
+ }, children: [
6787
+ s.spots_remaining,
6788
+ " left"
6789
+ ] })
6790
+ ]
6791
+ },
6792
+ s.id
6793
+ );
6794
+ }) }),
6795
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sk-date-select-wrap", children: /* @__PURE__ */ jsxRuntime.jsxs(
6796
+ "select",
6797
+ {
6798
+ defaultValue: "",
6799
+ onChange: (e) => {
6800
+ const scheduleId = e.target.value;
6801
+ const s = schedules.find((x) => x.id === scheduleId);
6802
+ if (s) handleEventClick(eventItem, s);
6803
+ e.currentTarget.value = "";
6804
+ },
6805
+ style: {
6806
+ width: "100%",
6807
+ padding: "0.625rem 0.75rem",
6808
+ border: "1px solid var(--sk-border)",
6809
+ borderRadius: "0.5rem",
6810
+ background: "var(--sk-bg)",
6811
+ color: "var(--sk-text-primary)",
6812
+ fontSize: "0.875rem",
6813
+ fontWeight: 500,
6814
+ cursor: "pointer"
6815
+ },
6816
+ children: [
6817
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Select a date to register\u2026" }),
6818
+ schedules.map((s) => {
6819
+ const soldOut = s.spots_remaining === 0;
6820
+ const low = !soldOut && s.spots_remaining !== null && s.spots_remaining !== void 0 && s.spots_remaining < 5;
6821
+ return /* @__PURE__ */ jsxRuntime.jsxs("option", { value: s.id, disabled: soldOut, children: [
6822
+ formatDate(s.starts_at),
6823
+ " \xB7 ",
6824
+ formatTime(s.starts_at),
6825
+ soldOut ? " \u2014 Sold Out" : low ? ` \u2014 ${s.spots_remaining} left` : ""
6826
+ ] }, s.id);
6827
+ })
6828
+ ]
6829
+ }
6830
+ ) })
6696
6831
  ] })
6697
6832
  ] })
6698
6833
  ]
@@ -6700,7 +6835,7 @@ function EventsWidget({
6700
6835
  uniqueKey
6701
6836
  );
6702
6837
  }) }),
6703
- showViewAll && events.length > limit && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", marginTop: "1.5rem" }, children: /* @__PURE__ */ jsxRuntime.jsx(
6838
+ showViewAll && groupedList.length >= limit && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", marginTop: "1.5rem" }, children: /* @__PURE__ */ jsxRuntime.jsx(
6704
6839
  "a",
6705
6840
  {
6706
6841
  href: viewAllUrl,
@@ -6850,6 +6985,35 @@ function getApiKey2() {
6850
6985
  }
6851
6986
  return "";
6852
6987
  }
6988
+ function groupEventsByOffering(events) {
6989
+ const groups = /* @__PURE__ */ new Map();
6990
+ for (const ev of events) {
6991
+ const incoming = (ev.schedules || []).filter(Boolean);
6992
+ const existing = groups.get(ev.id);
6993
+ if (existing) {
6994
+ for (const s of incoming) {
6995
+ if (!existing.schedules.some((x) => x.id === s.id)) {
6996
+ existing.schedules.push(s);
6997
+ }
6998
+ }
6999
+ } else {
7000
+ groups.set(ev.id, { event: ev, schedules: [...incoming] });
7001
+ }
7002
+ }
7003
+ for (const g of groups.values()) {
7004
+ g.schedules.sort(
7005
+ (a, b) => new Date(a.starts_at).getTime() - new Date(b.starts_at).getTime()
7006
+ );
7007
+ }
7008
+ return Array.from(groups.values()).sort((a, b) => {
7009
+ const aFirst = a.schedules[0]?.starts_at;
7010
+ const bFirst = b.schedules[0]?.starts_at;
7011
+ if (!aFirst && !bFirst) return 0;
7012
+ if (!aFirst) return 1;
7013
+ if (!bFirst) return -1;
7014
+ return new Date(aFirst).getTime() - new Date(bFirst).getTime();
7015
+ });
7016
+ }
6853
7017
 
6854
7018
  exports.CalendarView = CalendarView;
6855
7019
  exports.CheckoutForm = CheckoutForm;
@@ -6895,5 +7059,5 @@ exports.registerForEvent = registerForEvent;
6895
7059
  exports.useEventModal = useEventModal;
6896
7060
  exports.validateAddress = validateAddress;
6897
7061
  exports.validateDiscountCode = validateDiscountCode;
6898
- //# sourceMappingURL=chunk-TA2RGEE3.js.map
6899
- //# sourceMappingURL=chunk-TA2RGEE3.js.map
7062
+ //# sourceMappingURL=chunk-JPVTQNIS.js.map
7063
+ //# sourceMappingURL=chunk-JPVTQNIS.js.map