@ticketlayer/elements 0.3.3 → 1.0.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.
- package/README.md +3 -2
- package/dist/cjs/{index-BpfoKd9Q.js → index-DanPUX0s.js} +1 -1
- package/dist/cjs/index.cjs.js +2 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/ticket-selector-BYVL13k_.js +3623 -0
- package/dist/cjs/ticketlayer-elements.cjs.js +2 -2
- package/dist/cjs/tl-buy-modal.cjs.entry.js +4 -4
- package/dist/cjs/tl-buy-tickets-button.cjs.entry.js +89 -71
- package/dist/cjs/tl-buy-tickets-wrapper.cjs.entry.js +62 -31
- package/dist/cjs/tl-cart-badge.cjs.entry.js +75 -62
- package/dist/cjs/tl-cart-drawer.cjs.entry.js +52 -24
- package/dist/cjs/tl-cart.cjs.entry.js +72 -98
- package/dist/cjs/tl-checkout-wrapper.cjs.entry.js +52 -30
- package/dist/cjs/tl-event-card.cjs.entry.js +44 -105
- package/dist/cjs/tl-event-list.cjs.entry.js +73 -36
- package/dist/cjs/tl-login.cjs.entry.js +75 -141
- package/dist/cjs/tl-my-orders.cjs.entry.js +53 -92
- package/dist/cjs/tl-occurrence-selector_2.cjs.entry.js +205 -641
- package/dist/cjs/tl-order-confirmation.cjs.entry.js +72 -105
- package/dist/cjs/tl-order-tickets_2.cjs.entry.js +50 -76
- package/dist/cjs/tl-promo-code.cjs.entry.js +51 -47
- package/dist/cjs/tl-seat-map.cjs.entry.js +4 -4
- package/dist/cjs/web-query-Ce73jB4k.js +16 -0
- package/dist/collection/components/tl-buy-modal/tl-buy-modal.css +12 -19
- package/dist/collection/components/tl-buy-modal/tl-buy-modal.js +2 -2
- package/dist/collection/components/tl-buy-tickets-button/tl-buy-tickets-button.css +41 -4
- package/dist/collection/components/tl-buy-tickets-button/tl-buy-tickets-button.js +105 -76
- package/dist/collection/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.css +2 -2
- package/dist/collection/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.js +73 -30
- package/dist/collection/components/tl-cart/tl-cart.css +52 -51
- package/dist/collection/components/tl-cart/tl-cart.js +82 -101
- package/dist/collection/components/tl-cart-badge/tl-cart-badge.css +11 -11
- package/dist/collection/components/tl-cart-badge/tl-cart-badge.js +62 -62
- package/dist/collection/components/tl-cart-drawer/tl-cart-drawer.css +6 -6
- package/dist/collection/components/tl-cart-drawer/tl-cart-drawer.js +56 -24
- package/dist/collection/components/tl-checkout-wrapper/tl-checkout-wrapper.css +2 -2
- package/dist/collection/components/tl-checkout-wrapper/tl-checkout-wrapper.js +61 -29
- package/dist/collection/components/tl-event-card/event-card-adapter.js +11 -23
- package/dist/collection/components/tl-event-card/tl-event-card.css +22 -22
- package/dist/collection/components/tl-event-card/tl-event-card.js +51 -84
- package/dist/collection/components/tl-event-list/tl-event-list.css +17 -17
- package/dist/collection/components/tl-event-list/tl-event-list.js +82 -38
- package/dist/collection/components/tl-login/tl-login.css +26 -26
- package/dist/collection/components/tl-login/tl-login.js +83 -147
- package/dist/collection/components/tl-my-orders/tl-my-orders.css +40 -40
- package/dist/collection/components/tl-my-orders/tl-my-orders.js +58 -96
- package/dist/collection/components/tl-occurrence-selector/tl-occurrence-selector.css +54 -65
- package/dist/collection/components/tl-occurrence-selector/tl-occurrence-selector.js +137 -516
- package/dist/collection/components/tl-order-confirmation/tl-order-confirmation.css +38 -38
- package/dist/collection/components/tl-order-confirmation/tl-order-confirmation.js +81 -113
- package/dist/collection/components/tl-order-tickets/tl-order-tickets.css +9 -9
- package/dist/collection/components/tl-order-tickets/tl-order-tickets.js +57 -92
- package/dist/collection/components/tl-promo-code/tl-promo-code.css +25 -25
- package/dist/collection/components/tl-promo-code/tl-promo-code.js +55 -50
- package/dist/collection/components/tl-seat-map/tl-seat-map.css +10 -10
- package/dist/collection/components/tl-seat-map/tl-seat-map.js +2 -2
- package/dist/collection/components/tl-ticket/tl-ticket.css +13 -13
- package/dist/collection/components/tl-ticket-selector/tl-ticket-selector.css +74 -49
- package/dist/collection/components/tl-ticket-selector/tl-ticket-selector.js +95 -135
- package/dist/collection/utils/cart-totals.js +9 -0
- package/dist/collection/utils/order-summary.js +15 -99
- package/dist/collection/utils/testing/deep-text.js +29 -0
- package/dist/collection/utils/testing/fixtures.js +290 -0
- package/dist/collection/utils/testing/mock-sdk.js +13 -2
- package/dist/collection/utils/web-query.js +12 -0
- package/dist/collection/utils/web-storage.js +22 -0
- package/dist/components/ticket-selector.js +1 -0
- package/dist/components/tl-buy-modal.js +1 -1
- package/dist/components/tl-buy-tickets-button.js +1 -1
- package/dist/components/tl-buy-tickets-wrapper2.js +1 -1
- package/dist/components/tl-cart-badge.js +1 -1
- package/dist/components/tl-cart-drawer.js +1 -1
- package/dist/components/tl-cart2.js +1 -1
- package/dist/components/tl-checkout-wrapper2.js +1 -1
- package/dist/components/tl-event-card2.js +1 -1
- package/dist/components/tl-event-list.js +1 -1
- package/dist/components/tl-login2.js +1 -1
- package/dist/components/tl-my-orders.js +1 -1
- package/dist/components/tl-occurrence-selector2.js +1 -1
- package/dist/components/tl-order-confirmation.js +1 -1
- package/dist/components/tl-order-tickets2.js +1 -1
- package/dist/components/tl-promo-code.js +1 -1
- package/dist/components/tl-seat-map.js +1 -1
- package/dist/components/tl-ticket-selector2.js +1 -1
- package/dist/components/tl-ticket2.js +1 -1
- package/dist/components/web-query.js +1 -0
- package/dist/elements.docs.json +36 -36
- package/dist/esm/{index-CNX8hZa8.js → index-imfxp765.js} +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/ticket-selector-BwChnHVC.js +3606 -0
- package/dist/esm/ticketlayer-elements.js +3 -3
- package/dist/esm/tl-buy-modal.entry.js +4 -4
- package/dist/esm/tl-buy-tickets-button.entry.js +90 -72
- package/dist/esm/tl-buy-tickets-wrapper.entry.js +63 -32
- package/dist/esm/tl-cart-badge.entry.js +76 -63
- package/dist/esm/tl-cart-drawer.entry.js +53 -25
- package/dist/esm/tl-cart.entry.js +73 -99
- package/dist/esm/tl-checkout-wrapper.entry.js +53 -31
- package/dist/esm/tl-event-card.entry.js +45 -106
- package/dist/esm/tl-event-list.entry.js +74 -37
- package/dist/esm/tl-login.entry.js +76 -142
- package/dist/esm/tl-my-orders.entry.js +54 -93
- package/dist/esm/tl-occurrence-selector_2.entry.js +206 -642
- package/dist/esm/tl-order-confirmation.entry.js +73 -106
- package/dist/esm/tl-order-tickets_2.entry.js +51 -77
- package/dist/esm/tl-promo-code.entry.js +52 -48
- package/dist/esm/tl-seat-map.entry.js +4 -4
- package/dist/esm/web-query-Bdbb2lk5.js +14 -0
- package/dist/ticketlayer-elements/index.esm.js +1 -1
- package/dist/ticketlayer-elements/p-45923d2c.entry.js +1 -0
- package/dist/ticketlayer-elements/p-492adc77.entry.js +1 -0
- package/dist/ticketlayer-elements/p-4cfc9e53.entry.js +1 -0
- package/dist/ticketlayer-elements/p-5135630e.entry.js +1 -0
- package/dist/ticketlayer-elements/p-5bbce3b5.entry.js +1 -0
- package/dist/ticketlayer-elements/p-7d547721.entry.js +1 -0
- package/dist/ticketlayer-elements/p-7fe7b6ba.entry.js +1 -0
- package/dist/ticketlayer-elements/p-8122f0c1.entry.js +1 -0
- package/dist/ticketlayer-elements/p-98d40869.entry.js +1 -0
- package/dist/ticketlayer-elements/p-Bdbb2lk5.js +1 -0
- package/dist/ticketlayer-elements/p-BwChnHVC.js +1 -0
- package/dist/ticketlayer-elements/p-abec290a.entry.js +1 -0
- package/dist/ticketlayer-elements/p-ac79a3f6.entry.js +1 -0
- package/dist/ticketlayer-elements/p-d01f4429.entry.js +1 -0
- package/dist/ticketlayer-elements/p-d7ffaf46.entry.js +1 -0
- package/dist/ticketlayer-elements/p-e7170f3c.entry.js +1 -0
- package/dist/ticketlayer-elements/p-e787e862.entry.js +1 -0
- package/dist/ticketlayer-elements/p-f1ff931f.entry.js +1 -0
- package/dist/ticketlayer-elements/p-imfxp765.js +3 -0
- package/dist/ticketlayer-elements/ticketlayer-elements.css +1 -1
- package/dist/ticketlayer-elements/ticketlayer-elements.esm.js +1 -1
- package/dist/types/components/tl-buy-tickets-button/tl-buy-tickets-button.d.ts +40 -8
- package/dist/types/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.d.ts +20 -1
- package/dist/types/components/tl-cart/tl-cart.d.ts +40 -32
- package/dist/types/components/tl-cart-badge/tl-cart-badge.d.ts +22 -7
- package/dist/types/components/tl-cart-drawer/tl-cart-drawer.d.ts +28 -5
- package/dist/types/components/tl-checkout-wrapper/tl-checkout-wrapper.d.ts +18 -1
- package/dist/types/components/tl-event-card/event-card-adapter.d.ts +9 -20
- package/dist/types/components/tl-event-card/tl-event-card.d.ts +25 -28
- package/dist/types/components/tl-event-list/tl-event-list.d.ts +46 -6
- package/dist/types/components/tl-login/tl-login.d.ts +68 -22
- package/dist/types/components/tl-my-orders/tl-my-orders.d.ts +30 -12
- package/dist/types/components/tl-occurrence-selector/tl-occurrence-selector.d.ts +73 -161
- package/dist/types/components/tl-order-confirmation/tl-order-confirmation.d.ts +48 -15
- package/dist/types/components/tl-order-tickets/tl-order-tickets.d.ts +29 -31
- package/dist/types/components/tl-promo-code/tl-promo-code.d.ts +28 -10
- package/dist/types/components/tl-ticket/tl-ticket.d.ts +2 -11
- package/dist/types/components/tl-ticket-selector/tl-ticket-selector.d.ts +61 -32
- package/dist/types/components.d.ts +302 -62
- package/dist/types/utils/cart-totals.d.ts +10 -0
- package/dist/types/utils/order-summary.d.ts +16 -65
- package/dist/types/utils/testing/deep-text.d.ts +13 -0
- package/dist/types/utils/testing/fixtures.d.ts +225 -0
- package/dist/types/utils/testing/mock-sdk.d.ts +14 -1
- package/dist/types/utils/web-query.d.ts +18 -0
- package/dist/types/utils/web-storage.d.ts +16 -0
- package/elements.catalogue.json +676 -55
- package/package.json +14 -6
- package/dist/cjs/order-summary-ZMkJ5bez.js +0 -116
- package/dist/components/order-summary.js +0 -1
- package/dist/esm/order-summary-BGekdjN9.js +0 -103
- package/dist/ticketlayer-elements/p-0b1d16f8.entry.js +0 -1
- package/dist/ticketlayer-elements/p-1471f6d8.entry.js +0 -1
- package/dist/ticketlayer-elements/p-1c51cbc1.entry.js +0 -1
- package/dist/ticketlayer-elements/p-5169f68b.entry.js +0 -1
- package/dist/ticketlayer-elements/p-895ba1f3.entry.js +0 -1
- package/dist/ticketlayer-elements/p-8d5722e1.entry.js +0 -1
- package/dist/ticketlayer-elements/p-917d8e09.entry.js +0 -1
- package/dist/ticketlayer-elements/p-9629029a.entry.js +0 -1
- package/dist/ticketlayer-elements/p-BGekdjN9.js +0 -1
- package/dist/ticketlayer-elements/p-CNX8hZa8.js +0 -3
- package/dist/ticketlayer-elements/p-a22714d0.entry.js +0 -1
- package/dist/ticketlayer-elements/p-bf73044b.entry.js +0 -1
- package/dist/ticketlayer-elements/p-e02079fa.entry.js +0 -1
- package/dist/ticketlayer-elements/p-e04ace15.entry.js +0 -1
- package/dist/ticketlayer-elements/p-e6fab1d5.entry.js +0 -1
- package/dist/ticketlayer-elements/p-f826b753.entry.js +0 -1
- package/dist/ticketlayer-elements/p-fa639d88.entry.js +0 -1
- package/dist/ticketlayer-elements/p-fbaca948.entry.js +0 -1
|
@@ -1,133 +1,72 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h } from './index-
|
|
2
|
-
import { w as whenSDK } from './sdk-connector-CqhvfyKV.js';
|
|
3
|
-
import {
|
|
1
|
+
import { r as registerInstance, c as createEvent, h } from './index-imfxp765.js';
|
|
2
|
+
import { w as whenSDK, g as getSDK } from './sdk-connector-CqhvfyKV.js';
|
|
3
|
+
import { c as createElement, f as eventCardCore } from './ticket-selector-BwChnHVC.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
function toEventCardEvent(detail) {
|
|
7
|
-
const occurrences = detail.occurrences ?? [];
|
|
8
|
-
const starts = occurrences
|
|
9
|
-
.map((o) => o.startsAt)
|
|
10
|
-
.filter((s) => !!s)
|
|
11
|
-
.sort();
|
|
12
|
-
const now = Date.now();
|
|
13
|
-
const next = starts.find((s) => new Date(s).getTime() >= now) ?? starts[0];
|
|
14
|
-
const soldOut = detail.status === 'sold_out' ||
|
|
15
|
-
(occurrences.length > 0 && occurrences.every((o) => o.status === 'sold_out'));
|
|
16
|
-
return {
|
|
17
|
-
id: detail.id,
|
|
18
|
-
name: detail.name,
|
|
19
|
-
...(detail.shortDescription ? { shortDescription: detail.shortDescription } : {}),
|
|
20
|
-
...(detail.imageUrl ? { imageUrl: detail.imageUrl } : {}),
|
|
21
|
-
...(detail.venueName
|
|
22
|
-
? { venue: { id: detail.venueId ?? '', name: detail.venueName, city: detail.venueCity ?? '' } }
|
|
23
|
-
: {}),
|
|
24
|
-
...(next ? { nextOccurrence: { startsAt: next } } : {}),
|
|
25
|
-
availabilityStatus: soldOut ? 'sold_out' : 'available',
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const tlEventCardCss = () => `:host{display:block;font-family:var(--tl-font-family, system-ui, sans-serif)}.event-card{background:var(--tl-secondary, #f3f4f6);border-radius:var(--tl-radius-lg, 0.75rem);overflow:hidden;box-shadow:0 1px 3px rgba(0, 0, 0, 0.1);cursor:pointer;transition:box-shadow 0.2s ease, transform 0.2s ease}.event-card:hover{box-shadow:0 4px 12px rgba(0, 0, 0, 0.15);transform:translateY(-2px)}.image-container{position:relative;aspect-ratio:16 / 9;overflow:hidden;background:var(--tl-muted, #f9fafb)}.event-image{width:100%;height:100%;object-fit:cover;transition:transform 0.3s ease}.event-card:hover .event-image{transform:scale(1.05)}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:var(--tl-muted-foreground, #6b7280)}.status-container{position:absolute;top:0.5rem;right:0.5rem}.status-badge{display:inline-block;padding:0.25rem 0.5rem;font-size:0.75rem;font-weight:500;border-radius:var(--tl-radius-sm, 0.25rem)}.status-available{background:var(--tl-success, #10b981);color:var(--tl-success-foreground, #ffffff)}.status-limited{background:var(--tl-warning, #f59e0b);color:var(--tl-warning-foreground, #ffffff)}.status-sold-out{background:var(--tl-error, #ef4444);color:var(--tl-error-foreground, #ffffff)}.content{padding:var(--tl-spacing-4, 1rem)}.category{display:inline-block;font-size:0.75rem;font-weight:500;text-transform:uppercase;letter-spacing:0.05em;color:var(--tl-primary, #6366f1)}.title{margin:0.25rem 0 0;font-size:1.125rem;font-weight:600;color:var(--tl-foreground, #111827);line-height:1.3}.event-card:hover .title{color:var(--tl-primary, #6366f1)}.meta{display:flex;align-items:center;gap:0.5rem;margin:0.5rem 0 0;font-size:0.875rem;color:var(--tl-muted-foreground, #6b7280)}.meta:first-of-type{margin-top:0.75rem}.icon{width:1rem;height:1rem;flex-shrink:0}.description{margin:0.75rem 0 0;font-size:0.875rem;color:var(--tl-muted-foreground, #6b7280);line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.card-skeleton{cursor:default;pointer-events:none}.card-skeleton .image-container{animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite}.skeleton-line{height:0.875rem;margin-top:0.5rem;background:var(--tl-muted, #f9fafb);border-radius:var(--tl-radius-sm, 0.25rem);animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite}.skeleton-line.short{width:40%}.skeleton-line.long{width:80%}.card-error{padding:var(--tl-spacing-4, 1rem);font-size:0.875rem;color:var(--tl-error, #ef4444);cursor:default}.card-error:hover{transform:none}@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.5}}`;
|
|
5
|
+
const tlEventCardCss = () => `:host{display:block;font-family:var(--tl-font-family)}.event-card{background:var(--tl-secondary);border-radius:var(--tl-radius-lg);overflow:hidden;box-shadow:0 1px 3px rgba(0, 0, 0, 0.1);cursor:pointer;transition:box-shadow 0.2s ease, transform 0.2s ease}.event-card:hover{box-shadow:0 4px 12px rgba(0, 0, 0, 0.15);transform:translateY(-2px)}.image-container{position:relative;aspect-ratio:16 / 9;overflow:hidden;background:var(--tl-muted)}.event-image{width:100%;height:100%;object-fit:cover;transition:transform 0.3s ease}.event-card:hover .event-image{transform:scale(1.05)}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:var(--tl-muted-foreground)}.status-container{position:absolute;top:0.5rem;right:0.5rem}.status-badge{display:inline-block;padding:0.25rem 0.5rem;font-size:0.75rem;font-weight:500;border-radius:var(--tl-radius-sm)}.status-available{background:var(--tl-success);color:var(--tl-success-foreground)}.status-limited{background:var(--tl-warning);color:var(--tl-warning-foreground)}.status-sold-out{background:var(--tl-error);color:var(--tl-error-foreground)}.content{padding:var(--tl-spacing-4)}.category{display:inline-block;font-size:0.75rem;font-weight:500;text-transform:uppercase;letter-spacing:0.05em;color:var(--tl-primary)}.title{margin:0.25rem 0 0;font-size:1.125rem;font-weight:600;color:var(--tl-foreground);line-height:1.3}.event-card:hover .title{color:var(--tl-primary)}.meta{display:flex;align-items:center;gap:0.5rem;margin:0.5rem 0 0;font-size:0.875rem;color:var(--tl-muted-foreground)}.meta:first-of-type{margin-top:0.75rem}.icon{width:1rem;height:1rem;flex-shrink:0}.description{margin:0.75rem 0 0;font-size:0.875rem;color:var(--tl-muted-foreground);line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.card-skeleton{cursor:default;pointer-events:none}.card-skeleton .image-container{animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite}.skeleton-line{height:0.875rem;margin-top:0.5rem;background:var(--tl-muted);border-radius:var(--tl-radius-sm);animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite}.skeleton-line.short{width:40%}.skeleton-line.long{width:80%}.card-error{padding:var(--tl-spacing-4);font-size:0.875rem;color:var(--tl-error);cursor:default}.card-error:hover{transform:none}@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.5}}`;
|
|
30
6
|
|
|
31
7
|
const TlEventCard = class {
|
|
32
8
|
constructor(hostRef) {
|
|
33
9
|
registerInstance(this, hostRef);
|
|
34
10
|
this.tlClick = createEvent(this, "tlClick");
|
|
35
11
|
this.tlError = createEvent(this, "tlError");
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
12
|
+
this.element = createElement(eventCardCore, {
|
|
13
|
+
client: () => getSDK(),
|
|
14
|
+
clientReady: () => whenSDK(),
|
|
15
|
+
emit: (event, detail) => this.forward(event, detail),
|
|
16
|
+
});
|
|
17
|
+
/** The core's whole view. Assigning it is what makes Stencil re-render. */
|
|
18
|
+
this.view = this.element.view;
|
|
39
19
|
this.handleClick = () => {
|
|
40
|
-
|
|
41
|
-
if (!event)
|
|
42
|
-
return;
|
|
43
|
-
console.log('[tl-event-card] Clicked:', event.id);
|
|
44
|
-
this.tlClick.emit({ eventId: event.id });
|
|
20
|
+
this.element.actions.click();
|
|
45
21
|
};
|
|
46
22
|
}
|
|
47
|
-
|
|
48
|
-
this.
|
|
23
|
+
syncProps() {
|
|
24
|
+
this.element.setProps({ event: this.event, eventId: this.eventId });
|
|
49
25
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
async loadEvent() {
|
|
56
|
-
if (this.event || !this.eventId)
|
|
57
|
-
return;
|
|
58
|
-
try {
|
|
59
|
-
this.loading = true;
|
|
60
|
-
this.error = null;
|
|
61
|
-
const sdk = await whenSDK();
|
|
62
|
-
const detail = (await sdk.getEventsManager().get(this.eventId));
|
|
63
|
-
if (!detail)
|
|
64
|
-
throw new Error('Event not found');
|
|
65
|
-
this.loadedEvent = toEventCardEvent(detail);
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
console.error('[tl-event-card] Failed to load event:', err);
|
|
69
|
-
this.error = errorMessage(err, 'Failed to load event');
|
|
70
|
-
this.tlError.emit({ message: this.error });
|
|
71
|
-
}
|
|
72
|
-
finally {
|
|
73
|
-
this.loading = false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
get current() {
|
|
77
|
-
return this.event ?? this.loadedEvent;
|
|
26
|
+
/** A new id is a new subject: tear the old mount down and start again. */
|
|
27
|
+
watchEventId() {
|
|
28
|
+
this.syncProps();
|
|
29
|
+
this.teardown?.();
|
|
30
|
+
this.teardown = this.element.mount();
|
|
78
31
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
minute: '2-digit',
|
|
87
|
-
});
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
this.syncProps();
|
|
34
|
+
this.unsubscribe ?? (this.unsubscribe = this.element.subscribe((view) => {
|
|
35
|
+
this.view = view;
|
|
36
|
+
}));
|
|
37
|
+
this.view = this.element.view;
|
|
38
|
+
this.teardown = this.element.mount();
|
|
88
39
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
case 'limited':
|
|
95
|
-
return `${baseClass} status-limited`;
|
|
96
|
-
case 'sold_out':
|
|
97
|
-
return `${baseClass} status-sold-out`;
|
|
98
|
-
default:
|
|
99
|
-
return baseClass;
|
|
100
|
-
}
|
|
40
|
+
disconnectedCallback() {
|
|
41
|
+
this.teardown?.();
|
|
42
|
+
this.teardown = undefined;
|
|
43
|
+
this.unsubscribe?.();
|
|
44
|
+
this.unsubscribe = undefined;
|
|
101
45
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return 'Limited';
|
|
108
|
-
case 'sold_out':
|
|
109
|
-
return 'Sold Out';
|
|
110
|
-
default:
|
|
111
|
-
return '';
|
|
112
|
-
}
|
|
46
|
+
forward(event, detail) {
|
|
47
|
+
if (event === 'tlClick')
|
|
48
|
+
this.tlClick.emit(detail);
|
|
49
|
+
else if (event === 'tlError')
|
|
50
|
+
this.tlError.emit(detail);
|
|
113
51
|
}
|
|
114
52
|
render() {
|
|
115
|
-
|
|
53
|
+
const { status, state, derived } = this.view;
|
|
54
|
+
if (status === 'loading') {
|
|
116
55
|
return (h("div", { class: "event-card card-skeleton", "aria-busy": "true" }, h("div", { class: "image-container" }), h("div", { class: "content" }, h("div", { class: "skeleton-line short" }), h("div", { class: "skeleton-line long" }))));
|
|
117
56
|
}
|
|
118
|
-
if (
|
|
119
|
-
return h("div", { class: "event-card card-error" },
|
|
57
|
+
if (status === 'error') {
|
|
58
|
+
return h("div", { class: "event-card card-error" }, state.error);
|
|
120
59
|
}
|
|
121
|
-
const event =
|
|
60
|
+
const event = derived.event;
|
|
122
61
|
if (!event) {
|
|
123
62
|
return null;
|
|
124
63
|
}
|
|
125
|
-
|
|
126
|
-
// `thumbnailUrl` is an accepted alias if a host ever supplies a distinct one.
|
|
127
|
-
const image = event.thumbnailUrl || event.imageUrl;
|
|
128
|
-
return (h("div", { class: "event-card", onClick: this.handleClick }, h("div", { class: "image-container" }, image ? (h("img", { src: image, alt: event.name, class: "event-image" })) : (h("div", { class: "image-placeholder" }, h("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "1.5", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" })))), h("div", { class: "status-container" }, h("span", { class: this.getStatusBadgeClass() }, this.getStatusLabel()))), h("div", { class: "content" }, event.category && h("span", { class: "category" }, event.category), h("h3", { class: "title" }, event.name), event.nextOccurrence && (h("p", { class: "meta" }, h("svg", { class: "icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" })), this.formatDate(event.nextOccurrence.startsAt))), event.venue && (h("p", { class: "meta" }, h("svg", { class: "icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" }), h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M15 11a3 3 0 11-6 0 3 3 0 016 0z" })), event.venue.name, ", ", event.venue.city)), event.shortDescription && (h("p", { class: "description" }, event.shortDescription)))));
|
|
64
|
+
return (h("div", { class: "event-card", onClick: this.handleClick }, h("div", { class: "image-container" }, derived.image ? (h("img", { src: derived.image, alt: event.name, class: "event-image" })) : (h("div", { class: "image-placeholder" }, h("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "1.5", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" })))), h("div", { class: "status-container" }, h("span", { class: derived.statusBadgeClass }, derived.statusLabel))), h("div", { class: "content" }, event.category && h("span", { class: "category" }, event.category), h("h3", { class: "title" }, event.name), derived.dateLabel && (h("p", { class: "meta" }, h("svg", { class: "icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" })), derived.dateLabel)), derived.venueLabel && (h("p", { class: "meta" }, h("svg", { class: "icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" }), h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M15 11a3 3 0 11-6 0 3 3 0 016 0z" })), derived.venueLabel)), event.shortDescription && h("p", { class: "description" }, event.shortDescription))));
|
|
129
65
|
}
|
|
130
66
|
static get watchers() { return {
|
|
67
|
+
"event": [{
|
|
68
|
+
"syncProps": 0
|
|
69
|
+
}],
|
|
131
70
|
"eventId": [{
|
|
132
71
|
"watchEventId": 0
|
|
133
72
|
}]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h } from './index-
|
|
2
|
-
import { w as whenSDK } from './sdk-connector-CqhvfyKV.js';
|
|
1
|
+
import { r as registerInstance, c as createEvent, h } from './index-imfxp765.js';
|
|
2
|
+
import { w as whenSDK, g as getSDK } from './sdk-connector-CqhvfyKV.js';
|
|
3
|
+
import { c as createElement, e as eventListCore } from './ticket-selector-BwChnHVC.js';
|
|
3
4
|
|
|
4
|
-
const tlEventListCss = () => `:host{display:block;font-family:var(--tl-font-family
|
|
5
|
+
const tlEventListCss = () => `:host{display:block;font-family:var(--tl-font-family)}.event-grid{display:grid;gap:var(--tl-spacing-6)}.cols-1{grid-template-columns:1fr}.cols-2{grid-template-columns:repeat(2, 1fr)}.cols-3{grid-template-columns:repeat(3, 1fr)}.cols-4{grid-template-columns:repeat(4, 1fr)}@media (max-width: 1024px){.cols-4,.cols-3{grid-template-columns:repeat(2, 1fr)}}@media (max-width: 640px){.cols-4,.cols-3,.cols-2{grid-template-columns:1fr}}.skeleton-card{background:var(--tl-secondary);border-radius:var(--tl-radius-lg);overflow:hidden}.skeleton-image{aspect-ratio:16 / 9;background:var(--tl-muted);animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite}.skeleton-content{padding:var(--tl-spacing-4);display:flex;flex-direction:column;gap:0.5rem}.skeleton-line{height:1rem;background:var(--tl-muted);border-radius:var(--tl-radius-sm);animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite}.skeleton-line.short{width:4rem;height:0.75rem}.skeleton-line.medium{width:75%}.skeleton-line.long{width:50%}@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.5}}.error-state{background:rgba(239, 68, 68, 0.1);border:1px solid var(--tl-error);border-radius:var(--tl-radius-lg);padding:var(--tl-spacing-4)}.error-title{margin:0;font-weight:500;color:var(--tl-error)}.error-message{margin:0.25rem 0 0;font-size:0.875rem;color:var(--tl-error)}.empty-state{text-align:center;padding:var(--tl-spacing-8) var(--tl-spacing-4)}.empty-icon{width:4rem;height:4rem;margin:0 auto 1rem;color:var(--tl-muted-foreground)}.empty-title{margin:0;font-size:1.25rem;font-weight:600;color:var(--tl-foreground)}.empty-message{margin:0.5rem 0 0;color:var(--tl-muted-foreground)}`;
|
|
5
6
|
|
|
6
7
|
const TlEventList = class {
|
|
7
8
|
constructor(hostRef) {
|
|
@@ -15,54 +16,87 @@ const TlEventList = class {
|
|
|
15
16
|
* Columns for grid layout (1, 2, 3, or 4)
|
|
16
17
|
*/
|
|
17
18
|
this.columns = 3;
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
this.element = createElement(eventListCore, {
|
|
20
|
+
client: () => getSDK(),
|
|
21
|
+
clientReady: () => whenSDK(),
|
|
22
|
+
emit: (event, detail) => this.forward(event, detail),
|
|
23
|
+
});
|
|
24
|
+
/** The core's whole view. Assigning it is what makes Stencil re-render. */
|
|
25
|
+
this.view = this.element.view;
|
|
26
|
+
/** A card was clicked. The core has nothing to decide about it; pass it on. */
|
|
21
27
|
this.handleEventClick = (event) => {
|
|
22
|
-
console.log('[tl-event-list] Event clicked:', event.detail.eventId);
|
|
23
28
|
this.tlEventClick.emit(event.detail);
|
|
24
29
|
};
|
|
25
30
|
}
|
|
31
|
+
/** A different question deserves a fresh answer. */
|
|
26
32
|
watchFiltersChange() {
|
|
27
|
-
this.
|
|
33
|
+
this.syncProps();
|
|
34
|
+
this.element.actions.load();
|
|
28
35
|
}
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
syncProps() {
|
|
37
|
+
this.element.setProps({ limit: this.limit, category: this.category, columns: this.columns });
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
connectedCallback() {
|
|
40
|
+
this.syncProps();
|
|
41
|
+
this.unsubscribe ?? (this.unsubscribe = this.element.subscribe((view) => {
|
|
42
|
+
this.view = view;
|
|
43
|
+
}));
|
|
44
|
+
this.view = this.element.view;
|
|
45
|
+
this.teardown = this.element.mount();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Nothing is painted until the first listing has landed.
|
|
49
|
+
*
|
|
50
|
+
* Kept as found rather than improved, and it is the harness's to keep: the
|
|
51
|
+
* component awaited its read in `componentWillLoad`, and Stencil does not
|
|
52
|
+
* paint a component until that resolves, so a slow channel shows an empty
|
|
53
|
+
* box where the skeleton markup below would fit. Held by the spec.
|
|
54
|
+
*
|
|
55
|
+
* Expressed against the core's own status rather than against a read this
|
|
56
|
+
* harness starts, because the read is the core's (`connectedCallback` has
|
|
57
|
+
* already mounted it). Every later read draws the skeleton, exactly as
|
|
58
|
+
* before.
|
|
59
|
+
*/
|
|
60
|
+
componentWillLoad() {
|
|
61
|
+
if (this.view.status !== 'loading')
|
|
62
|
+
return undefined;
|
|
63
|
+
return new Promise((resolve) => {
|
|
64
|
+
const off = this.element.subscribe((view) => {
|
|
65
|
+
if (view.status === 'loading')
|
|
66
|
+
return;
|
|
67
|
+
off();
|
|
68
|
+
resolve();
|
|
42
69
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Off screen: run the mount's teardown, and nothing more. `destroy()` is
|
|
74
|
+
* terminal and Stencil calls this for a move as well as a removal, so
|
|
75
|
+
* destroying here would leave a re-inserted element frozen.
|
|
76
|
+
*/
|
|
77
|
+
disconnectedCallback() {
|
|
78
|
+
this.teardown?.();
|
|
79
|
+
this.teardown = undefined;
|
|
80
|
+
this.unsubscribe?.();
|
|
81
|
+
this.unsubscribe = undefined;
|
|
82
|
+
}
|
|
83
|
+
forward(event, detail) {
|
|
84
|
+
if (event === 'tlEventClick')
|
|
85
|
+
this.tlEventClick.emit(detail);
|
|
53
86
|
}
|
|
54
87
|
render() {
|
|
55
|
-
const
|
|
56
|
-
|
|
88
|
+
const { status, state, strings, derived } = this.view;
|
|
89
|
+
const gridClass = `event-grid cols-${derived.columns}`;
|
|
90
|
+
if (status === 'loading') {
|
|
57
91
|
return (h("div", { class: gridClass }, Array.from({ length: 6 }).map((_, i) => (h("div", { class: "skeleton-card", key: i }, h("div", { class: "skeleton-image" }), h("div", { class: "skeleton-content" }, h("div", { class: "skeleton-line short" }), h("div", { class: "skeleton-line medium" }), h("div", { class: "skeleton-line long" })))))));
|
|
58
92
|
}
|
|
59
|
-
if (
|
|
60
|
-
return (h("div", { class: "error-state" }, h("p", { class: "error-title" },
|
|
93
|
+
if (status === 'error') {
|
|
94
|
+
return (h("div", { class: "error-state" }, h("p", { class: "error-title" }, strings.errorTitle), h("p", { class: "error-message" }, state.error)));
|
|
61
95
|
}
|
|
62
|
-
if (
|
|
63
|
-
return (h("div", { class: "empty-state" }, h("svg", { class: "empty-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "1.5", d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" })), h("p", { class: "empty-title" },
|
|
96
|
+
if (status === 'empty') {
|
|
97
|
+
return (h("div", { class: "empty-state" }, h("svg", { class: "empty-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "1.5", d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" })), h("p", { class: "empty-title" }, strings.emptyTitle), h("p", { class: "empty-message" }, strings.emptyMessage)));
|
|
64
98
|
}
|
|
65
|
-
return (h("div", { class: gridClass },
|
|
99
|
+
return (h("div", { class: gridClass }, derived.events.map((event) => (h("tl-event-card", { key: event.id, event: event, onTlClick: this.handleEventClick })))));
|
|
66
100
|
}
|
|
67
101
|
static get watchers() { return {
|
|
68
102
|
"limit": [{
|
|
@@ -70,6 +104,9 @@ const TlEventList = class {
|
|
|
70
104
|
}],
|
|
71
105
|
"category": [{
|
|
72
106
|
"watchFiltersChange": 0
|
|
107
|
+
}],
|
|
108
|
+
"columns": [{
|
|
109
|
+
"syncProps": 0
|
|
73
110
|
}]
|
|
74
111
|
}; }
|
|
75
112
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h } from './index-
|
|
2
|
-
import { w as whenSDK } from './sdk-connector-CqhvfyKV.js';
|
|
3
|
-
import {
|
|
1
|
+
import { r as registerInstance, c as createEvent, h } from './index-imfxp765.js';
|
|
2
|
+
import { w as whenSDK, g as getSDK } from './sdk-connector-CqhvfyKV.js';
|
|
3
|
+
import { w as webQuery } from './web-query-Bdbb2lk5.js';
|
|
4
|
+
import { c as createElement, l as loginCore } from './ticket-selector-BwChnHVC.js';
|
|
4
5
|
|
|
5
|
-
const tlLoginCss = () => `:host{display:block;font-family:var(--tl-font-family
|
|
6
|
+
const tlLoginCss = () => `:host{display:block;font-family:var(--tl-font-family);color:var(--tl-foreground)}.login{display:flex;flex-direction:column;gap:var(--tl-spacing-3);padding:var(--tl-spacing-6);background:var(--tl-background);border:1px solid var(--tl-border);border-radius:var(--tl-radius-lg)}.title{margin:0;font-size:1.25rem;font-weight:600}.lead{margin:0;font-size:0.875rem;color:var(--tl-muted-foreground)}.label{font-size:0.875rem;font-weight:500}.input{padding:var(--tl-spacing-3);font:inherit;font-size:0.9375rem;color:var(--tl-foreground);background:var(--tl-background);border:1px solid var(--tl-border);border-radius:var(--tl-radius-md)}.input:focus{outline:2px solid var(--tl-primary);outline-offset:1px}.code-input{font-family:var(--tl-font-family-mono);font-size:1.25rem;letter-spacing:0.25em;text-align:center}.primary,.secondary{padding:var(--tl-spacing-3) var(--tl-spacing-4);font:inherit;font-size:0.9375rem;font-weight:600;border-radius:var(--tl-radius-md);cursor:pointer}.primary{color:var(--tl-primary-foreground);background:var(--tl-primary);border:none}.primary:hover:not(:disabled){opacity:0.9}.secondary{color:var(--tl-foreground);background:var(--tl-secondary);border:1px solid var(--tl-border)}.primary:disabled,.secondary:disabled,.input:disabled{opacity:0.6;cursor:not-allowed}.link{padding:0;font:inherit;font-size:0.875rem;color:var(--tl-primary);background:none;border:none;cursor:pointer}.link:hover{text-decoration:underline}.actions{display:flex;flex-wrap:wrap;align-items:center;gap:var(--tl-spacing-4)}.error{margin:0;font-size:0.8125rem;color:var(--tl-error)}.notice{margin:0;font-size:0.8125rem;color:var(--tl-success)}.signed-in{flex-direction:row;align-items:center;justify-content:space-between;flex-wrap:wrap}.signed-in-text{margin:0;font-size:0.875rem;overflow-wrap:anywhere}`;
|
|
6
7
|
|
|
7
8
|
const TlLogin = class {
|
|
8
9
|
constructor(hostRef) {
|
|
@@ -14,168 +15,101 @@ const TlLogin = class {
|
|
|
14
15
|
this.heading = 'Sign in';
|
|
15
16
|
/** Offer a "enter the code" path alongside the emailed link (default true). */
|
|
16
17
|
this.allowCodeEntry = true;
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.
|
|
25
|
-
this.unsubscribes = [];
|
|
26
|
-
// A magic-link code is single-use; never exchange the URL code twice.
|
|
27
|
-
this.urlCodeUsed = false;
|
|
18
|
+
this.element = createElement(loginCore, {
|
|
19
|
+
client: () => getSDK(),
|
|
20
|
+
clientReady: () => whenSDK(),
|
|
21
|
+
query: webQuery,
|
|
22
|
+
emit: (event, detail) => this.forward(event, detail),
|
|
23
|
+
});
|
|
24
|
+
/** The core's whole view. Assigning it is what makes Stencil re-render. */
|
|
25
|
+
this.view = this.element.view;
|
|
28
26
|
this.handleEmailInput = (e) => {
|
|
29
|
-
this.
|
|
30
|
-
this.error = null;
|
|
27
|
+
this.element.actions.setEmail(e.target.value);
|
|
31
28
|
};
|
|
32
29
|
this.handleCodeInput = (e) => {
|
|
33
|
-
this.
|
|
34
|
-
this.error = null;
|
|
30
|
+
this.element.actions.setCode(e.target.value);
|
|
35
31
|
};
|
|
36
32
|
this.handleEmailSubmit = (e) => {
|
|
37
33
|
e.preventDefault();
|
|
38
|
-
this.requestLink();
|
|
34
|
+
this.element.actions.requestLink();
|
|
39
35
|
};
|
|
40
36
|
this.handleCodeSubmit = (e) => {
|
|
41
37
|
e.preventDefault();
|
|
42
|
-
this.
|
|
38
|
+
this.element.actions.submitCode();
|
|
43
39
|
};
|
|
44
40
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (!sdk) {
|
|
48
|
-
this.error = 'Sign-in is not available right now';
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
this.auth = sdk.getAuthManager?.() ?? null;
|
|
52
|
-
if (!this.auth) {
|
|
53
|
-
this.error = 'Sign-in is not available with this SDK';
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
this.syncFromSDK();
|
|
57
|
-
// The session hydrates after the SDK publishes; follow both signals.
|
|
58
|
-
this.unsubscribes.push(sdk.on('auth:changed', () => this.syncFromSDK()));
|
|
59
|
-
this.unsubscribes.push(sdk.on('session:changed', () => this.syncFromSDK()));
|
|
60
|
-
const urlCode = this.codeFromUrl();
|
|
61
|
-
if (urlCode && !this.auth.authenticated) {
|
|
62
|
-
await this.exchange(urlCode);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
disconnectedCallback() {
|
|
66
|
-
this.unsubscribes.forEach((off) => off());
|
|
67
|
-
this.unsubscribes = [];
|
|
41
|
+
syncProps() {
|
|
42
|
+
this.element.setProps({ heading: this.heading, allowCodeEntry: this.allowCodeEntry });
|
|
68
43
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
44
|
+
connectedCallback() {
|
|
45
|
+
this.syncProps();
|
|
46
|
+
this.unsubscribe ?? (this.unsubscribe = this.element.subscribe((view) => {
|
|
47
|
+
this.view = view;
|
|
48
|
+
}));
|
|
49
|
+
this.view = this.element.view;
|
|
50
|
+
this.teardown = this.element.mount();
|
|
76
51
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const email = this.email.trim();
|
|
91
|
-
if (!email) {
|
|
92
|
-
this.error = 'Enter your email address';
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (!this.auth)
|
|
96
|
-
return;
|
|
97
|
-
this.busy = true;
|
|
98
|
-
this.error = null;
|
|
99
|
-
this.notice = null;
|
|
100
|
-
try {
|
|
101
|
-
// Always reports success; account existence is never revealed.
|
|
102
|
-
await this.auth.requestMagicLink({ email });
|
|
103
|
-
this.phase = 'sent';
|
|
104
|
-
this.notice = resend ? 'Sent again. Check your inbox.' : null;
|
|
105
|
-
this.tlMagicLinkSent.emit({ email });
|
|
106
|
-
}
|
|
107
|
-
catch (err) {
|
|
108
|
-
console.error('[tl-login] Magic-link request failed:', err);
|
|
109
|
-
this.error = errorMessage(err, 'Could not send your sign-in link');
|
|
110
|
-
this.tlError.emit({ message: this.error });
|
|
111
|
-
}
|
|
112
|
-
finally {
|
|
113
|
-
this.busy = false;
|
|
114
|
-
}
|
|
52
|
+
/**
|
|
53
|
+
* Nothing is painted until this page's client is up.
|
|
54
|
+
*
|
|
55
|
+
* A rendering decision, and the harness's to make: Stencil waits on this
|
|
56
|
+
* promise before the first render, and without it the form would flash
|
|
57
|
+
* disabled for a microtask on every page. The core is already at work by
|
|
58
|
+
* now - `connectedCallback` mounted it - so this waits on the same
|
|
59
|
+
* `whenSDK()` it is waiting on rather than deciding anything of its own, and
|
|
60
|
+
* a page that never starts Live renders the core's "not available" state
|
|
61
|
+
* instead of hanging.
|
|
62
|
+
*/
|
|
63
|
+
componentWillLoad() {
|
|
64
|
+
return whenSDK().catch(() => undefined);
|
|
115
65
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.
|
|
125
|
-
this.
|
|
126
|
-
this.phase = 'verifying';
|
|
127
|
-
try {
|
|
128
|
-
const res = (await this.auth.exchange(code));
|
|
129
|
-
this.customer = this.auth.customer ?? res?.customer ?? null;
|
|
130
|
-
this.phase = 'signed-in';
|
|
131
|
-
this.code = '';
|
|
132
|
-
this.tlAuthChanged.emit({ customer: this.customer, authenticated: true });
|
|
133
|
-
}
|
|
134
|
-
catch (err) {
|
|
135
|
-
console.error('[tl-login] Code exchange failed:', err);
|
|
136
|
-
this.phase = previous === 'verifying' || previous === 'email' ? 'email' : 'code';
|
|
137
|
-
this.error = 'That code did not work. Check it and try again, or request a new link.';
|
|
138
|
-
this.tlError.emit({ message: this.error });
|
|
139
|
-
}
|
|
140
|
-
finally {
|
|
141
|
-
this.busy = false;
|
|
142
|
-
}
|
|
66
|
+
/**
|
|
67
|
+
* Off screen: run the mount's teardown, which drops both auth
|
|
68
|
+
* subscriptions. Not `destroy()`: Stencil calls this for a DOM move as well
|
|
69
|
+
* as a removal, and a destroyed core never mounts again.
|
|
70
|
+
*/
|
|
71
|
+
disconnectedCallback() {
|
|
72
|
+
this.teardown?.();
|
|
73
|
+
this.teardown = undefined;
|
|
74
|
+
this.unsubscribe?.();
|
|
75
|
+
this.unsubscribe = undefined;
|
|
143
76
|
}
|
|
144
|
-
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
catch (err) {
|
|
152
|
-
console.error('[tl-login] Sign out failed:', err);
|
|
153
|
-
}
|
|
154
|
-
finally {
|
|
155
|
-
this.busy = false;
|
|
156
|
-
this.customer = null;
|
|
157
|
-
this.phase = 'email';
|
|
158
|
-
this.tlAuthChanged.emit({ customer: null, authenticated: false });
|
|
159
|
-
}
|
|
77
|
+
forward(event, detail) {
|
|
78
|
+
if (event === 'tlAuthChanged')
|
|
79
|
+
this.tlAuthChanged.emit(detail);
|
|
80
|
+
else if (event === 'tlMagicLinkSent')
|
|
81
|
+
this.tlMagicLinkSent.emit(detail);
|
|
82
|
+
else if (event === 'tlError')
|
|
83
|
+
this.tlError.emit(detail);
|
|
160
84
|
}
|
|
161
85
|
renderError() {
|
|
162
|
-
|
|
86
|
+
const error = this.view.state.error;
|
|
87
|
+
return error ? (h("p", { class: "error", role: "alert" }, error)) : null;
|
|
163
88
|
}
|
|
164
89
|
render() {
|
|
165
|
-
|
|
166
|
-
|
|
90
|
+
const { status, state, strings, derived } = this.view;
|
|
91
|
+
if (status === 'signed-in') {
|
|
92
|
+
return (h("div", { class: "login signed-in" }, h("p", { class: "signed-in-text" }, strings.signedInPrefix, h("strong", null, derived.signedInEmail)), h("button", { type: "button", class: "secondary", disabled: state.busy, onClick: () => this.element.actions.signOut() }, strings.signOut)));
|
|
167
93
|
}
|
|
168
|
-
if (
|
|
169
|
-
return (h("div", { class: "login" }, h("h2", { class: "title" },
|
|
94
|
+
if (status === 'verifying') {
|
|
95
|
+
return (h("div", { class: "login" }, h("h2", { class: "title" }, strings.verifyingTitle), h("p", { class: "lead" }, strings.verifyingLead)));
|
|
170
96
|
}
|
|
171
|
-
if (
|
|
172
|
-
return (h("div", { class: "login" }, h("h2", { class: "title" },
|
|
97
|
+
if (status === 'sent') {
|
|
98
|
+
return (h("div", { class: "login" }, h("h2", { class: "title" }, strings.sentTitle), h("p", { class: "lead" }, strings.sentLeadBefore, h("strong", null, state.email), strings.sentLeadAfter), state.notice && h("p", { class: "notice" }, state.notice), this.renderError(), h("div", { class: "actions" }, h("button", { type: "button", class: "secondary", disabled: state.busy, onClick: () => this.element.actions.requestLink(true) }, derived.resendLabel), derived.showCodeEntry && (h("button", { type: "button", class: "link", onClick: () => this.element.actions.goTo('code') }, strings.enterCodeInstead)), h("button", { type: "button", class: "link", onClick: () => this.element.actions.goTo('email') }, strings.differentEmail))));
|
|
173
99
|
}
|
|
174
|
-
if (
|
|
175
|
-
return (h("form", { class: "login", onSubmit: this.handleCodeSubmit }, h("h2", { class: "title" },
|
|
100
|
+
if (status === 'code') {
|
|
101
|
+
return (h("form", { class: "login", onSubmit: this.handleCodeSubmit }, h("h2", { class: "title" }, strings.codeTitle), h("p", { class: "lead" }, strings.codeLeadBefore, h("strong", null, state.email), strings.codeLeadAfter), h("label", { class: "label", htmlFor: "tl-login-code" }, strings.codeLabel), h("input", { id: "tl-login-code", class: "input code-input", type: "text", inputmode: "numeric", autocomplete: "one-time-code", placeholder: strings.codePlaceholder, value: state.code, disabled: state.busy, onInput: this.handleCodeInput }), this.renderError(), h("button", { type: "submit", class: "primary", disabled: state.busy }, derived.codeSubmitLabel), h("div", { class: "actions" }, h("button", { type: "button", class: "link", onClick: () => this.element.actions.requestLink(true) }, strings.resendLink), h("button", { type: "button", class: "link", onClick: () => this.element.actions.goTo('sent') }, strings.back))));
|
|
176
102
|
}
|
|
177
|
-
return (h("form", { class: "login", onSubmit: this.handleEmailSubmit }, h("h2", { class: "title" }, this.heading), h("p", { class: "lead" },
|
|
103
|
+
return (h("form", { class: "login", onSubmit: this.handleEmailSubmit }, h("h2", { class: "title" }, this.heading), h("p", { class: "lead" }, strings.emailLead), h("label", { class: "label", htmlFor: "tl-login-email" }, strings.emailLabel), h("input", { id: "tl-login-email", class: "input", type: "email", autocomplete: "email", placeholder: strings.emailPlaceholder, required: true, value: state.email, disabled: derived.inputsDisabled, onInput: this.handleEmailInput }), this.renderError(), h("button", { type: "submit", class: "primary", disabled: derived.inputsDisabled }, derived.emailSubmitLabel)));
|
|
178
104
|
}
|
|
105
|
+
static get watchers() { return {
|
|
106
|
+
"heading": [{
|
|
107
|
+
"syncProps": 0
|
|
108
|
+
}],
|
|
109
|
+
"allowCodeEntry": [{
|
|
110
|
+
"syncProps": 0
|
|
111
|
+
}]
|
|
112
|
+
}; }
|
|
179
113
|
};
|
|
180
114
|
TlLogin.style = tlLoginCss();
|
|
181
115
|
|