@uvalib/web-components 1.2.0 → 1.3.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 +87 -0
- package/README.md +808 -46
- package/dist/analytics.d.ts +10 -0
- package/dist/analytics.js +9 -0
- package/dist/analytics.js.map +1 -0
- package/dist/base/UvalibElement.js +8 -5
- package/dist/base/UvalibElement.js.map +1 -1
- package/dist/base/analytics-state.d.ts +7 -0
- package/dist/base/analytics-state.js.map +1 -1
- package/dist/base/light-dom-styles.d.ts +13 -0
- package/dist/base/light-dom-styles.js +26 -0
- package/dist/base/light-dom-styles.js.map +1 -1
- package/dist/base/search-tracker.d.ts +57 -0
- package/dist/base/search-tracker.js +51 -0
- package/dist/base/search-tracker.js.map +1 -0
- package/dist/base.css +286 -14
- package/dist/base.d.ts +2 -0
- package/dist/base.js +1 -0
- package/dist/base.js.map +1 -1
- package/dist/components/site-analytics/SiteAnalytics.d.ts +20 -1
- package/dist/components/site-analytics/SiteAnalytics.js +93 -12
- package/dist/components/site-analytics/SiteAnalytics.js.map +1 -1
- package/dist/components/site-page/SitePage.d.ts +23 -0
- package/dist/components/site-page/SitePage.js +77 -0
- package/dist/components/site-page/SitePage.js.map +1 -1
- package/dist/components/uvalib-back-to-top/UvalibBackToTop.d.ts +58 -0
- package/dist/components/uvalib-back-to-top/UvalibBackToTop.js +250 -0
- package/dist/components/uvalib-back-to-top/UvalibBackToTop.js.map +1 -0
- package/dist/components/uvalib-back-to-top/uvalib-back-to-top.d.ts +1 -0
- package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js +4 -0
- package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js.map +1 -0
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.d.ts +14 -0
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js +56 -4
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js.map +1 -1
- package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +25 -3
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js +80 -10
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -1
- package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +212 -0
- package/dist/components/uvalib-combobox/UvalibCombobox.js +1088 -0
- package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -0
- package/dist/components/uvalib-combobox/uvalib-combobox.d.ts +1 -0
- package/dist/components/uvalib-combobox/uvalib-combobox.js +4 -0
- package/dist/components/uvalib-combobox/uvalib-combobox.js.map +1 -0
- package/dist/components/uvalib-contents/UvalibContents.d.ts +53 -0
- package/dist/components/uvalib-contents/UvalibContents.js +202 -3
- package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.d.ts +56 -17
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +285 -81
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -1
- package/dist/components/uvalib-date-range/UvalibDateRange.d.ts +6 -0
- package/dist/components/uvalib-date-range/UvalibDateRange.js +23 -0
- package/dist/components/uvalib-date-range/UvalibDateRange.js.map +1 -1
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +113 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +589 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -0
- package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.d.ts +1 -0
- package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js +4 -0
- package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js.map +1 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.d.ts +130 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js +658 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -0
- package/dist/components/uvalib-image-regions/regions.d.ts +57 -0
- package/dist/components/uvalib-image-regions/regions.js +117 -0
- package/dist/components/uvalib-image-regions/regions.js.map +1 -0
- package/dist/components/uvalib-image-regions/uvalib-image-regions.d.ts +1 -0
- package/dist/components/uvalib-image-regions/uvalib-image-regions.js +4 -0
- package/dist/components/uvalib-image-regions/uvalib-image-regions.js.map +1 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +40 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +144 -16
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-map/UvalibMap.d.ts +182 -0
- package/dist/components/uvalib-map/UvalibMap.js +1001 -0
- package/dist/components/uvalib-map/UvalibMap.js.map +1 -0
- package/dist/components/uvalib-map/uvalib-map.d.ts +1 -0
- package/dist/components/uvalib-map/uvalib-map.js +4 -0
- package/dist/components/uvalib-map/uvalib-map.js.map +1 -0
- package/dist/components/uvalib-metadata/UvalibMetadata.d.ts +39 -2
- package/dist/components/uvalib-metadata/UvalibMetadata.js +214 -8
- package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
- package/dist/components/uvalib-pager/UvalibPager.d.ts +22 -3
- package/dist/components/uvalib-pager/UvalibPager.js +42 -4
- package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
- package/dist/custom-elements.json +9253 -3253
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/pagefind.css +4 -0
- package/dist/styles/base.js +119 -0
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +5 -0
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.js +6 -0
- package/dist/styles/controls.js.map +1 -1
- package/dist/styles/hidden.d.ts +2 -0
- package/dist/styles/hidden.js +51 -0
- package/dist/styles/hidden.js.map +1 -0
- package/dist/styles/message.d.ts +1 -0
- package/dist/styles/message.js +82 -0
- package/dist/styles/message.js.map +1 -0
- package/dist/styles/pagefind.js +4 -0
- package/dist/styles/pagefind.js.map +1 -1
- package/dist/styles/result-list.d.ts +1 -0
- package/dist/styles/result-list.js +111 -0
- package/dist/styles/result-list.js.map +1 -0
- package/dist/styles/results.js +0 -15
- package/dist/styles/results.js.map +1 -1
- package/dist/testing/index.d.ts +110 -0
- package/dist/testing/index.js +100 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/lighthouse-rules.d.ts +10 -0
- package/dist/testing/lighthouse-rules.js +44 -0
- package/dist/testing/lighthouse-rules.js.map +1 -0
- package/dist/tokens.css +5 -0
- package/dist-cdn/analytics.js +32 -0
- package/dist-cdn/analytics.js.map +1 -0
- package/dist-cdn/base.css +286 -14
- package/dist-cdn/bento-box.js +3 -3
- package/dist-cdn/chunks/{SiteAnalytics-Cm-FyhYS.js → SiteAnalytics-B9gu5aGO.js} +59 -30
- package/dist-cdn/chunks/SiteAnalytics-B9gu5aGO.js.map +1 -0
- package/dist-cdn/chunks/{UvalibElement-BnI-eRRR.js → UvalibElement-pGONDAwB.js} +108 -101
- package/dist-cdn/chunks/UvalibElement-pGONDAwB.js.map +1 -0
- package/dist-cdn/chunks/{accessible-GqhVn5_H.js → accessible-DJv7YOtS.js} +2 -2
- package/dist-cdn/chunks/{accessible-GqhVn5_H.js.map → accessible-DJv7YOtS.js.map} +1 -1
- package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js.map +1 -1
- package/dist-cdn/chunks/{base-p5pk0vb2.js → base-BI8h0Gf3.js} +121 -2
- package/dist-cdn/chunks/base-BI8h0Gf3.js.map +1 -0
- package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js → library-weekly-hours-CrV3TlP5.js} +3 -3
- package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js.map → library-weekly-hours-CrV3TlP5.js.map} +1 -1
- package/dist-cdn/chunks/regions-B8ExwUGP.js +86 -0
- package/dist-cdn/chunks/regions-B8ExwUGP.js.map +1 -0
- package/dist-cdn/chunks/{repeat-CIFUYkyh.js → repeat-m5Zd_QeP.js} +2 -2
- package/dist-cdn/chunks/{repeat-CIFUYkyh.js.map → repeat-m5Zd_QeP.js.map} +1 -1
- package/dist-cdn/chunks/{site-header-BlOYvQg1.js → site-header-DYRMpdBj.js} +9 -4
- package/dist-cdn/chunks/{site-header-BlOYvQg1.js.map → site-header-DYRMpdBj.js.map} +1 -1
- package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js → site-main-nav-DURrQMal.js} +3 -3
- package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js.map → site-main-nav-DURrQMal.js.map} +1 -1
- package/dist-cdn/chunks/{static-html-1mTAG6nS.js → static-html-C1rhtCHu.js} +2 -2
- package/dist-cdn/chunks/{static-html-1mTAG6nS.js.map → static-html-C1rhtCHu.js.map} +1 -1
- package/dist-cdn/custom-elements.json +9253 -3253
- package/dist-cdn/events-section.js +3 -3
- package/dist-cdn/library-hours-setup.js +2 -2
- package/dist-cdn/library-weekly-hours.js +1 -1
- package/dist-cdn/manifest.json +10 -2
- package/dist-cdn/pagefind.css +4 -0
- package/dist-cdn/site-alerts.js +4 -4
- package/dist-cdn/site-analytics.js +2 -2
- package/dist-cdn/site-footer.js +2 -2
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-hours-section.js +4 -4
- package/dist-cdn/site-main-nav.js +1 -1
- package/dist-cdn/site-page.js +56 -11
- package/dist-cdn/site-page.js.map +1 -1
- package/dist-cdn/site-style.js +2 -2
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +98 -13
- package/dist-cdn/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +300 -13
- package/dist-cdn/skills/uvalib-web-components/reference/snippets.md +1 -1
- package/dist-cdn/tokens.css +5 -0
- package/dist-cdn/uvalib-analytics.js +2 -2
- package/dist-cdn/uvalib-back-to-top.js +156 -0
- package/dist-cdn/uvalib-back-to-top.js.map +1 -0
- package/dist-cdn/uvalib-breadcrumbs.js +31 -11
- package/dist-cdn/uvalib-breadcrumbs.js.map +1 -1
- package/dist-cdn/uvalib-card-grid.js +1 -1
- package/dist-cdn/uvalib-card.js +3 -3
- package/dist-cdn/uvalib-chip-group.js +53 -14
- package/dist-cdn/uvalib-chip-group.js.map +1 -1
- package/dist-cdn/uvalib-combobox.js +667 -0
- package/dist-cdn/uvalib-combobox.js.map +1 -0
- package/dist-cdn/uvalib-contents.js +100 -22
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-date-histogram.js +237 -127
- package/dist-cdn/uvalib-date-histogram.js.map +1 -1
- package/dist-cdn/uvalib-date-range.js +14 -2
- package/dist-cdn/uvalib-date-range.js.map +1 -1
- package/dist-cdn/uvalib-filter-drawer.js +355 -0
- package/dist-cdn/uvalib-filter-drawer.js.map +1 -0
- package/dist-cdn/uvalib-filter.js +3 -3
- package/dist-cdn/uvalib-image-regions.js +447 -0
- package/dist-cdn/uvalib-image-regions.js.map +1 -0
- package/dist-cdn/uvalib-lightbox.js +144 -55
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-map.js +471 -0
- package/dist-cdn/uvalib-map.js.map +1 -0
- package/dist-cdn/uvalib-metadata.js +150 -24
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pager.js +29 -17
- package/dist-cdn/uvalib-pager.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +2 -2
- package/dist-cdn/uvalib-results-count.js +2 -2
- package/dist-cdn/uvalib-tabs.js +2 -2
- package/dist-cdn/uvalib-tag-list.js +2 -2
- package/package.json +43 -1
- package/skills/uvalib-web-components/SKILL.md +98 -13
- package/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
- package/skills/uvalib-web-components/reference/components.md +300 -13
- package/skills/uvalib-web-components/reference/snippets.md +1 -1
- package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js.map +0 -1
- package/dist-cdn/chunks/UvalibElement-BnI-eRRR.js.map +0 -1
- package/dist-cdn/chunks/base-p5pk0vb2.js.map +0 -1
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { css, html, nothing, unsafeCSS } from 'lit';
|
|
8
|
+
import { property, state } from 'lit/decorators.js';
|
|
9
|
+
import { trackEvent } from '../../base/analytics.js';
|
|
10
|
+
import { precedingHeadingLevel } from '../../base/heading-level.js';
|
|
11
|
+
import { installLightDomStyles } from '../../base/light-dom-styles.js';
|
|
12
|
+
import { normalize, safeHref } from '../../base/source-children.js';
|
|
13
|
+
import { UvalibElement } from '../../base/UvalibElement.js';
|
|
14
|
+
import { accessible } from '../../styles/accessible.js';
|
|
15
|
+
import { parseXywh, toPercent, toRegion } from './regions.js';
|
|
16
|
+
const DEFAULT_LABEL = 'Regions';
|
|
17
|
+
let nextId = 0;
|
|
18
|
+
/** Controls inside a list item, which are actions and not part of the region's name. */
|
|
19
|
+
const NOT_LABEL = 'button, input, select, textarea, ol, ul, [hidden], [aria-hidden="true"]';
|
|
20
|
+
/**
|
|
21
|
+
* Kept with `no-style`: the layout (the image at its own width, at most the element's, and
|
|
22
|
+
* the list beside it when at least 14rem is left, else under it: the same wrapping flex row
|
|
23
|
+
* base.css gives the children before the element upgrades, so nothing moves), the overlay
|
|
24
|
+
* over the image, and the double outlines and number badges (without them the regions are
|
|
25
|
+
* not visible). `host` is `:host` (shadow) or the tag (light DOM).
|
|
26
|
+
*/
|
|
27
|
+
const structuralRules = (host) => `
|
|
28
|
+
${host} { display: block; }
|
|
29
|
+
${host} .layout {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-wrap: wrap;
|
|
32
|
+
gap: 1rem;
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
}
|
|
35
|
+
${host} .media {
|
|
36
|
+
position: relative;
|
|
37
|
+
flex: 0 1 auto;
|
|
38
|
+
width: fit-content;
|
|
39
|
+
min-width: 0;
|
|
40
|
+
max-width: 100%;
|
|
41
|
+
margin: 0;
|
|
42
|
+
}
|
|
43
|
+
${host} .list { flex: 1 1 14rem; min-width: 0; }
|
|
44
|
+
${host} .media img, ${host} .img-host > picture${host === ':host' ? ', ::slotted(img), ::slotted(picture)' : ''} { display: block; max-width: 100%; height: auto; }
|
|
45
|
+
${host} .overlay {
|
|
46
|
+
position: absolute;
|
|
47
|
+
inset: 0;
|
|
48
|
+
overflow: clip;
|
|
49
|
+
overflow-clip-margin: 0.5rem;
|
|
50
|
+
pointer-events: none;
|
|
51
|
+
forced-color-adjust: none;
|
|
52
|
+
}
|
|
53
|
+
${host} .region {
|
|
54
|
+
position: absolute;
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
border: 2px solid #fff;
|
|
57
|
+
outline: 2px solid #000;
|
|
58
|
+
pointer-events: auto;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
${host} .region.active { z-index: 1; border-width: 4px; outline-width: 4px; }
|
|
62
|
+
${host} .overlay.has-active .region:not(.active) { opacity: 0.6; }
|
|
63
|
+
${host} .badge {
|
|
64
|
+
position: absolute;
|
|
65
|
+
inset-block-start: 0;
|
|
66
|
+
inset-inline-start: 0;
|
|
67
|
+
display: flex;
|
|
68
|
+
gap: 0.375em;
|
|
69
|
+
max-width: 16rem;
|
|
70
|
+
padding: 0.0625rem 0.375rem;
|
|
71
|
+
background: #000;
|
|
72
|
+
color: #fff;
|
|
73
|
+
font-size: 0.875rem;
|
|
74
|
+
font-weight: 700;
|
|
75
|
+
line-height: 1.25;
|
|
76
|
+
white-space: nowrap;
|
|
77
|
+
outline: 1px solid #fff;
|
|
78
|
+
}
|
|
79
|
+
${host} .region:not([data-inside]) .badge {
|
|
80
|
+
inset-block-start: auto;
|
|
81
|
+
inset-block-end: calc(100% + 4px);
|
|
82
|
+
inset-inline-start: -4px;
|
|
83
|
+
}
|
|
84
|
+
${host} .region.active:not([data-inside]) .badge {
|
|
85
|
+
inset-block-end: calc(100% + 8px);
|
|
86
|
+
inset-inline-start: -8px;
|
|
87
|
+
}
|
|
88
|
+
${host} .badge .name { overflow: hidden; text-overflow: ellipsis; }
|
|
89
|
+
${host} .region:not(.active) .badge .name, ${host} .badge:empty { display: none; }
|
|
90
|
+
${host} .region:not(.active) .badge.no-number { display: none; }
|
|
91
|
+
${host} .heading { margin: 0 0 0.5rem; }
|
|
92
|
+
${host} .items { margin: 0; }
|
|
93
|
+
@media (forced-colors: active) {
|
|
94
|
+
${host} .region { border-color: Canvas; outline-color: CanvasText; }
|
|
95
|
+
${host} .region.active { outline-color: Highlight; }
|
|
96
|
+
${host} .badge { background: CanvasText; color: Canvas; outline-color: Canvas; }
|
|
97
|
+
${host} .region.active .badge { background: Highlight; color: HighlightText; }
|
|
98
|
+
}
|
|
99
|
+
${host}[hidden], ${host} [hidden] { display: none !important; }
|
|
100
|
+
`;
|
|
101
|
+
const shadowStructure = unsafeCSS(structuralRules(':host'));
|
|
102
|
+
/**
|
|
103
|
+
* A region's list entry: room for the highlight bar, and the bar (with a tint) while its
|
|
104
|
+
* region is highlighted, so it is shown by more than colour. Shadow mode also installs
|
|
105
|
+
* these in the page, scoped to the tag, for the author's own list items.
|
|
106
|
+
*/
|
|
107
|
+
const entryRules = (p) => `
|
|
108
|
+
${p}[data-uvalib-region] {
|
|
109
|
+
box-sizing: border-box;
|
|
110
|
+
padding-block: 0.5rem;
|
|
111
|
+
padding-inline: calc(0.5rem + 0.375rem) 0.5rem;
|
|
112
|
+
overflow-wrap: anywhere;
|
|
113
|
+
}
|
|
114
|
+
${p}[data-uvalib-region][data-uvalib-active] {
|
|
115
|
+
padding-inline-start: 0.5rem;
|
|
116
|
+
border-inline-start: 0.375rem solid currentColor;
|
|
117
|
+
background: var(--uva-color-surface-hover, #f1f1f1);
|
|
118
|
+
}
|
|
119
|
+
${p}[data-uvalib-region]:focus-visible {
|
|
120
|
+
outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));
|
|
121
|
+
outline-offset: 2px;
|
|
122
|
+
}
|
|
123
|
+
${p}[data-uvalib-region][tabindex='-1']:focus:not(:focus-visible) { outline: none; }
|
|
124
|
+
@media (forced-colors: active) {
|
|
125
|
+
${p}[data-uvalib-region][data-uvalib-active] { border-inline-start-color: Highlight; }
|
|
126
|
+
}
|
|
127
|
+
`;
|
|
128
|
+
const entryStyles = unsafeCSS(entryRules(''));
|
|
129
|
+
/**
|
|
130
|
+
* An image with numbered region outlines (people, objects, inscriptions) and a list of the
|
|
131
|
+
* same regions beside it (under it on a narrow screen). The list is the way in: the
|
|
132
|
+
* outlines are a visual aid, hidden from assistive technology and not in the tab order, so
|
|
133
|
+
* no region is a second tab stop. Hovering or focusing a list entry (or anything in it)
|
|
134
|
+
* highlights its region with a thicker double outline and its label, and dims the others;
|
|
135
|
+
* hovering a region highlights its entry. Clicking a region moves focus to its entry.
|
|
136
|
+
*
|
|
137
|
+
* The image: an `<img>` (or `<picture>`) child, which keeps its `alt`, or `src` and `alt`.
|
|
138
|
+
* Give it `width` and `height` so its space is reserved before it loads.
|
|
139
|
+
*
|
|
140
|
+
* The regions: an `<ol>` child whose `<li>` items carry `data-xywh` (IIIF / Media Fragments:
|
|
141
|
+
* `percent:10,20,30,40`, or pixels `160,120,320,240` of the image's natural size). The list
|
|
142
|
+
* is shown as written, so it works before the component loads or without JavaScript, and
|
|
143
|
+
* any links and buttons in it stay the page's own (their events are the page's). Or set
|
|
144
|
+
* the `items` property, and the component draws the list. Region numbers are the list's
|
|
145
|
+
* numbers, from 1 (or the `<ol>`'s `start`).
|
|
146
|
+
*
|
|
147
|
+
* @tagname uvalib-image-regions
|
|
148
|
+
* @slot - The region list (`<ol>` with `<li data-xywh>`), shown as written. Not used with `items`.
|
|
149
|
+
* @slot image - The image. A first `<img>` or `<picture>` child is put here by itself.
|
|
150
|
+
* @csspart layout - The grid holding the image and the list.
|
|
151
|
+
* @csspart media - The image and its overlay.
|
|
152
|
+
* @csspart overlay - The outlines over the image (`aria-hidden`).
|
|
153
|
+
* @csspart region - One outline.
|
|
154
|
+
* @csspart list - The heading and the list.
|
|
155
|
+
* @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.
|
|
156
|
+
* @fires select - A region's outline was clicked (focus moved to its list entry): `detail` is `{ item, index }`. Bubbles and is composed.
|
|
157
|
+
* @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.
|
|
158
|
+
* @cssprop --uva-color-text - Dark-mode role token: text (else `--uva-grey-darkest`).
|
|
159
|
+
* @cssprop --uva-color-surface-hover - Dark-mode role token: the highlighted entry's tint (else #f1f1f1).
|
|
160
|
+
* @cssprop --uva-color-link - Dark-mode role token: entry links (else `--uva-brand-blue`).
|
|
161
|
+
* @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).
|
|
162
|
+
* @cssprop --uva-color-text-muted - Dark-mode role token: descriptions (else #4b5563).
|
|
163
|
+
*/
|
|
164
|
+
export class UvalibImageRegions extends UvalibElement {
|
|
165
|
+
static { this.styles = [
|
|
166
|
+
accessible,
|
|
167
|
+
shadowStructure,
|
|
168
|
+
entryStyles,
|
|
169
|
+
css `
|
|
170
|
+
.list {
|
|
171
|
+
color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));
|
|
172
|
+
}
|
|
173
|
+
.heading {
|
|
174
|
+
font-size: 1.125rem;
|
|
175
|
+
font-weight: 700;
|
|
176
|
+
line-height: 1.3;
|
|
177
|
+
}
|
|
178
|
+
.items {
|
|
179
|
+
padding-inline-start: 1.75rem;
|
|
180
|
+
}
|
|
181
|
+
.items a {
|
|
182
|
+
color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));
|
|
183
|
+
}
|
|
184
|
+
.description {
|
|
185
|
+
display: block;
|
|
186
|
+
color: var(--uva-color-text-muted, #4b5563);
|
|
187
|
+
font-size: 0.9375rem;
|
|
188
|
+
}
|
|
189
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
190
|
+
.region {
|
|
191
|
+
transition: opacity 0.15s ease;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
`,
|
|
195
|
+
]; }
|
|
196
|
+
constructor() {
|
|
197
|
+
super();
|
|
198
|
+
/** The regions, when the component draws the list. Overrides the child list. */
|
|
199
|
+
this.items = null;
|
|
200
|
+
/** Image URL, when there is no `<img>` child. */
|
|
201
|
+
this.src = '';
|
|
202
|
+
/** The image's alternative text (with `src`). */
|
|
203
|
+
this.alt = '';
|
|
204
|
+
/** The list's heading, and the analytics name. */
|
|
205
|
+
this.label = 'Regions';
|
|
206
|
+
/** `numbers` (default) shows each region's number on its outline; `none` hides them. */
|
|
207
|
+
this.numbering = 'numbers';
|
|
208
|
+
/** Hide the outlines (the list stays). */
|
|
209
|
+
this.hideOutlines = false;
|
|
210
|
+
this.entries = [];
|
|
211
|
+
this.natural = null;
|
|
212
|
+
this.active = -1;
|
|
213
|
+
this.inferredLevel = 2;
|
|
214
|
+
this.hover = -1;
|
|
215
|
+
this.focused = -1;
|
|
216
|
+
this.headingId = `uvalib-image-regions-heading-${++nextId}`;
|
|
217
|
+
this.watchedImg = null;
|
|
218
|
+
this.key = '';
|
|
219
|
+
this.resized = 0;
|
|
220
|
+
this.onImageLoad = () => this.measure();
|
|
221
|
+
this.onPointerOver = (e) => {
|
|
222
|
+
this.hover = this.indexFrom(e)?.i ?? -1;
|
|
223
|
+
this.setActive();
|
|
224
|
+
};
|
|
225
|
+
this.onPointerLeave = () => {
|
|
226
|
+
this.hover = -1;
|
|
227
|
+
this.setActive();
|
|
228
|
+
};
|
|
229
|
+
this.onFocusIn = (e) => {
|
|
230
|
+
this.focused = this.indexFrom(e)?.i ?? -1;
|
|
231
|
+
this.setActive();
|
|
232
|
+
};
|
|
233
|
+
this.onFocusOut = (e) => {
|
|
234
|
+
const to = e.relatedTarget;
|
|
235
|
+
if (to instanceof Node && (this.contains(to) || this.renderRoot.contains(to)))
|
|
236
|
+
return;
|
|
237
|
+
this.focused = -1;
|
|
238
|
+
this.setActive();
|
|
239
|
+
};
|
|
240
|
+
this.onClick = (e) => {
|
|
241
|
+
const hit = this.indexFrom(e);
|
|
242
|
+
if (!hit?.outline)
|
|
243
|
+
return;
|
|
244
|
+
this.choose(hit.i);
|
|
245
|
+
};
|
|
246
|
+
this.addEventListener('pointerover', this.onPointerOver);
|
|
247
|
+
this.addEventListener('pointerleave', this.onPointerLeave);
|
|
248
|
+
this.addEventListener('focusin', this.onFocusIn);
|
|
249
|
+
this.addEventListener('focusout', this.onFocusOut);
|
|
250
|
+
this.addEventListener('click', this.onClick);
|
|
251
|
+
}
|
|
252
|
+
createRenderRoot() {
|
|
253
|
+
const root = super.createRenderRoot();
|
|
254
|
+
if (this.noStyle && root instanceof ShadowRoot && shadowStructure.styleSheet)
|
|
255
|
+
root.adoptedStyleSheets = [shadowStructure.styleSheet];
|
|
256
|
+
return root;
|
|
257
|
+
}
|
|
258
|
+
connectedCallback() {
|
|
259
|
+
super.connectedCallback();
|
|
260
|
+
const node = this.getRootNode();
|
|
261
|
+
const root = node instanceof Document || node instanceof ShadowRoot ? node : undefined;
|
|
262
|
+
if (this.lightDom && this.noStyle) {
|
|
263
|
+
installLightDomStyles(`${this.localName}::structure`, unsafeCSS(structuralRules(this.localName)), { root, scope: false });
|
|
264
|
+
}
|
|
265
|
+
else if (!this.lightDom && !this.noStyle) {
|
|
266
|
+
// The author's list items are page content: their highlight is styled in the page.
|
|
267
|
+
installLightDomStyles(`${this.localName}::entries`, unsafeCSS(entryRules(`${this.localName} `)), { root, scope: false });
|
|
268
|
+
}
|
|
269
|
+
const above = precedingHeadingLevel(this);
|
|
270
|
+
this.inferredLevel = above === null ? 2 : Math.min(Math.max(above + 1, 2), 6);
|
|
271
|
+
this.sync();
|
|
272
|
+
this.observer ??= new MutationObserver(() => this.sync());
|
|
273
|
+
this.observer.observe(this, {
|
|
274
|
+
childList: true,
|
|
275
|
+
subtree: true,
|
|
276
|
+
attributes: true,
|
|
277
|
+
attributeFilter: ['data-xywh', 'data-label', 'data-id', 'href', 'start', 'src', 'srcset'],
|
|
278
|
+
characterData: true,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
disconnectedCallback() {
|
|
282
|
+
super.disconnectedCallback();
|
|
283
|
+
this.observer?.disconnect();
|
|
284
|
+
this.resizer?.disconnect();
|
|
285
|
+
this.resizer = undefined;
|
|
286
|
+
this.watchImage(null);
|
|
287
|
+
}
|
|
288
|
+
willUpdate(changed) {
|
|
289
|
+
if (changed.has('items') || changed.has('src'))
|
|
290
|
+
this.sync();
|
|
291
|
+
}
|
|
292
|
+
updated(changed) {
|
|
293
|
+
super.updated(changed);
|
|
294
|
+
this.arrange();
|
|
295
|
+
this.observeSize();
|
|
296
|
+
this.place();
|
|
297
|
+
this.mark();
|
|
298
|
+
// Reading the image's size may set state: not from inside this update.
|
|
299
|
+
queueMicrotask(() => {
|
|
300
|
+
if (this.isConnected)
|
|
301
|
+
this.watchImage(this.imageEl());
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
// ---------------------------------------------------------------- sources
|
|
305
|
+
/** The author's image element (`<img>` or `<picture>`), wherever it is now. */
|
|
306
|
+
sourceImage() {
|
|
307
|
+
if (this.src)
|
|
308
|
+
return null;
|
|
309
|
+
const kids = this.lightDom
|
|
310
|
+
? [...this.children, ...(this.imgHost?.children ?? [])]
|
|
311
|
+
: [...this.children];
|
|
312
|
+
const named = kids.find((k) => k.getAttribute('slot') === 'image');
|
|
313
|
+
const el = named ?? kids.find((k) => k.localName === 'img' || k.localName === 'picture');
|
|
314
|
+
return el instanceof HTMLElement ? el : null;
|
|
315
|
+
}
|
|
316
|
+
/** The author's list (`<ol>` or `<ul>`), wherever it is now. */
|
|
317
|
+
sourceList() {
|
|
318
|
+
const kids = this.lightDom
|
|
319
|
+
? [...this.children, ...(this.listHost?.children ?? [])]
|
|
320
|
+
: [...this.children];
|
|
321
|
+
const el = kids.find((k) => k.localName === 'ol' || k.localName === 'ul');
|
|
322
|
+
return el ?? null;
|
|
323
|
+
}
|
|
324
|
+
get imgHost() {
|
|
325
|
+
return this.lightDom ? this.querySelector(':scope > .layout .img-host') : null;
|
|
326
|
+
}
|
|
327
|
+
get listHost() {
|
|
328
|
+
return this.lightDom ? this.querySelector(':scope > .layout .list-host') : null;
|
|
329
|
+
}
|
|
330
|
+
/** The `<img>` whose natural size measures pixel regions. */
|
|
331
|
+
imageEl() {
|
|
332
|
+
if (this.src)
|
|
333
|
+
return this.renderRoot.querySelector('.media > img');
|
|
334
|
+
const el = this.sourceImage();
|
|
335
|
+
if (!el)
|
|
336
|
+
return null;
|
|
337
|
+
return el instanceof HTMLImageElement ? el : el.querySelector('img');
|
|
338
|
+
}
|
|
339
|
+
/** Re-read the regions (and in shadow mode put the image in its slot). */
|
|
340
|
+
sync() {
|
|
341
|
+
const img = this.sourceImage();
|
|
342
|
+
if (img && !this.lightDom && !img.hasAttribute('slot'))
|
|
343
|
+
img.setAttribute('slot', 'image');
|
|
344
|
+
const next = this.items ? this.fromItems(this.items) : this.fromList();
|
|
345
|
+
const key = JSON.stringify(next.map((e) => [e.item, e.box, e.number]));
|
|
346
|
+
const sameEls = next.length === this.entries.length && next.every((e, i) => e.el === this.entries[i]?.el);
|
|
347
|
+
if (key === this.key && sameEls)
|
|
348
|
+
return;
|
|
349
|
+
this.key = key;
|
|
350
|
+
this.entries = next;
|
|
351
|
+
if (this.active >= next.length)
|
|
352
|
+
this.active = -1;
|
|
353
|
+
}
|
|
354
|
+
fromItems(items) {
|
|
355
|
+
const out = [];
|
|
356
|
+
for (const raw of Array.isArray(items) ? items : []) {
|
|
357
|
+
const item = toRegion(raw);
|
|
358
|
+
if (!item)
|
|
359
|
+
continue;
|
|
360
|
+
const { x, y, w, h, unit = 'px' } = item;
|
|
361
|
+
out.push({ item, box: { x, y, w, h, unit }, number: out.length + 1, el: null });
|
|
362
|
+
}
|
|
363
|
+
return out;
|
|
364
|
+
}
|
|
365
|
+
fromList() {
|
|
366
|
+
const list = this.sourceList();
|
|
367
|
+
if (!list)
|
|
368
|
+
return [];
|
|
369
|
+
const start = list.localName === 'ol' ? Number(list.getAttribute('start') ?? 1) || 1 : 1;
|
|
370
|
+
const out = [];
|
|
371
|
+
[...list.children].forEach((li, i) => {
|
|
372
|
+
if (li.localName !== 'li' || !(li instanceof HTMLElement))
|
|
373
|
+
return;
|
|
374
|
+
const box = parseXywh(li.dataset.xywh);
|
|
375
|
+
const link = li.querySelector('a[href]');
|
|
376
|
+
const label = normalize(li.dataset.label) || normalize(link?.textContent) || this.text(li);
|
|
377
|
+
const item = box ? { label, ...box } : { label, x: 0, y: 0, w: 0, h: 0 };
|
|
378
|
+
const id = normalize(li.dataset.id) || li.id;
|
|
379
|
+
if (id)
|
|
380
|
+
item.id = id;
|
|
381
|
+
const href = link?.getAttribute('href');
|
|
382
|
+
if (href)
|
|
383
|
+
item.href = href;
|
|
384
|
+
out.push({ item, box, number: start + i, el: li });
|
|
385
|
+
});
|
|
386
|
+
return out;
|
|
387
|
+
}
|
|
388
|
+
/** A list item's own text, without its actions (buttons, fields) or a nested list. */
|
|
389
|
+
text(li) {
|
|
390
|
+
const parts = [];
|
|
391
|
+
const walk = (n) => {
|
|
392
|
+
if (n.nodeType === Node.TEXT_NODE)
|
|
393
|
+
parts.push(n.textContent ?? '');
|
|
394
|
+
else if (n instanceof Element && !n.matches(NOT_LABEL))
|
|
395
|
+
n.childNodes.forEach(walk);
|
|
396
|
+
};
|
|
397
|
+
li.childNodes.forEach(walk);
|
|
398
|
+
return normalize(parts.join(' '));
|
|
399
|
+
}
|
|
400
|
+
// ---------------------------------------------------------------- layout
|
|
401
|
+
/** Light DOM: move the author's image and list into the layout (the same nodes). */
|
|
402
|
+
arrange() {
|
|
403
|
+
if (!this.lightDom)
|
|
404
|
+
return;
|
|
405
|
+
const img = this.sourceImage();
|
|
406
|
+
const imgHost = this.imgHost;
|
|
407
|
+
if (img && imgHost && img.parentElement !== imgHost)
|
|
408
|
+
imgHost.append(img);
|
|
409
|
+
const list = this.items ? null : this.sourceList();
|
|
410
|
+
const listHost = this.listHost;
|
|
411
|
+
if (list && listHost && list.parentElement !== listHost)
|
|
412
|
+
listHost.append(list);
|
|
413
|
+
}
|
|
414
|
+
watchImage(img) {
|
|
415
|
+
if (img === this.watchedImg) {
|
|
416
|
+
if (img)
|
|
417
|
+
this.measure();
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
this.watchedImg?.removeEventListener('load', this.onImageLoad);
|
|
421
|
+
this.watchedImg = img;
|
|
422
|
+
img?.addEventListener('load', this.onImageLoad);
|
|
423
|
+
this.measure();
|
|
424
|
+
}
|
|
425
|
+
measure() {
|
|
426
|
+
const img = this.watchedImg;
|
|
427
|
+
const w = img?.complete ? img.naturalWidth : 0;
|
|
428
|
+
const h = img?.complete ? img.naturalHeight : 0;
|
|
429
|
+
const next = w > 0 && h > 0 ? { w, h } : null;
|
|
430
|
+
if (next?.w !== this.natural?.w || next?.h !== this.natural?.h)
|
|
431
|
+
this.natural = next;
|
|
432
|
+
}
|
|
433
|
+
/** The size pixel regions are measured in. */
|
|
434
|
+
get space() {
|
|
435
|
+
const w = Number(this.imageWidth);
|
|
436
|
+
const h = Number(this.imageHeight);
|
|
437
|
+
if (w > 0 && h > 0)
|
|
438
|
+
return { w, h };
|
|
439
|
+
return this.natural ?? { w: 0, h: 0 };
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Position the outlines in percent of the image, so they scale with it (CSSOM, not markup).
|
|
443
|
+
* A number badge sits above its outline, or inside it when there is no room above.
|
|
444
|
+
*/
|
|
445
|
+
place() {
|
|
446
|
+
const { w, h } = this.space;
|
|
447
|
+
const overlay = this.renderRoot.querySelector('.overlay');
|
|
448
|
+
const tall = overlay?.clientHeight ?? 0;
|
|
449
|
+
for (const el of this.renderRoot.querySelectorAll('.overlay > .region')) {
|
|
450
|
+
const entry = this.entries[Number(el.dataset.index)];
|
|
451
|
+
const box = entry?.box ? toPercent(entry.box, w, h) : null;
|
|
452
|
+
el.hidden = !box;
|
|
453
|
+
if (!box)
|
|
454
|
+
continue;
|
|
455
|
+
el.style.left = `${box.x}%`;
|
|
456
|
+
el.style.top = `${box.y}%`;
|
|
457
|
+
el.style.width = `${box.w}%`;
|
|
458
|
+
el.style.height = `${box.h}%`;
|
|
459
|
+
el.toggleAttribute('data-inside', (box.y / 100) * tall < 28);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
observeSize() {
|
|
463
|
+
const media = this.renderRoot.querySelector('.media');
|
|
464
|
+
if (!media || typeof ResizeObserver === 'undefined')
|
|
465
|
+
return;
|
|
466
|
+
if (!this.resizer) {
|
|
467
|
+
this.resizer = new ResizeObserver(() => {
|
|
468
|
+
// The outlines scale by themselves (percent); only the badges' side may change.
|
|
469
|
+
const h = media.clientHeight;
|
|
470
|
+
if (h === this.resized)
|
|
471
|
+
return;
|
|
472
|
+
this.resized = h;
|
|
473
|
+
this.place();
|
|
474
|
+
});
|
|
475
|
+
this.resizer.observe(media);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
/** The list entry of region `i`. */
|
|
479
|
+
entryEl(i) {
|
|
480
|
+
const entry = this.entries[i];
|
|
481
|
+
if (!entry)
|
|
482
|
+
return null;
|
|
483
|
+
if (entry.el)
|
|
484
|
+
return entry.el;
|
|
485
|
+
return this.renderRoot.querySelector(`.items > li[data-index="${i}"]`);
|
|
486
|
+
}
|
|
487
|
+
/** Mark the entries (their padding) and the highlighted one. */
|
|
488
|
+
mark() {
|
|
489
|
+
this.entries.forEach((e, i) => {
|
|
490
|
+
const el = this.entryEl(i);
|
|
491
|
+
if (!el)
|
|
492
|
+
return;
|
|
493
|
+
if (el.getAttribute('data-uvalib-region') !== String(e.number))
|
|
494
|
+
el.setAttribute('data-uvalib-region', String(e.number));
|
|
495
|
+
el.toggleAttribute('data-uvalib-active', i === this.active);
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
// ---------------------------------------------------------------- interaction
|
|
499
|
+
/** The region an event is about: its outline or its list entry (or anything inside it). */
|
|
500
|
+
indexFrom(e) {
|
|
501
|
+
for (const n of e.composedPath()) {
|
|
502
|
+
if (n === this)
|
|
503
|
+
break;
|
|
504
|
+
if (!(n instanceof HTMLElement))
|
|
505
|
+
continue;
|
|
506
|
+
if (n.classList.contains('region') && n.parentElement?.classList.contains('overlay'))
|
|
507
|
+
return { i: Number(n.dataset.index), outline: true };
|
|
508
|
+
const at = this.entries.findIndex((en, i) => (en.el ?? this.entryEl(i)) === n);
|
|
509
|
+
if (at >= 0)
|
|
510
|
+
return { i: at, outline: false };
|
|
511
|
+
}
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
setActive() {
|
|
515
|
+
const next = this.hover >= 0 ? this.hover : this.focused;
|
|
516
|
+
if (next === this.active)
|
|
517
|
+
return;
|
|
518
|
+
this.active = next;
|
|
519
|
+
const item = this.entries[next]?.item ?? null;
|
|
520
|
+
this.dispatchEvent(new CustomEvent('highlight', {
|
|
521
|
+
detail: { item, index: item ? next : -1 },
|
|
522
|
+
bubbles: true,
|
|
523
|
+
composed: true,
|
|
524
|
+
}));
|
|
525
|
+
}
|
|
526
|
+
/** An outline was clicked: focus its entry, and say so. */
|
|
527
|
+
choose(i) {
|
|
528
|
+
const entry = this.entries[i];
|
|
529
|
+
const el = this.entryEl(i);
|
|
530
|
+
if (!entry || !el)
|
|
531
|
+
return;
|
|
532
|
+
if (!el.hasAttribute('tabindex'))
|
|
533
|
+
el.tabIndex = -1;
|
|
534
|
+
el.focus();
|
|
535
|
+
el.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
536
|
+
this.dispatchEvent(new CustomEvent('select', {
|
|
537
|
+
detail: { item: entry.item, index: i },
|
|
538
|
+
bubbles: true,
|
|
539
|
+
composed: true,
|
|
540
|
+
}));
|
|
541
|
+
const name = normalize(this.label) || DEFAULT_LABEL;
|
|
542
|
+
trackEvent(this, ['uvalib-image-regions', 'select', name, entry.number]);
|
|
543
|
+
}
|
|
544
|
+
// ---------------------------------------------------------------- render
|
|
545
|
+
get level() {
|
|
546
|
+
const n = Math.trunc(Number(this.headingLevel));
|
|
547
|
+
return n >= 2 && n <= 6 ? n : this.inferredLevel;
|
|
548
|
+
}
|
|
549
|
+
renderOwnList() {
|
|
550
|
+
const base = this.ownerDocument.baseURI;
|
|
551
|
+
return html `<ol class="items" aria-labelledby=${this.headingId}>
|
|
552
|
+
${this.entries.map(({ item }, i) => {
|
|
553
|
+
const href = item.href && safeHref(item.href, base) ? item.href : '';
|
|
554
|
+
return html `<li data-index=${i}>
|
|
555
|
+
${href ? html `<a href=${href}>${item.label}</a>` : html `<span>${item.label}</span>`}
|
|
556
|
+
${item.description ? html `<span class="description">${item.description}</span>` : nothing}
|
|
557
|
+
</li>`;
|
|
558
|
+
})}
|
|
559
|
+
</ol>`;
|
|
560
|
+
}
|
|
561
|
+
render() {
|
|
562
|
+
const light = this.lightDom;
|
|
563
|
+
const numbers = this.numbering !== 'none';
|
|
564
|
+
const image = this.src
|
|
565
|
+
? html `<img
|
|
566
|
+
part="image"
|
|
567
|
+
src=${this.src}
|
|
568
|
+
alt=${this.alt}
|
|
569
|
+
width=${this.width ?? nothing}
|
|
570
|
+
height=${this.height ?? nothing}
|
|
571
|
+
@load=${this.onImageLoad}
|
|
572
|
+
/>`
|
|
573
|
+
: light
|
|
574
|
+
? html `<div class="img-host"></div>`
|
|
575
|
+
: html `<slot name="image" @slotchange=${() => this.requestUpdate()}></slot>`;
|
|
576
|
+
const list = this.items
|
|
577
|
+
? this.renderOwnList()
|
|
578
|
+
: light
|
|
579
|
+
? html `<div class="list-host"></div>`
|
|
580
|
+
: html `<slot @slotchange=${() => this.sync()}></slot>`;
|
|
581
|
+
const hasActive = this.active >= 0 && !!this.entries[this.active]?.box;
|
|
582
|
+
return html `<div class="layout" part="layout">
|
|
583
|
+
<div class="media" part="media">
|
|
584
|
+
${image}
|
|
585
|
+
<div
|
|
586
|
+
class="overlay ${hasActive ? 'has-active' : ''}"
|
|
587
|
+
part="overlay"
|
|
588
|
+
aria-hidden="true"
|
|
589
|
+
?hidden=${this.hideOutlines}
|
|
590
|
+
>
|
|
591
|
+
${this.entries.map((e, i) => e.box
|
|
592
|
+
? html `<div
|
|
593
|
+
class="region ${i === this.active ? 'active' : ''}"
|
|
594
|
+
part="region"
|
|
595
|
+
data-index=${i}
|
|
596
|
+
>
|
|
597
|
+
<span class="badge ${numbers ? '' : 'no-number'}"
|
|
598
|
+
>${numbers ? html `<span class="number">${e.number}</span>` : nothing}${e.item.label ? html `<span class="name">${e.item.label}</span>` : nothing}</span
|
|
599
|
+
>
|
|
600
|
+
</div>`
|
|
601
|
+
: nothing)}
|
|
602
|
+
</div>
|
|
603
|
+
</div>
|
|
604
|
+
<div class="list" part="list">
|
|
605
|
+
<div class="heading" role="heading" aria-level=${this.level} id=${this.headingId}>
|
|
606
|
+
${normalize(this.label) || DEFAULT_LABEL}
|
|
607
|
+
</div>
|
|
608
|
+
${list}
|
|
609
|
+
</div>
|
|
610
|
+
</div>`;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
__decorate([
|
|
614
|
+
property({ attribute: false })
|
|
615
|
+
], UvalibImageRegions.prototype, "items", void 0);
|
|
616
|
+
__decorate([
|
|
617
|
+
property({ type: String })
|
|
618
|
+
], UvalibImageRegions.prototype, "src", void 0);
|
|
619
|
+
__decorate([
|
|
620
|
+
property({ type: String })
|
|
621
|
+
], UvalibImageRegions.prototype, "alt", void 0);
|
|
622
|
+
__decorate([
|
|
623
|
+
property({ type: Number })
|
|
624
|
+
], UvalibImageRegions.prototype, "width", void 0);
|
|
625
|
+
__decorate([
|
|
626
|
+
property({ type: Number })
|
|
627
|
+
], UvalibImageRegions.prototype, "height", void 0);
|
|
628
|
+
__decorate([
|
|
629
|
+
property({ type: Number, attribute: 'image-width' })
|
|
630
|
+
], UvalibImageRegions.prototype, "imageWidth", void 0);
|
|
631
|
+
__decorate([
|
|
632
|
+
property({ type: Number, attribute: 'image-height' })
|
|
633
|
+
], UvalibImageRegions.prototype, "imageHeight", void 0);
|
|
634
|
+
__decorate([
|
|
635
|
+
property({ type: String })
|
|
636
|
+
], UvalibImageRegions.prototype, "label", void 0);
|
|
637
|
+
__decorate([
|
|
638
|
+
property({ type: Number, attribute: 'heading-level' })
|
|
639
|
+
], UvalibImageRegions.prototype, "headingLevel", void 0);
|
|
640
|
+
__decorate([
|
|
641
|
+
property({ type: String })
|
|
642
|
+
], UvalibImageRegions.prototype, "numbering", void 0);
|
|
643
|
+
__decorate([
|
|
644
|
+
property({ type: Boolean, reflect: true, attribute: 'hide-outlines' })
|
|
645
|
+
], UvalibImageRegions.prototype, "hideOutlines", void 0);
|
|
646
|
+
__decorate([
|
|
647
|
+
state()
|
|
648
|
+
], UvalibImageRegions.prototype, "entries", void 0);
|
|
649
|
+
__decorate([
|
|
650
|
+
state()
|
|
651
|
+
], UvalibImageRegions.prototype, "natural", void 0);
|
|
652
|
+
__decorate([
|
|
653
|
+
state()
|
|
654
|
+
], UvalibImageRegions.prototype, "active", void 0);
|
|
655
|
+
__decorate([
|
|
656
|
+
state()
|
|
657
|
+
], UvalibImageRegions.prototype, "inferredLevel", void 0);
|
|
658
|
+
//# sourceMappingURL=UvalibImageRegions.js.map
|