@atelic-action/ui 8.2.0 → 8.4.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.
@@ -212,7 +212,11 @@ export function SiteShell({
212
212
  ? undefined
213
213
  : site.hours?.map((row) => ({
214
214
  label: row.labelShort,
215
- range: formatHoursRange(row, { short: true, clock: site.clock }),
215
+ range: formatHoursRange(row, {
216
+ short: site.footer?.hoursShort ?? true,
217
+ clock: site.clock,
218
+ meridiem: site.meridiem,
219
+ }),
216
220
  }));
217
221
  // The rating links to the Google profile: the site's own link for it, else
218
222
  // the profile the address already links to.
@@ -269,6 +273,7 @@ export function SiteShell({
269
273
  phone={site.phone}
270
274
  email={site.email}
271
275
  hours={footerHours}
276
+ hoursPlacement={site.footer?.hoursPlacement}
272
277
  columns={footerColumns}
273
278
  attribution={site.attribution}
274
279
  note={site.footer?.note}
@@ -21,11 +21,21 @@ export interface StickyCTABarProps {
21
21
  /** The call shortcut's accessible name. Defaults to "Call us". */
22
22
  callLabel?: string;
23
23
  /**
24
- * Hears the room the bar takes at the foot of the screen, in pixels: its
25
- * measured height while it shows, and 0 while it is hidden (scrolled
26
- * above its threshold, or on a desktop, where the stylesheet hides it).
27
- * `SiteShell` pads the page's closing bar by it, so the copyright and the
28
- * credit are never under the bar.
24
+ * Hears the room the bar reserves at the foot of the page, in pixels: its
25
+ * measured height wherever it can show, from the first measure, whether
26
+ * or not it has slid in yet, and 0 on a desktop, where the stylesheet
27
+ * hides it. `SiteShell` pads the page's closing bar by it, so the
28
+ * copyright and the credit are never under the bar, even on a page whose
29
+ * bar slides in only once scrolled and a jump straight to its end: the
30
+ * page is already as long as it will be when the bar shows, so its
31
+ * arrival moves nothing under the reader. A listener swapped in is told the
32
+ * current height at once and the one it replaced gets 0; no listener
33
+ * hears one value twice. A listener made anew each render that sets state
34
+ * should store a plain number (or be memoized): each new function hears
35
+ * the height once, and a state equal to it stops the renders. One that
36
+ * stores an object is cut off after three arrivals with nothing measured
37
+ * between: the listener leaving still hears 0, and the one arriving
38
+ * waits for the next measure.
29
39
  */
30
40
  onSpaceChange?: (pixels: number) => void;
31
41
  }
@@ -42,13 +52,20 @@ export function StickyCTABar({
42
52
  const [show, setShow] = useState(fromTop);
43
53
  const barRef = useRef<HTMLDivElement>(null);
44
54
  // The latest listener, so a caller passing a new function each render
45
- // never restarts the measuring below. Whether there is one at all does:
46
- // a listener supplied after mount starts the measuring then.
55
+ // never restarts the measuring below. Whether there is one at all does: a
56
+ // listener supplied after mount starts the measuring then.
47
57
  const spaceRef = useRef(onSpaceChange);
48
58
  spaceRef.current = onSpaceChange;
49
59
  const listening = onSpaceChange !== undefined;
50
- // The measuring effect's report, so a swap of listeners is told at once.
51
- const reportRef = useRef<(() => void) | null>(null);
60
+ // The height last measured (-1 before any, and after the bar goes), and
61
+ // what each listener was last told: no listener hears one value twice.
62
+ const heightRef = useRef(-1);
63
+ const toldRef = useRef(new WeakMap<(pixels: number) => void, number>());
64
+ const tell = (listener: ((pixels: number) => void) | undefined, pixels: number) => {
65
+ if (!listener || toldRef.current.get(listener) === pixels) return;
66
+ toldRef.current.set(listener, pixels);
67
+ listener(pixels);
68
+ };
52
69
 
53
70
  useEffect(() => {
54
71
  if (fromTop) {
@@ -61,49 +78,65 @@ export function StickyCTABar({
61
78
  return () => window.removeEventListener("scroll", onScroll);
62
79
  }, [threshold, fromTop]);
63
80
 
64
- // The bar's real height while it shows, measured again whenever it changes
65
- // size (a phone turned, a font loading, a label wrapping), never assumed.
66
- // Hidden by the stylesheet its height reads 0, so a desktop reserves nothing.
81
+ // The bar's real height, measured again whenever it changes size (a phone
82
+ // turned, a font loading, a label wrapping), never assumed. It is reported
83
+ // while the bar waits below the screen too (its slide is a transform, which
84
+ // leaves its height as it is), so the space at the page's end is reserved
85
+ // from the start and never grows as the bar slides in, where a jump to the
86
+ // end would stop short of it. Hidden by the stylesheet its height reads 0,
87
+ // so a desktop reserves nothing.
88
+ // biome-ignore lint/correctness/useExhaustiveDependencies: tell reads only refs
67
89
  useEffect(() => {
68
90
  const bar = barRef.current;
69
91
  if (!bar || !listening) return;
70
- let last = -1;
71
- // The listener last told a height: the one holding the space, which
72
- // the cleanup hands back. Never the caller's latest, which after a
73
- // swap is a listener that was never told anything.
74
- let heard: ((pixels: number) => void) | undefined;
75
92
  const report = () => {
76
- const next = show ? bar.offsetHeight : 0;
77
- const listener = spaceRef.current;
78
- if (next === last && listener === heard) return;
79
- // A caller swapped listeners since the last report: the old one
80
- // gives its space back before the new one is told the height.
81
- if (heard && heard !== listener) heard(0);
82
- last = next;
83
- heard = listener;
84
- heard?.(next);
93
+ heightRef.current = bar.offsetHeight;
94
+ arrivalsRef.current = 0;
95
+ tell(spaceRef.current, heightRef.current);
85
96
  };
86
97
  report();
87
- reportRef.current = report;
88
98
  const sizes = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(report);
89
99
  sizes?.observe(bar);
90
100
  window.addEventListener("resize", report);
91
101
  return () => {
92
- reportRef.current = null;
93
102
  sizes?.disconnect();
94
103
  window.removeEventListener("resize", report);
95
- // A final 0 on unmount, on hiding, and when the listener goes, to the
96
- // listener that holds the space, so no foot padding outlives the bar.
97
- heard?.(0);
104
+ // A final 0 on unmount and when the listener goes, so no foot padding
105
+ // outlives the bar.
106
+ heightRef.current = -1;
107
+ tell(spaceRef.current, 0);
98
108
  };
99
- }, [show, listening]);
109
+ }, [listening]);
100
110
 
101
- // A caller that swaps listeners is heard at once: the old one gives its
102
- // space back and the new one is told the height, with no resize to wait
103
- // for. A first render's report has already run, so this one says nothing.
104
- // biome-ignore lint/correctness/useExhaustiveDependencies: the listener is the trigger; the report reads it through spaceRef
111
+ // A listener swapped in is told the current height, and the one it
112
+ // replaced gets 0, unless either already heard that value. A function made
113
+ // anew each render (an inline listener) hears the height once a function
114
+ // until the caller's state settles; a stable listener hears nothing here.
115
+ const previousRef = useRef(onSpaceChange);
116
+ // Arrivals told since the bar last measured. A listener that sets object
117
+ // state is a new function on every render its own call causes, which no
118
+ // test of identity tells from a real swap; past three arrivals in a row
119
+ // with nothing measured between, the rest wait for the next measure, so
120
+ // such a listener cannot loop. Three real swaps in a row are all told.
121
+ const arrivalsRef = useRef(0);
122
+ // biome-ignore lint/correctness/useExhaustiveDependencies: the listener is the trigger; tell reads only refs
105
123
  useEffect(() => {
106
- reportRef.current?.();
124
+ const previous = previousRef.current;
125
+ previousRef.current = onSpaceChange;
126
+ if (previous === onSpaceChange) return;
127
+ if (onSpaceChange && arrivalsRef.current >= 3) {
128
+ // Past the cap the outgoing one still gives back any space it holds;
129
+ // only the arrival waits. Only a listener told a height is told 0, so
130
+ // a looping listener hears it once: the function its 0 makes was
131
+ // never told anything, and the next swap tells no one.
132
+ if (previous && (toldRef.current.get(previous) ?? 0) > 0) tell(previous, 0);
133
+ return;
134
+ }
135
+ arrivalsRef.current += 1;
136
+ // The outgoing one gives its space back, the bar measured or not (a
137
+ // listener taken away leaves the measuring off by now).
138
+ tell(previous, 0);
139
+ if (heightRef.current >= 0) tell(onSpaceChange, heightRef.current);
107
140
  }, [onSpaceChange]);
108
141
 
109
142
  return (
@@ -9,6 +9,7 @@ export type {
9
9
  ContactDockItem,
10
10
  FooterColumn,
11
11
  FooterColumnLink,
12
+ FooterHoursPlacement,
12
13
  FooterIcon,
13
14
  HeaderPhone,
14
15
  HoursRow,
@@ -234,7 +234,7 @@ export function DataTable({
234
234
  const body = isEmpty(cell, c) ? (
235
235
  <>
236
236
  <span className="data-table-empty" aria-hidden="true" />
237
- <span className="data-table-empty-label">
237
+ <span className="data-table-empty-label visually-hidden">
238
238
  {columns[c]?.emptyLabel ?? "None"}
239
239
  </span>
240
240
  </>
@@ -119,7 +119,7 @@ export function ReportCard({
119
119
  <span className="rc-grade">
120
120
  {row.before && (
121
121
  <span className="rc-before">
122
- <span className="rc-sr">{`${labels.before}: ${gradeLabel[row.before]}. `}</span>
122
+ <span className="rc-sr visually-hidden">{`${labels.before}: ${gradeLabel[row.before]}. `}</span>
123
123
  <span aria-hidden="true">
124
124
  <GradeChip grade={row.before} />
125
125
  </span>
@@ -127,14 +127,14 @@ export function ReportCard({
127
127
  )}
128
128
  {row.grade ? (
129
129
  <>
130
- <span className="rc-sr">{`${labels.grade} ${gradeLabel[row.grade]}: `}</span>
130
+ <span className="rc-sr visually-hidden">{`${labels.grade} ${gradeLabel[row.grade]}: `}</span>
131
131
  <span aria-hidden="true">
132
132
  <GradeChip grade={row.grade} />
133
133
  </span>
134
134
  </>
135
135
  ) : (
136
136
  <>
137
- <span className="rc-sr">{`${labels.notGraded}: `}</span>
137
+ <span className="rc-sr visually-hidden">{`${labels.notGraded}: `}</span>
138
138
  <span className="rc-dash" aria-hidden="true" />
139
139
  </>
140
140
  )}
package/src/lib/hours.ts CHANGED
@@ -1,16 +1,20 @@
1
- import type { Clock, OpeningHours } from "../sections/siteConfig";
1
+ import type { Clock, Meridiem, OpeningHours } from "../sections/siteConfig";
2
2
 
3
3
  /** How a time prints: `short` drops a whole hour's minutes on the 12 hour clock. */
4
4
  export interface ClockOptions {
5
5
  short?: boolean;
6
6
  /** "12h" (the default) or "24h"; see `SiteConfig.clock`. */
7
7
  clock?: Clock;
8
+ /** "letter" (the default, "9a") or "word" ("9 am"); see `SiteConfig.meridiem`. */
9
+ meridiem?: Meridiem;
8
10
  }
9
11
 
10
12
  /**
11
13
  * Formats a 24 hour "HH:MM" time as the display style used across the
12
14
  * marketing components: "11:00" -> "11:00a", "19:00" -> "7:00p".
13
15
  * With short: true, whole hours drop their minutes: "11a", "7p".
16
+ * With meridiem: "word", the mark is a word after a no break space:
17
+ * "11:00 am", "7 pm" short.
14
18
  * With clock: "24h", the time prints as "HH:MM" with a leading zero
15
19
  * ("09:00", "17:00") and short changes nothing.
16
20
  */
@@ -18,7 +22,10 @@ export function formatClock(time: string, opts: ClockOptions = {}): string {
18
22
  const [hourStr, minuteStr = "00"] = time.split(":");
19
23
  const hour24 = Number(hourStr);
20
24
  if (opts.clock === "24h") return `${String(hour24 % 24).padStart(2, "0")}:${minuteStr}`;
21
- const suffix = hour24 % 24 >= 12 ? "p" : "a";
25
+ const afternoon = hour24 % 24 >= 12;
26
+ // A word joins with a no break space, so "5:00 pm" never breaks before its mark.
27
+ const word = afternoon ? "\u00a0pm" : "\u00a0am";
28
+ const suffix = opts.meridiem === "word" ? word : afternoon ? "p" : "a";
22
29
  const hour = hour24 % 12 || 12;
23
30
  if (opts.short && minuteStr === "00") return `${hour}${suffix}`;
24
31
  return `${hour}:${minuteStr}${suffix}`;
@@ -114,13 +114,42 @@ function eventID(): string {
114
114
  return id;
115
115
  }
116
116
 
117
- /** The thrown value as Sentry's exception: its type, message, and frames. */
118
- function exceptionOf(error: unknown) {
119
- if (error instanceof Error) {
120
- const frames = parseStack(error.stack);
117
+ /** How many causes deep a report follows a thrown value's `cause`. */
118
+ const CAUSE_DEPTH = 5;
119
+
120
+ /** The longest an exception's message is kept in a report. */
121
+ const EXCEPTION_VALUE_MAX = 300;
122
+
123
+ /**
124
+ * One thrown value as Sentry's exception: its type, message, and frames. A
125
+ * cause's words are upstream free text (a resolver's, a socket's), so they
126
+ * take the refusal's scrub, and its `code` (ENOTFOUND, ECONNRESET, a TLS
127
+ * error's) leads its message when the message does not already say it, so a
128
+ * DNS fault reads apart from a refused connection.
129
+ */
130
+ function exceptionOne(error: unknown, isCause: boolean) {
131
+ const words = (text: string) => (isCause ? scrub(text) : text).slice(0, EXCEPTION_VALUE_MAX);
132
+ const shaped =
133
+ error instanceof Error ||
134
+ (isCause &&
135
+ error !== null &&
136
+ typeof error === "object" &&
137
+ ("message" in error || "code" in error));
138
+ if (shaped) {
139
+ const { name, message, stack, code } = error as {
140
+ name?: unknown;
141
+ message?: unknown;
142
+ stack?: unknown;
143
+ code?: unknown;
144
+ };
145
+ const text = typeof message === "string" ? message : "";
146
+ const coded =
147
+ isCause && (typeof code === "string" || typeof code === "number") ? String(code) : "";
148
+ const value = coded && !text.includes(coded) ? (text ? `${coded}: ${text}` : coded) : text;
149
+ const frames = parseStack(typeof stack === "string" ? stack : undefined);
121
150
  return {
122
- type: error.name || "Error",
123
- value: error.message,
151
+ type: typeof name === "string" && name ? name : "Error",
152
+ value: words(value),
124
153
  ...(frames.length ? { stacktrace: { frames } } : {}),
125
154
  };
126
155
  }
@@ -130,7 +159,47 @@ function exceptionOf(error: unknown) {
130
159
  } catch {
131
160
  value = String(error);
132
161
  }
133
- return { type: "Error", value: value ?? String(error) };
162
+ return { type: "Error", value: words(value ?? String(error)) };
163
+ }
164
+
165
+ /** A value's `cause`, read so that a throwing getter reads as none. */
166
+ function causeOf(error: unknown): unknown {
167
+ if (error === null || typeof error !== "object") return undefined;
168
+ try {
169
+ return (error as { cause?: unknown }).cause;
170
+ } catch {
171
+ return undefined;
172
+ }
173
+ }
174
+
175
+ /**
176
+ * The thrown value and the causes under it, up to five deep, as Sentry's
177
+ * exception values: innermost first and the thrown value last, as Sentry
178
+ * orders a chain, each cause linked to the one it caused (`mechanism`
179
+ * `chained`, `source` `cause`, its own `exception_id` and its parent's
180
+ * `parent_id`), the thrown value `exception_id` 0 under the generic
181
+ * mechanism, handled, since the reporter is called by code that caught it.
182
+ * A cause met twice (a cycle) ends the chain. A value with no cause is the
183
+ * one exception it always was, with no mechanism.
184
+ */
185
+ function exceptionsOf(error: unknown) {
186
+ const chain: unknown[] = [error];
187
+ const seen = new Set<unknown>([error]);
188
+ for (let cause = causeOf(error); chain.length <= CAUSE_DEPTH; cause = causeOf(cause)) {
189
+ if (cause === undefined || cause === null || seen.has(cause)) break;
190
+ seen.add(cause);
191
+ chain.push(cause);
192
+ }
193
+ if (chain.length === 1) return [exceptionOne(error, false)];
194
+ return chain
195
+ .map((value, id) => ({
196
+ ...exceptionOne(value, id > 0),
197
+ mechanism:
198
+ id === 0
199
+ ? { type: "generic", handled: true, exception_id: 0 }
200
+ : { type: "chained", source: "cause", exception_id: id, parent_id: id - 1 },
201
+ }))
202
+ .reverse();
134
203
  }
135
204
 
136
205
  /**
@@ -179,7 +248,7 @@ export function buildEnvelope(
179
248
  ...(environment ? { environment } : {}),
180
249
  tags: { runtime: runtime(), ...options.tags },
181
250
  ...(request ? { request } : {}),
182
- exception: { values: [exceptionOf(error)] },
251
+ exception: { values: exceptionsOf(error) },
183
252
  };
184
253
  const header = { event_id: id, sent_at: now.toISOString(), dsn, sdk: SDK };
185
254
  return [JSON.stringify(header), JSON.stringify({ type: "event" }), JSON.stringify(event)].join(
@@ -290,8 +359,41 @@ export function reportServerErrorLater(
290
359
  }
291
360
  }
292
361
 
293
- /** Anything shaped like an email address, which a refusal may quote (the recipient, the sender). */
294
- const ADDRESS = /[^\s@<>()[\]"',;:]+@[^\s@<>()[\]"',;:]+\.[^\s@<>()[\]"',;:]+/g;
362
+ /**
363
+ * Anything shaped like an email address, which a refusal may quote (the
364
+ * recipient, the sender). The domain is labels of letters in any script,
365
+ * digits, hyphens, and underscores joined by dots, so an internationalized
366
+ * domain is caught and a sentence's closing period stays outside it.
367
+ */
368
+ const ADDRESS = /[^\s@<>()[\]"',;:]+@[\p{L}\p{N}_-]+(?:\.[\p{L}\p{N}_-]+)+/gu;
369
+
370
+ /** A separator inside a phone number: a space, a dot, a slash, or any hyphen or dash. */
371
+ const SEP = "[\\s./\\u2010-\\u2015\\u2212-]";
372
+
373
+ /** One part of a dotted IPv4 address, 0 to 255. */
374
+ const OCTET = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)";
375
+
376
+ /**
377
+ * A run shaped like a phone number: an optional country code (a plus sign
378
+ * and one to three digits, or one to three digits and a separator, as in
379
+ * 1-555-555-0142), then an area code in parentheses and the number after
380
+ * it, or at least three groups of digits joined by separators, the last of
381
+ * three or four digits, or a plus sign and seven to fifteen digits run
382
+ * together (E.164); any of them may close on an extension (x12, ext. 12). A
383
+ * date (2026-11-23), a bare id (12345678), a count beside a year (120
384
+ * 2026), a status (429), and a dotted IPv4 address (192.168.10.200) are none
385
+ * of these, and stay. A run starts at a word's edge and never just after a
386
+ * digit's dot, so no tail of a longer dotted run is taken for one.
387
+ */
388
+ const PHONE = new RegExp(
389
+ `(?<![\\w+-])(?<!\\d\\.)(?:\\+\\d{7,15}|(?!(?:${OCTET}\\.){3}${OCTET}(?![\\w.-]))(?:\\+\\d{1,3}${SEP}?|\\d{1,3}${SEP})?(?:\\(\\d{2,4}\\)${SEP}?\\d{2,4}(?:${SEP}\\d{3,4})?|\\d{2,4}(?:${SEP}\\d{2,4}){1,2}${SEP}\\d{3,4}))(?:\\s*(?:x|ext\\.?|extension)\\s*\\d{1,6})?(?![\\w-])`,
390
+ "giu",
391
+ );
392
+
393
+ /** A refusal's field with every address and phone number in it replaced. */
394
+ function scrub(text: string): string {
395
+ return text.replace(ADDRESS, "[address]").replace(PHONE, "[number]");
396
+ }
295
397
 
296
398
  /** The longest a refusal's field is kept, so a report never carries a page of text. */
297
399
  const REFUSAL_FIELD_MAX = 300;
@@ -300,8 +402,15 @@ const REFUSAL_FIELD_MAX = 300;
300
402
  * A refused upstream answer as an error a report may carry: the service's
301
403
  * name, the status, and the error body's `name` and `message` fields alone,
302
404
  * each with anything shaped like an email address replaced by `[address]`
303
- * and cut to 300 characters. Nothing else of the body is read, and a body
304
- * that is not JSON leaves the status alone. Never throws.
405
+ * and anything shaped like a phone number (grouped as one is written) by
406
+ * `[number]`, then cut to 300
407
+ * characters. Nothing else of the body is read, and a body that is not JSON
408
+ * leaves the status alone. Never throws.
409
+ *
410
+ * The scrub takes out the shapes it knows and nothing more: the fields are
411
+ * still the upstream's free text, and a name, a street, or a message quoted
412
+ * in it in words passes through. Report a refusal from a service whose
413
+ * errors are about the request, never one that echoes what a person wrote.
305
414
  *
306
415
  * await refusalError(response, "Resend") // Error("Resend answered 422: validation_error: ...")
307
416
  */
@@ -318,7 +427,7 @@ export async function refusalError(
318
427
  }
319
428
  const parts = [body.name, body.message]
320
429
  .filter((part): part is string => typeof part === "string" && part.trim() !== "")
321
- .map((part) => part.replace(ADDRESS, "[address]").slice(0, REFUSAL_FIELD_MAX));
430
+ .map((part) => scrub(part).slice(0, REFUSAL_FIELD_MAX));
322
431
  return new Error(
323
432
  `${service} answered ${response.status}${parts.length ? `: ${parts.join(": ")}` : ""}`,
324
433
  );
@@ -1,7 +1,24 @@
1
+ /** One of the router's matches, by the plain fields `isMiss` reads. */
2
+ export interface MissMatch {
3
+ routeId: string;
4
+ params: Record<string, string>;
5
+ staticData?: { missing?: (params: Record<string, string>) => boolean };
6
+ /** The match's state; `notFound` once a route's loader has thrown `notFound()`. */
7
+ status?: string;
8
+ /** Set on the match that renders a not found nothing below it handled. */
9
+ globalNotFound?: boolean;
10
+ }
11
+
12
+ /** The catch all route's id in a TanStack file route tree. */
13
+ export const CATCH_ALL_ROUTE_ID = "/$";
14
+
1
15
  /**
2
16
  * Whether the router's matches are a miss: the catch all route took the
3
- * path (an unknown page), or a route with params says its params name a page
4
- * it does not have (a blog slug nobody wrote) through `staticData.missing`.
17
+ * path (an unknown page), a route with params says its params name a page
18
+ * it does not have (a blog slug nobody wrote) through `staticData.missing`,
19
+ * or the router already reports a match not found (a loader's `notFound()`,
20
+ * 8.3.0). The one predicate the root's 404 head and the not found pending
21
+ * view both ask, so the two never disagree.
5
22
  * Router free: it reads the plain fields every TanStack match carries, so a
6
23
  * site's root route asks it from `head` and from `useMatches`.
7
24
  *
@@ -13,20 +30,15 @@
13
30
  * the site's shell from the root layout, so the shell stays mounted while
14
31
  * the not found body swaps from its pending render to its own.
15
32
  */
16
- export interface MissMatch {
17
- routeId: string;
18
- params: Record<string, string>;
19
- staticData?: { missing?: (params: Record<string, string>) => boolean };
20
- }
21
-
22
- /** The catch all route's id in a TanStack file route tree. */
23
- export const CATCH_ALL_ROUTE_ID = "/$";
24
-
25
33
  export function isMiss(
26
34
  matches: ReadonlyArray<MissMatch>,
27
35
  catchAllId: string = CATCH_ALL_ROUTE_ID,
28
36
  ): boolean {
29
37
  return matches.some(
30
- (match) => match.routeId === catchAllId || match.staticData?.missing?.(match.params) === true,
38
+ (match) =>
39
+ match.routeId === catchAllId ||
40
+ match.staticData?.missing?.(match.params) === true ||
41
+ match.status === "notFound" ||
42
+ match.globalNotFound === true,
31
43
  );
32
44
  }
@@ -7,7 +7,10 @@ export interface StaticNotFoundOptions {
7
7
  * The router's own `useMatches` (`import { useMatches } from
8
8
  * "@tanstack/react-router"`). With it, the pending view draws the not
9
9
  * found page on a miss alone and nothing on any other route's pending
10
- * state, so a slow client navigation never flashes a bare 404 body.
10
+ * state, so a slow client navigation never flashes a bare 404 body. A
11
+ * miss is the catch all route's match, a route whose
12
+ * `staticData.missing(params)` says its params name no page, or a match
13
+ * the router already reports as not found.
11
14
  */
12
15
  useMatches: (options: { select: (matches: ReadonlyArray<MissMatch>) => boolean }) => boolean;
13
16
  /** The catch all route's id, when it is not `/$`. */
@@ -38,6 +41,15 @@ export interface StaticNotFoundOptions {
38
41
  * state on a slow client navigation shows no bare 404 body. Without it the
39
42
  * pending view is the page itself, as before.
40
43
  *
44
+ * What a route must set: a route with params that can claim a path with no
45
+ * page behind it (a blog slug nobody wrote) sets `staticData.missing(params)`.
46
+ * The static host serves such a path the 404 prerender, and it hydrates
47
+ * through the pending state before the route's loader has run, so its
48
+ * `notFound()` arrives too late for that first render: without `missing`,
49
+ * the pending view draws nothing where the server drew the page, and the
50
+ * page hydrates blank. A loader's `notFound()` is still honored once the
51
+ * router reports it (a client navigation to the slug).
52
+ *
41
53
  * Static sites only. On a live app the pending state is a real loading
42
54
  * moment; an app sets defaultNotFoundComponent alone.
43
55
  *
@@ -55,6 +67,7 @@ export function staticNotFoundRouting<Page extends ComponentType>(
55
67
  export function staticNotFoundRouting<Page>(page: Page, options?: StaticNotFoundOptions) {
56
68
  if (!options) return { defaultNotFoundComponent: page, defaultPendingComponent: page };
57
69
  const { useMatches, catchAllId = CATCH_ALL_ROUTE_ID } = options;
70
+ // The one miss predicate the root's 404 head asks too, so the two agree.
58
71
  const select = (matches: ReadonlyArray<MissMatch>) => isMiss(matches, catchAllId);
59
72
  function NotFoundPending(): ReactElement | null {
60
73
  const miss = useMatches({ select });
@@ -1,3 +1,4 @@
1
+ import { breakableEmail } from "../lib/emailText";
1
2
  import { newTabProps } from "../lib/newTabProps";
2
3
  import { useWithBase } from "../routing/BasePathProvider";
3
4
  import type { SiteConfig } from "./siteConfig";
@@ -28,6 +29,12 @@ export interface ContactInfoCardProps {
28
29
  * broken card, and inventing one is worse.
29
30
  */
30
31
  showAddress?: boolean;
32
+ /**
33
+ * The words beside the single `site.phone` row. Defaults to "Call", which
34
+ * asserts nothing a business may not do; a line that answers texts says
35
+ * so here ("Call or text").
36
+ */
37
+ phoneLabel?: string;
31
38
  }
32
39
 
33
40
  /** Dark card with direct contact rows: call, email, visit, portal. */
@@ -36,6 +43,7 @@ export function ContactInfoCard({
36
43
  title = "Reach us directly",
37
44
  phones,
38
45
  showAddress = true,
46
+ phoneLabel = "Call",
39
47
  }: ContactInfoCardProps) {
40
48
  const withBase = useWithBase();
41
49
  const portal = site.footerLinks?.find((link) => link.label.toLowerCase().includes("portal"));
@@ -54,7 +62,7 @@ export function ContactInfoCard({
54
62
  ))
55
63
  : site.phone && (
56
64
  <div className="ci-row">
57
- <span className="k">Call / Text</span>
65
+ <span className="k">{phoneLabel}</span>
58
66
  <span className="v">
59
67
  <a href={`tel:${site.phone.e164}`}>{site.phone.display}</a>
60
68
  </span>
@@ -63,7 +71,8 @@ export function ContactInfoCard({
63
71
  <div className={["ci-row", !showAddress && !portal && "last"].filter(Boolean).join(" ")}>
64
72
  <span className="k">Email</span>
65
73
  <span className="v">
66
- <a href={`mailto:${site.email}`}>{site.email}</a>
74
+ {/* Breaks after the @ and before each dot, never inside a word, as the footer's does. */}
75
+ <a href={`mailto:${site.email}`}>{breakableEmail(site.email)}</a>
67
76
  </span>
68
77
  </div>
69
78
  {showAddress && (
@@ -1,4 +1,5 @@
1
1
  import type { CSSProperties, ReactNode } from "react";
2
+ import { newTabProps } from "../lib/newTabProps";
2
3
  import { SectionHeading } from "../primitives";
3
4
  import { useWithBase } from "../routing/BasePathProvider";
4
5
  import type { Surface } from "./siteConfig";
@@ -22,8 +23,19 @@ interface FeatureCardBase {
22
23
  * rather than a constraint.
23
24
  */
24
25
  export type FeatureCard =
25
- | (FeatureCardBase & { description: ReactNode; href?: never; linkLabel?: never })
26
- | (FeatureCardBase & { description: string; href: string; linkLabel?: string });
26
+ | (FeatureCardBase & {
27
+ description: ReactNode;
28
+ href?: never;
29
+ linkLabel?: never;
30
+ external?: never;
31
+ })
32
+ | (FeatureCardBase & {
33
+ description: string;
34
+ href: string;
35
+ linkLabel?: string;
36
+ /** Opens in a new tab, except on mailto, tel, and sms links, and says so to a screen reader. */
37
+ external?: boolean;
38
+ });
27
39
 
28
40
  export interface FeatureGridProps {
29
41
  eyebrow?: string;
@@ -37,6 +49,11 @@ export interface FeatureGridProps {
37
49
  columns?: 2 | 3 | 4;
38
50
  surface?: Surface;
39
51
  id?: string;
52
+ /**
53
+ * The words a screen reader hears after a card that opens in a new tab.
54
+ * Defaults to "opens in a new tab".
55
+ */
56
+ newTabLabel?: string;
40
57
  }
41
58
 
42
59
  /** Numbered feature/service card grid with hover lift. */
@@ -48,6 +65,7 @@ export function FeatureGrid({
48
65
  columns = 4,
49
66
  surface = "alt",
50
67
  id,
68
+ newTabLabel = "opens in a new tab",
51
69
  }: FeatureGridProps) {
52
70
  const withBase = useWithBase();
53
71
  const sectionClasses = ["section", surface === "alt" && "surface-alt"].filter(Boolean).join(" ");
@@ -70,11 +88,17 @@ export function FeatureGrid({
70
88
  )}
71
89
  </>
72
90
  );
73
- return item.href ? (
74
- <a key={item.title} className="feature-card" href={withBase(item.href)}>
75
- {inner}
76
- </a>
77
- ) : (
91
+ if (item.href) {
92
+ const tab = newTabProps(item.href, item.external);
93
+ return (
94
+ <a key={item.title} className="feature-card" href={withBase(item.href)} {...tab}>
95
+ {inner}
96
+ {/* Said to a screen reader only, as the card's last words. */}
97
+ {tab.target && <span className="visually-hidden">, {newTabLabel}</span>}
98
+ </a>
99
+ );
100
+ }
101
+ return (
78
102
  <div key={item.title} className="feature-card">
79
103
  {inner}
80
104
  </div>
@@ -1,14 +1,16 @@
1
1
  import { formatHoursRange, isClosed } from "../lib/hours";
2
- import type { Clock, OpeningHours } from "./siteConfig";
2
+ import type { Clock, Meridiem, OpeningHours } from "./siteConfig";
3
3
 
4
4
  export interface HoursTableProps {
5
5
  hours: OpeningHours[];
6
6
  /** "12h" (the default) or "24h"; pass the site's `SiteConfig.clock`. */
7
7
  clock?: Clock;
8
+ /** "letter" (the default) or "word"; pass the site's `SiteConfig.meridiem`. */
9
+ meridiem?: Meridiem;
8
10
  }
9
11
 
10
12
  /** Day-by-day hours rows with dashed rules and mono times. */
11
- export function HoursTable({ hours, clock }: HoursTableProps) {
13
+ export function HoursTable({ hours, clock, meridiem }: HoursTableProps) {
12
14
  return (
13
15
  <div>
14
16
  {hours.map((row) => (
@@ -17,7 +19,7 @@ export function HoursTable({ hours, clock }: HoursTableProps) {
17
19
  className={["hours-row", isClosed(row) && "closed"].filter(Boolean).join(" ")}
18
20
  >
19
21
  <span className="day">{row.label}</span>
20
- <span className="time">{formatHoursRange(row, { clock })}</span>
22
+ <span className="time">{formatHoursRange(row, { clock, meridiem })}</span>
21
23
  </div>
22
24
  ))}
23
25
  </div>