@semics-tech/emdash-events 1.0.0-rc.3 → 1.0.0-rc.5

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.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The look of the plugins' own full pages (`/booking`, the suite's `/_events/waiver`), which run outside the
3
+ * site's layout: a default stylesheet built only on the `--events-*` properties, and what a site sets through
4
+ * `eventsIntegration({ page })` / `eventsSuite({ page })`. It is one exact string so the signing page can allow
5
+ * it by hash (its CSP allows nothing else inline, `ceremonyCsp`). Web APIs only (R35).
6
+ *
7
+ * The site's own layout is deliberately not wrapped around these pages: an emailed link's one-time code is in the
8
+ * URL here, and a signing page's CSP would block the layout's scripts and styles anyway.
9
+ */
10
+ /** A theme value by property: `accent` sets `--events-accent` (the signing form follows, see `PAGE_CSS`). */
11
+ export declare const THEME_PROPERTIES: readonly ["fg", "muted", "bg", "border", "accent", "accent-fg", "error", "success", "radius", "font", "page-bg", "heading-font", "heading-fg"];
12
+ export type ThemeProperty = (typeof THEME_PROPERTIES)[number];
13
+ export interface PageBrand {
14
+ /** The site's name: the link's text, or the logo's alternative text. */
15
+ name: string;
16
+ /** Where it links, a path on this site (default `/`). */
17
+ href?: string;
18
+ /** A logo, a path on this site. */
19
+ logo?: string;
20
+ }
21
+ export interface PageOptions {
22
+ /** Values for the pages' custom properties, for example `{ accent: "#1f3a2e", "page-bg": "#f6f1ea" }`. */
23
+ theme?: Partial<Record<ThemeProperty, string>>;
24
+ /** A stylesheet on this site, loaded after the defaults: for `@font-face`, or any further rules. */
25
+ stylesheet?: string;
26
+ /** The site's name or logo at the top of each page. */
27
+ brand?: PageBrand;
28
+ /** The event's page, where "Book again" goes: a path with `{slug}` (default `/events/{slug}`). */
29
+ eventPath?: string;
30
+ }
31
+ /** Checks a site's page options when the site's config loads; a bad value stops the build with its name. */
32
+ export declare function checkPageOptions(page?: PageOptions): PageOptions;
33
+ /** The event's page for "Book again"; undefined when the booking does not know its slug. */
34
+ export declare function eventPageHref(slug: string | null | undefined, eventPath?: string): string | undefined;
35
+ /** Works with no site theme at all. Zero specificity on elements, so the components' own rules win. */
36
+ export declare const PAGE_CSS = "*,*::before,*::after{box-sizing:border-box}\nhtml{color-scheme:light;-webkit-text-size-adjust:100%}\nbody.semics-page{margin:0;min-block-size:100vh;background:var(--events-page-bg, #f5f4f0);color:var(--events-fg, #1a1a1a);font-family:var(--events-font, system-ui, sans-serif);font-size:1.0625rem;line-height:1.55;overflow-wrap:anywhere;\n--esign-fg:var(--events-fg, #1a1a1a);--esign-muted:var(--events-muted, #4a4a4a);--esign-bg:var(--events-bg, #ffffff);--esign-border:var(--events-border, #6b6b6b);--esign-accent:var(--events-accent, #0b57d0);--esign-accent-fg:var(--events-accent-fg, #ffffff);--esign-error:var(--events-error, #b3261e);--esign-radius:var(--events-radius, 6px)}\n.semics-page-brand{max-inline-size:38rem;margin-inline:auto;padding:1rem 1rem 0;font-family:var(--events-heading-font, inherit);font-weight:600}\n.semics-page-brand a{color:var(--events-heading-fg, inherit);text-decoration:none}\n.semics-page-brand img{display:block;block-size:2.5rem;inline-size:auto;max-inline-size:100%}\n.semics-page-main{max-inline-size:38rem;margin-inline:auto;padding:1.5rem 1rem 3rem}\n:where(.semics-page) :is(h1,h2,h3){margin:0 0 .75rem;font-family:var(--events-heading-font, inherit);color:var(--events-heading-fg, inherit);line-height:1.2}\n:where(.semics-page) h1{font-size:clamp(1.75rem,1.5rem + 1.5vw,2.25rem)}\n:where(.semics-page) h2{font-size:1.25rem}\n:where(.semics-page) h3{font-size:1.0625rem}\n:where(.semics-page) p{margin:0 0 .75rem}\n:where(.semics-page) a{color:var(--events-accent, #0b57d0);text-underline-offset:.2em}\n:where(.semics-page) :focus-visible{outline:3px solid var(--events-accent, #0b57d0);outline-offset:2px}\n:where(.semics-page-main) > section,:where(.semics-page-main) > form:not([hidden]){margin-block:0 1rem;padding:1rem 1.25rem;background:var(--events-bg, #ffffff);border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);max-inline-size:none}\n:where(.semics-page) [role=\"alert\"]{padding:.5rem .75rem;border:1px solid var(--events-error, #b3261e);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-error, #b3261e)}\n:where(.semics-page) :is(input:not([type=\"checkbox\"],[type=\"radio\"],[type=\"hidden\"]),select,textarea){font:inherit;inline-size:100%;min-block-size:2.75rem;padding:.375rem .5rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-fg, #1a1a1a)}\n:where(.semics-page) label{display:block}\n:where(.semics-page) fieldset{min-inline-size:0;margin:0 0 .75rem;padding:.5rem .75rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px)}\n:where(.semics-page) button{font:inherit;min-block-size:2.75rem;padding:.5rem 1rem;border:0;border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);cursor:pointer}\n";
37
+ /** The stylesheet for a page: the defaults, then the site's theme. Exact: the signing page hashes this text. */
38
+ export declare function pageCss(page?: PageOptions): string;
@@ -0,0 +1,88 @@
1
+ // i18n-ignore-file: a stylesheet and its option names, no text for people.
2
+ /**
3
+ * The look of the plugins' own full pages (`/booking`, the suite's `/_events/waiver`), which run outside the
4
+ * site's layout: a default stylesheet built only on the `--events-*` properties, and what a site sets through
5
+ * `eventsIntegration({ page })` / `eventsSuite({ page })`. It is one exact string so the signing page can allow
6
+ * it by hash (its CSP allows nothing else inline, `ceremonyCsp`). Web APIs only (R35).
7
+ *
8
+ * The site's own layout is deliberately not wrapped around these pages: an emailed link's one-time code is in the
9
+ * URL here, and a signing page's CSP would block the layout's scripts and styles anyway.
10
+ */
11
+ /** A theme value by property: `accent` sets `--events-accent` (the signing form follows, see `PAGE_CSS`). */
12
+ export const THEME_PROPERTIES = [
13
+ "fg",
14
+ "muted",
15
+ "bg",
16
+ "border",
17
+ "accent",
18
+ "accent-fg",
19
+ "error",
20
+ "success",
21
+ "radius",
22
+ "font",
23
+ "page-bg",
24
+ "heading-font",
25
+ "heading-fg",
26
+ ];
27
+ /** One line of CSS, nothing that could end the declaration, the rule or the `<style>` element. */
28
+ const THEME_VALUE = /^[^;{}<>\\@]{1,200}$/;
29
+ const SITE_PATH = /^\/(?!\/)[^\s"'<>\\]*$/;
30
+ /** Checks a site's page options when the site's config loads; a bad value stops the build with its name. */
31
+ export function checkPageOptions(page = {}) {
32
+ const refuse = (what) => {
33
+ throw new Error(`page.${what} is not valid`); // i18n-ignore
34
+ };
35
+ for (const [name, value] of Object.entries(page.theme ?? {})) {
36
+ const known = THEME_PROPERTIES.includes(name);
37
+ if (!known || typeof value !== "string" || !THEME_VALUE.test(value) || /url\(/i.test(value))
38
+ refuse(`theme.${name}`);
39
+ }
40
+ const { brand, stylesheet, eventPath } = page;
41
+ if (stylesheet !== undefined && !SITE_PATH.test(stylesheet))
42
+ refuse("stylesheet");
43
+ if (eventPath !== undefined && !(SITE_PATH.test(eventPath) && eventPath.includes("{slug}")))
44
+ refuse("eventPath");
45
+ if (brand) {
46
+ if (typeof brand.name !== "string" || !brand.name.trim())
47
+ refuse("brand.name");
48
+ if (brand.href !== undefined && !SITE_PATH.test(brand.href))
49
+ refuse("brand.href");
50
+ if (brand.logo !== undefined && !SITE_PATH.test(brand.logo))
51
+ refuse("brand.logo");
52
+ }
53
+ return page;
54
+ }
55
+ /** The event's page for "Book again"; undefined when the booking does not know its slug. */
56
+ export function eventPageHref(slug, eventPath) {
57
+ return slug ? (eventPath ?? "/events/{slug}").replace("{slug}", encodeURIComponent(slug)) : undefined;
58
+ }
59
+ /** Works with no site theme at all. Zero specificity on elements, so the components' own rules win. */
60
+ export const PAGE_CSS = `*,*::before,*::after{box-sizing:border-box}
61
+ html{color-scheme:light;-webkit-text-size-adjust:100%}
62
+ body.semics-page{margin:0;min-block-size:100vh;background:var(--events-page-bg, #f5f4f0);color:var(--events-fg, #1a1a1a);font-family:var(--events-font, system-ui, sans-serif);font-size:1.0625rem;line-height:1.55;overflow-wrap:anywhere;
63
+ --esign-fg:var(--events-fg, #1a1a1a);--esign-muted:var(--events-muted, #4a4a4a);--esign-bg:var(--events-bg, #ffffff);--esign-border:var(--events-border, #6b6b6b);--esign-accent:var(--events-accent, #0b57d0);--esign-accent-fg:var(--events-accent-fg, #ffffff);--esign-error:var(--events-error, #b3261e);--esign-radius:var(--events-radius, 6px)}
64
+ .semics-page-brand{max-inline-size:38rem;margin-inline:auto;padding:1rem 1rem 0;font-family:var(--events-heading-font, inherit);font-weight:600}
65
+ .semics-page-brand a{color:var(--events-heading-fg, inherit);text-decoration:none}
66
+ .semics-page-brand img{display:block;block-size:2.5rem;inline-size:auto;max-inline-size:100%}
67
+ .semics-page-main{max-inline-size:38rem;margin-inline:auto;padding:1.5rem 1rem 3rem}
68
+ :where(.semics-page) :is(h1,h2,h3){margin:0 0 .75rem;font-family:var(--events-heading-font, inherit);color:var(--events-heading-fg, inherit);line-height:1.2}
69
+ :where(.semics-page) h1{font-size:clamp(1.75rem,1.5rem + 1.5vw,2.25rem)}
70
+ :where(.semics-page) h2{font-size:1.25rem}
71
+ :where(.semics-page) h3{font-size:1.0625rem}
72
+ :where(.semics-page) p{margin:0 0 .75rem}
73
+ :where(.semics-page) a{color:var(--events-accent, #0b57d0);text-underline-offset:.2em}
74
+ :where(.semics-page) :focus-visible{outline:3px solid var(--events-accent, #0b57d0);outline-offset:2px}
75
+ :where(.semics-page-main) > section,:where(.semics-page-main) > form:not([hidden]){margin-block:0 1rem;padding:1rem 1.25rem;background:var(--events-bg, #ffffff);border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);max-inline-size:none}
76
+ :where(.semics-page) [role="alert"]{padding:.5rem .75rem;border:1px solid var(--events-error, #b3261e);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-error, #b3261e)}
77
+ :where(.semics-page) :is(input:not([type="checkbox"],[type="radio"],[type="hidden"]),select,textarea){font:inherit;inline-size:100%;min-block-size:2.75rem;padding:.375rem .5rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-fg, #1a1a1a)}
78
+ :where(.semics-page) label{display:block}
79
+ :where(.semics-page) fieldset{min-inline-size:0;margin:0 0 .75rem;padding:.5rem .75rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px)}
80
+ :where(.semics-page) button{font:inherit;min-block-size:2.75rem;padding:.5rem 1rem;border:0;border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);cursor:pointer}
81
+ `;
82
+ /** The stylesheet for a page: the defaults, then the site's theme. Exact: the signing page hashes this text. */
83
+ export function pageCss(page = {}) {
84
+ const set = Object.entries(page.theme ?? {});
85
+ if (set.length === 0)
86
+ return PAGE_CSS;
87
+ return `${PAGE_CSS}:root{${set.map(([name, value]) => `--events-${name}:${value}`).join(";")}}\n`;
88
+ }
@@ -1,3 +1,5 @@
1
+ import { type PageOptions } from "../astro/lib/page.ts";
2
+ export type { PageOptions };
1
3
  export interface EventsIntegrationOptions {
2
4
  /**
3
5
  * The sandboxed core's plugin id. Defaults to the slug (`semics-events`, npm installs).
@@ -15,6 +17,8 @@ export interface EventsIntegrationOptions {
15
17
  * for a booking waiting for signatures (the suite passes its own, T066). Without it nothing is reconciled.
16
18
  */
17
19
  reconcile?: string;
20
+ /** How the plugin's own pages look on this site: theme, stylesheet, brand, event page path (`PageOptions`). */
21
+ page?: PageOptions;
18
22
  }
19
23
  /** The slice of Astro's integration API this needs (so the package takes no `astro` dependency). */
20
24
  interface SetupArgs {
@@ -1,4 +1,5 @@
1
1
  import { EVENTS_PLUGIN_ID } from "../astro/lib/call.js";
2
+ import { checkPageOptions } from "../astro/lib/page.js";
2
3
  const VIRTUAL = "virtual:semics-events/config";
3
4
  const RESOLVED = `\0${VIRTUAL}`;
4
5
  /**
@@ -14,6 +15,7 @@ export function eventsIntegration(options = {}) {
14
15
  const pluginId = options.pluginId ?? EVENTS_PLUGIN_ID;
15
16
  const config = [
16
17
  `export const pluginId = ${JSON.stringify(pluginId)};`,
18
+ `export const page = ${JSON.stringify(checkPageOptions(options.page))};`,
17
19
  `export const esignPluginId = ${JSON.stringify(options.esignPluginId ?? null)};`,
18
20
  options.reconcile
19
21
  ? `export { reconcileBooking as reconcile } from ${JSON.stringify(options.reconcile)};`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semics-tech/emdash-events",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0-rc.5",
4
4
  "type": "module",
5
5
  "main": "dist/index.mjs",
6
6
  "exports": {
@@ -25,6 +25,7 @@
25
25
  "./i18n": "./src/i18n/index.ts",
26
26
  "./client/*": "./src/client/*.ts",
27
27
  "./astro/BookingPage.astro": "./src/astro/BookingPage.astro",
28
+ "./astro/PageBrand.astro": "./src/astro/PageBrand.astro",
28
29
  "./astro/DoorSignPage.astro": "./src/astro/DoorSignPage.astro",
29
30
  "./astro/CheckIn.astro": "./src/astro/CheckIn.astro",
30
31
  "./astro/OptOutPage.astro": "./src/astro/OptOutPage.astro",
@@ -6,6 +6,7 @@
6
6
  // and emails of attendees who have not signed, until the cutoff. Rows come from `signingRows`.
7
7
  import { around, pickLocale, translator } from "../i18n/index";
8
8
  import type { SigningRow } from "./lib/attendees";
9
+ import { zonedAt } from "./lib/list";
9
10
 
10
11
  interface Props {
11
12
  rows: SigningRow[];
@@ -13,25 +14,18 @@ interface Props {
13
14
  action: string;
14
15
  /** While names may be changed: the deadline (ISO). */
15
16
  editUntil?: string;
17
+ /** The event's time zone, for that deadline. */
18
+ zone?: string | null;
16
19
  locale?: string;
17
20
  }
18
21
 
19
- const { rows, action, editUntil } = Astro.props;
22
+ const { rows, action, editUntil, zone } = Astro.props;
20
23
  const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
21
24
  const { t, lang, dir } = translator(locale);
22
25
  const editable = rows.filter((r) => r.canEdit);
23
26
  const [untilBefore, untilAfter] = around(t("booking.attendees.editUntil"), "time");
24
27
  const [emailedBefore, emailedAfter] = around(t("booking.attendees.emailed"), "email");
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
- };
28
+ const at = (iso: string) => zonedAt(iso, zone, locale);
35
29
  ---
36
30
  <section class="semics-events semics-attendee-list" data-testid="attendee-list" lang={lang} dir={dir} aria-labelledby="semics-attendees-title">
37
31
  <h2 id="semics-attendees-title">{t("booking.attendees.title")}</h2>
@@ -73,6 +67,7 @@ const at = (iso: string) => {
73
67
  ))
