@session-services/web-elements 0.1.23 → 0.1.24

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.
@@ -23626,6 +23626,7 @@ const sessionServicesTicketingCss = () => `:host{--background:transparent;--fore
23626
23626
 
23627
23627
  const quoteTotal = (quote) => quote.price?.total ?? 0;
23628
23628
  const QUOTE_DEBOUNCE_MS = 150;
23629
+ const STICKY_CHECKOUT_SCROLL_OFFSET_PX = 100;
23629
23630
  function objectValue(value, key) {
23630
23631
  if (!value || typeof value !== "object")
23631
23632
  return undefined;
@@ -24452,14 +24453,21 @@ const SessionsTicketing = class {
24452
24453
  handleStickyCheckoutClick(state) {
24453
24454
  if (state.isDoorOnly || !hasQuoteItems(this.quote)) {
24454
24455
  this.promptTicketSelection();
24455
- this.host.scrollIntoView({
24456
- behavior: "smooth",
24457
- block: "start",
24458
- });
24456
+ this.scrollToTicketSelector();
24459
24457
  return;
24460
24458
  }
24461
24459
  this.initiateCheckout().catch(() => undefined);
24462
24460
  }
24461
+ scrollToTicketSelector() {
24462
+ const target = this.host.shadowRoot?.querySelector(".tickets-wrapper") ??
24463
+ this.host;
24464
+ window.scrollTo({
24465
+ behavior: "smooth",
24466
+ top: Math.max(target.getBoundingClientRect().top +
24467
+ window.scrollY -
24468
+ STICKY_CHECKOUT_SCROLL_OFFSET_PX, 0),
24469
+ });
24470
+ }
24463
24471
  getCartProducts() {
24464
24472
  if (!this.quote)
24465
24473
  return [];
@@ -24777,7 +24785,8 @@ const SessionsTicketing = class {
24777
24785
  return null;
24778
24786
  if (!state.externalTicketUrl)
24779
24787
  return null;
24780
- return (index.h("div", { class: "sticky-checkout-bar" }, index.h("a", { class: "external-ticket-button sticky-checkout-btn", href: state.externalTicketUrl, target: "_blank", rel: "noreferrer" }, index.h("span", { class: "external-ticket-label" }, "Get tickets"))));
24788
+ const domain = urlDomain(state.externalTicketUrl);
24789
+ return (index.h("div", { class: "sticky-checkout-bar" }, index.h("a", { class: "external-ticket-button sticky-checkout-btn", href: state.externalTicketUrl, target: "_blank", rel: "noreferrer" }, index.h("span", { class: "external-ticket-label" }, "Get tickets"), index.h("span", { class: "external-ticket-domain" }, "via ", domain))));
24781
24790
  }
24782
24791
  renderModal() {
24783
24792
  if (!this.openModalAdmissionId)
@@ -9,6 +9,7 @@ h, } from "@stencil/core";
9
9
  import { admissionPriceSavings, discountCouponFromSearch, getAdmissionDisplayState, getAdmissionPriceDisplay, getTicketingState, parseSelectionKey, previewQuoteItems, priceTotal, quoteItemsBySelection, selectionKey, topLevelTicketItems, visibleAdmissions, } from "./session-services-ticketing.logic";
10
10
  const quoteTotal = (quote) => quote.price?.total ?? 0;
11
11
  const QUOTE_DEBOUNCE_MS = 150;
12
+ const STICKY_CHECKOUT_SCROLL_OFFSET_PX = 100;
12
13
  function objectValue(value, key) {
13
14
  if (!value || typeof value !== "object")
14
15
  return undefined;
@@ -829,14 +830,21 @@ export class SessionsTicketing {
829
830
  handleStickyCheckoutClick(state) {
830
831
  if (state.isDoorOnly || !hasQuoteItems(this.quote)) {
831
832
  this.promptTicketSelection();
832
- this.host.scrollIntoView({
833
- behavior: "smooth",
834
- block: "start",
835
- });
833
+ this.scrollToTicketSelector();
836
834
  return;
837
835
  }
838
836
  this.initiateCheckout().catch(() => undefined);
839
837
  }
838
+ scrollToTicketSelector() {
839
+ const target = this.host.shadowRoot?.querySelector(".tickets-wrapper") ??
840
+ this.host;
841
+ window.scrollTo({
842
+ behavior: "smooth",
843
+ top: Math.max(target.getBoundingClientRect().top +
844
+ window.scrollY -
845
+ STICKY_CHECKOUT_SCROLL_OFFSET_PX, 0),
846
+ });
847
+ }
840
848
  getCartProducts() {
841
849
  if (!this.quote)
842
850
  return [];
@@ -1155,7 +1163,8 @@ export class SessionsTicketing {
1155
1163
  return null;
1156
1164
  if (!state.externalTicketUrl)
1157
1165
  return null;
1158
- return (h("div", { class: "sticky-checkout-bar" }, h("a", { class: "external-ticket-button sticky-checkout-btn", href: state.externalTicketUrl, target: "_blank", rel: "noreferrer" }, h("span", { class: "external-ticket-label" }, "Get tickets"))));
1166
+ const domain = urlDomain(state.externalTicketUrl);
1167
+ return (h("div", { class: "sticky-checkout-bar" }, h("a", { class: "external-ticket-button sticky-checkout-btn", href: state.externalTicketUrl, target: "_blank", rel: "noreferrer" }, h("span", { class: "external-ticket-label" }, "Get tickets"), h("span", { class: "external-ticket-domain" }, "via ", domain))));
1159
1168
  }
1160
1169
  renderModal() {
1161
1170
  if (!this.openModalAdmissionId)
@@ -138,6 +138,9 @@ function widget() {
138
138
  const item = new SessionsTicketing();
139
139
  item.eventId = "evt_1";
140
140
  item.event = event();
141
+ item.host = {
142
+ getBoundingClientRect: () => ({ top: 0 }),
143
+ };
141
144
  item.selectedItems = new Map();
142
145
  item.quote = null;
143
146
  item.previewQuote = null;
@@ -276,6 +279,9 @@ describe("session-services-ticketing component", () => {
276
279
  expect(links[0].props.href).toBe("https://tickets.example");
277
280
  expect(hasClass(links[0], "external-ticket-button")).toBe(true);
278
281
  expect(hasClass(links[0], "sticky-checkout-btn")).toBe(true);
282
+ expect(rendered(links[0], (node) => node.tag === "span" &&
283
+ hasClass(node, "external-ticket-domain") &&
284
+ node.children.join("") === "via tickets.example")).toHaveLength(1);
279
285
  });
280
286
  it("keeps external ticketing under the sticky checkout host state", () => {
281
287
  const item = widget();
@@ -290,6 +296,26 @@ describe("session-services-ticketing component", () => {
290
296
  expect(links.some((link) => hasClass(link, "inline-external-ticket-button"))).toBe(true);
291
297
  expect(links.some((link) => hasClass(link, "sticky-checkout-btn"))).toBe(true);
292
298
  });
299
+ it("scrolls to the ticket selector with a 100px top offset", () => {
300
+ const item = widget();
301
+ const scrollTo = vi.fn();
302
+ const tickets = {
303
+ getBoundingClientRect: () => ({ top: 420 }),
304
+ };
305
+ item.host = {
306
+ shadowRoot: {
307
+ querySelector: vi.fn().mockReturnValue(tickets),
308
+ },
309
+ getBoundingClientRect: () => ({ top: 900 }),
310
+ };
311
+ vi.stubGlobal("window", { scrollY: 250, scrollTo });
312
+ item.handleStickyCheckoutClick(getTicketingState(item.event));
313
+ expect(scrollTo).toHaveBeenCalledWith({
314
+ behavior: "smooth",
315
+ top: 570,
316
+ });
317
+ vi.unstubAllGlobals();
318
+ });
293
319
  it("classifies only passcode access failures as passcode errors", async () => {
294
320
  const item = widget();
295
321
  item.client.event.get = vi
@@ -23624,6 +23624,7 @@ const sessionServicesTicketingCss = () => `:host{--background:transparent;--fore
23624
23624
 
23625
23625
  const quoteTotal = (quote) => quote.price?.total ?? 0;
23626
23626
  const QUOTE_DEBOUNCE_MS = 150;
23627
+ const STICKY_CHECKOUT_SCROLL_OFFSET_PX = 100;
23627
23628
  function objectValue(value, key) {
23628
23629
  if (!value || typeof value !== "object")
23629
23630
  return undefined;
@@ -24454,14 +24455,21 @@ const SessionsTicketing = /*@__PURE__*/ proxyCustomElement(class SessionsTicketi
24454
24455
  handleStickyCheckoutClick(state) {
24455
24456
  if (state.isDoorOnly || !hasQuoteItems(this.quote)) {
24456
24457
  this.promptTicketSelection();
24457
- this.host.scrollIntoView({
24458
- behavior: "smooth",
24459
- block: "start",
24460
- });
24458
+ this.scrollToTicketSelector();
24461
24459
  return;
24462
24460
  }
24463
24461
  this.initiateCheckout().catch(() => undefined);
24464
24462
  }
24463
+ scrollToTicketSelector() {
24464
+ const target = this.host.shadowRoot?.querySelector(".tickets-wrapper") ??
24465
+ this.host;
24466
+ window.scrollTo({
24467
+ behavior: "smooth",
24468
+ top: Math.max(target.getBoundingClientRect().top +
24469
+ window.scrollY -
24470
+ STICKY_CHECKOUT_SCROLL_OFFSET_PX, 0),
24471
+ });
24472
+ }
24465
24473
  getCartProducts() {
24466
24474
  if (!this.quote)
24467
24475
  return [];
@@ -24779,7 +24787,8 @@ const SessionsTicketing = /*@__PURE__*/ proxyCustomElement(class SessionsTicketi
24779
24787
  return null;
24780
24788
  if (!state.externalTicketUrl)
24781
24789
  return null;
24782
- return (h$2("div", { class: "sticky-checkout-bar" }, h$2("a", { class: "external-ticket-button sticky-checkout-btn", href: state.externalTicketUrl, target: "_blank", rel: "noreferrer" }, h$2("span", { class: "external-ticket-label" }, "Get tickets"))));
24790
+ const domain = urlDomain(state.externalTicketUrl);
24791
+ return (h$2("div", { class: "sticky-checkout-bar" }, h$2("a", { class: "external-ticket-button sticky-checkout-btn", href: state.externalTicketUrl, target: "_blank", rel: "noreferrer" }, h$2("span", { class: "external-ticket-label" }, "Get tickets"), h$2("span", { class: "external-ticket-domain" }, "via ", domain))));
24783
24792
  }
24784
24793
  renderModal() {
24785
24794
  if (!this.openModalAdmissionId)
@@ -23624,6 +23624,7 @@ const sessionServicesTicketingCss = () => `:host{--background:transparent;--fore
23624
23624
 
23625
23625
  const quoteTotal = (quote) => quote.price?.total ?? 0;
23626
23626
  const QUOTE_DEBOUNCE_MS = 150;
23627
+ const STICKY_CHECKOUT_SCROLL_OFFSET_PX = 100;
23627
23628
  function objectValue(value, key) {
23628
23629
  if (!value || typeof value !== "object")
23629
23630
  return undefined;
@@ -24450,14 +24451,21 @@ const SessionsTicketing = class {
24450
24451
  handleStickyCheckoutClick(state) {
24451
24452
  if (state.isDoorOnly || !hasQuoteItems(this.quote)) {
24452
24453
  this.promptTicketSelection();
24453
- this.host.scrollIntoView({
24454
- behavior: "smooth",
24455
- block: "start",
24456
- });
24454
+ this.scrollToTicketSelector();
24457
24455
  return;
24458
24456
  }
24459
24457
  this.initiateCheckout().catch(() => undefined);
24460
24458
  }
24459
+ scrollToTicketSelector() {
24460
+ const target = this.host.shadowRoot?.querySelector(".tickets-wrapper") ??
24461
+ this.host;
24462
+ window.scrollTo({
24463
+ behavior: "smooth",
24464
+ top: Math.max(target.getBoundingClientRect().top +
24465
+ window.scrollY -
24466
+ STICKY_CHECKOUT_SCROLL_OFFSET_PX, 0),
24467
+ });
24468
+ }
24461
24469
  getCartProducts() {
24462
24470
  if (!this.quote)
24463
24471
  return [];
@@ -24775,7 +24783,8 @@ const SessionsTicketing = class {
24775
24783
  return null;
24776
24784
  if (!state.externalTicketUrl)
24777
24785
  return null;
24778
- return (h$2("div", { class: "sticky-checkout-bar" }, h$2("a", { class: "external-ticket-button sticky-checkout-btn", href: state.externalTicketUrl, target: "_blank", rel: "noreferrer" }, h$2("span", { class: "external-ticket-label" }, "Get tickets"))));
24786
+ const domain = urlDomain(state.externalTicketUrl);
24787
+ return (h$2("div", { class: "sticky-checkout-bar" }, h$2("a", { class: "external-ticket-button sticky-checkout-btn", href: state.externalTicketUrl, target: "_blank", rel: "noreferrer" }, h$2("span", { class: "external-ticket-label" }, "Get tickets"), h$2("span", { class: "external-ticket-domain" }, "via ", domain))));
24779
24788
  }
24780
24789
  renderModal() {
24781
24790
  if (!this.openModalAdmissionId)