@spillway-cms/blocks 0.1.24 → 0.1.25
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/dist/collection.d.ts +32 -1
- package/dist/collection.js +40 -5
- package/dist/collection.js.map +1 -1
- package/dist/config.d.ts +15 -1
- package/dist/config.js +23 -3
- package/dist/config.js.map +1 -1
- package/dist/countdown.d.ts +34 -0
- package/dist/countdown.js +81 -0
- package/dist/countdown.js.map +1 -0
- package/dist/css.js +17 -0
- package/dist/css.js.map +1 -1
- package/dist/documents.d.ts +52 -0
- package/dist/documents.js +146 -0
- package/dist/documents.js.map +1 -0
- package/dist/examples.js +74 -0
- package/dist/examples.js.map +1 -1
- package/dist/form.d.ts +11 -3
- package/dist/form.js +27 -11
- package/dist/form.js.map +1 -1
- package/dist/glossary.d.ts +56 -0
- package/dist/glossary.js +117 -0
- package/dist/glossary.js.map +1 -0
- package/dist/hours.d.ts +44 -0
- package/dist/hours.js +163 -0
- package/dist/hours.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/language-switcher.d.ts +38 -0
- package/dist/language-switcher.js +60 -0
- package/dist/language-switcher.js.map +1 -0
- package/dist/listing-script.d.ts +13 -0
- package/dist/listing-script.js +44 -0
- package/dist/listing-script.js.map +1 -0
- package/dist/location-map.d.ts +60 -0
- package/dist/location-map.js +215 -0
- package/dist/location-map.js.map +1 -0
- package/dist/meta.js +37 -2
- package/dist/meta.js.map +1 -1
- package/dist/motion.js +1 -1
- package/dist/progress.d.ts +46 -0
- package/dist/progress.js +106 -0
- package/dist/progress.js.map +1 -0
- package/dist/registry-package.js +1 -1
- package/dist/registry-package.js.map +1 -1
- package/dist/registry-types.d.ts +5 -0
- package/dist/registry-types.js.map +1 -1
- package/dist/styles.css +193 -1
- package/dist/utility-script.d.ts +20 -0
- package/dist/utility-script.js +90 -0
- package/dist/utility-script.js.map +1 -0
- package/dist/utility-shared.d.ts +18 -0
- package/dist/utility-shared.js +32 -0
- package/dist/utility-shared.js.map +1 -0
- package/package.json +2 -2
package/dist/glossary.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx, keyFor, ldJson, slugOf, textOf } from './utility-shared.js';
|
|
3
|
+
export const GLOSSARY_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
|
|
4
|
+
/** The letter a term files under: its first letter with accents folded (Éclair → E), else `#`. */
|
|
5
|
+
export function letterOf(term) {
|
|
6
|
+
const c = term.trim().normalize('NFKD').replace(/[̀-ͯ]/g, '').charAt(0).toUpperCase();
|
|
7
|
+
return c >= 'A' && c <= 'Z' ? c : '#';
|
|
8
|
+
}
|
|
9
|
+
/** Terms sorted (accents and case ignored) and filed by letter, `#` last; each with a unique id. */
|
|
10
|
+
export function fileTerms(terms, lang = 'en') {
|
|
11
|
+
const coll = new Intl.Collator(lang, { sensitivity: 'base', numeric: true });
|
|
12
|
+
const seen = new Set();
|
|
13
|
+
const sorted = terms.filter((t) => t && textOf(t.term).trim()).sort((a, b) => coll.compare(a.term.trim(), b.term.trim()));
|
|
14
|
+
const out = new Map();
|
|
15
|
+
for (const t of sorted) {
|
|
16
|
+
let base = slugOf(textOf(t.anchor)) || slugOf(t.term) || 'term';
|
|
17
|
+
if (/^\d/.test(base))
|
|
18
|
+
base = `n-${base}`;
|
|
19
|
+
let id = base;
|
|
20
|
+
for (let n = 2; seen.has(id); n++)
|
|
21
|
+
id = `${base}-${n}`;
|
|
22
|
+
seen.add(id);
|
|
23
|
+
const l = letterOf(t.term);
|
|
24
|
+
out.set(l, [...(out.get(l) ?? []), { term: t.term.trim(), definition: textOf(t.definition).trim(), ...(t.href ? { href: t.href } : {}), id }]);
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
export const glossaryComponent = {
|
|
29
|
+
label: 'Glossary A to Z',
|
|
30
|
+
fields: {
|
|
31
|
+
title: { type: 'text', label: 'Title', contentEditable: true },
|
|
32
|
+
intro: { type: 'textarea', label: 'Introduction' },
|
|
33
|
+
anchor: { type: 'text', label: 'Link name (letters link to #<link name>-a)', placeholder: 'glossary' },
|
|
34
|
+
source: { type: 'radio', label: 'Terms from', options: [{ label: 'This block', value: 'inline' }, { label: 'A content type', value: 'type' }, { label: 'A vocabulary', value: 'vocabulary' }] },
|
|
35
|
+
terms: {
|
|
36
|
+
type: 'array',
|
|
37
|
+
label: 'Terms (when the terms are in this block)',
|
|
38
|
+
max: 500,
|
|
39
|
+
getItemSummary: (t, i) => t?.term || `Term ${(i ?? 0) + 1}`,
|
|
40
|
+
arrayFields: {
|
|
41
|
+
term: { type: 'text', label: 'Term' },
|
|
42
|
+
definition: { type: 'textarea', label: 'Definition' },
|
|
43
|
+
anchor: { type: 'text', label: 'Link name (empty: from the term)' },
|
|
44
|
+
},
|
|
45
|
+
defaultItemProps: { term: '', definition: '', anchor: '' },
|
|
46
|
+
},
|
|
47
|
+
typeKey: { type: 'text', label: 'Content type key (terms from a content type)' },
|
|
48
|
+
termField: { type: 'text', label: 'Term field (empty: the title)' },
|
|
49
|
+
definitionField: { type: 'text', label: 'Definition field', placeholder: 'summary' },
|
|
50
|
+
vocabulary: { type: 'text', label: 'Vocabulary key (terms from a vocabulary)' },
|
|
51
|
+
search: { type: 'radio', label: 'Search box', options: [{ label: 'Off', value: false }, { label: 'On', value: true }] },
|
|
52
|
+
structuredData: { type: 'radio', label: 'Terms in search results (DefinedTermSet)', options: [{ label: 'On', value: true }, { label: 'Off', value: false }] },
|
|
53
|
+
},
|
|
54
|
+
defaultProps: {
|
|
55
|
+
title: 'Glossary',
|
|
56
|
+
intro: '',
|
|
57
|
+
anchor: 'glossary',
|
|
58
|
+
source: 'inline',
|
|
59
|
+
terms: [
|
|
60
|
+
{ term: 'Add/drop period', definition: 'The first week of a term, when you can add or drop classes without a fee.', anchor: '' },
|
|
61
|
+
{ term: 'Bursar', definition: 'The office that bills tuition and fees and issues refunds.', anchor: '' },
|
|
62
|
+
{ term: 'Credit hour', definition: 'One hour of class a week for a term, the unit a degree counts.', anchor: '' },
|
|
63
|
+
],
|
|
64
|
+
typeKey: '',
|
|
65
|
+
termField: '',
|
|
66
|
+
definitionField: 'summary',
|
|
67
|
+
vocabulary: '',
|
|
68
|
+
search: false,
|
|
69
|
+
structuredData: true,
|
|
70
|
+
},
|
|
71
|
+
render: (props) => {
|
|
72
|
+
const { title, intro, anchor, source, terms, search, structuredData, resolved } = props;
|
|
73
|
+
const list = source === 'type' || source === 'vocabulary' ? (resolved?.terms ?? []) : (Array.isArray(terms) ? terms : []).map((t) => ({ term: textOf(t?.term), definition: textOf(t?.definition), anchor: textOf(t?.anchor) }));
|
|
74
|
+
const filed = fileTerms(list);
|
|
75
|
+
const base = slugOf(textOf(anchor)) || 'glossary';
|
|
76
|
+
const key = keyFor('glossary', props.id, base);
|
|
77
|
+
const titleText = textOf(title);
|
|
78
|
+
const Letter = titleText ? 'h3' : 'h2';
|
|
79
|
+
const letters = [...GLOSSARY_LETTERS, '#'];
|
|
80
|
+
const idOf = (l) => `${base}-${l === '#' ? 'other' : l.toLowerCase()}`;
|
|
81
|
+
const total = [...filed.values()].reduce((n, e) => n + e.length, 0);
|
|
82
|
+
const filtering = search === true && total > 1;
|
|
83
|
+
const ld = structuredData !== false && total
|
|
84
|
+
? {
|
|
85
|
+
'@context': 'https://schema.org',
|
|
86
|
+
'@type': 'DefinedTermSet',
|
|
87
|
+
...(titleText ? { name: titleText } : {}),
|
|
88
|
+
hasDefinedTerm: [...filed.values()].flat().map((e) => ({ '@type': 'DefinedTerm', name: e.term, ...(e.definition ? { description: e.definition } : {}) })),
|
|
89
|
+
}
|
|
90
|
+
: null;
|
|
91
|
+
return (_jsx("section", { className: "sw-block sw-glossary", "data-sw-filter": filtering ? 'terms' : undefined, "aria-labelledby": titleText ? `${key}-title` : undefined, children: _jsxs("div", { className: "sw-container", children: [titleText ? (_jsx("h2", { className: "sw-glossary__title", id: `${key}-title`, children: title })) : null, textOf(intro).trim() ? _jsx("p", { className: "sw-glossary__intro", children: intro }) : null, _jsx("nav", { className: "sw-glossary__letters", "aria-label": titleText ? `${titleText}: letters` : 'Glossary letters', children: _jsx("ul", { children: letters.map((l) => (_jsx("li", { children: filed.has(l) ? (_jsx("a", { href: `#${idOf(l)}`, "data-sw-filter-letter": idOf(l), children: l })) : (_jsx("span", { className: "sw-glossary__letter-empty", "aria-disabled": "true", children: l })) }, l))) }) }), filtering ? (_jsxs("div", { className: "sw-filter", "data-sw-filter-tools": "", hidden: true, children: [_jsxs("div", { className: "sw-filter__field", children: [_jsx("label", { htmlFor: `${key}-q`, children: "Search terms" }), _jsx("input", { id: `${key}-q`, className: "sw-filter__input", type: "search", autoComplete: "off", "data-sw-filter-input": "" })] }), _jsx("p", { className: "sw-filter__status", role: "status", "data-sw-filter-status": "" })] })) : null, total === 0 ? _jsx("p", { className: "sw-glossary__empty", children: "No terms yet." }) : null, letters
|
|
92
|
+
.filter((l) => filed.has(l))
|
|
93
|
+
.map((l) => (_jsxs("section", { className: "sw-glossary__section", id: idOf(l), "aria-labelledby": `${idOf(l)}-h`, "data-sw-filter-group": idOf(l), children: [_jsx(Letter, { className: "sw-glossary__letter", id: `${idOf(l)}-h`, children: l === '#' ? _jsx("span", { "aria-label": "Numbers and symbols", children: "#" }) : l }), _jsx("dl", { className: "sw-glossary__list", children: filed.get(l).map((e) => (_jsxs("div", { className: "sw-glossary__entry", id: e.id, "data-sw-filter-item": "", children: [_jsx("dt", { className: cx('sw-glossary__term'), children: e.href ? _jsx("a", { href: e.href, children: e.term }) : e.term }), _jsx("dd", { className: "sw-glossary__definition", children: e.definition })] }, e.id))) })] }, l))), filtering ? (_jsx("p", { className: "sw-glossary__empty", "data-sw-filter-empty": "", hidden: true, children: "No terms match." })) : null, ld ? _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: ldJson(ld) } }) : null] }) }));
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
export const GLOSSARY_CSS = `
|
|
97
|
+
/* ---------- Glossary ---------- */
|
|
98
|
+
.sw-glossary__title { margin: 0 0 var(--sw-space-1); }
|
|
99
|
+
.sw-glossary__intro { margin: 0 0 var(--sw-space-2); color: var(--sw-color-muted); max-width: 70ch; }
|
|
100
|
+
.sw-glossary__letters ul { display: flex; flex-wrap: wrap; gap: 0.25rem; list-style: none; margin: 0 0 var(--sw-space-2); padding: 0; }
|
|
101
|
+
.sw-glossary__letters a, .sw-glossary__letter-empty { display: inline-flex; align-items: center; justify-content: center; min-width: 2.75rem; min-height: 2.75rem; border-radius: var(--sw-radius); font-weight: 700; text-decoration: none; }
|
|
102
|
+
.sw-glossary__letters a { color: var(--sw-color-primary); border: 1px solid var(--sw-color-border); }
|
|
103
|
+
.sw-glossary__letters a:hover { background: var(--sw-color-surface); }
|
|
104
|
+
.sw-glossary__letters a:focus-visible { outline: none; box-shadow: var(--sw-focus-ring); }
|
|
105
|
+
.sw-glossary__letter-empty { color: var(--sw-color-muted); }
|
|
106
|
+
.sw-glossary__section { scroll-margin-top: var(--sw-space-3); }
|
|
107
|
+
.sw-glossary__section + .sw-glossary__section { margin-top: var(--sw-space-3); }
|
|
108
|
+
.sw-glossary__letter { margin: 0 0 var(--sw-space-1); padding-bottom: 0.25rem; border-bottom: 2px solid var(--sw-color-primary); font-size: 1.5rem; }
|
|
109
|
+
.sw-glossary__list { margin: 0; }
|
|
110
|
+
.sw-glossary__entry { padding: var(--sw-space-1) 0; border-bottom: 1px solid var(--sw-color-border); scroll-margin-top: var(--sw-space-3); }
|
|
111
|
+
.sw-glossary__entry:target { background: var(--sw-color-surface); }
|
|
112
|
+
.sw-glossary__term { font-weight: 700; }
|
|
113
|
+
.sw-glossary__definition { margin: 0.25rem 0 0; max-width: 70ch; }
|
|
114
|
+
.sw-glossary__empty { color: var(--sw-color-muted); }
|
|
115
|
+
.sw-glossary__empty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E,CACX,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;CAoB3B,CAAC"}
|
package/dist/hours.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hours of operation (docs/dev/utility-blocks.md): weekly hours per location, dated exceptions (holidays, closures, special hours)
|
|
3
|
+
* and a status line ("Open now, closes at 5:00 PM") computed in the site's time zone (or the block's). The server renders the
|
|
4
|
+
* status from its clock (`resolved`), so it is right with no script; UTILITY_SCRIPT refreshes it every minute from the schedule
|
|
5
|
+
* in `data-sw-hours-schedule`. Each location carries its schema.org place with OpeningHoursSpecification. Server-safe and pure.
|
|
6
|
+
*/
|
|
7
|
+
import type { ComponentConfig } from '@puckeditor/core';
|
|
8
|
+
import { type HoursClock, type HoursException, type HoursRow } from '@spillway-cms/shared';
|
|
9
|
+
export interface HoursLocation {
|
|
10
|
+
/** The location's name (stored as `title`, which translation reads as copy). */
|
|
11
|
+
title: string;
|
|
12
|
+
address?: string;
|
|
13
|
+
phone?: string;
|
|
14
|
+
note?: string;
|
|
15
|
+
hours: HoursRow[];
|
|
16
|
+
}
|
|
17
|
+
export interface HoursProps {
|
|
18
|
+
title: string;
|
|
19
|
+
locations: HoursLocation[];
|
|
20
|
+
/** Dated exceptions; `location` names the one it applies to, empty for every location. */
|
|
21
|
+
exceptions: HoursException[];
|
|
22
|
+
/** An IANA time zone for this block; empty uses the site's. */
|
|
23
|
+
timeZone: string;
|
|
24
|
+
clock: HoursClock;
|
|
25
|
+
showWeek: boolean;
|
|
26
|
+
/** Lists exceptions in the next 60 days under Holiday hours. */
|
|
27
|
+
showExceptions: boolean;
|
|
28
|
+
schemaType: 'LocalBusiness' | 'GovernmentOffice' | 'Library' | 'Place';
|
|
29
|
+
structuredData: boolean;
|
|
30
|
+
/** Added by the server's resolver, never stored: its clock and the time zone used. */
|
|
31
|
+
resolved?: {
|
|
32
|
+
now: number;
|
|
33
|
+
timeZone: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export declare const HOURS_SCHEMA_TYPES: readonly ["LocalBusiness", "GovernmentOffice", "Library", "Place"];
|
|
37
|
+
/** The rows that are well formed (a known day and two HH:MM times). */
|
|
38
|
+
export declare function cleanRows(rows: unknown): HoursRow[];
|
|
39
|
+
/** The exceptions that apply to a location (its own and those for every location), well formed. */
|
|
40
|
+
export declare function exceptionsFor(exceptions: unknown, location: string): HoursException[];
|
|
41
|
+
/** The schema.org place for one location: its weekly rows and its exceptions as OpeningHoursSpecification. */
|
|
42
|
+
export declare function hoursJsonLd(type: string, loc: HoursLocation, rows: HoursRow[], exceptions: HoursException[]): Record<string, unknown>;
|
|
43
|
+
export declare const hoursComponent: ComponentConfig<HoursProps>;
|
|
44
|
+
export declare const HOURS_CSS = "\n/* ---------- Hours of operation ---------- */\n.sw-hours__title { margin: 0 0 var(--sw-space-2); }\n.sw-hours__grid { display: grid; gap: var(--sw-space-3); }\n@media (min-width: 640px) { .sw-hours__grid--many { grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); } }\n.sw-hours__location { padding: var(--sw-space-2); border: 1px solid var(--sw-color-border); border-radius: var(--sw-radius); background: var(--sw-color-bg); }\n.sw-hours__name { margin: 0 0 var(--sw-space-1); font-size: 1.25rem; }\n.sw-hours__status { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 var(--sw-space-1); font-weight: 600; }\n.sw-hours__status::before { content: \"\"; flex: none; width: 0.625rem; height: 0.625rem; border-radius: 50%; background: var(--sw-color-muted); }\n.sw-hours__status--open::before { background: var(--sw-color-success, #15803d); }\n.sw-hours__status--closed::before { background: var(--sw-color-danger, #b91c1c); }\n.sw-hours__status[hidden] { display: none; }\n.sw-hours__detail, .sw-hours__note { margin: 0 0 0.25rem; color: var(--sw-color-muted); }\n.sw-hours__week { width: 100%; margin-top: var(--sw-space-1); border-collapse: collapse; font-variant-numeric: tabular-nums; }\n.sw-hours__week th, .sw-hours__week td { padding: 0.375rem 0; text-align: left; border-bottom: 1px solid var(--sw-color-border); vertical-align: top; }\n.sw-hours__week th { font-weight: 400; padding-right: var(--sw-space-2); }\n.sw-hours__today th, .sw-hours__today td { font-weight: 700; }\n.sw-hours__exceptions { margin-top: var(--sw-space-2); }\n.sw-hours__subhead { margin: 0 0 0.25rem; font-weight: 700; }\n.sw-hours__exceptions ul { margin: 0; padding-left: 1.25rem; }\n.sw-hours__exception-date { font-weight: 600; }\n";
|
package/dist/hours.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DATE_RE, HOURS_DAY_LABELS, HOURS_DAYS, formatClock, formatDateRange, hoursStatus, minutesOf, upcomingExceptions, weeklyTable, zoneOr, } from '@spillway-cms/shared';
|
|
3
|
+
import { cx, keyFor, ldJson, textOf } from './utility-shared.js';
|
|
4
|
+
export const HOURS_SCHEMA_TYPES = ['LocalBusiness', 'GovernmentOffice', 'Library', 'Place'];
|
|
5
|
+
const DAY_URL = {
|
|
6
|
+
MO: ['Monday'],
|
|
7
|
+
TU: ['Tuesday'],
|
|
8
|
+
WE: ['Wednesday'],
|
|
9
|
+
TH: ['Thursday'],
|
|
10
|
+
FR: ['Friday'],
|
|
11
|
+
SA: ['Saturday'],
|
|
12
|
+
SU: ['Sunday'],
|
|
13
|
+
weekdays: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
|
|
14
|
+
weekend: ['Saturday', 'Sunday'],
|
|
15
|
+
daily: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
|
|
16
|
+
};
|
|
17
|
+
/** The rows that are well formed (a known day and two HH:MM times). */
|
|
18
|
+
export function cleanRows(rows) {
|
|
19
|
+
return (Array.isArray(rows) ? rows : []).filter((r) => !!r && HOURS_DAYS.includes(r.day) && minutesOf(r.opens) !== null && minutesOf(r.closes) !== null);
|
|
20
|
+
}
|
|
21
|
+
/** The exceptions that apply to a location (its own and those for every location), well formed. */
|
|
22
|
+
export function exceptionsFor(exceptions, location) {
|
|
23
|
+
const name = location.trim().toLowerCase();
|
|
24
|
+
return (Array.isArray(exceptions) ? exceptions : [])
|
|
25
|
+
.filter((e) => !!e && typeof e.date === 'string' && DATE_RE.test(e.date.trim()))
|
|
26
|
+
.filter((e) => !e.location?.trim() || e.location.trim().toLowerCase() === name)
|
|
27
|
+
.map((e) => ({ ...e, date: e.date.trim(), ...(e.endDate?.trim() ? { endDate: e.endDate.trim() } : {}), closed: e.closed === true || e.closed === 'true' || minutesOf(e.opens) === null || minutesOf(e.closes) === null }));
|
|
28
|
+
}
|
|
29
|
+
/** The schema.org place for one location: its weekly rows and its exceptions as OpeningHoursSpecification. */
|
|
30
|
+
export function hoursJsonLd(type, loc, rows, exceptions) {
|
|
31
|
+
const spec = rows.map((r) => ({ '@type': 'OpeningHoursSpecification', dayOfWeek: DAY_URL[r.day].map((d) => `https://schema.org/${d}`), opens: r.opens, closes: r.closes }));
|
|
32
|
+
for (const e of exceptions) {
|
|
33
|
+
spec.push({ '@type': 'OpeningHoursSpecification', validFrom: e.date, validThrough: e.endDate && e.endDate >= e.date ? e.endDate : e.date, opens: e.closed ? '00:00' : e.opens, closes: e.closed ? '00:00' : e.closes });
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
'@context': 'https://schema.org',
|
|
37
|
+
'@type': HOURS_SCHEMA_TYPES.includes(type) ? type : 'LocalBusiness',
|
|
38
|
+
name: loc.title,
|
|
39
|
+
...(loc.address?.trim() ? { address: loc.address.trim() } : {}),
|
|
40
|
+
...(loc.phone?.trim() ? { telephone: loc.phone.trim() } : {}),
|
|
41
|
+
openingHoursSpecification: spec,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const dayOptions = HOURS_DAYS.map((d) => ({ label: HOURS_DAY_LABELS[d], value: d }));
|
|
45
|
+
export const hoursComponent = {
|
|
46
|
+
label: 'Hours of operation',
|
|
47
|
+
fields: {
|
|
48
|
+
title: { type: 'text', label: 'Title', contentEditable: true },
|
|
49
|
+
locations: {
|
|
50
|
+
type: 'array',
|
|
51
|
+
label: 'Locations',
|
|
52
|
+
min: 1,
|
|
53
|
+
max: 12,
|
|
54
|
+
getItemSummary: (item, i) => item.title || `Location ${(i ?? 0) + 1}`,
|
|
55
|
+
arrayFields: {
|
|
56
|
+
title: { type: 'text', label: 'Name' },
|
|
57
|
+
address: { type: 'text', label: 'Address' },
|
|
58
|
+
phone: { type: 'text', label: 'Phone' },
|
|
59
|
+
note: { type: 'textarea', label: 'Note' },
|
|
60
|
+
hours: {
|
|
61
|
+
type: 'array',
|
|
62
|
+
label: 'Weekly hours (a day with no row is closed)',
|
|
63
|
+
getItemSummary: (r) => (r?.day ? `${HOURS_DAY_LABELS[r.day] ?? r.day} ${r.opens ?? ''}–${r.closes ?? ''}` : 'Hours'),
|
|
64
|
+
arrayFields: {
|
|
65
|
+
day: { type: 'select', label: 'Day', options: dayOptions },
|
|
66
|
+
opens: { type: 'text', label: 'Opens (HH:MM)', placeholder: '09:00' },
|
|
67
|
+
closes: { type: 'text', label: 'Closes (HH:MM)', placeholder: '17:00' },
|
|
68
|
+
},
|
|
69
|
+
defaultItemProps: { day: 'weekdays', opens: '09:00', closes: '17:00' },
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
defaultItemProps: { title: 'Office', address: '', phone: '', note: '', hours: [{ day: 'weekdays', opens: '09:00', closes: '17:00' }] },
|
|
73
|
+
},
|
|
74
|
+
exceptions: {
|
|
75
|
+
type: 'array',
|
|
76
|
+
label: 'Exceptions and holidays',
|
|
77
|
+
getItemSummary: (e, i) => (e?.date ? `${e.date}${e.label ? ` ${e.label}` : ''}` : `Exception ${(i ?? 0) + 1}`),
|
|
78
|
+
arrayFields: {
|
|
79
|
+
date: { type: 'text', label: 'Date (YYYY-MM-DD)', placeholder: '2026-12-25' },
|
|
80
|
+
endDate: { type: 'text', label: 'Through (YYYY-MM-DD, optional)' },
|
|
81
|
+
label: { type: 'text', label: 'Label', placeholder: 'Winter break' },
|
|
82
|
+
closed: { type: 'radio', label: 'Hours', options: [{ label: 'Closed', value: true }, { label: 'Open', value: false }] },
|
|
83
|
+
opens: { type: 'text', label: 'Opens (HH:MM)' },
|
|
84
|
+
closes: { type: 'text', label: 'Closes (HH:MM)' },
|
|
85
|
+
location: { type: 'text', label: 'Location (empty: every location)' },
|
|
86
|
+
},
|
|
87
|
+
defaultItemProps: { date: '', endDate: '', label: '', closed: true, opens: '', closes: '', location: '' },
|
|
88
|
+
},
|
|
89
|
+
timeZone: { type: 'text', label: 'Time zone (empty: the site’s)', placeholder: 'America/Chicago' },
|
|
90
|
+
clock: { type: 'radio', label: 'Times', options: [{ label: '12-hour', value: '12' }, { label: '24-hour', value: '24' }] },
|
|
91
|
+
showWeek: { type: 'radio', label: 'Weekly table', options: [{ label: 'Show', value: true }, { label: 'Hide', value: false }] },
|
|
92
|
+
showExceptions: { type: 'radio', label: 'Holiday hours (the next 60 days)', options: [{ label: 'Show', value: true }, { label: 'Hide', value: false }] },
|
|
93
|
+
schemaType: { type: 'select', label: 'Structured data type', options: HOURS_SCHEMA_TYPES.map((t) => ({ label: t === 'LocalBusiness' ? 'Local business' : t === 'GovernmentOffice' ? 'Government office' : t, value: t })) },
|
|
94
|
+
structuredData: { type: 'radio', label: 'Opening hours in search results', options: [{ label: 'On', value: true }, { label: 'Off', value: false }] },
|
|
95
|
+
},
|
|
96
|
+
defaultProps: {
|
|
97
|
+
title: 'Hours',
|
|
98
|
+
locations: [
|
|
99
|
+
{
|
|
100
|
+
title: 'Main office',
|
|
101
|
+
address: '',
|
|
102
|
+
phone: '',
|
|
103
|
+
note: '',
|
|
104
|
+
hours: [
|
|
105
|
+
{ day: 'weekdays', opens: '08:30', closes: '17:00' },
|
|
106
|
+
{ day: 'SA', opens: '10:00', closes: '14:00' },
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
exceptions: [],
|
|
111
|
+
timeZone: '',
|
|
112
|
+
clock: '12',
|
|
113
|
+
showWeek: true,
|
|
114
|
+
showExceptions: true,
|
|
115
|
+
schemaType: 'LocalBusiness',
|
|
116
|
+
structuredData: true,
|
|
117
|
+
},
|
|
118
|
+
render: (props) => {
|
|
119
|
+
const { title, locations, exceptions, timeZone, clock, showWeek, showExceptions, schemaType, structuredData, resolved } = props;
|
|
120
|
+
const tz = resolved?.timeZone ?? zoneOr(timeZone);
|
|
121
|
+
const ck = clock === '24' ? '24' : '12';
|
|
122
|
+
const key = keyFor('hours', props.id, JSON.stringify(locations ?? []).slice(0, 200));
|
|
123
|
+
const titleText = textOf(title);
|
|
124
|
+
const Name = titleText ? 'h3' : 'h2';
|
|
125
|
+
const list = (Array.isArray(locations) ? locations : []).filter((l) => l && (textOf(l.title).trim() || cleanRows(l.hours).length));
|
|
126
|
+
return (_jsx("section", { className: "sw-block sw-hours", "data-sw-hours": "", "data-tz": tz, "data-clock": ck, "aria-labelledby": titleText ? `${key}-title` : undefined, children: _jsxs("div", { className: "sw-container", children: [titleText ? (_jsx("h2", { className: "sw-hours__title", id: `${key}-title`, children: title })) : null, _jsx("div", { className: cx('sw-hours__grid', list.length > 1 && 'sw-hours__grid--many'), children: list.map((loc, i) => {
|
|
127
|
+
const name = textOf(loc.title).trim();
|
|
128
|
+
const rows = cleanRows(loc.hours);
|
|
129
|
+
const ex = exceptionsFor(exceptions, name);
|
|
130
|
+
const status = resolved ? hoursStatus({ rows, exceptions: ex }, resolved.now, tz, ck) : null;
|
|
131
|
+
const upcoming = showExceptions !== false && status ? upcomingExceptions(ex, status.today) : [];
|
|
132
|
+
const schedule = JSON.stringify({ rows: rows.map((r) => [r.day, r.opens, r.closes]), ex: ex.map((e) => [e.date, e.endDate ?? '', e.label ?? '', e.closed ? 1 : 0, e.opens ?? '', e.closes ?? '']) });
|
|
133
|
+
return (_jsxs("article", { className: "sw-hours__location", "data-sw-hours-schedule": schedule, "aria-labelledby": name ? `${key}-${i}` : undefined, children: [name ? (_jsx(Name, { className: "sw-hours__name", id: `${key}-${i}`, children: name })) : null, _jsx("p", { className: cx('sw-hours__status', status && (status.open ? 'sw-hours__status--open' : 'sw-hours__status--closed')), "data-sw-hours-status": "", hidden: status ? undefined : true, children: status?.text ?? '' }), loc.address?.trim() ? _jsx("p", { className: "sw-hours__detail", children: loc.address }) : null, loc.phone?.trim() ? (_jsx("p", { className: "sw-hours__detail", children: _jsx("a", { href: `tel:${loc.phone.replace(/[^\d+]/g, '')}`, children: loc.phone }) })) : null, loc.note?.trim() ? _jsx("p", { className: "sw-hours__note", children: loc.note }) : null, showWeek !== false ? (_jsxs("table", { className: "sw-hours__week", children: [_jsx("caption", { className: "sw-visually-hidden", children: name ? `Weekly hours, ${name}` : 'Weekly hours' }), _jsx("tbody", { children: weeklyTable(rows, ck).map((d, wd) => (_jsxs("tr", { "data-weekday": wd, className: status?.weekday === wd ? 'sw-hours__today' : undefined, "aria-current": status?.weekday === wd ? 'date' : undefined, children: [_jsx("th", { scope: "row", children: d.day }), _jsx("td", { children: d.hours })] }, d.day))) })] })) : null, upcoming.length ? (_jsxs("div", { className: "sw-hours__exceptions", children: [_jsx("p", { className: "sw-hours__subhead", children: "Holiday hours" }), _jsx("ul", { children: upcoming.map((e, j) => {
|
|
134
|
+
const o = minutesOf(e.opens);
|
|
135
|
+
const c = minutesOf(e.closes);
|
|
136
|
+
return (_jsxs("li", { children: [_jsx("span", { className: "sw-hours__exception-date", children: formatDateRange(e.date, e.endDate) }), `${e.label?.trim() ? ` (${e.label.trim()})` : ''}: ${e.closed || o === null || c === null ? 'Closed' : `${formatClock(o, ck)} to ${formatClock(c, ck)}`}`] }, j));
|
|
137
|
+
}) })] })) : null, structuredData !== false && name && (rows.length || ex.length) ? _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: ldJson(hoursJsonLd(schemaType, { ...loc, title: name }, rows, ex)) } }) : null] }, i));
|
|
138
|
+
}) })] }) }));
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
export const HOURS_CSS = `
|
|
142
|
+
/* ---------- Hours of operation ---------- */
|
|
143
|
+
.sw-hours__title { margin: 0 0 var(--sw-space-2); }
|
|
144
|
+
.sw-hours__grid { display: grid; gap: var(--sw-space-3); }
|
|
145
|
+
@media (min-width: 640px) { .sw-hours__grid--many { grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); } }
|
|
146
|
+
.sw-hours__location { padding: var(--sw-space-2); border: 1px solid var(--sw-color-border); border-radius: var(--sw-radius); background: var(--sw-color-bg); }
|
|
147
|
+
.sw-hours__name { margin: 0 0 var(--sw-space-1); font-size: 1.25rem; }
|
|
148
|
+
.sw-hours__status { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 var(--sw-space-1); font-weight: 600; }
|
|
149
|
+
.sw-hours__status::before { content: ""; flex: none; width: 0.625rem; height: 0.625rem; border-radius: 50%; background: var(--sw-color-muted); }
|
|
150
|
+
.sw-hours__status--open::before { background: var(--sw-color-success, #15803d); }
|
|
151
|
+
.sw-hours__status--closed::before { background: var(--sw-color-danger, #b91c1c); }
|
|
152
|
+
.sw-hours__status[hidden] { display: none; }
|
|
153
|
+
.sw-hours__detail, .sw-hours__note { margin: 0 0 0.25rem; color: var(--sw-color-muted); }
|
|
154
|
+
.sw-hours__week { width: 100%; margin-top: var(--sw-space-1); border-collapse: collapse; font-variant-numeric: tabular-nums; }
|
|
155
|
+
.sw-hours__week th, .sw-hours__week td { padding: 0.375rem 0; text-align: left; border-bottom: 1px solid var(--sw-color-border); vertical-align: top; }
|
|
156
|
+
.sw-hours__week th { font-weight: 400; padding-right: var(--sw-space-2); }
|
|
157
|
+
.sw-hours__today th, .sw-hours__today td { font-weight: 700; }
|
|
158
|
+
.sw-hours__exceptions { margin-top: var(--sw-space-2); }
|
|
159
|
+
.sw-hours__subhead { margin: 0 0 0.25rem; font-weight: 700; }
|
|
160
|
+
.sw-hours__exceptions ul { margin: 0; padding-left: 1.25rem; }
|
|
161
|
+
.sw-hours__exception-date { font-weight: 600; }
|
|
162
|
+
`;
|
|
163
|
+
//# sourceMappingURL=hours.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hours.js","sourceRoot":"","sources":["../src/hours.tsx"],"names":[],"mappings":";AAOA,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,eAAe,EACf,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,MAAM,GAKP,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA2BjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,eAAe,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AACrG,MAAM,OAAO,GAA6B;IACxC,EAAE,EAAE,CAAC,QAAQ,CAAC;IACd,EAAE,EAAE,CAAC,SAAS,CAAC;IACf,EAAE,EAAE,CAAC,WAAW,CAAC;IACjB,EAAE,EAAE,CAAC,UAAU,CAAC;IAChB,EAAE,EAAE,CAAC,QAAQ,CAAC;IACd,EAAE,EAAE,CAAC,UAAU,CAAC;IAChB,EAAE,EAAE,CAAC,QAAQ,CAAC;IACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAC;IAClE,OAAO,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC;IAC/B,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC;CACtF,CAAC;AAEF,uEAAuE;AACvE,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,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CAAC,UAAU,EAAE,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAI,CAAC,CAAC,CAAC,IAAI,KA9C3M,CAAC,CA+CL,CACX,CAAC;wBACJ,CAAC,CAAC,GACE,IACF,GACE,CACX,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBxB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export { isLottieFile, isModelFile } from './players.js';
|
|
|
12
12
|
export { MOTION_CSS, MOTION_SCRIPT, MOTION_STORAGE_KEY } from './motion.js';
|
|
13
13
|
export type { BlocksConfig, BlockName, BlockProps, BlockCategory, HeroProps, HeadingProps, TextProps, ImageProps, ColumnsProps, CallToActionProps, CardsProps, CardItem, SectionProps, SpacerProps, DividerProps, EmbedProps, ButtonProps, RootProps, } from './config.js';
|
|
14
14
|
export type { CollectionProps, CollectionDisplay, ListingData } from './collection.js';
|
|
15
|
+
export { isInteractiveCollection } from './collection.js';
|
|
16
|
+
export { LISTING_SCRIPT } from './listing-script.js';
|
|
15
17
|
export type { FaqProps, FaqItem, TestimonialsProps, Testimonial, StatsProps, Stat, LogoStripProps, Logo } from './marketing.js';
|
|
16
18
|
export type { ScrollytellingProps, StoryStep } from './story.js';
|
|
17
19
|
export { WIDGETS_SCRIPT, WIDGET_BLOCKS, needsWidgetsScript, slugify } from './widgets.js';
|
|
@@ -20,7 +22,19 @@ export type { IconDef, IconShape, IconProps } from './icons.js';
|
|
|
20
22
|
export { headingTree, deepestLevel } from './toc.js';
|
|
21
23
|
export type { OnThisPageProps, TocHeading } from './toc.js';
|
|
22
24
|
export { anchorIdOf } from './config.js';
|
|
25
|
+
export { LOCMAP_SCRIPT, LOCATION_MAP_BLOCKS, osmPlaceUrl } from './location-map.js';
|
|
26
|
+
export type { LocationMapProps, LocationMapHeight } from './location-map.js';
|
|
23
27
|
export type { AccordionProps, AccordionItem, TabsProps, TabsTab, CarouselProps, CarouselSlide, CarouselVariant } from './widgets.js';
|
|
28
|
+
export { UTILITY_SCRIPT, UTILITY_BLOCKS, needsUtilityScript } from './utility-script.js';
|
|
29
|
+
export type { CountdownProps } from './countdown.js';
|
|
30
|
+
export { cleanRows, exceptionsFor, hoursJsonLd, HOURS_SCHEMA_TYPES } from './hours.js';
|
|
31
|
+
export type { HoursProps, HoursLocation } from './hours.js';
|
|
32
|
+
export { formatBytes, familyOf, groupItems } from './documents.js';
|
|
33
|
+
export type { DocumentLibraryProps } from './documents.js';
|
|
34
|
+
export { fileTerms, letterOf, GLOSSARY_LETTERS } from './glossary.js';
|
|
35
|
+
export type { GlossaryProps, GlossaryTerm } from './glossary.js';
|
|
36
|
+
export { formatAmount, percentOf } from './progress.js';
|
|
37
|
+
export type { CampaignProgressProps } from './progress.js';
|
|
24
38
|
export type { LottieProps, Model3DProps } from './players.js';
|
|
25
39
|
export { captionTracks, isCaptionsFile, isVideoFile, isoDuration, remoteVideoOf, videoLightboxId, videoObject } from './video.js';
|
|
26
40
|
export type { VideoProps, VideoTrack, ResolvedVideo, RemoteVideo } from './video.js';
|
|
@@ -43,6 +57,8 @@ export { searchFieldId, type SearchProps } from './search.js';
|
|
|
43
57
|
export { ANSWER_SCRIPT, askFieldId, type AskProps } from './ask.js';
|
|
44
58
|
export type { MenuBlockProps, MenuBlockItem } from './menu.js';
|
|
45
59
|
export type { BreadcrumbsBlockProps, BreadcrumbItem } from './breadcrumbs.js';
|
|
60
|
+
export { LanguageSwitcherNav } from './language-switcher.js';
|
|
61
|
+
export type { LanguageSwitcherBlockProps, LanguageSwitcherDisplay, LanguageSwitcherNavProps } from './language-switcher.js';
|
|
46
62
|
export type { RegistryStatsProps } from './registry-stats.js';
|
|
47
63
|
export type { ThemeGalleryProps } from './registry-gallery.js';
|
|
48
64
|
export type { PublisherProfileProps } from './registry-publisher.js';
|
package/dist/index.js
CHANGED
|
@@ -10,10 +10,18 @@ export { config } from './config.js';
|
|
|
10
10
|
export { hasMotion, motionAttributes, MOTION_ITEM_BLOCKS, MOTION_SCRIPT_BLOCKS, PLAYER_BLOCKS } from './config.js';
|
|
11
11
|
export { isLottieFile, isModelFile } from './players.js';
|
|
12
12
|
export { MOTION_CSS, MOTION_SCRIPT, MOTION_STORAGE_KEY } from './motion.js';
|
|
13
|
+
export { isInteractiveCollection } from './collection.js';
|
|
14
|
+
export { LISTING_SCRIPT } from './listing-script.js';
|
|
13
15
|
export { WIDGETS_SCRIPT, WIDGET_BLOCKS, needsWidgetsScript, slugify } from './widgets.js';
|
|
14
16
|
export { Icon, ICONS, ICON_NAMES, ICON_SOURCE, isIconName, iconField } from './icons.js';
|
|
15
17
|
export { headingTree, deepestLevel } from './toc.js';
|
|
16
18
|
export { anchorIdOf } from './config.js';
|
|
19
|
+
export { LOCMAP_SCRIPT, LOCATION_MAP_BLOCKS, osmPlaceUrl } from './location-map.js';
|
|
20
|
+
export { UTILITY_SCRIPT, UTILITY_BLOCKS, needsUtilityScript } from './utility-script.js';
|
|
21
|
+
export { cleanRows, exceptionsFor, hoursJsonLd, HOURS_SCHEMA_TYPES } from './hours.js';
|
|
22
|
+
export { formatBytes, familyOf, groupItems } from './documents.js';
|
|
23
|
+
export { fileTerms, letterOf, GLOSSARY_LETTERS } from './glossary.js';
|
|
24
|
+
export { formatAmount, percentOf } from './progress.js';
|
|
17
25
|
export { captionTracks, isCaptionsFile, isVideoFile, isoDuration, remoteVideoOf, videoLightboxId, videoObject } from './video.js';
|
|
18
26
|
export { renderForm } from './form.js';
|
|
19
27
|
export { ResponsiveImage, focalPosition } from './image.js';
|
|
@@ -22,6 +30,7 @@ export { COPY_SCRIPT } from './registry-package.js';
|
|
|
22
30
|
export { LIGHTBOX_SCRIPT, lightboxId } from './gallery.js';
|
|
23
31
|
export { searchFieldId } from './search.js';
|
|
24
32
|
export { ANSWER_SCRIPT, askFieldId } from './ask.js';
|
|
33
|
+
export { LanguageSwitcherNav } from './language-switcher.js';
|
|
25
34
|
export { DOCS_FEEDBACK_SCRIPT } from './docs-feedback.js';
|
|
26
35
|
export { moduleBlockClass } from './module-block.js';
|
|
27
36
|
export { REGISTRY_KIND_LABELS, explainCapability } from './registry-types.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAsB5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE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,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAoBrD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,IAAI,kBAAkB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1G,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzN,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACtK,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Language switcher block (docs/dev/language-switcher.md): links to this page in the site's other languages, or to a
|
|
3
|
+
* language's home page with a note when this page has no translation in it. A navigation landmark with a label; every link
|
|
4
|
+
* carries `lang` and `hreflang`, the page's own language `aria-current="page"`; names, never flags. No script: the Menu display
|
|
5
|
+
* is a `<details>` disclosure. The server resolves `languages` before render (core i18n/switcher.ts); the site header shows
|
|
6
|
+
* the same markup through `LanguageSwitcherNav` when Site settings → Languages turns it on. A link to a machine translation of the
|
|
7
|
+
* page (Site settings → Languages → Machine translation) carries the note "machine translated" instead, and `rel="nofollow"`
|
|
8
|
+
* so crawlers, which must not index it, do not spend the site's translation budget following it.
|
|
9
|
+
*/
|
|
10
|
+
import type { ComponentConfig } from '@puckeditor/core';
|
|
11
|
+
import { type LanguageLink } from '@spillway-cms/shared';
|
|
12
|
+
export type LanguageSwitcherDisplay = 'links' | 'menu';
|
|
13
|
+
export interface LanguageSwitcherBlockProps {
|
|
14
|
+
display: LanguageSwitcherDisplay;
|
|
15
|
+
/** The landmark's name (and the Menu display's button text). */
|
|
16
|
+
label: string;
|
|
17
|
+
/** The words after a language whose link goes to its home page because this page is not translated into it. */
|
|
18
|
+
note: string;
|
|
19
|
+
/** Resolved by the server; never stored. */
|
|
20
|
+
languages?: LanguageLink[];
|
|
21
|
+
/** The page's own locale, resolved with `languages`: the note's `lang`. */
|
|
22
|
+
pageLocale?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface LanguageSwitcherNavProps {
|
|
25
|
+
languages: LanguageLink[];
|
|
26
|
+
display: LanguageSwitcherDisplay;
|
|
27
|
+
label?: string;
|
|
28
|
+
note?: string;
|
|
29
|
+
/** The words after a language whose link goes to a machine translation of this page (default MACHINE_TRANSLATION_NOTE). */
|
|
30
|
+
machineNote?: string;
|
|
31
|
+
/** The page's locale (the note's language); the current link's locale when absent. */
|
|
32
|
+
pageLocale?: string;
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
/** The switcher's markup, shared by the block and the site header. Renders nothing without at least one other language. */
|
|
36
|
+
export declare function LanguageSwitcherNav({ languages, display, label, note, machineNote, pageLocale, className }: LanguageSwitcherNavProps): import("react").JSX.Element | null;
|
|
37
|
+
export declare const languageSwitcherBlockComponent: ComponentConfig<LanguageSwitcherBlockProps>;
|
|
38
|
+
export declare const languageSwitcherCss = "/* ---------- Language switcher ---------- */\n.sw-language-switcher-block { padding: var(--sw-space-2, 0.75rem) 0; }\n.sw-language-switcher__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }\n.sw-language-switcher__list a { display: inline-block; padding: 0.35rem 0.15rem; font-weight: 500; text-decoration: none; color: inherit; }\n.sw-language-switcher__list a:hover { text-decoration: underline; }\n.sw-language-switcher__list a[aria-current=\"page\"] { font-weight: 700; color: var(--sw-color-primary); text-decoration: underline; text-underline-offset: 0.2em; }\n.sw-language-switcher__list a:focus-visible, .sw-language-switcher__summary:focus-visible { outline: 2px solid var(--sw-color-primary); outline-offset: 2px; }\n.sw-language-switcher__note { font-weight: 400; font-size: 0.875em; color: var(--sw-color-muted, #555); }\n.sw-language-switcher__menu { position: relative; display: inline-block; }\n.sw-language-switcher__summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.75rem; font-weight: 600; border: 1px solid color-mix(in srgb, currentColor 25%, transparent); border-radius: var(--sw-radius, 8px); }\n.sw-language-switcher__summary::-webkit-details-marker { display: none; }\n.sw-language-switcher__summary::after { content: \"\"; width: 0.45em; height: 0.45em; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); margin-top: -0.25em; }\n.sw-language-switcher__menu[open] > .sw-language-switcher__summary::after { transform: rotate(225deg); margin-top: 0.15em; }\n.sw-language-switcher__menu .sw-language-switcher__list { flex-direction: column; gap: 0; margin-top: 0.35rem; padding: 0.35rem; min-width: 12rem; border: 1px solid color-mix(in srgb, currentColor 15%, transparent); border-radius: var(--sw-radius, 8px); background: var(--sw-color-bg, #fff); }\n.sw-language-switcher__menu .sw-language-switcher__list a { display: block; padding: 0.45rem 0.6rem; }\n@media (min-width: 600px) { .sw-language-switcher__menu .sw-language-switcher__list { position: absolute; right: 0; z-index: 30; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12); } }\n.sw-language-switcher__placeholder { padding: 0.75rem 1rem; border: 1px dashed color-mix(in srgb, currentColor 30%, transparent); border-radius: var(--sw-radius, 8px); font-size: 0.9rem; }\n";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { LANGUAGE_SWITCHER_NOTE, MACHINE_TRANSLATION_NOTE } from '@spillway-cms/shared';
|
|
3
|
+
/** The switcher's markup, shared by the block and the site header. Renders nothing without at least one other language. */
|
|
4
|
+
export function LanguageSwitcherNav({ languages, display, label, note, machineNote, pageLocale, className }) {
|
|
5
|
+
const links = languages.filter((l) => l && typeof l.href === 'string' && typeof l.locale === 'string');
|
|
6
|
+
if (!links.some((l) => !l.current))
|
|
7
|
+
return null;
|
|
8
|
+
const name = label?.trim() || 'Language';
|
|
9
|
+
const words = note?.trim() || LANGUAGE_SWITCHER_NOTE;
|
|
10
|
+
const machineWords = machineNote?.trim() || MACHINE_TRANSLATION_NOTE;
|
|
11
|
+
const current = links.find((l) => l.current);
|
|
12
|
+
const ownLang = pageLocale || current?.locale;
|
|
13
|
+
const list = (_jsx("ul", { className: "sw-language-switcher__list", children: links.map((l) => (_jsx("li", { className: "sw-language-switcher__item", children: _jsxs("a", { href: l.href, hrefLang: l.locale, lang: l.locale, rel: l.machine && !l.current ? 'nofollow' : undefined, "aria-current": l.current ? 'page' : undefined, children: [l.label, l.machine || !l.translated ? (_jsx("span", { className: l.machine ? 'sw-language-switcher__note sw-language-switcher__note--machine' : 'sw-language-switcher__note', lang: ownLang, children: ` (${l.machine ? machineWords : words})` })) : null] }) }, l.locale))) }));
|
|
14
|
+
const cls = ['sw-language-switcher', `sw-language-switcher--${display}`, className].filter(Boolean).join(' ');
|
|
15
|
+
return (_jsx("nav", { className: cls, "aria-label": name, children: display === 'menu' ? (_jsxs("details", { className: "sw-language-switcher__menu", children: [_jsxs("summary", { className: "sw-language-switcher__summary", children: [`${name}: `, _jsx("span", { lang: current?.locale, children: current?.label ?? '' })] }), list] })) : (list) }));
|
|
16
|
+
}
|
|
17
|
+
export const languageSwitcherBlockComponent = {
|
|
18
|
+
label: 'Language switcher',
|
|
19
|
+
fields: {
|
|
20
|
+
display: {
|
|
21
|
+
type: 'radio',
|
|
22
|
+
label: 'Display',
|
|
23
|
+
options: [
|
|
24
|
+
{ label: 'Links', value: 'links' },
|
|
25
|
+
{ label: 'Menu', value: 'menu' },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
label: { type: 'text', label: 'Label' },
|
|
29
|
+
note: { type: 'text', label: 'Note on languages without this page' },
|
|
30
|
+
},
|
|
31
|
+
defaultProps: { display: 'links', label: 'Language', note: LANGUAGE_SWITCHER_NOTE },
|
|
32
|
+
render: ({ languages, display, label, note, pageLocale, puck }) => {
|
|
33
|
+
const links = Array.isArray(languages) ? languages : [];
|
|
34
|
+
if (!links.some((l) => l && !l.current)) {
|
|
35
|
+
if (!puck?.isEditing)
|
|
36
|
+
return _jsx(_Fragment, {});
|
|
37
|
+
return (_jsx("section", { className: "sw-block sw-language-switcher sw-language-switcher--placeholder", children: _jsx("div", { className: "sw-container", children: _jsx("div", { className: "sw-language-switcher__placeholder", role: "note", children: "Language switcher: links to this page in the site\u2019s other languages, shown on the published page when the site has more than one language." }) }) }));
|
|
38
|
+
}
|
|
39
|
+
return (_jsx("div", { className: "sw-block sw-language-switcher-block", children: _jsx("div", { className: "sw-container", children: _jsx(LanguageSwitcherNav, { languages: links, display: display === 'menu' ? 'menu' : 'links', label: label, note: note, pageLocale: pageLocale }) }) }));
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export const languageSwitcherCss = `/* ---------- Language switcher ---------- */
|
|
43
|
+
.sw-language-switcher-block { padding: var(--sw-space-2, 0.75rem) 0; }
|
|
44
|
+
.sw-language-switcher__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
|
|
45
|
+
.sw-language-switcher__list a { display: inline-block; padding: 0.35rem 0.15rem; font-weight: 500; text-decoration: none; color: inherit; }
|
|
46
|
+
.sw-language-switcher__list a:hover { text-decoration: underline; }
|
|
47
|
+
.sw-language-switcher__list a[aria-current="page"] { font-weight: 700; color: var(--sw-color-primary); text-decoration: underline; text-underline-offset: 0.2em; }
|
|
48
|
+
.sw-language-switcher__list a:focus-visible, .sw-language-switcher__summary:focus-visible { outline: 2px solid var(--sw-color-primary); outline-offset: 2px; }
|
|
49
|
+
.sw-language-switcher__note { font-weight: 400; font-size: 0.875em; color: var(--sw-color-muted, #555); }
|
|
50
|
+
.sw-language-switcher__menu { position: relative; display: inline-block; }
|
|
51
|
+
.sw-language-switcher__summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.75rem; font-weight: 600; border: 1px solid color-mix(in srgb, currentColor 25%, transparent); border-radius: var(--sw-radius, 8px); }
|
|
52
|
+
.sw-language-switcher__summary::-webkit-details-marker { display: none; }
|
|
53
|
+
.sw-language-switcher__summary::after { content: ""; width: 0.45em; height: 0.45em; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); margin-top: -0.25em; }
|
|
54
|
+
.sw-language-switcher__menu[open] > .sw-language-switcher__summary::after { transform: rotate(225deg); margin-top: 0.15em; }
|
|
55
|
+
.sw-language-switcher__menu .sw-language-switcher__list { flex-direction: column; gap: 0; margin-top: 0.35rem; padding: 0.35rem; min-width: 12rem; border: 1px solid color-mix(in srgb, currentColor 15%, transparent); border-radius: var(--sw-radius, 8px); background: var(--sw-color-bg, #fff); }
|
|
56
|
+
.sw-language-switcher__menu .sw-language-switcher__list a { display: block; padding: 0.45rem 0.6rem; }
|
|
57
|
+
@media (min-width: 600px) { .sw-language-switcher__menu .sw-language-switcher__list { position: absolute; right: 0; z-index: 30; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12); } }
|
|
58
|
+
.sw-language-switcher__placeholder { padding: 0.75rem 1rem; border: 1px dashed color-mix(in srgb, currentColor 30%, transparent); border-radius: var(--sw-radius, 8px); font-size: 0.9rem; }
|
|
59
|
+
`;
|
|
60
|
+
//# sourceMappingURL=language-switcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-switcher.js","sourceRoot":"","sources":["../src/language-switcher.tsx"],"names":[],"mappings":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ACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;CAiBlC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Collection block's listing script, carried once by a page with an interactive Collection block (filters, a pager, sorting
|
|
3
|
+
* or page sizes; `isInteractiveCollection`). It is progressive enhancement only: the server renders a plain GET form and links.
|
|
4
|
+
*
|
|
5
|
+
* With the script, the filter form, the A to Z letters, the pager and the sort links load the new view in place: it fetches the
|
|
6
|
+
* page at the new URL (the same server render, cached per query), swaps the block's content for the fetched block's (the n-th
|
|
7
|
+
* `[data-sw-listing]` of the page), writes the new result count into the existing live region so screen readers announce it, and
|
|
8
|
+
* pushes the URL, so the address stays shareable and the back button goes back to the previous view (popstate loads it again).
|
|
9
|
+
* The count and (after a submit) the form are never taken out of the page, so the live region keeps announcing and focus stays
|
|
10
|
+
* on the control that was used; a letter link focuses the new letter, the pager and sort links focus the results.
|
|
11
|
+
* The form is kept as the visitor left it after a submit; Back loads the earlier form too. Any failure falls back to a normal page load.
|
|
12
|
+
*/
|
|
13
|
+
export declare const LISTING_SCRIPT = "(function(){var d=document,h=d.documentElement;if(h.hasAttribute('data-sw-listing-ready'))return;h.setAttribute('data-sw-listing-ready','');\nif(!window.fetch||!window.DOMParser||!window.URLSearchParams||!window.FormData||!history.pushState)return;\nvar here=location.pathname+location.search;\nfunction all(doc){return doc.querySelectorAll('[data-sw-listing]')}\nfunction indexOf(el){var a=all(d);for(var i=0;i<a.length;i++)if(a[i]===el)return i;return -1}\nfunction swap(el,next,keep){var cur=el.querySelector('.sw-container'),nw=next.querySelector('.sw-container');if(!cur||!nw)throw 0;\nvar count=cur.querySelector('[data-sw-listing-count]'),form=keep?cur.querySelector('form.sw-listing__form'):null,act=d.activeElement,kids=[],c,n;\nfor(c=nw.firstElementChild;c;c=c.nextElementSibling)kids.push(c);\nfor(c=cur.firstChild;c;c=n){n=c.nextSibling;if(c!==count&&c!==form)cur.removeChild(c)}\nvar ref=cur.firstChild;\nfor(var i=0;i<kids.length;i++){var k=kids[i];\nif(count&&k.hasAttribute('data-sw-listing-count')){if(count.textContent!==k.textContent)count.textContent=k.textContent;ref=count.nextSibling;continue}\nif(form&&k.matches('form.sw-listing__form')){ref=form.nextSibling;continue}\ncur.insertBefore(d.importNode(k,true),ref)}\nif(act&&act!==d.body&&d.contains(act)&&d.activeElement!==act)try{act.focus()}catch(e){}}\nfunction load(el,url,opts){var i=indexOf(el);if(i<0){location.href=url;return}el.setAttribute('aria-busy','true');\nfetch(url,{credentials:'same-origin',headers:{Accept:'text/html'}}).then(function(r){if(!r.ok)throw 0;return r.text()}).then(function(html){\nvar next=all(new DOMParser().parseFromString(html,'text/html'))[i];if(!next)throw 0;swap(el,next,opts.keep);el.removeAttribute('aria-busy');\nif(opts.push){history.pushState({swListing:1},'',url);here=location.pathname+location.search}\nif(opts.focus)opts.focus(el)}).catch(function(){location.href=url})}\nfunction results(el){var r=el.querySelector('.sw-collection__results')||el.querySelector('[data-sw-listing-count]');if(r){if(!r.hasAttribute('tabindex'))r.setAttribute('tabindex','-1');try{r.focus()}catch(e){}}}\nd.addEventListener('submit',function(e){var f=e.target;if(!f.matches||!f.matches('form.sw-listing__form'))return;var el=f.closest('[data-sw-listing]');if(!el)return;\ne.preventDefault();var sp=new URLSearchParams();new FormData(f).forEach(function(v,k){if(typeof v==='string'&&v!=='')sp.append(k,v)});\nvar qs=sp.toString(),u=new URL(f.getAttribute('action')||location.pathname,location.href);load(el,u.pathname+(qs?'?'+qs:''),{push:true,keep:true})});\nd.addEventListener('click',function(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;\nvar a=e.target.closest&&e.target.closest('a[href]');if(!a||!a.matches('.sw-listing__letter,.sw-listing__pager a,.sw-collection__sort,.sw-listing__reset'))return;\nvar el=a.closest('[data-sw-listing]');if(!el)return;var u=new URL(a.href,location.href);if(u.origin!==location.origin)return;e.preventDefault();\nvar letter=a.classList.contains('sw-listing__letter')?a.textContent:null;\nload(el,u.pathname+u.search,{push:true,focus:function(b){if(letter!==null){var ls=b.querySelectorAll('.sw-listing__letter');for(var j=0;j<ls.length;j++)if(ls[j].textContent===letter&&ls[j].tagName==='A'){ls[j].focus();return}}results(b)}})});\nwindow.addEventListener('popstate',function(){var now=location.pathname+location.search;if(now===here)return;here=now;var a=all(d);for(var i=0;i<a.length;i++)load(a[i],now,{push:false})});\n})();";
|