74
68
  }
75
69
  </ul>
70
+ {rows.some((r) => r.canResend) && <p class="semics-attendee-note" data-testid="attendee-not-arrived">{t("booking.attendees.notArrived")}</p>}
76
71
  {
77
72
  editable.length > 0 && (
78
73
  <form method="post" action={action} class="semics-attendee-edit" data-testid="attendee-edit">
@@ -8,11 +8,12 @@
8
8
  // `src/client/receipt.ts` clears the fragment and posts the receipt here, which forwards it to the
9
9
  // core's `signatures/receipt` (no access token needed: the receipt is HMAC-signed) and redirects to
10
10
  // `?ref=&waiver=<outcome>`.
11
- import { esignPluginId, pluginId, reconcile } from "virtual:semics-events/config";
11
+ import { esignPluginId, page, pluginId, reconcile } from "virtual:semics-events/config";
12
12
 
13
13
  import { type MessageKey, pickLocale, translator } from "../i18n/index";
14
14
  import AddToCalendar from "./AddToCalendar.astro";
15
15
  import BookingStatus from "./BookingStatus.astro";
16
+ import PageBrand from "./PageBrand.astro";
16
17
  import PaymentReturn from "./PaymentReturn.astro";
17
18
  import { callPublicRoute } from "./lib/call";
18
19
  import {
@@ -28,6 +29,7 @@ import {
28
29
  } from "./lib/checkout-form";
29
30
  import AttendeeList from "./AttendeeList.astro";
30
31
  import { handleAttendeeAction, signingRows } from "./lib/attendees";
32
+ import { eventPageHref, pageCss } from "./lib/page";
31
33
  import { paymentView } from "./lib/payment";
32
34
  import { forwardReceipt } from "./lib/receipt";
33
35
  import { type BookingView, type PublicEvent, reconcileWanted, ticketNames } from "./lib/widget";
@@ -177,9 +179,12 @@ const passes = booking && !cancelled && booking.status === "confirmed" ? booking
177
179
  <meta name="robots" content="noindex" />
178
180
  <meta name="referrer" content="no-referrer" />
179
181
  <title>{t("booking.title")}</title>
182
+ <style is:inline set:html={pageCss(page)}></style>
183
+ {page.stylesheet && <link rel="stylesheet" href={page.stylesheet} />}
180
184
  </head>
181
- <body>
182
- <main class="semics-booking" data-testid="booking-page">
185
+ <body class="semics-page">
186
+ <PageBrand brand={page.brand} />
187
+ <main class="semics-booking semics-page-main" data-testid="booking-page">
183
188
  <h1>{t("booking.title")}</h1>
184
189
  <form method="post" action={ref ? `/booking?ref=${ref}` : "/booking"} data-semics-fragment="receipt" hidden>
185
190
  <input type="hidden" name="intent" value="receipt" />
@@ -196,13 +201,14 @@ const passes = booking && !cancelled && booking.status === "confirmed" ? booking
196
201
  </form>
197
202
  ) : booking ? (
198
203
  <>
199
- <BookingStatus booking={booking} cancelled={cancelled} cancelAction={`/booking?ref=${ref}`} ticketNames={names} locale={locale} />
204
+ <BookingStatus booking={booking} cancelled={cancelled} cancelAction={`/booking?ref=${ref}`} ticketNames={names} bookAgain={eventPageHref(booking.event?.slug, page.eventPath)} locale={locale} />
200
205
  {payment && <PaymentReturn view={payment} bookingRef={ref} action={`/booking?ref=${ref}`} locale={locale} />}
201
206
  {signingList && (
202
207
  <AttendeeList
203
208
  rows={signingList}
204
209
  action={`/booking?ref=${ref}`}
205
210
  editUntil={booking.signingList?.editable ? booking.signingList.editUntil : undefined}
211
+ zone={booking.event?.timezone}
206
212
  locale={locale}
207
213
  />
208
214
  )}
@@ -2,7 +2,8 @@
2
2
  // <BookingStatus>: a booking's state, order and cancel button (EU-FR-06). Rendered by the
3
3
  // `/booking` page from the `public/booking` answer; the cancel form is a plain POST back to it.
4
4
  import { around, pickLocale, translator } from "../i18n/index";
5
- import { type BookingView, formatMoney, statusLabel } from "./lib/widget";
5
+ import { zonedAt } from "./lib/list";
6
+ import { type BookingView, endedNotes, formatMoney, statusLabel } from "./lib/widget";
6
7
 
7
8
  interface Props {
8
9
  booking: BookingView;
@@ -12,10 +13,12 @@ interface Props {
12
13
  cancelAction?: string;
13
14
  /** Ticket type names by id, when the page knows them. */
14
15
  ticketNames?: Record<string, string>;
16
+ /** A lapsed booking's way back: the event's page, when known. */
17
+ bookAgain?: string;
15
18
  locale?: string;
16
19
  }
17
20
 
18
- const { booking, cancelled = false, cancelAction, ticketNames = {} } = Astro.props;
21
+ const { booking, cancelled = false, cancelAction, ticketNames = {}, bookAgain } = Astro.props;
19
22
  const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
20
23
  const { t, plural, lang, dir } = translator(locale);
21
24
  // A request awaiting approval (T131) holds its places until the organiser's deadline.
@@ -26,16 +29,8 @@ const [heldBefore, heldAfter] = around(
26
29
  const [cancelBefore, cancelAfter] = around(t("booking.cancelUntil"), "time");
27
30
  const tickets = booking.lines.reduce((n, line) => n + line.qty, 0);
28
31
  const status = cancelled ? "cancelled" : booking.status;
29
- const at = (iso: string) => {
30
- try {
31
- const time = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" }).format(
32
- new Date(iso),
33
- );
34
- return t("time.utc", { time });
35
- } catch {
36
- return iso;
37
- }
38
- };
32
+ const at = (iso: string) => zonedAt(iso, booking.event?.timezone, locale);
33
+ const notes = endedNotes({ ...booking, status }, locale);
39
34
  ---
40
35
  <section class="semics-events semics-booking-status" data-testid="booking-details" data-status={status} lang={lang} dir={dir} aria-labelledby="semics-booking-status-title">
41
36
  <h2 id="semics-booking-status-title" class="semics-visually-hidden">{t("booking.status")}</h2>
@@ -52,6 +47,8 @@ const at = (iso: string) => {
52
47
  </p>
53
48
  )
54
49
  }
50
+ {notes.map((note) => <p data-testid="booking-note">{note}</p>)}
51
+ {status === "expired" && bookAgain && <p><a href={bookAgain} data-testid="booking-book-again">{t("booking.bookAgain")}</a></p>}
55
52
  <ul class="semics-lines" aria-label={plural("booking.lines", tickets)}>
56
53
  {
57
54
  booking.lines.map((line) => (
@@ -0,0 +1,18 @@
1
+ ---
2
+ // The site's name or logo at the top of the plugins' own pages (`/booking`, `/_events/waiver`), linking
3
+ // home: those pages run outside the site's layout (`eventsIntegration({ page: { brand } })`).
4
+ import type { PageBrand } from "./lib/page";
5
+
6
+ interface Props {
7
+ brand?: PageBrand | undefined;
8
+ }
9
+
10
+ const { brand } = Astro.props;
11
+ ---
12
+ {
13
+ brand && (
14
+ <header class="semics-page-brand">
15
+ <a href={brand.href ?? "/"}>{brand.logo ? <img src={brand.logo} alt={brand.name} /> : brand.name}</a>
16
+ </header>
17
+ )
18
+ }
@@ -52,8 +52,8 @@ export interface AttendeeEdit {
52
52
  email?: string;
53
53
  }
54
54
 
55
- /** Statuses in which a waiver can still be signed: the hold's, and a confirmed booking's pending seats. */
56
- const OPEN = ["awaiting_signature", "awaiting_payment", "confirmed"];
55
+ /** Statuses in which a waiver can still be signed: the holds', and a confirmed booking's pending seats. */
56
+ const OPEN = ["awaiting_signature", "awaiting_payment", "awaiting_approval", "confirmed"];
57
57
  const SEAT = /^[0-9]{1,3}$/;
58
58
  const CODE = /^[A-Z_]{1,40}$/;
59
59
  const MAX_TEXT = 254;
@@ -62,6 +62,27 @@ const WHEN: Intl.DateTimeFormatOptions = {
62
62
  timeZoneName: "short",
63
63
  };
64
64
 
65
+ const AT: Intl.DateTimeFormatOptions = {
66
+ day: "numeric",
67
+ month: "short",
68
+ year: "numeric",
69
+ hour: "2-digit",
70
+ minute: "2-digit",
71
+ hourCycle: "h23",
72
+ };
73
+
74
+ /**
75
+ * A deadline on a customer page: local time in the event's own zone, named as the emails name it
76
+ * ("9 Nov 2026, 15:09 (Europe/London)", not workerd's "GMT+0"). UTC for a missing or unknown zone; the raw value
77
+ * for one that is not a date.
78
+ */
79
+ export function zonedAt(iso: string, timezone: string | null | undefined, locale: string): string {
80
+ const ms = Date.parse(iso);
81
+ if (!Number.isFinite(ms)) return iso;
82
+ const zone = timezone && isValidTimeZone(timezone) ? timezone : "UTC";
83
+ return `${formatInZone(ms, zone, locale, AT)} (${zone})`;
84
+ }
85
+
65
86
  const BADGES = { cancelled: "list.badge.cancelled", closed: "list.badge.closed", paused: "list.badge.paused" } as const;
66
87
 
67
88
  /** The start in the event's own zone; a missing or unknown zone shows UTC rather than failing. */
@@ -0,0 +1,108 @@
1
+ // i18n-ignore-file: a stylesheet and its option names, no text for people.
2
+ /**
3
+ * The look of the plugins' own full pages (`/booking`, the suite's `/_events/waiver`), which run outside the
4
+ * site's layout: a default stylesheet built only on the `--events-*` properties, and what a site sets through
5
+ * `eventsIntegration({ page })` / `eventsSuite({ page })`. It is one exact string so the signing page can allow
6
+ * it by hash (its CSP allows nothing else inline, `ceremonyCsp`). Web APIs only (R35).
7
+ *
8
+ * The site's own layout is deliberately not wrapped around these pages: an emailed link's one-time code is in the
9
+ * URL here, and a signing page's CSP would block the layout's scripts and styles anyway.
10
+ */
11
+
12
+ /** A theme value by property: `accent` sets `--events-accent` (the signing form follows, see `PAGE_CSS`). */
13
+ export const THEME_PROPERTIES = [
14
+ "fg",
15
+ "muted",
16
+ "bg",
17
+ "border",
18
+ "accent",
19
+ "accent-fg",
20
+ "error",
21
+ "success",
22
+ "radius",
23
+ "font",
24
+ "page-bg",
25
+ "heading-font",
26
+ "heading-fg",
27
+ ] as const;
28
+ export type ThemeProperty = (typeof THEME_PROPERTIES)[number];
29
+ export interface PageBrand {
30
+ /** The site's name: the link's text, or the logo's alternative text. */
31
+ name: string;
32
+ /** Where it links, a path on this site (default `/`). */
33
+ href?: string;
34
+ /** A logo, a path on this site. */
35
+ logo?: string;
36
+ }
37
+
38
+ export interface PageOptions {
39
+ /** Values for the pages' custom properties, for example `{ accent: "#1f3a2e", "page-bg": "#f6f1ea" }`. */
40
+ theme?: Partial<Record<ThemeProperty, string>>;
41
+ /** A stylesheet on this site, loaded after the defaults: for `@font-face`, or any further rules. */
42
+ stylesheet?: string;
43
+ /** The site's name or logo at the top of each page. */
44
+ brand?: PageBrand;
45
+ /** The event's page, where "Book again" goes: a path with `{slug}` (default `/events/{slug}`). */
46
+ eventPath?: string;
47
+ }
48
+
49
+ /** One line of CSS, nothing that could end the declaration, the rule or the `<style>` element. */
50
+ const THEME_VALUE = /^[^;{}<>\\@]{1,200}$/;
51
+ const SITE_PATH = /^\/(?!\/)[^\s"'<>\\]*$/;
52
+
53
+ /** Checks a site's page options when the site's config loads; a bad value stops the build with its name. */
54
+ export function checkPageOptions(page: PageOptions = {}): PageOptions {
55
+ const refuse = (what: string) => {
56
+ throw new Error(`page.${what} is not valid`); // i18n-ignore
57
+ };
58
+ for (const [name, value] of Object.entries(page.theme ?? {})) {
59
+ const known = (THEME_PROPERTIES as readonly string[]).includes(name);
60
+ if (!known || typeof value !== "string" || !THEME_VALUE.test(value) || /url\(/i.test(value))
61
+ refuse(`theme.${name}`);
62
+ }
63
+ const { brand, stylesheet, eventPath } = page;
64
+ if (stylesheet !== undefined && !SITE_PATH.test(stylesheet)) refuse("stylesheet");
65
+ if (eventPath !== undefined && !(SITE_PATH.test(eventPath) && eventPath.includes("{slug}"))) refuse("eventPath");
66
+ if (brand) {
67
+ if (typeof brand.name !== "string" || !brand.name.trim()) refuse("brand.name");
68
+ if (brand.href !== undefined && !SITE_PATH.test(brand.href)) refuse("brand.href");
69
+ if (brand.logo !== undefined && !SITE_PATH.test(brand.logo)) refuse("brand.logo");
70
+ }
71
+ return page;
72
+ }
73
+
74
+ /** The event's page for "Book again"; undefined when the booking does not know its slug. */
75
+ export function eventPageHref(slug: string | null | undefined, eventPath?: string): string | undefined {
76
+ return slug ? (eventPath ?? "/events/{slug}").replace("{slug}", encodeURIComponent(slug)) : undefined;
77
+ }
78
+
79
+ /** Works with no site theme at all. Zero specificity on elements, so the components' own rules win. */
80
+ export const PAGE_CSS = `*,*::before,*::after{box-sizing:border-box}
81
+ html{color-scheme:light;-webkit-text-size-adjust:100%}
82
+ body.semics-page{margin:0;min-block-size:100vh;background:var(--events-page-bg, #f5f4f0);color:var(--events-fg, #1a1a1a);font-family:var(--events-font, system-ui, sans-serif);font-size:1.0625rem;line-height:1.55;overflow-wrap:anywhere;
83
+ --esign-fg:var(--events-fg, #1a1a1a);--esign-muted:var(--events-muted, #4a4a4a);--esign-bg:var(--events-bg, #ffffff);--esign-border:var(--events-border, #6b6b6b);--esign-accent:var(--events-accent, #0b57d0);--esign-accent-fg:var(--events-accent-fg, #ffffff);--esign-error:var(--events-error, #b3261e);--esign-radius:var(--events-radius, 6px)}
84
+ .semics-page-brand{max-inline-size:38rem;margin-inline:auto;padding:1rem 1rem 0;font-family:var(--events-heading-font, inherit);font-weight:600}
85
+ .semics-page-brand a{color:var(--events-heading-fg, inherit);text-decoration:none}
86
+ .semics-page-brand img{display:block;block-size:2.5rem;inline-size:auto;max-inline-size:100%}
87
+ .semics-page-main{max-inline-size:38rem;margin-inline:auto;padding:1.5rem 1rem 3rem}
88
+ :where(.semics-page) :is(h1,h2,h3){margin:0 0 .75rem;font-family:var(--events-heading-font, inherit);color:var(--events-heading-fg, inherit);line-height:1.2}
89
+ :where(.semics-page) h1{font-size:clamp(1.75rem,1.5rem + 1.5vw,2.25rem)}
90
+ :where(.semics-page) h2{font-size:1.25rem}
91
+ :where(.semics-page) h3{font-size:1.0625rem}
92
+ :where(.semics-page) p{margin:0 0 .75rem}
93
+ :where(.semics-page) a{color:var(--events-accent, #0b57d0);text-underline-offset:.2em}
94
+ :where(.semics-page) :focus-visible{outline:3px solid var(--events-accent, #0b57d0);outline-offset:2px}
95
+ :where(.semics-page-main) > section,:where(.semics-page-main) > form:not([hidden]){margin-block:0 1rem;padding:1rem 1.25rem;background:var(--events-bg, #ffffff);border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);max-inline-size:none}
96
+ :where(.semics-page) [role="alert"]{padding:.5rem .75rem;border:1px solid var(--events-error, #b3261e);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-error, #b3261e)}
97
+ :where(.semics-page) :is(input:not([type="checkbox"],[type="radio"],[type="hidden"]),select,textarea){font:inherit;inline-size:100%;min-block-size:2.75rem;padding:.375rem .5rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-fg, #1a1a1a)}
98
+ :where(.semics-page) label{display:block}
99
+ :where(.semics-page) fieldset{min-inline-size:0;margin:0 0 .75rem;padding:.5rem .75rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px)}
100
+ :where(.semics-page) button{font:inherit;min-block-size:2.75rem;padding:.5rem 1rem;border:0;border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);cursor:pointer}
101
+ `;
102
+
103
+ /** The stylesheet for a page: the defaults, then the site's theme. Exact: the signing page hashes this text. */
104
+ export function pageCss(page: PageOptions = {}): string {
105
+ const set = Object.entries(page.theme ?? {}) as Array<[ThemeProperty, string]>;
106
+ if (set.length === 0) return PAGE_CSS;
107
+ return `${PAGE_CSS}:root{${set.map(([name, value]) => `--events-${name}:${value}`).join(";")}}\n`;
108
+ }
@@ -5,6 +5,7 @@
5
5
  * way" are told apart by asking the core, never by a query parameter.
6
6
  */
7
7
  import { type MessageKey, t } from "../../i18n/index";
8
+ import { zonedAt } from "./list";
8
9
  import type { BookingView } from "./widget";
9
10
 
10
11
  export type PaymentState = "confirmed" | "pending" | "expired" | "cancelled" | "refunded" | "refunded_unavailable";
@@ -19,15 +20,6 @@ export interface PaymentView {
19
20
  resume: boolean;
20
21
  }
21
22
 
22
- const utc = (iso: string, locale: string) => {
23
- try {
24
- const at = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" });
25
- return t(locale, "time.utc", { time: at.format(new Date(iso)) });
26
- } catch {
27
- return iso;
28
- }
29
- };
30
-
31
23
  /** The provider's payment page is followed only when it is an `https:` URL (never `javascript:` or `//host`). */
32
24
  export function isPayUrl(value: unknown): value is string {
33
25
  if (typeof value !== "string" || !value.startsWith("https://")) return false;
@@ -55,7 +47,9 @@ export function paymentView(booking: BookingView, locale = "en-GB"): PaymentView
55
47
  state: "pending",
56
48
  heading: t(locale, "payment.pending.heading"),
57
49
  body: booking.holdExpiresAt
58
- ? t(locale, "payment.pending.bodyUntil", { time: utc(booking.holdExpiresAt, locale) })
50
+ ? t(locale, "payment.pending.bodyUntil", {
51
+ time: zonedAt(booking.holdExpiresAt, booking.event?.timezone, locale),
52
+ })
59
53
  : t(locale, "payment.pending.body"),
60
54
  poll: true,
61
55
  resume: true,
@@ -36,6 +36,8 @@ export interface PublicEvent {
36
36
  turnstileSiteKey?: string;
37
37
  /** True when the event requires a signed waiver (T066): the booking form then asks for attendees. */
38
38
  waiver?: boolean;
39
+ /** Events Pro: that waiver is signed per attendee, so its seat rules can be checked before reserving. */
40
+ waiverEach?: boolean;
39
41
  /** True when the core takes promo codes (Events Pro, T078): the widget then shows a code field. */
40
42
  promoCodes?: boolean;
41
43
  /** True when a sold-out event takes a waitlist (T081): the widget then shows a "Join the waitlist" form. */
@@ -74,6 +76,12 @@ export interface BookingView {
74
76
  lines: Array<{ ticketTypeId: string; qty: number }>;
75
77
  totals: { totalMinor: number; currency: string };
76
78
  holdExpiresAt?: string;
79
+ /** The event's public info (`timezone` for times on the page, `slug` for "Book again"). */
80
+ event?: { title?: string; startsAt?: string; timezone?: string | null; slug?: string | null };
81
+ /** Why the organiser declined (`status: "declined"`), when they said. */
82
+ declineReason?: string | null;
83
+ /** Declined, a price was due and no money was taken (`closeBooking`). */
84
+ notCharged?: boolean;
77
85
  /** `qr`: Events Pro's QR matrix of `code` (T082), drawn by `<TicketPass>`; Free sends none. */
78
86
  attendees: Array<{ name: string; ticketTypeId?: string; status: string; code?: string; qr?: unknown }>;
79
87
  canCancel: boolean;
@@ -302,3 +310,13 @@ export const statusLabel = (status: string, locale?: string) =>
302
310
 
303
311
  /** English status labels (the 1.0 API; components use `statusLabel`). */
304
312
  export const STATUS_LABELS: Record<string, string> = Object.fromEntries(STATUSES.map((s) => [s, statusLabel(s, "en")]));
313
+
314
+ /** What a booking that ended without going ahead should say beyond its status (declined, or lapsed). */
315
+ export function endedNotes(booking: Pick<BookingView, "status" | "declineReason" | "notCharged">, locale?: string) {
316
+ if (booking.status === "expired") return [t(locale, "booking.lapsed")];
317
+ if (booking.status !== "declined") return [];
318
+ return [
319
+ ...(booking.declineReason ? [t(locale, "booking.declinedReason", { reason: booking.declineReason })] : []),
320
+ ...(booking.notCharged ? [t(locale, "booking.notCharged")] : []),
321
+ ];
322
+ }
@@ -1,6 +1,8 @@
1
1
  // Provided by the integration's Vite plugin (`eventsIntegration({ pluginId })`).
2
2
  declare module "virtual:semics-events/config" {
3
3
  export const pluginId: string;
4
+ /** How the site dresses the plugin's own pages (`eventsIntegration({ page })`). */
5
+ export const page: import("./lib/page").PageOptions;
4
6
  /** The e-sign core's plugin id, or `null` when e-sign is not configured (`eventsIntegration({ esignPluginId })`). */
5
7
  export const esignPluginId: string | null;
6
8
  /**
package/src/i18n/ar.ts CHANGED
@@ -3,7 +3,6 @@ import type { Messages } from "./index";
3
3
  /** Arabic (right to left). Plural forms follow `Intl.PluralRules("ar")`: zero, one, two, few, many, other. */
4
4
  export const ar: Messages = {
5
5
  "money.free": "مجاني",
6
- "time.utc": "{time} بالتوقيت العالمي",
7
6
 
8
7
  "list.heading": "الفعاليات القادمة",
9
8
  "list.error": "الفعاليات غير متاحة الآن.",
@@ -101,6 +100,11 @@ export const ar: Messages = {
101
100
  "booking.status": "حالة الحجز",
102
101
  "booking.reference": "الرقم المرجعي",
103
102
  "booking.heldUntil": "تذاكرك محجوزة حتى {time}.",
103
+ "booking.declinedReason": "سبب المنظّم: {reason}",
104
+ "booking.notCharged": "لم يُخصم أي مبلغ من بطاقتك.",
105
+ "booking.lapsed":
106
+ "انتهت صلاحية هذا الحجز لأنه لم يكتمل في الوقت المحدد، لذا أُتيحت أماكنه للآخرين. للمتابعة، ابدأ حجزًا جديدًا؛ وإذا كان هناك إقرار تنازل فستوقّعه مرة أخرى.",
107
+ "booking.bookAgain": "احجز مرة أخرى",
104
108
  "booking.decideBy": "سيوافق المنظّم على طلبك أو يرفضه بحلول {time}، وسنراسلك بالبريد الإلكتروني.",
105
109
  "booking.line": "{qty} × {name}",
106
110
  "booking.total": "المجموع",
@@ -133,6 +137,8 @@ export const ar: Messages = {
133
137
  "booking.attendees.signed": "موقَّع",
134
138
  "booking.attendees.waiting": "بانتظار التوقيع",
135
139
  "booking.attendees.minor": "دون 18 عامًا: توقّع أنت بصفتك وليّ الأمر.",
140
+ "booking.attendees.notArrived":
141
+ "لم تصل الدعوة؟ تحقّق من العنوان وأعد إرسالها، أو استخدم التوقيع الآن. لا يمكننا رؤية الرسائل المرتجعة: تبقى هذه القائمة على حالة الانتظار حتى يوقّعوا.",
136
142
  "booking.attendees.emailed": "أُرسلت دعوة بالبريد الإلكتروني إلى {email}.",
137
143
  "booking.attendees.signNow": "وقّع الآن على هذا الجهاز",
138
144
  "booking.attendees.resend": "أعد إرسال الدعوة",
package/src/i18n/en.ts CHANGED
@@ -6,7 +6,6 @@
6
6
  */
7
7
  export const en = {
8
8
  "money.free": "Free",
9
- "time.utc": "{time} UTC",
10
9
 
11
10
  "list.heading": "Upcoming events",
12
11
  "list.error": "Events are unavailable right now.",
@@ -104,6 +103,11 @@ export const en = {
104
103
  "booking.reference": "Reference",
105
104
  "booking.heldUntil": "Your tickets are held until {time}.",
106
105
  "booking.decideBy": "The organiser will approve or decline your request by {time}; we will email you.",
106
+ "booking.declinedReason": "The organiser's reason: {reason}",
107
+ "booking.notCharged": "Your card was not charged.",
108
+ "booking.lapsed":
109
+ "This booking lapsed because it was not finished in time, so its places were released. To go ahead, start a new booking; if there is a waiver, you will sign it again.",
110
+ "booking.bookAgain": "Book again",
107
111
  "booking.line": "{qty} × {name}",
108
112
  "booking.total": "Total",
109
113
  "booking.cancelUntil": "You can cancel until {time}.",
@@ -138,6 +142,8 @@ export const en = {
138
142
  "booking.attendees.waiting": "Waiting",
139
143
  "booking.attendees.minor": "Under 18: you sign as their guardian.",
140
144
  "booking.attendees.emailed": "Invited by email to {email}.",
145
+ "booking.attendees.notArrived":
146
+ "Invitation not arrived? Check the address and resend it, or use Sign now. We cannot see emails that bounce: this list stays on Waiting until they sign.",
141
147
  "booking.attendees.signNow": "Sign now on this device",
142
148
  "booking.attendees.resend": "Resend invitation",
143
149
  "booking.attendees.edit": "Change attendee details",