@semics-tech/emdash-events 0.0.0-stage → 1.0.0-rc.1
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 +83 -2
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +416 -0
- package/dist/manifest.json +425 -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 +222 -0
- package/package.json +78 -3
- package/src/astro/AddToCalendar.astro +47 -0
- package/src/astro/AttendeeList.astro +157 -0
- package/src/astro/BookingBlock.astro +30 -0
- package/src/astro/BookingPage.astro +230 -0
- package/src/astro/BookingStatus.astro +112 -0
- package/src/astro/BookingWidget.astro +776 -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/attendees.ts +170 -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/picker.ts +245 -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 +299 -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 +190 -0
- package/src/client/checkin.ts +260 -0
- package/src/client/payment.ts +76 -0
- package/src/client/picker.ts +143 -0
- package/src/client/receipt.ts +75 -0
- package/src/i18n/ar.ts +251 -0
- package/src/i18n/en.ts +255 -0
- package/src/i18n/index.ts +121 -0
|
@@ -0,0 +1,776 @@
|
|
|
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 { pickerFetchFrom, pickerHref, pickerParam, pickerView, usesPicker } from "./lib/picker";
|
|
12
|
+
import { PROMO_PATH, type PromoView, promoCookieName, promoView } from "./lib/promo";
|
|
13
|
+
import { QUESTIONS_MARKER, questionControls } from "./lib/questions";
|
|
14
|
+
import { readWaitlistState, WAITLIST_PATH, waitlistMessage } from "./lib/waitlist";
|
|
15
|
+
import {
|
|
16
|
+
anchorId,
|
|
17
|
+
errorMessage,
|
|
18
|
+
fieldMessage,
|
|
19
|
+
formatMoney,
|
|
20
|
+
newIdempotencyKey,
|
|
21
|
+
type PublicEvent,
|
|
22
|
+
readWidgetState,
|
|
23
|
+
safeReturnTo,
|
|
24
|
+
type WidgetField,
|
|
25
|
+
} from "./lib/widget";
|
|
26
|
+
|
|
27
|
+
interface Props {
|
|
28
|
+
/** The event's content entry id. */
|
|
29
|
+
event: string;
|
|
30
|
+
/** The `public/event` answer, when the page already has it. */
|
|
31
|
+
data?: PublicEvent;
|
|
32
|
+
heading?: string;
|
|
33
|
+
/** Overrides the site key from `public/event`. */
|
|
34
|
+
turnstileSiteKey?: string;
|
|
35
|
+
locale?: string;
|
|
36
|
+
/** The applied promo code's view, when the page already has it (`null`: none). */
|
|
37
|
+
promo?: PromoView | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const { event: eventId } = Astro.props;
|
|
41
|
+
// The language: the `locale` prop, else the page's (Astro i18n), else British English (T102).
|
|
42
|
+
const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
|
|
43
|
+
const { t, lang, dir } = translator(locale);
|
|
44
|
+
const heading = Astro.props.heading ?? t("widget.heading");
|
|
45
|
+
const fieldText = (field: Parameters<typeof fieldMessage>[0]) => fieldMessage(field, locale);
|
|
46
|
+
let data = Astro.props.data;
|
|
47
|
+
// The day-then-time picker's page (T130): the first local day it shows, from this widget's own
|
|
48
|
+
// `booking_from.<eventId>` (T134: another picker on the page keeps its month).
|
|
49
|
+
const pickerStart = Astro.url.searchParams.get(pickerParam(eventId));
|
|
50
|
+
if (!data) {
|
|
51
|
+
const from = pickerFetchFrom(pickerStart);
|
|
52
|
+
const result = await callPublicRoute<PublicEvent>(Astro, {
|
|
53
|
+
path: "public/event",
|
|
54
|
+
pluginId,
|
|
55
|
+
body: { eventId, ...(from ? { from } : {}) },
|
|
56
|
+
});
|
|
57
|
+
if (result.ok) data = result.data;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const id = anchorId(eventId);
|
|
61
|
+
// Promo codes are Events Pro's (T078): the field shows only when the core says it takes them. An
|
|
62
|
+
// applied code lives in an HttpOnly cookie (`/_events/promo`), never the URL, and is checked again here.
|
|
63
|
+
const takesCodes = data?.promoCodes === true;
|
|
64
|
+
let promo: PromoView | null = Astro.props.promo ?? null;
|
|
65
|
+
if (takesCodes && Astro.props.promo === undefined) {
|
|
66
|
+
let code = "";
|
|
67
|
+
try {
|
|
68
|
+
code = Astro.cookies.get(promoCookieName(eventId))?.value ?? "";
|
|
69
|
+
} catch {
|
|
70
|
+
// A prerendered page has no cookies.
|
|
71
|
+
}
|
|
72
|
+
if (code) promo = await promoView(Astro, { eventId, code, currency: data?.currency, locale }, { pluginId });
|
|
73
|
+
}
|
|
74
|
+
const promoForm = `${id}-promo-form`;
|
|
75
|
+
const siteKey = Astro.props.turnstileSiteKey ?? data?.turnstileSiteKey ?? "";
|
|
76
|
+
const state = readWidgetState(Astro.url, eventId);
|
|
77
|
+
const returnTo = safeReturnTo(`${Astro.url.pathname}${Astro.url.search}`, Astro.url.origin) ?? "";
|
|
78
|
+
const occurrences = data?.occurrences ?? [];
|
|
79
|
+
const listed = new Set((data?.ticketTypes ?? []).map((t) => t.id));
|
|
80
|
+
// An unlock code's hidden types join the list (reserve checks the code again before it sells them).
|
|
81
|
+
const ticketTypes = [
|
|
82
|
+
...(data?.ticketTypes ?? []),
|
|
83
|
+
...(takesCodes ? (promo?.hiddenTypes ?? []) : []).filter((t) => !listed.has(t.id)),
|
|
84
|
+
] as PublicEvent["ticketTypes"];
|
|
85
|
+
const onSale = data?.status === "on_sale" && ticketTypes.length > 0;
|
|
86
|
+
// Many dates a day, or a slot schedule (T130): a month calendar of days, then the day's times. Without
|
|
87
|
+
// JavaScript the same month's dates show as a select grouped by day.
|
|
88
|
+
const zone = data?.timezone ?? "UTC";
|
|
89
|
+
const picker = usesPicker(data, zone)
|
|
90
|
+
? pickerView(occurrences, { zone, locale, start: pickerStart, now: Date.now(), more: data?.more === true })
|
|
91
|
+
: null;
|
|
92
|
+
const pickerIds = new Set(picker?.days.flatMap((d) => d.slots.map((s) => s.id)));
|
|
93
|
+
const monthId = `${id}-month`;
|
|
94
|
+
// The waitlist (T081): offered when the core takes one and the tickets, or some dates, are sold out.
|
|
95
|
+
const fullDates = occurrences.filter((o) => o.available === 0 && (!picker || pickerIds.has(o.id)));
|
|
96
|
+
const waitlist =
|
|
97
|
+
onSale &&
|
|
98
|
+
data?.waitlist === true &&
|
|
99
|
+
(ticketTypes.every((t) => t.available === 0) || fullDates.length > 0);
|
|
100
|
+
const waitlistDates = ticketTypes.every((t) => t.available === 0)
|
|
101
|
+
? occurrences.filter((o) => !picker || pickerIds.has(o.id))
|
|
102
|
+
: fullDates;
|
|
103
|
+
const waitlistOutcome = readWaitlistState(Astro.url, eventId);
|
|
104
|
+
// Custom attendee questions are Events Pro's (T080): `public/event` lists them only on a Pro core.
|
|
105
|
+
const questions = questionControls(data?.questions, id, state.fields, locale);
|
|
106
|
+
const bad = (field: WidgetField) => state.fields.includes(field);
|
|
107
|
+
const errId = (field: WidgetField) => `${id}-${field}-error`;
|
|
108
|
+
const invalid = (field: WidgetField) => (bad(field) ? "true" : undefined);
|
|
109
|
+
const formAlert = state.code ? errorMessage(state.code, locale) : "";
|
|
110
|
+
const when = (iso: string) => {
|
|
111
|
+
const options = { dateStyle: "full", timeStyle: "short" } as const;
|
|
112
|
+
try {
|
|
113
|
+
return new Intl.DateTimeFormat(locale, { ...options, timeZone: data?.timezone ?? "UTC" }).format(new Date(iso));
|
|
114
|
+
} catch {
|
|
115
|
+
return new Intl.DateTimeFormat(locale, { ...options, timeZone: "UTC" }).format(new Date(iso));
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
---
|
|
119
|
+
<section id={id} class="semics-events semics-booking-widget" lang={lang} dir={dir} aria-labelledby={`${id}-title`} data-testid="booking-widget">
|
|
120
|
+
<h2 id={`${id}-title`}>{heading}</h2>
|
|
121
|
+
{
|
|
122
|
+
!onSale ? (
|
|
123
|
+
<p data-testid="booking-unavailable">{t("widget.unavailable")}</p>
|
|
124
|
+
) : (
|
|
125
|
+
<>
|
|
126
|
+
{takesCodes && (
|
|
127
|
+
<form id={promoForm} method="post" action={PROMO_PATH} hidden>
|
|
128
|
+
<input type="hidden" name="eventId" value={eventId} />
|
|
129
|
+
<input type="hidden" name="returnTo" value={returnTo} />
|
|
130
|
+
</form>
|
|
131
|
+
)}
|
|
132
|
+
<form
|
|
133
|
+
method="post"
|
|
134
|
+
action={CHECKOUT_PATH}
|
|
135
|
+
data-semics-booking
|
|
136
|
+
data-currency={data?.currency}
|
|
137
|
+
data-locale={locale}
|
|
138
|
+
data-free={t("money.free")}
|
|
139
|
+
data-turnstile={siteKey ? "on" : undefined}
|
|
140
|
+
data-turnstile-message={siteKey ? t("widget.turnstile") : undefined}
|
|
141
|
+
>
|
|
142
|
+
<p class="semics-form-alert" role="alert" data-form-alert hidden={!formAlert}>{formAlert}</p>
|
|
143
|
+
<input type="hidden" name="eventId" value={eventId} />
|
|
144
|
+
<input type="hidden" name="returnTo" value={returnTo} />
|
|
145
|
+
<input type="hidden" name="idempotencyKey" value={newIdempotencyKey()} />
|
|
146
|
+
|
|
147
|
+
{picker && (
|
|
148
|
+
<div class="semics-field semics-picker-field">
|
|
149
|
+
<input type="hidden" name="needsOccurrence" value="1" />
|
|
150
|
+
<div class="semics-field" data-picker-fallback>
|
|
151
|
+
<label for={`${id}-occurrence`}>{t("widget.date")}</label>
|
|
152
|
+
<select
|
|
153
|
+
id={`${id}-occurrence`}
|
|
154
|
+
name="occurrenceId"
|
|
155
|
+
required
|
|
156
|
+
aria-invalid={invalid("occurrence")}
|
|
157
|
+
aria-describedby={[monthId, errId("occurrence")].join(" ")}
|
|
158
|
+
>
|
|
159
|
+
<option value="">{t("widget.chooseDate")}</option>
|
|
160
|
+
{picker.days.map((day) => (
|
|
161
|
+
<optgroup label={day.label}>
|
|
162
|
+
{day.slots.map((s) => (
|
|
163
|
+
<option value={s.id} disabled={s.full}>{s.label}</option>
|
|
164
|
+
))}
|
|
165
|
+
</optgroup>
|
|
166
|
+
))}
|
|
167
|
+
</select>
|
|
168
|
+
</div>
|
|
169
|
+
<nav class="semics-picker-nav" aria-labelledby={monthId}>
|
|
170
|
+
<p id={monthId} class="semics-picker-month">{picker.month.label}</p>
|
|
171
|
+
{picker.prev && <a href={pickerHref(Astro.url, picker.prev, eventId)} rel="nofollow">{t("widget.picker.earlier")}</a>}
|
|
172
|
+
{picker.next && <a href={pickerHref(Astro.url, picker.next, eventId)} rel="nofollow">{t("widget.picker.later")}</a>}
|
|
173
|
+
</nav>
|
|
174
|
+
{picker.days.length === 0 && <p data-testid="picker-none">{t("widget.picker.none")}</p>}
|
|
175
|
+
<fieldset
|
|
176
|
+
class="semics-picker"
|
|
177
|
+
data-picker
|
|
178
|
+
data-field="occurrence"
|
|
179
|
+
data-testid="booking-picker"
|
|
180
|
+
hidden
|
|
181
|
+
aria-invalid={invalid("occurrence")}
|
|
182
|
+
aria-describedby={errId("occurrence")}
|
|
183
|
+
>
|
|
184
|
+
<legend>{t("widget.date")}</legend>
|
|
185
|
+
<table role="grid" class="semics-calendar" aria-labelledby={monthId}>
|
|
186
|
+
<thead>
|
|
187
|
+
<tr>
|
|
188
|
+
{picker.weekdays.map((w) => (
|
|
189
|
+
<th scope="col" abbr={w.long}>{w.short}</th>
|
|
190
|
+
))}
|
|
191
|
+
</tr>
|
|
192
|
+
</thead>
|
|
193
|
+
<tbody>
|
|
194
|
+
{picker.weeks.map((week) => (
|
|
195
|
+
<tr>
|
|
196
|
+
{week.map((cell) => (
|
|
197
|
+
<td>
|
|
198
|
+
{cell && cell.slots.length > 0 ? (
|
|
199
|
+
<button
|
|
200
|
+
type="button"
|
|
201
|
+
class={cell.open ? undefined : "semics-day-full"}
|
|
202
|
+
data-day={cell.key}
|
|
203
|
+
data-n={String(cell.day)}
|
|
204
|
+
aria-label={cell.buttonLabel}
|
|
205
|
+
aria-pressed="false"
|
|
206
|
+
tabindex={cell.key === picker.focusDay ? "0" : "-1"}
|
|
207
|
+
>
|
|
208
|
+
{cell.day}
|
|
209
|
+
</button>
|
|
210
|
+
) : cell ? (
|
|
211
|
+
<span class="semics-day-none">{cell.day}</span>
|
|
212
|
+
) : null}
|
|
213
|
+
</td>
|
|
214
|
+
))}
|
|
215
|
+
</tr>
|
|
216
|
+
))}
|
|
217
|
+
</tbody>
|
|
218
|
+
</table>
|
|
219
|
+
<p class="semics-hint" data-picker-hint>{t("widget.picker.hint")}</p>
|
|
220
|
+
{picker.days.map((day) => (
|
|
221
|
+
<div class="semics-times" role="radiogroup" data-times={day.key} aria-label={t("widget.picker.times", { date: day.label })} hidden>
|
|
222
|
+
{day.slots.map((s, i) => (
|
|
223
|
+
<button
|
|
224
|
+
type="button"
|
|
225
|
+
role="radio"
|
|
226
|
+
aria-checked="false"
|
|
227
|
+
aria-disabled={s.full ? "true" : undefined}
|
|
228
|
+
aria-label={s.label}
|
|
229
|
+
data-occurrence={s.id}
|
|
230
|
+
tabindex={i === day.slots.findIndex((x) => !x.full) ? "0" : "-1"}
|
|
231
|
+
>
|
|
232
|
+
<span>{s.time}</span>
|
|
233
|
+
{s.places && <span class="semics-places">{s.places}</span>}
|
|
234
|
+
</button>
|
|
235
|
+
))}
|
|
236
|
+
</div>
|
|
237
|
+
))}
|
|
238
|
+
</fieldset>
|
|
239
|
+
<p class="semics-field-error" id={errId("occurrence")} data-error-for="occurrence" data-message={fieldText("occurrence")}>
|
|
240
|
+
{bad("occurrence") ? fieldText("occurrence") : ""}
|
|
241
|
+
</p>
|
|
242
|
+
</div>
|
|
243
|
+
)}
|
|
244
|
+
|
|
245
|
+
{!picker && occurrences.length > 0 && (
|
|
246
|
+
<div class="semics-field">
|
|
247
|
+
<input type="hidden" name="needsOccurrence" value="1" />
|
|
248
|
+
<label for={`${id}-occurrence`}>{t("widget.date")}</label>
|
|
249
|
+
<select
|
|
250
|
+
id={`${id}-occurrence`}
|
|
251
|
+
name="occurrenceId"
|
|
252
|
+
required
|
|
253
|
+
data-field="occurrence"
|
|
254
|
+
aria-invalid={invalid("occurrence")}
|
|
255
|
+
aria-describedby={errId("occurrence")}
|
|
256
|
+
>
|
|
257
|
+
<option value="">{t("widget.chooseDate")}</option>
|
|
258
|
+
{occurrences.map((o) => (
|
|
259
|
+
<option value={o.id} disabled={o.available === 0}>
|
|
260
|
+
{o.available === 0 ? t("widget.dateSoldOut", { date: when(o.startsAt) }) : when(o.startsAt)}
|
|
261
|
+
</option>
|
|
262
|
+
))}
|
|
263
|
+
</select>
|
|
264
|
+
<p class="semics-field-error" id={errId("occurrence")} data-error-for="occurrence" data-message={fieldText("occurrence")}>
|
|
265
|
+
{bad("occurrence") ? fieldText("occurrence") : ""}
|
|
266
|
+
</p>
|
|
267
|
+
</div>
|
|
268
|
+
)}
|
|
269
|
+
|
|
270
|
+
{takesCodes && (
|
|
271
|
+
<div class="semics-field semics-promo">
|
|
272
|
+
{promo && <input type="hidden" name="promoCode" value={promo.code} />}
|
|
273
|
+
<label for={`${id}-promo`}>{t("widget.promo.label")}</label>
|
|
274
|
+
<div class="semics-promo-row">
|
|
275
|
+
<input
|
|
276
|
+
id={`${id}-promo`}
|
|
277
|
+
form={promoForm}
|
|
278
|
+
name="promoCode"
|
|
279
|
+
type="text"
|
|
280
|
+
autocomplete="off"
|
|
281
|
+
autocapitalize="characters"
|
|
282
|
+
spellcheck="false"
|
|
283
|
+
maxlength="60"
|
|
284
|
+
value={promo?.code ?? ""}
|
|
285
|
+
data-field="promo"
|
|
286
|
+
aria-invalid={invalid("promo")}
|
|
287
|
+
aria-describedby={`${errId("promo")}${promo ? ` ${id}-promo-note` : ""}`}
|
|
288
|
+
/>
|
|
289
|
+
<button type="submit" form={promoForm} class="semics-secondary" data-promo-apply>
|
|
290
|
+
{promo ? t("widget.promo.update") : t("widget.promo.apply")}
|
|
291
|
+
</button>
|
|
292
|
+
</div>
|
|
293
|
+
<p class="semics-field-error" id={errId("promo")} data-error-for="promo" data-message={fieldText("promo")}>
|
|
294
|
+
{bad("promo") ? fieldText("promo") : ""}
|
|
295
|
+
</p>
|
|
296
|
+
{promo && (
|
|
297
|
+
<p class="semics-promo-note" id={`${id}-promo-note`} data-testid="promo-note">
|
|
298
|
+
{promo.note}
|
|
299
|
+
</p>
|
|
300
|
+
)}
|
|
301
|
+
</div>
|
|
302
|
+
)}
|
|
303
|
+
|
|
304
|
+
<fieldset class="semics-tickets" data-field="tickets" aria-invalid={invalid("tickets")} aria-describedby={errId("tickets")}>
|
|
305
|
+
<legend>{t("widget.tickets")}</legend>
|
|
306
|
+
{ticketTypes.map((type) => {
|
|
307
|
+
const soldOut = type.available === 0;
|
|
308
|
+
const max = Math.min(type.maxPerOrder ?? 50, type.available ?? 50, 50);
|
|
309
|
+
return (
|
|
310
|
+
<div class="semics-ticket">
|
|
311
|
+
<label for={`${id}-qty-${type.id}`}>
|
|
312
|
+
<span class="semics-ticket-name">{type.name}</span>
|
|
313
|
+
<span class="semics-ticket-price">{formatMoney(type.priceMinor, data?.currency ?? "GBP", locale)}</span>
|
|
314
|
+
{soldOut && <span class="semics-ticket-soldout">{t("widget.soldOut")}</span>}
|
|
315
|
+
</label>
|
|
316
|
+
<input
|
|
317
|
+
id={`${id}-qty-${type.id}`}
|
|
318
|
+
type="number"
|
|
319
|
+
inputmode="numeric"
|
|
320
|
+
name={`${QTY_PREFIX}${type.id}`}
|
|
321
|
+
value="0"
|
|
322
|
+
min="0"
|
|
323
|
+
max={String(max)}
|
|
324
|
+
disabled={soldOut}
|
|
325
|
+
data-price-minor={String(type.priceMinor)}
|
|
326
|
+
/>
|
|
327
|
+
</div>
|
|
328
|
+
);
|
|
329
|
+
})}
|
|
330
|
+
<p class="semics-field-error" id={errId("tickets")} data-error-for="tickets" data-message={fieldText("tickets")}>
|
|
331
|
+
{bad("tickets") ? fieldText("tickets") : ""}
|
|
332
|
+
</p>
|
|
333
|
+
</fieldset>
|
|
334
|
+
|
|
335
|
+
<div class="semics-field">
|
|
336
|
+
<label for={`${id}-name`}>{t("widget.name")}</label>
|
|
337
|
+
<input
|
|
338
|
+
id={`${id}-name`}
|
|
339
|
+
name="name"
|
|
340
|
+
type="text"
|
|
341
|
+
autocomplete="name"
|
|
342
|
+
required
|
|
343
|
+
maxlength="200"
|
|
344
|
+
data-field="name"
|
|
345
|
+
aria-invalid={invalid("name")}
|
|
346
|
+
aria-describedby={errId("name")}
|
|
347
|
+
/>
|
|
348
|
+
<p class="semics-field-error" id={errId("name")} data-error-for="name" data-message={fieldText("name")}>
|
|
349
|
+
{bad("name") ? fieldText("name") : ""}
|
|
350
|
+
</p>
|
|
351
|
+
</div>
|
|
352
|
+
|
|
353
|
+
<div class="semics-field">
|
|
354
|
+
<label for={`${id}-email`}>{t("widget.email")}</label>
|
|
355
|
+
<input
|
|
356
|
+
id={`${id}-email`}
|
|
357
|
+
name="email"
|
|
358
|
+
type="email"
|
|
359
|
+
autocomplete="email"
|
|
360
|
+
required
|
|
361
|
+
maxlength="254"
|
|
362
|
+
data-field="email"
|
|
363
|
+
aria-invalid={invalid("email")}
|
|
364
|
+
aria-describedby={errId("email")}
|
|
365
|
+
/>
|
|
366
|
+
<p class="semics-field-error" id={errId("email")} data-error-for="email" data-message={fieldText("email")}>
|
|
367
|
+
{bad("email") ? fieldText("email") : ""}
|
|
368
|
+
</p>
|
|
369
|
+
</div>
|
|
370
|
+
|
|
371
|
+
{questions.length > 0 && (
|
|
372
|
+
<fieldset class="semics-questions" data-testid="booking-questions">
|
|
373
|
+
<legend>{t("widget.questions")}</legend>
|
|
374
|
+
<input type="hidden" name={QUESTIONS_MARKER} value="1" />
|
|
375
|
+
{questions.map((q) => (
|
|
376
|
+
<div class={q.kind === "checkbox" ? "semics-field semics-check" : "semics-field"}>
|
|
377
|
+
{q.kind === "checkbox" ? (
|
|
378
|
+
<>
|
|
379
|
+
<input
|
|
380
|
+
id={q.id}
|
|
381
|
+
type="checkbox"
|
|
382
|
+
name={q.name}
|
|
383
|
+
value="yes"
|
|
384
|
+
required={q.required}
|
|
385
|
+
data-question
|
|
386
|
+
data-field={q.field}
|
|
387
|
+
aria-invalid={q.invalid ? "true" : undefined}
|
|
388
|
+
aria-describedby={q.errorId}
|
|
389
|
+
/>
|
|
390
|
+
<label for={q.id}>
|
|
391
|
+
{q.label}
|
|
392
|
+
{q.hint && <span class="semics-hint"> {q.hint}</span>}
|
|
393
|
+
</label>
|
|
394
|
+
</>
|
|
395
|
+
) : (
|
|
396
|
+
<>
|
|
397
|
+
<label for={q.id}>
|
|
398
|
+
{q.label}
|
|
399
|
+
{q.hint && <span class="semics-hint"> {q.hint}</span>}
|
|
400
|
+
</label>
|
|
401
|
+
{q.kind === "select" ? (
|
|
402
|
+
<select
|
|
403
|
+
id={q.id}
|
|
404
|
+
name={q.name}
|
|
405
|
+
required={q.required}
|
|
406
|
+
data-question
|
|
407
|
+
data-field={q.field}
|
|
408
|
+
aria-invalid={q.invalid ? "true" : undefined}
|
|
409
|
+
aria-describedby={q.errorId}
|
|
410
|
+
>
|
|
411
|
+
{(q.options ?? []).map((o) => <option value={o.value}>{o.label}</option>)}
|
|
412
|
+
</select>
|
|
413
|
+
) : (
|
|
414
|
+
<input
|
|
415
|
+
id={q.id}
|
|
416
|
+
type="text"
|
|
417
|
+
name={q.name}
|
|
418
|
+
maxlength={String(q.maxLength)}
|
|
419
|
+
required={q.required}
|
|
420
|
+
data-question
|
|
421
|
+
data-field={q.field}
|
|
422
|
+
aria-invalid={q.invalid ? "true" : undefined}
|
|
423
|
+
aria-describedby={q.errorId}
|
|
424
|
+
/>
|
|
425
|
+
)}
|
|
426
|
+
</>
|
|
427
|
+
)}
|
|
428
|
+
<p class="semics-field-error" id={q.errorId} data-error-for={q.field} data-message={q.message}>
|
|
429
|
+
{q.invalid ? q.message : ""}
|
|
430
|
+
</p>
|
|
431
|
+
</div>
|
|
432
|
+
))}
|
|
433
|
+
</fieldset>
|
|
434
|
+
)}
|
|
435
|
+
|
|
436
|
+
<p class="semics-total" data-total data-testid="booking-total" hidden aria-live="polite">
|
|
437
|
+
{t("widget.total")} <strong data-total-value></strong>
|
|
438
|
+
</p>
|
|
439
|
+
|
|
440
|
+
{siteKey && (
|
|
441
|
+
<>
|
|
442
|
+
<div class="cf-turnstile" data-sitekey={siteKey}></div>
|
|
443
|
+
{/* 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). */}
|
|
444
|
+
<script is:inline>(function (s) { var t = s && s.previousElementSibling; if (t && t.clientWidth < 300) t.setAttribute("data-size", "compact"); })(document.currentScript);</script>
|
|
445
|
+
<noscript>
|
|
446
|
+
<p class="semics-needs-js" data-testid="booking-needs-js">{t("widget.needsJs")}</p>
|
|
447
|
+
</noscript>
|
|
448
|
+
<script is:inline src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
|
|
449
|
+
</>
|
|
450
|
+
)}
|
|
451
|
+
|
|
452
|
+
<button type="submit" disabled={siteKey ? true : undefined}>{t("widget.book")}</button>
|
|
453
|
+
</form>
|
|
454
|
+
{waitlist && (
|
|
455
|
+
<form method="post" action={WAITLIST_PATH} class="semics-waitlist" data-testid="waitlist-form" aria-labelledby={`${id}-wl-title`}>
|
|
456
|
+
<h3 id={`${id}-wl-title`}>{t("waitlist.heading")}</h3>
|
|
457
|
+
<p>{t("waitlist.intro")}</p>
|
|
458
|
+
{waitlistOutcome && (
|
|
459
|
+
<p role={waitlistOutcome === "joined" ? "status" : "alert"} data-testid="waitlist-outcome" data-code={waitlistOutcome}>
|
|
460
|
+
{waitlistMessage(waitlistOutcome, locale)}
|
|
461
|
+
</p>
|
|
462
|
+
)}
|
|
463
|
+
<input type="hidden" name="eventId" value={eventId} />
|
|
464
|
+
<input type="hidden" name="returnTo" value={returnTo} />
|
|
465
|
+
{waitlistDates.length > 0 && (
|
|
466
|
+
<div class="semics-field">
|
|
467
|
+
<label for={`${id}-wl-date`}>{t("widget.date")}</label>
|
|
468
|
+
<select id={`${id}-wl-date`} name="occurrenceId" required>
|
|
469
|
+
{waitlistDates.map((o) => <option value={o.id}>{when(o.startsAt)}</option>)}
|
|
470
|
+
</select>
|
|
471
|
+
</div>
|
|
472
|
+
)}
|
|
473
|
+
{ticketTypes.length > 1 && (
|
|
474
|
+
<div class="semics-field">
|
|
475
|
+
<label for={`${id}-wl-type`}>{t("waitlist.ticket")}</label>
|
|
476
|
+
<select id={`${id}-wl-type`} name="ticketTypeId">
|
|
477
|
+
<option value="">{t("waitlist.anyTicket")}</option>
|
|
478
|
+
{ticketTypes.map((type) => <option value={type.id}>{type.name}</option>)}
|
|
479
|
+
</select>
|
|
480
|
+
</div>
|
|
481
|
+
)}
|
|
482
|
+
<div class="semics-field">
|
|
483
|
+
<label for={`${id}-wl-qty`}>{t("widget.tickets")}</label>
|
|
484
|
+
<input id={`${id}-wl-qty`} name="qty" type="number" inputmode="numeric" min="1" max="10" value="1" required />
|
|
485
|
+
</div>
|
|
486
|
+
<div class="semics-field">
|
|
487
|
+
<label for={`${id}-wl-name`}>{t("widget.name")}</label>
|
|
488
|
+
<input id={`${id}-wl-name`} name="name" type="text" autocomplete="name" required maxlength="200" />
|
|
489
|
+
</div>
|
|
490
|
+
<div class="semics-field">
|
|
491
|
+
<label for={`${id}-wl-email`}>{t("widget.email")}</label>
|
|
492
|
+
<input id={`${id}-wl-email`} name="email" type="email" autocomplete="email" required maxlength="254" />
|
|
493
|
+
</div>
|
|
494
|
+
{siteKey && (
|
|
495
|
+
<>
|
|
496
|
+
<div class="cf-turnstile" data-sitekey={siteKey}></div>
|
|
497
|
+
<script is:inline>(function (s) { var t = s && s.previousElementSibling; if (t && t.clientWidth < 300) t.setAttribute("data-size", "compact"); })(document.currentScript);</script>
|
|
498
|
+
</>
|
|
499
|
+
)}
|
|
500
|
+
<button type="submit" class="semics-secondary">{t("waitlist.button")}</button>
|
|
501
|
+
</form>
|
|
502
|
+
)}
|
|
503
|
+
</>
|
|
504
|
+
)
|
|
505
|
+
}
|
|
506
|
+
</section>
|
|
507
|
+
|
|
508
|
+
<script>
|
|
509
|
+
import "../client/booking.ts";
|
|
510
|
+
import "../client/picker.ts";
|
|
511
|
+
</script>
|
|
512
|
+
|
|
513
|
+
<style>
|
|
514
|
+
.semics-booking-widget {
|
|
515
|
+
--_fg: var(--events-fg, #1a1a1a);
|
|
516
|
+
--_muted: var(--events-muted, #4a4a4a);
|
|
517
|
+
--_bg: var(--events-bg, #ffffff);
|
|
518
|
+
--_border: var(--events-border, #6b6b6b);
|
|
519
|
+
--_accent: var(--events-accent, #0b57d0);
|
|
520
|
+
--_accent-fg: var(--events-accent-fg, #ffffff);
|
|
521
|
+
--_error: var(--events-error, #b3261e);
|
|
522
|
+
--_radius: var(--events-radius, 6px);
|
|
523
|
+
box-sizing: border-box;
|
|
524
|
+
max-inline-size: 36rem;
|
|
525
|
+
padding: 1rem;
|
|
526
|
+
border: 1px solid var(--_border);
|
|
527
|
+
border-radius: var(--_radius);
|
|
528
|
+
background: var(--_bg);
|
|
529
|
+
color: var(--_fg);
|
|
530
|
+
overflow-wrap: anywhere;
|
|
531
|
+
}
|
|
532
|
+
.semics-booking-widget *,
|
|
533
|
+
.semics-booking-widget *::before,
|
|
534
|
+
.semics-booking-widget *::after {
|
|
535
|
+
box-sizing: border-box;
|
|
536
|
+
}
|
|
537
|
+
.semics-booking-widget h2 {
|
|
538
|
+
margin: 0 0 0.75rem;
|
|
539
|
+
font-size: 1.25rem;
|
|
540
|
+
}
|
|
541
|
+
.semics-booking-widget form {
|
|
542
|
+
display: grid;
|
|
543
|
+
grid-template-columns: minmax(0, 1fr);
|
|
544
|
+
gap: 0.75rem;
|
|
545
|
+
}
|
|
546
|
+
.semics-booking-widget .semics-waitlist {
|
|
547
|
+
margin-block-start: 1.25rem;
|
|
548
|
+
padding-block-start: 1rem;
|
|
549
|
+
border-block-start: 1px solid var(--_border);
|
|
550
|
+
}
|
|
551
|
+
.semics-waitlist h3,
|
|
552
|
+
.semics-waitlist p {
|
|
553
|
+
margin: 0;
|
|
554
|
+
}
|
|
555
|
+
.semics-tickets {
|
|
556
|
+
margin: 0;
|
|
557
|
+
padding: 0.5rem 0.75rem;
|
|
558
|
+
border: 1px solid var(--_border);
|
|
559
|
+
border-radius: var(--_radius);
|
|
560
|
+
min-inline-size: 0;
|
|
561
|
+
}
|
|
562
|
+
.semics-questions {
|
|
563
|
+
display: grid;
|
|
564
|
+
gap: 0.75rem;
|
|
565
|
+
margin: 0;
|
|
566
|
+
padding: 0.5rem 0.75rem 0.75rem;
|
|
567
|
+
border: 1px solid var(--_border);
|
|
568
|
+
border-radius: var(--_radius);
|
|
569
|
+
min-inline-size: 0;
|
|
570
|
+
}
|
|
571
|
+
.semics-check {
|
|
572
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
573
|
+
align-items: center;
|
|
574
|
+
column-gap: 0.5rem;
|
|
575
|
+
}
|
|
576
|
+
.semics-check .semics-field-error {
|
|
577
|
+
grid-column: 1 / -1;
|
|
578
|
+
}
|
|
579
|
+
.semics-booking-widget .semics-check input {
|
|
580
|
+
min-block-size: 1.25rem;
|
|
581
|
+
inline-size: 1.25rem;
|
|
582
|
+
margin: 0;
|
|
583
|
+
}
|
|
584
|
+
.semics-hint {
|
|
585
|
+
color: var(--_muted);
|
|
586
|
+
}
|
|
587
|
+
.semics-picker-nav {
|
|
588
|
+
display: flex;
|
|
589
|
+
flex-wrap: wrap;
|
|
590
|
+
align-items: baseline;
|
|
591
|
+
gap: 0.25rem 1rem;
|
|
592
|
+
}
|
|
593
|
+
.semics-picker-month {
|
|
594
|
+
margin: 0;
|
|
595
|
+
margin-inline-end: auto;
|
|
596
|
+
font-weight: 600;
|
|
597
|
+
}
|
|
598
|
+
.semics-picker-nav a {
|
|
599
|
+
color: var(--_accent);
|
|
600
|
+
min-block-size: 1.5rem;
|
|
601
|
+
}
|
|
602
|
+
.semics-picker {
|
|
603
|
+
display: grid;
|
|
604
|
+
gap: 0.5rem;
|
|
605
|
+
margin: 0;
|
|
606
|
+
padding: 0.5rem 0.75rem 0.75rem;
|
|
607
|
+
border: 1px solid var(--_border);
|
|
608
|
+
border-radius: var(--_radius);
|
|
609
|
+
min-inline-size: 0;
|
|
610
|
+
}
|
|
611
|
+
.semics-picker p {
|
|
612
|
+
margin: 0;
|
|
613
|
+
}
|
|
614
|
+
.semics-calendar {
|
|
615
|
+
inline-size: 100%;
|
|
616
|
+
border-collapse: collapse;
|
|
617
|
+
table-layout: fixed;
|
|
618
|
+
text-align: center;
|
|
619
|
+
}
|
|
620
|
+
.semics-calendar th {
|
|
621
|
+
padding-block: 0.25rem;
|
|
622
|
+
font-weight: 400;
|
|
623
|
+
font-size: 0.875rem;
|
|
624
|
+
color: var(--_muted);
|
|
625
|
+
}
|
|
626
|
+
.semics-calendar td {
|
|
627
|
+
padding: 1px;
|
|
628
|
+
}
|
|
629
|
+
.semics-booking-widget .semics-calendar button,
|
|
630
|
+
.semics-booking-widget .semics-times button {
|
|
631
|
+
inline-size: 100%;
|
|
632
|
+
padding: 0.25rem;
|
|
633
|
+
border: 1px solid var(--_accent);
|
|
634
|
+
background: var(--_bg);
|
|
635
|
+
color: var(--_accent);
|
|
636
|
+
}
|
|
637
|
+
.semics-booking-widget .semics-calendar button.semics-day-full,
|
|
638
|
+
.semics-booking-widget .semics-times button[aria-disabled="true"] {
|
|
639
|
+
border-color: var(--_border);
|
|
640
|
+
color: var(--_muted);
|
|
641
|
+
text-decoration: line-through;
|
|
642
|
+
}
|
|
643
|
+
.semics-booking-widget .semics-times button[aria-disabled="true"] {
|
|
644
|
+
cursor: not-allowed;
|
|
645
|
+
}
|
|
646
|
+
.semics-booking-widget .semics-calendar button[aria-pressed="true"],
|
|
647
|
+
.semics-booking-widget .semics-times button[aria-checked="true"] {
|
|
648
|
+
background: var(--_accent);
|
|
649
|
+
color: var(--_accent-fg);
|
|
650
|
+
}
|
|
651
|
+
.semics-day-none {
|
|
652
|
+
display: block;
|
|
653
|
+
padding-block: 0.75rem;
|
|
654
|
+
color: var(--_muted);
|
|
655
|
+
}
|
|
656
|
+
.semics-times {
|
|
657
|
+
display: grid;
|
|
658
|
+
grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
|
|
659
|
+
gap: 0.5rem;
|
|
660
|
+
}
|
|
661
|
+
.semics-booking-widget .semics-times button {
|
|
662
|
+
display: grid;
|
|
663
|
+
justify-items: center;
|
|
664
|
+
}
|
|
665
|
+
.semics-places {
|
|
666
|
+
font-size: 0.875rem;
|
|
667
|
+
}
|
|
668
|
+
.semics-ticket {
|
|
669
|
+
display: flex;
|
|
670
|
+
flex-wrap: wrap;
|
|
671
|
+
align-items: center;
|
|
672
|
+
justify-content: space-between;
|
|
673
|
+
gap: 0.5rem;
|
|
674
|
+
padding-block: 0.25rem;
|
|
675
|
+
}
|
|
676
|
+
.semics-ticket label {
|
|
677
|
+
display: flex;
|
|
678
|
+
flex-wrap: wrap;
|
|
679
|
+
gap: 0 0.5rem;
|
|
680
|
+
flex: 1 1 10rem;
|
|
681
|
+
min-inline-size: 0;
|
|
682
|
+
}
|
|
683
|
+
.semics-ticket-price,
|
|
684
|
+
.semics-ticket-soldout {
|
|
685
|
+
color: var(--_muted);
|
|
686
|
+
}
|
|
687
|
+
.semics-ticket input {
|
|
688
|
+
inline-size: 5rem;
|
|
689
|
+
}
|
|
690
|
+
.semics-field {
|
|
691
|
+
display: grid;
|
|
692
|
+
grid-template-columns: minmax(0, 1fr);
|
|
693
|
+
gap: 0.25rem;
|
|
694
|
+
}
|
|
695
|
+
.semics-field select {
|
|
696
|
+
inline-size: 100%;
|
|
697
|
+
}
|
|
698
|
+
.semics-booking-widget input,
|
|
699
|
+
.semics-booking-widget select,
|
|
700
|
+
.semics-booking-widget button {
|
|
701
|
+
font: inherit;
|
|
702
|
+
min-block-size: 2.75rem;
|
|
703
|
+
max-inline-size: 100%;
|
|
704
|
+
}
|
|
705
|
+
.semics-booking-widget input,
|
|
706
|
+
.semics-booking-widget select {
|
|
707
|
+
padding: 0.375rem 0.5rem;
|
|
708
|
+
border: 1px solid var(--_border);
|
|
709
|
+
border-radius: var(--_radius);
|
|
710
|
+
background: var(--_bg);
|
|
711
|
+
color: var(--_fg);
|
|
712
|
+
}
|
|
713
|
+
.semics-booking-widget [aria-invalid="true"] {
|
|
714
|
+
border-color: var(--_error);
|
|
715
|
+
outline: 1px solid var(--_error);
|
|
716
|
+
}
|
|
717
|
+
.semics-field-error,
|
|
718
|
+
.semics-form-alert {
|
|
719
|
+
margin: 0;
|
|
720
|
+
color: var(--_error);
|
|
721
|
+
}
|
|
722
|
+
.semics-field-error:empty {
|
|
723
|
+
display: none;
|
|
724
|
+
}
|
|
725
|
+
.semics-form-alert {
|
|
726
|
+
padding: 0.5rem 0.75rem;
|
|
727
|
+
border: 1px solid var(--_error);
|
|
728
|
+
border-radius: var(--_radius);
|
|
729
|
+
}
|
|
730
|
+
.semics-needs-js {
|
|
731
|
+
margin: 0;
|
|
732
|
+
font-weight: 600;
|
|
733
|
+
}
|
|
734
|
+
.semics-total {
|
|
735
|
+
margin: 0;
|
|
736
|
+
}
|
|
737
|
+
.semics-booking-widget button {
|
|
738
|
+
justify-self: start;
|
|
739
|
+
padding: 0.5rem 1.5rem;
|
|
740
|
+
border: 0;
|
|
741
|
+
border-radius: var(--_radius);
|
|
742
|
+
background: var(--_accent);
|
|
743
|
+
color: var(--_accent-fg);
|
|
744
|
+
cursor: pointer;
|
|
745
|
+
}
|
|
746
|
+
.semics-promo-row {
|
|
747
|
+
display: flex;
|
|
748
|
+
flex-wrap: wrap;
|
|
749
|
+
gap: 0.5rem;
|
|
750
|
+
}
|
|
751
|
+
.semics-promo-row input {
|
|
752
|
+
flex: 1 1 10rem;
|
|
753
|
+
min-inline-size: 0;
|
|
754
|
+
}
|
|
755
|
+
.semics-booking-widget button.semics-secondary {
|
|
756
|
+
padding-inline: 1rem;
|
|
757
|
+
border: 1px solid var(--_accent);
|
|
758
|
+
background: var(--_bg);
|
|
759
|
+
color: var(--_accent);
|
|
760
|
+
}
|
|
761
|
+
.semics-promo-note {
|
|
762
|
+
margin: 0;
|
|
763
|
+
color: var(--_muted);
|
|
764
|
+
}
|
|
765
|
+
.semics-booking-widget button:disabled {
|
|
766
|
+
opacity: 0.6;
|
|
767
|
+
cursor: not-allowed;
|
|
768
|
+
}
|
|
769
|
+
.semics-booking-widget :focus-visible {
|
|
770
|
+
outline: 3px solid var(--_accent);
|
|
771
|
+
outline-offset: 2px;
|
|
772
|
+
}
|
|
773
|
+
[hidden] {
|
|
774
|
+
display: none !important;
|
|
775
|
+
}
|
|
776
|
+
</style>
|