@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,133 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
font-family: var(--tl-font-family, system-ui, sans-serif);
|
|
4
|
+
color: var(--tl-foreground, #111827);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.login {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: var(--tl-spacing-3, 0.75rem);
|
|
11
|
+
padding: var(--tl-spacing-6, 1.5rem);
|
|
12
|
+
background: var(--tl-background, #ffffff);
|
|
13
|
+
border: 1px solid var(--tl-border, #e5e7eb);
|
|
14
|
+
border-radius: var(--tl-radius-lg, 0.75rem);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.title {
|
|
18
|
+
margin: 0;
|
|
19
|
+
font-size: 1.25rem;
|
|
20
|
+
font-weight: 600;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.lead {
|
|
24
|
+
margin: 0;
|
|
25
|
+
font-size: 0.875rem;
|
|
26
|
+
color: var(--tl-muted-foreground, #6b7280);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.label {
|
|
30
|
+
font-size: 0.875rem;
|
|
31
|
+
font-weight: 500;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.input {
|
|
35
|
+
padding: var(--tl-spacing-3, 0.75rem);
|
|
36
|
+
font: inherit;
|
|
37
|
+
font-size: 0.9375rem;
|
|
38
|
+
color: var(--tl-foreground, #111827);
|
|
39
|
+
background: var(--tl-background, #ffffff);
|
|
40
|
+
border: 1px solid var(--tl-border, #e5e7eb);
|
|
41
|
+
border-radius: var(--tl-radius-md, 0.5rem);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.input:focus {
|
|
45
|
+
outline: 2px solid var(--tl-primary, #6366f1);
|
|
46
|
+
outline-offset: 1px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.code-input {
|
|
50
|
+
font-family: var(--tl-font-family-mono, ui-monospace, monospace);
|
|
51
|
+
font-size: 1.25rem;
|
|
52
|
+
letter-spacing: 0.25em;
|
|
53
|
+
text-align: center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.primary,
|
|
57
|
+
.secondary {
|
|
58
|
+
padding: var(--tl-spacing-3, 0.75rem) var(--tl-spacing-4, 1rem);
|
|
59
|
+
font: inherit;
|
|
60
|
+
font-size: 0.9375rem;
|
|
61
|
+
font-weight: 600;
|
|
62
|
+
border-radius: var(--tl-radius-md, 0.5rem);
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.primary {
|
|
67
|
+
color: var(--tl-primary-foreground, #ffffff);
|
|
68
|
+
background: var(--tl-primary, #6366f1);
|
|
69
|
+
border: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.primary:hover:not(:disabled) {
|
|
73
|
+
opacity: 0.9;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.secondary {
|
|
77
|
+
color: var(--tl-foreground, #111827);
|
|
78
|
+
background: var(--tl-secondary, #f3f4f6);
|
|
79
|
+
border: 1px solid var(--tl-border, #e5e7eb);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.primary:disabled,
|
|
83
|
+
.secondary:disabled,
|
|
84
|
+
.input:disabled {
|
|
85
|
+
opacity: 0.6;
|
|
86
|
+
cursor: not-allowed;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.link {
|
|
90
|
+
padding: 0;
|
|
91
|
+
font: inherit;
|
|
92
|
+
font-size: 0.875rem;
|
|
93
|
+
color: var(--tl-primary, #6366f1);
|
|
94
|
+
background: none;
|
|
95
|
+
border: none;
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.link:hover {
|
|
100
|
+
text-decoration: underline;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.actions {
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-wrap: wrap;
|
|
106
|
+
align-items: center;
|
|
107
|
+
gap: var(--tl-spacing-4, 1rem);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.error {
|
|
111
|
+
margin: 0;
|
|
112
|
+
font-size: 0.8125rem;
|
|
113
|
+
color: var(--tl-error, #ef4444);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.notice {
|
|
117
|
+
margin: 0;
|
|
118
|
+
font-size: 0.8125rem;
|
|
119
|
+
color: var(--tl-success, #10b981);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.signed-in {
|
|
123
|
+
flex-direction: row;
|
|
124
|
+
align-items: center;
|
|
125
|
+
justify-content: space-between;
|
|
126
|
+
flex-wrap: wrap;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.signed-in-text {
|
|
130
|
+
margin: 0;
|
|
131
|
+
font-size: 0.875rem;
|
|
132
|
+
overflow-wrap: anywhere;
|
|
133
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { whenSDK } from "../../utils/sdk-connector";
|
|
3
|
+
import { errorMessage } from "../../utils/order-summary";
|
|
4
|
+
/**
|
|
5
|
+
* tl-login - magic-link sign-in. The customer enters an email, we ask the SDK
|
|
6
|
+
* to send a link (POST /sales/customer-auth/magic-link), then either the link
|
|
7
|
+
* lands back on this page with `?code=` or the customer types the code from
|
|
8
|
+
* the email; both exchange through the SDK (POST /sales/customer-tokens). No
|
|
9
|
+
* password is ever handled here.
|
|
10
|
+
*
|
|
11
|
+
* States: enter email -> check your inbox (resend, enter code) -> signed in
|
|
12
|
+
* (email + sign out).
|
|
13
|
+
*
|
|
14
|
+
* Usage: <tl-login></tl-login>
|
|
15
|
+
*
|
|
16
|
+
* @event tlAuthChanged - signed in or out ({ customer, authenticated })
|
|
17
|
+
* @event tlMagicLinkSent - a link was requested for an email
|
|
18
|
+
* @event tlError - request or code exchange failed
|
|
19
|
+
*/
|
|
20
|
+
export class TlLogin {
|
|
21
|
+
constructor() {
|
|
22
|
+
/** Heading for the email step. */
|
|
23
|
+
this.heading = 'Sign in';
|
|
24
|
+
/** Offer a "enter the code" path alongside the emailed link (default true). */
|
|
25
|
+
this.allowCodeEntry = true;
|
|
26
|
+
this.phase = 'email';
|
|
27
|
+
this.email = '';
|
|
28
|
+
this.code = '';
|
|
29
|
+
this.busy = false;
|
|
30
|
+
this.error = null;
|
|
31
|
+
this.notice = null;
|
|
32
|
+
this.customer = null;
|
|
33
|
+
this.auth = null;
|
|
34
|
+
this.unsubscribes = [];
|
|
35
|
+
// A magic-link code is single-use; never exchange the URL code twice.
|
|
36
|
+
this.urlCodeUsed = false;
|
|
37
|
+
this.handleEmailInput = (e) => {
|
|
38
|
+
this.email = e.target.value;
|
|
39
|
+
this.error = null;
|
|
40
|
+
};
|
|
41
|
+
this.handleCodeInput = (e) => {
|
|
42
|
+
this.code = e.target.value;
|
|
43
|
+
this.error = null;
|
|
44
|
+
};
|
|
45
|
+
this.handleEmailSubmit = (e) => {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
this.requestLink();
|
|
48
|
+
};
|
|
49
|
+
this.handleCodeSubmit = (e) => {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
this.exchange(this.code.trim());
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async componentWillLoad() {
|
|
55
|
+
const sdk = await whenSDK().catch(() => null);
|
|
56
|
+
if (!sdk) {
|
|
57
|
+
this.error = 'Sign-in is not available right now';
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.auth = sdk.getAuthManager?.() ?? null;
|
|
61
|
+
if (!this.auth) {
|
|
62
|
+
this.error = 'Sign-in is not available with this SDK';
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.syncFromSDK();
|
|
66
|
+
// The session hydrates after the SDK publishes; follow both signals.
|
|
67
|
+
this.unsubscribes.push(sdk.on('auth:changed', () => this.syncFromSDK()));
|
|
68
|
+
this.unsubscribes.push(sdk.on('session:changed', () => this.syncFromSDK()));
|
|
69
|
+
const urlCode = this.codeFromUrl();
|
|
70
|
+
if (urlCode && !this.auth.authenticated) {
|
|
71
|
+
await this.exchange(urlCode);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
disconnectedCallback() {
|
|
75
|
+
this.unsubscribes.forEach((off) => off());
|
|
76
|
+
this.unsubscribes = [];
|
|
77
|
+
}
|
|
78
|
+
codeFromUrl() {
|
|
79
|
+
if (typeof window === 'undefined' || !window.location?.search || this.urlCodeUsed)
|
|
80
|
+
return null;
|
|
81
|
+
const code = new URLSearchParams(window.location.search).get('code');
|
|
82
|
+
if (code)
|
|
83
|
+
this.urlCodeUsed = true;
|
|
84
|
+
return code;
|
|
85
|
+
}
|
|
86
|
+
syncFromSDK() {
|
|
87
|
+
if (!this.auth)
|
|
88
|
+
return;
|
|
89
|
+
if (this.auth.authenticated) {
|
|
90
|
+
this.customer = this.auth.customer ?? null;
|
|
91
|
+
this.phase = 'signed-in';
|
|
92
|
+
}
|
|
93
|
+
else if (this.phase === 'signed-in') {
|
|
94
|
+
this.customer = null;
|
|
95
|
+
this.phase = 'email';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async requestLink(resend = false) {
|
|
99
|
+
const email = this.email.trim();
|
|
100
|
+
if (!email) {
|
|
101
|
+
this.error = 'Enter your email address';
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!this.auth)
|
|
105
|
+
return;
|
|
106
|
+
this.busy = true;
|
|
107
|
+
this.error = null;
|
|
108
|
+
this.notice = null;
|
|
109
|
+
try {
|
|
110
|
+
// Always reports success; account existence is never revealed.
|
|
111
|
+
await this.auth.requestMagicLink({ email });
|
|
112
|
+
this.phase = 'sent';
|
|
113
|
+
this.notice = resend ? 'Sent again. Check your inbox.' : null;
|
|
114
|
+
this.tlMagicLinkSent.emit({ email });
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
console.error('[tl-login] Magic-link request failed:', err);
|
|
118
|
+
this.error = errorMessage(err, 'Could not send your sign-in link');
|
|
119
|
+
this.tlError.emit({ message: this.error });
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
this.busy = false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async exchange(code) {
|
|
126
|
+
if (!code) {
|
|
127
|
+
this.error = 'Enter the code from your email';
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (!this.auth)
|
|
131
|
+
return;
|
|
132
|
+
const previous = this.phase;
|
|
133
|
+
this.busy = true;
|
|
134
|
+
this.error = null;
|
|
135
|
+
this.phase = 'verifying';
|
|
136
|
+
try {
|
|
137
|
+
const res = (await this.auth.exchange(code));
|
|
138
|
+
this.customer = this.auth.customer ?? res?.customer ?? null;
|
|
139
|
+
this.phase = 'signed-in';
|
|
140
|
+
this.code = '';
|
|
141
|
+
this.tlAuthChanged.emit({ customer: this.customer, authenticated: true });
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
console.error('[tl-login] Code exchange failed:', err);
|
|
145
|
+
this.phase = previous === 'verifying' || previous === 'email' ? 'email' : 'code';
|
|
146
|
+
this.error = 'That code did not work. Check it and try again, or request a new link.';
|
|
147
|
+
this.tlError.emit({ message: this.error });
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
this.busy = false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async signOut() {
|
|
154
|
+
if (!this.auth)
|
|
155
|
+
return;
|
|
156
|
+
this.busy = true;
|
|
157
|
+
try {
|
|
158
|
+
await this.auth.logout();
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
console.error('[tl-login] Sign out failed:', err);
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
this.busy = false;
|
|
165
|
+
this.customer = null;
|
|
166
|
+
this.phase = 'email';
|
|
167
|
+
this.tlAuthChanged.emit({ customer: null, authenticated: false });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
renderError() {
|
|
171
|
+
return this.error ? (h("p", { class: "error", role: "alert" }, this.error)) : null;
|
|
172
|
+
}
|
|
173
|
+
render() {
|
|
174
|
+
if (this.phase === 'signed-in') {
|
|
175
|
+
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")));
|
|
176
|
+
}
|
|
177
|
+
if (this.phase === 'verifying') {
|
|
178
|
+
return (h("div", { class: "login" }, h("h2", { class: "title" }, "Signing you in\u2026"), h("p", { class: "lead" }, "Just a moment.")));
|
|
179
|
+
}
|
|
180
|
+
if (this.phase === 'sent') {
|
|
181
|
+
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"))));
|
|
182
|
+
}
|
|
183
|
+
if (this.phase === 'code') {
|
|
184
|
+
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"))));
|
|
185
|
+
}
|
|
186
|
+
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')));
|
|
187
|
+
}
|
|
188
|
+
static get is() { return "tl-login"; }
|
|
189
|
+
static get encapsulation() { return "shadow"; }
|
|
190
|
+
static get originalStyleUrls() {
|
|
191
|
+
return {
|
|
192
|
+
"$": ["tl-login.css"]
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
static get styleUrls() {
|
|
196
|
+
return {
|
|
197
|
+
"$": ["tl-login.css"]
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
static get properties() {
|
|
201
|
+
return {
|
|
202
|
+
"heading": {
|
|
203
|
+
"type": "string",
|
|
204
|
+
"mutable": false,
|
|
205
|
+
"complexType": {
|
|
206
|
+
"original": "string",
|
|
207
|
+
"resolved": "string",
|
|
208
|
+
"references": {}
|
|
209
|
+
},
|
|
210
|
+
"required": false,
|
|
211
|
+
"optional": false,
|
|
212
|
+
"docs": {
|
|
213
|
+
"tags": [],
|
|
214
|
+
"text": "Heading for the email step."
|
|
215
|
+
},
|
|
216
|
+
"getter": false,
|
|
217
|
+
"setter": false,
|
|
218
|
+
"reflect": false,
|
|
219
|
+
"attribute": "heading",
|
|
220
|
+
"defaultValue": "'Sign in'"
|
|
221
|
+
},
|
|
222
|
+
"allowCodeEntry": {
|
|
223
|
+
"type": "boolean",
|
|
224
|
+
"mutable": false,
|
|
225
|
+
"complexType": {
|
|
226
|
+
"original": "boolean",
|
|
227
|
+
"resolved": "boolean",
|
|
228
|
+
"references": {}
|
|
229
|
+
},
|
|
230
|
+
"required": false,
|
|
231
|
+
"optional": false,
|
|
232
|
+
"docs": {
|
|
233
|
+
"tags": [],
|
|
234
|
+
"text": "Offer a \"enter the code\" path alongside the emailed link (default true)."
|
|
235
|
+
},
|
|
236
|
+
"getter": false,
|
|
237
|
+
"setter": false,
|
|
238
|
+
"reflect": false,
|
|
239
|
+
"attribute": "allow-code-entry",
|
|
240
|
+
"defaultValue": "true"
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
static get states() {
|
|
245
|
+
return {
|
|
246
|
+
"phase": {},
|
|
247
|
+
"email": {},
|
|
248
|
+
"code": {},
|
|
249
|
+
"busy": {},
|
|
250
|
+
"error": {},
|
|
251
|
+
"notice": {},
|
|
252
|
+
"customer": {}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
static get events() {
|
|
256
|
+
return [{
|
|
257
|
+
"method": "tlAuthChanged",
|
|
258
|
+
"name": "tlAuthChanged",
|
|
259
|
+
"bubbles": true,
|
|
260
|
+
"cancelable": true,
|
|
261
|
+
"composed": true,
|
|
262
|
+
"docs": {
|
|
263
|
+
"tags": [],
|
|
264
|
+
"text": ""
|
|
265
|
+
},
|
|
266
|
+
"complexType": {
|
|
267
|
+
"original": "TlAuthChanged",
|
|
268
|
+
"resolved": "TlAuthChanged",
|
|
269
|
+
"references": {
|
|
270
|
+
"TlAuthChanged": {
|
|
271
|
+
"location": "local",
|
|
272
|
+
"path": "/home/runner/work/live-elements/live-elements/src/components/tl-login/tl-login.tsx",
|
|
273
|
+
"id": "src/components/tl-login/tl-login.tsx::TlAuthChanged"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}, {
|
|
278
|
+
"method": "tlMagicLinkSent",
|
|
279
|
+
"name": "tlMagicLinkSent",
|
|
280
|
+
"bubbles": true,
|
|
281
|
+
"cancelable": true,
|
|
282
|
+
"composed": true,
|
|
283
|
+
"docs": {
|
|
284
|
+
"tags": [],
|
|
285
|
+
"text": ""
|
|
286
|
+
},
|
|
287
|
+
"complexType": {
|
|
288
|
+
"original": "{ email: string }",
|
|
289
|
+
"resolved": "{ email: string; }",
|
|
290
|
+
"references": {}
|
|
291
|
+
}
|
|
292
|
+
}, {
|
|
293
|
+
"method": "tlError",
|
|
294
|
+
"name": "tlError",
|
|
295
|
+
"bubbles": true,
|
|
296
|
+
"cancelable": true,
|
|
297
|
+
"composed": true,
|
|
298
|
+
"docs": {
|
|
299
|
+
"tags": [],
|
|
300
|
+
"text": ""
|
|
301
|
+
},
|
|
302
|
+
"complexType": {
|
|
303
|
+
"original": "{ message: string }",
|
|
304
|
+
"resolved": "{ message: string; }",
|
|
305
|
+
"references": {}
|
|
306
|
+
}
|
|
307
|
+
}];
|
|
308
|
+
}
|
|
309
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
font-family: var(--tl-font-family, system-ui, sans-serif);
|
|
4
|
+
color: var(--tl-foreground, #111827);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.orders {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: var(--tl-spacing-4, 1rem);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.order-list {
|
|
14
|
+
list-style: none;
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: var(--tl-spacing-3, 0.75rem);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.order {
|
|
23
|
+
background: var(--tl-background, #ffffff);
|
|
24
|
+
border: 1px solid var(--tl-border, #e5e7eb);
|
|
25
|
+
border-radius: var(--tl-radius-lg, 0.75rem);
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.order:hover,
|
|
31
|
+
.order.expanded {
|
|
32
|
+
border-color: var(--tl-primary, #6366f1);
|
|
33
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.order-row {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: space-between;
|
|
40
|
+
gap: var(--tl-spacing-4, 1rem);
|
|
41
|
+
width: 100%;
|
|
42
|
+
padding: var(--tl-spacing-4, 1rem);
|
|
43
|
+
font: inherit;
|
|
44
|
+
color: inherit;
|
|
45
|
+
text-align: left;
|
|
46
|
+
background: none;
|
|
47
|
+
border: none;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.order-main {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-direction: column;
|
|
54
|
+
gap: var(--tl-spacing-1, 0.25rem);
|
|
55
|
+
min-width: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.order-number {
|
|
59
|
+
font-size: 0.75rem;
|
|
60
|
+
font-weight: 500;
|
|
61
|
+
text-transform: uppercase;
|
|
62
|
+
letter-spacing: 0.05em;
|
|
63
|
+
color: var(--tl-muted-foreground, #6b7280);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.order-event {
|
|
67
|
+
font-size: 1rem;
|
|
68
|
+
font-weight: 600;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
text-overflow: ellipsis;
|
|
71
|
+
white-space: nowrap;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.order-meta {
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-wrap: wrap;
|
|
77
|
+
gap: var(--tl-spacing-3, 0.75rem);
|
|
78
|
+
font-size: 0.8125rem;
|
|
79
|
+
color: var(--tl-muted-foreground, #6b7280);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.order-side {
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
gap: var(--tl-spacing-3, 0.75rem);
|
|
86
|
+
flex-shrink: 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.order-total {
|
|
90
|
+
font-weight: 600;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.status {
|
|
94
|
+
padding: 0.125rem 0.5rem;
|
|
95
|
+
font-size: 0.75rem;
|
|
96
|
+
font-weight: 500;
|
|
97
|
+
border-radius: 9999px;
|
|
98
|
+
background: var(--tl-secondary, #f3f4f6);
|
|
99
|
+
color: var(--tl-secondary-foreground, #111827);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.status-success {
|
|
103
|
+
background: var(--tl-success, #10b981);
|
|
104
|
+
color: var(--tl-success-foreground, #ffffff);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.status-info {
|
|
108
|
+
background: var(--tl-primary, #6366f1);
|
|
109
|
+
color: var(--tl-primary-foreground, #ffffff);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.status-warning {
|
|
113
|
+
background: var(--tl-warning, #f59e0b);
|
|
114
|
+
color: var(--tl-warning-foreground, #ffffff);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.status-error {
|
|
118
|
+
background: var(--tl-error, #ef4444);
|
|
119
|
+
color: var(--tl-error-foreground, #ffffff);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.chevron {
|
|
123
|
+
width: 1.125rem;
|
|
124
|
+
height: 1.125rem;
|
|
125
|
+
color: var(--tl-muted-foreground, #6b7280);
|
|
126
|
+
transition: transform 0.2s ease;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.expanded .chevron {
|
|
130
|
+
transform: rotate(90deg);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.order-tickets {
|
|
134
|
+
padding: 0 var(--tl-spacing-4, 1rem) var(--tl-spacing-4, 1rem);
|
|
135
|
+
border-top: 1px solid var(--tl-border, #e5e7eb);
|
|
136
|
+
padding-top: var(--tl-spacing-4, 1rem);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@media (max-width: 480px) {
|
|
140
|
+
.order-row {
|
|
141
|
+
flex-direction: column;
|
|
142
|
+
align-items: stretch;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.order-side {
|
|
146
|
+
justify-content: space-between;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* Sign-in, empty and error states */
|
|
151
|
+
.signin {
|
|
152
|
+
text-align: center;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.signin-title,
|
|
156
|
+
.state-title {
|
|
157
|
+
margin: 0;
|
|
158
|
+
font-size: 1.125rem;
|
|
159
|
+
font-weight: 600;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.signin-text,
|
|
163
|
+
.state-text {
|
|
164
|
+
margin: var(--tl-spacing-1, 0.25rem) 0 0;
|
|
165
|
+
font-size: 0.875rem;
|
|
166
|
+
color: var(--tl-muted-foreground, #6b7280);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.state {
|
|
170
|
+
padding: var(--tl-spacing-8, 2rem) var(--tl-spacing-4, 1rem);
|
|
171
|
+
text-align: center;
|
|
172
|
+
background: var(--tl-background, #ffffff);
|
|
173
|
+
border: 1px solid var(--tl-border, #e5e7eb);
|
|
174
|
+
border-radius: var(--tl-radius-lg, 0.75rem);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.state.error .state-title {
|
|
178
|
+
color: var(--tl-error, #ef4444);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.empty-icon {
|
|
182
|
+
width: 3rem;
|
|
183
|
+
height: 3rem;
|
|
184
|
+
margin: 0 auto var(--tl-spacing-3, 0.75rem);
|
|
185
|
+
color: var(--tl-primary, #6366f1);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* Skeleton */
|
|
189
|
+
.skeleton {
|
|
190
|
+
height: 5rem;
|
|
191
|
+
background: var(--tl-secondary, #f3f4f6);
|
|
192
|
+
border-radius: var(--tl-radius-lg, 0.75rem);
|
|
193
|
+
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
@keyframes pulse {
|
|
197
|
+
0%,
|
|
198
|
+
100% {
|
|
199
|
+
opacity: 1;
|
|
200
|
+
}
|
|
201
|
+
50% {
|
|
202
|
+
opacity: 0.5;
|
|
203
|
+
}
|
|
204
|
+
}
|