@uvalib/web-components 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +56 -12
- package/dist/base/states.d.ts +12 -0
- package/dist/base/states.js +33 -0
- package/dist/base/states.js.map +1 -0
- package/dist/base.css +15 -5
- package/dist/components/bento-box/BentoBox.js +1 -0
- package/dist/components/bento-box/BentoBox.js.map +1 -1
- package/dist/components/events-section/EventsSection.js +1 -0
- package/dist/components/events-section/EventsSection.js.map +1 -1
- package/dist/components/library-hours/hours-data.js +1 -1
- package/dist/components/library-hours/hours-data.js.map +1 -1
- package/dist/components/library-weekly-hours/LibraryWeeklyHours.js +1 -0
- package/dist/components/library-weekly-hours/LibraryWeeklyHours.js.map +1 -1
- package/dist/components/uvalib-card/UvalibCard.js +6 -0
- package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
- package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +27 -0
- package/dist/components/uvalib-combobox/UvalibCombobox.js +85 -1
- package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -1
- package/dist/components/uvalib-contents/UvalibContents.js +5 -0
- package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +6 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +10 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -1
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js +2 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -1
- package/dist/components/uvalib-image-regions/regions.d.ts +6 -2
- package/dist/components/uvalib-image-regions/regions.js +6 -3
- package/dist/components/uvalib-image-regions/regions.js.map +1 -1
- package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +9 -2
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +23 -3
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-lightbox/compare.d.ts +30 -3
- package/dist/components/uvalib-lightbox/compare.js +98 -29
- package/dist/components/uvalib-lightbox/compare.js.map +1 -1
- package/dist/components/uvalib-map/UvalibMap.js +2 -2
- package/dist/components/uvalib-map/UvalibMap.js.map +1 -1
- package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -0
- package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +3 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +3 -3
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +16 -8
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
- package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +4 -1
- package/dist/components/uvalib-tag-list/UvalibTagList.js +9 -2
- package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -1
- package/dist/custom-elements.json +1926 -1637
- package/dist/styles/message.js +4 -0
- package/dist/styles/message.js.map +1 -1
- package/dist/styles/result-list.js +25 -4
- package/dist/styles/result-list.js.map +1 -1
- package/dist/styles/results.js +17 -2
- package/dist/styles/results.js.map +1 -1
- package/dist-cdn/base.css +15 -5
- package/dist-cdn/bento-box.js +1 -0
- package/dist-cdn/bento-box.js.map +1 -1
- package/dist-cdn/chunks/{compare-DV6ltvsJ.js → compare-C0nhByn7.js} +66 -29
- package/dist-cdn/chunks/compare-C0nhByn7.js.map +1 -0
- package/dist-cdn/chunks/{hours-data-Bw6vkIw7.js → hours-data-gMu5uT7H.js} +2 -2
- package/dist-cdn/chunks/hours-data-gMu5uT7H.js.map +1 -0
- package/dist-cdn/chunks/{library-weekly-hours-CrV3TlP5.js → library-weekly-hours-BJgxAyah.js} +3 -2
- package/dist-cdn/chunks/library-weekly-hours-BJgxAyah.js.map +1 -0
- package/dist-cdn/chunks/{regions-B8ExwUGP.js → regions-B-rOwa-v.js} +15 -15
- package/dist-cdn/chunks/regions-B-rOwa-v.js.map +1 -0
- package/dist-cdn/chunks/states-DGXGzcte.js +17 -0
- package/dist-cdn/chunks/states-DGXGzcte.js.map +1 -0
- package/dist-cdn/custom-elements.json +1926 -1637
- package/dist-cdn/events-section.js +1 -0
- package/dist-cdn/events-section.js.map +1 -1
- package/dist-cdn/library-hours-setup.js +1 -1
- package/dist-cdn/library-weekly-hours.js +1 -1
- package/dist-cdn/manifest.json +1 -1
- package/dist-cdn/site-hours-section.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +5 -4
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +33 -6
- package/dist-cdn/uvalib-card.js +6 -0
- package/dist-cdn/uvalib-card.js.map +1 -1
- package/dist-cdn/uvalib-combobox.js +107 -68
- package/dist-cdn/uvalib-combobox.js.map +1 -1
- package/dist-cdn/uvalib-contents.js +5 -0
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-filter-drawer.js +27 -25
- package/dist-cdn/uvalib-filter-drawer.js.map +1 -1
- package/dist-cdn/uvalib-image-regions.js +3 -1
- package/dist-cdn/uvalib-image-regions.js.map +1 -1
- package/dist-cdn/uvalib-lightbox.js +80 -69
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-map.js +2 -2
- package/dist-cdn/uvalib-map.js.map +1 -1
- package/dist-cdn/uvalib-metadata.js +3 -0
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pagefind-search.js +2 -1
- package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +4 -5
- package/dist-cdn/uvalib-photo-grid.js.map +1 -1
- package/dist-cdn/uvalib-tag-list.js +21 -16
- package/dist-cdn/uvalib-tag-list.js.map +1 -1
- package/package.json +1 -1
- package/skills/uvalib-web-components/SKILL.md +5 -4
- package/skills/uvalib-web-components/reference/components.md +33 -6
- package/dist-cdn/chunks/compare-DV6ltvsJ.js.map +0 -1
- package/dist-cdn/chunks/hours-data-Bw6vkIw7.js.map +0 -1
- package/dist-cdn/chunks/library-weekly-hours-CrV3TlP5.js.map +0 -1
- package/dist-cdn/chunks/regions-B8ExwUGP.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events-section.js","names":["unsafeCSS","nothing","unsafeStatic","_decorate","property","state","n","i","r$1","define","__decorate","A","r","installLightDomStyles","UvalibElement","precedingHeadingLevel","s","trackEvent","trackError","accessible","fetchJson","formatter","todayInNewYork","TIME_ZONE","PARAMS","eventsEndpoints","eventsTiming","EXTRA","MAX_FETCH","setEventsEndpoints","key","value","from","globalApplied","endpoints","ADDED","eventsUrl","base","query","q","path","search","kept","pair","count","limit","category","SAFE_PROTOCOLS","safeUrl","parseEvents","list","json","out","title","url","start","end","upcoming","events","now","a","b","cache","loadEvents","hit","maxAge","entry","ny","options","plain","part","o","at","p","type","clock","shortDay","zone","eventWhen","multiDay","time","DEFAULT_LIMIT","DEFAULT_LEVEL","structuralRules","host","shadowStructure","lightTitleMargin","tag","EventsSection","_args","root","sheet","above","node","changed","id","background","all","card","position","hadFocus","active","max","chars","when","h","placeholders","e"],"sources":["../src/components/events-section/events-data.ts","../src/components/events-section/EventsSection.ts","../src/components/events-section/events-section.ts"],"sourcesContent":["// Data and formatting for <events-section>: upcoming events from LibCal. Internal: not\n// exported from the package entry (only the EventItem type is). No side effects on import.\n\nimport { fetchJson } from '../../data/fetch-json.js';\nimport { TIME_ZONE, formatter, todayInNewYork } from '../../data/new-york.js';\n\n/** One event, reduced to what the section shows. */\nexport interface EventItem {\n title: string;\n /** The event's public LibCal page. */\n url: string;\n /** Start and end instants (ms since the epoch). */\n start: number;\n end: number;\n allDay: boolean;\n}\n\n/** The two LibCal URLs, with their fixed parameters; `limit`, `category` and `search` are added. */\nexport interface EventsEndpoints {\n /** The event list (no search query). */\n events: string;\n /** The event search, used when the element has a `query`. */\n search: string;\n}\n\n/**\n * LibCal's public, read-only events widget key (already public in the live bundles), the\n * library's LibCal instance (863) and its public events calendar (4299). LibCal caps `days`\n * at about 30.\n */\nconst PARAMS = 'key=c45a1428103ed000ba4025e9970edf54&iid=863&cal_id=4299&days=30';\n\n/**\n * Where events come from, shared by every <events-section> (and exposed to pages as the\n * element's static `endpoints`). A page can also set `window.uvalibEventsEndpoints`\n * (`{ events?, search? }`) before the element's script runs; it is merged in at the first\n * fetch. Requests are cached by URL, so a change applies to the next load.\n */\nexport const eventsEndpoints: EventsEndpoints = {\n events: `https://cal.lib.virginia.edu/api/1.0/events?${PARAMS}`,\n search: `https://cal.lib.virginia.edu/api/1.0/event_search?${PARAMS}`,\n};\n\n/**\n * Fetch attempts, the delay between them (ms) and each attempt's timeout (ms); how often (ms)\n * an element checks its events (after an error it tries again; otherwise it drops ended\n * events), and the age (ms) after which that check fetches them again.\n */\nexport const eventsTiming = {\n retries: 3,\n retryDelay: 1000,\n timeout: 10_000,\n retryEvery: 60_000,\n maxAge: 3_600_000,\n};\n\n/** Events fetched beyond `limit`, so the list still fills once ended events are dropped. */\nconst EXTRA = 10;\n/** LibCal's own maximum `limit`. */\nconst MAX_FETCH = 100;\n\ndeclare global {\n interface Window {\n /** Optional endpoint overrides for <events-section>, read at its first fetch. */\n uvalibEventsEndpoints?: Partial<EventsEndpoints>;\n }\n}\n\n/** Copy the known endpoint keys (strings only) from `from` into the shared endpoints. */\nexport function setEventsEndpoints(from: Partial<EventsEndpoints> | null | undefined): void {\n for (const key of ['events', 'search'] as const) {\n const value = from?.[key];\n if (typeof value === 'string' && value) eventsEndpoints[key] = value;\n }\n}\n\nlet globalApplied = false;\nfunction endpoints(): EventsEndpoints {\n if (!globalApplied) {\n globalApplied = true;\n setEventsEndpoints(globalThis.window?.uvalibEventsEndpoints);\n }\n return eventsEndpoints;\n}\n\n/** What an element asks for. */\nexport interface EventsQuery {\n limit: number;\n /** LibCal category id(s), comma-separated. */\n category?: string;\n /** Search text: uses the `search` endpoint. */\n query?: string;\n}\n\nconst ADDED = new Set(['limit', 'category', 'search']);\n\n/**\n * The LibCal URL for `q`: the endpoint with `limit` (ten more than asked for, at most 100),\n * and `category` and `search` when set. Any of those three already in the endpoint is\n * dropped first, so no parameter is sent twice. Values are encoded with encodeURIComponent\n * (commas in a category list are kept).\n */\nexport function eventsUrl({ limit, category, query }: EventsQuery): string {\n const base = query ? endpoints().search : endpoints().events;\n const q = base.indexOf('?');\n const [path, search] = q < 0 ? [base, ''] : [base.slice(0, q), base.slice(q + 1)];\n const kept = search\n .split('&')\n .filter((pair) => pair && !ADDED.has(decodeURIComponent(pair.split('=')[0]!)));\n const count = Math.min(Math.max(1, Math.trunc(limit) || 0) + EXTRA, MAX_FETCH);\n kept.push(`limit=${count}`);\n if (category) kept.push(`category=${encodeURIComponent(category).replace(/%2C/gi, ',')}`);\n if (query) kept.push(`search=${encodeURIComponent(query)}`);\n return `${path}?${kept.join('&')}`;\n}\n\nconst SAFE_PROTOCOLS = new Set(['http:', 'https:']);\n\nfunction safeUrl(value: unknown): string | undefined {\n if (typeof value !== 'string' || !value) return undefined;\n try {\n return SAFE_PROTOCOLS.has(new URL(value).protocol) ? value : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * LibCal's `{ events: [...] }` reduced to EventItem, in response order. Events without a\n * title, a public http(s) URL, or a parseable start and end (end not before start) are\n * skipped; everything else LibCal sends (descriptions, owners, seats…) is dropped.\n */\nexport function parseEvents(json: unknown): EventItem[] {\n const list = (json as { events?: unknown } | null)?.events;\n if (!Array.isArray(list)) return [];\n const out: EventItem[] = [];\n for (const e of list as Record<string, unknown>[]) {\n if (!e || typeof e !== 'object') continue;\n const title = typeof e.title === 'string' ? e.title.trim() : '';\n const url = safeUrl((e.url as { public?: unknown } | null)?.public);\n const start = typeof e.start === 'string' ? Date.parse(e.start) : NaN;\n const end = typeof e.end === 'string' ? Date.parse(e.end) : NaN;\n if (!title || !url || !Number.isFinite(start) || !Number.isFinite(end) || end < start) continue;\n out.push({ title, url, start, end, allDay: e.allday === true });\n }\n return out;\n}\n\n/** The first `limit` events that have not ended at `now`, by start time. */\nexport function upcoming(\n events: readonly EventItem[],\n limit: number,\n now = Date.now(),\n): EventItem[] {\n return events\n .filter((e) => e.end > now)\n .sort((a, b) => a.start - b.start)\n .slice(0, Math.max(0, limit));\n}\n\ninterface CacheEntry {\n at: number;\n promise: Promise<EventItem[]>;\n}\nconst cache = new Map<string, CacheEntry>();\n\n/**\n * The events for `q` (all of them, ended ones included: see `upcoming`). Identical requests\n * share one fetch; a cached answer older than `maxAge` ms is fetched again. A failure is not\n * cached.\n */\nexport function loadEvents(q: EventsQuery, maxAge = Infinity): Promise<EventItem[]> {\n const url = eventsUrl(q);\n const hit = cache.get(url);\n if (hit && performance.now() - hit.at <= maxAge) return hit.promise;\n const entry: CacheEntry = {\n at: performance.now(),\n promise: fetchJson(url, eventsTiming).then(parseEvents),\n };\n cache.set(url, entry);\n entry.promise.catch(() => {\n if (cache.get(url) === entry) cache.delete(url);\n });\n return entry.promise;\n}\n\n/** Forget cached events and re-read `window.uvalibEventsEndpoints` (for tests). */\nexport function resetEventsCache(): void {\n cache.clear();\n globalApplied = false;\n}\n\n// --- dates, in America/New_York ----------------------------------------------------------\n\n/** How an event's date and time are shown. */\nexport interface EventWhen {\n /** The start's New York date, `YYYY-MM-DD`, for `<time datetime>`. */\n datetime: string;\n /** \"Nov\", \"16\", \"Mon\": the date column. */\n month: string;\n day: string;\n weekday: string;\n /** \"Monday, November 16\": the date column for assistive technology. */\n fullDate: string;\n /** \"11:00 AM - 12:00 PM EST\", \"All day\", or with dates for a multi-day event. */\n time: string;\n}\n\nconst ny = (key: string, options: Intl.DateTimeFormatOptions) =>\n formatter(`events-${key}`, { ...options, timeZone: TIME_ZONE });\n\n/** Intl's narrow and plain no-break spaces (before AM/PM) as plain spaces. */\nconst plain = (s: string) => s.replace(/[ ]/g, ' ');\n\nfunction part(\n at: number,\n type: Intl.DateTimeFormatPartTypes,\n key: string,\n o: Intl.DateTimeFormatOptions,\n) {\n return (\n ny(key, o)\n .formatToParts(at)\n .find((p) => p.type === type)?.value ?? ''\n );\n}\n\nconst clock = (at: number) => plain(ny('clock', { hour: 'numeric', minute: '2-digit' }).format(at));\nconst shortDay = (at: number) => ny('short', { month: 'short', day: 'numeric' }).format(at);\nconst zone = (at: number) => part(at, 'timeZoneName', 'zone', { timeZoneName: 'short' });\n\n/** The date column and time line for `e`, in America/New_York. */\nexport function eventWhen(e: EventItem): EventWhen {\n const { start, end } = e;\n const multiDay = todayInNewYork(start) !== todayInNewYork(end);\n let time: string;\n if (e.allDay) time = multiDay ? `${shortDay(start)} - ${shortDay(end)}, all day` : 'All day';\n else if (multiDay)\n time = `${shortDay(start)}, ${clock(start)} - ${shortDay(end)}, ${clock(end)} ${zone(end)}`;\n else time = `${clock(start)} - ${clock(end)} ${zone(end)}`;\n return {\n datetime: todayInNewYork(start),\n month: part(start, 'month', 'month', { month: 'short' }),\n day: part(start, 'day', 'day', { day: 'numeric' }),\n weekday: part(start, 'weekday', 'weekday', { weekday: 'short' }),\n fullDate: ny('full', { weekday: 'long', month: 'long', day: 'numeric' }).format(start),\n time,\n };\n}\n","import { precedingHeadingLevel } from '../../base/heading-level.js';\nimport { css, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { html, unsafeStatic, type StaticValue } from 'lit/static-html.js';\nimport { property, state } from 'lit/decorators.js';\nimport { trackError, trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { accessible } from '../../styles/accessible.js';\nimport {\n eventWhen,\n eventsEndpoints,\n eventsTiming,\n loadEvents,\n setEventsEndpoints,\n upcoming,\n type EventItem,\n type EventsEndpoints,\n} from './events-data.js';\n\n/**\n * `loading` until the first answer, then `ready` (events shown), `empty` (no upcoming events)\n * or `error` (they could not be loaded).\n */\nexport type EventsState = 'loading' | 'ready' | 'empty' | 'error';\n\nconst DEFAULT_LIMIT = 8;\nconst DEFAULT_LEVEL = 3;\n\n/**\n * The rules the element needs even with `no-style`, where the Drupal theme styles the cards:\n * the host is a block, placeholder cards are invisible, titles are clamped to three lines (the\n * whole title stays in the DOM), the status line sits over the top of the cards at a constant\n * one-line height so it never moves anything, and `[hidden]` hides. `host` is `:host`\n * (shadow) or the tag name (light DOM, so they stay scoped).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; position: relative; }\n ${host}[loading] { min-height: var(--events-section-min-height, 0); }\n ${host} .event-placeholder { visibility: hidden; }\n ${host} .event-title {\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 3;\n line-clamp: 3;\n overflow: hidden;\n }\n ${host} .event-url:hover .event-title { text-decoration: underline; }\n ${host} .events-status {\n position: absolute;\n inset-block-start: 0;\n inset-inline: 0;\n min-height: 1.5em;\n min-height: 1lh;\n pointer-events: none;\n }\n ${host} .events-status button { pointer-events: auto; }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n ${host} .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/**\n * Light DOM only, unlayered: the card title's top margin. The Drupal theme gives `h3` a 3rem\n * top margin and `h4` 1rem, and `.event-title` sets none, so without this the default h3\n * titles would push every card 2rem taller than the old h4 ones. 1rem is the old h4 value,\n * so the cards keep their geometry whatever `heading-level` is. Unlayered (and more\n * specific than a bare `h3`) so it beats the page's own heading rules.\n */\nconst lightTitleMargin = (tag: string) =>\n unsafeCSS(`${tag} .event-url .event-title { margin-block-start: 1rem; }`);\n\n/**\n * Upcoming UVA Library events from LibCal, as on the library.virginia.edu home page: a grid of\n * cards, each one link with the event's title, a date column (month, day, weekday) and its\n * time, in America/New_York. Events that have ended are left out. Light DOM output keeps the\n * classes the Drupal theme styles (`event-container`, `event`, `event-url`, `event-title`,\n * `event-date`, `event--month`, `event--day`, `event--wkday`, `event-time`).\n *\n * @tagname events-section\n * @fires uvalib-analytics-event - For `<site-analytics>`: a click on an event, `['events-section', 'event-click', <category id, or all>, <position, from 1>]` (never its title or URL), and `['events-section', 'error', 'events-load']` once when the events cannot be loaded. Bubbles and is composed.\n * @cssprop [--events-section-min-height=0] - Height the element keeps during its first load (while it has the `loading` attribute). Its placeholder cards already hold the final height; this only matters for a page that wants more. Applies with `no-style` too. Pages can reserve height before the element upgrades with `events-section:not(:defined) { display: block; min-height: … }`.\n * @cssprop [--uva-brand-orange-dark=#b35900] - Background of the date column (white text on it is 4.8:1).\n * @cssprop [--uva-brand-blue=#232d4b] - Event title colour.\n * @cssprop --uva-color-link - Dark-mode role token: event title colour (else `--uva-brand-blue`).\n * @cssprop --uva-color-text - Dark-mode role token: time and status text (else #2b2b2b).\n * @cssprop --uva-color-border - Dark-mode role token: card border (else #dadada).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: card and button background (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class EventsSection extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n container-type: inline-size;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .event-container {\n display: grid;\n grid-template-columns: repeat(4, minmax(0, 1fr));\n gap: 2rem;\n align-items: stretch;\n }\n /* Four columns only where each card leaves its time line room for a multi-day range\n on two lines; two below 75rem (as the Drupal theme does inside /rmc's columns), one\n below 40rem. */\n @container (width < 75rem) {\n .event-container {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n }\n }\n @container (width < 40rem) {\n .event-container {\n grid-template-columns: minmax(0, 1fr);\n }\n }\n .event {\n display: grid;\n }\n .event-url {\n display: grid;\n grid-template-columns: 4.5rem minmax(0, 1fr);\n grid-template-rows: 1fr auto;\n column-gap: 1rem;\n min-height: 9rem;\n box-sizing: border-box;\n border: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n background: var(--uva-color-surface-raised, #fff);\n color: inherit;\n text-decoration: none;\n }\n .event-date {\n grid-area: 1 / 1 / 3 / 2;\n display: flex;\n flex-direction: column;\n align-items: center;\n margin: 0;\n padding: 1rem 0.25rem;\n background: var(--uva-brand-orange-dark, #b35900);\n color: #fff;\n text-align: center;\n line-height: 1.2;\n font-weight: bold;\n }\n .event--month,\n .event--wkday {\n font-size: 1.0625rem;\n }\n .event--day {\n font-size: 1.75rem;\n }\n .event-title {\n grid-area: 1 / 2 / 2 / 3;\n align-self: start;\n /* A 1rem top margin, as light DOM gets unlayered (see lightTitleMargin). */\n margin: 1rem 0 0;\n padding: 0 1rem 0 0;\n min-height: 3lh;\n font-size: 1rem;\n line-height: 1.3;\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n .event-time {\n grid-area: 2 / 2 / 3 / 3;\n margin: 0;\n padding: 0.5rem 1rem 1rem 0;\n /* Two lines, so a multi-day range (\"Nov 20, 9:00 AM - Nov 21, 5:00 PM EST\") that\n wraps does not make its row taller than the placeholders. */\n min-height: 2lh;\n font-size: 0.9375rem;\n line-height: 1.3;\n }\n .events-status {\n line-height: 1.5;\n }\n .uvalib-button {\n font: inherit;\n margin-inline-start: 0.5rem;\n padding: 0.1rem 0.75rem;\n border: 1px solid var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n border-radius: 0.3rem;\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n cursor: pointer;\n }\n .uvalib-button[aria-disabled='true'] {\n cursor: progress;\n }\n `,\n ];\n\n /**\n * The LibCal URLs shared by every `<events-section>`: `events` and `search` (used with\n * `query`). Assigning an object (or setting a key) changes them for every element from the\n * next load on. To repoint before elements already in the HTML start fetching, set\n * `window.uvalibEventsEndpoints` before the define script runs.\n */\n static get endpoints(): EventsEndpoints {\n return eventsEndpoints;\n }\n static set endpoints(value: Partial<EventsEndpoints>) {\n setEventsEndpoints(value);\n }\n\n /** How many events to show (at most; fewer when fewer are coming up). */\n @property({ type: Number })\n limit = 8;\n\n /** Only events in this LibCal category (its id, for example `38740`; several comma-separated). */\n @property({ type: String })\n category?: string;\n\n /** Only events matching this search text (LibCal's event search). */\n @property({ type: String })\n query?: string;\n\n /**\n * Cut titles longer than this many characters, with \"…\", for sighted users; assistive\n * technology still gets the whole title. Titles are clamped to three lines anyway, so this\n * is only kept for old pages.\n */\n @property({ type: Number, attribute: 'max-title-length' })\n maxTitleLength?: number;\n\n /**\n * The level of each event's title heading, 1 to 6. Unset (the default), it is one below\n * the nearest heading before the element in the page (an `<h2>` above gives `<h3>`\n * titles), or 3 when there is none.\n */\n @property({ type: Number, attribute: 'heading-level' })\n headingLevel?: number;\n\n /** One below the nearest preceding heading, worked out on connect (see `level`). */\n @state() private inferredLevel = DEFAULT_LEVEL;\n\n /** `loading` (the default, until the first answer), `ready`, `empty` or `error`. Read-only. */\n get state(): EventsState {\n return this._state;\n }\n\n @state() private _state: EventsState = 'loading';\n /** The events shown: kept on screen while a later load (an attribute change) runs. */\n @state() private events?: EventItem[];\n /** A Retry click's load is running: the button stays, disabled, so focus stays on it. */\n @state() private retrying = false;\n\n private loadId = 0;\n private retryTimer?: ReturnType<typeof setInterval>;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const above = precedingHeadingLevel(this);\n this.inferredLevel = above === null ? DEFAULT_LEVEL : Math.min(above + 1, 6);\n if (this.lightDom) {\n const node = this.getRootNode();\n const root = node instanceof ShadowRoot || node instanceof Document ? node : undefined;\n if (this.noStyle)\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n { root, scope: false },\n );\n installLightDomStyles(`${this.localName}::title-margin`, lightTitleMargin(this.localName), {\n root,\n scope: false,\n layer: false,\n });\n }\n clearInterval(this.retryTimer);\n // Quietly try again after an error; once loaded, drop events that have since ended\n // (from the cache), fetching them again when the cached answer is an hour old.\n this.retryTimer = setInterval(() => {\n if (this._state !== 'loading')\n void this.load({ background: true, maxAge: eventsTiming.maxAge });\n }, eventsTiming.retryEvery);\n // Reconnected after a disconnect: catch up.\n if (this.hasUpdated) void this.load({ background: true });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n clearInterval(this.retryTimer);\n this.retryTimer = undefined;\n }\n\n private get count(): number {\n const n = Math.trunc(this.limit);\n return Number.isFinite(n) && n > 0 ? Math.min(n, 100) : DEFAULT_LIMIT;\n }\n\n private get level(): number {\n const n = Math.trunc(this.headingLevel ?? Number.NaN);\n return n >= 1 && n <= 6 ? n : this.inferredLevel;\n }\n\n protected override willUpdate(changed: PropertyValues<this>) {\n if (!this.isConnected) return;\n if (!this.hasUpdated || changed.has('limit') || changed.has('category') || changed.has('query'))\n void this.load();\n }\n\n protected override updated() {\n // Only while nothing real is shown does --events-section-min-height apply.\n this.toggleAttribute('loading', this._state === 'loading' && !this.events?.length);\n }\n\n /**\n * Load the events. The current cards stay on screen until the new ones land. A\n * `background` load (the retry interval) does not show the loading state and, if it fails\n * while events are shown, keeps them.\n */\n private async load({\n background = false,\n maxAge = Infinity,\n }: { background?: boolean; maxAge?: number } = {}) {\n const id = ++this.loadId;\n const limit = this.count;\n if (!background) this._state = 'loading';\n try {\n const all = await loadEvents(\n {\n limit,\n category: this.category?.trim() || undefined,\n query: this.query?.trim() || undefined,\n },\n maxAge,\n );\n if (id !== this.loadId) return; // a newer load owns the element\n this.events = upcoming(all, limit);\n this._state = this.events.length ? 'ready' : 'empty';\n } catch {\n if (id !== this.loadId) return;\n if (background && this._state !== 'error') return;\n this.events = undefined;\n this._state = 'error';\n trackError(this, 'events-section', 'events-load');\n }\n }\n\n /** Analytics: which card (its position) was opened, and under which category. */\n private onClick(e: Event) {\n const card = (e.target as Element).closest('.event');\n if (!card?.querySelector('.event-url[href]')) return;\n const position = [...card.parentNode!.children].indexOf(card) + 1;\n trackEvent(this, ['events-section', 'event-click', this.category?.trim() || 'all', position]);\n }\n\n private async retry() {\n if (this.retrying) return;\n const hadFocus = this.focusedInside();\n this.retrying = true;\n try {\n await this.load();\n } finally {\n this.retrying = false;\n }\n await this.updateComplete;\n // Keep keyboard focus in the element: on the first event, on Retry again, or on the\n // status line when there is nothing else to focus.\n if (!hadFocus) return;\n const r = this.renderRoot;\n if (this._state === 'ready') r.querySelector<HTMLAnchorElement>('.event-url[href]')?.focus();\n else if (this._state === 'error')\n r.querySelector<HTMLButtonElement>('.events-status button')?.focus();\n else r.querySelector<HTMLElement>('.events-status')?.focus();\n }\n\n private focusedInside(): boolean {\n const active =\n this.renderRoot instanceof ShadowRoot\n ? this.renderRoot.activeElement\n : document.activeElement;\n return !!active && (this.renderRoot as Node).contains(active) && active !== this;\n }\n\n /** The title, or with `max-title-length` a cut copy for the eye and the whole for AT. */\n private renderTitle(title: string) {\n const max = Math.trunc(this.maxTitleLength ?? 0);\n const chars = [...title];\n if (!(max > 0) || chars.length <= max) return title;\n return html`<span aria-hidden=\"true\">${chars.slice(0, max).join('').trimEnd()}…</span\n ><span class=\"visually-hidden\">${title}</span>`;\n }\n\n private renderEvent(e: EventItem, h: StaticValue) {\n const when = eventWhen(e);\n return html`<div class=\"event\">\n <a href=${e.url} class=\"event-url\">\n <${h} class=\"event-title\">${this.renderTitle(e.title)}</${h}>\n <p class=\"event-date\">\n <span class=\"event--month\" aria-hidden=\"true\">${when.month}</span>\n <span class=\"event--day\" aria-hidden=\"true\">${when.day}</span>\n <span class=\"event--wkday\" aria-hidden=\"true\">${when.weekday}</span>\n <time class=\"visually-hidden\" datetime=${when.datetime}>${when.fullDate}</time>\n </p>\n <p class=\"event-time\">${when.time}</p>\n </a>\n </div>`;\n }\n\n /**\n * An invisible card with the real DOM and classes and typical text, so the section has its\n * final height, in the page's own font and grid, before the events arrive. Its link has no\n * href, so nothing in it is focusable.\n */\n private renderPlaceholder(h: StaticValue) {\n return html`<div class=\"event event-placeholder\" aria-hidden=\"true\">\n <a class=\"event-url\">\n <${h} class=\"event-title\">Library event</${h}>\n <p class=\"event-date\">\n <span class=\"event--month\">Nov</span>\n <span class=\"event--day\">30</span>\n <span class=\"event--wkday\">Mon</span>\n </p>\n <p class=\"event-time\">10:00 AM - 11:00 AM EST</p>\n </a>\n </div>`;\n }\n\n private renderStatus() {\n if (this.retrying || this._state === 'error')\n return html`Events are unavailable right now.\n <button\n type=\"button\"\n class=\"uvalib-button uvalib-button--basic\"\n aria-disabled=${this.retrying ? 'true' : nothing}\n @click=${this.retry}\n >\n ${this.retrying ? 'Retrying…' : 'Retry'}\n </button>`;\n switch (this._state) {\n case 'loading':\n return this.events?.length ? nothing : 'Loading events…';\n case 'empty':\n return 'No upcoming events.';\n default:\n return nothing;\n }\n }\n\n render() {\n const h = unsafeStatic(`h${this.level}`);\n const events = this.events?.length ? this.events : undefined;\n // Before the first answer: the limit's worth of placeholders, so the section has its\n // final height. Empty, failed or retrying: one row, so a failure does not leave a long\n // blank area (a phone stacks the cards in one column).\n const placeholders = events ? 0 : this._state === 'loading' && !this.retrying ? this.count : 1;\n return html`<div class=\"event-container\" @click=${this.onClick}>\n ${\n events\n ? events.map((e) => this.renderEvent(e, h))\n : Array.from({ length: placeholders }, () => this.renderPlaceholder(h))\n }\n </div>\n <div class=\"events-status\" role=\"status\" tabindex=\"-1\">${this.renderStatus()}</div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { EventsSection } from './EventsSection.js';\n\ndefine('events-section', EventsSection);\n"],"mappings":";;;;;;;;AA8BA,IAAMwB,IAAS,oEAQFC,IAAmC;CAC9C,QAAQ,+CAA+CD;CACvD,QAAQ,qDAAqDA;AAC/D,GAOaE,IAAe;CAC1B,SAAS;CACT,YAAY;CACZ,SAAS;CACT,YA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EAAA,WAAA,iBAAA,KAAA,CAAA,GAONrF,EAAA,CAAAE,EAAM,CAAA,GAAAmF,EAAA,WAAA,UAAA,KAAA,CAAA,GAENrF,EAAA,CAAAE,EAAM,CAAA,GAAAmF,EAAA,WAAA,UAAA,KAAA,CAAA,GAENrF,EAAA,CAAAE,EAAM,CAAA,GAAAmF,EAAA,WAAA,YAAA,KAAA,CAAA,GC5PT/E,EAAO,kBAAkB+E,CAAa"}
|
|
1
|
+
{"version":3,"file":"events-section.js","names":["unsafeCSS","nothing","unsafeStatic","_decorate","property","state","n","i","r$1","define","__decorate","A","r","installLightDomStyles","UvalibElement","precedingHeadingLevel","s","trackEvent","trackError","accessible","fetchJson","formatter","todayInNewYork","TIME_ZONE","PARAMS","eventsEndpoints","eventsTiming","EXTRA","MAX_FETCH","setEventsEndpoints","key","value","from","globalApplied","endpoints","ADDED","eventsUrl","base","query","q","path","search","kept","pair","count","limit","category","SAFE_PROTOCOLS","safeUrl","parseEvents","list","json","out","title","url","start","end","upcoming","events","now","a","b","cache","loadEvents","hit","maxAge","entry","ny","options","plain","part","o","at","p","type","clock","shortDay","zone","eventWhen","multiDay","time","DEFAULT_LIMIT","DEFAULT_LEVEL","structuralRules","host","shadowStructure","lightTitleMargin","tag","EventsSection","_args","root","sheet","above","node","changed","id","background","all","card","position","hadFocus","active","max","chars","when","h","placeholders","e"],"sources":["../src/components/events-section/events-data.ts","../src/components/events-section/EventsSection.ts","../src/components/events-section/events-section.ts"],"sourcesContent":["// Data and formatting for <events-section>: upcoming events from LibCal. Internal: not\n// exported from the package entry (only the EventItem type is). No side effects on import.\n\nimport { fetchJson } from '../../data/fetch-json.js';\nimport { TIME_ZONE, formatter, todayInNewYork } from '../../data/new-york.js';\n\n/** One event, reduced to what the section shows. */\nexport interface EventItem {\n title: string;\n /** The event's public LibCal page. */\n url: string;\n /** Start and end instants (ms since the epoch). */\n start: number;\n end: number;\n allDay: boolean;\n}\n\n/** The two LibCal URLs, with their fixed parameters; `limit`, `category` and `search` are added. */\nexport interface EventsEndpoints {\n /** The event list (no search query). */\n events: string;\n /** The event search, used when the element has a `query`. */\n search: string;\n}\n\n/**\n * LibCal's public, read-only events widget key (already public in the live bundles), the\n * library's LibCal instance (863) and its public events calendar (4299). LibCal caps `days`\n * at about 30.\n */\nconst PARAMS = 'key=c45a1428103ed000ba4025e9970edf54&iid=863&cal_id=4299&days=30';\n\n/**\n * Where events come from, shared by every <events-section> (and exposed to pages as the\n * element's static `endpoints`). A page can also set `window.uvalibEventsEndpoints`\n * (`{ events?, search? }`) before the element's script runs; it is merged in at the first\n * fetch. Requests are cached by URL, so a change applies to the next load.\n */\nexport const eventsEndpoints: EventsEndpoints = {\n events: `https://cal.lib.virginia.edu/api/1.0/events?${PARAMS}`,\n search: `https://cal.lib.virginia.edu/api/1.0/event_search?${PARAMS}`,\n};\n\n/**\n * Fetch attempts, the delay between them (ms) and each attempt's timeout (ms); how often (ms)\n * an element checks its events (after an error it tries again; otherwise it drops ended\n * events), and the age (ms) after which that check fetches them again.\n */\nexport const eventsTiming = {\n retries: 3,\n retryDelay: 1000,\n timeout: 10_000,\n retryEvery: 60_000,\n maxAge: 3_600_000,\n};\n\n/** Events fetched beyond `limit`, so the list still fills once ended events are dropped. */\nconst EXTRA = 10;\n/** LibCal's own maximum `limit`. */\nconst MAX_FETCH = 100;\n\ndeclare global {\n interface Window {\n /** Optional endpoint overrides for <events-section>, read at its first fetch. */\n uvalibEventsEndpoints?: Partial<EventsEndpoints>;\n }\n}\n\n/** Copy the known endpoint keys (strings only) from `from` into the shared endpoints. */\nexport function setEventsEndpoints(from: Partial<EventsEndpoints> | null | undefined): void {\n for (const key of ['events', 'search'] as const) {\n const value = from?.[key];\n if (typeof value === 'string' && value) eventsEndpoints[key] = value;\n }\n}\n\nlet globalApplied = false;\nfunction endpoints(): EventsEndpoints {\n if (!globalApplied) {\n globalApplied = true;\n setEventsEndpoints(globalThis.window?.uvalibEventsEndpoints);\n }\n return eventsEndpoints;\n}\n\n/** What an element asks for. */\nexport interface EventsQuery {\n limit: number;\n /** LibCal category id(s), comma-separated. */\n category?: string;\n /** Search text: uses the `search` endpoint. */\n query?: string;\n}\n\nconst ADDED = new Set(['limit', 'category', 'search']);\n\n/**\n * The LibCal URL for `q`: the endpoint with `limit` (ten more than asked for, at most 100),\n * and `category` and `search` when set. Any of those three already in the endpoint is\n * dropped first, so no parameter is sent twice. Values are encoded with encodeURIComponent\n * (commas in a category list are kept).\n */\nexport function eventsUrl({ limit, category, query }: EventsQuery): string {\n const base = query ? endpoints().search : endpoints().events;\n const q = base.indexOf('?');\n const [path, search] = q < 0 ? [base, ''] : [base.slice(0, q), base.slice(q + 1)];\n const kept = search\n .split('&')\n .filter((pair) => pair && !ADDED.has(decodeURIComponent(pair.split('=')[0]!)));\n const count = Math.min(Math.max(1, Math.trunc(limit) || 0) + EXTRA, MAX_FETCH);\n kept.push(`limit=${count}`);\n if (category) kept.push(`category=${encodeURIComponent(category).replace(/%2C/gi, ',')}`);\n if (query) kept.push(`search=${encodeURIComponent(query)}`);\n return `${path}?${kept.join('&')}`;\n}\n\nconst SAFE_PROTOCOLS = new Set(['http:', 'https:']);\n\nfunction safeUrl(value: unknown): string | undefined {\n if (typeof value !== 'string' || !value) return undefined;\n try {\n return SAFE_PROTOCOLS.has(new URL(value).protocol) ? value : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * LibCal's `{ events: [...] }` reduced to EventItem, in response order. Events without a\n * title, a public http(s) URL, or a parseable start and end (end not before start) are\n * skipped; everything else LibCal sends (descriptions, owners, seats…) is dropped.\n */\nexport function parseEvents(json: unknown): EventItem[] {\n const list = (json as { events?: unknown } | null)?.events;\n if (!Array.isArray(list)) return [];\n const out: EventItem[] = [];\n for (const e of list as Record<string, unknown>[]) {\n if (!e || typeof e !== 'object') continue;\n const title = typeof e.title === 'string' ? e.title.trim() : '';\n const url = safeUrl((e.url as { public?: unknown } | null)?.public);\n const start = typeof e.start === 'string' ? Date.parse(e.start) : NaN;\n const end = typeof e.end === 'string' ? Date.parse(e.end) : NaN;\n if (!title || !url || !Number.isFinite(start) || !Number.isFinite(end) || end < start) continue;\n out.push({ title, url, start, end, allDay: e.allday === true });\n }\n return out;\n}\n\n/** The first `limit` events that have not ended at `now`, by start time. */\nexport function upcoming(\n events: readonly EventItem[],\n limit: number,\n now = Date.now(),\n): EventItem[] {\n return events\n .filter((e) => e.end > now)\n .sort((a, b) => a.start - b.start)\n .slice(0, Math.max(0, limit));\n}\n\ninterface CacheEntry {\n at: number;\n promise: Promise<EventItem[]>;\n}\nconst cache = new Map<string, CacheEntry>();\n\n/**\n * The events for `q` (all of them, ended ones included: see `upcoming`). Identical requests\n * share one fetch; a cached answer older than `maxAge` ms is fetched again. A failure is not\n * cached.\n */\nexport function loadEvents(q: EventsQuery, maxAge = Infinity): Promise<EventItem[]> {\n const url = eventsUrl(q);\n const hit = cache.get(url);\n if (hit && performance.now() - hit.at <= maxAge) return hit.promise;\n const entry: CacheEntry = {\n at: performance.now(),\n promise: fetchJson(url, eventsTiming).then(parseEvents),\n };\n cache.set(url, entry);\n entry.promise.catch(() => {\n if (cache.get(url) === entry) cache.delete(url);\n });\n return entry.promise;\n}\n\n/** Forget cached events and re-read `window.uvalibEventsEndpoints` (for tests). */\nexport function resetEventsCache(): void {\n cache.clear();\n globalApplied = false;\n}\n\n// --- dates, in America/New_York ----------------------------------------------------------\n\n/** How an event's date and time are shown. */\nexport interface EventWhen {\n /** The start's New York date, `YYYY-MM-DD`, for `<time datetime>`. */\n datetime: string;\n /** \"Nov\", \"16\", \"Mon\": the date column. */\n month: string;\n day: string;\n weekday: string;\n /** \"Monday, November 16\": the date column for assistive technology. */\n fullDate: string;\n /** \"11:00 AM - 12:00 PM EST\", \"All day\", or with dates for a multi-day event. */\n time: string;\n}\n\nconst ny = (key: string, options: Intl.DateTimeFormatOptions) =>\n formatter(`events-${key}`, { ...options, timeZone: TIME_ZONE });\n\n/** Intl's narrow and plain no-break spaces (before AM/PM) as plain spaces. */\nconst plain = (s: string) => s.replace(/[ ]/g, ' ');\n\nfunction part(\n at: number,\n type: Intl.DateTimeFormatPartTypes,\n key: string,\n o: Intl.DateTimeFormatOptions,\n) {\n return (\n ny(key, o)\n .formatToParts(at)\n .find((p) => p.type === type)?.value ?? ''\n );\n}\n\nconst clock = (at: number) => plain(ny('clock', { hour: 'numeric', minute: '2-digit' }).format(at));\nconst shortDay = (at: number) => ny('short', { month: 'short', day: 'numeric' }).format(at);\nconst zone = (at: number) => part(at, 'timeZoneName', 'zone', { timeZoneName: 'short' });\n\n/** The date column and time line for `e`, in America/New_York. */\nexport function eventWhen(e: EventItem): EventWhen {\n const { start, end } = e;\n const multiDay = todayInNewYork(start) !== todayInNewYork(end);\n let time: string;\n if (e.allDay) time = multiDay ? `${shortDay(start)} - ${shortDay(end)}, all day` : 'All day';\n else if (multiDay)\n time = `${shortDay(start)}, ${clock(start)} - ${shortDay(end)}, ${clock(end)} ${zone(end)}`;\n else time = `${clock(start)} - ${clock(end)} ${zone(end)}`;\n return {\n datetime: todayInNewYork(start),\n month: part(start, 'month', 'month', { month: 'short' }),\n day: part(start, 'day', 'day', { day: 'numeric' }),\n weekday: part(start, 'weekday', 'weekday', { weekday: 'short' }),\n fullDate: ny('full', { weekday: 'long', month: 'long', day: 'numeric' }).format(start),\n time,\n };\n}\n","import { precedingHeadingLevel } from '../../base/heading-level.js';\nimport { css, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { html, unsafeStatic, type StaticValue } from 'lit/static-html.js';\nimport { property, state } from 'lit/decorators.js';\nimport { trackError, trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { accessible } from '../../styles/accessible.js';\nimport {\n eventWhen,\n eventsEndpoints,\n eventsTiming,\n loadEvents,\n setEventsEndpoints,\n upcoming,\n type EventItem,\n type EventsEndpoints,\n} from './events-data.js';\n\n/**\n * `loading` until the first answer, then `ready` (events shown), `empty` (no upcoming events)\n * or `error` (they could not be loaded).\n */\nexport type EventsState = 'loading' | 'ready' | 'empty' | 'error';\n\nconst DEFAULT_LIMIT = 8;\nconst DEFAULT_LEVEL = 3;\n\n/**\n * The rules the element needs even with `no-style`, where the Drupal theme styles the cards:\n * the host is a block, placeholder cards are invisible, titles are clamped to three lines (the\n * whole title stays in the DOM), the status line sits over the top of the cards at a constant\n * one-line height so it never moves anything, and `[hidden]` hides. `host` is `:host`\n * (shadow) or the tag name (light DOM, so they stay scoped).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; position: relative; }\n ${host}[loading] { min-height: var(--events-section-min-height, 0); }\n ${host} .event-placeholder { visibility: hidden; }\n ${host} .event-title {\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 3;\n line-clamp: 3;\n overflow: hidden;\n }\n ${host} .event-url:hover .event-title { text-decoration: underline; }\n ${host} .events-status {\n position: absolute;\n inset-block-start: 0;\n inset-inline: 0;\n min-height: 1.5em;\n min-height: 1lh;\n pointer-events: none;\n }\n ${host} .events-status button { pointer-events: auto; }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n ${host} .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/**\n * Light DOM only, unlayered: the card title's top margin. The Drupal theme gives `h3` a 3rem\n * top margin and `h4` 1rem, and `.event-title` sets none, so without this the default h3\n * titles would push every card 2rem taller than the old h4 ones. 1rem is the old h4 value,\n * so the cards keep their geometry whatever `heading-level` is. Unlayered (and more\n * specific than a bare `h3`) so it beats the page's own heading rules.\n */\nconst lightTitleMargin = (tag: string) =>\n unsafeCSS(`${tag} .event-url .event-title { margin-block-start: 1rem; }`);\n\n/**\n * Upcoming UVA Library events from LibCal, as on the library.virginia.edu home page: a grid of\n * cards, each one link with the event's title, a date column (month, day, weekday) and its\n * time, in America/New_York. Events that have ended are left out. Light DOM output keeps the\n * classes the Drupal theme styles (`event-container`, `event`, `event-url`, `event-title`,\n * `event-date`, `event--month`, `event--day`, `event--wkday`, `event-time`).\n *\n * @tagname events-section\n * @fires uvalib-analytics-event - For `<site-analytics>`: a click on an event, `['events-section', 'event-click', <category id, or all>, <position, from 1>]` (never its title or URL), and `['events-section', 'error', 'events-load']` once when the events cannot be loaded. Bubbles and is composed.\n * @cssprop [--events-section-min-height=0] - Height the element keeps during its first load (while it has the `loading` attribute). Its placeholder cards already hold the final height; this only matters for a page that wants more. Applies with `no-style` too. Pages can reserve height before the element upgrades with `events-section:not(:defined) { display: block; min-height: … }`.\n * @cssprop [--uva-brand-orange-dark=#b35900] - Background of the date column (white text on it is 4.8:1).\n * @cssprop [--uva-brand-blue=#232d4b] - Event title colour.\n * @cssprop --uva-color-link - Dark-mode role token: event title colour (else `--uva-brand-blue`).\n * @cssprop --uva-color-text - Dark-mode role token: time and status text (else #2b2b2b).\n * @cssprop --uva-color-border - Dark-mode role token: card border (else #dadada).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: card and button background (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class EventsSection extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n container-type: inline-size;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .event-container {\n display: grid;\n grid-template-columns: repeat(4, minmax(0, 1fr));\n gap: 2rem;\n align-items: stretch;\n }\n /* Four columns only where each card leaves its time line room for a multi-day range\n on two lines; two below 75rem (as the Drupal theme does inside /rmc's columns), one\n below 40rem. */\n @container (width < 75rem) {\n .event-container {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n }\n }\n @container (width < 40rem) {\n .event-container {\n grid-template-columns: minmax(0, 1fr);\n }\n }\n .event {\n display: grid;\n }\n .event-url {\n display: grid;\n grid-template-columns: 4.5rem minmax(0, 1fr);\n grid-template-rows: 1fr auto;\n column-gap: 1rem;\n min-height: 9rem;\n box-sizing: border-box;\n border: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n background: var(--uva-color-surface-raised, #fff);\n color: inherit;\n text-decoration: none;\n }\n .event-date {\n grid-area: 1 / 1 / 3 / 2;\n display: flex;\n flex-direction: column;\n align-items: center;\n margin: 0;\n padding: 1rem 0.25rem;\n background: var(--uva-brand-orange-dark, #b35900);\n color: #fff;\n text-align: center;\n line-height: 1.2;\n font-weight: bold;\n }\n .event--month,\n .event--wkday {\n font-size: 1.0625rem;\n }\n .event--day {\n font-size: 1.75rem;\n }\n .event-title {\n grid-area: 1 / 2 / 2 / 3;\n align-self: start;\n /* A 1rem top margin, as light DOM gets unlayered (see lightTitleMargin). */\n margin: 1rem 0 0;\n padding: 0 1rem 0 0;\n min-height: 3lh;\n font-size: 1rem;\n line-height: 1.3;\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n text-wrap: balance;\n }\n .event-time {\n grid-area: 2 / 2 / 3 / 3;\n margin: 0;\n padding: 0.5rem 1rem 1rem 0;\n /* Two lines, so a multi-day range (\"Nov 20, 9:00 AM - Nov 21, 5:00 PM EST\") that\n wraps does not make its row taller than the placeholders. */\n min-height: 2lh;\n font-size: 0.9375rem;\n line-height: 1.3;\n }\n .events-status {\n line-height: 1.5;\n }\n .uvalib-button {\n font: inherit;\n margin-inline-start: 0.5rem;\n padding: 0.1rem 0.75rem;\n border: 1px solid var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n border-radius: 0.3rem;\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n cursor: pointer;\n }\n .uvalib-button[aria-disabled='true'] {\n cursor: progress;\n }\n `,\n ];\n\n /**\n * The LibCal URLs shared by every `<events-section>`: `events` and `search` (used with\n * `query`). Assigning an object (or setting a key) changes them for every element from the\n * next load on. To repoint before elements already in the HTML start fetching, set\n * `window.uvalibEventsEndpoints` before the define script runs.\n */\n static get endpoints(): EventsEndpoints {\n return eventsEndpoints;\n }\n static set endpoints(value: Partial<EventsEndpoints>) {\n setEventsEndpoints(value);\n }\n\n /** How many events to show (at most; fewer when fewer are coming up). */\n @property({ type: Number })\n limit = 8;\n\n /** Only events in this LibCal category (its id, for example `38740`; several comma-separated). */\n @property({ type: String })\n category?: string;\n\n /** Only events matching this search text (LibCal's event search). */\n @property({ type: String })\n query?: string;\n\n /**\n * Cut titles longer than this many characters, with \"…\", for sighted users; assistive\n * technology still gets the whole title. Titles are clamped to three lines anyway, so this\n * is only kept for old pages.\n */\n @property({ type: Number, attribute: 'max-title-length' })\n maxTitleLength?: number;\n\n /**\n * The level of each event's title heading, 1 to 6. Unset (the default), it is one below\n * the nearest heading before the element in the page (an `<h2>` above gives `<h3>`\n * titles), or 3 when there is none.\n */\n @property({ type: Number, attribute: 'heading-level' })\n headingLevel?: number;\n\n /** One below the nearest preceding heading, worked out on connect (see `level`). */\n @state() private inferredLevel = DEFAULT_LEVEL;\n\n /** `loading` (the default, until the first answer), `ready`, `empty` or `error`. Read-only. */\n get state(): EventsState {\n return this._state;\n }\n\n @state() private _state: EventsState = 'loading';\n /** The events shown: kept on screen while a later load (an attribute change) runs. */\n @state() private events?: EventItem[];\n /** A Retry click's load is running: the button stays, disabled, so focus stays on it. */\n @state() private retrying = false;\n\n private loadId = 0;\n private retryTimer?: ReturnType<typeof setInterval>;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const above = precedingHeadingLevel(this);\n this.inferredLevel = above === null ? DEFAULT_LEVEL : Math.min(above + 1, 6);\n if (this.lightDom) {\n const node = this.getRootNode();\n const root = node instanceof ShadowRoot || node instanceof Document ? node : undefined;\n if (this.noStyle)\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n { root, scope: false },\n );\n installLightDomStyles(`${this.localName}::title-margin`, lightTitleMargin(this.localName), {\n root,\n scope: false,\n layer: false,\n });\n }\n clearInterval(this.retryTimer);\n // Quietly try again after an error; once loaded, drop events that have since ended\n // (from the cache), fetching them again when the cached answer is an hour old.\n this.retryTimer = setInterval(() => {\n if (this._state !== 'loading')\n void this.load({ background: true, maxAge: eventsTiming.maxAge });\n }, eventsTiming.retryEvery);\n // Reconnected after a disconnect: catch up.\n if (this.hasUpdated) void this.load({ background: true });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n clearInterval(this.retryTimer);\n this.retryTimer = undefined;\n }\n\n private get count(): number {\n const n = Math.trunc(this.limit);\n return Number.isFinite(n) && n > 0 ? Math.min(n, 100) : DEFAULT_LIMIT;\n }\n\n private get level(): number {\n const n = Math.trunc(this.headingLevel ?? Number.NaN);\n return n >= 1 && n <= 6 ? n : this.inferredLevel;\n }\n\n protected override willUpdate(changed: PropertyValues<this>) {\n if (!this.isConnected) return;\n if (!this.hasUpdated || changed.has('limit') || changed.has('category') || changed.has('query'))\n void this.load();\n }\n\n protected override updated() {\n // Only while nothing real is shown does --events-section-min-height apply.\n this.toggleAttribute('loading', this._state === 'loading' && !this.events?.length);\n }\n\n /**\n * Load the events. The current cards stay on screen until the new ones land. A\n * `background` load (the retry interval) does not show the loading state and, if it fails\n * while events are shown, keeps them.\n */\n private async load({\n background = false,\n maxAge = Infinity,\n }: { background?: boolean; maxAge?: number } = {}) {\n const id = ++this.loadId;\n const limit = this.count;\n if (!background) this._state = 'loading';\n try {\n const all = await loadEvents(\n {\n limit,\n category: this.category?.trim() || undefined,\n query: this.query?.trim() || undefined,\n },\n maxAge,\n );\n if (id !== this.loadId) return; // a newer load owns the element\n this.events = upcoming(all, limit);\n this._state = this.events.length ? 'ready' : 'empty';\n } catch {\n if (id !== this.loadId) return;\n if (background && this._state !== 'error') return;\n this.events = undefined;\n this._state = 'error';\n trackError(this, 'events-section', 'events-load');\n }\n }\n\n /** Analytics: which card (its position) was opened, and under which category. */\n private onClick(e: Event) {\n const card = (e.target as Element).closest('.event');\n if (!card?.querySelector('.event-url[href]')) return;\n const position = [...card.parentNode!.children].indexOf(card) + 1;\n trackEvent(this, ['events-section', 'event-click', this.category?.trim() || 'all', position]);\n }\n\n private async retry() {\n if (this.retrying) return;\n const hadFocus = this.focusedInside();\n this.retrying = true;\n try {\n await this.load();\n } finally {\n this.retrying = false;\n }\n await this.updateComplete;\n // Keep keyboard focus in the element: on the first event, on Retry again, or on the\n // status line when there is nothing else to focus.\n if (!hadFocus) return;\n const r = this.renderRoot;\n if (this._state === 'ready') r.querySelector<HTMLAnchorElement>('.event-url[href]')?.focus();\n else if (this._state === 'error')\n r.querySelector<HTMLButtonElement>('.events-status button')?.focus();\n else r.querySelector<HTMLElement>('.events-status')?.focus();\n }\n\n private focusedInside(): boolean {\n const active =\n this.renderRoot instanceof ShadowRoot\n ? this.renderRoot.activeElement\n : document.activeElement;\n return !!active && (this.renderRoot as Node).contains(active) && active !== this;\n }\n\n /** The title, or with `max-title-length` a cut copy for the eye and the whole for AT. */\n private renderTitle(title: string) {\n const max = Math.trunc(this.maxTitleLength ?? 0);\n const chars = [...title];\n if (!(max > 0) || chars.length <= max) return title;\n return html`<span aria-hidden=\"true\">${chars.slice(0, max).join('').trimEnd()}…</span\n ><span class=\"visually-hidden\">${title}</span>`;\n }\n\n private renderEvent(e: EventItem, h: StaticValue) {\n const when = eventWhen(e);\n return html`<div class=\"event\">\n <a href=${e.url} class=\"event-url\">\n <${h} class=\"event-title\">${this.renderTitle(e.title)}</${h}>\n <p class=\"event-date\">\n <span class=\"event--month\" aria-hidden=\"true\">${when.month}</span>\n <span class=\"event--day\" aria-hidden=\"true\">${when.day}</span>\n <span class=\"event--wkday\" aria-hidden=\"true\">${when.weekday}</span>\n <time class=\"visually-hidden\" datetime=${when.datetime}>${when.fullDate}</time>\n </p>\n <p class=\"event-time\">${when.time}</p>\n </a>\n </div>`;\n }\n\n /**\n * An invisible card with the real DOM and classes and typical text, so the section has its\n * final height, in the page's own font and grid, before the events arrive. Its link has no\n * href, so nothing in it is focusable.\n */\n private renderPlaceholder(h: StaticValue) {\n return html`<div class=\"event event-placeholder\" aria-hidden=\"true\">\n <a class=\"event-url\">\n <${h} class=\"event-title\">Library event</${h}>\n <p class=\"event-date\">\n <span class=\"event--month\">Nov</span>\n <span class=\"event--day\">30</span>\n <span class=\"event--wkday\">Mon</span>\n </p>\n <p class=\"event-time\">10:00 AM - 11:00 AM EST</p>\n </a>\n </div>`;\n }\n\n private renderStatus() {\n if (this.retrying || this._state === 'error')\n return html`Events are unavailable right now.\n <button\n type=\"button\"\n class=\"uvalib-button uvalib-button--basic\"\n aria-disabled=${this.retrying ? 'true' : nothing}\n @click=${this.retry}\n >\n ${this.retrying ? 'Retrying…' : 'Retry'}\n </button>`;\n switch (this._state) {\n case 'loading':\n return this.events?.length ? nothing : 'Loading events…';\n case 'empty':\n return 'No upcoming events.';\n default:\n return nothing;\n }\n }\n\n render() {\n const h = unsafeStatic(`h${this.level}`);\n const events = this.events?.length ? this.events : undefined;\n // Before the first answer: the limit's worth of placeholders, so the section has its\n // final height. Empty, failed or retrying: one row, so a failure does not leave a long\n // blank area (a phone stacks the cards in one column).\n const placeholders = events ? 0 : this._state === 'loading' && !this.retrying ? this.count : 1;\n return html`<div class=\"event-container\" @click=${this.onClick}>\n ${\n events\n ? events.map((e) => this.renderEvent(e, h))\n : Array.from({ length: placeholders }, () => this.renderPlaceholder(h))\n }\n </div>\n <div class=\"events-status\" role=\"status\" tabindex=\"-1\">${this.renderStatus()}</div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { EventsSection } from './EventsSection.js';\n\ndefine('events-section', EventsSection);\n"],"mappings":";;;;;;;;AA8BA,IAAMwB,IAAS,oEAQFC,IAAmC;CAC9C,QAAQ,+CAA+CD;CACvD,QAAQ,qDAAq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WAAA,gBAAA,KAAA,CAAA,GAIrDrF,EAAA,CAAAE,EAAM,CAAA,GAAAmF,EAAA,WAAA,iBAAA,KAAA,CAAA,GAONrF,EAAA,CAAAE,EAAM,CAAA,GAAAmF,EAAA,WAAA,UAAA,KAAA,CAAA,GAENrF,EAAA,CAAAE,EAAM,CAAA,GAAAmF,EAAA,WAAA,UAAA,KAAA,CAAA,GAENrF,EAAA,CAAAE,EAAM,CAAA,GAAAmF,EAAA,WAAA,YAAA,KAAA,CAAA,GC7PT/E,EAAO,kBAAkB+E,CAAa"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as e } from "./chunks/UvalibElement-pGONDAwB.js";
|
|
2
|
-
import "./chunks/library-weekly-hours-
|
|
2
|
+
import "./chunks/library-weekly-hours-BJgxAyah.js";
|
|
3
3
|
// src/components/library-hours-setup/LibraryHoursSetup.ts
|
|
4
4
|
var t = "div[type=\"library-weekly-hours\"]", n = "library-weekly-hours", r = /* @__PURE__ */ new Set(["harrison"]), i = class extends HTMLElement {
|
|
5
5
|
connectedCallback() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "./chunks/library-weekly-hours-
|
|
1
|
+
import "./chunks/library-weekly-hours-BJgxAyah.js";
|
package/dist-cdn/manifest.json
CHANGED
|
@@ -4,7 +4,7 @@ import { t as l } from "./chunks/repeat-m5Zd_QeP.js";
|
|
|
4
4
|
import { a as u, i as d } from "./chunks/analytics-DTTihuBD.js";
|
|
5
5
|
import { t as f } from "./chunks/accessible-DJv7YOtS.js";
|
|
6
6
|
import { r as p } from "./chunks/new-york-DkcnqvJ4.js";
|
|
7
|
-
import { a as m, i as h, l as g, n as _, o as v, p as y, r as b, s as x, u as S } from "./chunks/hours-data-
|
|
7
|
+
import { a as m, i as h, l as g, n as _, o as v, p as y, r as b, s as x, u as S } from "./chunks/hours-data-gMu5uT7H.js";
|
|
8
8
|
// src/components/site-hours-section/SiteHoursSection.ts
|
|
9
9
|
var C = class extends o {
|
|
10
10
|
constructor(...e) {
|
|
@@ -76,6 +76,7 @@ Theme only through the documented surface, never by reaching into internals:
|
|
|
76
76
|
|
|
77
77
|
- Inherited `--uva-*` custom properties (colors such as `--uva-brand-blue`, `--uva-brand-orange`; `--uva-font-family`, `--uva-font-size-base`). Set them on `:root` or an ancestor of `<site-page>`. The full set is in `tokens.css`; per-component ones are in reference/components.md. Prefer the library's values; override only with a stated reason.
|
|
78
78
|
- `::part()` in shadow mode. On a page, use `site-page::part(header)`, `site-page::part(footer)` and `site-page::part(main)` (`<site-page>` re-exports the header and footer parts; `site-header::part(header)` cannot reach through its shadow root). For a standalone `<site-header>` or `<site-footer>` use `site-header::part(header)` / `site-footer::part(footer)`. In light mode there are no shadow parts; style the elements with ordinary selectors.
|
|
79
|
+
- Custom states for runtime state, in shadow and light mode: `uvalib-combobox:state(open)`, `:state(invalid)`, `:state(loading)`; `uvalib-filter-drawer:state(modal)` (phone layout), `:state(open)`; `uvalib-lightbox:state(open)`; `uvalib-tag-list:state(expanded)`. Style them; never add or watch attributes for that state (there are none) or set it yourself (a page cannot). Browsers without custom states just never match.
|
|
79
80
|
- Never pierce shadow roots with JS, depend on internal class names, or use `!important` to fight the chrome.
|
|
80
81
|
|
|
81
82
|
### Dark mode (opt-in)
|
|
@@ -594,10 +595,10 @@ A static site (11ty, Jekyll, a generated collection) that searches with [Pagefin
|
|
|
594
595
|
For a results list of your own (a collection, a Virgo-like listing, a photo archive), use these instead of hand-made pills, counts and spinners. Classes are in `base.css`; the two elements load from `uvalib-tag-list.js` and `uvalib-results-count.js`.
|
|
595
596
|
|
|
596
597
|
- Badges: `.uvalib-badge` (neutral) with `--category` (the card chip), `--count` (on media, inside `.uvalib-media`; several in `.uvalib-media__badges`), `--status` plus `--success` / `--warning` / `--danger` / `--info`, `--new`, and `--body` for body size. A status badge always says its state in words; an icon in it gets `aria-hidden="true"`. Inside `<uvalib-card>` use its `badge` and `chip` slots instead.
|
|
597
|
-
- Toolbar: `.uvalib-toolbar` around `.uvalib-toolbar__field` (label over control; `--grow` takes the spare width), `.uvalib-toolbar__group` (`role="group"` with an `aria-label`, `.uvalib-button` toggles with `aria-pressed`) and `.uvalib-toolbar__summary`. It stacks
|
|
598
|
+
- Toolbar: `.uvalib-toolbar` around `.uvalib-toolbar__field` (label over control; `--grow` takes the spare width), `.uvalib-toolbar__group` (`role="group"` with an `aria-label`, `.uvalib-button` toggles with `aria-pressed`) and `.uvalib-toolbar__summary`. It stacks when it is itself 30em wide or less (a phone, a sidebar, a drawer): toolbar, result list and photo grid follow their own width (CSS size containers), so give one a width in a shrink-to-fit box.
|
|
598
599
|
- `<uvalib-results-count shown total noun singular>`: the visible “Showing 48 of 3,694 shoots”, announced politely once it settles (1 s); never the first render, but the first count after an empty one (data loading) is. Leave `shown`/`total` unset while loading. Set `shown` and `total` after every filter change; do not add your own live region for the count. Not beside `<bento-box>` or `<uvalib-pagefind-search>`, which announce their own.
|
|
599
600
|
- `<uvalib-tag-list label="Subjects" track-label limit="8" href-template="/search?q={tag}">` with `<a href>` or `<span>` children (or `items`): links are outlined pills, plain tags filled chips; a child's `lang`/`dir` and inline markup are kept; `limit` adds “Show all N”. Always set `label` (`hide-label` hides it visually). It reports tag clicks as `list N` and the tag's position, never the tag text; add `track-label` only when the label is fixed text you wrote, never one filled from a record.
|
|
600
|
-
- Long result sets (hundreds or thousands of rows): `<ul class="uvalib-result-list">` of `<li class="uvalib-result">` rows holding `__meta` (badges, date), `__title` (the row's one link), `__snippet` (search terms in `<mark>`, drawn bold on `--uva-color-highlight`) and `__actions` (secondary buttons, each with a unique visually hidden name). Plain HTML, never a `<uvalib-card>` per row; rows skip rendering off screen (`content-visibility: auto`). A heading and a list per group for date order.
|
|
601
|
+
- Long result sets (hundreds or thousands of rows): `<ul class="uvalib-result-list">` of `<li class="uvalib-result">` rows holding `__meta` (badges, date), `__title` (the row's one link), `__snippet` (search terms in `<mark>`, drawn bold on `--uva-color-highlight`) and `__actions` (secondary buttons, each with a unique visually hidden name). Plain HTML, never a `<uvalib-card>` per row; rows skip rendering off screen (`content-visibility: auto`); the actions wrap below when the list itself is 40em or narrower. A heading and a list per group for date order.
|
|
601
602
|
- No results: `.uvalib-empty-state` (decorative `__icon`, a heading, a sentence, one action). Loading: `.uvalib-skeleton` (give it a height, or `--media` for 3:2) and `.uvalib-skeleton-text` (one line), sized like what replaces them, inside an `aria-hidden="true"` container, with `aria-busy="true"` on the region while it loads.
|
|
602
603
|
|
|
603
604
|
```html snippet
|
|
@@ -723,8 +724,8 @@ Use these instead of a hand-built gallery or a carousel. There is no autoplay.
|
|
|
723
724
|
- From the page: `open(idOrIndex)` (false if unknown) and `close({ focus })` (after deleting the open item; focus your heading); `uvalib-lightbox-open` (`{ id, index, restored }`) and `uvalib-lightbox-close` (`{ id, index, reason }`) report both. Never click the dialog's own Close.
|
|
724
725
|
- `<uvalib-image-regions>` from `uvalib-image-regions.js`: numbered outlines on an image (people, objects, inscriptions) with a list of the same regions beside it. Write the page's own `<img width height alt>` and `<ol>` inside, each `<li data-xywh="percent:x,y,w,h">` (or pixels of the natural size, `160,120,320,240`; `image-width`/`image-height` for a IIIF derivative) holding the region's link and your own action buttons, which stay yours; or set `items` (`{ label, x, y, w, h, unit?, href?, description? }[]`). The list is the accessible route: the outlines are `aria-hidden`, not tab stops, and never the only place a name or action is; hovering or focusing an entry highlights its outline (thicker double outline and label) and back, and clicking an outline focuses its entry. `label` names the list. Listen for `uvalib-image-regions-activate` (an outline clicked, before its entry takes focus; `detail: { index, item, entry }`, `entry` the page's own `<li>`; cancelable, so the page can focus its own control in the entry, such as a "Who is this?" field) and `highlight`; never read the shadow DOM's outlines for it. Do not hand-build absolutely positioned outlines. It reports outline clicks itself (the list's label and the number, never a region's label).
|
|
725
726
|
- Regions in the viewer: `data-regions` on a lightbox link (a JSON array, or `percent:10,20,30,40 Person 1; percent:55,15,20,30 Sign`), or the lightbox's `regions` callback (`({ element, id, href, index }) => regions`). The open image then shows the outlines, their list and a "Show regions" toggle; `regions-label` names the list. For your own buttons in each entry, `data-regions-list="<id>"` (or the `regionsList` callback) names a hidden `<ol>` of `<li data-xywh>` in the page: it is lent to the viewer (same nodes, your listeners and CSS keep working) and put back on close; give each action a unique name ("Confirm Tim Kaine"). In React, create that `<ol>` (and a details element) outside React and make it the `createPortal` target for the entries, never render it inside a portal (README "React and other frameworks").
|
|
726
|
-
- Versions in the viewer: `data-versions='[{"label":"Original"},{"label":"AI colorization","href":"color.jpg","note":"The colours are an AI model’s guess."}]'` on a lightbox link (first entry = the link's image; or the `versions` callback) compares them over the photo, the comparison loaded on first use: Switch (default), Reveal (`compare="wipe"`, a divider: click the photo or the slider) or Fade; label AI versions as such and give them a `note`; a version with a different framing (AI-expanded frame, whole plate, crop) gives `"frame": "percent:x,y,w,h"` (the original's box in it; pixels need its `width`/`height`) and is drawn at the original's scale around it; `version-param` (with `url-param`) keeps `?version=wipe:40`; `uvalib-lightbox-version` reports changes.
|
|
727
|
-
- `<uvalib-photo-grid>` from `uvalib-photo-grid.js`: justified rows. Each direct `<a href>` or `<button>` is one photo and stays a real control. The row is about 220px, and 140px
|
|
727
|
+
- Versions in the viewer: `data-versions='[{"label":"Original"},{"label":"AI colorization","href":"color.jpg","note":"The colours are an AI model’s guess."}]'` on a lightbox link (first entry = the link's image; or the `versions` callback) compares them over the photo, the comparison loaded on first use: Switch (default), Reveal (`compare="wipe"`, a divider: click the photo or the slider) or Fade; label AI versions as such and give them a `note`; a version with a different framing (AI-expanded frame, whole plate, crop) gives `"frame": "percent:x,y,w,h"` (the original's box in it; pixels need its `width`/`height`) and is drawn at the original's scale around it (a crop's frame goes past it: `percent:-25,-25,150,150`); `data-version="1"` (the `version-param` format) opens a link on that version, the original still first; `version-param` (with `url-param`) keeps `?version=wipe:40`; `uvalib-lightbox-version` reports changes.
|
|
728
|
+
- `<uvalib-photo-grid>` from `uvalib-photo-grid.js`: justified rows. Each direct `<a href>` or `<button>` is one photo and stays a real control. The row is about 220px, and 140px when the grid itself is under 48rem (also in a sidebar), unless `row-height` is set (a bare number is pixels). Give each image `width` and `height` so the row does not jump when it loads. An image with no visible text gets a caption from its alt, and a repeated alt is cleared (the original is kept for a lightbox). A different alt is kept. Do not set an `aria-label` that differs from the visible text; the grid will not add a caption beside one. Generated "Photo N" captions renumber when the photos change order. A `<span slot="badge">` inside the item, or `data-badge` on it (“seq”, “3 photos”), is drawn over the thumbnail and stays in the accessible name; an existing `aria-label` gains the badge text. A grid inside a lightbox opens the viewer. The grid reports no analytics.
|
|
728
729
|
|
|
729
730
|
```html snippet
|
|
730
731
|
<!doctype html>
|
|
@@ -775,7 +775,7 @@ A row of chips: a segmented control or single-select filter (`mode="single"`), f
|
|
|
775
775
|
|
|
776
776
|
## `<uvalib-combobox>`
|
|
777
777
|
|
|
778
|
-
An editable text field that suggests values as you type, from a local list or a URL: a person, place or subject picker. It follows the WAI-ARIA APG “Editable Combobox With List Autocomplete”: a real `<input role="combobox">` and a `role="listbox"` popup under it. Suggestions come from the `items` property (`{ value, label?, description?, disabled? }` objects, or strings), from `<option>` children (directly or inside a `<datalist>`; the `label` attribute or text is the label, `data-description` the second line), or from `src`, a URL template with `{q}` (fetched 250 ms after the last keystroke once the text has `min-length` characters, default 1; a newer keystroke aborts the older request; the response is a JSON array of the same shape, or anything `transform(data, query)` turns into one). `items` wins over the children while set. Local suggestions match anywhere in the label, ignoring case and accents, those starting with the text first, then those with a word starting with it; at most `max-results` (default 50, 0 for all) are shown, which keeps a list of 16,000 people fast. The matched text is bold and underlined in a `<mark>`. Keys: Down opens the list on the first suggestion and moves (wrapping), Up opens on the last, Alt+Down opens without moving, Alt+Up closes, Enter chooses the active suggestion (and then does not submit the form; with none active, Enter submits as in any field), Escape closes the list and a second Escape clears the field, Home, End, Left and Right move the caret, and Tab leaves without choosing. A real clear button (“Clear <label>”, 44px, shown only with text) empties the field and returns focus to it. Free text is allowed: `value` is whatever is in the field, and `selected` the chosen suggestion (or null); typing after choosing clears it, and leaving the field with text that is exactly one suggestion's label chooses it. `must-choose` makes any other text invalid (“Choose one of the suggestions.”). The element is form-associated: with `name` it submits the chosen suggestion's value, or else the text, and a form reset restores the `value` attribute. `required` and `disabled` (also from a disabled fieldset) work as on an input. A polite status says “5 suggestions”, “50 of 1,234 suggestions”, “No suggestions”, “Loading suggestions” or “Couldn't load suggestions” half a second after the list settles (never on the first render); the popup shows the same notes visibly. A failed load never throws. Before it upgrades, `base.css` shows the label (from the attribute) and holds the field's height. A fallback `<input list>` child works as a plain field meanwhile; on upgrade its text, `name` and `placeholder` carry over, and it is disabled so it does not submit twice.
|
|
778
|
+
An editable text field that suggests values as you type, from a local list or a URL: a person, place or subject picker. It follows the WAI-ARIA APG “Editable Combobox With List Autocomplete”: a real `<input role="combobox">` and a `role="listbox"` popup under it. Suggestions come from the `items` property (`{ value, label?, description?, disabled? }` objects, or strings), from `<option>` children (directly or inside a `<datalist>`; the `label` attribute or text is the label, `data-description` the second line), or from `src`, a URL template with `{q}` (fetched 250 ms after the last keystroke once the text has `min-length` characters, default 1; a newer keystroke aborts the older request; the response is a JSON array of the same shape, or anything `transform(data, query)` turns into one). `items` wins over the children while set. Local suggestions match anywhere in the label, ignoring case and accents, those starting with the text first, then those with a word starting with it; at most `max-results` (default 50, 0 for all) are shown, which keeps a list of 16,000 people fast. The matched text is bold and underlined in a `<mark>`. Keys: Down opens the list on the first suggestion and moves (wrapping), Up opens on the last, Alt+Down opens without moving, Alt+Up closes, Enter chooses the active suggestion (and then does not submit the form; with none active, Enter submits as in any field), Escape closes the list and a second Escape clears the field, Home, End, Left and Right move the caret, and Tab leaves without choosing. A real clear button (“Clear <label>”, 44px, shown only with text) empties the field and returns focus to it. Free text is allowed: `value` is whatever is in the field, and `selected` the chosen suggestion (or null); typing after choosing clears it, and leaving the field with text that is exactly one suggestion's label chooses it. `must-choose` makes any other text invalid (“Choose one of the suggestions.”). The element is form-associated: with `name` it submits the chosen suggestion's value, or else the text, and a form reset restores the `value` attribute. `required` and `disabled` (also from a disabled fieldset) work as on an input. A polite status says “5 suggestions”, “50 of 1,234 suggestions”, “No suggestions”, “Loading suggestions” or “Couldn't load suggestions” half a second after the list settles (never on the first render); the popup shows the same notes visibly. A failed load never throws. Where the browser supports the Popover API and CSS anchor positioning, the popup is a manual popover in the top layer, anchored under the field and as wide as it (above it when there is no room below), so an ancestor with `overflow: hidden` or a scrolling panel never clips it. Elsewhere it is positioned under the field inside the element, as before. Pages can style the runtime state with `:state(open)`, `:state(invalid)` and `:state(loading)` (no attributes are added). Before it upgrades, `base.css` shows the label (from the attribute) and holds the field's height. A fallback `<input list>` child works as a plain field meanwhile; on upgrade its text, `name` and `placeholder` carry over, and it is disabled so it does not submit twice.
|
|
779
779
|
|
|
780
780
|
### Attributes
|
|
781
781
|
|
|
@@ -806,6 +806,14 @@ An editable text field that suggests values as you type, from a local list or a
|
|
|
806
806
|
| `option` | Each suggestion. |
|
|
807
807
|
| `description` | The hint under the field. |
|
|
808
808
|
|
|
809
|
+
### CSS states
|
|
810
|
+
|
|
811
|
+
| State | Description |
|
|
812
|
+
|---|---|
|
|
813
|
+
| `:state(open)` | The popup is showing (suggestions or a note such as “No suggestions”). |
|
|
814
|
+
| `:state(invalid)` | The text was shown as invalid (`aria-invalid="true"`: `must-choose` text that is not a suggestion, after leaving the field or pressing Enter). |
|
|
815
|
+
| `:state(loading)` | Suggestions from `src` are loading. |
|
|
816
|
+
|
|
809
817
|
### Events
|
|
810
818
|
|
|
811
819
|
| Event | Description |
|
|
@@ -1022,7 +1030,7 @@ A faceted-search filter: a fieldset of checkboxes (value plus result count), opt
|
|
|
1022
1030
|
|
|
1023
1031
|
## `<uvalib-filter-drawer>`
|
|
1024
1032
|
|
|
1025
|
-
A search page's form and filters: a plain sidebar on wide screens, and on narrow ones a “Search and filters” button that opens them in a modal panel from the side. Put the page's search form, `<uvalib-filter>`s and other facets inside. Above `breakpoint` (default `48rem`) they are shown as written: no button, no dialog role. At and below it only the button is shown; it opens a native `<dialog>` (`showModal()`) with a visible heading (the `label`) and a 44px Close button, which takes focus. Escape, Close and a click on the backdrop close it, and focus returns to the button; widening the window past the breakpoint closes it and keeps focus where it was. While it is open the rest of the page, including `<site-page>`'s header, skip link and alerts, is inert (the browser's modal dialog), so focus cannot leave it except to the browser itself, and nothing else is announced. The children are the same nodes in both layouts (moved, never re-created): typed text, checked boxes, listeners and each filter's state are kept. Inert content is not announced, so results counts and status notices outside the panel would go silent while the visitor filters: name them in `live` (space-separated ids) and the drawer repeats what they announce in its own polite live region while it is open. `count` (the page's number of active filters) is shown on the button when above 0. The drawer never counts by itself: only the page knows which inputs are filters.
|
|
1033
|
+
A search page's form and filters: a plain sidebar on wide screens, and on narrow ones a “Search and filters” button that opens them in a modal panel from the side. Put the page's search form, `<uvalib-filter>`s and other facets inside. Above `breakpoint` (default `48rem`) they are shown as written: no button, no dialog role. At and below it only the button is shown; it opens a native `<dialog>` (`showModal()`) with a visible heading (the `label`) and a 44px Close button, which takes focus. Escape, Close and a click on the backdrop close it, and focus returns to the button; widening the window past the breakpoint closes it and keeps focus where it was. While it is open the rest of the page, including `<site-page>`'s header, skip link and alerts, is inert (the browser's modal dialog), so focus cannot leave it except to the browser itself, and nothing else is announced. The children are the same nodes in both layouts (moved, never re-created): typed text, checked boxes, listeners and each filter's state are kept. Inert content is not announced, so results counts and status notices outside the panel would go silent while the visitor filters: name them in `live` (space-separated ids) and the drawer repeats what they announce in its own polite live region while it is open. `count` (the page's number of active filters) is shown on the button when above 0. The drawer never counts by itself: only the page knows which inputs are filters. Pages can style the runtime layout with `:state(modal)` (at or below the breakpoint: the button and panel) and `:state(open)` (the panel is open).
|
|
1026
1034
|
|
|
1027
1035
|
### Attributes
|
|
1028
1036
|
|
|
@@ -1054,6 +1062,13 @@ A search page's form and filters: a plain sidebar on wide screens, and on narrow
|
|
|
1054
1062
|
| `close` | The Close button. |
|
|
1055
1063
|
| `body` | The wrapper of the children, in the sidebar or the panel. |
|
|
1056
1064
|
|
|
1065
|
+
### CSS states
|
|
1066
|
+
|
|
1067
|
+
| State | Description |
|
|
1068
|
+
|---|---|
|
|
1069
|
+
| `:state(modal)` | The viewport is at or below the breakpoint: the button and panel, not the sidebar. |
|
|
1070
|
+
| `:state(open)` | The panel is open. |
|
|
1071
|
+
|
|
1057
1072
|
### Events
|
|
1058
1073
|
|
|
1059
1074
|
| Event | Description |
|
|
@@ -1136,7 +1151,7 @@ An image with numbered region outlines (people, objects, inscriptions) and a lis
|
|
|
1136
1151
|
|
|
1137
1152
|
## `<uvalib-lightbox>`
|
|
1138
1153
|
|
|
1139
|
-
An accessible image viewer over a set of plain links. With JavaScript a primary click opens a modal dialog; without it (or with a modified click) the link opens the image as before. Wrap the links, or point at them with `selector` (for example `a.pb-image` on a reading page). There is no autoplay and no carousel. The dialog is labelled by the caption (`data-caption`, else the image alt, else the link text). Focus moves to Close on open and back to the trigger on close. Escape and a click on the backdrop close it. With more than one image, Previous and Next and the arrow keys move through the set (wrapping), and a polite “3 of 13” counter is shown. Full size opens the original image in a new tab. A IIIF Image API URL keeps its region; only the size becomes `!W,H` for the viewport. TIFF and JPEG2000 URLs are left as written. `url-param` (for example `photo`) keeps `?photo=<id>` in sync, including on a hash route (`#/text?photo=<id>`): opening pushes a history entry, stepping replaces it, and Back closes. Optional details: children with `slot="details"` (and `data-for` equal to the item's id or its position from 1; without `data-for` they show for every image), or `data-details-id` on a link pointing at an element elsewhere on the page. Either is shown inside the dialog and put back exactly (same place, `hidden` and `slot`) when the viewer moves on or closes. The `data-details-id` element stays in the page (in shadow mode it becomes a child of the lightbox slotted into the dialog), so `getElementById`, the page's CSS (except selectors through its old ancestors) and listeners keep working; nothing is cloned. Details that appear while their image is open (rendered after a fetch) are shown then. `open(idOrIndex)` and `close({ focus })` let the page open or close the viewer itself; `uvalib-lightbox-open` and `uvalib-lightbox-close` say when it did. Optional regions (people, objects, inscriptions): `data-regions` on a link, a JSON array of `{ label, x, y, w, h, unit? }` or `xywh` values each followed by its label, separated by `;` (`percent:10,20,30,40 Person 1; percent:55,15,20,30 Sign`), or the `regions` callback. The open image then shows numbered outlines (`<uvalib-image-regions>`, loaded on first use) and a list of the regions beside it, with a "Show regions" toggle (`aria-pressed`) that hides the outlines. Pixel regions are measured in `data-image-width` × `data-image-height` when set (the viewer shows a resized IIIF image), else in the image's natural size. Or the page's own list, with its own buttons: `data-regions-list="<id>"` on a link (or the `regionsList` callback) names an `<ol>` or `<ul>` of `<li data-xywh>` anywhere in the page, usually `hidden`. While that image is open the list (the same nodes, so the page's listeners keep working) is the region list: in shadow mode it becomes a child of the lightbox slotted into the viewer, not moved into the shadow root, so the page's CSS still applies to it. When the image changes or the viewer closes it goes back where it was, `hidden` as before. It wins over `data-regions`. Optional versions of an image (an original scan and an AI colorization, a restoration, an infrared capture): `data-versions` on a link, a JSON array of `{ label, href?, note? }` whose first entry is the link's own image, or the `versions` callback. The viewer then compares them over the photo (loaded on first use): Switch (a segmented control), Reveal (a divider: click or tap the photo, or use the slider) or Fade (a slider), `compare` choosing the first. A version's `note` shows under the photo while it is visible, and the image's accessible name ends with the label of the version shown. `version-param` (with `url-param`) keeps the comparison in the address: `?version=2` (Switch, the version from 0), `?version=wipe:40` or `?version=fade:60` (the percentage of the other version shown; `wipe:40:2` compares the original with version 2). A version with a different framing (an AI-expanded frame, a crop, the whole plate) gives `frame`, the original's box in it (`percent:x,y,w,h`, or pixels of its `width` × `height`): the viewer draws every version at the original's scale in one box, the original lined up, and regions stay on it.
|
|
1154
|
+
An accessible image viewer over a set of plain links. With JavaScript a primary click opens a modal dialog; without it (or with a modified click) the link opens the image as before. Wrap the links, or point at them with `selector` (for example `a.pb-image` on a reading page). There is no autoplay and no carousel. The dialog is labelled by the caption (`data-caption`, else the image alt, else the link text). Focus moves to Close on open and back to the trigger on close. Escape and a click on the backdrop close it. With more than one image, Previous and Next and the arrow keys move through the set (wrapping), and a polite “3 of 13” counter is shown. Full size opens the original image in a new tab. A IIIF Image API URL keeps its region; only the size becomes `!W,H` for the viewport. TIFF and JPEG2000 URLs are left as written. `url-param` (for example `photo`) keeps `?photo=<id>` in sync, including on a hash route (`#/text?photo=<id>`): opening pushes a history entry, stepping replaces it, and Back closes. Optional details: children with `slot="details"` (and `data-for` equal to the item's id or its position from 1; without `data-for` they show for every image), or `data-details-id` on a link pointing at an element elsewhere on the page. Either is shown inside the dialog and put back exactly (same place, `hidden` and `slot`) when the viewer moves on or closes. The `data-details-id` element stays in the page (in shadow mode it becomes a child of the lightbox slotted into the dialog), so `getElementById`, the page's CSS (except selectors through its old ancestors) and listeners keep working; nothing is cloned. Details that appear while their image is open (rendered after a fetch) are shown then. `open(idOrIndex)` and `close({ focus })` let the page open or close the viewer itself; `uvalib-lightbox-open` and `uvalib-lightbox-close` say when it did. Optional regions (people, objects, inscriptions): `data-regions` on a link, a JSON array of `{ label, x, y, w, h, unit? }` or `xywh` values each followed by its label, separated by `;` (`percent:10,20,30,40 Person 1; percent:55,15,20,30 Sign`), or the `regions` callback. The open image then shows numbered outlines (`<uvalib-image-regions>`, loaded on first use) and a list of the regions beside it, with a "Show regions" toggle (`aria-pressed`) that hides the outlines. Pixel regions are measured in `data-image-width` × `data-image-height` when set (the viewer shows a resized IIIF image), else in the image's natural size. Or the page's own list, with its own buttons: `data-regions-list="<id>"` on a link (or the `regionsList` callback) names an `<ol>` or `<ul>` of `<li data-xywh>` anywhere in the page, usually `hidden`. While that image is open the list (the same nodes, so the page's listeners keep working) is the region list: in shadow mode it becomes a child of the lightbox slotted into the viewer, not moved into the shadow root, so the page's CSS still applies to it. When the image changes or the viewer closes it goes back where it was, `hidden` as before. It wins over `data-regions`. Optional versions of an image (an original scan and an AI colorization, a restoration, an infrared capture): `data-versions` on a link, a JSON array of `{ label, href?, note? }` whose first entry is the link's own image, or the `versions` callback. The viewer then compares them over the photo (loaded on first use): Switch (a segmented control), Reveal (a divider: click or tap the photo, or use the slider) or Fade (a slider), `compare` choosing the first. A version's `note` shows under the photo while it is visible, and the image's accessible name ends with the label of the version shown. `version-param` (with `url-param`) keeps the comparison in the address: `?version=2` (Switch, the version from 0), `?version=wipe:40` or `?version=fade:60` (the percentage of the other version shown; `wipe:40:2` compares the original with version 2). `data-version` on a link (the same values) opens that image on that version, from a click, `open()` or Previous and Next; an address with `version-param` wins. A version with a different framing (an AI-expanded frame, a crop, the whole plate) gives `frame`, the original's box in it (`percent:x,y,w,h`, or pixels of its `width` × `height`): the viewer draws every version at the original's scale in one box, the original lined up, and regions stay on it. Pages can style the element while the viewer is open with `:state(open)`.
|
|
1140
1155
|
|
|
1141
1156
|
### Attributes
|
|
1142
1157
|
|
|
@@ -1170,6 +1185,12 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
|
|
|
1170
1185
|
| `regions` | The `<uvalib-image-regions>` around an image with regions. |
|
|
1171
1186
|
| `compare` | The version comparison controls and notes under the photo. |
|
|
1172
1187
|
|
|
1188
|
+
### CSS states
|
|
1189
|
+
|
|
1190
|
+
| State | Description |
|
|
1191
|
+
|---|---|
|
|
1192
|
+
| `:state(open)` | The viewer is open. |
|
|
1193
|
+
|
|
1173
1194
|
### Events
|
|
1174
1195
|
|
|
1175
1196
|
| Event | Description |
|
|
@@ -1378,13 +1399,13 @@ Previous/next section links, as on a reading page, or a numbered page list. Prev
|
|
|
1378
1399
|
|
|
1379
1400
|
## `<uvalib-photo-grid>`
|
|
1380
1401
|
|
|
1381
|
-
Justified rows of thumbnails. Each direct child that is a link or a button is one photo; its image keeps its shape from the `width` and `height` attributes, or from the loaded image, so the row does not jump when the picture arrives. The row is about 220px tall and shorter
|
|
1402
|
+
Justified rows of thumbnails. Each direct child that is a link or a button is one photo; its image keeps its shape from the `width` and `height` attributes, or from the loaded image, so the row does not jump when the picture arrives. The row is about 220px tall and shorter when the grid is narrow (a phone, a sidebar); `row-height` sets that height. Every item stays a real link or button. An image with no visible text gets a visible caption from its alt (the caption is then the accessible name, and a repeated alt is cleared). The original alt is kept in `data-uvalib-alt` so a lightbox still describes the picture. An item with no name at all is captioned “Photo N” and warned about once; that caption is renumbered when the photos change order. An `aria-label` is left as the name: the grid does not add a caption that would disagree with it. Put the grid inside `<uvalib-lightbox>` and a plain click opens the viewer. A badge sits on the thumbnail: `<span slot="badge">` inside the link or button, or `data-badge` on that item (for example “seq” or “3 photos”). It is read after the caption (“The Lawn, 3 photos”). When the item already has an `aria-label`, the badge is appended to that label (the author’s words stay in `data-uvalib-label`) and an alt that repeats those words is cleared. A badge does not replace the alt caption.
|
|
1382
1403
|
|
|
1383
1404
|
### Attributes
|
|
1384
1405
|
|
|
1385
1406
|
| Attribute | Type | Default | Description |
|
|
1386
1407
|
|---|---|---|---|
|
|
1387
|
-
| `row-height` | `string` | `''` | Row height. A bare number is pixels (`220` is 220px); `px`, `rem`, `em`, `vh`, `vw`, `vmin`, `vmax`, `ch` and `%` are kept. Empty uses 220px, or 140px when the
|
|
1408
|
+
| `row-height` | `string` | `''` | Row height. A bare number is pixels (`220` is 220px); `px`, `rem`, `em`, `vh`, `vw`, `vmin`, `vmax`, `ch` and `%` are kept. Empty uses 220px, or 140px when the grid itself is narrower than 48rem (a phone, a sidebar, a drawer). |
|
|
1388
1409
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1389
1410
|
| `no-style` | `boolean` | `false` | |
|
|
1390
1411
|
|
|
@@ -1478,7 +1499,7 @@ Tabs, as on library.virginia.edu: a row of buttons over one visible panel. Each
|
|
|
1478
1499
|
|
|
1479
1500
|
## `<uvalib-tag-list>`
|
|
1480
1501
|
|
|
1481
|
-
A labelled list of keywords or subjects that wraps: each tag a link (for example a search for that term) or plain text. Link tags are outlined pills in the link colour; plain tags are filled chips (the card chip's colours), so a link never looks like a label. Every tag and the toggle are at least 2rem (34px) tall and wide, 0.5rem apart. Give the tags as children: `<a href>` for a link, any other element (`<span>`) for plain text. A child's `lang` and `dir` are kept, and so is inline markup inside it (`em`, `cite`, `abbr`, `bdi`, a `span lang`…), copied element by element (never parsed as HTML). Or set `href-template` (with `{tag}`, replaced by the URL-encoded text) to make every tag without its own href a link; a blank href counts as none. Apps can set the `items` property (`{ label, href?, lang?, dir? }`) instead; it wins over the children. Children with no text are skipped with one warning. `label` names the list (shown above it, or visually hidden with `hide-label`); without one a console warning is logged. `limit` shows that many tags and a “Show all N” button (`aria-expanded`, `aria-controls`), which reveals the rest in place and keeps focus. Analytics never sends a tag's text (record tags can be user-submitted or machine-made), and by default not the label either, which a template may fill from a record: the name is the list's place among the tag lists on the page, `list N`. Add `track-label` when the label is fixed text the page author wrote (“Subjects”), to send it instead.
|
|
1502
|
+
A labelled list of keywords or subjects that wraps: each tag a link (for example a search for that term) or plain text. Link tags are outlined pills in the link colour; plain tags are filled chips (the card chip's colours), so a link never looks like a label. Every tag and the toggle are at least 2rem (34px) tall and wide, 0.5rem apart. Give the tags as children: `<a href>` for a link, any other element (`<span>`) for plain text. A child's `lang` and `dir` are kept, and so is inline markup inside it (`em`, `cite`, `abbr`, `bdi`, a `span lang`…), copied element by element (never parsed as HTML). Or set `href-template` (with `{tag}`, replaced by the URL-encoded text) to make every tag without its own href a link; a blank href counts as none. Apps can set the `items` property (`{ label, href?, lang?, dir? }`) instead; it wins over the children. Children with no text are skipped with one warning. `label` names the list (shown above it, or visually hidden with `hide-label`); without one a console warning is logged. `limit` shows that many tags and a “Show all N” button (`aria-expanded`, `aria-controls`), which reveals the rest in place and keeps focus. Pages can style the list while every tag is shown with `:state(expanded)`. Analytics never sends a tag's text (record tags can be user-submitted or machine-made), and by default not the label either, which a template may fill from a record: the name is the list's place among the tag lists on the page, `list N`. Add `track-label` when the label is fixed text the page author wrote (“Subjects”), to send it instead.
|
|
1482
1503
|
|
|
1483
1504
|
### Attributes
|
|
1484
1505
|
|
|
@@ -1492,6 +1513,12 @@ A labelled list of keywords or subjects that wraps: each tag a link (for example
|
|
|
1492
1513
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1493
1514
|
| `no-style` | `boolean` | `false` | |
|
|
1494
1515
|
|
|
1516
|
+
### CSS states
|
|
1517
|
+
|
|
1518
|
+
| State | Description |
|
|
1519
|
+
|---|---|
|
|
1520
|
+
| `:state(expanded)` | Show all was pressed: every tag is shown (the toggle's `aria-expanded="true"`). |
|
|
1521
|
+
|
|
1495
1522
|
### Events
|
|
1496
1523
|
|
|
1497
1524
|
| Event | Description |
|
package/dist-cdn/uvalib-card.js
CHANGED
|
@@ -168,10 +168,16 @@ var m = 3, h = /* @__PURE__ */ new Set([
|
|
|
168
168
|
padding: 1rem 1.25rem;
|
|
169
169
|
flex: 1 1 auto;
|
|
170
170
|
}
|
|
171
|
+
/* Short heading: balanced lines. Longer excerpt: no one-word last line. Both are
|
|
172
|
+
look, not structure (dropped with no-style), and ignored where unsupported. */
|
|
171
173
|
.title {
|
|
172
174
|
font-size: 1.25rem;
|
|
173
175
|
line-height: 1.3;
|
|
174
176
|
font-weight: 600;
|
|
177
|
+
text-wrap: balance;
|
|
178
|
+
}
|
|
179
|
+
.excerpt {
|
|
180
|
+
text-wrap: pretty;
|
|
175
181
|
}
|
|
176
182
|
.title-link {
|
|
177
183
|
color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));
|