@uvalib/web-components 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +133 -12
- package/dist/base/states.d.ts +12 -0
- package/dist/base/states.js +33 -0
- package/dist/base/states.js.map +1 -0
- package/dist/base.css +15 -5
- package/dist/components/bento-box/BentoBox.js +1 -0
- package/dist/components/bento-box/BentoBox.js.map +1 -1
- package/dist/components/events-section/EventsSection.js +1 -0
- package/dist/components/events-section/EventsSection.js.map +1 -1
- package/dist/components/library-hours/hours-data.js +1 -1
- package/dist/components/library-hours/hours-data.js.map +1 -1
- package/dist/components/library-weekly-hours/LibraryWeeklyHours.js +1 -0
- package/dist/components/library-weekly-hours/LibraryWeeklyHours.js.map +1 -1
- package/dist/components/uvalib-card/UvalibCard.js +6 -0
- package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
- package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +27 -0
- package/dist/components/uvalib-combobox/UvalibCombobox.js +85 -1
- package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -1
- package/dist/components/uvalib-contents/UvalibContents.js +5 -0
- package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +6 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +10 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -1
- package/dist/components/uvalib-image-regions/UvalibImageRegions.d.ts +1 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js +4 -1
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -1
- package/dist/components/uvalib-image-regions/regions.d.ts +6 -2
- package/dist/components/uvalib-image-regions/regions.js +6 -3
- package/dist/components/uvalib-image-regions/regions.js.map +1 -1
- package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +100 -7
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +310 -83
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-lightbox/compare.d.ts +48 -8
- package/dist/components/uvalib-lightbox/compare.js +226 -22
- package/dist/components/uvalib-lightbox/compare.js.map +1 -1
- package/dist/components/uvalib-map/UvalibMap.js +2 -2
- package/dist/components/uvalib-map/UvalibMap.js.map +1 -1
- package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -0
- package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +3 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +3 -3
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +16 -8
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
- package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +4 -1
- package/dist/components/uvalib-tag-list/UvalibTagList.js +9 -2
- package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -1
- package/dist/custom-elements.json +596 -19
- package/dist/styles/message.js +4 -0
- package/dist/styles/message.js.map +1 -1
- package/dist/styles/result-list.js +25 -4
- package/dist/styles/result-list.js.map +1 -1
- package/dist/styles/results.js +17 -2
- package/dist/styles/results.js.map +1 -1
- package/dist-cdn/base.css +15 -5
- package/dist-cdn/bento-box.js +1 -0
- package/dist-cdn/bento-box.js.map +1 -1
- package/dist-cdn/chunks/{compare-D4VdaIJN.js → compare-C0nhByn7.js} +185 -56
- package/dist-cdn/chunks/compare-C0nhByn7.js.map +1 -0
- package/dist-cdn/chunks/{hours-data-Bw6vkIw7.js → hours-data-gMu5uT7H.js} +2 -2
- package/dist-cdn/chunks/hours-data-gMu5uT7H.js.map +1 -0
- package/dist-cdn/chunks/{library-weekly-hours-CrV3TlP5.js → library-weekly-hours-BJgxAyah.js} +3 -2
- package/dist-cdn/chunks/library-weekly-hours-BJgxAyah.js.map +1 -0
- package/dist-cdn/chunks/{regions-B8ExwUGP.js → regions-B-rOwa-v.js} +15 -15
- package/dist-cdn/chunks/regions-B-rOwa-v.js.map +1 -0
- package/dist-cdn/chunks/states-DGXGzcte.js +17 -0
- package/dist-cdn/chunks/states-DGXGzcte.js.map +1 -0
- package/dist-cdn/custom-elements.json +596 -19
- package/dist-cdn/events-section.js +1 -0
- package/dist-cdn/events-section.js.map +1 -1
- package/dist-cdn/library-hours-setup.js +1 -1
- package/dist-cdn/library-weekly-hours.js +1 -1
- package/dist-cdn/manifest.json +1 -1
- package/dist-cdn/site-hours-section.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +8 -6
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +37 -6
- package/dist-cdn/uvalib-card.js +6 -0
- package/dist-cdn/uvalib-card.js.map +1 -1
- package/dist-cdn/uvalib-combobox.js +107 -68
- package/dist-cdn/uvalib-combobox.js.map +1 -1
- package/dist-cdn/uvalib-contents.js +5 -0
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-filter-drawer.js +27 -25
- package/dist-cdn/uvalib-filter-drawer.js.map +1 -1
- package/dist-cdn/uvalib-image-regions.js +4 -2
- package/dist-cdn/uvalib-image-regions.js.map +1 -1
- package/dist-cdn/uvalib-lightbox.js +230 -129
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-map.js +2 -2
- package/dist-cdn/uvalib-map.js.map +1 -1
- package/dist-cdn/uvalib-metadata.js +3 -0
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pagefind-search.js +2 -1
- package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +4 -5
- package/dist-cdn/uvalib-photo-grid.js.map +1 -1
- package/dist-cdn/uvalib-tag-list.js +21 -16
- package/dist-cdn/uvalib-tag-list.js.map +1 -1
- package/package.json +1 -1
- package/skills/uvalib-web-components/SKILL.md +8 -6
- package/skills/uvalib-web-components/reference/components.md +37 -6
- package/dist-cdn/chunks/compare-D4VdaIJN.js.map +0 -1
- package/dist-cdn/chunks/hours-data-Bw6vkIw7.js.map +0 -1
- package/dist-cdn/chunks/library-weekly-hours-CrV3TlP5.js.map +0 -1
- package/dist-cdn/chunks/regions-B8ExwUGP.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uvalib-card.js","names":["unsafeCSS","nothing","unsafeStatic","_decorate","property","n","i","b","define","__decorate","A","r","installLightDomStyles","UvalibElement","u","s","precedingHeadingLevel","trackEvent","accessible","DEFAULT_LEVEL","SAFE_SCHEMES","hostFn","host","pseudo","structuralRules","shadowStructure","shadowSlotted","lightTitleMargin","tag","CONTENT","arrow","UvalibCard","_args","root","sheet","node","raw","above","next","ok","href","name","circle","el","inMedia","grid","direct","index","a","pos","go","source","region","incoming","named","filled","slot","byName","excerpt","dest","empty","media","value","card","inner","heading"],"sources":["../src/components/uvalib-card/UvalibCard.ts","../src/components/uvalib-card/uvalib-card.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS } from 'lit';\nimport { html as staticHtml, unsafeStatic } from 'lit/static-html.js';\nimport { property } from 'lit/decorators.js';\nimport { precedingHeadingLevel } from '../../base/heading-level.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { accessible } from '../../styles/accessible.js';\n\nconst DEFAULT_LEVEL = 3;\n\n/** Schemes a card may link to; anything else (`javascript:`, `data:`, …) is not a link. */\nconst SAFE_SCHEMES = new Set(['http:', 'https:', 'mailto:', 'tel:']);\n\n/**\n * Kept with `no-style`: the card is a column that fills its grid cell, the heading link's\n * box stretches over the card (the link itself is not positioned), empty regions stay\n * hidden, and `[hidden]` hides. `host` is `:host` (shadow) or the tag (light DOM).\n */\n/** `:host(:dir(rtl))` in shadow, `uvalib-card:dir(rtl)` in a document sheet. */\nconst hostFn = (host: string, pseudo: string) =>\n host === ':host' ? `:host(${pseudo})` : `${host}${pseudo}`;\n\nconst structuralRules = (host: string) => `\n ${host} {\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n width: 100%;\n min-width: 0;\n max-width: 100%;\n }\n ${host} .card {\n position: relative;\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-width: 0;\n min-height: 100%;\n overflow: hidden;\n }\n ${host} .title { margin: 0; }\n ${host} .title-link {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n width: 100%;\n min-height: 1.5rem;\n text-decoration: none;\n }\n ${host} .title-link::after { content: \"\"; position: absolute; inset: 0; z-index: 1; }\n ${host} .title-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }\n ${host} .arrow { flex: none; }\n ${hostFn(host, ':dir(rtl)')} .arrow,\n ${hostFn(host, '[dir=\"rtl\"]')} .arrow { transform: scaleX(-1); }\n ${host} .body { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }\n ${host} .excerpt { margin: 0; overflow-wrap: anywhere; }\n ${host} .media { position: relative; }\n ${host} .media img, ${host} .media video {\n display: block;\n width: 100%;\n height: auto;\n aspect-ratio: 3 / 2;\n object-fit: cover;\n }\n ${host} .badge { position: absolute; z-index: 0; }\n ${hostFn(host, \"[media-shape='circle' i]\")} .media {\n width: 8rem;\n max-width: 100%;\n margin-inline: auto;\n }\n ${hostFn(host, \"[media-shape='circle' i]\")} .media img,\n ${hostFn(host, \"[media-shape='circle' i]\")} .media video {\n width: 100%;\n aspect-ratio: 1;\n border-radius: 50%;\n object-fit: cover;\n }\n ${host} .actions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.75rem;\n }\n ${host} .actions a,\n ${host} .actions button {\n display: inline-flex;\n align-items: center;\n min-width: 44px;\n min-height: 44px;\n }\n\n ${host} .card-source { display: none !important; }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n @media (forced-colors: active) {\n ${hostFn(host, \"[media-shape='circle' i]\")} .media img,\n ${hostFn(host, \"[media-shape='circle' i]\")} .media video {\n border: 1px solid CanvasText;\n }\n }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/** Shadow only. `::slotted` must be the subject; a :host descendant combinator does not match. */\nconst shadowSlotted = css`\n slot::slotted(img.uvalib-circle),\n slot::slotted(video.uvalib-circle) {\n display: block;\n width: 8rem;\n max-width: 100%;\n margin-inline: auto;\n aspect-ratio: 1;\n border-radius: 50%;\n object-fit: cover;\n }\n slot::slotted([slot='actions']) {\n display: inline-flex;\n align-items: center;\n min-width: 44px;\n min-height: 44px;\n }\n @media (forced-colors: active) {\n slot::slotted(img.uvalib-circle),\n slot::slotted(video.uvalib-circle) {\n border: 1px solid CanvasText;\n }\n }\n`;\n\n/**\n * Light DOM only, unlayered. The Drupal theme gives `h3` a large top margin; this keeps the\n * card title flush whatever `heading-level` is. Unlayered, and more specific than a bare\n * `h3`, so it beats the page's heading rules. `::slotted` is not used here: it is invalid\n * in a document sheet and would drop the rule.\n */\nconst lightTitleMargin = (tag: string) => unsafeCSS(`${tag} .title { margin-block: 0; }`);\n\nconst CONTENT: MutationObserverInit = {\n attributeFilter: ['slot'],\n attributes: true,\n childList: true,\n subtree: true,\n};\n\nconst arrow = html`<svg\n class=\"arrow\"\n viewBox=\"0 0 20 20\"\n width=\"1em\"\n height=\"1em\"\n aria-hidden=\"true\"\n focusable=\"false\"\n>\n <path\n d=\"M4 10h12M12 6l4 4-4 4\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.75\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n ></path>\n</svg>`;\n\n/**\n * One card: a collection (title and “N texts”), a photo (image, count, date, category,\n * title, excerpt) or any other raised summary. With `href`, the heading is the link and a\n * pseudo-element stretches that link over the card, so the whole card is one click. The\n * arrow is only a visual aid. The card is never wrapped in an `<a>`.\n *\n * A clickable card must not contain another link, button or other control: the stretched\n * link covers it. A static card (no `href`, or an empty or unsafe one) has no stretch, so\n * its excerpt and `actions` slot may contain links. With `href`, the heading needs an\n * accessible name (text, or an image `alt` or `aria-label`); otherwise the link is hidden.\n *\n * `media-shape=\"circle\"` draws the media as a centered circle, for a person or avatar.\n * The image keeps its alt, and the count badge still sits on it. Any other shape is ignored.\n *\n * Regions are light-DOM children. Give `slot=\"media\"`, `slot=\"badge\"`, `slot=\"heading\"`,\n * `slot=\"meta\"`, `slot=\"chip\"` or `slot=\"actions\"`; anything else (including text) is the\n * excerpt. An image needs a real alt, or `alt=\"\"` when the heading already names it. A date\n * belongs in `<time>` in the meta slot. One element per chip. `actions` is a row of links\n * or buttons on a static card (“Read the story”, “Photos (132)”).\n *\n * The heading level defaults like `<events-section>`: one below the nearest heading before\n * the card, or 3 when there is none. `heading-level` (1–6) wins. An invalid value is\n * ignored.\n *\n * @tagname uvalib-card\n * @slot media - Image or other media. An `<img>` needs a real alt, or `alt=\"\"` when the heading names it.\n * @slot badge - Short label drawn over the media, such as “13 photos”.\n * @slot heading - The card title. With `href`, this heading’s link is the card, so it needs an accessible name.\n * @slot meta - Date (`<time>`) or byline, under the title.\n * @slot chip - Category. One element per chip.\n * @slot actions - Links or buttons on a static card. A clickable card must not contain them; the card link covers them.\n * @slot - Excerpt. A static card may put links here; a clickable card must not contain other controls.\n * @fires uvalib-analytics-event - For `<site-analytics>`: a primary-button click on the card link that was not already canceled, including a modified click, `['uvalib-card', 'card-click', 'single']` or, inside `<uvalib-card-grid>`, `['uvalib-card', 'card-click', '<n>', <n>]` (n from 1, the card’s place in that grid). Never the title or URL. Bubbles and is composed.\n * @fires uvalib-card-navigate - A plain click on the card link: `detail` is `{ href, position }` (`position` is `'single'` or `'1'`, `'2'`, …). Cancel it (`preventDefault()`) to route in the app; the click’s default is then prevented. Bubbles and is composed.\n * @cssprop [--uva-brand-blue=#232d4b] - Title link when `--uva-color-link` is unset, and the badge background when `--uva-color-accent-bg` is unset.\n * @cssprop [--uva-blue-alt-300=#BFE7F7] - Chip background. With `--uva-blue-alt-dark` this pair is 6.13:1 (WCAG AA for normal text, short of AAA’s 7:1).\n * @cssprop [--uva-blue-alt-dark=#005679] - Chip text.\n * @cssprop [--uva-grey-100=#DADADA] - Hover shadow colour when `--uva-color-shadow` is unset.\n * @cssprop --uva-color-surface-raised - Dark-mode role token: card background (else #fff).\n * @cssprop --uva-color-border - Dark-mode role token: card border (else `--uva-grey-100`).\n * @cssprop --uva-color-text - Dark-mode role token: body text (else `--uva-grey-darkest`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: meta line (else #4f4f4f).\n * @cssprop --uva-color-link - Dark-mode role token: title link (else `--uva-brand-blue`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring on the card (else `--uva-brand-orange`).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: badge background (else `--uva-brand-blue`).\n * @cssprop --uva-color-on-accent - Text on the badge (else #fff).\n * @cssprop --uva-color-shadow - Dark-mode role token: hover shadow colour (else `--uva-grey-100`).\n */\nexport class UvalibCard extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n shadowSlotted,\n css`\n :host {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .card {\n background: var(--uva-color-surface-raised, #fff);\n border: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n border-radius: 0.3rem;\n transition: box-shadow 0.25s ease;\n }\n :host(:hover) .card,\n :host(:focus-within) .card {\n box-shadow: 0 0 20px 0 var(--uva-color-shadow, var(--uva-grey-100, #dadada));\n }\n /* The ring is on the card, not the heading link. :has() on .card sees the link\n in this tree; :host(:has()) would look outside the shadow root and miss it. */\n .card:has(.title-link:focus-visible) {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n .title-link:focus-visible {\n outline: none;\n }\n .body {\n padding: 1rem 1.25rem;\n flex: 1 1 auto;\n }\n .title {\n font-size: 1.25rem;\n line-height: 1.3;\n font-weight: 600;\n }\n .title-link {\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n font-weight: inherit;\n }\n .title-link:hover .title-text {\n text-decoration: underline;\n }\n .meta {\n color: var(--uva-color-text-muted, #4f4f4f);\n font-size: 0.875rem;\n }\n .chips {\n display: flex;\n flex-wrap: wrap;\n gap: 0.375rem;\n }\n .badge {\n inset-block-start: 0.5rem;\n inset-inline-start: 0.5rem;\n max-width: calc(100% - 1rem);\n padding: 0.15rem 0.5rem;\n border-radius: 0.25rem;\n background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n color: var(--uva-color-on-accent, #fff);\n font-size: 0.875rem;\n line-height: 1.4;\n }\n .media:has([data-region='badge']:not([hidden])) {\n min-height: 2.5rem;\n }\n @media (prefers-reduced-motion: reduce) {\n .card {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .card {\n background: Canvas;\n border-color: CanvasText;\n box-shadow: none;\n }\n :host(:hover) .card,\n :host(:focus-within) .card {\n box-shadow: none;\n }\n .card:has(.title-link:focus-visible) {\n outline-color: Highlight;\n }\n .badge {\n background: CanvasText;\n color: Canvas;\n }\n }\n `,\n // ::slotted is its own rule. Combining it with a light-DOM selector drops both in\n // engines that reject the whole rule when one selector is invalid.\n css`\n ::slotted(img),\n ::slotted(video) {\n display: block;\n width: 100%;\n height: auto;\n aspect-ratio: 3 / 2;\n object-fit: cover;\n }\n ::slotted(img.uvalib-circle),\n ::slotted(video.uvalib-circle) {\n width: 8rem;\n max-width: 100%;\n margin-inline: auto;\n aspect-ratio: 1;\n border-radius: 50%;\n object-fit: cover;\n }\n ::slotted([slot='chip']) {\n background: var(--uva-blue-alt-300, #bfe7f7);\n color: var(--uva-blue-alt-dark, #005679);\n border-radius: 999px;\n padding: 0.1rem 0.6rem;\n font-size: 0.875rem;\n line-height: 1.4;\n }\n `,\n css`\n [data-region='chip'] > * {\n background: var(--uva-blue-alt-300, #bfe7f7);\n color: var(--uva-blue-alt-dark, #005679);\n border-radius: 999px;\n padding: 0.1rem 0.6rem;\n font-size: 0.875rem;\n line-height: 1.4;\n }\n `,\n ];\n\n /** Makes the card one link: the heading stretches over the card. Empty is not a link. */\n @property({ type: String }) href?: string;\n\n /**\n * `circle` crops the media to a centered circle and keeps the image alt. Anything else\n * is ignored, with one console warning.\n */\n @property({ attribute: 'media-shape' }) mediaShape = '';\n\n /**\n * Heading level of the title, 1–6. Unset, it is one below the nearest heading before\n * this card, or 3 when there is none. Any other value is ignored.\n */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel?: number;\n\n /** One below the nearest preceding heading. A field, so the first render can use it. */\n private inferred = DEFAULT_LEVEL;\n private warnedHref = false;\n private warnedNested = false;\n private warnedHeading = false;\n private warnedShape = false;\n private observer?: MutationObserver;\n /** Author nodes captured before the first light-DOM render. */\n private saved: Node[] = [];\n /** Set once the author's children have been lifted off the host, including a reconnect before the first render. */\n private captured = false;\n /** Light DOM nodes this element rendered (Lit markers and the card), never author content. */\n private own = new WeakSet<Node>();\n private placing = false;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheets = [shadowStructure.styleSheet, shadowSlotted.styleSheet].filter(\n (sheet): sheet is CSSStyleSheet => !!sheet,\n );\n root.adoptedStyleSheets = sheets;\n }\n return root;\n }\n\n override connectedCallback(): void {\n const light = this.hasAttribute('no-shadow-dom') || this.noShadowDom;\n // Before super: the first update is a microtask, and a light-DOM render would drop\n // the author's children. On reconnect they are already parked in the card.\n // A grid may move the card (disconnect and reconnect) before the first render.\n // Capturing again would replace `saved` with an empty child list and drop the content.\n if (light && !this.hasUpdated && !this.captured) {\n this.captured = true;\n this.saved = [...this.childNodes];\n for (const n of this.saved) n.parentNode?.removeChild(n);\n }\n this.infer();\n super.connectedCallback();\n if (this.lightDom) {\n const node = this.getRootNode();\n const root = node instanceof ShadowRoot || node instanceof Document ? node : undefined;\n if (this.noStyle)\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n { root, scope: false },\n );\n installLightDomStyles(`${this.localName}::title-margin`, lightTitleMargin(this.localName), {\n root,\n scope: false,\n layer: false,\n });\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n // A grid assigns slot=\"card-N\". Left on the card, that name hides it inside\n // <site-page>, whose default slot only shows unslotted children.\n if (this.hasAttribute('data-grid-slot')) {\n this.removeAttribute('slot');\n this.removeAttribute('data-grid-slot');\n }\n }\n\n private get level(): number {\n const n = Math.trunc(this.headingLevel ?? Number.NaN);\n return n >= 1 && n <= 6 ? n : this.inferred;\n }\n\n /** The href when it may be a link; null when absent, blank or an unsafe scheme. */\n private get linkHref(): string | null {\n const raw = this.href ?? '';\n if (!raw.trim()) return null;\n return this.safe(raw.trim()) ? raw.trim() : null;\n }\n\n private infer(): void {\n if (!this.isConnected) return;\n const above = precedingHeadingLevel(this);\n const next = above === null ? DEFAULT_LEVEL : Math.min(above + 1, 6);\n this.inferred = next;\n }\n\n private safe(href: string): boolean {\n let ok = false;\n try {\n ok = SAFE_SCHEMES.has(new URL(href, this.ownerDocument.baseURI).protocol);\n } catch {\n ok = false;\n }\n if (!ok && !this.warnedHref) {\n this.warnedHref = true;\n console.warn(\n `${this.localName}: not linking a card whose href is not http(s), mailto, tel or relative.`,\n );\n }\n return ok;\n }\n\n /** A named shadow slot, or nothing in light DOM (the regions are filled by moving nodes). */\n private renderSlot(name?: string) {\n if (this.lightDom) return nothing;\n return name\n ? html`<slot name=${name} @slotchange=${this.onSlotChange}></slot>`\n : html`<slot @slotchange=${this.onSlotChange}></slot>`;\n }\n\n private onSlotChange = (): void => {\n this.syncShape();\n this.syncHidden();\n this.warnNested();\n };\n\n /** `::slotted` cannot see a host attribute, so the circle image carries a class. */\n private syncShape(): void {\n const circle = this.mediaShape.trim().toLowerCase() === 'circle';\n for (const el of this.querySelectorAll('img, video')) {\n if (!(el instanceof HTMLElement)) continue;\n const inMedia = el.getAttribute('slot') === 'media' || !!el.closest('[data-region=\"media\"]');\n el.classList.toggle('uvalib-circle', circle && inMedia);\n }\n }\n\n /** Place among the cards of the nearest grid, from 1, or `'single'` when there is none. */\n private position(): { name: string; value?: number } {\n const grid = this.closest('uvalib-card-grid');\n if (!grid) return { name: 'single' };\n const direct = [...grid.querySelectorAll(':scope > uvalib-card')];\n const cards = direct.length\n ? direct\n : [...grid.querySelectorAll(':scope > ul > li > uvalib-card')];\n const index = cards.indexOf(this);\n if (index < 0) return { name: 'single' };\n return { name: String(index + 1), value: index + 1 };\n }\n\n /**\n * A plain primary-button click on the card link fires a cancelable `uvalib-card-navigate`.\n * A click that was already canceled, or that is not the primary button, is ignored.\n * Modified clicks are tracked and do not fire the navigate event.\n */\n private onClick(e: MouseEvent): void {\n const node = e.target instanceof Node ? e.target : null;\n const el = node instanceof Element ? node : node?.parentElement;\n const a = el?.closest('a.title-link');\n if (!a || !this.renderRoot.contains(a)) return;\n if (e.defaultPrevented || e.button !== 0) return;\n const pos = this.position();\n trackEvent(\n this,\n pos.value === undefined\n ? ['uvalib-card', 'card-click', pos.name]\n : ['uvalib-card', 'card-click', pos.name, pos.value],\n );\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n const go = new CustomEvent('uvalib-card-navigate', {\n detail: { href: a.getAttribute('href'), position: pos.name },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n private sourceEl(): HTMLElement | null {\n return this.renderRoot.querySelector('.card-source');\n }\n\n private regions(): HTMLElement[] {\n return [...this.renderRoot.querySelectorAll<HTMLElement>('[data-region]')];\n }\n\n /** Move light-DOM region children back to the source before Lit may recreate the heading. */\n private reclaim(): void {\n const source = this.sourceEl();\n if (!source) return;\n for (const region of this.regions()) {\n while (region.firstChild) source.appendChild(region.firstChild);\n }\n }\n\n /** Author nodes appended to the host later, not the nodes this element rendered. */\n private ingest(): void {\n const source = this.sourceEl();\n if (!source) return;\n const incoming = [...this.childNodes].filter((n) => !this.own.has(n) && n !== source);\n if (incoming.length) source.append(...incoming);\n }\n\n private hasContent(n: Node): boolean {\n if (n.nodeType === Node.TEXT_NODE) return !!n.textContent?.trim();\n if (n instanceof Element) {\n if (n.matches('img, svg, picture, video')) return true;\n return !!n.textContent?.trim() || !!n.querySelector('img, svg, picture, video');\n }\n return false;\n }\n\n /**\n * An accessible name: trimmed text (including an `svg` `title`), or a non-empty\n * `alt` / `aria-label`. An `img` with `alt=\"\"` does not count.\n */\n private hasName(n: Node): boolean {\n if (n.nodeType === Node.TEXT_NODE) return !!n.textContent?.trim();\n if (!(n instanceof Element)) return false;\n const own = n.getAttribute('alt')?.trim() || n.getAttribute('aria-label')?.trim();\n if (own) return true;\n if (n.textContent?.trim()) return true;\n return [...n.querySelectorAll('[alt], [aria-label]')].some(\n (el) => !!(el.getAttribute('alt')?.trim() || el.getAttribute('aria-label')?.trim()),\n );\n }\n\n private isEmpty(region: Element | null): boolean {\n if (!region) return true;\n // Only the heading needs a name. A decorative media image (`alt=\"\"`) still counts.\n const named = region.getAttribute('data-region') === 'heading';\n const filled = (n: Node) => (named ? this.hasName(n) : this.hasContent(n));\n if (!this.lightDom) {\n const slot = region.querySelector('slot');\n const nodes = slot ? slot.assignedNodes({ flatten: true }) : [...region.childNodes];\n return !nodes.some(filled);\n }\n return ![...region.childNodes].some(filled);\n }\n\n /** Shadow slots can still be empty on the first update, before the browser assigns them. */\n private headingPending(): boolean {\n if (this.lightDom) return false;\n const slot = this.renderRoot.querySelector('[data-region=\"heading\"] slot');\n if (!(slot instanceof HTMLSlotElement) || slot.assignedNodes({ flatten: true }).length > 0)\n return false;\n return [...this.childNodes].some(\n (n) => n instanceof Element && n.getAttribute('slot') === 'heading' && this.hasName(n),\n );\n }\n\n private warnEmptyHeading(): void {\n if (!this.linkHref || this.warnedHeading || this.headingPending()) return;\n this.warnedHeading = true;\n console.warn(\n `${this.localName}: a clickable card (one with href) has a heading with no accessible name, so its link is hidden.`,\n );\n }\n\n /** Put each author node in the region its slot names; the rest is the excerpt. */\n private distribute(): void {\n const source = this.sourceEl();\n if (!source) return;\n const byName = new Map<string, HTMLElement>();\n for (const region of this.regions()) {\n const name = region.dataset.region;\n if (name) byName.set(name, region);\n }\n const excerpt = byName.get('excerpt');\n for (const n of [...source.childNodes]) {\n if (n.nodeType === Node.COMMENT_NODE) continue;\n if (n.nodeType === Node.TEXT_NODE && !n.textContent?.trim()) continue;\n const slot = n instanceof Element ? n.getAttribute('slot') : null;\n const dest = (slot && byName.get(slot)) || excerpt;\n if (dest) dest.appendChild(n);\n }\n }\n\n private syncHidden(): void {\n const root = this.renderRoot;\n for (const region of this.regions()) {\n const empty = this.isEmpty(region);\n region.toggleAttribute('hidden', empty);\n if (region.dataset.region === 'heading') {\n region.closest('.title')?.toggleAttribute('hidden', empty);\n if (empty) this.warnEmptyHeading();\n }\n }\n const media = root.querySelector('.media');\n if (media instanceof HTMLElement) {\n const empty =\n this.isEmpty(root.querySelector('[data-region=\"media\"]')) &&\n this.isEmpty(root.querySelector('[data-region=\"badge\"]'));\n media.toggleAttribute('hidden', empty);\n }\n }\n\n private warnShape(): void {\n const value = this.mediaShape.trim().toLowerCase();\n if (!value || value === 'circle' || this.warnedShape) return;\n this.warnedShape = true;\n console.warn(\n `${this.localName}: media-shape \"${this.mediaShape.trim()}\" is not supported. Use \"circle\".`,\n );\n }\n\n private warnNested(): void {\n if (!this.linkHref || this.warnedNested) return;\n const nested = [\n ...this.querySelectorAll(\n 'a[href], button, input:not([type=\"hidden\"]), select, textarea, summary, [role=\"button\"], [role=\"link\"], [tabindex]:not([tabindex=\"-1\"])',\n ),\n ].filter((n) => !n.classList.contains('title-link'));\n if (!nested.length) return;\n this.warnedNested = true;\n console.warn(\n `${this.localName}: a clickable card (one with href) must not contain other links, buttons or controls; the card link covers them. Use a static card for an actions row.`,\n );\n }\n\n private arm(): void {\n if (!this.lightDom) return;\n this.observer ??= new MutationObserver(() => this.onAuthorChange());\n const source = this.sourceEl();\n const card = this.renderRoot.querySelector('.card');\n if (source) this.observer.observe(source, CONTENT);\n if (card) this.observer.observe(card, CONTENT);\n this.observer.observe(this, { childList: true });\n }\n\n private onAuthorChange(): void {\n if (this.placing || !this.lightDom) return;\n this.placing = true;\n this.observer?.disconnect();\n try {\n this.ingest();\n this.reclaim();\n this.distribute();\n this.syncShape();\n this.syncHidden();\n this.warnNested();\n } finally {\n this.placing = false;\n this.arm();\n }\n }\n\n protected override willUpdate(): void {\n this.infer();\n this.warnShape();\n if (this.lightDom && this.hasUpdated && !this.placing) {\n this.observer?.disconnect();\n this.reclaim();\n }\n }\n\n protected override firstUpdated(): void {\n if (this.lightDom) for (const n of this.childNodes) this.own.add(n);\n }\n\n protected override updated(): void {\n this.syncShape();\n if (!this.lightDom) {\n this.syncHidden();\n this.warnNested();\n return;\n }\n if (this.placing) return;\n this.placing = true;\n this.observer?.disconnect();\n try {\n const source = this.sourceEl();\n if (source && this.saved.length) {\n source.append(...this.saved);\n this.saved = [];\n }\n this.ingest();\n this.distribute();\n this.syncShape();\n this.syncHidden();\n this.warnNested();\n } finally {\n this.placing = false;\n this.arm();\n }\n }\n\n private headingEl(inner: unknown) {\n const tag = unsafeStatic(`h${this.level}`);\n const href = this.linkHref;\n if (href)\n return staticHtml`<${tag} class=\"title\"><a class=\"title-link\" href=${href}>${inner}${arrow}</a></${tag}>`;\n return staticHtml`<${tag} class=\"title\">${inner}</${tag}>`;\n }\n\n protected override render() {\n const heading = html`<span class=\"title-text\" data-region=\"heading\"\n >${this.renderSlot('heading')}</span\n >`;\n return html`${this.lightDom ? html`<div class=\"card-source\" hidden></div>` : nothing}\n <div class=\"card\" @click=${this.onClick}>\n <div class=\"media\">\n <div data-region=\"media\">${this.renderSlot('media')}</div>\n <div class=\"badge\" data-region=\"badge\">${this.renderSlot('badge')}</div>\n </div>\n <div class=\"body\">\n ${this.headingEl(heading)}\n <div class=\"meta\" data-region=\"meta\">${this.renderSlot('meta')}</div>\n <div class=\"chips\" data-region=\"chip\">${this.renderSlot('chip')}</div>\n <div class=\"excerpt\" data-region=\"excerpt\">${this.renderSlot()}</div>\n <div class=\"actions\" data-region=\"actions\">${this.renderSlot('actions')}</div>\n </div>\n </div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibCard } from './UvalibCard.js';\n\ndefine('uvalib-card', UvalibCard);\n"],"mappings":";;;;;;AASA,IAAMmB,IAAgB,GAGhBC,oBAAe,IAAI,IAAI;CAAC;CAAS;CAAU;CAAW;AAAM,CAAC,GAQ7DC,KAAU,GAAc,MAC5BC,MAAS,UAAU,SAASC,EAAO,KAAK,GAAGD,IAAOC,KAE9CC,KAAmB,MAAiB;IACtCF,EAAK;;;;;;;;IAQLA,EAAK;;;;;;;;;IASLA,EAAK;IACLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;IACLA,EAAK;IACLD,EAAOC,GAAM,WAAW,EAAE;IAC1BD,EAAOC,GAAM,eAAa,EAAE;IAC5BA,EAAK;IACLA,EAAK;IACLA,EAAK;IACLA,EAAK,eAAeA,EAAK;;;;;;;IAOzBA,EAAK;IACLD,EAAOC,GAAM,0BAA0B,EAAE;;;;;IAKzCD,EAAOC,GAAM,0BAA0B,EAAE;IACzCD,EAAOC,GAAM,0BAA0B,EAAE;;;;;;IAMzCA,EAAK;;;;;;IAMLA,EAAK;IACLA,EAAK;;;;;;;IAOLA,EAAK;IACLA,EAAK,YAAYA,EAAK;;MAEpBD,EAAOC,GAAM,0BAA0B,EAAE;MACzCD,EAAOC,GAAM,0BAA0B,EAAE;;;;GAKzCG,IAAkBzB,EAAUwB,EAAgB,OAAO,CAAC,GAGpDE,IAAgB,CAAG;;;;;;;;;;;;;;;;;;;;;;;GA+BnBC,KAAoB,MAAgB3B,EAAU,GAAG4B,EAAI,6BAA6B,GAElFC,IAAgC;CACpC,iBAAiB,CAAC,MAAM;CACxB,YAAY;CACZ,WAAW;CACX,SAAS;AACX,GAEMC,IAAQ,CAAI;;;;;;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K,WAAW;GAClB,UAAU;IAER,AADA,KAAK,UAAU,IACf,KAAK,IAAI;GACX;EAhBe;CAiBjB;CAEA,UAAkB,GAAgB;EAChC,IAAMvB,IAAM1B,EAAa,IAAI,KAAK,OAAO,GACnCsC,IAAO,KAAK;EAGlB,OAFIA,IACK,CAAU,IAAIZ,EAAI,4CAA4CY,EAAK,GAAGwB,IAAQlC,EAAM,QAAQF,EAAI,KAClG,CAAU,IAAIA,EAAI,iBAAiBoC,EAAM,IAAIpC,EAAI;CAC1D;CAEA,SAA4B;EAC1B,IAAMqC,IAAU,CAAI;SACf,KAAK,WAAW,SAAS,EAAE;;EAEhC,OAAO,CAAI,GAAG,KAAK,WAAW,CAAI,2CAA2ChE,EAAQ;iCACxD,KAAK,QAAQ;;qCAET,KAAK,WAAW,OAAO,EAAE;mDACX,KAAK,WAAW,OAAO,EAAE;;;YAGhE,KAAK,UAAUgE,CAAO,EAAE;iDACa,KAAK,WAAW,MAAM,EAAE;kDACvB,KAAK,WAAW,MAAM,EAAE;uDACnB,KAAK,WAAW,EAAE;uDAClB,KAAK,WAAW,SAAS,EAAE;;;CAGhF;AACF;;AAjaG9D,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA2B,EAAA,WAAA,QAAA,KAAA,CAAA,GAMzB5B,EAAA,CAAAC,EAAS,EAAE,WAAW,cAAc,CAAC,CAAA,GAAA2B,EAAA,WAAA,cAAA,KAAA,CAAA,GAMrC5B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAgB,CAAC,CAAA,GAAA2B,EAAA,WAAA,gBAAA,KAAA,CAAA,GCjWxDvB,EAAO,eAAeuB,CAAU"}
|
|
1
|
+
{"version":3,"file":"uvalib-card.js","names":["unsafeCSS","nothing","unsafeStatic","_decorate","property","n","i","b","define","__decorate","A","r","installLightDomStyles","UvalibElement","u","s","precedingHeadingLevel","trackEvent","accessible","DEFAULT_LEVEL","SAFE_SCHEMES","hostFn","host","pseudo","structuralRules","shadowStructure","shadowSlotted","lightTitleMargin","tag","CONTENT","arrow","UvalibCard","_args","root","sheet","node","raw","above","next","ok","href","name","circle","el","inMedia","grid","direct","index","a","pos","go","source","region","incoming","named","filled","slot","byName","excerpt","dest","empty","media","value","card","inner","heading"],"sources":["../src/components/uvalib-card/UvalibCard.ts","../src/components/uvalib-card/uvalib-card.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS } from 'lit';\nimport { html as staticHtml, unsafeStatic } from 'lit/static-html.js';\nimport { property } from 'lit/decorators.js';\nimport { precedingHeadingLevel } from '../../base/heading-level.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { accessible } from '../../styles/accessible.js';\n\nconst DEFAULT_LEVEL = 3;\n\n/** Schemes a card may link to; anything else (`javascript:`, `data:`, …) is not a link. */\nconst SAFE_SCHEMES = new Set(['http:', 'https:', 'mailto:', 'tel:']);\n\n/**\n * Kept with `no-style`: the card is a column that fills its grid cell, the heading link's\n * box stretches over the card (the link itself is not positioned), empty regions stay\n * hidden, and `[hidden]` hides. `host` is `:host` (shadow) or the tag (light DOM).\n */\n/** `:host(:dir(rtl))` in shadow, `uvalib-card:dir(rtl)` in a document sheet. */\nconst hostFn = (host: string, pseudo: string) =>\n host === ':host' ? `:host(${pseudo})` : `${host}${pseudo}`;\n\nconst structuralRules = (host: string) => `\n ${host} {\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n width: 100%;\n min-width: 0;\n max-width: 100%;\n }\n ${host} .card {\n position: relative;\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-width: 0;\n min-height: 100%;\n overflow: hidden;\n }\n ${host} .title { margin: 0; }\n ${host} .title-link {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n width: 100%;\n min-height: 1.5rem;\n text-decoration: none;\n }\n ${host} .title-link::after { content: \"\"; position: absolute; inset: 0; z-index: 1; }\n ${host} .title-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }\n ${host} .arrow { flex: none; }\n ${hostFn(host, ':dir(rtl)')} .arrow,\n ${hostFn(host, '[dir=\"rtl\"]')} .arrow { transform: scaleX(-1); }\n ${host} .body { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }\n ${host} .excerpt { margin: 0; overflow-wrap: anywhere; }\n ${host} .media { position: relative; }\n ${host} .media img, ${host} .media video {\n display: block;\n width: 100%;\n height: auto;\n aspect-ratio: 3 / 2;\n object-fit: cover;\n }\n ${host} .badge { position: absolute; z-index: 0; }\n ${hostFn(host, \"[media-shape='circle' i]\")} .media {\n width: 8rem;\n max-width: 100%;\n margin-inline: auto;\n }\n ${hostFn(host, \"[media-shape='circle' i]\")} .media img,\n ${hostFn(host, \"[media-shape='circle' i]\")} .media video {\n width: 100%;\n aspect-ratio: 1;\n border-radius: 50%;\n object-fit: cover;\n }\n ${host} .actions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.75rem;\n }\n ${host} .actions a,\n ${host} .actions button {\n display: inline-flex;\n align-items: center;\n min-width: 44px;\n min-height: 44px;\n }\n\n ${host} .card-source { display: none !important; }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n @media (forced-colors: active) {\n ${hostFn(host, \"[media-shape='circle' i]\")} .media img,\n ${hostFn(host, \"[media-shape='circle' i]\")} .media video {\n border: 1px solid CanvasText;\n }\n }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/** Shadow only. `::slotted` must be the subject; a :host descendant combinator does not match. */\nconst shadowSlotted = css`\n slot::slotted(img.uvalib-circle),\n slot::slotted(video.uvalib-circle) {\n display: block;\n width: 8rem;\n max-width: 100%;\n margin-inline: auto;\n aspect-ratio: 1;\n border-radius: 50%;\n object-fit: cover;\n }\n slot::slotted([slot='actions']) {\n display: inline-flex;\n align-items: center;\n min-width: 44px;\n min-height: 44px;\n }\n @media (forced-colors: active) {\n slot::slotted(img.uvalib-circle),\n slot::slotted(video.uvalib-circle) {\n border: 1px solid CanvasText;\n }\n }\n`;\n\n/**\n * Light DOM only, unlayered. The Drupal theme gives `h3` a large top margin; this keeps the\n * card title flush whatever `heading-level` is. Unlayered, and more specific than a bare\n * `h3`, so it beats the page's heading rules. `::slotted` is not used here: it is invalid\n * in a document sheet and would drop the rule.\n */\nconst lightTitleMargin = (tag: string) => unsafeCSS(`${tag} .title { margin-block: 0; }`);\n\nconst CONTENT: MutationObserverInit = {\n attributeFilter: ['slot'],\n attributes: true,\n childList: true,\n subtree: true,\n};\n\nconst arrow = html`<svg\n class=\"arrow\"\n viewBox=\"0 0 20 20\"\n width=\"1em\"\n height=\"1em\"\n aria-hidden=\"true\"\n focusable=\"false\"\n>\n <path\n d=\"M4 10h12M12 6l4 4-4 4\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.75\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n ></path>\n</svg>`;\n\n/**\n * One card: a collection (title and “N texts”), a photo (image, count, date, category,\n * title, excerpt) or any other raised summary. With `href`, the heading is the link and a\n * pseudo-element stretches that link over the card, so the whole card is one click. The\n * arrow is only a visual aid. The card is never wrapped in an `<a>`.\n *\n * A clickable card must not contain another link, button or other control: the stretched\n * link covers it. A static card (no `href`, or an empty or unsafe one) has no stretch, so\n * its excerpt and `actions` slot may contain links. With `href`, the heading needs an\n * accessible name (text, or an image `alt` or `aria-label`); otherwise the link is hidden.\n *\n * `media-shape=\"circle\"` draws the media as a centered circle, for a person or avatar.\n * The image keeps its alt, and the count badge still sits on it. Any other shape is ignored.\n *\n * Regions are light-DOM children. Give `slot=\"media\"`, `slot=\"badge\"`, `slot=\"heading\"`,\n * `slot=\"meta\"`, `slot=\"chip\"` or `slot=\"actions\"`; anything else (including text) is the\n * excerpt. An image needs a real alt, or `alt=\"\"` when the heading already names it. A date\n * belongs in `<time>` in the meta slot. One element per chip. `actions` is a row of links\n * or buttons on a static card (“Read the story”, “Photos (132)”).\n *\n * The heading level defaults like `<events-section>`: one below the nearest heading before\n * the card, or 3 when there is none. `heading-level` (1–6) wins. An invalid value is\n * ignored.\n *\n * @tagname uvalib-card\n * @slot media - Image or other media. An `<img>` needs a real alt, or `alt=\"\"` when the heading names it.\n * @slot badge - Short label drawn over the media, such as “13 photos”.\n * @slot heading - The card title. With `href`, this heading’s link is the card, so it needs an accessible name.\n * @slot meta - Date (`<time>`) or byline, under the title.\n * @slot chip - Category. One element per chip.\n * @slot actions - Links or buttons on a static card. A clickable card must not contain them; the card link covers them.\n * @slot - Excerpt. A static card may put links here; a clickable card must not contain other controls.\n * @fires uvalib-analytics-event - For `<site-analytics>`: a primary-button click on the card link that was not already canceled, including a modified click, `['uvalib-card', 'card-click', 'single']` or, inside `<uvalib-card-grid>`, `['uvalib-card', 'card-click', '<n>', <n>]` (n from 1, the card’s place in that grid). Never the title or URL. Bubbles and is composed.\n * @fires uvalib-card-navigate - A plain click on the card link: `detail` is `{ href, position }` (`position` is `'single'` or `'1'`, `'2'`, …). Cancel it (`preventDefault()`) to route in the app; the click’s default is then prevented. Bubbles and is composed.\n * @cssprop [--uva-brand-blue=#232d4b] - Title link when `--uva-color-link` is unset, and the badge background when `--uva-color-accent-bg` is unset.\n * @cssprop [--uva-blue-alt-300=#BFE7F7] - Chip background. With `--uva-blue-alt-dark` this pair is 6.13:1 (WCAG AA for normal text, short of AAA’s 7:1).\n * @cssprop [--uva-blue-alt-dark=#005679] - Chip text.\n * @cssprop [--uva-grey-100=#DADADA] - Hover shadow colour when `--uva-color-shadow` is unset.\n * @cssprop --uva-color-surface-raised - Dark-mode role token: card background (else #fff).\n * @cssprop --uva-color-border - Dark-mode role token: card border (else `--uva-grey-100`).\n * @cssprop --uva-color-text - Dark-mode role token: body text (else `--uva-grey-darkest`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: meta line (else #4f4f4f).\n * @cssprop --uva-color-link - Dark-mode role token: title link (else `--uva-brand-blue`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring on the card (else `--uva-brand-orange`).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: badge background (else `--uva-brand-blue`).\n * @cssprop --uva-color-on-accent - Text on the badge (else #fff).\n * @cssprop --uva-color-shadow - Dark-mode role token: hover shadow colour (else `--uva-grey-100`).\n */\nexport class UvalibCard extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n shadowSlotted,\n css`\n :host {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .card {\n background: var(--uva-color-surface-raised, #fff);\n border: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n border-radius: 0.3rem;\n transition: box-shadow 0.25s ease;\n }\n :host(:hover) .card,\n :host(:focus-within) .card {\n box-shadow: 0 0 20px 0 var(--uva-color-shadow, var(--uva-grey-100, #dadada));\n }\n /* The ring is on the card, not the heading link. :has() on .card sees the link\n in this tree; :host(:has()) would look outside the shadow root and miss it. */\n .card:has(.title-link:focus-visible) {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n .title-link:focus-visible {\n outline: none;\n }\n .body {\n padding: 1rem 1.25rem;\n flex: 1 1 auto;\n }\n /* Short heading: balanced lines. Longer excerpt: no one-word last line. Both are\n look, not structure (dropped with no-style), and ignored where unsupported. */\n .title {\n font-size: 1.25rem;\n line-height: 1.3;\n font-weight: 600;\n text-wrap: balance;\n }\n .excerpt {\n text-wrap: pretty;\n }\n .title-link {\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n font-weight: inherit;\n }\n .title-link:hover .title-text {\n text-decoration: underline;\n }\n .meta {\n color: var(--uva-color-text-muted, #4f4f4f);\n font-size: 0.875rem;\n }\n .chips {\n display: flex;\n flex-wrap: wrap;\n gap: 0.375rem;\n }\n .badge {\n inset-block-start: 0.5rem;\n inset-inline-start: 0.5rem;\n max-width: calc(100% - 1rem);\n padding: 0.15rem 0.5rem;\n border-radius: 0.25rem;\n background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n color: var(--uva-color-on-accent, #fff);\n font-size: 0.875rem;\n line-height: 1.4;\n }\n .media:has([data-region='badge']:not([hidden])) {\n min-height: 2.5rem;\n }\n @media (prefers-reduced-motion: reduce) {\n .card {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .card {\n background: Canvas;\n border-color: CanvasText;\n box-shadow: none;\n }\n :host(:hover) .card,\n :host(:focus-within) .card {\n box-shadow: none;\n }\n .card:has(.title-link:focus-visible) {\n outline-color: Highlight;\n }\n .badge {\n background: CanvasText;\n color: Canvas;\n }\n }\n `,\n // ::slotted is its own rule. Combining it with a light-DOM selector drops both in\n // engines that reject the whole rule when one selector is invalid.\n css`\n ::slotted(img),\n ::slotted(video) {\n display: block;\n width: 100%;\n height: auto;\n aspect-ratio: 3 / 2;\n object-fit: cover;\n }\n ::slotted(img.uvalib-circle),\n ::slotted(video.uvalib-circle) {\n width: 8rem;\n max-width: 100%;\n margin-inline: auto;\n aspect-ratio: 1;\n border-radius: 50%;\n object-fit: cover;\n }\n ::slotted([slot='chip']) {\n background: var(--uva-blue-alt-300, #bfe7f7);\n color: var(--uva-blue-alt-dark, #005679);\n border-radius: 999px;\n padding: 0.1rem 0.6rem;\n font-size: 0.875rem;\n line-height: 1.4;\n }\n `,\n css`\n [data-region='chip'] > * {\n background: var(--uva-blue-alt-300, #bfe7f7);\n color: var(--uva-blue-alt-dark, #005679);\n border-radius: 999px;\n padding: 0.1rem 0.6rem;\n font-size: 0.875rem;\n line-height: 1.4;\n }\n `,\n ];\n\n /** Makes the card one link: the heading stretches over the card. Empty is not a link. */\n @property({ type: String }) href?: string;\n\n /**\n * `circle` crops the media to a centered circle and keeps the image alt. Anything else\n * is ignored, with one console warning.\n */\n @property({ attribute: 'media-shape' }) mediaShape = '';\n\n /**\n * Heading level of the title, 1–6. Unset, it is one below the nearest heading before\n * this card, or 3 when there is none. Any other value is ignored.\n */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel?: number;\n\n /** One below the nearest preceding heading. A field, so the first render can use it. */\n private inferred = DEFAULT_LEVEL;\n private warnedHref = false;\n private warnedNested = false;\n private warnedHeading = false;\n private warnedShape = false;\n private observer?: MutationObserver;\n /** Author nodes captured before the first light-DOM render. */\n private saved: Node[] = [];\n /** Set once the author's children have been lifted off the host, including a reconnect before the first render. */\n private captured = false;\n /** Light DOM nodes this element rendered (Lit markers and the card), never author content. */\n private own = new WeakSet<Node>();\n private placing = false;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheets = [shadowStructure.styleSheet, shadowSlotted.styleSheet].filter(\n (sheet): sheet is CSSStyleSheet => !!sheet,\n );\n root.adoptedStyleSheets = sheets;\n }\n return root;\n }\n\n override connectedCallback(): void {\n const light = this.hasAttribute('no-shadow-dom') || this.noShadowDom;\n // Before super: the first update is a microtask, and a light-DOM render would drop\n // the author's children. On reconnect they are already parked in the card.\n // A grid may move the card (disconnect and reconnect) before the first render.\n // Capturing again would replace `saved` with an empty child list and drop the content.\n if (light && !this.hasUpdated && !this.captured) {\n this.captured = true;\n this.saved = [...this.childNodes];\n for (const n of this.saved) n.parentNode?.removeChild(n);\n }\n this.infer();\n super.connectedCallback();\n if (this.lightDom) {\n const node = this.getRootNode();\n const root = node instanceof ShadowRoot || node instanceof Document ? node : undefined;\n if (this.noStyle)\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n { root, scope: false },\n );\n installLightDomStyles(`${this.localName}::title-margin`, lightTitleMargin(this.localName), {\n root,\n scope: false,\n layer: false,\n });\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n // A grid assigns slot=\"card-N\". Left on the card, that name hides it inside\n // <site-page>, whose default slot only shows unslotted children.\n if (this.hasAttribute('data-grid-slot')) {\n this.removeAttribute('slot');\n this.removeAttribute('data-grid-slot');\n }\n }\n\n private get level(): number {\n const n = Math.trunc(this.headingLevel ?? Number.NaN);\n return n >= 1 && n <= 6 ? n : this.inferred;\n }\n\n /** The href when it may be a link; null when absent, blank or an unsafe scheme. */\n private get linkHref(): string | null {\n const raw = this.href ?? '';\n if (!raw.trim()) return null;\n return this.safe(raw.trim()) ? raw.trim() : null;\n }\n\n private infer(): void {\n if (!this.isConnected) return;\n const above = precedingHeadingLevel(this);\n const next = above === null ? DEFAULT_LEVEL : Math.min(above + 1, 6);\n this.inferred = next;\n }\n\n private safe(href: string): boolean {\n let ok = false;\n try {\n ok = SAFE_SCHEMES.has(new URL(href, this.ownerDocument.baseURI).protocol);\n } catch {\n ok = false;\n }\n if (!ok && !this.warnedHref) {\n this.warnedHref = true;\n console.warn(\n `${this.localName}: not linking a card whose href is not http(s), mailto, tel or relative.`,\n );\n }\n return ok;\n }\n\n /** A named shadow slot, or nothing in light DOM (the regions are filled by moving nodes). */\n private renderSlot(name?: string) {\n if (this.lightDom) return nothing;\n return name\n ? html`<slot name=${name} @slotchange=${this.onSlotChange}></slot>`\n : html`<slot @slotchange=${this.onSlotChange}></slot>`;\n }\n\n private onSlotChange = (): void => {\n this.syncShape();\n this.syncHidden();\n this.warnNested();\n };\n\n /** `::slotted` cannot see a host attribute, so the circle image carries a class. */\n private syncShape(): void {\n const circle = this.mediaShape.trim().toLowerCase() === 'circle';\n for (const el of this.querySelectorAll('img, video')) {\n if (!(el instanceof HTMLElement)) continue;\n const inMedia = el.getAttribute('slot') === 'media' || !!el.closest('[data-region=\"media\"]');\n el.classList.toggle('uvalib-circle', circle && inMedia);\n }\n }\n\n /** Place among the cards of the nearest grid, from 1, or `'single'` when there is none. */\n private position(): { name: string; value?: number } {\n const grid = this.closest('uvalib-card-grid');\n if (!grid) return { name: 'single' };\n const direct = [...grid.querySelectorAll(':scope > uvalib-card')];\n const cards = direct.length\n ? direct\n : [...grid.querySelectorAll(':scope > ul > li > uvalib-card')];\n const index = cards.indexOf(this);\n if (index < 0) return { name: 'single' };\n return { name: String(index + 1), value: index + 1 };\n }\n\n /**\n * A plain primary-button click on the card link fires a cancelable `uvalib-card-navigate`.\n * A click that was already canceled, or that is not the primary button, is ignored.\n * Modified clicks are tracked and do not fire the navigate event.\n */\n private onClick(e: MouseEvent): void {\n const node = e.target instanceof Node ? e.target : null;\n const el = node instanceof Element ? node : node?.parentElement;\n const a = el?.closest('a.title-link');\n if (!a || !this.renderRoot.contains(a)) return;\n if (e.defaultPrevented || e.button !== 0) return;\n const pos = this.position();\n trackEvent(\n this,\n pos.value === undefined\n ? ['uvalib-card', 'card-click', pos.name]\n : ['uvalib-card', 'card-click', pos.name, pos.value],\n );\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n const go = new CustomEvent('uvalib-card-navigate', {\n detail: { href: a.getAttribute('href'), position: pos.name },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n private sourceEl(): HTMLElement | null {\n return this.renderRoot.querySelector('.card-source');\n }\n\n private regions(): HTMLElement[] {\n return [...this.renderRoot.querySelectorAll<HTMLElement>('[data-region]')];\n }\n\n /** Move light-DOM region children back to the source before Lit may recreate the heading. */\n private reclaim(): void {\n const source = this.sourceEl();\n if (!source) return;\n for (const region of this.regions()) {\n while (region.firstChild) source.appendChild(region.firstChild);\n }\n }\n\n /** Author nodes appended to the host later, not the nodes this element rendered. */\n private ingest(): void {\n const source = this.sourceEl();\n if (!source) return;\n const incoming = [...this.childNodes].filter((n) => !this.own.has(n) && n !== source);\n if (incoming.length) source.append(...incoming);\n }\n\n private hasContent(n: Node): boolean {\n if (n.nodeType === Node.TEXT_NODE) return !!n.textContent?.trim();\n if (n instanceof Element) {\n if (n.matches('img, svg, picture, video')) return true;\n return !!n.textContent?.trim() || !!n.querySelector('img, svg, picture, video');\n }\n return false;\n }\n\n /**\n * An accessible name: trimmed text (including an `svg` `title`), or a non-empty\n * `alt` / `aria-label`. An `img` with `alt=\"\"` does not count.\n */\n private hasName(n: Node): boolean {\n if (n.nodeType === Node.TEXT_NODE) return !!n.textContent?.trim();\n if (!(n instanceof Element)) return false;\n const own = n.getAttribute('alt')?.trim() || n.getAttribute('aria-label')?.trim();\n if (own) return true;\n if (n.textContent?.trim()) return true;\n return [...n.querySelectorAll('[alt], [aria-label]')].some(\n (el) => !!(el.getAttribute('alt')?.trim() || el.getAttribute('aria-label')?.trim()),\n );\n }\n\n private isEmpty(region: Element | null): boolean {\n if (!region) return true;\n // Only the heading needs a name. A decorative media image (`alt=\"\"`) still counts.\n const named = region.getAttribute('data-region') === 'heading';\n const filled = (n: Node) => (named ? this.hasName(n) : this.hasContent(n));\n if (!this.lightDom) {\n const slot = region.querySelector('slot');\n const nodes = slot ? slot.assignedNodes({ flatten: true }) : [...region.childNodes];\n return !nodes.some(filled);\n }\n return ![...region.childNodes].some(filled);\n }\n\n /** Shadow slots can still be empty on the first update, before the browser assigns them. */\n private headingPending(): boolean {\n if (this.lightDom) return false;\n const slot = this.renderRoot.querySelector('[data-region=\"heading\"] slot');\n if (!(slot instanceof HTMLSlotElement) || slot.assignedNodes({ flatten: true }).length > 0)\n return false;\n return [...this.childNodes].some(\n (n) => n instanceof Element && n.getAttribute('slot') === 'heading' && this.hasName(n),\n );\n }\n\n private warnEmptyHeading(): void {\n if (!this.linkHref || this.warnedHeading || this.headingPending()) return;\n this.warnedHeading = true;\n console.warn(\n `${this.localName}: a clickable card (one with href) has a heading with no accessible name, so its link is hidden.`,\n );\n }\n\n /** Put each author node in the region its slot names; the rest is the excerpt. */\n private distribute(): void {\n const source = this.sourceEl();\n if (!source) return;\n const byName = new Map<string, HTMLElement>();\n for (const region of this.regions()) {\n const name = region.dataset.region;\n if (name) byName.set(name, region);\n }\n const excerpt = byName.get('excerpt');\n for (const n of [...source.childNodes]) {\n if (n.nodeType === Node.COMMENT_NODE) continue;\n if (n.nodeType === Node.TEXT_NODE && !n.textContent?.trim()) continue;\n const slot = n instanceof Element ? n.getAttribute('slot') : null;\n const dest = (slot && byName.get(slot)) || excerpt;\n if (dest) dest.appendChild(n);\n }\n }\n\n private syncHidden(): void {\n const root = this.renderRoot;\n for (const region of this.regions()) {\n const empty = this.isEmpty(region);\n region.toggleAttribute('hidden', empty);\n if (region.dataset.region === 'heading') {\n region.closest('.title')?.toggleAttribute('hidden', empty);\n if (empty) this.warnEmptyHeading();\n }\n }\n const media = root.querySelector('.media');\n if (media instanceof HTMLElement) {\n const empty =\n this.isEmpty(root.querySelector('[data-region=\"media\"]')) &&\n this.isEmpty(root.querySelector('[data-region=\"badge\"]'));\n media.toggleAttribute('hidden', empty);\n }\n }\n\n private warnShape(): void {\n const value = this.mediaShape.trim().toLowerCase();\n if (!value || value === 'circle' || this.warnedShape) return;\n this.warnedShape = true;\n console.warn(\n `${this.localName}: media-shape \"${this.mediaShape.trim()}\" is not supported. Use \"circle\".`,\n );\n }\n\n private warnNested(): void {\n if (!this.linkHref || this.warnedNested) return;\n const nested = [\n ...this.querySelectorAll(\n 'a[href], button, input:not([type=\"hidden\"]), select, textarea, summary, [role=\"button\"], [role=\"link\"], [tabindex]:not([tabindex=\"-1\"])',\n ),\n ].filter((n) => !n.classList.contains('title-link'));\n if (!nested.length) return;\n this.warnedNested = true;\n console.warn(\n `${this.localName}: a clickable card (one with href) must not contain other links, buttons or controls; the card link covers them. Use a static card for an actions row.`,\n );\n }\n\n private arm(): void {\n if (!this.lightDom) return;\n this.observer ??= new MutationObserver(() => this.onAuthorChange());\n const source = this.sourceEl();\n const card = this.renderRoot.querySelector('.card');\n if (source) this.observer.observe(source, CONTENT);\n if (card) this.observer.observe(card, CONTENT);\n this.observer.observe(this, { childList: true });\n }\n\n private onAuthorChange(): void {\n if (this.placing || !this.lightDom) return;\n this.placing = true;\n this.observer?.disconnect();\n try {\n this.ingest();\n this.reclaim();\n this.distribute();\n this.syncShape();\n this.syncHidden();\n this.warnNested();\n } finally {\n this.placing = false;\n this.arm();\n }\n }\n\n protected override willUpdate(): void {\n this.infer();\n this.warnShape();\n if (this.lightDom && this.hasUpdated && !this.placing) {\n this.observer?.disconnect();\n this.reclaim();\n }\n }\n\n protected override firstUpdated(): void {\n if (this.lightDom) for (const n of this.childNodes) this.own.add(n);\n }\n\n protected override updated(): void {\n this.syncShape();\n if (!this.lightDom) {\n this.syncHidden();\n this.warnNested();\n return;\n }\n if (this.placing) return;\n this.placing = true;\n this.observer?.disconnect();\n try {\n const source = this.sourceEl();\n if (source && this.saved.length) {\n source.append(...this.saved);\n this.saved = [];\n }\n this.ingest();\n this.distribute();\n this.syncShape();\n this.syncHidden();\n this.warnNested();\n } finally {\n this.placing = false;\n this.arm();\n }\n }\n\n private headingEl(inner: unknown) {\n const tag = unsafeStatic(`h${this.level}`);\n const href = this.linkHref;\n if (href)\n return staticHtml`<${tag} class=\"title\"><a class=\"title-link\" href=${href}>${inner}${arrow}</a></${tag}>`;\n return staticHtml`<${tag} class=\"title\">${inner}</${tag}>`;\n }\n\n protected override render() {\n const heading = html`<span class=\"title-text\" data-region=\"heading\"\n >${this.renderSlot('heading')}</span\n >`;\n return html`${this.lightDom ? html`<div class=\"card-source\" hidden></div>` : nothing}\n <div class=\"card\" @click=${this.onClick}>\n <div class=\"media\">\n <div data-region=\"media\">${this.renderSlot('media')}</div>\n <div class=\"badge\" data-region=\"badge\">${this.renderSlot('badge')}</div>\n </div>\n <div class=\"body\">\n ${this.headingEl(heading)}\n <div class=\"meta\" data-region=\"meta\">${this.renderSlot('meta')}</div>\n <div class=\"chips\" data-region=\"chip\">${this.renderSlot('chip')}</div>\n <div class=\"excerpt\" data-region=\"excerpt\">${this.renderSlot()}</div>\n <div class=\"actions\" data-region=\"actions\">${this.renderSlot('actions')}</div>\n </div>\n </div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibCard } from './UvalibCard.js';\n\ndefine('uvalib-card', UvalibCard);\n"],"mappings":";;;;;;AASA,IAAMmB,IAAgB,GAGhBC,oBAAe,IAAI,IAAI;CAAC;CAAS;CAAU;CAAW;AAAM,CAAC,GAQ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A,SAA4B;EAC1B,IAAMqC,IAAU,CAAI;SACf,KAAK,WAAW,SAAS,EAAE;;EAEhC,OAAO,CAAI,GAAG,KAAK,WAAW,CAAI,2CAA2ChE,EAAQ;iCACxD,KAAK,QAAQ;;qCAET,KAAK,WAAW,OAAO,EAAE;mDACX,KAAK,WAAW,OAAO,EAAE;;;YAGhE,KAAK,UAAUgE,CAAO,EAAE;iDACa,KAAK,WAAW,MAAM,EAAE;kDACvB,KAAK,WAAW,MAAM,EAAE;uDACnB,KAAK,WAAW,EAAE;uDAClB,KAAK,WAAW,SAAS,EAAE;;;CAGhF;AACF;;AAjaG9D,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA2B,EAAA,WAAA,QAAA,KAAA,CAAA,GAMzB5B,EAAA,CAAAC,EAAS,EAAE,WAAW,cAAc,CAAC,CAAA,GAAA2B,EAAA,WAAA,cAAA,KAAA,CAAA,GAMrC5B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAgB,CAAC,CAAA,GAAA2B,EAAA,WAAA,gBAAA,KAAA,CAAA,GCvWxDvB,EAAO,eAAeuB,CAAU"}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { a as e, d as t, f as n, i as r, l as i, m as a, n as o, o as s, p as c, r as l, t as u } from "./chunks/UvalibElement-pGONDAwB.js";
|
|
2
2
|
import { a as d, i as f } from "./chunks/analytics-DTTihuBD.js";
|
|
3
|
-
import { n as p
|
|
4
|
-
import { t as h } from "./chunks/
|
|
3
|
+
import { n as p } from "./chunks/states-DGXGzcte.js";
|
|
4
|
+
import { n as m, t as h } from "./chunks/source-children-BHsDwCvL.js";
|
|
5
|
+
import { t as g } from "./chunks/accessible-DJv7YOtS.js";
|
|
5
6
|
// src/components/uvalib-combobox/UvalibCombobox.ts
|
|
6
|
-
var
|
|
7
|
+
var _ = {
|
|
7
8
|
debounce: 250,
|
|
8
9
|
announce: 500
|
|
9
|
-
},
|
|
10
|
-
function
|
|
10
|
+
}, v = "(anchor-name: --a) and (position-try-fallbacks: flip-block) and (inline-size: anchor-size(inline))";
|
|
11
|
+
function y() {
|
|
12
|
+
try {
|
|
13
|
+
return typeof HTMLElement < "u" && Object.hasOwn(HTMLElement.prototype, "popover") && typeof CSS < "u" && CSS.supports(v);
|
|
14
|
+
} catch {
|
|
15
|
+
return !1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
var b = { topLayer: y() }, x = "uvalib-combobox", S = 5e3, C = 30, w = 0, T = /\p{M}/gu, E = (e) => e.normalize("NFD").replace(T, "").toLowerCase();
|
|
19
|
+
function D(e) {
|
|
11
20
|
let t = "", n = [], r = 0;
|
|
12
21
|
for (let i of e) {
|
|
13
|
-
let e =
|
|
22
|
+
let e = E(i);
|
|
14
23
|
for (let t = 0; t < e.length; t++) n.push(r);
|
|
15
24
|
t += e, r += i.length;
|
|
16
25
|
}
|
|
@@ -19,15 +28,15 @@ function C(e) {
|
|
|
19
28
|
map: n
|
|
20
29
|
};
|
|
21
30
|
}
|
|
22
|
-
var
|
|
23
|
-
function
|
|
31
|
+
var O = /[\p{L}\p{N}]/u;
|
|
32
|
+
function k(e) {
|
|
24
33
|
if (typeof e == "string" || typeof e == "number") {
|
|
25
|
-
let t =
|
|
34
|
+
let t = m(e);
|
|
26
35
|
return t ? {
|
|
27
36
|
value: t,
|
|
28
37
|
label: t,
|
|
29
38
|
disabled: !1,
|
|
30
|
-
fold:
|
|
39
|
+
fold: E(t),
|
|
31
40
|
raw: {
|
|
32
41
|
value: t,
|
|
33
42
|
label: t
|
|
@@ -35,18 +44,18 @@ function T(e) {
|
|
|
35
44
|
} : null;
|
|
36
45
|
}
|
|
37
46
|
if (!e || typeof e != "object") return null;
|
|
38
|
-
let t = e, n =
|
|
47
|
+
let t = e, n = m(t.label ?? t.value);
|
|
39
48
|
if (!n) return null;
|
|
40
49
|
let r = {
|
|
41
50
|
value: String(t.value ?? n),
|
|
42
51
|
label: n,
|
|
43
52
|
disabled: !!t.disabled,
|
|
44
|
-
fold:
|
|
53
|
+
fold: E(n),
|
|
45
54
|
raw: t
|
|
46
|
-
}, i =
|
|
55
|
+
}, i = m(t.description);
|
|
47
56
|
return i && (r.description = i), r;
|
|
48
57
|
}
|
|
49
|
-
var
|
|
58
|
+
var A = (e) => Array.isArray(e) ? e.map(k).filter((e) => e !== null) : [], j = (e) => e.toLocaleString("en-US"), M = (e) => `
|
|
50
59
|
${e} { display: block; max-width: 100%; line-height: 1.5; }
|
|
51
60
|
${e} .label { display: block; margin-block-end: 0.25rem; }
|
|
52
61
|
${e} .field { position: relative; }
|
|
@@ -85,6 +94,21 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
85
94
|
overflow-y: auto;
|
|
86
95
|
overscroll-behavior: contain;
|
|
87
96
|
}
|
|
97
|
+
/* Where supported, the popup is a manual popover in the top layer, so no ancestor's
|
|
98
|
+
overflow clips it: anchored under the field, as wide as it, above it when there is no
|
|
99
|
+
room below. Elsewhere it stays absolutely positioned (no popover attribute). */
|
|
100
|
+
@supports ${v} {
|
|
101
|
+
${e} .popup[popover] {
|
|
102
|
+
position: fixed;
|
|
103
|
+
inset: auto;
|
|
104
|
+
inline-size: anchor-size(inline);
|
|
105
|
+
max-inline-size: 100vw;
|
|
106
|
+
margin: 0;
|
|
107
|
+
margin-block-start: 2px;
|
|
108
|
+
position-area: block-end span-inline-end;
|
|
109
|
+
position-try-fallbacks: flip-block;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
88
112
|
${e} .listbox { margin: 0; padding: 0; list-style: none; }
|
|
89
113
|
${e} .option {
|
|
90
114
|
display: flex;
|
|
@@ -110,7 +134,7 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
110
134
|
border: 0;
|
|
111
135
|
}
|
|
112
136
|
${e}[hidden], ${e} [hidden] { display: none !important; }
|
|
113
|
-
`,
|
|
137
|
+
`, N = c(M(":host")), P = c("var(--uva-color-control-border, var(--uva-grey, #808080))"), F = c("var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))"), I = c("var(--uva-color-text-muted, var(--uva-grey-A, #4f4f4f))"), L = c("var(--uva-color-input-text, var(--uva-grey-darkest, #2b2b2b))"), R = c("var(--uva-color-surface-raised, #ffffff)"), z = t`<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" focusable="false"><path d="M4 4l8 8M12 4l-8 8" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`, B = class extends u {
|
|
114
138
|
static {
|
|
115
139
|
this.formAssociated = !0;
|
|
116
140
|
}
|
|
@@ -122,8 +146,8 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
122
146
|
}
|
|
123
147
|
static {
|
|
124
148
|
this.styles = [
|
|
125
|
-
|
|
126
|
-
|
|
149
|
+
g,
|
|
150
|
+
N,
|
|
127
151
|
n`
|
|
128
152
|
.label {
|
|
129
153
|
font-weight: 600;
|
|
@@ -131,18 +155,18 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
131
155
|
.input {
|
|
132
156
|
padding-block: 0.5rem;
|
|
133
157
|
padding-inline-start: 0.75rem;
|
|
134
|
-
border: 1px solid ${
|
|
158
|
+
border: 1px solid ${P};
|
|
135
159
|
border-radius: 5px;
|
|
136
|
-
background: ${
|
|
137
|
-
color: ${
|
|
160
|
+
background: ${R};
|
|
161
|
+
color: ${L};
|
|
138
162
|
}
|
|
139
163
|
.input::placeholder {
|
|
140
|
-
color: ${
|
|
164
|
+
color: ${I};
|
|
141
165
|
opacity: 1;
|
|
142
166
|
}
|
|
143
167
|
.input:disabled {
|
|
144
168
|
background: var(--uva-color-track, var(--uva-grey-200, #f1f1f1));
|
|
145
|
-
color: ${
|
|
169
|
+
color: ${I};
|
|
146
170
|
cursor: not-allowed;
|
|
147
171
|
}
|
|
148
172
|
.input[aria-invalid='true'] {
|
|
@@ -152,20 +176,21 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
152
176
|
border: 0;
|
|
153
177
|
border-radius: 5px;
|
|
154
178
|
background: none;
|
|
155
|
-
color: ${
|
|
179
|
+
color: ${I};
|
|
156
180
|
}
|
|
157
181
|
.clear:hover {
|
|
158
|
-
color: ${
|
|
182
|
+
color: ${L};
|
|
159
183
|
}
|
|
160
184
|
.clear:focus-visible {
|
|
161
185
|
outline-offset: -4px;
|
|
162
186
|
}
|
|
163
187
|
.popup {
|
|
164
188
|
padding-block: 0.25rem;
|
|
165
|
-
|
|
189
|
+
padding-inline: 0;
|
|
190
|
+
border: 1px solid ${P};
|
|
166
191
|
border-radius: 5px;
|
|
167
|
-
background: ${
|
|
168
|
-
color: ${
|
|
192
|
+
background: ${R};
|
|
193
|
+
color: ${L};
|
|
169
194
|
box-shadow: 0 4px 12px var(--uva-color-shadow, rgba(0, 0, 0, 0.2));
|
|
170
195
|
}
|
|
171
196
|
.option {
|
|
@@ -177,17 +202,17 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
177
202
|
}
|
|
178
203
|
/* The active suggestion: a fill, a bar at the start and an outline, never colour alone. */
|
|
179
204
|
.option[aria-selected='true'] {
|
|
180
|
-
border-inline-start-color: ${
|
|
205
|
+
border-inline-start-color: ${F};
|
|
181
206
|
background: var(--uva-color-surface-hover, var(--uva-grey-100, #dadada));
|
|
182
|
-
outline: 2px solid ${
|
|
207
|
+
outline: 2px solid ${F};
|
|
183
208
|
outline-offset: -2px;
|
|
184
209
|
}
|
|
185
210
|
.option[aria-disabled='true'] {
|
|
186
|
-
color: ${
|
|
211
|
+
color: ${I};
|
|
187
212
|
font-style: italic;
|
|
188
213
|
}
|
|
189
214
|
.option-description {
|
|
190
|
-
color: ${
|
|
215
|
+
color: ${I};
|
|
191
216
|
font-size: 0.875em;
|
|
192
217
|
}
|
|
193
218
|
mark {
|
|
@@ -199,10 +224,10 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
199
224
|
}
|
|
200
225
|
.message {
|
|
201
226
|
padding: 0.625rem 0.75rem;
|
|
202
|
-
color: ${
|
|
227
|
+
color: ${I};
|
|
203
228
|
}
|
|
204
229
|
.description {
|
|
205
|
-
color: ${
|
|
230
|
+
color: ${I};
|
|
206
231
|
}
|
|
207
232
|
@media (forced-colors: active) {
|
|
208
233
|
.input,
|
|
@@ -230,15 +255,15 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
230
255
|
];
|
|
231
256
|
}
|
|
232
257
|
constructor() {
|
|
233
|
-
super(), this.label = "", this.description = "", this.placeholder = "", this.name = "", this.value = "", this.selected = null, this.src = "", this.minLength = 1, this.maxResults = 50, this.mustChoose = !1, this.required = !1, this.disabled = !1, this.open = !1, this.active = -1, this.shown = [], this.total = 0, this.loading = "idle", this.announcement = "", this.formDisabled = !1, this.invalidShown = !1, this.childEntries = [], this.uid = `${
|
|
258
|
+
super(), this.label = "", this.description = "", this.placeholder = "", this.name = "", this.value = "", this.selected = null, this.src = "", this.minLength = 1, this.maxResults = 50, this.mustChoose = !1, this.required = !1, this.disabled = !1, this.open = !1, this.active = -1, this.shown = [], this.total = 0, this.loading = "idle", this.announcement = "", this.formDisabled = !1, this.invalidShown = !1, this.childEntries = [], this.uid = `${x}-${++w}`, this.warned = /* @__PURE__ */ new Set(), this.committed = {
|
|
234
259
|
value: "",
|
|
235
260
|
item: null
|
|
236
|
-
}, this.remote = [], this.cache = /* @__PURE__ */ new Map(), this.lastAnnounced = "", this.adopted = /* @__PURE__ */ new WeakSet(), this.started = !1, this.internals = this.attachInternals(), new
|
|
261
|
+
}, this.remote = [], this.cache = /* @__PURE__ */ new Map(), this.lastAnnounced = "", this.adopted = /* @__PURE__ */ new WeakSet(), this.started = !1, this.topLayer = b.topLayer, this.internals = this.attachInternals(), new h(this, () => this.lightDom, (e) => this.read(e));
|
|
237
262
|
}
|
|
238
263
|
createRenderRoot() {
|
|
239
264
|
let e = super.createRenderRoot();
|
|
240
265
|
if (e instanceof ShadowRoot && this.noStyle) {
|
|
241
|
-
let t =
|
|
266
|
+
let t = N.styleSheet;
|
|
242
267
|
t && (e.adoptedStyleSheets = [t]);
|
|
243
268
|
}
|
|
244
269
|
return e;
|
|
@@ -246,7 +271,7 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
246
271
|
connectedCallback() {
|
|
247
272
|
if (super.connectedCallback(), this.lightDom && this.noStyle) {
|
|
248
273
|
let e = this.getRootNode();
|
|
249
|
-
l(`${this.localName}::structure`, c(
|
|
274
|
+
l(`${this.localName}::structure`, c(M(this.localName)), {
|
|
250
275
|
root: e instanceof ShadowRoot || e instanceof Document ? e : void 0,
|
|
251
276
|
scope: !1
|
|
252
277
|
});
|
|
@@ -307,8 +332,8 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
307
332
|
read(e) {
|
|
308
333
|
let t = [];
|
|
309
334
|
for (let n of e) n instanceof HTMLOptionElement ? t.push(n) : n instanceof HTMLDataListElement ? t.push(...n.options) : n instanceof HTMLInputElement && (this.adopt(n), n.list && !e.includes(n.list) && t.push(...n.list.options));
|
|
310
|
-
let n =
|
|
311
|
-
let t =
|
|
335
|
+
let n = A(t.map((e) => {
|
|
336
|
+
let t = m(e.getAttribute("label") ?? e.textContent) || e.value, n = {
|
|
312
337
|
value: e.value || t,
|
|
313
338
|
label: t
|
|
314
339
|
}, r = e.getAttribute("data-description");
|
|
@@ -320,13 +345,13 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
320
345
|
this.adopted.has(e) || (this.adopted.add(e), !this.name && e.name && (this.name = e.name), !this.placeholder && e.placeholder && (this.placeholder = e.placeholder), !this.value && e.value && this.setOwn(e.value, null), e.disabled = !0);
|
|
321
346
|
}
|
|
322
347
|
get local() {
|
|
323
|
-
return this.items ? (this.items !== this.itemsSource && (this.itemsSource = this.items, this.itemEntries =
|
|
348
|
+
return this.items ? (this.items !== this.itemsSource && (this.itemsSource = this.items, this.itemEntries = A(this.items)), this.itemEntries) : this.childEntries;
|
|
324
349
|
}
|
|
325
350
|
get query() {
|
|
326
|
-
let e =
|
|
351
|
+
let e = m(this.value);
|
|
327
352
|
return {
|
|
328
353
|
text: e,
|
|
329
|
-
folded:
|
|
354
|
+
folded: E(e)
|
|
330
355
|
};
|
|
331
356
|
}
|
|
332
357
|
get max() {
|
|
@@ -348,7 +373,7 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
348
373
|
let t = a.fold.indexOf(e);
|
|
349
374
|
if (t < 0) continue;
|
|
350
375
|
i++;
|
|
351
|
-
let o = t === 0 ? 0 :
|
|
376
|
+
let o = t === 0 ? 0 : O.test(a.fold[t - 1]) ? 2 : 1;
|
|
352
377
|
r[o].length < n && r[o].push(a);
|
|
353
378
|
}
|
|
354
379
|
this.shown = r.flat().slice(0, n), this.total = i;
|
|
@@ -362,7 +387,7 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
362
387
|
request(e) {
|
|
363
388
|
this.cancelFetch();
|
|
364
389
|
let t = this.cache.get(e);
|
|
365
|
-
t ? this.showRemote(e, t) : (this.loading = "loading", this.fetchTimer = setTimeout(() => void this.load(e),
|
|
390
|
+
t ? this.showRemote(e, t) : (this.loading = "loading", this.fetchTimer = setTimeout(() => void this.load(e), _.debounce));
|
|
366
391
|
}
|
|
367
392
|
async load(e) {
|
|
368
393
|
let t = new AbortController();
|
|
@@ -377,12 +402,12 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
377
402
|
let i = await r.json(), a = this.transform ? this.transform(i, e) : i;
|
|
378
403
|
if (!Array.isArray(a)) throw Error("the response is not an array");
|
|
379
404
|
if (t.signal.aborted) return;
|
|
380
|
-
let o =
|
|
381
|
-
if (this.cache.set(e, o), this.cache.size >
|
|
405
|
+
let o = A(a);
|
|
406
|
+
if (this.cache.set(e, o), this.cache.size > C && this.cache.delete(this.cache.keys().next().value), this.query.text !== e) return;
|
|
382
407
|
this.showRemote(e, o), this.active = -1;
|
|
383
408
|
} catch (e) {
|
|
384
409
|
if (t.signal.aborted) return;
|
|
385
|
-
this.loading = "error", this.shown = [], this.total = 0, this.remoteQuery = void 0, this.warnOnce("load", `couldn't load suggestions (${e.message}).`), f(this,
|
|
410
|
+
this.loading = "error", this.shown = [], this.total = 0, this.remoteQuery = void 0, this.warnOnce("load", `couldn't load suggestions (${e.message}).`), f(this, x, "load");
|
|
386
411
|
} finally {
|
|
387
412
|
this.abort === t && (this.abort = void 0);
|
|
388
413
|
}
|
|
@@ -448,7 +473,7 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
448
473
|
choose(e) {
|
|
449
474
|
let t = this.shown[e];
|
|
450
475
|
t && !t.disabled && (this.cancelFetch(), this.setOwn(t.label, t.raw), this.close(), this.invalidShown = !1, this.emit("select", { item: t.raw }), d(this, [
|
|
451
|
-
|
|
476
|
+
x,
|
|
452
477
|
"select",
|
|
453
478
|
this.label.trim(),
|
|
454
479
|
e + 1
|
|
@@ -456,13 +481,13 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
456
481
|
}
|
|
457
482
|
clear() {
|
|
458
483
|
this.cancelFetch(), this.loading = "idle", this.setOwn("", null), this.close(), d(this, [
|
|
459
|
-
|
|
484
|
+
x,
|
|
460
485
|
"clear",
|
|
461
486
|
this.label.trim()
|
|
462
487
|
]), this.commit(), this.focus();
|
|
463
488
|
}
|
|
464
489
|
onInput(e) {
|
|
465
|
-
let t = e.target.value, n = this.selected && t ===
|
|
490
|
+
let t = e.target.value, n = this.selected && t === m(this.selected.label ?? this.selected.value);
|
|
466
491
|
this.setOwn(t, n ? this.selected : null), this.invalidShown = !1, this.active = -1, this.query.text.length < this.minLength ? (this.cancelFetch(), this.loading = "idle", this.close()) : (this.refresh(), this.open = !0);
|
|
467
492
|
}
|
|
468
493
|
onKeydown(e) {
|
|
@@ -513,11 +538,11 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
513
538
|
};
|
|
514
539
|
let e = this.shown.length;
|
|
515
540
|
return e ? this.total > e ? {
|
|
516
|
-
visible: `Showing ${
|
|
517
|
-
spoken: `${
|
|
541
|
+
visible: `Showing ${j(e)} of ${j(this.total)}. Type more to narrow them.`,
|
|
542
|
+
spoken: `${j(e)} of ${j(this.total)} suggestions`
|
|
518
543
|
} : {
|
|
519
544
|
visible: "",
|
|
520
|
-
spoken: `${
|
|
545
|
+
spoken: `${j(e)} suggestion${e === 1 ? "" : "s"}`
|
|
521
546
|
} : {
|
|
522
547
|
visible: "No suggestions",
|
|
523
548
|
spoken: "No suggestions"
|
|
@@ -528,17 +553,17 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
528
553
|
let e = this.open ? this.note.spoken : "";
|
|
529
554
|
e ? e !== this.lastAnnounced && (this.announceTimer = setTimeout(() => {
|
|
530
555
|
let e = this.open ? this.note.spoken : "";
|
|
531
|
-
e && e !== this.lastAnnounced && (this.lastAnnounced = e, this.announcement = e, clearTimeout(this.clearTimer), this.clearTimer = setTimeout(() => this.announcement = "",
|
|
532
|
-
},
|
|
556
|
+
e && e !== this.lastAnnounced && (this.lastAnnounced = e, this.announcement = e, clearTimeout(this.clearTimer), this.clearTimer = setTimeout(() => this.announcement = "", S));
|
|
557
|
+
}, _.announce)) : this.lastAnnounced = "";
|
|
533
558
|
}
|
|
534
559
|
willUpdate(e) {
|
|
535
560
|
if (this.label.trim() || this.warnOnce("label", "set label: the field needs a visible label."), e.has("selected") && this.selected !== this.ownSelected) {
|
|
536
|
-
let e = this.selected, t = e == null ? null :
|
|
561
|
+
let e = this.selected, t = e == null ? null : k(e);
|
|
537
562
|
this.selected = this.ownSelected = t ? t.raw : null, t && (this.value = this.ownValue = t.label), this.committed = {
|
|
538
563
|
value: this.value,
|
|
539
564
|
item: this.selected
|
|
540
565
|
};
|
|
541
|
-
} else e.has("value") && this.value !== this.ownValue && (this.value = this.ownValue = String(this.value ?? ""), this.selected && this.value !==
|
|
566
|
+
} else e.has("value") && this.value !== this.ownValue && (this.value = this.ownValue = String(this.value ?? ""), this.selected && this.value !== m(this.selected.label ?? this.selected.value) && (this.selected = this.ownSelected = null), this.committed = {
|
|
542
567
|
value: this.value,
|
|
543
568
|
item: this.selected
|
|
544
569
|
});
|
|
@@ -547,17 +572,30 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
547
572
|
updated(e) {
|
|
548
573
|
super.updated(e);
|
|
549
574
|
let t = this.input;
|
|
550
|
-
t && t.value !== this.value && (t.value = this.value), this.started ? ((e.has("value") || e.has("selected") || e.has("required") || e.has("mustChoose")) && this.updateForm(), (e.has("open") || e.has("shown") || e.has("total") || e.has("loading")) && this.scheduleAnnouncement(), e.has("active") && this.active >= 0 && this.reveal()) : (this.started = !0, this.updateForm());
|
|
575
|
+
t && t.value !== this.value && (t.value = this.value), this.started ? ((e.has("value") || e.has("selected") || e.has("required") || e.has("mustChoose")) && this.updateForm(), (e.has("open") || e.has("shown") || e.has("total") || e.has("loading")) && this.scheduleAnnouncement(), this.syncPopup(), e.has("active") && this.active >= 0 && this.reveal()) : (this.started = !0, this.updateForm());
|
|
576
|
+
}
|
|
577
|
+
get popup() {
|
|
578
|
+
return this.renderRoot.querySelector(".popup");
|
|
579
|
+
}
|
|
580
|
+
syncPopup() {
|
|
581
|
+
let e = this.popup, t = !!e && !e.hidden;
|
|
582
|
+
if (p(this.internals, "open", t), p(this.internals, "invalid", this.invalidShown), p(this.internals, "loading", this.loading === "loading"), !this.topLayer || !e) return;
|
|
583
|
+
let n = `--${this.uid}`, r = this.input;
|
|
584
|
+
r && r.style.getPropertyValue("anchor-name") !== n && (r.style.setProperty("anchor-name", n), e.style.setProperty("position-anchor", n));
|
|
585
|
+
let i = e.matches(":popover-open");
|
|
586
|
+
try {
|
|
587
|
+
t && !i && this.isConnected ? e.showPopover() : !t && i && e.hidePopover();
|
|
588
|
+
} catch {}
|
|
551
589
|
}
|
|
552
590
|
reveal() {
|
|
553
|
-
let e = this.
|
|
591
|
+
let e = this.popup, t = this.renderRoot.querySelector(`#${this.uid}-opt-${this.active}`);
|
|
554
592
|
if (!e || !t) return;
|
|
555
593
|
let n = t.offsetTop, r = n + t.offsetHeight;
|
|
556
594
|
n < e.scrollTop ? e.scrollTop = n : r > e.scrollTop + e.clientHeight && (e.scrollTop = r - e.clientHeight);
|
|
557
595
|
}
|
|
558
596
|
marked(e, t) {
|
|
559
597
|
if (!t) return e;
|
|
560
|
-
let { text: n, map: r } =
|
|
598
|
+
let { text: n, map: r } = D(e), a = [], o = 0, s = 0;
|
|
561
599
|
for (let c = n.indexOf(t); c !== -1; c = n.indexOf(t, s)) {
|
|
562
600
|
let n = r[c], l = r[c + t.length];
|
|
563
601
|
n > o && a.push(e.slice(o, n)), a.push(i`<mark>${e.slice(n, l)}</mark>`), o = l, s = c + t.length;
|
|
@@ -603,11 +641,12 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
603
641
|
@mousedown=${(e) => e.preventDefault()}
|
|
604
642
|
@click=${this.clear}
|
|
605
643
|
>
|
|
606
|
-
${
|
|
644
|
+
${z}
|
|
607
645
|
</button>
|
|
608
646
|
<div
|
|
609
647
|
class="popup"
|
|
610
648
|
part="popup"
|
|
649
|
+
popover=${this.topLayer ? "manual" : s}
|
|
611
650
|
?hidden=${!this.open || !this.shown.length && !a}
|
|
612
651
|
@mousedown=${(e) => e.preventDefault()}
|
|
613
652
|
>
|
|
@@ -644,24 +683,24 @@ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (
|
|
|
644
683
|
}
|
|
645
684
|
};
|
|
646
685
|
// src/components/uvalib-combobox/uvalib-combobox.ts
|
|
647
|
-
o([e({ type: String })],
|
|
686
|
+
o([e({ type: String })], B.prototype, "label", void 0), o([e({ type: String })], B.prototype, "description", void 0), o([e({ type: String })], B.prototype, "placeholder", void 0), o([e({
|
|
648
687
|
type: String,
|
|
649
688
|
reflect: !0
|
|
650
|
-
})],
|
|
689
|
+
})], B.prototype, "name", void 0), o([e({ type: String })], B.prototype, "value", void 0), o([e({ attribute: !1 })], B.prototype, "selected", void 0), o([e({ attribute: !1 })], B.prototype, "items", void 0), o([e({ type: String })], B.prototype, "src", void 0), o([e({ attribute: !1 })], B.prototype, "transform", void 0), o([e({
|
|
651
690
|
type: Number,
|
|
652
691
|
attribute: "min-length"
|
|
653
|
-
})],
|
|
692
|
+
})], B.prototype, "minLength", void 0), o([e({
|
|
654
693
|
type: Number,
|
|
655
694
|
attribute: "max-results"
|
|
656
|
-
})],
|
|
695
|
+
})], B.prototype, "maxResults", void 0), o([e({
|
|
657
696
|
type: Boolean,
|
|
658
697
|
attribute: "must-choose"
|
|
659
|
-
})],
|
|
698
|
+
})], B.prototype, "mustChoose", void 0), o([e({
|
|
660
699
|
type: Boolean,
|
|
661
700
|
reflect: !0
|
|
662
|
-
})],
|
|
701
|
+
})], B.prototype, "required", void 0), o([e({
|
|
663
702
|
type: Boolean,
|
|
664
703
|
reflect: !0
|
|
665
|
-
})],
|
|
704
|
+
})], B.prototype, "disabled", void 0), o([r()], B.prototype, "open", void 0), o([r()], B.prototype, "active", void 0), o([r()], B.prototype, "shown", void 0), o([r()], B.prototype, "total", void 0), o([r()], B.prototype, "loading", void 0), o([r()], B.prototype, "announcement", void 0), o([r()], B.prototype, "formDisabled", void 0), o([r()], B.prototype, "invalidShown", void 0), o([r()], B.prototype, "childEntries", void 0), a("uvalib-combobox", B);
|
|
666
705
|
|
|
667
706
|
//# sourceMappingURL=uvalib-combobox.js.map
|