@ticketlayer/elements 0.2.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/LICENSE +21 -0
- package/README.md +55 -0
- package/dist/cjs/index-DfzcrE9-.js +3598 -0
- package/dist/cjs/index.cjs.js +16 -0
- package/dist/cjs/loader.cjs.js +12 -0
- package/dist/cjs/order-summary-ZMkJ5bez.js +116 -0
- package/dist/cjs/sdk-connector-ClDF3013.js +108 -0
- package/dist/cjs/ticketlayer-elements.cjs.js +24 -0
- package/dist/cjs/tl-buy-modal.cjs.entry.js +127 -0
- package/dist/cjs/tl-buy-tickets-button.cjs.entry.js +131 -0
- package/dist/cjs/tl-buy-tickets-wrapper.cjs.entry.js +58 -0
- package/dist/cjs/tl-cart-badge.cjs.entry.js +109 -0
- package/dist/cjs/tl-cart-drawer.cjs.entry.js +67 -0
- package/dist/cjs/tl-cart.cjs.entry.js +148 -0
- package/dist/cjs/tl-checkout-wrapper.cjs.entry.js +57 -0
- package/dist/cjs/tl-event-card.cjs.entry.js +140 -0
- package/dist/cjs/tl-event-list.cjs.entry.js +80 -0
- package/dist/cjs/tl-login.cjs.entry.js +184 -0
- package/dist/cjs/tl-my-orders.cjs.entry.js +123 -0
- package/dist/cjs/tl-occurrence-selector_2.cjs.entry.js +754 -0
- package/dist/cjs/tl-order-confirmation.cjs.entry.js +146 -0
- package/dist/cjs/tl-order-tickets_2.cjs.entry.js +3198 -0
- package/dist/cjs/tl-promo-code.cjs.entry.js +75 -0
- package/dist/cjs/tl-seat-map.cjs.entry.js +147 -0
- package/dist/collection/collection-manifest.json +29 -0
- package/dist/collection/components/tl-buy-modal/tl-buy-modal.css +264 -0
- package/dist/collection/components/tl-buy-modal/tl-buy-modal.js +249 -0
- package/dist/collection/components/tl-buy-tickets-button/tl-buy-tickets-button.css +120 -0
- package/dist/collection/components/tl-buy-tickets-button/tl-buy-tickets-button.js +412 -0
- package/dist/collection/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.css +23 -0
- package/dist/collection/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.js +192 -0
- package/dist/collection/components/tl-cart/tl-cart.css +251 -0
- package/dist/collection/components/tl-cart/tl-cart.js +314 -0
- package/dist/collection/components/tl-cart-badge/tl-cart-badge.css +138 -0
- package/dist/collection/components/tl-cart-badge/tl-cart-badge.js +217 -0
- package/dist/collection/components/tl-cart-drawer/tl-cart-drawer.css +98 -0
- package/dist/collection/components/tl-cart-drawer/tl-cart-drawer.js +185 -0
- package/dist/collection/components/tl-checkout-wrapper/tl-checkout-wrapper.css +23 -0
- package/dist/collection/components/tl-checkout-wrapper/tl-checkout-wrapper.js +148 -0
- package/dist/collection/components/tl-event-card/event-card-adapter.js +23 -0
- package/dist/collection/components/tl-event-card/tl-event-card.css +175 -0
- package/dist/collection/components/tl-event-card/tl-event-card.js +205 -0
- package/dist/collection/components/tl-event-list/tl-event-list.css +134 -0
- package/dist/collection/components/tl-event-list/tl-event-list.js +171 -0
- package/dist/collection/components/tl-login/tl-login.css +133 -0
- package/dist/collection/components/tl-login/tl-login.js +309 -0
- package/dist/collection/components/tl-my-orders/tl-my-orders.css +204 -0
- package/dist/collection/components/tl-my-orders/tl-my-orders.js +221 -0
- package/dist/collection/components/tl-occurrence-selector/tl-occurrence-selector.css +658 -0
- package/dist/collection/components/tl-occurrence-selector/tl-occurrence-selector.js +707 -0
- package/dist/collection/components/tl-order-confirmation/tl-order-confirmation.css +176 -0
- package/dist/collection/components/tl-order-confirmation/tl-order-confirmation.js +298 -0
- package/dist/collection/components/tl-order-tickets/tl-order-tickets.css +30 -0
- package/dist/collection/components/tl-order-tickets/tl-order-tickets.js +122 -0
- package/dist/collection/components/tl-promo-code/tl-promo-code.css +106 -0
- package/dist/collection/components/tl-promo-code/tl-promo-code.js +181 -0
- package/dist/collection/components/tl-seat-map/tl-seat-map.css +85 -0
- package/dist/collection/components/tl-seat-map/tl-seat-map.js +366 -0
- package/dist/collection/components/tl-ticket/tl-ticket.css +90 -0
- package/dist/collection/components/tl-ticket/tl-ticket.js +129 -0
- package/dist/collection/components/tl-ticket-selector/tl-ticket-selector.css +205 -0
- package/dist/collection/components/tl-ticket-selector/tl-ticket-selector.js +332 -0
- package/dist/collection/index.js +10 -0
- package/dist/collection/utils/order-summary.js +101 -0
- package/dist/collection/utils/sdk-connector.js +100 -0
- package/dist/collection/utils/testing/mock-sdk.js +95 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/order-summary.js +1 -0
- package/dist/components/sdk-connector.js +1 -0
- package/dist/components/tl-buy-modal.d.ts +11 -0
- package/dist/components/tl-buy-modal.js +1 -0
- package/dist/components/tl-buy-tickets-button.d.ts +11 -0
- package/dist/components/tl-buy-tickets-button.js +1 -0
- package/dist/components/tl-buy-tickets-wrapper.d.ts +11 -0
- package/dist/components/tl-buy-tickets-wrapper.js +1 -0
- package/dist/components/tl-buy-tickets-wrapper2.js +1 -0
- package/dist/components/tl-cart-badge.d.ts +11 -0
- package/dist/components/tl-cart-badge.js +1 -0
- package/dist/components/tl-cart-drawer.d.ts +11 -0
- package/dist/components/tl-cart-drawer.js +1 -0
- package/dist/components/tl-cart.d.ts +11 -0
- package/dist/components/tl-cart.js +1 -0
- package/dist/components/tl-cart2.js +1 -0
- package/dist/components/tl-checkout-wrapper.d.ts +11 -0
- package/dist/components/tl-checkout-wrapper.js +1 -0
- package/dist/components/tl-checkout-wrapper2.js +1 -0
- package/dist/components/tl-event-card.d.ts +11 -0
- package/dist/components/tl-event-card.js +1 -0
- package/dist/components/tl-event-card2.js +1 -0
- package/dist/components/tl-event-list.d.ts +11 -0
- package/dist/components/tl-event-list.js +1 -0
- package/dist/components/tl-login.d.ts +11 -0
- package/dist/components/tl-login.js +1 -0
- package/dist/components/tl-login2.js +1 -0
- package/dist/components/tl-my-orders.d.ts +11 -0
- package/dist/components/tl-my-orders.js +1 -0
- package/dist/components/tl-occurrence-selector.d.ts +11 -0
- package/dist/components/tl-occurrence-selector.js +1 -0
- package/dist/components/tl-occurrence-selector2.js +1 -0
- package/dist/components/tl-order-confirmation.d.ts +11 -0
- package/dist/components/tl-order-confirmation.js +1 -0
- package/dist/components/tl-order-tickets.d.ts +11 -0
- package/dist/components/tl-order-tickets.js +1 -0
- package/dist/components/tl-order-tickets2.js +1 -0
- package/dist/components/tl-promo-code.d.ts +11 -0
- package/dist/components/tl-promo-code.js +1 -0
- package/dist/components/tl-seat-map.d.ts +11 -0
- package/dist/components/tl-seat-map.js +1 -0
- package/dist/components/tl-ticket-selector.d.ts +11 -0
- package/dist/components/tl-ticket-selector.js +1 -0
- package/dist/components/tl-ticket-selector2.js +1 -0
- package/dist/components/tl-ticket.d.ts +11 -0
- package/dist/components/tl-ticket.js +1 -0
- package/dist/components/tl-ticket2.js +1 -0
- package/dist/elements.docs.d.ts +454 -0
- package/dist/elements.docs.json +3008 -0
- package/dist/esm/index-Ba-RZTFI.js +3588 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/loader.js +10 -0
- package/dist/esm/order-summary-BGekdjN9.js +103 -0
- package/dist/esm/sdk-connector-CqhvfyKV.js +102 -0
- package/dist/esm/ticketlayer-elements.js +20 -0
- package/dist/esm/tl-buy-modal.entry.js +125 -0
- package/dist/esm/tl-buy-tickets-button.entry.js +129 -0
- package/dist/esm/tl-buy-tickets-wrapper.entry.js +56 -0
- package/dist/esm/tl-cart-badge.entry.js +107 -0
- package/dist/esm/tl-cart-drawer.entry.js +65 -0
- package/dist/esm/tl-cart.entry.js +146 -0
- package/dist/esm/tl-checkout-wrapper.entry.js +55 -0
- package/dist/esm/tl-event-card.entry.js +138 -0
- package/dist/esm/tl-event-list.entry.js +78 -0
- package/dist/esm/tl-login.entry.js +182 -0
- package/dist/esm/tl-my-orders.entry.js +121 -0
- package/dist/esm/tl-occurrence-selector_2.entry.js +751 -0
- package/dist/esm/tl-order-confirmation.entry.js +144 -0
- package/dist/esm/tl-order-tickets_2.entry.js +3195 -0
- package/dist/esm/tl-promo-code.entry.js +73 -0
- package/dist/esm/tl-seat-map.entry.js +145 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/ticketlayer-elements/index.esm.js +1 -0
- package/dist/ticketlayer-elements/p-0291df4c.entry.js +1 -0
- package/dist/ticketlayer-elements/p-10f01a1f.entry.js +1 -0
- package/dist/ticketlayer-elements/p-11273f8f.entry.js +1 -0
- package/dist/ticketlayer-elements/p-340ab4f5.entry.js +1 -0
- package/dist/ticketlayer-elements/p-41d22d7c.entry.js +1 -0
- package/dist/ticketlayer-elements/p-82752e3b.entry.js +1 -0
- package/dist/ticketlayer-elements/p-976770f3.entry.js +1 -0
- package/dist/ticketlayer-elements/p-9a903ff6.entry.js +1 -0
- package/dist/ticketlayer-elements/p-9c9072c8.entry.js +1 -0
- package/dist/ticketlayer-elements/p-9d8163d6.entry.js +1 -0
- package/dist/ticketlayer-elements/p-BGekdjN9.js +1 -0
- package/dist/ticketlayer-elements/p-Ba-RZTFI.js +2 -0
- package/dist/ticketlayer-elements/p-CqhvfyKV.js +1 -0
- package/dist/ticketlayer-elements/p-a5c90b68.entry.js +1 -0
- package/dist/ticketlayer-elements/p-b6d479ad.entry.js +1 -0
- package/dist/ticketlayer-elements/p-dd43f015.entry.js +1 -0
- package/dist/ticketlayer-elements/p-eb640760.entry.js +1 -0
- package/dist/ticketlayer-elements/p-ee3aa227.entry.js +1 -0
- package/dist/ticketlayer-elements/p-fb9444c4.entry.js +1 -0
- package/dist/ticketlayer-elements/ticketlayer-elements.css +1 -0
- package/dist/ticketlayer-elements/ticketlayer-elements.esm.js +1 -0
- package/dist/types/components/tl-buy-modal/tl-buy-modal.d.ts +54 -0
- package/dist/types/components/tl-buy-tickets-button/tl-buy-tickets-button.d.ts +61 -0
- package/dist/types/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.d.ts +52 -0
- package/dist/types/components/tl-cart/tl-cart.d.ts +80 -0
- package/dist/types/components/tl-cart-badge/tl-cart-badge.d.ts +36 -0
- package/dist/types/components/tl-cart-drawer/tl-cart-drawer.d.ts +35 -0
- package/dist/types/components/tl-checkout-wrapper/tl-checkout-wrapper.d.ts +39 -0
- package/dist/types/components/tl-event-card/event-card-adapter.d.ts +23 -0
- package/dist/types/components/tl-event-card/tl-event-card.d.ts +55 -0
- package/dist/types/components/tl-event-list/tl-event-list.d.ts +30 -0
- package/dist/types/components/tl-login/tl-login.d.ts +59 -0
- package/dist/types/components/tl-my-orders/tl-my-orders.d.ts +39 -0
- package/dist/types/components/tl-occurrence-selector/tl-occurrence-selector.d.ts +208 -0
- package/dist/types/components/tl-order-confirmation/tl-order-confirmation.d.ts +54 -0
- package/dist/types/components/tl-order-tickets/tl-order-tickets.d.ts +21 -0
- package/dist/types/components/tl-promo-code/tl-promo-code.d.ts +39 -0
- package/dist/types/components/tl-seat-map/tl-seat-map.d.ts +68 -0
- package/dist/types/components/tl-ticket/tl-ticket.d.ts +28 -0
- package/dist/types/components/tl-ticket-selector/tl-ticket-selector.d.ts +78 -0
- package/dist/types/components.d.ts +1629 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/stencil-public-runtime.d.ts +1839 -0
- package/dist/types/utils/order-summary.d.ts +67 -0
- package/dist/types/utils/sdk-connector.d.ts +113 -0
- package/dist/types/utils/testing/mock-sdk.d.ts +36 -0
- package/elements.catalogue.json +968 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +101 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, h } from './index-Ba-RZTFI.js';
|
|
2
|
+
import { w as whenSDK } from './sdk-connector-CqhvfyKV.js';
|
|
3
|
+
import { e as errorMessage } from './order-summary-BGekdjN9.js';
|
|
4
|
+
|
|
5
|
+
const tlLoginCss = () => `:host{display:block;font-family:var(--tl-font-family, system-ui, sans-serif);color:var(--tl-foreground, #111827)}.login{display:flex;flex-direction:column;gap:var(--tl-spacing-3, 0.75rem);padding:var(--tl-spacing-6, 1.5rem);background:var(--tl-background, #ffffff);border:1px solid var(--tl-border, #e5e7eb);border-radius:var(--tl-radius-lg, 0.75rem)}.title{margin:0;font-size:1.25rem;font-weight:600}.lead{margin:0;font-size:0.875rem;color:var(--tl-muted-foreground, #6b7280)}.label{font-size:0.875rem;font-weight:500}.input{padding:var(--tl-spacing-3, 0.75rem);font:inherit;font-size:0.9375rem;color:var(--tl-foreground, #111827);background:var(--tl-background, #ffffff);border:1px solid var(--tl-border, #e5e7eb);border-radius:var(--tl-radius-md, 0.5rem)}.input:focus{outline:2px solid var(--tl-primary, #6366f1);outline-offset:1px}.code-input{font-family:var(--tl-font-family-mono, ui-monospace, monospace);font-size:1.25rem;letter-spacing:0.25em;text-align:center}.primary,.secondary{padding:var(--tl-spacing-3, 0.75rem) var(--tl-spacing-4, 1rem);font:inherit;font-size:0.9375rem;font-weight:600;border-radius:var(--tl-radius-md, 0.5rem);cursor:pointer}.primary{color:var(--tl-primary-foreground, #ffffff);background:var(--tl-primary, #6366f1);border:none}.primary:hover:not(:disabled){opacity:0.9}.secondary{color:var(--tl-foreground, #111827);background:var(--tl-secondary, #f3f4f6);border:1px solid var(--tl-border, #e5e7eb)}.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, #6366f1);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, 1rem)}.error{margin:0;font-size:0.8125rem;color:var(--tl-error, #ef4444)}.notice{margin:0;font-size:0.8125rem;color:var(--tl-success, #10b981)}.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
|
+
const TlLogin = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
registerInstance(this, hostRef);
|
|
10
|
+
this.tlAuthChanged = createEvent(this, "tlAuthChanged");
|
|
11
|
+
this.tlMagicLinkSent = createEvent(this, "tlMagicLinkSent");
|
|
12
|
+
this.tlError = createEvent(this, "tlError");
|
|
13
|
+
/** Heading for the email step. */
|
|
14
|
+
this.heading = 'Sign in';
|
|
15
|
+
/** Offer a "enter the code" path alongside the emailed link (default true). */
|
|
16
|
+
this.allowCodeEntry = true;
|
|
17
|
+
this.phase = 'email';
|
|
18
|
+
this.email = '';
|
|
19
|
+
this.code = '';
|
|
20
|
+
this.busy = false;
|
|
21
|
+
this.error = null;
|
|
22
|
+
this.notice = null;
|
|
23
|
+
this.customer = null;
|
|
24
|
+
this.auth = null;
|
|
25
|
+
this.unsubscribes = [];
|
|
26
|
+
// A magic-link code is single-use; never exchange the URL code twice.
|
|
27
|
+
this.urlCodeUsed = false;
|
|
28
|
+
this.handleEmailInput = (e) => {
|
|
29
|
+
this.email = e.target.value;
|
|
30
|
+
this.error = null;
|
|
31
|
+
};
|
|
32
|
+
this.handleCodeInput = (e) => {
|
|
33
|
+
this.code = e.target.value;
|
|
34
|
+
this.error = null;
|
|
35
|
+
};
|
|
36
|
+
this.handleEmailSubmit = (e) => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
this.requestLink();
|
|
39
|
+
};
|
|
40
|
+
this.handleCodeSubmit = (e) => {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
this.exchange(this.code.trim());
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async componentWillLoad() {
|
|
46
|
+
const sdk = await whenSDK().catch(() => null);
|
|
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 = [];
|
|
68
|
+
}
|
|
69
|
+
codeFromUrl() {
|
|
70
|
+
if (typeof window === 'undefined' || !window.location?.search || this.urlCodeUsed)
|
|
71
|
+
return null;
|
|
72
|
+
const code = new URLSearchParams(window.location.search).get('code');
|
|
73
|
+
if (code)
|
|
74
|
+
this.urlCodeUsed = true;
|
|
75
|
+
return code;
|
|
76
|
+
}
|
|
77
|
+
syncFromSDK() {
|
|
78
|
+
if (!this.auth)
|
|
79
|
+
return;
|
|
80
|
+
if (this.auth.authenticated) {
|
|
81
|
+
this.customer = this.auth.customer ?? null;
|
|
82
|
+
this.phase = 'signed-in';
|
|
83
|
+
}
|
|
84
|
+
else if (this.phase === 'signed-in') {
|
|
85
|
+
this.customer = null;
|
|
86
|
+
this.phase = 'email';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async requestLink(resend = false) {
|
|
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
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async exchange(code) {
|
|
117
|
+
if (!code) {
|
|
118
|
+
this.error = 'Enter the code from your email';
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!this.auth)
|
|
122
|
+
return;
|
|
123
|
+
const previous = this.phase;
|
|
124
|
+
this.busy = true;
|
|
125
|
+
this.error = null;
|
|
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
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async signOut() {
|
|
145
|
+
if (!this.auth)
|
|
146
|
+
return;
|
|
147
|
+
this.busy = true;
|
|
148
|
+
try {
|
|
149
|
+
await this.auth.logout();
|
|
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
|
+
}
|
|
160
|
+
}
|
|
161
|
+
renderError() {
|
|
162
|
+
return this.error ? (h("p", { class: "error", role: "alert" }, this.error)) : null;
|
|
163
|
+
}
|
|
164
|
+
render() {
|
|
165
|
+
if (this.phase === 'signed-in') {
|
|
166
|
+
return (h("div", { class: "login signed-in" }, h("p", { class: "signed-in-text" }, "Signed in as ", h("strong", null, this.customer?.email ?? 'your account')), h("button", { type: "button", class: "secondary", disabled: this.busy, onClick: () => this.signOut() }, "Sign out")));
|
|
167
|
+
}
|
|
168
|
+
if (this.phase === 'verifying') {
|
|
169
|
+
return (h("div", { class: "login" }, h("h2", { class: "title" }, "Signing you in\u2026"), h("p", { class: "lead" }, "Just a moment.")));
|
|
170
|
+
}
|
|
171
|
+
if (this.phase === 'sent') {
|
|
172
|
+
return (h("div", { class: "login" }, h("h2", { class: "title" }, "Check your inbox"), h("p", { class: "lead" }, "We've sent a sign-in link to ", h("strong", null, this.email), ". Open it on this device to continue."), this.notice && h("p", { class: "notice" }, this.notice), this.renderError(), h("div", { class: "actions" }, h("button", { type: "button", class: "secondary", disabled: this.busy, onClick: () => this.requestLink(true) }, this.busy ? 'Sending…' : 'Resend link'), this.allowCodeEntry && (h("button", { type: "button", class: "link", onClick: () => (this.phase = 'code') }, "Enter the code instead")), h("button", { type: "button", class: "link", onClick: () => (this.phase = 'email') }, "Use a different email"))));
|
|
173
|
+
}
|
|
174
|
+
if (this.phase === 'code') {
|
|
175
|
+
return (h("form", { class: "login", onSubmit: this.handleCodeSubmit }, h("h2", { class: "title" }, "Enter your code"), h("p", { class: "lead" }, "Type the 6-digit code from the email we sent to ", h("strong", null, this.email), "."), h("label", { class: "label", htmlFor: "tl-login-code" }, "Code"), h("input", { id: "tl-login-code", class: "input code-input", type: "text", inputmode: "numeric", autocomplete: "one-time-code", placeholder: "123456", value: this.code, disabled: this.busy, onInput: this.handleCodeInput }), this.renderError(), h("button", { type: "submit", class: "primary", disabled: this.busy }, this.busy ? 'Checking…' : 'Sign in'), h("div", { class: "actions" }, h("button", { type: "button", class: "link", onClick: () => this.requestLink(true) }, "Resend link"), h("button", { type: "button", class: "link", onClick: () => (this.phase = 'sent') }, "Back"))));
|
|
176
|
+
}
|
|
177
|
+
return (h("form", { class: "login", onSubmit: this.handleEmailSubmit }, h("h2", { class: "title" }, this.heading), h("p", { class: "lead" }, "Enter your email and we'll send you a secure sign-in link. No password needed."), h("label", { class: "label", htmlFor: "tl-login-email" }, "Email address"), h("input", { id: "tl-login-email", class: "input", type: "email", autocomplete: "email", placeholder: "you@example.com", required: true, value: this.email, disabled: this.busy || !this.auth, onInput: this.handleEmailInput }), this.renderError(), h("button", { type: "submit", class: "primary", disabled: this.busy || !this.auth }, this.busy ? 'Sending link…' : 'Email me a sign-in link')));
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
TlLogin.style = tlLoginCss();
|
|
181
|
+
|
|
182
|
+
export { TlLogin as tl_login };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, h } from './index-Ba-RZTFI.js';
|
|
2
|
+
import { w as whenSDK } from './sdk-connector-CqhvfyKV.js';
|
|
3
|
+
import { i as isAuthError, e as errorMessage, t as ticketCount, o as orderEventName, f as formatDate, a as formatPrice, s as statusTone, b as statusLabel } from './order-summary-BGekdjN9.js';
|
|
4
|
+
|
|
5
|
+
const tlMyOrdersCss = () => `:host{display:block;font-family:var(--tl-font-family, system-ui, sans-serif);color:var(--tl-foreground, #111827)}.orders{display:flex;flex-direction:column;gap:var(--tl-spacing-4, 1rem)}.order-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:var(--tl-spacing-3, 0.75rem)}.order{background:var(--tl-background, #ffffff);border:1px solid var(--tl-border, #e5e7eb);border-radius:var(--tl-radius-lg, 0.75rem);overflow:hidden;transition:border-color 0.2s ease, box-shadow 0.2s ease}.order:hover,.order.expanded{border-color:var(--tl-primary, #6366f1);box-shadow:0 1px 3px rgba(0, 0, 0, 0.08)}.order-row{display:flex;align-items:center;justify-content:space-between;gap:var(--tl-spacing-4, 1rem);width:100%;padding:var(--tl-spacing-4, 1rem);font:inherit;color:inherit;text-align:left;background:none;border:none;cursor:pointer}.order-main{display:flex;flex-direction:column;gap:var(--tl-spacing-1, 0.25rem);min-width:0}.order-number{font-size:0.75rem;font-weight:500;text-transform:uppercase;letter-spacing:0.05em;color:var(--tl-muted-foreground, #6b7280)}.order-event{font-size:1rem;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.order-meta{display:flex;flex-wrap:wrap;gap:var(--tl-spacing-3, 0.75rem);font-size:0.8125rem;color:var(--tl-muted-foreground, #6b7280)}.order-side{display:flex;align-items:center;gap:var(--tl-spacing-3, 0.75rem);flex-shrink:0}.order-total{font-weight:600}.status{padding:0.125rem 0.5rem;font-size:0.75rem;font-weight:500;border-radius:9999px;background:var(--tl-secondary, #f3f4f6);color:var(--tl-secondary-foreground, #111827)}.status-success{background:var(--tl-success, #10b981);color:var(--tl-success-foreground, #ffffff)}.status-info{background:var(--tl-primary, #6366f1);color:var(--tl-primary-foreground, #ffffff)}.status-warning{background:var(--tl-warning, #f59e0b);color:var(--tl-warning-foreground, #ffffff)}.status-error{background:var(--tl-error, #ef4444);color:var(--tl-error-foreground, #ffffff)}.chevron{width:1.125rem;height:1.125rem;color:var(--tl-muted-foreground, #6b7280);transition:transform 0.2s ease}.expanded .chevron{transform:rotate(90deg)}.order-tickets{padding:0 var(--tl-spacing-4, 1rem) var(--tl-spacing-4, 1rem);border-top:1px solid var(--tl-border, #e5e7eb);padding-top:var(--tl-spacing-4, 1rem)}@media (max-width: 480px){.order-row{flex-direction:column;align-items:stretch}.order-side{justify-content:space-between}}.signin{text-align:center}.signin-title,.state-title{margin:0;font-size:1.125rem;font-weight:600}.signin-text,.state-text{margin:var(--tl-spacing-1, 0.25rem) 0 0;font-size:0.875rem;color:var(--tl-muted-foreground, #6b7280)}.state{padding:var(--tl-spacing-8, 2rem) var(--tl-spacing-4, 1rem);text-align:center;background:var(--tl-background, #ffffff);border:1px solid var(--tl-border, #e5e7eb);border-radius:var(--tl-radius-lg, 0.75rem)}.state.error .state-title{color:var(--tl-error, #ef4444)}.empty-icon{width:3rem;height:3rem;margin:0 auto var(--tl-spacing-3, 0.75rem);color:var(--tl-primary, #6366f1)}.skeleton{height:5rem;background:var(--tl-secondary, #f3f4f6);border-radius:var(--tl-radius-lg, 0.75rem);animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite}@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.5}}`;
|
|
6
|
+
|
|
7
|
+
const TlMyOrders = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
registerInstance(this, hostRef);
|
|
10
|
+
this.tlOrderSelect = createEvent(this, "tlOrderSelect");
|
|
11
|
+
this.tlError = createEvent(this, "tlError");
|
|
12
|
+
/** Copy for the empty state. */
|
|
13
|
+
this.emptyMessage = "When you buy tickets they'll show up here, ready to view and download.";
|
|
14
|
+
/** Columns for the expanded ticket grid. */
|
|
15
|
+
this.columns = 2;
|
|
16
|
+
this.orders = [];
|
|
17
|
+
this.authenticated = false;
|
|
18
|
+
this.loading = true;
|
|
19
|
+
this.error = null;
|
|
20
|
+
this.expandedId = null;
|
|
21
|
+
this.sdk = null;
|
|
22
|
+
this.unsubscribes = [];
|
|
23
|
+
}
|
|
24
|
+
async componentWillLoad() {
|
|
25
|
+
this.sdk = await whenSDK().catch(() => null);
|
|
26
|
+
if (!this.sdk) {
|
|
27
|
+
this.loading = false;
|
|
28
|
+
this.error = 'Orders are not available right now';
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Older SDKs have no auth accessor: try the list and let a 401 decide.
|
|
32
|
+
const auth = this.sdk.getAuthManager?.();
|
|
33
|
+
this.authenticated = auth ? auth.authenticated : true;
|
|
34
|
+
// The session hydrates after the SDK publishes; follow both signals.
|
|
35
|
+
this.unsubscribes.push(this.sdk.on('auth:changed', () => this.syncAuth()));
|
|
36
|
+
this.unsubscribes.push(this.sdk.on('session:changed', () => this.syncAuth()));
|
|
37
|
+
if (this.authenticated) {
|
|
38
|
+
await this.load();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.loading = false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
disconnectedCallback() {
|
|
45
|
+
this.unsubscribes.forEach((off) => off());
|
|
46
|
+
this.unsubscribes = [];
|
|
47
|
+
}
|
|
48
|
+
syncAuth() {
|
|
49
|
+
const auth = this.sdk?.getAuthManager?.();
|
|
50
|
+
if (!auth)
|
|
51
|
+
return;
|
|
52
|
+
const was = this.authenticated;
|
|
53
|
+
this.authenticated = auth.authenticated;
|
|
54
|
+
if (this.authenticated && !was) {
|
|
55
|
+
this.load();
|
|
56
|
+
}
|
|
57
|
+
else if (!this.authenticated && was) {
|
|
58
|
+
this.orders = [];
|
|
59
|
+
this.expandedId = null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async load() {
|
|
63
|
+
if (!this.sdk)
|
|
64
|
+
return;
|
|
65
|
+
try {
|
|
66
|
+
this.loading = true;
|
|
67
|
+
this.error = null;
|
|
68
|
+
const orders = this.sdk.getOrdersManager?.();
|
|
69
|
+
if (!orders)
|
|
70
|
+
throw new Error('Orders are not available');
|
|
71
|
+
const list = (await orders.mine());
|
|
72
|
+
this.orders = list ?? [];
|
|
73
|
+
this.authenticated = true;
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
if (isAuthError(err)) {
|
|
77
|
+
// Not signed in: fall through to the inline login rather than an error.
|
|
78
|
+
this.authenticated = false;
|
|
79
|
+
this.orders = [];
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.error('[tl-my-orders] Failed to load orders:', err);
|
|
83
|
+
this.error = errorMessage(err, 'Failed to load your orders');
|
|
84
|
+
this.tlError.emit({ message: this.error });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
this.loading = false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
toggle(orderId) {
|
|
92
|
+
const opening = this.expandedId !== orderId;
|
|
93
|
+
this.expandedId = opening ? orderId : null;
|
|
94
|
+
if (opening)
|
|
95
|
+
this.tlOrderSelect.emit({ orderId });
|
|
96
|
+
}
|
|
97
|
+
renderRow(order) {
|
|
98
|
+
const expanded = this.expandedId === order.id;
|
|
99
|
+
const count = ticketCount(order);
|
|
100
|
+
const tone = statusTone(order.status);
|
|
101
|
+
return (h("li", { class: { order: true, expanded }, key: order.id }, h("button", { type: "button", class: "order-row", "aria-expanded": expanded ? 'true' : 'false', onClick: () => this.toggle(order.id) }, h("span", { class: "order-main" }, h("span", { class: "order-number" }, "Order ", order.orderNumber), h("span", { class: "order-event" }, orderEventName(order) ?? 'Order'), h("span", { class: "order-meta" }, order.createdAt && h("span", null, formatDate(order.createdAt)), h("span", null, count, " ticket", count === 1 ? '' : 's'))), h("span", { class: "order-side" }, h("span", { class: "order-total" }, formatPrice(order.total, order.currency)), h("span", { class: `status status-${tone}` }, statusLabel(order.status)), h("svg", { class: "chevron", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "aria-hidden": "true" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M9 18l6-6-6-6" })))), expanded && (h("div", { class: "order-tickets" }, h("tl-order-tickets", { orderId: order.id, columns: this.columns })))));
|
|
102
|
+
}
|
|
103
|
+
render() {
|
|
104
|
+
if (this.loading) {
|
|
105
|
+
return (h("div", { class: "orders" }, [0, 1, 2].map((i) => (h("div", { class: "skeleton", key: i })))));
|
|
106
|
+
}
|
|
107
|
+
if (!this.authenticated) {
|
|
108
|
+
return (h("div", { class: "orders" }, h("div", { class: "signin" }, h("p", { class: "signin-title" }, "Sign in to see your orders"), h("p", { class: "signin-text" }, "Your tickets and order history live in your account.")), h("tl-login", null)));
|
|
109
|
+
}
|
|
110
|
+
if (this.error) {
|
|
111
|
+
return (h("div", { class: "orders" }, h("div", { class: "state error" }, h("p", { class: "state-title" }, "Could not load your orders"), h("p", { class: "state-text" }, this.error))));
|
|
112
|
+
}
|
|
113
|
+
if (this.orders.length === 0) {
|
|
114
|
+
return (h("div", { class: "orders" }, h("div", { class: "state empty" }, h("svg", { class: "empty-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "aria-hidden": "true" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "1.5", d: "M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z" }), h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "1.5", d: "M13 5v2M13 17v2M13 11v2" })), h("p", { class: "state-title" }, "No orders yet"), h("p", { class: "state-text" }, this.emptyMessage))));
|
|
115
|
+
}
|
|
116
|
+
return (h("div", { class: "orders" }, h("ul", { class: "order-list" }, this.orders.map((o) => this.renderRow(o)))));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
TlMyOrders.style = tlMyOrdersCss();
|
|
120
|
+
|
|
121
|
+
export { TlMyOrders as tl_my_orders };
|