@semics-tech/emdash-events 0.0.0-stage → 1.0.0-rc.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 +82 -2
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +392 -0
- package/dist/manifest.json +401 -0
- package/dist/plugin.d.mts +11 -0
- package/dist/plugin.mjs +7 -0
- package/dist/ts/astro/lib/call.d.ts +54 -0
- package/dist/ts/astro/lib/call.js +121 -0
- package/dist/ts/integration/index.d.ts +48 -0
- package/dist/ts/integration/index.js +76 -0
- package/dist/ts/ui/index.d.ts +6 -0
- package/dist/ts/ui/index.js +46 -0
- package/emdash-plugin.jsonc +206 -0
- package/package.json +77 -3
- package/src/astro/AddToCalendar.astro +47 -0
- package/src/astro/BookingBlock.astro +30 -0
- package/src/astro/BookingPage.astro +193 -0
- package/src/astro/BookingStatus.astro +106 -0
- package/src/astro/BookingWidget.astro +581 -0
- package/src/astro/CheckIn.astro +186 -0
- package/src/astro/DoorSignPage.astro +62 -0
- package/src/astro/EventCard.astro +81 -0
- package/src/astro/EventList.astro +83 -0
- package/src/astro/OptOutPage.astro +58 -0
- package/src/astro/PaymentReturn.astro +96 -0
- package/src/astro/TicketPass.astro +95 -0
- package/src/astro/checkout-endpoint.ts +11 -0
- package/src/astro/index.js +18 -0
- package/src/astro/lib/call.ts +185 -0
- package/src/astro/lib/checkout-form.ts +271 -0
- package/src/astro/lib/list.ts +99 -0
- package/src/astro/lib/opt-out.ts +49 -0
- package/src/astro/lib/pass.ts +35 -0
- package/src/astro/lib/payment.ts +73 -0
- package/src/astro/lib/promo.ts +162 -0
- package/src/astro/lib/questions.ts +107 -0
- package/src/astro/lib/receipt.ts +132 -0
- package/src/astro/lib/waitlist.ts +72 -0
- package/src/astro/lib/widget.ts +278 -0
- package/src/astro/promo-endpoint.ts +11 -0
- package/src/astro/virtual.d.ts +16 -0
- package/src/astro/waitlist-endpoint.ts +12 -0
- package/src/client/booking.ts +188 -0
- package/src/client/checkin.ts +260 -0
- package/src/client/payment.ts +76 -0
- package/src/client/receipt.ts +75 -0
- package/src/i18n/ar.ts +213 -0
- package/src/i18n/en.ts +219 -0
- package/src/i18n/index.ts +121 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
// <BookingStatus>: a booking's state, order and cancel button (EU-FR-06). Rendered by the
|
|
3
|
+
// `/booking` page from the `public/booking` answer; the cancel form is a plain POST back to it.
|
|
4
|
+
import { around, pickLocale, translator } from "../i18n/index";
|
|
5
|
+
import { type BookingView, formatMoney, statusLabel } from "./lib/widget";
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
booking: BookingView;
|
|
9
|
+
/** Shown as cancelled (the page just cancelled it). */
|
|
10
|
+
cancelled?: boolean;
|
|
11
|
+
/** Where the cancel form posts. */
|
|
12
|
+
cancelAction?: string;
|
|
13
|
+
/** Ticket type names by id, when the page knows them. */
|
|
14
|
+
ticketNames?: Record<string, string>;
|
|
15
|
+
locale?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { booking, cancelled = false, cancelAction, ticketNames = {} } = Astro.props;
|
|
19
|
+
const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
|
|
20
|
+
const { t, plural, lang, dir } = translator(locale);
|
|
21
|
+
const [heldBefore, heldAfter] = around(t("booking.heldUntil"), "time");
|
|
22
|
+
const [cancelBefore, cancelAfter] = around(t("booking.cancelUntil"), "time");
|
|
23
|
+
const tickets = booking.lines.reduce((n, line) => n + line.qty, 0);
|
|
24
|
+
const status = cancelled ? "cancelled" : booking.status;
|
|
25
|
+
const at = (iso: string) => {
|
|
26
|
+
try {
|
|
27
|
+
const time = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" }).format(
|
|
28
|
+
new Date(iso),
|
|
29
|
+
);
|
|
30
|
+
return t("time.utc", { time });
|
|
31
|
+
} catch {
|
|
32
|
+
return iso;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
---
|
|
36
|
+
<section class="semics-events semics-booking-status" data-testid="booking-details" data-status={status} lang={lang} dir={dir} aria-labelledby="semics-booking-status-title">
|
|
37
|
+
<h2 id="semics-booking-status-title" class="semics-visually-hidden">{t("booking.status")}</h2>
|
|
38
|
+
<p>
|
|
39
|
+
{t("booking.reference")} <strong data-testid="booking-ref">{booking.bookingRef}</strong>
|
|
40
|
+
</p>
|
|
41
|
+
<p class="semics-status" data-testid="booking-status" data-status={status}>
|
|
42
|
+
<span class="semics-status-badge">{statusLabel(status, locale)}</span>
|
|
43
|
+
</p>
|
|
44
|
+
{
|
|
45
|
+
!cancelled && booking.holdExpiresAt && (
|
|
46
|
+
<p data-testid="booking-hold">
|
|
47
|
+
{heldBefore}<time datetime={booking.holdExpiresAt}>{at(booking.holdExpiresAt)}</time>{heldAfter}
|
|
48
|
+
</p>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
<ul class="semics-lines" aria-label={plural("booking.lines", tickets)}>
|
|
52
|
+
{
|
|
53
|
+
booking.lines.map((line) => (
|
|
54
|
+
<li>
|
|
55
|
+
{t("booking.line", { qty: new Intl.NumberFormat(locale).format(line.qty), name: ticketNames[line.ticketTypeId] ?? line.ticketTypeId })}
|
|
56
|
+
</li>
|
|
57
|
+
))
|
|
58
|
+
}
|
|
59
|
+
</ul>
|
|
60
|
+
<p>{t("booking.total")} <strong>{formatMoney(booking.totals.totalMinor, booking.totals.currency, locale)}</strong></p>
|
|
61
|
+
{
|
|
62
|
+
booking.canCancel && !cancelled && cancelAction && (
|
|
63
|
+
<form method="post" action={cancelAction}>
|
|
64
|
+
<input type="hidden" name="intent" value="cancel" />
|
|
65
|
+
{booking.cancelBy && (
|
|
66
|
+
<p>
|
|
67
|
+
{cancelBefore}<time datetime={booking.cancelBy}>{at(booking.cancelBy)}</time>{cancelAfter}
|
|
68
|
+
</p>
|
|
69
|
+
)}
|
|
70
|
+
<button type="submit">{t("booking.cancel")}</button>
|
|
71
|
+
</form>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
</section>
|
|
75
|
+
|
|
76
|
+
<style>
|
|
77
|
+
.semics-booking-status {
|
|
78
|
+
box-sizing: border-box;
|
|
79
|
+
max-inline-size: 36rem;
|
|
80
|
+
color: var(--events-fg, #1a1a1a);
|
|
81
|
+
overflow-wrap: anywhere;
|
|
82
|
+
}
|
|
83
|
+
.semics-status-badge {
|
|
84
|
+
display: inline-block;
|
|
85
|
+
padding: 0.125rem 0.5rem;
|
|
86
|
+
border: 1px solid currentColor;
|
|
87
|
+
border-radius: var(--events-radius, 6px);
|
|
88
|
+
font-weight: 600;
|
|
89
|
+
}
|
|
90
|
+
.semics-booking-status[data-status="confirmed"] .semics-status-badge {
|
|
91
|
+
color: var(--events-success, #146c2e);
|
|
92
|
+
}
|
|
93
|
+
.semics-booking-status button {
|
|
94
|
+
font: inherit;
|
|
95
|
+
min-block-size: 2.75rem;
|
|
96
|
+
padding: 0.5rem 1rem;
|
|
97
|
+
}
|
|
98
|
+
.semics-visually-hidden {
|
|
99
|
+
position: absolute;
|
|
100
|
+
inline-size: 1px;
|
|
101
|
+
block-size: 1px;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
clip-path: inset(50%);
|
|
104
|
+
white-space: nowrap;
|
|
105
|
+
}
|
|
106
|
+
</style>
|
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
---
|
|
2
|
+
// <BookingWidget event={entryId} />: a plain form that posts to `/_events/checkout` (works with no
|
|
3
|
+
// JavaScript), enhanced by `src/client/booking.ts`. Loads the event's ticket types from
|
|
4
|
+
// `public/event` unless the page passes them as `data`. All text is rendered as text (Astro escapes
|
|
5
|
+
// every expression; nothing here injects raw HTML).
|
|
6
|
+
import { pluginId } from "virtual:semics-events/config";
|
|
7
|
+
|
|
8
|
+
import { pickLocale, translator } from "../i18n/index";
|
|
9
|
+
import { callPublicRoute } from "./lib/call";
|
|
10
|
+
import { CHECKOUT_PATH, QTY_PREFIX } from "./lib/checkout-form";
|
|
11
|
+
import { PROMO_PATH, type PromoView, promoCookieName, promoView } from "./lib/promo";
|
|
12
|
+
import { QUESTIONS_MARKER, questionControls } from "./lib/questions";
|
|
13
|
+
import { readWaitlistState, WAITLIST_PATH, waitlistMessage } from "./lib/waitlist";
|
|
14
|
+
import {
|
|
15
|
+
anchorId,
|
|
16
|
+
errorMessage,
|
|
17
|
+
fieldMessage,
|
|
18
|
+
formatMoney,
|
|
19
|
+
newIdempotencyKey,
|
|
20
|
+
type PublicEvent,
|
|
21
|
+
readWidgetState,
|
|
22
|
+
safeReturnTo,
|
|
23
|
+
type WidgetField,
|
|
24
|
+
} from "./lib/widget";
|
|
25
|
+
|
|
26
|
+
interface Props {
|
|
27
|
+
/** The event's content entry id. */
|
|
28
|
+
event: string;
|
|
29
|
+
/** The `public/event` answer, when the page already has it. */
|
|
30
|
+
data?: PublicEvent;
|
|
31
|
+
heading?: string;
|
|
32
|
+
/** Overrides the site key from `public/event`. */
|
|
33
|
+
turnstileSiteKey?: string;
|
|
34
|
+
locale?: string;
|
|
35
|
+
/** The applied promo code's view, when the page already has it (`null`: none). */
|
|
36
|
+
promo?: PromoView | null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { event: eventId } = Astro.props;
|
|
40
|
+
// The language: the `locale` prop, else the page's (Astro i18n), else British English (T102).
|
|
41
|
+
const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
|
|
42
|
+
const { t, lang, dir } = translator(locale);
|
|
43
|
+
const heading = Astro.props.heading ?? t("widget.heading");
|
|
44
|
+
const fieldText = (field: Parameters<typeof fieldMessage>[0]) => fieldMessage(field, locale);
|
|
45
|
+
let data = Astro.props.data;
|
|
46
|
+
if (!data) {
|
|
47
|
+
const result = await callPublicRoute<PublicEvent>(Astro, {
|
|
48
|
+
path: "public/event",
|
|
49
|
+
pluginId,
|
|
50
|
+
body: { eventId },
|
|
51
|
+
});
|
|
52
|
+
if (result.ok) data = result.data;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const id = anchorId(eventId);
|
|
56
|
+
// Promo codes are Events Pro's (T078): the field shows only when the core says it takes them. An
|
|
57
|
+
// applied code lives in an HttpOnly cookie (`/_events/promo`), never the URL, and is checked again here.
|
|
58
|
+
const takesCodes = data?.promoCodes === true;
|
|
59
|
+
let promo: PromoView | null = Astro.props.promo ?? null;
|
|
60
|
+
if (takesCodes && Astro.props.promo === undefined) {
|
|
61
|
+
let code = "";
|
|
62
|
+
try {
|
|
63
|
+
code = Astro.cookies.get(promoCookieName(eventId))?.value ?? "";
|
|
64
|
+
} catch {
|
|
65
|
+
// A prerendered page has no cookies.
|
|
66
|
+
}
|
|
67
|
+
if (code) promo = await promoView(Astro, { eventId, code, currency: data?.currency, locale }, { pluginId });
|
|
68
|
+
}
|
|
69
|
+
const promoForm = `${id}-promo-form`;
|
|
70
|
+
const siteKey = Astro.props.turnstileSiteKey ?? data?.turnstileSiteKey ?? "";
|
|
71
|
+
const state = readWidgetState(Astro.url, eventId);
|
|
72
|
+
const returnTo = safeReturnTo(`${Astro.url.pathname}${Astro.url.search}`, Astro.url.origin) ?? "";
|
|
73
|
+
const occurrences = data?.occurrences ?? [];
|
|
74
|
+
const listed = new Set((data?.ticketTypes ?? []).map((t) => t.id));
|
|
75
|
+
// An unlock code's hidden types join the list (reserve checks the code again before it sells them).
|
|
76
|
+
const ticketTypes = [
|
|
77
|
+
...(data?.ticketTypes ?? []),
|
|
78
|
+
...(takesCodes ? (promo?.hiddenTypes ?? []) : []).filter((t) => !listed.has(t.id)),
|
|
79
|
+
] as PublicEvent["ticketTypes"];
|
|
80
|
+
const onSale = data?.status === "on_sale" && ticketTypes.length > 0;
|
|
81
|
+
// The waitlist (T081): offered when the core takes one and the tickets, or some dates, are sold out.
|
|
82
|
+
const fullDates = occurrences.filter((o) => o.available === 0);
|
|
83
|
+
const waitlist =
|
|
84
|
+
onSale &&
|
|
85
|
+
data?.waitlist === true &&
|
|
86
|
+
(ticketTypes.every((t) => t.available === 0) || fullDates.length > 0);
|
|
87
|
+
const waitlistDates = ticketTypes.every((t) => t.available === 0) ? occurrences : fullDates;
|
|
88
|
+
const waitlistOutcome = readWaitlistState(Astro.url, eventId);
|
|
89
|
+
// Custom attendee questions are Events Pro's (T080): `public/event` lists them only on a Pro core.
|
|
90
|
+
const questions = questionControls(data?.questions, id, state.fields, locale);
|
|
91
|
+
const bad = (field: WidgetField) => state.fields.includes(field);
|
|
92
|
+
const errId = (field: WidgetField) => `${id}-${field}-error`;
|
|
93
|
+
const invalid = (field: WidgetField) => (bad(field) ? "true" : undefined);
|
|
94
|
+
const formAlert = state.code ? errorMessage(state.code, locale) : "";
|
|
95
|
+
const when = (iso: string) => {
|
|
96
|
+
const options = { dateStyle: "full", timeStyle: "short" } as const;
|
|
97
|
+
try {
|
|
98
|
+
return new Intl.DateTimeFormat(locale, { ...options, timeZone: data?.timezone ?? "UTC" }).format(new Date(iso));
|
|
99
|
+
} catch {
|
|
100
|
+
return new Intl.DateTimeFormat(locale, { ...options, timeZone: "UTC" }).format(new Date(iso));
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
---
|
|
104
|
+
<section id={id} class="semics-events semics-booking-widget" lang={lang} dir={dir} aria-labelledby={`${id}-title`} data-testid="booking-widget">
|
|
105
|
+
<h2 id={`${id}-title`}>{heading}</h2>
|
|
106
|
+
{
|
|
107
|
+
!onSale ? (
|
|
108
|
+
<p data-testid="booking-unavailable">{t("widget.unavailable")}</p>
|
|
109
|
+
) : (
|
|
110
|
+
<>
|
|
111
|
+
{takesCodes && (
|
|
112
|
+
<form id={promoForm} method="post" action={PROMO_PATH} hidden>
|
|
113
|
+
<input type="hidden" name="eventId" value={eventId} />
|
|
114
|
+
<input type="hidden" name="returnTo" value={returnTo} />
|
|
115
|
+
</form>
|
|
116
|
+
)}
|
|
117
|
+
<form
|
|
118
|
+
method="post"
|
|
119
|
+
action={CHECKOUT_PATH}
|
|
120
|
+
data-semics-booking
|
|
121
|
+
data-currency={data?.currency}
|
|
122
|
+
data-locale={locale}
|
|
123
|
+
data-free={t("money.free")}
|
|
124
|
+
data-turnstile={siteKey ? "on" : undefined}
|
|
125
|
+
data-turnstile-message={siteKey ? t("widget.turnstile") : undefined}
|
|
126
|
+
>
|
|
127
|
+
<p class="semics-form-alert" role="alert" data-form-alert hidden={!formAlert}>{formAlert}</p>
|
|
128
|
+
<input type="hidden" name="eventId" value={eventId} />
|
|
129
|
+
<input type="hidden" name="returnTo" value={returnTo} />
|
|
130
|
+
<input type="hidden" name="idempotencyKey" value={newIdempotencyKey()} />
|
|
131
|
+
|
|
132
|
+
{occurrences.length > 0 && (
|
|
133
|
+
<div class="semics-field">
|
|
134
|
+
<input type="hidden" name="needsOccurrence" value="1" />
|
|
135
|
+
<label for={`${id}-occurrence`}>{t("widget.date")}</label>
|
|
136
|
+
<select
|
|
137
|
+
id={`${id}-occurrence`}
|
|
138
|
+
name="occurrenceId"
|
|
139
|
+
required
|
|
140
|
+
data-field="occurrence"
|
|
141
|
+
aria-invalid={invalid("occurrence")}
|
|
142
|
+
aria-describedby={errId("occurrence")}
|
|
143
|
+
>
|
|
144
|
+
<option value="">{t("widget.chooseDate")}</option>
|
|
145
|
+
{occurrences.map((o) => (
|
|
146
|
+
<option value={o.id} disabled={o.available === 0}>
|
|
147
|
+
{o.available === 0 ? t("widget.dateSoldOut", { date: when(o.startsAt) }) : when(o.startsAt)}
|
|
148
|
+
</option>
|
|
149
|
+
))}
|
|
150
|
+
</select>
|
|
151
|
+
<p class="semics-field-error" id={errId("occurrence")} data-error-for="occurrence" data-message={fieldText("occurrence")}>
|
|
152
|
+
{bad("occurrence") ? fieldText("occurrence") : ""}
|
|
153
|
+
</p>
|
|
154
|
+
</div>
|
|
155
|
+
)}
|
|
156
|
+
|
|
157
|
+
{takesCodes && (
|
|
158
|
+
<div class="semics-field semics-promo">
|
|
159
|
+
{promo && <input type="hidden" name="promoCode" value={promo.code} />}
|
|
160
|
+
<label for={`${id}-promo`}>{t("widget.promo.label")}</label>
|
|
161
|
+
<div class="semics-promo-row">
|
|
162
|
+
<input
|
|
163
|
+
id={`${id}-promo`}
|
|
164
|
+
form={promoForm}
|
|
165
|
+
name="promoCode"
|
|
166
|
+
type="text"
|
|
167
|
+
autocomplete="off"
|
|
168
|
+
autocapitalize="characters"
|
|
169
|
+
spellcheck="false"
|
|
170
|
+
maxlength="60"
|
|
171
|
+
value={promo?.code ?? ""}
|
|
172
|
+
data-field="promo"
|
|
173
|
+
aria-invalid={invalid("promo")}
|
|
174
|
+
aria-describedby={`${errId("promo")}${promo ? ` ${id}-promo-note` : ""}`}
|
|
175
|
+
/>
|
|
176
|
+
<button type="submit" form={promoForm} class="semics-secondary" data-promo-apply>
|
|
177
|
+
{promo ? t("widget.promo.update") : t("widget.promo.apply")}
|
|
178
|
+
</button>
|
|
179
|
+
</div>
|
|
180
|
+
<p class="semics-field-error" id={errId("promo")} data-error-for="promo" data-message={fieldText("promo")}>
|
|
181
|
+
{bad("promo") ? fieldText("promo") : ""}
|
|
182
|
+
</p>
|
|
183
|
+
{promo && (
|
|
184
|
+
<p class="semics-promo-note" id={`${id}-promo-note`} data-testid="promo-note">
|
|
185
|
+
{promo.note}
|
|
186
|
+
</p>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
)}
|
|
190
|
+
|
|
191
|
+
<fieldset class="semics-tickets" data-field="tickets" aria-invalid={invalid("tickets")} aria-describedby={errId("tickets")}>
|
|
192
|
+
<legend>{t("widget.tickets")}</legend>
|
|
193
|
+
{ticketTypes.map((type) => {
|
|
194
|
+
const soldOut = type.available === 0;
|
|
195
|
+
const max = Math.min(type.maxPerOrder ?? 50, type.available ?? 50, 50);
|
|
196
|
+
return (
|
|
197
|
+
<div class="semics-ticket">
|
|
198
|
+
<label for={`${id}-qty-${type.id}`}>
|
|
199
|
+
<span class="semics-ticket-name">{type.name}</span>
|
|
200
|
+
<span class="semics-ticket-price">{formatMoney(type.priceMinor, data?.currency ?? "GBP", locale)}</span>
|
|
201
|
+
{soldOut && <span class="semics-ticket-soldout">{t("widget.soldOut")}</span>}
|
|
202
|
+
</label>
|
|
203
|
+
<input
|
|
204
|
+
id={`${id}-qty-${type.id}`}
|
|
205
|
+
type="number"
|
|
206
|
+
inputmode="numeric"
|
|
207
|
+
name={`${QTY_PREFIX}${type.id}`}
|
|
208
|
+
value="0"
|
|
209
|
+
min="0"
|
|
210
|
+
max={String(max)}
|
|
211
|
+
disabled={soldOut}
|
|
212
|
+
data-price-minor={String(type.priceMinor)}
|
|
213
|
+
/>
|
|
214
|
+
</div>
|
|
215
|
+
);
|
|
216
|
+
})}
|
|
217
|
+
<p class="semics-field-error" id={errId("tickets")} data-error-for="tickets" data-message={fieldText("tickets")}>
|
|
218
|
+
{bad("tickets") ? fieldText("tickets") : ""}
|
|
219
|
+
</p>
|
|
220
|
+
</fieldset>
|
|
221
|
+
|
|
222
|
+
<div class="semics-field">
|
|
223
|
+
<label for={`${id}-name`}>{t("widget.name")}</label>
|
|
224
|
+
<input
|
|
225
|
+
id={`${id}-name`}
|
|
226
|
+
name="name"
|
|
227
|
+
type="text"
|
|
228
|
+
autocomplete="name"
|
|
229
|
+
required
|
|
230
|
+
maxlength="200"
|
|
231
|
+
data-field="name"
|
|
232
|
+
aria-invalid={invalid("name")}
|
|
233
|
+
aria-describedby={errId("name")}
|
|
234
|
+
/>
|
|
235
|
+
<p class="semics-field-error" id={errId("name")} data-error-for="name" data-message={fieldText("name")}>
|
|
236
|
+
{bad("name") ? fieldText("name") : ""}
|
|
237
|
+
</p>
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
<div class="semics-field">
|
|
241
|
+
<label for={`${id}-email`}>{t("widget.email")}</label>
|
|
242
|
+
<input
|
|
243
|
+
id={`${id}-email`}
|
|
244
|
+
name="email"
|
|
245
|
+
type="email"
|
|
246
|
+
autocomplete="email"
|
|
247
|
+
required
|
|
248
|
+
maxlength="254"
|
|
249
|
+
data-field="email"
|
|
250
|
+
aria-invalid={invalid("email")}
|
|
251
|
+
aria-describedby={errId("email")}
|
|
252
|
+
/>
|
|
253
|
+
<p class="semics-field-error" id={errId("email")} data-error-for="email" data-message={fieldText("email")}>
|
|
254
|
+
{bad("email") ? fieldText("email") : ""}
|
|
255
|
+
</p>
|
|
256
|
+
</div>
|
|
257
|
+
|
|
258
|
+
{questions.length > 0 && (
|
|
259
|
+
<fieldset class="semics-questions" data-testid="booking-questions">
|
|
260
|
+
<legend>{t("widget.questions")}</legend>
|
|
261
|
+
<input type="hidden" name={QUESTIONS_MARKER} value="1" />
|
|
262
|
+
{questions.map((q) => (
|
|
263
|
+
<div class={q.kind === "checkbox" ? "semics-field semics-check" : "semics-field"}>
|
|
264
|
+
{q.kind === "checkbox" ? (
|
|
265
|
+
<>
|
|
266
|
+
<input
|
|
267
|
+
id={q.id}
|
|
268
|
+
type="checkbox"
|
|
269
|
+
name={q.name}
|
|
270
|
+
value="yes"
|
|
271
|
+
required={q.required}
|
|
272
|
+
data-question
|
|
273
|
+
data-field={q.field}
|
|
274
|
+
aria-invalid={q.invalid ? "true" : undefined}
|
|
275
|
+
aria-describedby={q.errorId}
|
|
276
|
+
/>
|
|
277
|
+
<label for={q.id}>
|
|
278
|
+
{q.label}
|
|
279
|
+
{q.hint && <span class="semics-hint"> {q.hint}</span>}
|
|
280
|
+
</label>
|
|
281
|
+
</>
|
|
282
|
+
) : (
|
|
283
|
+
<>
|
|
284
|
+
<label for={q.id}>
|
|
285
|
+
{q.label}
|
|
286
|
+
{q.hint && <span class="semics-hint"> {q.hint}</span>}
|
|
287
|
+
</label>
|
|
288
|
+
{q.kind === "select" ? (
|
|
289
|
+
<select
|
|
290
|
+
id={q.id}
|
|
291
|
+
name={q.name}
|
|
292
|
+
required={q.required}
|
|
293
|
+
data-question
|
|
294
|
+
data-field={q.field}
|
|
295
|
+
aria-invalid={q.invalid ? "true" : undefined}
|
|
296
|
+
aria-describedby={q.errorId}
|
|
297
|
+
>
|
|
298
|
+
{(q.options ?? []).map((o) => <option value={o.value}>{o.label}</option>)}
|
|
299
|
+
</select>
|
|
300
|
+
) : (
|
|
301
|
+
<input
|
|
302
|
+
id={q.id}
|
|
303
|
+
type="text"
|
|
304
|
+
name={q.name}
|
|
305
|
+
maxlength={String(q.maxLength)}
|
|
306
|
+
required={q.required}
|
|
307
|
+
data-question
|
|
308
|
+
data-field={q.field}
|
|
309
|
+
aria-invalid={q.invalid ? "true" : undefined}
|
|
310
|
+
aria-describedby={q.errorId}
|
|
311
|
+
/>
|
|
312
|
+
)}
|
|
313
|
+
</>
|
|
314
|
+
)}
|
|
315
|
+
<p class="semics-field-error" id={q.errorId} data-error-for={q.field} data-message={q.message}>
|
|
316
|
+
{q.invalid ? q.message : ""}
|
|
317
|
+
</p>
|
|
318
|
+
</div>
|
|
319
|
+
))}
|
|
320
|
+
</fieldset>
|
|
321
|
+
)}
|
|
322
|
+
|
|
323
|
+
<p class="semics-total" data-total data-testid="booking-total" hidden aria-live="polite">
|
|
324
|
+
{t("widget.total")} <strong data-total-value></strong>
|
|
325
|
+
</p>
|
|
326
|
+
|
|
327
|
+
{siteKey && (
|
|
328
|
+
<>
|
|
329
|
+
<div class="cf-turnstile" data-sitekey={siteKey}></div>
|
|
330
|
+
{/* Turnstile is 300 px wide; in a narrower widget use its compact size so a 320 px screen never scrolls sideways (WCAG 1.4.10). */}
|
|
331
|
+
<script is:inline>(function (s) { var t = s && s.previousElementSibling; if (t && t.clientWidth < 300) t.setAttribute("data-size", "compact"); })(document.currentScript);</script>
|
|
332
|
+
<noscript>
|
|
333
|
+
<p class="semics-needs-js" data-testid="booking-needs-js">{t("widget.needsJs")}</p>
|
|
334
|
+
</noscript>
|
|
335
|
+
<script is:inline src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
|
|
336
|
+
</>
|
|
337
|
+
)}
|
|
338
|
+
|
|
339
|
+
<button type="submit" disabled={siteKey ? true : undefined}>{t("widget.book")}</button>
|
|
340
|
+
</form>
|
|
341
|
+
{waitlist && (
|
|
342
|
+
<form method="post" action={WAITLIST_PATH} class="semics-waitlist" data-testid="waitlist-form" aria-labelledby={`${id}-wl-title`}>
|
|
343
|
+
<h3 id={`${id}-wl-title`}>{t("waitlist.heading")}</h3>
|
|
344
|
+
<p>{t("waitlist.intro")}</p>
|
|
345
|
+
{waitlistOutcome && (
|
|
346
|
+
<p role={waitlistOutcome === "joined" ? "status" : "alert"} data-testid="waitlist-outcome" data-code={waitlistOutcome}>
|
|
347
|
+
{waitlistMessage(waitlistOutcome, locale)}
|
|
348
|
+
</p>
|
|
349
|
+
)}
|
|
350
|
+
<input type="hidden" name="eventId" value={eventId} />
|
|
351
|
+
<input type="hidden" name="returnTo" value={returnTo} />
|
|
352
|
+
{waitlistDates.length > 0 && (
|
|
353
|
+
<div class="semics-field">
|
|
354
|
+
<label for={`${id}-wl-date`}>{t("widget.date")}</label>
|
|
355
|
+
<select id={`${id}-wl-date`} name="occurrenceId" required>
|
|
356
|
+
{waitlistDates.map((o) => <option value={o.id}>{when(o.startsAt)}</option>)}
|
|
357
|
+
</select>
|
|
358
|
+
</div>
|
|
359
|
+
)}
|
|
360
|
+
{ticketTypes.length > 1 && (
|
|
361
|
+
<div class="semics-field">
|
|
362
|
+
<label for={`${id}-wl-type`}>{t("waitlist.ticket")}</label>
|
|
363
|
+
<select id={`${id}-wl-type`} name="ticketTypeId">
|
|
364
|
+
<option value="">{t("waitlist.anyTicket")}</option>
|
|
365
|
+
{ticketTypes.map((type) => <option value={type.id}>{type.name}</option>)}
|
|
366
|
+
</select>
|
|
367
|
+
</div>
|
|
368
|
+
)}
|
|
369
|
+
<div class="semics-field">
|
|
370
|
+
<label for={`${id}-wl-qty`}>{t("widget.tickets")}</label>
|
|
371
|
+
<input id={`${id}-wl-qty`} name="qty" type="number" inputmode="numeric" min="1" max="10" value="1" required />
|
|
372
|
+
</div>
|
|
373
|
+
<div class="semics-field">
|
|
374
|
+
<label for={`${id}-wl-name`}>{t("widget.name")}</label>
|
|
375
|
+
<input id={`${id}-wl-name`} name="name" type="text" autocomplete="name" required maxlength="200" />
|
|
376
|
+
</div>
|
|
377
|
+
<div class="semics-field">
|
|
378
|
+
<label for={`${id}-wl-email`}>{t("widget.email")}</label>
|
|
379
|
+
<input id={`${id}-wl-email`} name="email" type="email" autocomplete="email" required maxlength="254" />
|
|
380
|
+
</div>
|
|
381
|
+
{siteKey && (
|
|
382
|
+
<>
|
|
383
|
+
<div class="cf-turnstile" data-sitekey={siteKey}></div>
|
|
384
|
+
<script is:inline>(function (s) { var t = s && s.previousElementSibling; if (t && t.clientWidth < 300) t.setAttribute("data-size", "compact"); })(document.currentScript);</script>
|
|
385
|
+
</>
|
|
386
|
+
)}
|
|
387
|
+
<button type="submit" class="semics-secondary">{t("waitlist.button")}</button>
|
|
388
|
+
</form>
|
|
389
|
+
)}
|
|
390
|
+
</>
|
|
391
|
+
)
|
|
392
|
+
}
|
|
393
|
+
</section>
|
|
394
|
+
|
|
395
|
+
<script>
|
|
396
|
+
import "../client/booking.ts";
|
|
397
|
+
</script>
|
|
398
|
+
|
|
399
|
+
<style>
|
|
400
|
+
.semics-booking-widget {
|
|
401
|
+
--_fg: var(--events-fg, #1a1a1a);
|
|
402
|
+
--_muted: var(--events-muted, #4a4a4a);
|
|
403
|
+
--_bg: var(--events-bg, #ffffff);
|
|
404
|
+
--_border: var(--events-border, #6b6b6b);
|
|
405
|
+
--_accent: var(--events-accent, #0b57d0);
|
|
406
|
+
--_accent-fg: var(--events-accent-fg, #ffffff);
|
|
407
|
+
--_error: var(--events-error, #b3261e);
|
|
408
|
+
--_radius: var(--events-radius, 6px);
|
|
409
|
+
box-sizing: border-box;
|
|
410
|
+
max-inline-size: 36rem;
|
|
411
|
+
padding: 1rem;
|
|
412
|
+
border: 1px solid var(--_border);
|
|
413
|
+
border-radius: var(--_radius);
|
|
414
|
+
background: var(--_bg);
|
|
415
|
+
color: var(--_fg);
|
|
416
|
+
overflow-wrap: anywhere;
|
|
417
|
+
}
|
|
418
|
+
.semics-booking-widget *,
|
|
419
|
+
.semics-booking-widget *::before,
|
|
420
|
+
.semics-booking-widget *::after {
|
|
421
|
+
box-sizing: border-box;
|
|
422
|
+
}
|
|
423
|
+
.semics-booking-widget h2 {
|
|
424
|
+
margin: 0 0 0.75rem;
|
|
425
|
+
font-size: 1.25rem;
|
|
426
|
+
}
|
|
427
|
+
.semics-booking-widget form {
|
|
428
|
+
display: grid;
|
|
429
|
+
grid-template-columns: minmax(0, 1fr);
|
|
430
|
+
gap: 0.75rem;
|
|
431
|
+
}
|
|
432
|
+
.semics-booking-widget .semics-waitlist {
|
|
433
|
+
margin-block-start: 1.25rem;
|
|
434
|
+
padding-block-start: 1rem;
|
|
435
|
+
border-block-start: 1px solid var(--_border);
|
|
436
|
+
}
|
|
437
|
+
.semics-waitlist h3,
|
|
438
|
+
.semics-waitlist p {
|
|
439
|
+
margin: 0;
|
|
440
|
+
}
|
|
441
|
+
.semics-tickets {
|
|
442
|
+
margin: 0;
|
|
443
|
+
padding: 0.5rem 0.75rem;
|
|
444
|
+
border: 1px solid var(--_border);
|
|
445
|
+
border-radius: var(--_radius);
|
|
446
|
+
min-inline-size: 0;
|
|
447
|
+
}
|
|
448
|
+
.semics-questions {
|
|
449
|
+
display: grid;
|
|
450
|
+
gap: 0.75rem;
|
|
451
|
+
margin: 0;
|
|
452
|
+
padding: 0.5rem 0.75rem 0.75rem;
|
|
453
|
+
border: 1px solid var(--_border);
|
|
454
|
+
border-radius: var(--_radius);
|
|
455
|
+
min-inline-size: 0;
|
|
456
|
+
}
|
|
457
|
+
.semics-check {
|
|
458
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
459
|
+
align-items: center;
|
|
460
|
+
column-gap: 0.5rem;
|
|
461
|
+
}
|
|
462
|
+
.semics-check .semics-field-error {
|
|
463
|
+
grid-column: 1 / -1;
|
|
464
|
+
}
|
|
465
|
+
.semics-booking-widget .semics-check input {
|
|
466
|
+
min-block-size: 1.25rem;
|
|
467
|
+
inline-size: 1.25rem;
|
|
468
|
+
margin: 0;
|
|
469
|
+
}
|
|
470
|
+
.semics-hint {
|
|
471
|
+
color: var(--_muted);
|
|
472
|
+
}
|
|
473
|
+
.semics-ticket {
|
|
474
|
+
display: flex;
|
|
475
|
+
flex-wrap: wrap;
|
|
476
|
+
align-items: center;
|
|
477
|
+
justify-content: space-between;
|
|
478
|
+
gap: 0.5rem;
|
|
479
|
+
padding-block: 0.25rem;
|
|
480
|
+
}
|
|
481
|
+
.semics-ticket label {
|
|
482
|
+
display: flex;
|
|
483
|
+
flex-wrap: wrap;
|
|
484
|
+
gap: 0 0.5rem;
|
|
485
|
+
flex: 1 1 10rem;
|
|
486
|
+
min-inline-size: 0;
|
|
487
|
+
}
|
|
488
|
+
.semics-ticket-price,
|
|
489
|
+
.semics-ticket-soldout {
|
|
490
|
+
color: var(--_muted);
|
|
491
|
+
}
|
|
492
|
+
.semics-ticket input {
|
|
493
|
+
inline-size: 5rem;
|
|
494
|
+
}
|
|
495
|
+
.semics-field {
|
|
496
|
+
display: grid;
|
|
497
|
+
grid-template-columns: minmax(0, 1fr);
|
|
498
|
+
gap: 0.25rem;
|
|
499
|
+
}
|
|
500
|
+
.semics-field select {
|
|
501
|
+
inline-size: 100%;
|
|
502
|
+
}
|
|
503
|
+
.semics-booking-widget input,
|
|
504
|
+
.semics-booking-widget select,
|
|
505
|
+
.semics-booking-widget button {
|
|
506
|
+
font: inherit;
|
|
507
|
+
min-block-size: 2.75rem;
|
|
508
|
+
max-inline-size: 100%;
|
|
509
|
+
}
|
|
510
|
+
.semics-booking-widget input,
|
|
511
|
+
.semics-booking-widget select {
|
|
512
|
+
padding: 0.375rem 0.5rem;
|
|
513
|
+
border: 1px solid var(--_border);
|
|
514
|
+
border-radius: var(--_radius);
|
|
515
|
+
background: var(--_bg);
|
|
516
|
+
color: var(--_fg);
|
|
517
|
+
}
|
|
518
|
+
.semics-booking-widget [aria-invalid="true"] {
|
|
519
|
+
border-color: var(--_error);
|
|
520
|
+
outline: 1px solid var(--_error);
|
|
521
|
+
}
|
|
522
|
+
.semics-field-error,
|
|
523
|
+
.semics-form-alert {
|
|
524
|
+
margin: 0;
|
|
525
|
+
color: var(--_error);
|
|
526
|
+
}
|
|
527
|
+
.semics-field-error:empty {
|
|
528
|
+
display: none;
|
|
529
|
+
}
|
|
530
|
+
.semics-form-alert {
|
|
531
|
+
padding: 0.5rem 0.75rem;
|
|
532
|
+
border: 1px solid var(--_error);
|
|
533
|
+
border-radius: var(--_radius);
|
|
534
|
+
}
|
|
535
|
+
.semics-needs-js {
|
|
536
|
+
margin: 0;
|
|
537
|
+
font-weight: 600;
|
|
538
|
+
}
|
|
539
|
+
.semics-total {
|
|
540
|
+
margin: 0;
|
|
541
|
+
}
|
|
542
|
+
.semics-booking-widget button {
|
|
543
|
+
justify-self: start;
|
|
544
|
+
padding: 0.5rem 1.5rem;
|
|
545
|
+
border: 0;
|
|
546
|
+
border-radius: var(--_radius);
|
|
547
|
+
background: var(--_accent);
|
|
548
|
+
color: var(--_accent-fg);
|
|
549
|
+
cursor: pointer;
|
|
550
|
+
}
|
|
551
|
+
.semics-promo-row {
|
|
552
|
+
display: flex;
|
|
553
|
+
flex-wrap: wrap;
|
|
554
|
+
gap: 0.5rem;
|
|
555
|
+
}
|
|
556
|
+
.semics-promo-row input {
|
|
557
|
+
flex: 1 1 10rem;
|
|
558
|
+
min-inline-size: 0;
|
|
559
|
+
}
|
|
560
|
+
.semics-booking-widget button.semics-secondary {
|
|
561
|
+
padding-inline: 1rem;
|
|
562
|
+
border: 1px solid var(--_accent);
|
|
563
|
+
background: var(--_bg);
|
|
564
|
+
color: var(--_accent);
|
|
565
|
+
}
|
|
566
|
+
.semics-promo-note {
|
|
567
|
+
margin: 0;
|
|
568
|
+
color: var(--_muted);
|
|
569
|
+
}
|
|
570
|
+
.semics-booking-widget button:disabled {
|
|
571
|
+
opacity: 0.6;
|
|
572
|
+
cursor: not-allowed;
|
|
573
|
+
}
|
|
574
|
+
.semics-booking-widget :focus-visible {
|
|
575
|
+
outline: 3px solid var(--_accent);
|
|
576
|
+
outline-offset: 2px;
|
|
577
|
+
}
|
|
578
|
+
[hidden] {
|
|
579
|
+
display: none !important;
|
|
580
|
+
}
|
|
581
|
+
</style>
|