@uvalib/web-components 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +47 -7
- package/dist/components/uvalib-image-regions/UvalibImageRegions.d.ts +9 -1
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js +39 -8
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -1
- package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +41 -2
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +161 -10
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-map/UvalibMap.d.ts +79 -10
- package/dist/components/uvalib-map/UvalibMap.js +502 -108
- package/dist/components/uvalib-map/UvalibMap.js.map +1 -1
- package/dist/custom-elements.json +554 -44
- package/dist-cdn/custom-elements.json +554 -44
- package/dist-cdn/manifest.json +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +2 -2
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +5 -4
- package/dist-cdn/uvalib-image-regions.js +27 -14
- package/dist-cdn/uvalib-image-regions.js.map +1 -1
- package/dist-cdn/uvalib-lightbox.js +100 -34
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-map.js +302 -106
- package/dist-cdn/uvalib-map.js.map +1 -1
- package/package.json +1 -1
- package/skills/uvalib-web-components/SKILL.md +2 -2
- package/skills/uvalib-web-components/reference/components.md +5 -4
package/dist-cdn/manifest.json
CHANGED
|
@@ -721,7 +721,7 @@ Use these instead of a hand-built gallery or a carousel. There is no autoplay.
|
|
|
721
721
|
- `url-param="photo"` keeps `?photo=<id>` in sync (the id is `data-id`, else `id`, else the IIIF identifier, else the position from 1): opening pushes a history entry, stepping replaces it, Back closes. On a hash route the parameter is written inside the hash. Opening from a URL that already has it is not an analytics event. With `spa="auto"`, that opening push may count as one Matomo page view.
|
|
722
722
|
- Details: a child with `slot="details"` (`data-for` selects one item by id or position from 1; without it the details show for every image), or `data-details-id` on a link naming an element elsewhere. It is put back when the viewer moves on or closes.
|
|
723
723
|
- `<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 `select` and `highlight` (`detail: { item, index }`). Do not hand-build absolutely positioned outlines. It reports outline clicks itself (the list's label and the number, never a region's label).
|
|
724
|
-
- 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.
|
|
724
|
+
- 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").
|
|
725
725
|
- `<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 at 767px and below, 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.
|
|
726
726
|
|
|
727
727
|
```html snippet
|
|
@@ -796,7 +796,7 @@ A map of places (buildings, rooms, outdoor spaces, collection subjects) is one `
|
|
|
796
796
|
|
|
797
797
|
- Leaflet is the page's: load `https://unpkg.com/leaflet@1.9.4/dist/leaflet.js` (with its integrity hash and `defer`, before the module scripts), or in a bundled app `import * as L from 'leaflet'` and set `el.leaflet = L`. The library never bundles it. Leaflet's CSS is not needed. Without Leaflet the element shows the list alone (one console warning).
|
|
798
798
|
- Give the places as the child list (`<ul>` of `<li><a href data-lat data-lng data-count>Name</a></li>`, which is the no-JavaScript list too) or the `items` property (`[{ id?, name, lat, lng, count?, href?, description? }]`). `label` is required; `count-label` is the noun in the markers' names (“The Rotunda, 2,702 photos”).
|
|
799
|
-
- It renders the skip link, the key instructions, the labelled region, 44px zoom buttons, the attribution, the tooltips and the list↔marker highlight itself; do not add your own. `select` (`detail: { item }`, cancelable) fires when a marker is chosen.
|
|
799
|
+
- It renders the skip link, the key instructions, the labelled region, 44px zoom buttons, the attribution, the tooltips and the list↔marker highlight itself; do not add your own. `select` (`detail: { item }`, cancelable) fires when a marker is chosen. Places at (nearly) the same point need nothing extra: overlapping markers become one group marker (“The Rotunda and 2 more places”, `place-label` is the noun) that zooms in or spreads them in a ring.
|
|
800
800
|
- Tiles default to OpenStreetMap's, which are for light use only (attribution kept, no heavy traffic): for a busy page set `tile-url` and `attribution` to a library-hosted or commercial tile source. In dark mode it inverts the tiles with a filter, or uses `dark-tile-url`.
|
|
801
801
|
- It reports `select` (the map's label and the place's position) and `zoom` to analytics itself, never a place: do not add your own tracking.
|
|
802
802
|
|
|
@@ -1133,7 +1133,7 @@ An image with numbered region outlines (people, objects, inscriptions) and a lis
|
|
|
1133
1133
|
|
|
1134
1134
|
## `<uvalib-lightbox>`
|
|
1135
1135
|
|
|
1136
|
-
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 when the viewer moves on or closes.
|
|
1136
|
+
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 when the viewer moves on or closes. 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`.
|
|
1137
1137
|
|
|
1138
1138
|
### Attributes
|
|
1139
1139
|
|
|
@@ -1190,7 +1190,7 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
|
|
|
1190
1190
|
|
|
1191
1191
|
## `<uvalib-map>`
|
|
1192
1192
|
|
|
1193
|
-
A map of places with a linked list of the same places: buildings, rooms or outdoor spaces, each a marker sized by a count, with a link to the place's page. It wraps [Leaflet](https://leafletjs.com) 1.9, which the page provides (the library never bundles it): set the `leaflet` property to the Leaflet module (`import * as L from 'leaflet'`), or load leaflet.js so that `window.L` exists. Without Leaflet only the list is shown, with one console warning. Leaflet's leaflet.css is optional: the element carries the layout rules it needs, in shadow DOM and light DOM alike. Places come from `items` (`{ id?, name, lat, lng, count?, href?, description? }`) or from a child `<ul>`/`<ol>` of `<li><a href data-lat data-lng data-count>Name</a></li>`, which is the list before the script runs (and without it). The list always stays, under the map: it is the text equivalent. Each marker is a real link (a button when the place has no `href`) named like "The Rotunda, 2,702 photos" (`count-label` is the noun), sized by the square root of its count (a 24 to 56px dot in a hit area of at least 44px). Tab or the arrow keys move between markers, Enter follows the link (or chooses the place), and Escape hides the tooltip. Hovering or focusing a marker shows a tooltip with its name and count and highlights its list entry; hovering or focusing a list entry highlights its marker (a ring and a larger dot, not colour alone) and brings it into view. The map is a region named by `label`, after a "Skip map, go to the list" link and a line of key instructions. It opens on the bounds of the places, or on `center` and `zoom`. The zoom buttons are 44px with a visible focus ring; the attribution stays. Tiles come from `tile-url` (OpenStreetMap by default: low-traffic use only) with `attribution`. In the page's dark mode the tiles are inverted with a CSS filter (`--uvalib-map-dark-filter`) unless `dark-tile-url` gives dark tiles; markers and controls are never filtered. With `prefers-reduced-motion` nothing animates.
|
|
1193
|
+
A map of places with a linked list of the same places: buildings, rooms or outdoor spaces, each a marker sized by a count, with a link to the place's page. It wraps [Leaflet](https://leafletjs.com) 1.9, which the page provides (the library never bundles it): set the `leaflet` property to the Leaflet module (`import * as L from 'leaflet'`), or load leaflet.js so that `window.L` exists. Without Leaflet only the list is shown, with one console warning. Leaflet's leaflet.css is optional: the element carries the layout rules it needs, in shadow DOM and light DOM alike. Places come from `items` (`{ id?, name, lat, lng, count?, href?, description? }`) or from a child `<ul>`/`<ol>` of `<li><a href data-lat data-lng data-count>Name</a></li>`, which is the list before the script runs (and without it). The list always stays, under the map: it is the text equivalent. Each marker is a real link (a button when the place has no `href`) named like "The Rotunda, 2,702 photos" (`count-label` is the noun), sized by the square root of its count (a 24 to 56px dot in a hit area of at least 44px). Tab or the arrow keys move between markers, Enter follows the link (or chooses the place), and Escape hides the tooltip. Hovering or focusing a marker shows a tooltip with its name and count and highlights its list entry; hovering or focusing a list entry highlights its marker (a ring and a larger dot, not colour alone) and brings it into view. Markers whose 44px targets would overlap at the current zoom are drawn as one group marker (regrouped after every zoom and resize): a button showing how many places it holds, sized by their summed count and named like "The Rotunda and 2 more places, 3,610 photos" (the largest place's name; `place-label` is the noun). Choosing it zooms in until its places part; when they cannot (one point, or the maximum zoom) it spreads them in a ring around it instead, with focus on the first; Escape or a zoom closes the ring and focus returns to the group. The arrow keys move between the markers shown (a group is one); a place in the list that is in a group highlights the group, whose tooltip names the place. The map is a region named by `label`, after a "Skip map, go to the list" link and a line of key instructions. It opens on the bounds of the places, or on `center` and `zoom`. The zoom buttons are 44px with a visible focus ring; the attribution stays. Tiles come from `tile-url` (OpenStreetMap by default: low-traffic use only) with `attribution`. In the page's dark mode the tiles are inverted with a CSS filter (`--uvalib-map-dark-filter`) unless `dark-tile-url` gives dark tiles; markers and controls are never filtered. With `prefers-reduced-motion` nothing animates.
|
|
1194
1194
|
|
|
1195
1195
|
### Attributes
|
|
1196
1196
|
|
|
@@ -1199,6 +1199,7 @@ A map of places with a linked list of the same places: buildings, rooms or outdo
|
|
|
1199
1199
|
| `items` | `MapItem[]` | `[]` | The places. When non-empty, wins over the child list. Set a new array to update. |
|
|
1200
1200
|
| `label` | `string` | `''` | The map's name (required): the region's label, the list's label and the analytics name. |
|
|
1201
1201
|
| `count-label` | `string` | `'items'` | The noun after each count, plural ("photos"); a count of one drops a trailing s. |
|
|
1202
|
+
| `place-label` | `string` | `'places'` | The noun for places in a group's name, plural: "The Rotunda and 2 more places" (one drops a trailing s: "and 1 more place"). For example "rooms". |
|
|
1202
1203
|
| `tile-url` | | `OSM_TILE_URL` | The tile URL template (`{z}/{x}/{y}`, optionally `{s}` and `{r}`). |
|
|
1203
1204
|
| `dark-tile-url` | `string` | `''` | Tiles for the page's dark mode. Without it, dark mode filters the light tiles instead. |
|
|
1204
1205
|
| `attribution` | | `OSM_ATTRIBUTION` | The tiles' attribution, as HTML. Required by most tile sources; always shown. |
|
|
@@ -1226,8 +1227,8 @@ A map of places with a linked list of the same places: buildings, rooms or outdo
|
|
|
1226
1227
|
|
|
1227
1228
|
| Event | Description |
|
|
1228
1229
|
|---|---|
|
|
1229
|
-
| `select` | A marker was chosen (click, Enter or Space). `detail` is `{ item }`. Cancelable: for a place with `href`, `preventDefault()` keeps the page from following the link. Bubbles and is composed. |
|
|
1230
|
-
| `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-map', 'select', '<label>', <position from 1>]` when a marker is chosen, and `['uvalib-map', 'zoom', '<label>', <zoom level>]` 1 s after the last zoom-button press. Never a place's name, coordinates or URL. Bubbles and is composed. |
|
|
1230
|
+
| `select` | A place's marker was chosen (click, Enter or Space); never a group's. `detail` is `{ item }`. Cancelable: for a place with `href`, `preventDefault()` keeps the page from following the link. Bubbles and is composed. |
|
|
1231
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-map', 'select', '<label>', <position from 1>]` when a place's marker is chosen, `['uvalib-map', 'expand', '<label>', <places in it>]` when a group is chosen (it zooms in or opens its ring), and `['uvalib-map', 'zoom', '<label>', <zoom level>]` 1 s after the last zoom-button press. Never a place's name, coordinates or URL. Bubbles and is composed. |
|
|
1231
1232
|
|
|
1232
1233
|
### CSS custom properties
|
|
1233
1234
|
|
|
@@ -133,7 +133,7 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
|
|
|
133
133
|
];
|
|
134
134
|
}
|
|
135
135
|
constructor() {
|
|
136
|
-
super(), this.items = null, this.src = "", this.alt = "", this.label = "Regions", this.numbering = "numbers", this.hideOutlines = !1, this.entries = [], this.natural = null, this.active = -1, this.inferredLevel = 2, this.hover = -1, this.focused = -1, this.headingId = `uvalib-image-regions-heading-${++y}`, this.watchedImg = null, this.key = "", this.resized = 0, this.onImageLoad = () => this.measure(), this.onPointerOver = (e) => {
|
|
136
|
+
super(), this.items = null, this.src = "", this.alt = "", this.label = "Regions", this.numbering = "numbers", this.hideOutlines = !1, this.entries = [], this.natural = null, this.active = -1, this.inferredLevel = 2, this.hover = -1, this.focused = -1, this.headingId = `uvalib-image-regions-heading-${++y}`, this.watchedImg = null, this.slottedList = null, this.key = "", this.resized = 0, this.onImageLoad = () => this.measure(), this.onPointerOver = (e) => {
|
|
137
137
|
this.hover = this.indexFrom(e)?.i ?? -1, this.setActive();
|
|
138
138
|
}, this.onPointerLeave = () => {
|
|
139
139
|
this.hover = -1, this.setActive();
|
|
@@ -141,7 +141,7 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
|
|
|
141
141
|
this.focused = this.indexFrom(e)?.i ?? -1, this.setActive();
|
|
142
142
|
}, this.onFocusOut = (e) => {
|
|
143
143
|
let t = e.relatedTarget;
|
|
144
|
-
t instanceof Node && (this.contains(t) || this.renderRoot.contains(t)) || (this.focused = -1, this.setActive());
|
|
144
|
+
t instanceof Node && (this.contains(t) || this.renderRoot.contains(t) || this.slottedList?.contains(t)) || (this.focused = -1, this.setActive());
|
|
145
145
|
}, this.onClick = (e) => {
|
|
146
146
|
let t = this.indexFrom(e);
|
|
147
147
|
t?.outline && this.choose(t.i);
|
|
@@ -162,7 +162,11 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
|
|
|
162
162
|
scope: !1
|
|
163
163
|
});
|
|
164
164
|
let n = d(this);
|
|
165
|
-
this.inferredLevel = n === null ? 2 : Math.min(Math.max(n + 1, 2), 6), this.
|
|
165
|
+
this.inferredLevel = n === null ? 2 : Math.min(Math.max(n + 1, 2), 6), this.slottedList = null, this.sync(), this.observe();
|
|
166
|
+
}
|
|
167
|
+
observe() {
|
|
168
|
+
this.observer ??= new MutationObserver(() => this.sync()), this.observer.disconnect();
|
|
169
|
+
let e = {
|
|
166
170
|
childList: !0,
|
|
167
171
|
subtree: !0,
|
|
168
172
|
attributes: !0,
|
|
@@ -176,7 +180,8 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
|
|
|
176
180
|
"srcset"
|
|
177
181
|
],
|
|
178
182
|
characterData: !0
|
|
179
|
-
}
|
|
183
|
+
};
|
|
184
|
+
this.observer.observe(this, e), this.slottedList && this.observer.observe(this.slottedList, e);
|
|
180
185
|
}
|
|
181
186
|
disconnectedCallback() {
|
|
182
187
|
super.disconnectedCallback(), this.observer?.disconnect(), this.resizer?.disconnect(), this.resizer = void 0, this.watchImage(null);
|
|
@@ -195,7 +200,7 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
|
|
|
195
200
|
return t instanceof HTMLElement ? t : null;
|
|
196
201
|
}
|
|
197
202
|
sourceList() {
|
|
198
|
-
return (this.lightDom ? [...this.children, ...this.listHost?.children ?? []] : [...this.children]).find((e) => e.localName === "ol" || e.localName === "ul") ?? null;
|
|
203
|
+
return (this.lightDom ? [...this.children, ...this.listHost?.children ?? []] : [...this.children]).flatMap((e) => e instanceof HTMLSlotElement ? e.assignedElements({ flatten: !0 }) : [e]).find((e) => e.localName === "ol" || e.localName === "ul") ?? null;
|
|
199
204
|
}
|
|
200
205
|
get imgHost() {
|
|
201
206
|
return this.lightDom ? this.querySelector(":scope > .layout .img-host") : null;
|
|
@@ -240,10 +245,17 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
|
|
|
240
245
|
return t;
|
|
241
246
|
}
|
|
242
247
|
fromList() {
|
|
243
|
-
let e = this.sourceList();
|
|
248
|
+
let e = this.sourceList(), t = e && !this.contains(e) ? e : null;
|
|
249
|
+
if (t !== this.slottedList && (this.slottedList = t, this.isConnected && this.observe(), t && !this.noStyle)) {
|
|
250
|
+
let e = t.getRootNode();
|
|
251
|
+
(e instanceof Document || e instanceof ShadowRoot) && c(`${this.localName}::slotted-entries`, w, {
|
|
252
|
+
root: e,
|
|
253
|
+
scope: !1
|
|
254
|
+
});
|
|
255
|
+
}
|
|
244
256
|
if (!e) return [];
|
|
245
|
-
let
|
|
246
|
-
return [...e.children].forEach((e,
|
|
257
|
+
let n = e.localName === "ol" && Number(e.getAttribute("start") ?? 1) || 1, r = [];
|
|
258
|
+
return [...e.children].forEach((e, t) => {
|
|
247
259
|
if (e.localName !== "li" || !(e instanceof HTMLElement)) return;
|
|
248
260
|
let i = g(e.dataset.xywh), a = e.querySelector("a[href]"), o = f(e.dataset.label) || f(a?.textContent) || this.text(e), s = i ? {
|
|
249
261
|
label: o,
|
|
@@ -257,13 +269,13 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
|
|
|
257
269
|
}, c = f(e.dataset.id) || e.id;
|
|
258
270
|
c && (s.id = c);
|
|
259
271
|
let l = a?.getAttribute("href");
|
|
260
|
-
l && (s.href = l),
|
|
272
|
+
l && (s.href = l), r.push({
|
|
261
273
|
item: s,
|
|
262
274
|
box: i,
|
|
263
|
-
number:
|
|
275
|
+
number: n + t,
|
|
264
276
|
el: e
|
|
265
277
|
});
|
|
266
|
-
}),
|
|
278
|
+
}), r;
|
|
267
279
|
}
|
|
268
280
|
text(e) {
|
|
269
281
|
let t = [], n = (e) => {
|
|
@@ -317,9 +329,10 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
|
|
|
317
329
|
return t ? t.el ? t.el : this.renderRoot.querySelector(`.items > li[data-index="${e}"]`) : null;
|
|
318
330
|
}
|
|
319
331
|
mark() {
|
|
320
|
-
this.
|
|
321
|
-
|
|
322
|
-
|
|
332
|
+
let e = this.items ? null : this.sourceList();
|
|
333
|
+
this.entries.forEach((t, n) => {
|
|
334
|
+
let r = this.entryEl(n);
|
|
335
|
+
!r || t.el && t.el.parentElement !== e || (r.getAttribute("data-uvalib-region") !== String(t.number) && r.setAttribute("data-uvalib-region", String(t.number)), r.toggleAttribute("data-uvalib-active", n === this.active));
|
|
323
336
|
});
|
|
324
337
|
}
|
|
325
338
|
indexFrom(e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uvalib-image-regions.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","precedingHeadingLevel","normalize","safeHref","accessible","toRegion","parseXywh","toPercent","DEFAULT_LABEL","nextId","NOT_LABEL","structuralRules","host","shadowStructure","entryRules","p","entryStyles","UvalibImageRegions","to","hit","root","node","above","changed","kids","el","k","img","next","key","sameEls","out","raw","items","item","list","start","li","box","link","label","id","href","parts","walk","imgHost","listHost","w","h","tall","entry","media","at","en","name","base","A","light","numbers","image","hasActive"],"sources":["../src/components/uvalib-image-regions/UvalibImageRegions.ts","../src/components/uvalib-image-regions/uvalib-image-regions.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { precedingHeadingLevel } from '../../base/heading-level.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { normalize, safeHref } from '../../base/source-children.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { accessible } from '../../styles/accessible.js';\nimport { parseXywh, toPercent, toRegion, type ImageRegion, type RegionBox } from './regions.js';\n\nexport type { ImageRegion } from './regions.js';\n\n/** One region as drawn: what events carry, its box, its number and its list entry. */\ninterface Entry {\n item: ImageRegion;\n box: RegionBox | null;\n number: number;\n /** The author's list item (children mode); own items are found by index. */\n el: HTMLElement | null;\n}\n\nconst DEFAULT_LABEL = 'Regions';\nlet nextId = 0;\n\n/** Controls inside a list item, which are actions and not part of the region's name. */\nconst NOT_LABEL = 'button, input, select, textarea, ol, ul, [hidden], [aria-hidden=\"true\"]';\n\n/**\n * Kept with `no-style`: the layout (the image at its own width, at most the element's, and\n * the list beside it when at least 14rem is left, else under it: the same wrapping flex row\n * base.css gives the children before the element upgrades, so nothing moves), the overlay\n * over the image, and the double outlines and number badges (without them the regions are\n * not visible). `host` is `:host` (shadow) or the tag (light DOM).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} .layout {\n display: flex;\n flex-wrap: wrap;\n gap: 1rem;\n align-items: flex-start;\n }\n ${host} .media {\n position: relative;\n flex: 0 1 auto;\n width: fit-content;\n min-width: 0;\n max-width: 100%;\n margin: 0;\n }\n ${host} .list { flex: 1 1 14rem; min-width: 0; }\n ${host} .media img, ${host} .img-host > picture${\n host === ':host' ? ', ::slotted(img), ::slotted(picture)' : ''\n } { display: block; max-width: 100%; height: auto; }\n ${host} .overlay {\n position: absolute;\n inset: 0;\n overflow: clip;\n overflow-clip-margin: 0.5rem;\n pointer-events: none;\n forced-color-adjust: none;\n }\n ${host} .region {\n position: absolute;\n box-sizing: border-box;\n border: 2px solid #fff;\n outline: 2px solid #000;\n pointer-events: auto;\n cursor: pointer;\n }\n ${host} .region.active { z-index: 1; border-width: 4px; outline-width: 4px; }\n ${host} .overlay.has-active .region:not(.active) { opacity: 0.6; }\n ${host} .badge {\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n display: flex;\n gap: 0.375em;\n max-width: 16rem;\n padding: 0.0625rem 0.375rem;\n background: #000;\n color: #fff;\n font-size: 0.875rem;\n font-weight: 700;\n line-height: 1.25;\n white-space: nowrap;\n outline: 1px solid #fff;\n }\n ${host} .region:not([data-inside]) .badge {\n inset-block-start: auto;\n inset-block-end: calc(100% + 4px);\n inset-inline-start: -4px;\n }\n ${host} .region.active:not([data-inside]) .badge {\n inset-block-end: calc(100% + 8px);\n inset-inline-start: -8px;\n }\n ${host} .badge .name { overflow: hidden; text-overflow: ellipsis; }\n ${host} .region:not(.active) .badge .name, ${host} .badge:empty { display: none; }\n ${host} .region:not(.active) .badge.no-number { display: none; }\n ${host} .heading { margin: 0 0 0.5rem; }\n ${host} .items { margin: 0; }\n @media (forced-colors: active) {\n ${host} .region { border-color: Canvas; outline-color: CanvasText; }\n ${host} .region.active { outline-color: Highlight; }\n ${host} .badge { background: CanvasText; color: Canvas; outline-color: Canvas; }\n ${host} .region.active .badge { background: Highlight; color: HighlightText; }\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/**\n * A region's list entry: room for the highlight bar, and the bar (with a tint) while its\n * region is highlighted, so it is shown by more than colour. Shadow mode also installs\n * these in the page, scoped to the tag, for the author's own list items.\n */\nconst entryRules = (p: string) => `\n ${p}[data-uvalib-region] {\n box-sizing: border-box;\n padding-block: 0.5rem;\n padding-inline: calc(0.5rem + 0.375rem) 0.5rem;\n overflow-wrap: anywhere;\n }\n ${p}[data-uvalib-region][data-uvalib-active] {\n padding-inline-start: 0.5rem;\n border-inline-start: 0.375rem solid currentColor;\n background: var(--uva-color-surface-hover, #f1f1f1);\n }\n ${p}[data-uvalib-region]:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n ${p}[data-uvalib-region][tabindex='-1']:focus:not(:focus-visible) { outline: none; }\n @media (forced-colors: active) {\n ${p}[data-uvalib-region][data-uvalib-active] { border-inline-start-color: Highlight; }\n }\n`;\nconst entryStyles = unsafeCSS(entryRules(''));\n\n/**\n * An image with numbered region outlines (people, objects, inscriptions) and a list of the\n * same regions beside it (under it on a narrow screen). The list is the way in: the\n * outlines are a visual aid, hidden from assistive technology and not in the tab order, so\n * no region is a second tab stop. Hovering or focusing a list entry (or anything in it)\n * highlights its region with a thicker double outline and its label, and dims the others;\n * hovering a region highlights its entry. Clicking a region moves focus to its entry.\n *\n * The image: an `<img>` (or `<picture>`) child, which keeps its `alt`, or `src` and `alt`.\n * Give it `width` and `height` so its space is reserved before it loads.\n *\n * The regions: an `<ol>` child whose `<li>` items carry `data-xywh` (IIIF / Media Fragments:\n * `percent:10,20,30,40`, or pixels `160,120,320,240` of the image's natural size). The list\n * is shown as written, so it works before the component loads or without JavaScript, and\n * any links and buttons in it stay the page's own (their events are the page's). Or set\n * the `items` property, and the component draws the list. Region numbers are the list's\n * numbers, from 1 (or the `<ol>`'s `start`).\n *\n * @tagname uvalib-image-regions\n * @slot - The region list (`<ol>` with `<li data-xywh>`), shown as written. Not used with `items`.\n * @slot image - The image. A first `<img>` or `<picture>` child is put here by itself.\n * @csspart layout - The grid holding the image and the list.\n * @csspart media - The image and its overlay.\n * @csspart overlay - The outlines over the image (`aria-hidden`).\n * @csspart region - One outline.\n * @csspart list - The heading and the list.\n * @fires highlight - The highlighted region changed by hover or focus: `detail` is `{ item, index }` (`item` null and `index` -1 when none is). Bubbles and is composed.\n * @fires select - A region's outline was clicked (focus moved to its list entry): `detail` is `{ item, index }`. Bubbles and is composed.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-image-regions', 'select', '<label>', <number>]` when an outline is clicked (the list's `label`, and the region's number from 1). Never a region's label (it may be a person's name). Nothing on hover or focus. Bubbles and is composed.\n * @cssprop --uva-color-text - Dark-mode role token: text (else `--uva-grey-darkest`).\n * @cssprop --uva-color-surface-hover - Dark-mode role token: the highlighted entry's tint (else #f1f1f1).\n * @cssprop --uva-color-link - Dark-mode role token: entry links (else `--uva-brand-blue`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: descriptions (else #4b5563).\n */\nexport class UvalibImageRegions extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n entryStyles,\n css`\n .list {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .heading {\n font-size: 1.125rem;\n font-weight: 700;\n line-height: 1.3;\n }\n .items {\n padding-inline-start: 1.75rem;\n }\n .items a {\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n .description {\n display: block;\n color: var(--uva-color-text-muted, #4b5563);\n font-size: 0.9375rem;\n }\n @media (prefers-reduced-motion: no-preference) {\n .region {\n transition: opacity 0.15s ease;\n }\n }\n `,\n ];\n\n /** The regions, when the component draws the list. Overrides the child list. */\n @property({ attribute: false }) items: ImageRegion[] | null = null;\n\n /** Image URL, when there is no `<img>` child. */\n @property({ type: String }) src = '';\n /** The image's alternative text (with `src`). */\n @property({ type: String }) alt = '';\n /** The image's width (with `src`), reserving its space. */\n @property({ type: Number }) width?: number;\n /** The image's height (with `src`). */\n @property({ type: Number }) height?: number;\n\n /**\n * The size pixel regions are measured in, when it is not the image's natural size (for\n * example a IIIF derivative of a larger original: the original's width and height).\n */\n @property({ type: Number, attribute: 'image-width' }) imageWidth?: number;\n /** The height pixel regions are measured in (with `image-width`). */\n @property({ type: Number, attribute: 'image-height' }) imageHeight?: number;\n\n /** The list's heading, and the analytics name. */\n @property({ type: String }) label = 'Regions';\n\n /** The heading's level (2 to 6). Default: one below the heading before the element. */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel?: number;\n\n /** `numbers` (default) shows each region's number on its outline; `none` hides them. */\n @property({ type: String }) numbering: 'numbers' | 'none' = 'numbers';\n\n /** Hide the outlines (the list stays). */\n @property({ type: Boolean, reflect: true, attribute: 'hide-outlines' }) hideOutlines = false;\n\n @state() private entries: Entry[] = [];\n @state() private natural: { w: number; h: number } | null = null;\n @state() private active = -1;\n @state() private inferredLevel = 2;\n\n private hover = -1;\n private focused = -1;\n private readonly headingId = `uvalib-image-regions-heading-${++nextId}`;\n private observer?: MutationObserver;\n private watchedImg: HTMLImageElement | null = null;\n private key = '';\n /** The image's rendered size decides where badges fit. */\n private resizer?: ResizeObserver;\n private resized = 0;\n\n constructor() {\n super();\n this.addEventListener('pointerover', this.onPointerOver);\n this.addEventListener('pointerleave', this.onPointerLeave);\n this.addEventListener('focusin', this.onFocusIn);\n this.addEventListener('focusout', this.onFocusOut);\n this.addEventListener('click', this.onClick);\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (this.noStyle && root instanceof ShadowRoot && shadowStructure.styleSheet)\n root.adoptedStyleSheets = [shadowStructure.styleSheet];\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const node = this.getRootNode();\n const root = node instanceof Document || node instanceof ShadowRoot ? node : undefined;\n if (this.lightDom && this.noStyle) {\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n { root, scope: false },\n );\n } else if (!this.lightDom && !this.noStyle) {\n // The author's list items are page content: their highlight is styled in the page.\n installLightDomStyles(\n `${this.localName}::entries`,\n unsafeCSS(entryRules(`${this.localName} `)),\n { root, scope: false },\n );\n }\n const above = precedingHeadingLevel(this);\n this.inferredLevel = above === null ? 2 : Math.min(Math.max(above + 1, 2), 6);\n this.sync();\n this.observer ??= new MutationObserver(() => this.sync());\n this.observer.observe(this, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['data-xywh', 'data-label', 'data-id', 'href', 'start', 'src', 'srcset'],\n characterData: true,\n });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n this.resizer?.disconnect();\n this.resizer = undefined;\n this.watchImage(null);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('items') || changed.has('src')) this.sync();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.arrange();\n this.observeSize();\n this.place();\n this.mark();\n // Reading the image's size may set state: not from inside this update.\n queueMicrotask(() => {\n if (this.isConnected) this.watchImage(this.imageEl());\n });\n }\n\n // ---------------------------------------------------------------- sources\n\n /** The author's image element (`<img>` or `<picture>`), wherever it is now. */\n private sourceImage(): HTMLElement | null {\n if (this.src) return null;\n const kids = this.lightDom\n ? [...this.children, ...(this.imgHost?.children ?? [])]\n : [...this.children];\n const named = kids.find((k) => k.getAttribute('slot') === 'image');\n const el = named ?? kids.find((k) => k.localName === 'img' || k.localName === 'picture');\n return el instanceof HTMLElement ? el : null;\n }\n\n /** The author's list (`<ol>` or `<ul>`), wherever it is now. */\n private sourceList(): HTMLOListElement | HTMLUListElement | null {\n const kids = this.lightDom\n ? [...this.children, ...(this.listHost?.children ?? [])]\n : [...this.children];\n const el = kids.find((k) => k.localName === 'ol' || k.localName === 'ul');\n return (el as HTMLOListElement | HTMLUListElement | undefined) ?? null;\n }\n\n private get imgHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .img-host') : null;\n }\n\n private get listHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .list-host') : null;\n }\n\n /** The `<img>` whose natural size measures pixel regions. */\n private imageEl(): HTMLImageElement | null {\n if (this.src) return this.renderRoot.querySelector<HTMLImageElement>('.media > img');\n const el = this.sourceImage();\n if (!el) return null;\n return el instanceof HTMLImageElement ? el : el.querySelector('img');\n }\n\n /** Re-read the regions (and in shadow mode put the image in its slot). */\n private sync(): void {\n const img = this.sourceImage();\n if (img && !this.lightDom && !img.hasAttribute('slot')) img.setAttribute('slot', 'image');\n const next = this.items ? this.fromItems(this.items) : this.fromList();\n const key = JSON.stringify(next.map((e) => [e.item, e.box, e.number]));\n const sameEls =\n next.length === this.entries.length && next.every((e, i) => e.el === this.entries[i]?.el);\n if (key === this.key && sameEls) return;\n this.key = key;\n this.entries = next;\n if (this.active >= next.length) this.active = -1;\n }\n\n private fromItems(items: unknown[]): Entry[] {\n const out: Entry[] = [];\n for (const raw of Array.isArray(items) ? items : []) {\n const item = toRegion(raw);\n if (!item) continue;\n const { x, y, w, h, unit = 'px' } = item;\n out.push({ item, box: { x, y, w, h, unit }, number: out.length + 1, el: null });\n }\n return out;\n }\n\n private fromList(): Entry[] {\n const list = this.sourceList();\n if (!list) return [];\n const start = list.localName === 'ol' ? Number(list.getAttribute('start') ?? 1) || 1 : 1;\n const out: Entry[] = [];\n [...list.children].forEach((li, i) => {\n if (li.localName !== 'li' || !(li instanceof HTMLElement)) return;\n const box = parseXywh(li.dataset.xywh);\n const link = li.querySelector('a[href]');\n const label = normalize(li.dataset.label) || normalize(link?.textContent) || this.text(li);\n const item: ImageRegion = box ? { label, ...box } : { label, x: 0, y: 0, w: 0, h: 0 };\n const id = normalize(li.dataset.id) || li.id;\n if (id) item.id = id;\n const href = link?.getAttribute('href');\n if (href) item.href = href;\n out.push({ item, box, number: start + i, el: li });\n });\n return out;\n }\n\n /** A list item's own text, without its actions (buttons, fields) or a nested list. */\n private text(li: Element): string {\n const parts: string[] = [];\n const walk = (n: Node) => {\n if (n.nodeType === Node.TEXT_NODE) parts.push(n.textContent ?? '');\n else if (n instanceof Element && !n.matches(NOT_LABEL)) n.childNodes.forEach(walk);\n };\n li.childNodes.forEach(walk);\n return normalize(parts.join(' '));\n }\n\n // ---------------------------------------------------------------- layout\n\n /** Light DOM: move the author's image and list into the layout (the same nodes). */\n private arrange(): void {\n if (!this.lightDom) return;\n const img = this.sourceImage();\n const imgHost = this.imgHost;\n if (img && imgHost && img.parentElement !== imgHost) imgHost.append(img);\n const list = this.items ? null : this.sourceList();\n const listHost = this.listHost;\n if (list && listHost && list.parentElement !== listHost) listHost.append(list);\n }\n\n private watchImage(img: HTMLImageElement | null): void {\n if (img === this.watchedImg) {\n if (img) this.measure();\n return;\n }\n this.watchedImg?.removeEventListener('load', this.onImageLoad);\n this.watchedImg = img;\n img?.addEventListener('load', this.onImageLoad);\n this.measure();\n }\n\n private readonly onImageLoad = (): void => this.measure();\n\n private measure(): void {\n const img = this.watchedImg;\n const w = img?.complete ? img.naturalWidth : 0;\n const h = img?.complete ? img.naturalHeight : 0;\n const next = w > 0 && h > 0 ? { w, h } : null;\n if (next?.w !== this.natural?.w || next?.h !== this.natural?.h) this.natural = next;\n }\n\n /** The size pixel regions are measured in. */\n private get space(): { w: number; h: number } {\n const w = Number(this.imageWidth);\n const h = Number(this.imageHeight);\n if (w > 0 && h > 0) return { w, h };\n return this.natural ?? { w: 0, h: 0 };\n }\n\n /**\n * Position the outlines in percent of the image, so they scale with it (CSSOM, not markup).\n * A number badge sits above its outline, or inside it when there is no room above.\n */\n private place(): void {\n const { w, h } = this.space;\n const overlay = this.renderRoot.querySelector<HTMLElement>('.overlay');\n const tall = overlay?.clientHeight ?? 0;\n for (const el of this.renderRoot.querySelectorAll<HTMLElement>('.overlay > .region')) {\n const entry = this.entries[Number(el.dataset.index)];\n const box = entry?.box ? toPercent(entry.box, w, h) : null;\n el.hidden = !box;\n if (!box) continue;\n el.style.left = `${box.x}%`;\n el.style.top = `${box.y}%`;\n el.style.width = `${box.w}%`;\n el.style.height = `${box.h}%`;\n el.toggleAttribute('data-inside', (box.y / 100) * tall < 28);\n }\n }\n\n private observeSize(): void {\n const media = this.renderRoot.querySelector<HTMLElement>('.media');\n if (!media || typeof ResizeObserver === 'undefined') return;\n if (!this.resizer) {\n this.resizer = new ResizeObserver(() => {\n // The outlines scale by themselves (percent); only the badges' side may change.\n const h = media.clientHeight;\n if (h === this.resized) return;\n this.resized = h;\n this.place();\n });\n this.resizer.observe(media);\n }\n }\n\n /** The list entry of region `i`. */\n private entryEl(i: number): HTMLElement | null {\n const entry = this.entries[i];\n if (!entry) return null;\n if (entry.el) return entry.el;\n return this.renderRoot.querySelector<HTMLElement>(`.items > li[data-index=\"${i}\"]`);\n }\n\n /** Mark the entries (their padding) and the highlighted one. */\n private mark(): void {\n this.entries.forEach((e, i) => {\n const el = this.entryEl(i);\n if (!el) return;\n if (el.getAttribute('data-uvalib-region') !== String(e.number))\n el.setAttribute('data-uvalib-region', String(e.number));\n el.toggleAttribute('data-uvalib-active', i === this.active);\n });\n }\n\n // ---------------------------------------------------------------- interaction\n\n /** The region an event is about: its outline or its list entry (or anything inside it). */\n private indexFrom(e: Event): { i: number; outline: boolean } | null {\n for (const n of e.composedPath()) {\n if (n === this) break;\n if (!(n instanceof HTMLElement)) continue;\n if (n.classList.contains('region') && n.parentElement?.classList.contains('overlay'))\n return { i: Number(n.dataset.index), outline: true };\n const at = this.entries.findIndex((en, i) => (en.el ?? this.entryEl(i)) === n);\n if (at >= 0) return { i: at, outline: false };\n }\n return null;\n }\n\n private setActive(): void {\n const next = this.hover >= 0 ? this.hover : this.focused;\n if (next === this.active) return;\n this.active = next;\n const item = this.entries[next]?.item ?? null;\n this.dispatchEvent(\n new CustomEvent('highlight', {\n detail: { item, index: item ? next : -1 },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private readonly onPointerOver = (e: PointerEvent): void => {\n this.hover = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onPointerLeave = (): void => {\n this.hover = -1;\n this.setActive();\n };\n\n private readonly onFocusIn = (e: FocusEvent): void => {\n this.focused = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onFocusOut = (e: FocusEvent): void => {\n const to = e.relatedTarget;\n if (to instanceof Node && (this.contains(to) || this.renderRoot.contains(to))) return;\n this.focused = -1;\n this.setActive();\n };\n\n private readonly onClick = (e: MouseEvent): void => {\n const hit = this.indexFrom(e);\n if (!hit?.outline) return;\n this.choose(hit.i);\n };\n\n /** An outline was clicked: focus its entry, and say so. */\n private choose(i: number): void {\n const entry = this.entries[i];\n const el = this.entryEl(i);\n if (!entry || !el) return;\n if (!el.hasAttribute('tabindex')) el.tabIndex = -1;\n el.focus();\n el.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n this.dispatchEvent(\n new CustomEvent('select', {\n detail: { item: entry.item, index: i },\n bubbles: true,\n composed: true,\n }),\n );\n const name = normalize(this.label) || DEFAULT_LABEL;\n trackEvent(this, ['uvalib-image-regions', 'select', name, entry.number]);\n }\n\n // ---------------------------------------------------------------- render\n\n private get level(): number {\n const n = Math.trunc(Number(this.headingLevel));\n return n >= 2 && n <= 6 ? n : this.inferredLevel;\n }\n\n private renderOwnList() {\n const base = this.ownerDocument.baseURI;\n return html`<ol class=\"items\" aria-labelledby=${this.headingId}>\n ${this.entries.map(({ item }, i) => {\n const href = item.href && safeHref(item.href, base) ? item.href : '';\n return html`<li data-index=${i}>\n ${href ? html`<a href=${href}>${item.label}</a>` : html`<span>${item.label}</span>`}\n ${item.description ? html`<span class=\"description\">${item.description}</span>` : nothing}\n </li>`;\n })}\n </ol>`;\n }\n\n protected override render() {\n const light = this.lightDom;\n const numbers = this.numbering !== 'none';\n const image = this.src\n ? html`<img\n part=\"image\"\n src=${this.src}\n alt=${this.alt}\n width=${this.width ?? nothing}\n height=${this.height ?? nothing}\n @load=${this.onImageLoad}\n />`\n : light\n ? html`<div class=\"img-host\"></div>`\n : html`<slot name=\"image\" @slotchange=${() => this.requestUpdate()}></slot>`;\n const list = this.items\n ? this.renderOwnList()\n : light\n ? html`<div class=\"list-host\"></div>`\n : html`<slot @slotchange=${() => this.sync()}></slot>`;\n const hasActive = this.active >= 0 && !!this.entries[this.active]?.box;\n return html`<div class=\"layout\" part=\"layout\">\n <div class=\"media\" part=\"media\">\n ${image}\n <div\n class=\"overlay ${hasActive ? 'has-active' : ''}\"\n part=\"overlay\"\n aria-hidden=\"true\"\n ?hidden=${this.hideOutlines}\n >\n ${this.entries.map((e, i) =>\n e.box\n ? html`<div\n class=\"region ${i === this.active ? 'active' : ''}\"\n part=\"region\"\n data-index=${i}\n >\n <span class=\"badge ${numbers ? '' : 'no-number'}\"\n >${numbers ? html`<span class=\"number\">${e.number}</span>` : nothing}${\n e.item.label ? html`<span class=\"name\">${e.item.label}</span>` : nothing\n }</span\n >\n </div>`\n : nothing,\n )}\n </div>\n </div>\n <div class=\"list\" part=\"list\">\n <div class=\"heading\" role=\"heading\" aria-level=${this.level} id=${this.headingId}>\n ${normalize(this.label) || DEFAULT_LABEL}\n </div>\n ${list}\n </div>\n </div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibImageRegions } from './UvalibImageRegions.js';\n\ndefine('uvalib-image-regions', UvalibImageRegions);\n"],"mappings":";;;;;;;AAqBA,IAAMsB,IAAgB,WAClBC,IAAS,GAGPC,IAAY,6EASZC,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;;;;;;IAMLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK,eAAeA,EAAK,sBACzBA,MAAS,UAAU,yCAAyC,GAC7D;IACCA,EAAK;;;;;;;;IAQLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;IACLA,EAAK;;;;;;;;;;;;;;;;IAgBLA,EAAK;;;;;IAKLA,EAAK;;;;IAILA,EAAK;IACLA,EAAK,sCAAsCA,EAAK;IAChDA,EAAK;IACLA,EAAK;IACLA,EAAK;;MAEHA,EAAK;MACLA,EAAK;MACLA,EAAK;MACLA,EAAK;;IAEPA,EAAK,YAAYA,EAAK;GAEpBC,IAAkB3B,EAAUyB,EAAgB,OAAO,CAAC,GAOpDG,KAAc,MAAc;IAC9BC,EAAE;;;;;;IAMFA,EAAE;;;;;IAKFA,EAAE;;;;IAIFA,EAAE;;MAEAA,EAAE;;GAGFC,IAAc9B,EAAU4B,EAAW,EAAE,CAAC,G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AA,KAAA,CAAA,GAEzB7B,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA4B,EAAA,WAAA,UAAA,KAAA,CAAA,GAMzB7B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAc,CAAC,CAAA,GAAA4B,EAAA,WAAA,cAAA,KAAA,CAAA,GAEnD7B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAe,CAAC,CAAA,GAAA4B,EAAA,WAAA,eAAA,KAAA,CAAA,GAGpD7B,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA4B,EAAA,WAAA,SAAA,KAAA,CAAA,GAGzB7B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAgB,CAAC,CAAA,GAAA4B,EAAA,WAAA,gBAAA,KAAA,CAAA,GAGrD7B,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA4B,EAAA,WAAA,aAAA,KAAA,CAAA,GAGzB7B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;AAAgB,CAAC,CAAA,GAAA4B,EAAA,WAAA,gBAAA,KAAA,CAAA,GAErE7B,EAAA,CAAAE,EAAM,CAAA,GAAA2B,EAAA,WAAA,WAAA,KAAA,CAAA,GACN7B,EAAA,CAAAE,EAAM,CAAA,GAAA2B,EAAA,WAAA,WAAA,KAAA,CAAA,GACN7B,EAAA,CAAAE,EAAM,CAAA,GAAA2B,EAAA,WAAA,UAAA,KAAA,CAAA,GACN7B,EAAA,CAAAE,EAAM,CAAA,GAAA2B,EAAA,WAAA,iBAAA,KAAA,CAAA,GChPTtB,EAAO,wBAAwBsB,CAAkB"}
|
|
1
|
+
{"version":3,"file":"uvalib-image-regions.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","precedingHeadingLevel","normalize","safeHref","accessible","toRegion","parseXywh","toPercent","DEFAULT_LABEL","nextId","NOT_LABEL","structuralRules","host","shadowStructure","entryRules","p","entryStyles","UvalibImageRegions","to","hit","root","node","above","options","changed","kids","el","k","img","next","key","sameEls","out","raw","items","item","list","outside","start","li","box","link","label","id","href","parts","walk","imgHost","listHost","w","h","tall","entry","media","e","at","en","name","base","A","light","numbers","image","hasActive"],"sources":["../src/components/uvalib-image-regions/UvalibImageRegions.ts","../src/components/uvalib-image-regions/uvalib-image-regions.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { precedingHeadingLevel } from '../../base/heading-level.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { normalize, safeHref } from '../../base/source-children.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { accessible } from '../../styles/accessible.js';\nimport { parseXywh, toPercent, toRegion, type ImageRegion, type RegionBox } from './regions.js';\n\nexport type { ImageRegion } from './regions.js';\n\n/** One region as drawn: what events carry, its box, its number and its list entry. */\ninterface Entry {\n item: ImageRegion;\n box: RegionBox | null;\n number: number;\n /** The author's list item (children mode); own items are found by index. */\n el: HTMLElement | null;\n}\n\nconst DEFAULT_LABEL = 'Regions';\nlet nextId = 0;\n\n/** Controls inside a list item, which are actions and not part of the region's name. */\nconst NOT_LABEL = 'button, input, select, textarea, ol, ul, [hidden], [aria-hidden=\"true\"]';\n\n/**\n * Kept with `no-style`: the layout (the image at its own width, at most the element's, and\n * the list beside it when at least 14rem is left, else under it: the same wrapping flex row\n * base.css gives the children before the element upgrades, so nothing moves), the overlay\n * over the image, and the double outlines and number badges (without them the regions are\n * not visible). `host` is `:host` (shadow) or the tag (light DOM).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} .layout {\n display: flex;\n flex-wrap: wrap;\n gap: 1rem;\n align-items: flex-start;\n }\n ${host} .media {\n position: relative;\n flex: 0 1 auto;\n width: fit-content;\n min-width: 0;\n max-width: 100%;\n margin: 0;\n }\n ${host} .list { flex: 1 1 14rem; min-width: 0; }\n ${host} .media img, ${host} .img-host > picture${\n host === ':host' ? ', ::slotted(img), ::slotted(picture)' : ''\n } { display: block; max-width: 100%; height: auto; }\n ${host} .overlay {\n position: absolute;\n inset: 0;\n overflow: clip;\n overflow-clip-margin: 0.5rem;\n pointer-events: none;\n forced-color-adjust: none;\n }\n ${host} .region {\n position: absolute;\n box-sizing: border-box;\n border: 2px solid #fff;\n outline: 2px solid #000;\n pointer-events: auto;\n cursor: pointer;\n }\n ${host} .region.active { z-index: 1; border-width: 4px; outline-width: 4px; }\n ${host} .overlay.has-active .region:not(.active) { opacity: 0.6; }\n ${host} .badge {\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n display: flex;\n gap: 0.375em;\n max-width: 16rem;\n padding: 0.0625rem 0.375rem;\n background: #000;\n color: #fff;\n font-size: 0.875rem;\n font-weight: 700;\n line-height: 1.25;\n white-space: nowrap;\n outline: 1px solid #fff;\n }\n ${host} .region:not([data-inside]) .badge {\n inset-block-start: auto;\n inset-block-end: calc(100% + 4px);\n inset-inline-start: -4px;\n }\n ${host} .region.active:not([data-inside]) .badge {\n inset-block-end: calc(100% + 8px);\n inset-inline-start: -8px;\n }\n ${host} .badge .name { overflow: hidden; text-overflow: ellipsis; }\n ${host} .region:not(.active) .badge .name, ${host} .badge:empty { display: none; }\n ${host} .region:not(.active) .badge.no-number { display: none; }\n ${host} .heading { margin: 0 0 0.5rem; }\n ${host} .items { margin: 0; }\n @media (forced-colors: active) {\n ${host} .region { border-color: Canvas; outline-color: CanvasText; }\n ${host} .region.active { outline-color: Highlight; }\n ${host} .badge { background: CanvasText; color: Canvas; outline-color: Canvas; }\n ${host} .region.active .badge { background: Highlight; color: HighlightText; }\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/**\n * A region's list entry: room for the highlight bar, and the bar (with a tint) while its\n * region is highlighted, so it is shown by more than colour. Shadow mode also installs\n * these in the page, scoped to the tag, for the author's own list items.\n */\nconst entryRules = (p: string) => `\n ${p}[data-uvalib-region] {\n box-sizing: border-box;\n padding-block: 0.5rem;\n padding-inline: calc(0.5rem + 0.375rem) 0.5rem;\n overflow-wrap: anywhere;\n }\n ${p}[data-uvalib-region][data-uvalib-active] {\n padding-inline-start: 0.5rem;\n border-inline-start: 0.375rem solid currentColor;\n background: var(--uva-color-surface-hover, #f1f1f1);\n }\n ${p}[data-uvalib-region]:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n ${p}[data-uvalib-region][tabindex='-1']:focus:not(:focus-visible) { outline: none; }\n @media (forced-colors: active) {\n ${p}[data-uvalib-region][data-uvalib-active] { border-inline-start-color: Highlight; }\n }\n`;\nconst entryStyles = unsafeCSS(entryRules(''));\n\n/**\n * An image with numbered region outlines (people, objects, inscriptions) and a list of the\n * same regions beside it (under it on a narrow screen). The list is the way in: the\n * outlines are a visual aid, hidden from assistive technology and not in the tab order, so\n * no region is a second tab stop. Hovering or focusing a list entry (or anything in it)\n * highlights its region with a thicker double outline and its label, and dims the others;\n * hovering a region highlights its entry. Clicking a region moves focus to its entry.\n *\n * The image: an `<img>` (or `<picture>`) child, which keeps its `alt`, or `src` and `alt`.\n * Give it `width` and `height` so its space is reserved before it loads.\n *\n * The regions: an `<ol>` child whose `<li>` items carry `data-xywh` (IIIF / Media Fragments:\n * `percent:10,20,30,40`, or pixels `160,120,320,240` of the image's natural size). The list\n * is shown as written, so it works before the component loads or without JavaScript, and\n * any links and buttons in it stay the page's own (their events are the page's). Or set\n * the `items` property, and the component draws the list. Region numbers are the list's\n * numbers, from 1 (or the `<ol>`'s `start`).\n *\n * @tagname uvalib-image-regions\n * @slot - The region list (`<ol>` with `<li data-xywh>`), shown as written. Not used with `items`.\n * @slot image - The image. A first `<img>` or `<picture>` child is put here by itself.\n * @csspart layout - The grid holding the image and the list.\n * @csspart media - The image and its overlay.\n * @csspart overlay - The outlines over the image (`aria-hidden`).\n * @csspart region - One outline.\n * @csspart list - The heading and the list.\n * @fires highlight - The highlighted region changed by hover or focus: `detail` is `{ item, index }` (`item` null and `index` -1 when none is). Bubbles and is composed.\n * @fires select - A region's outline was clicked (focus moved to its list entry): `detail` is `{ item, index }`. Bubbles and is composed.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-image-regions', 'select', '<label>', <number>]` when an outline is clicked (the list's `label`, and the region's number from 1). Never a region's label (it may be a person's name). Nothing on hover or focus. Bubbles and is composed.\n * @cssprop --uva-color-text - Dark-mode role token: text (else `--uva-grey-darkest`).\n * @cssprop --uva-color-surface-hover - Dark-mode role token: the highlighted entry's tint (else #f1f1f1).\n * @cssprop --uva-color-link - Dark-mode role token: entry links (else `--uva-brand-blue`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: descriptions (else #4b5563).\n */\nexport class UvalibImageRegions extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n entryStyles,\n css`\n .list {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .heading {\n font-size: 1.125rem;\n font-weight: 700;\n line-height: 1.3;\n }\n .items {\n padding-inline-start: 1.75rem;\n }\n .items a {\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n .description {\n display: block;\n color: var(--uva-color-text-muted, #4b5563);\n font-size: 0.9375rem;\n }\n @media (prefers-reduced-motion: no-preference) {\n .region {\n transition: opacity 0.15s ease;\n }\n }\n `,\n ];\n\n /** The regions, when the component draws the list. Overrides the child list. */\n @property({ attribute: false }) items: ImageRegion[] | null = null;\n\n /** Image URL, when there is no `<img>` child. */\n @property({ type: String }) src = '';\n /** The image's alternative text (with `src`). */\n @property({ type: String }) alt = '';\n /** The image's width (with `src`), reserving its space. */\n @property({ type: Number }) width?: number;\n /** The image's height (with `src`). */\n @property({ type: Number }) height?: number;\n\n /**\n * The size pixel regions are measured in, when it is not the image's natural size (for\n * example a IIIF derivative of a larger original: the original's width and height).\n */\n @property({ type: Number, attribute: 'image-width' }) imageWidth?: number;\n /** The height pixel regions are measured in (with `image-width`). */\n @property({ type: Number, attribute: 'image-height' }) imageHeight?: number;\n\n /** The list's heading, and the analytics name. */\n @property({ type: String }) label = 'Regions';\n\n /** The heading's level (2 to 6). Default: one below the heading before the element. */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel?: number;\n\n /** `numbers` (default) shows each region's number on its outline; `none` hides them. */\n @property({ type: String }) numbering: 'numbers' | 'none' = 'numbers';\n\n /** Hide the outlines (the list stays). */\n @property({ type: Boolean, reflect: true, attribute: 'hide-outlines' }) hideOutlines = false;\n\n @state() private entries: Entry[] = [];\n @state() private natural: { w: number; h: number } | null = null;\n @state() private active = -1;\n @state() private inferredLevel = 2;\n\n private hover = -1;\n private focused = -1;\n private readonly headingId = `uvalib-image-regions-heading-${++nextId}`;\n private observer?: MutationObserver;\n private watchedImg: HTMLImageElement | null = null;\n /** A list slotted through a `<slot>` child (from a host element's light DOM), also observed. */\n private slottedList: Element | null = null;\n private key = '';\n /** The image's rendered size decides where badges fit. */\n private resizer?: ResizeObserver;\n private resized = 0;\n\n constructor() {\n super();\n this.addEventListener('pointerover', this.onPointerOver);\n this.addEventListener('pointerleave', this.onPointerLeave);\n this.addEventListener('focusin', this.onFocusIn);\n this.addEventListener('focusout', this.onFocusOut);\n this.addEventListener('click', this.onClick);\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (this.noStyle && root instanceof ShadowRoot && shadowStructure.styleSheet)\n root.adoptedStyleSheets = [shadowStructure.styleSheet];\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const node = this.getRootNode();\n const root = node instanceof Document || node instanceof ShadowRoot ? node : undefined;\n if (this.lightDom && this.noStyle) {\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n { root, scope: false },\n );\n } else if (!this.lightDom && !this.noStyle) {\n // The author's list items are page content: their highlight is styled in the page.\n installLightDomStyles(\n `${this.localName}::entries`,\n unsafeCSS(entryRules(`${this.localName} `)),\n { root, scope: false },\n );\n }\n const above = precedingHeadingLevel(this);\n this.inferredLevel = above === null ? 2 : Math.min(Math.max(above + 1, 2), 6);\n this.slottedList = null;\n this.sync();\n this.observe();\n }\n\n /** Watch the children, and a list slotted from outside them (it is not in this subtree). */\n private observe(): void {\n this.observer ??= new MutationObserver(() => this.sync());\n this.observer.disconnect();\n const options: MutationObserverInit = {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['data-xywh', 'data-label', 'data-id', 'href', 'start', 'src', 'srcset'],\n characterData: true,\n };\n this.observer.observe(this, options);\n if (this.slottedList) this.observer.observe(this.slottedList, options);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n this.resizer?.disconnect();\n this.resizer = undefined;\n this.watchImage(null);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('items') || changed.has('src')) this.sync();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.arrange();\n this.observeSize();\n this.place();\n this.mark();\n // Reading the image's size may set state: not from inside this update.\n queueMicrotask(() => {\n if (this.isConnected) this.watchImage(this.imageEl());\n });\n }\n\n // ---------------------------------------------------------------- sources\n\n /** The author's image element (`<img>` or `<picture>`), wherever it is now. */\n private sourceImage(): HTMLElement | null {\n if (this.src) return null;\n const kids = this.lightDom\n ? [...this.children, ...(this.imgHost?.children ?? [])]\n : [...this.children];\n const named = kids.find((k) => k.getAttribute('slot') === 'image');\n const el = named ?? kids.find((k) => k.localName === 'img' || k.localName === 'picture');\n return el instanceof HTMLElement ? el : null;\n }\n\n /**\n * The author's list (`<ol>` or `<ul>`), wherever it is now. A `<slot>` child (this element\n * inside another component's shadow root) passes on that host's list, which stays in the\n * page's light DOM (so the page's styles and listeners still apply to it).\n */\n private sourceList(): HTMLOListElement | HTMLUListElement | null {\n const kids = (\n this.lightDom ? [...this.children, ...(this.listHost?.children ?? [])] : [...this.children]\n ).flatMap((k) => (k instanceof HTMLSlotElement ? k.assignedElements({ flatten: true }) : [k]));\n const el = kids.find((k) => k.localName === 'ol' || k.localName === 'ul');\n return (el as HTMLOListElement | HTMLUListElement | undefined) ?? null;\n }\n\n private get imgHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .img-host') : null;\n }\n\n private get listHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .list-host') : null;\n }\n\n /** The `<img>` whose natural size measures pixel regions. */\n private imageEl(): HTMLImageElement | null {\n if (this.src) return this.renderRoot.querySelector<HTMLImageElement>('.media > img');\n const el = this.sourceImage();\n if (!el) return null;\n return el instanceof HTMLImageElement ? el : el.querySelector('img');\n }\n\n /** Re-read the regions (and in shadow mode put the image in its slot). */\n private sync(): void {\n const img = this.sourceImage();\n if (img && !this.lightDom && !img.hasAttribute('slot')) img.setAttribute('slot', 'image');\n const next = this.items ? this.fromItems(this.items) : this.fromList();\n const key = JSON.stringify(next.map((e) => [e.item, e.box, e.number]));\n const sameEls =\n next.length === this.entries.length && next.every((e, i) => e.el === this.entries[i]?.el);\n if (key === this.key && sameEls) return;\n this.key = key;\n this.entries = next;\n if (this.active >= next.length) this.active = -1;\n }\n\n private fromItems(items: unknown[]): Entry[] {\n const out: Entry[] = [];\n for (const raw of Array.isArray(items) ? items : []) {\n const item = toRegion(raw);\n if (!item) continue;\n const { x, y, w, h, unit = 'px' } = item;\n out.push({ item, box: { x, y, w, h, unit }, number: out.length + 1, el: null });\n }\n return out;\n }\n\n private fromList(): Entry[] {\n const list = this.sourceList();\n const outside = list && !this.contains(list) ? list : null;\n if (outside !== this.slottedList) {\n this.slottedList = outside;\n if (this.isConnected) this.observe();\n if (outside && !this.noStyle) {\n // Its entries are styled where the list is (the page), not under this tag.\n const root = outside.getRootNode();\n if (root instanceof Document || root instanceof ShadowRoot)\n installLightDomStyles(`${this.localName}::slotted-entries`, entryStyles, {\n root,\n scope: false,\n });\n }\n }\n if (!list) return [];\n const start = list.localName === 'ol' ? Number(list.getAttribute('start') ?? 1) || 1 : 1;\n const out: Entry[] = [];\n [...list.children].forEach((li, i) => {\n if (li.localName !== 'li' || !(li instanceof HTMLElement)) return;\n const box = parseXywh(li.dataset.xywh);\n const link = li.querySelector('a[href]');\n const label = normalize(li.dataset.label) || normalize(link?.textContent) || this.text(li);\n const item: ImageRegion = box ? { label, ...box } : { label, x: 0, y: 0, w: 0, h: 0 };\n const id = normalize(li.dataset.id) || li.id;\n if (id) item.id = id;\n const href = link?.getAttribute('href');\n if (href) item.href = href;\n out.push({ item, box, number: start + i, el: li });\n });\n return out;\n }\n\n /** A list item's own text, without its actions (buttons, fields) or a nested list. */\n private text(li: Element): string {\n const parts: string[] = [];\n const walk = (n: Node) => {\n if (n.nodeType === Node.TEXT_NODE) parts.push(n.textContent ?? '');\n else if (n instanceof Element && !n.matches(NOT_LABEL)) n.childNodes.forEach(walk);\n };\n li.childNodes.forEach(walk);\n return normalize(parts.join(' '));\n }\n\n // ---------------------------------------------------------------- layout\n\n /** Light DOM: move the author's image and list into the layout (the same nodes). */\n private arrange(): void {\n if (!this.lightDom) return;\n const img = this.sourceImage();\n const imgHost = this.imgHost;\n if (img && imgHost && img.parentElement !== imgHost) imgHost.append(img);\n const list = this.items ? null : this.sourceList();\n const listHost = this.listHost;\n if (list && listHost && list.parentElement !== listHost) listHost.append(list);\n }\n\n private watchImage(img: HTMLImageElement | null): void {\n if (img === this.watchedImg) {\n if (img) this.measure();\n return;\n }\n this.watchedImg?.removeEventListener('load', this.onImageLoad);\n this.watchedImg = img;\n img?.addEventListener('load', this.onImageLoad);\n this.measure();\n }\n\n private readonly onImageLoad = (): void => this.measure();\n\n private measure(): void {\n const img = this.watchedImg;\n const w = img?.complete ? img.naturalWidth : 0;\n const h = img?.complete ? img.naturalHeight : 0;\n const next = w > 0 && h > 0 ? { w, h } : null;\n if (next?.w !== this.natural?.w || next?.h !== this.natural?.h) this.natural = next;\n }\n\n /** The size pixel regions are measured in. */\n private get space(): { w: number; h: number } {\n const w = Number(this.imageWidth);\n const h = Number(this.imageHeight);\n if (w > 0 && h > 0) return { w, h };\n return this.natural ?? { w: 0, h: 0 };\n }\n\n /**\n * Position the outlines in percent of the image, so they scale with it (CSSOM, not markup).\n * A number badge sits above its outline, or inside it when there is no room above.\n */\n private place(): void {\n const { w, h } = this.space;\n const overlay = this.renderRoot.querySelector<HTMLElement>('.overlay');\n const tall = overlay?.clientHeight ?? 0;\n for (const el of this.renderRoot.querySelectorAll<HTMLElement>('.overlay > .region')) {\n const entry = this.entries[Number(el.dataset.index)];\n const box = entry?.box ? toPercent(entry.box, w, h) : null;\n el.hidden = !box;\n if (!box) continue;\n el.style.left = `${box.x}%`;\n el.style.top = `${box.y}%`;\n el.style.width = `${box.w}%`;\n el.style.height = `${box.h}%`;\n el.toggleAttribute('data-inside', (box.y / 100) * tall < 28);\n }\n }\n\n private observeSize(): void {\n const media = this.renderRoot.querySelector<HTMLElement>('.media');\n if (!media || typeof ResizeObserver === 'undefined') return;\n if (!this.resizer) {\n this.resizer = new ResizeObserver(() => {\n // The outlines scale by themselves (percent); only the badges' side may change.\n const h = media.clientHeight;\n if (h === this.resized) return;\n this.resized = h;\n this.place();\n });\n this.resizer.observe(media);\n }\n }\n\n /** The list entry of region `i`. */\n private entryEl(i: number): HTMLElement | null {\n const entry = this.entries[i];\n if (!entry) return null;\n if (entry.el) return entry.el;\n return this.renderRoot.querySelector<HTMLElement>(`.items > li[data-index=\"${i}\"]`);\n }\n\n /** Mark the entries (their padding) and the highlighted one. */\n private mark(): void {\n const list = this.items ? null : this.sourceList();\n this.entries.forEach((e, i) => {\n const el = this.entryEl(i);\n // An author's item that has left the list (given back to the page) is not marked again.\n if (!el || (e.el && e.el.parentElement !== list)) return;\n if (el.getAttribute('data-uvalib-region') !== String(e.number))\n el.setAttribute('data-uvalib-region', String(e.number));\n el.toggleAttribute('data-uvalib-active', i === this.active);\n });\n }\n\n // ---------------------------------------------------------------- interaction\n\n /** The region an event is about: its outline or its list entry (or anything inside it). */\n private indexFrom(e: Event): { i: number; outline: boolean } | null {\n for (const n of e.composedPath()) {\n if (n === this) break;\n if (!(n instanceof HTMLElement)) continue;\n if (n.classList.contains('region') && n.parentElement?.classList.contains('overlay'))\n return { i: Number(n.dataset.index), outline: true };\n const at = this.entries.findIndex((en, i) => (en.el ?? this.entryEl(i)) === n);\n if (at >= 0) return { i: at, outline: false };\n }\n return null;\n }\n\n private setActive(): void {\n const next = this.hover >= 0 ? this.hover : this.focused;\n if (next === this.active) return;\n this.active = next;\n const item = this.entries[next]?.item ?? null;\n this.dispatchEvent(\n new CustomEvent('highlight', {\n detail: { item, index: item ? next : -1 },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private readonly onPointerOver = (e: PointerEvent): void => {\n this.hover = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onPointerLeave = (): void => {\n this.hover = -1;\n this.setActive();\n };\n\n private readonly onFocusIn = (e: FocusEvent): void => {\n this.focused = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onFocusOut = (e: FocusEvent): void => {\n const to = e.relatedTarget;\n if (\n to instanceof Node &&\n (this.contains(to) || this.renderRoot.contains(to) || this.slottedList?.contains(to))\n )\n return;\n this.focused = -1;\n this.setActive();\n };\n\n private readonly onClick = (e: MouseEvent): void => {\n const hit = this.indexFrom(e);\n if (!hit?.outline) return;\n this.choose(hit.i);\n };\n\n /** An outline was clicked: focus its entry, and say so. */\n private choose(i: number): void {\n const entry = this.entries[i];\n const el = this.entryEl(i);\n if (!entry || !el) return;\n if (!el.hasAttribute('tabindex')) el.tabIndex = -1;\n el.focus();\n el.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n this.dispatchEvent(\n new CustomEvent('select', {\n detail: { item: entry.item, index: i },\n bubbles: true,\n composed: true,\n }),\n );\n const name = normalize(this.label) || DEFAULT_LABEL;\n trackEvent(this, ['uvalib-image-regions', 'select', name, entry.number]);\n }\n\n // ---------------------------------------------------------------- render\n\n private get level(): number {\n const n = Math.trunc(Number(this.headingLevel));\n return n >= 2 && n <= 6 ? n : this.inferredLevel;\n }\n\n private renderOwnList() {\n const base = this.ownerDocument.baseURI;\n return html`<ol class=\"items\" aria-labelledby=${this.headingId}>\n ${this.entries.map(({ item }, i) => {\n const href = item.href && safeHref(item.href, base) ? item.href : '';\n return html`<li data-index=${i}>\n ${href ? html`<a href=${href}>${item.label}</a>` : html`<span>${item.label}</span>`}\n ${item.description ? html`<span class=\"description\">${item.description}</span>` : nothing}\n </li>`;\n })}\n </ol>`;\n }\n\n protected override render() {\n const light = this.lightDom;\n const numbers = this.numbering !== 'none';\n const image = this.src\n ? html`<img\n part=\"image\"\n src=${this.src}\n alt=${this.alt}\n width=${this.width ?? nothing}\n height=${this.height ?? nothing}\n @load=${this.onImageLoad}\n />`\n : light\n ? html`<div class=\"img-host\"></div>`\n : html`<slot name=\"image\" @slotchange=${() => this.requestUpdate()}></slot>`;\n const list = this.items\n ? this.renderOwnList()\n : light\n ? html`<div class=\"list-host\"></div>`\n : html`<slot @slotchange=${() => this.sync()}></slot>`;\n const hasActive = this.active >= 0 && !!this.entries[this.active]?.box;\n return html`<div class=\"layout\" part=\"layout\">\n <div class=\"media\" part=\"media\">\n ${image}\n <div\n class=\"overlay ${hasActive ? 'has-active' : ''}\"\n part=\"overlay\"\n aria-hidden=\"true\"\n ?hidden=${this.hideOutlines}\n >\n ${this.entries.map((e, i) =>\n e.box\n ? html`<div\n class=\"region ${i === this.active ? 'active' : ''}\"\n part=\"region\"\n data-index=${i}\n >\n <span class=\"badge ${numbers ? '' : 'no-number'}\"\n >${numbers ? html`<span class=\"number\">${e.number}</span>` : nothing}${\n e.item.label ? html`<span class=\"name\">${e.item.label}</span>` : nothing\n }</span\n >\n </div>`\n : nothing,\n )}\n </div>\n </div>\n <div class=\"list\" part=\"list\">\n <div class=\"heading\" role=\"heading\" aria-level=${this.level} id=${this.headingId}>\n ${normalize(this.label) || DEFAULT_LABEL}\n </div>\n ${list}\n </div>\n </div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibImageRegions } from './UvalibImageRegions.js';\n\ndefine('uvalib-image-regions', UvalibImageRegions);\n"],"mappings":";;;;;;;AAqBA,IAAMsB,IAAgB,WAClBC,IAAS,GAGPC,IAAY,6EASZC,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;;;;;;IAMLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK,eAAeA,EAAK,sBACzBA,MAAS,UAAU,yCAAyC,GAC7D;IACCA,EAAK;;;;;;;;IAQLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;IACLA,EAAK;;;;;;;;;;;;;;;;IAgBLA,EAAK;;;;;IAKLA,EAAK;;;;IAILA,EAAK;IACLA,EAAK,sCAAsCA,EAAK;IAChDA,EAAK;IACLA,EAAK;IACLA,EAAK;;MAEHA,EAAK;MACLA,EAAK;MACLA,EAAK;MACLA,EAAK;;IAEPA,EAAK,YAAYA,EAAK;GAEpBC,IAAkB3B,EAAUyB,EAAgB,OAAO,CAAC,GAOpDG,KAAc,MAAc;IAC9BC,EAAE;;;;;;IAMFA,EAAE;;;;;IAKFA,EAAE;;;;IAIFA,EAAE;;MAEAA,EAAE;;GAGFC,IAAc9B,EAAU4B,EAAW,EAAE,CAAC,GAqC/BG,IAAb,cAAwClB,EAAc;;EACpC,KAAA,SAAA;GACdK;GACAS;GACAG;GACA,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BL;;CAmDA,cAAc;EAMZ,AALA,MAAM,GAjDsD,KAAA,QAAA,MAG5B,KAAA,MAAA,IAEA,KAAA,MAAA,IAeE,KAAA,QAAA,WAMwB,KAAA,YAAA,WAG2B,KAAA,eAAA,IAEnD,KAAA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