@uvalib/web-components 1.8.5 → 1.10.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +719 -72
  3. package/bin/install-skill.mjs +174 -54
  4. package/dist/base/clipboard.d.ts +9 -0
  5. package/dist/base/clipboard.js +30 -0
  6. package/dist/base/clipboard.js.map +1 -0
  7. package/dist/base.css +301 -3
  8. package/dist/components/uvalib-citation/UvalibCitation.d.ts +124 -0
  9. package/dist/components/uvalib-citation/UvalibCitation.js +545 -0
  10. package/dist/components/uvalib-citation/UvalibCitation.js.map +1 -0
  11. package/dist/components/uvalib-citation/uvalib-citation.d.ts +1 -0
  12. package/dist/components/uvalib-citation/uvalib-citation.js +4 -0
  13. package/dist/components/uvalib-citation/uvalib-citation.js.map +1 -0
  14. package/dist/components/uvalib-dialog/UvalibDialog.d.ts +167 -0
  15. package/dist/components/uvalib-dialog/UvalibDialog.js +688 -0
  16. package/dist/components/uvalib-dialog/UvalibDialog.js.map +1 -0
  17. package/dist/components/uvalib-dialog/uvalib-dialog.d.ts +1 -0
  18. package/dist/components/uvalib-dialog/uvalib-dialog.js +4 -0
  19. package/dist/components/uvalib-dialog/uvalib-dialog.js.map +1 -0
  20. package/dist/components/uvalib-filter/UvalibFilter.d.ts +92 -9
  21. package/dist/components/uvalib-filter/UvalibFilter.js +748 -60
  22. package/dist/components/uvalib-filter/UvalibFilter.js.map +1 -1
  23. package/dist/components/uvalib-list-filter/UvalibListFilter.d.ts +162 -0
  24. package/dist/components/uvalib-list-filter/UvalibListFilter.js +685 -0
  25. package/dist/components/uvalib-list-filter/UvalibListFilter.js.map +1 -0
  26. package/dist/components/uvalib-list-filter/uvalib-list-filter.d.ts +1 -0
  27. package/dist/components/uvalib-list-filter/uvalib-list-filter.js +4 -0
  28. package/dist/components/uvalib-list-filter/uvalib-list-filter.js.map +1 -0
  29. package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -4
  30. package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
  31. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +28 -1
  32. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +139 -3
  33. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  34. package/dist/custom-elements.json +9503 -6086
  35. package/dist/edition.css +758 -0
  36. package/dist/index.d.ts +6 -0
  37. package/dist/index.js +3 -0
  38. package/dist/index.js.map +1 -1
  39. package/dist/styles/base.js +112 -1
  40. package/dist/styles/base.js.map +1 -1
  41. package/dist/styles/color-scheme.js +4 -0
  42. package/dist/styles/color-scheme.js.map +1 -1
  43. package/dist/styles/controls.js +6 -0
  44. package/dist/styles/controls.js.map +1 -1
  45. package/dist/styles/edition.d.ts +1 -0
  46. package/dist/styles/edition.js +747 -0
  47. package/dist/styles/edition.js.map +1 -0
  48. package/dist/styles/field-text.d.ts +1 -0
  49. package/dist/styles/field-text.js +21 -0
  50. package/dist/styles/field-text.js.map +1 -0
  51. package/dist/styles/hidden.js +15 -1
  52. package/dist/styles/hidden.js.map +1 -1
  53. package/dist/styles/layout.d.ts +1 -0
  54. package/dist/styles/layout.js +92 -0
  55. package/dist/styles/layout.js.map +1 -0
  56. package/dist/styles/table.d.ts +1 -0
  57. package/dist/styles/table.js +164 -0
  58. package/dist/styles/table.js.map +1 -0
  59. package/dist/tokens.css +4 -0
  60. package/dist-cdn/base.css +301 -3
  61. package/dist-cdn/chunks/{base-B3tNX103.js → base-DXkGlSgH.js} +113 -2
  62. package/dist-cdn/chunks/base-DXkGlSgH.js.map +1 -0
  63. package/dist-cdn/chunks/clipboard-CNG7Y_5X.js +18 -0
  64. package/dist-cdn/chunks/clipboard-CNG7Y_5X.js.map +1 -0
  65. package/dist-cdn/chunks/if-defined-COiQb-gl.js +6 -0
  66. package/dist-cdn/chunks/if-defined-COiQb-gl.js.map +1 -0
  67. package/dist-cdn/chunks/{site-header-CEmNtmk5.js → site-header-B78a_ldi.js} +27 -22
  68. package/dist-cdn/chunks/site-header-B78a_ldi.js.map +1 -0
  69. package/dist-cdn/chunks/{site-main-nav-CAwKq_x5.js → site-main-nav-CmMq2t8t.js} +52 -51
  70. package/dist-cdn/chunks/site-main-nav-CmMq2t8t.js.map +1 -0
  71. package/dist-cdn/custom-elements.json +9503 -6086
  72. package/dist-cdn/edition.css +758 -0
  73. package/dist-cdn/manifest.json +7 -3
  74. package/dist-cdn/site-header.js +1 -1
  75. package/dist-cdn/site-main-nav.js +1 -1
  76. package/dist-cdn/site-page.js +3 -3
  77. package/dist-cdn/site-style.js +1 -1
  78. package/dist-cdn/skills/uvalib-web-components/SKILL.md +34 -10
  79. package/dist-cdn/skills/uvalib-web-components/reference/components.md +188 -9
  80. package/dist-cdn/tokens.css +4 -0
  81. package/dist-cdn/uvalib-citation.js +382 -0
  82. package/dist-cdn/uvalib-citation.js.map +1 -0
  83. package/dist-cdn/uvalib-dialog.js +419 -0
  84. package/dist-cdn/uvalib-dialog.js.map +1 -0
  85. package/dist-cdn/uvalib-filter.js +603 -69
  86. package/dist-cdn/uvalib-filter.js.map +1 -1
  87. package/dist-cdn/uvalib-list-filter.js +451 -0
  88. package/dist-cdn/uvalib-list-filter.js.map +1 -0
  89. package/dist-cdn/uvalib-metadata.js +49 -49
  90. package/dist-cdn/uvalib-metadata.js.map +1 -1
  91. package/dist-cdn/uvalib-pagefind-search.js +118 -48
  92. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  93. package/package.json +14 -1
  94. package/skills/uvalib-web-components/SKILL.md +34 -10
  95. package/skills/uvalib-web-components/reference/components.md +188 -9
  96. package/dist-cdn/chunks/base-B3tNX103.js.map +0 -1
  97. package/dist-cdn/chunks/site-header-CEmNtmk5.js.map +0 -1
  98. package/dist-cdn/chunks/site-main-nav-CAwKq_x5.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uvalib-list-filter.js","names":["unsafeCSS","nothing","_decorate","property","state","n","w","i","r$1","b","define","__decorate","A","r","installLightDomStyles","UvalibElement","trackEvent","paramFromLocation","hrefWithParam","accessible","message","TAG","listFilterTiming","CLEAR_MS","uid","MARKS","fold","s","queryWords","q","queryKey","count","guards","MARK","installGuard","sheet","root","CLEAR_ICON","structuralRules","host","shadowStructure","BORDER","MUTED","TEXT","RAISED","UvalibListFilter","_args","input","name","node","fromUrl","changed","scope","found","items","group","el","groups","g","parent","idx","query","prevQuery","words","text","visible","shown","hide","t","hidden","user","rc","plural","total","key","say","p","id","label","own","empty"],"sources":["../src/styles/message.ts","../src/components/uvalib-list-filter/UvalibListFilter.ts","../src/components/uvalib-list-filter/uvalib-list-filter.ts"],"sourcesContent":["import { css } from 'lit';\n\n// An inline message for a page's own content (issue #8), in base.css only (composed into\n// `controls`): an error, a warning, a notice or a success, at the size of the content around\n// it. The severity look is <site-alerts>' list alerts at inline size: the alert background,\n// a thick start border in the severity colour, and the alert text and link colours, which are\n// 7:1 or more (WCAG AAA) on every alert background in light and dark (the\n// --uva-color-alert-* role tokens; success reads the two --uva-color-status-success-* ones).\n//\n// The severity is never colour alone: the author writes it in the text (`<strong\n// class=\"uvalib-message__label\">Error:</strong>`), optionally with a decorative icon. No\n// CSS-generated prefix: generated content is read inconsistently by screen readers, is not\n// translated with the page, and would double a word the author already wrote.\n//\n// In forced colors, where backgrounds are dropped, every message keeps a system-colour border\n// (thicker at the start), as <site-alerts> does.\n//\n// The text wraps with `text-wrap: pretty` (no one-word last line; ignored where unsupported),\n// not `balance`: the message is a box, and balanced lines would leave empty space in it.\nexport const message = css`\n .uvalib-message {\n display: block;\n box-sizing: border-box;\n max-inline-size: 100%;\n margin-block: 1rem;\n padding: 0.75rem 1rem;\n border: 1px solid transparent;\n border-inline-start: 6px solid var(--uva-color-alert-info-border, var(--uva-blue-alt, #007bac));\n border-radius: 0.3rem;\n background: var(--uva-color-alert-info-bg, var(--uva-blue-alt-300, #bfe7f7));\n color: var(--uva-color-alert-text, var(--uva-grey-darkest, #2b2b2b));\n line-height: 1.5;\n overflow-wrap: anywhere;\n text-wrap: pretty;\n }\n .uvalib-message > :first-child {\n margin-block-start: 0;\n }\n .uvalib-message > :last-child {\n margin-block-end: 0;\n }\n .uvalib-message a,\n .uvalib-message a:visited {\n color: var(--uva-color-alert-link, var(--uva-blue-alt-B, #141e3c));\n text-decoration: underline;\n }\n /* The ring follows the text colour, chosen to read on the message's own background. */\n .uvalib-message a:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 2px;\n }\n .uvalib-message__label {\n font-weight: 700;\n }\n .uvalib-message__icon {\n display: inline-block;\n inline-size: 1.25em;\n block-size: 1.25em;\n margin-inline-end: 0.35em;\n vertical-align: -0.25em;\n }\n .uvalib-message--error {\n border-inline-start-color: var(--uva-color-alert-critical-border, var(--uva-red-B, #b30000));\n background: var(--uva-color-alert-critical-bg, var(--uva-red-100, #fbcfda));\n }\n .uvalib-message--warning {\n border-inline-start-color: var(--uva-color-alert-warning-border, var(--uva-yellow, #ecc602));\n background: var(--uva-color-alert-warning-bg, var(--uva-yellow-100, #fef6c8));\n }\n .uvalib-message:is(.uvalib-message--info, .uvalib-message--notice) {\n border-inline-start-color: var(--uva-color-alert-info-border, var(--uva-blue-alt, #007bac));\n background: var(--uva-color-alert-info-bg, var(--uva-blue-alt-300, #bfe7f7));\n }\n .uvalib-message--success {\n border-inline-start-color: var(--uva-color-status-success-border, var(--uva-green-A, #4e9737));\n background: var(--uva-color-status-success-bg, var(--uva-green-200, #ddefdc));\n }\n @media (forced-colors: active) {\n .uvalib-message {\n border-color: CanvasText;\n }\n .uvalib-message a:focus-visible {\n outline-color: Highlight;\n }\n }\n`;\n","import { css, html, nothing, svg, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { hrefWithParam, paramFromLocation } from '../../base/url-param.js';\nimport { accessible } from '../../styles/accessible.js';\nimport { message } from '../../styles/message.js';\n\n/** What `uvalib-list-filter-change` carries. */\nexport interface ListFilterChangeDetail {\n /** The text in the field, as typed. */\n query: string;\n /** How many items match (are shown). */\n shown: number;\n /** How many items the list has. */\n total: number;\n}\n\nconst TAG = 'uvalib-list-filter';\n\n/**\n * How long (ms) the filter must stay put before it is announced and reported to analytics\n * (as `<uvalib-results-count>` and the date range settle), and before it is written to the\n * URL. Tests may shorten them.\n */\nexport const listFilterTiming = { settle: 1000, url: 250 };\n/** How long an announcement stays in the live region before it is cleared. */\nconst CLEAR_MS = 5000;\nlet uid = 0;\n\nconst MARKS = /\\p{M}/gu;\n/** Case- and accent-insensitive form: “Ébène” and “ebene” match. */\nexport const fold = (s: string): string => s.normalize('NFD').replace(MARKS, '').toLowerCase();\n/** The query's words, folded: every one must appear in an item, in any order. */\nexport const queryWords = (q: string): string[] => fold(q).split(/\\s+/).filter(Boolean);\n/** The same words in any case or order are the same query (for analytics). */\nconst queryKey = (q: string): string => queryWords(q).toSorted().join(' ');\n\nconst count = (n: number) => n.toLocaleString('en-US');\n\n/** The items as read from the page, with their folded text and what the filter last did. */\ninterface Index {\n items: HTMLElement[];\n /** Folded text per item, read on the first non-empty query. */\n text?: string[];\n hidden: boolean[];\n /** Each item's `[data-filter-group]` ancestor, if any. */\n group: (HTMLElement | null)[];\n groups: HTMLElement[];\n}\n\n/**\n * Hidden items stay hidden whatever `display` the page gives them: one unlayered sheet per\n * root (document or shadow root). It only reaches the direct children of the item and group\n * parents this element marks, so other `[hidden]` content on the page is left alone.\n */\nconst guards = new WeakMap<Document | ShadowRoot, CSSStyleSheet>();\nconst MARK = 'data-uvalib-list-filter';\nfunction installGuard(root: Document | ShadowRoot): void {\n let sheet = guards.get(root);\n if (!sheet) {\n const doc = (root as ShadowRoot).ownerDocument ?? (root as Document);\n const Ctor =\n (doc.defaultView as (Window & typeof globalThis) | null)?.CSSStyleSheet ?? CSSStyleSheet;\n sheet = new Ctor();\n sheet.replaceSync(`:where([${MARK}]) > [hidden] { display: none !important; }`);\n guards.set(root, sheet);\n }\n if (!root.adoptedStyleSheets.includes(sheet))\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];\n}\n\nconst CLEAR_ICON = svg`<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>`;\n\n/**\n * Kept with `no-style`: the label above a 44px field, the 44px clear button inside its end,\n * the visually hidden text, and `[hidden]`. `host` is `:host` or the tag.\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; max-width: 100%; font-size: 1rem; line-height: 1.5; }\n ${host} .label { display: block; margin-block-end: 0.25rem; }\n ${host} .field { position: relative; }\n ${host} .input {\n display: block;\n box-sizing: border-box;\n inline-size: 100%;\n min-block-size: 44px;\n margin: 0;\n padding-inline-end: 44px;\n font: inherit;\n line-height: 1.2;\n }\n ${host} .input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }\n ${host} .clear {\n position: absolute;\n inset-block-start: 0;\n inset-inline-end: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n inline-size: 44px;\n block-size: 44px;\n margin: 0;\n padding: 0;\n cursor: pointer;\n }\n ${host} .count { margin: 0.25rem 0 0; }\n ${host} .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\nconst BORDER = unsafeCSS('var(--uva-color-control-border, var(--uva-grey, #808080))');\nconst MUTED = unsafeCSS('var(--uva-color-text-muted, var(--uva-grey-A, #4f4f4f))');\nconst TEXT = unsafeCSS('var(--uva-color-input-text, var(--uva-grey-darkest, #2b2b2b))');\nconst RAISED = unsafeCSS('var(--uva-color-surface-raised, #ffffff)');\n\n/**\n * A text field that filters a long list on the page as you type: a collection's 473 texts, a\n * staff directory, a table of databases. The list is the page's own markup and stays fully\n * visible without the script.\n *\n * `for` is the id of the list: any element whose children are the items (a `<ul>` or `<ol>`,\n * a `<dl>` of `<div>` rows, a grid of cards; for a `<table>`, the rows of its bodies).\n * `selector` picks the items instead (inside `for` when both are set, else in the page).\n * An item matches when every word typed appears in its `data-filter-text`, or else its text,\n * in any order, ignoring case and accents (“eneide” finds “Énéide”). Items that do not match\n * get the `hidden` attribute (kept hidden whatever `display` the page gives them); clearing\n * the field shows them all again. Thousands of items filter at once on every keystroke: the\n * text is read once, and only items whose state changes are touched.\n *\n * Groups: give each group's wrapper `data-filter-group` (a `<section>` with its heading and\n * its list) and point `selector` at the items; a group whose items are all hidden is hidden\n * too, heading and all.\n *\n * The visible `label` (default “Filter”; `hide-label` hides it visually) names the field, and\n * a Clear button (“Clear <label>”, 44px, shown only with text) or Escape empties it, keeping\n * focus in the field. Under the field a count follows at once (“Showing 12 of 473 texts”;\n * `noun`, plural, and `singular` name the items), and a polite status announces it once the\n * typing settles (a second after the last keystroke), never on every key or at load. When\n * nothing matches, a message says “No texts match “…”.” To put the count elsewhere, point\n * `results-count` at a `<uvalib-results-count>` (give it `total` and `noun` in the markup):\n * the element then sets its `shown` and `total` and leaves the count and announcement to it.\n *\n * With `query-param` (bare: `filter`) the filter is read from that URL parameter at start\n * and written back with `history.replaceState` as you type, so a filtered list can be shared\n * and Back returns to it. The list's content is read once; call `refresh()` after changing an\n * item's text in script (added or removed items and `data-filter-text` changes are noticed).\n *\n * Before it upgrades, `base.css` holds the label, field and count's height, so nothing moves.\n *\n * @tagname uvalib-list-filter\n * @fires uvalib-list-filter-change - The filter was applied with a new query (typing, Clear, Escape, `value` set in script, the URL at start, Back and Forward). `detail` is `{ query, shown, total }`. Not fired at load without a query. Bubbles and is composed.\n * @fires uvalib-analytics-event - For `<site-analytics>`, on the visitor's actions only: `['uvalib-list-filter', 'filter', '', <shown>]` once the typing settles on a new query, and `['uvalib-list-filter', 'clear']` when the visitor empties the field. Never the typed text. Bubbles and is composed.\n * @csspart label - The visible label.\n * @csspart field - The box around the field and its clear button.\n * @csspart input - The text field.\n * @csspart clear - The clear button.\n * @csspart count - The visible count under the field.\n * @csspart empty - The “No … match” message.\n * @cssprop --uva-color-surface-raised - Dark-mode role token: field background (else #fff).\n * @cssprop --uva-color-control-border - Dark-mode role token: field border (else `--uva-grey`, #808080).\n * @cssprop --uva-color-input-text - Dark-mode role token: field text (else #2b2b2b).\n * @cssprop --uva-color-text - Dark-mode role token: label text (else #2b2b2b).\n * @cssprop --uva-color-text-muted - Dark-mode role token: placeholder, count and the clear icon (else #4f4f4f).\n * @cssprop --uva-color-alert-info-bg - Dark-mode role token: the no-match message background.\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibListFilter extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n message,\n css`\n :host {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .label {\n font-weight: 600;\n }\n .field {\n max-inline-size: 36rem;\n }\n .input {\n padding-block: 0.5rem;\n padding-inline-start: 0.75rem;\n border: 1px solid ${BORDER};\n border-radius: 5px;\n background: ${RAISED};\n color: ${TEXT};\n }\n .input::placeholder {\n color: ${MUTED};\n opacity: 1;\n }\n .clear {\n border: 0;\n border-radius: 5px;\n background: none;\n color: ${MUTED};\n }\n .clear:hover {\n color: ${TEXT};\n }\n .clear:focus-visible {\n outline-offset: -4px;\n }\n .count {\n color: ${MUTED};\n }\n .uvalib-message {\n margin-block: 0.75rem 0;\n }\n @media (forced-colors: active) {\n .input {\n border-color: CanvasText;\n }\n .clear {\n color: ButtonText;\n }\n }\n `,\n ];\n\n /** The id of the list whose children are the items (for a table, its body rows). */\n @property({ type: String, attribute: 'for' }) htmlFor = '';\n\n /** A CSS selector for the items, inside `for` when it is set, else in the page. */\n @property({ type: String }) selector = '';\n\n /** The field's visible label and accessible name. */\n @property({ type: String }) label = 'Filter';\n\n /** Hide the label visually (it still names the field), when a heading beside it says it. */\n @property({ type: Boolean, reflect: true, attribute: 'hide-label' }) hideLabel = false;\n\n /** Placeholder text in the empty field, such as “Title or author”. */\n @property({ type: String }) placeholder = '';\n\n /** What the items are, plural: “items” by default. */\n @property({ type: String }) noun = 'items';\n\n /** What one item is. Default: “item” when `noun` is unset, else `noun`. */\n @property({ type: String }) singular = '';\n\n /** The id of a `<uvalib-results-count>` to drive instead of the element's own count. */\n @property({ type: String, attribute: 'results-count' }) resultsCount = '';\n\n /**\n * The URL parameter to read the filter from and write it to; a bare attribute uses\n * `filter`. Off by default.\n */\n @property({ type: String, attribute: 'query-param' }) queryParam: string | null = null;\n\n /** The text in the field. Setting it filters the list (not reported to analytics). */\n @property({ type: String }) value = '';\n\n @state() private shownCount = 0;\n @state() private totalCount = 0;\n /** The query the shown counts belong to. */\n @state() private appliedQuery = '';\n @state() private announcement = '';\n\n private readonly uid = `${TAG}-${++uid}`;\n private index?: Index;\n private started = false;\n private warned = false;\n private observer?: MutationObserver;\n private observed?: Element;\n /** The words of the last query reported to analytics (or restored), joined. */\n private reported = '';\n private settleTimer?: ReturnType<typeof setTimeout>;\n private urlTimer?: ReturnType<typeof setTimeout>;\n private clearing?: ReturnType<typeof setTimeout>;\n\n /** How many items match now. */\n get shown(): number {\n return this.shownCount;\n }\n\n /** How many items the list has. */\n get total(): number {\n return this.totalCount;\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n window.addEventListener('popstate', this.onPopState);\n window.addEventListener('pagehide', this.flushUrl);\n // Moved in the page: read the list again and filter it as before.\n if (this.started) this.reset();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener('popstate', this.onPopState);\n window.removeEventListener('pagehide', this.flushUrl);\n clearTimeout(this.settleTimer);\n clearTimeout(this.clearing);\n this.flushUrl();\n this.observer?.disconnect();\n this.observed = undefined;\n // Without the field there is no way to clear the filter: show the whole list again.\n this.showAll();\n }\n\n /** The list may come after the element in a page still loading: wait for it then. */\n private begin(): void {\n if (document.readyState === 'loading' && !this.collect())\n document.addEventListener('DOMContentLoaded', () => this.start(), { once: true });\n else this.start();\n }\n\n private start(): void {\n if (this.started || !this.isConnected) return;\n this.started = true;\n const fromUrl = this.urlQuery();\n if (fromUrl !== null) this.value = fromUrl;\n this.reported = queryKey(this.value);\n this.apply();\n }\n\n // Filtering in willUpdate: the counts it sets render in the same update.\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (!this.hasUpdated) return this.begin();\n if (!this.started) return;\n if (changed.has('htmlFor') || changed.has('selector')) this.reset();\n else if (changed.has('value') && this.value !== this.appliedQuery) this.apply();\n }\n\n /** Read the list again (an item's text changed in script) and filter it with the current text. */\n refresh(): void {\n if (this.started) this.reset();\n }\n\n private reset(): void {\n this.showAll();\n this.index = undefined;\n this.apply();\n }\n\n // ---- the list\n\n private lookupRoot(): Document | ShadowRoot {\n const node = this.getRootNode();\n return node instanceof ShadowRoot || node instanceof Document ? node : document;\n }\n\n /** The `for` element, if any. */\n private target(): Element | null {\n return this.htmlFor ? this.lookupRoot().getElementById(this.htmlFor) : null;\n }\n\n private collect(): HTMLElement[] | null {\n const scope = this.target();\n if (this.htmlFor && !scope) return null;\n let found: Element[];\n if (this.selector) {\n try {\n found = [...(scope ?? this.lookupRoot()).querySelectorAll(this.selector)];\n } catch {\n return null;\n }\n } else if (!scope) return null;\n else if (scope instanceof HTMLTableElement)\n found = [...scope.tBodies].flatMap((b) => [...b.rows]);\n else found = [...scope.children];\n return found.filter((e): e is HTMLElement => e instanceof HTMLElement);\n }\n\n private build(): Index | undefined {\n const items = this.collect();\n if (!items) {\n if (!this.warned) {\n this.warned = true;\n console.warn(\n `<${TAG}>: no list found; set \"for\" to the id of the list, or \"selector\" to its items.`,\n );\n }\n return undefined;\n }\n const group = items.map(\n (el) => el.parentElement?.closest<HTMLElement>('[data-filter-group]') ?? null,\n );\n const groups = [...new Set(group.filter((g): g is HTMLElement => g !== null))];\n const root = items[0]?.getRootNode();\n if (root instanceof Document || root instanceof ShadowRoot) installGuard(root);\n for (const parent of new Set([...items, ...groups].map((e) => e.parentElement)))\n parent?.setAttribute(MARK, '');\n this.observe();\n return { items, hidden: items.map((el) => el.hidden), group, groups };\n }\n\n /** Added or removed items, and data-filter-text changes, read the list again. */\n private observe(): void {\n const scope = this.target();\n if (!scope || scope === this.observed) return;\n this.observer?.disconnect();\n this.observer ??= new MutationObserver(() => {\n this.index = undefined;\n this.apply();\n });\n this.observer.observe(scope, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['data-filter-text'],\n });\n this.observed = scope;\n }\n\n private textOf(idx: Index): string[] {\n idx.text ??= idx.items.map((el) => fold(el.dataset.filterText ?? el.textContent ?? ''));\n return idx.text;\n }\n\n /** Show or hide every item for the current text (`user`: typed, so settle, report and write the URL). */\n private apply(user = false): void {\n this.index ??= this.build();\n const idx = this.index;\n const query = this.value;\n const prevQuery = this.appliedQuery;\n this.appliedQuery = query;\n if (!idx) {\n this.shownCount = this.totalCount = 0;\n return;\n }\n const words = queryWords(query);\n const text = words.length ? this.textOf(idx) : [];\n const { items, hidden, group } = idx;\n const visible = new Map<HTMLElement, number>();\n let shown = 0;\n for (let i = 0; i < items.length; i++) {\n let hide = false;\n if (words.length) {\n const t = text[i]!;\n for (const w of words) {\n if (!t.includes(w)) {\n hide = true;\n break;\n }\n }\n }\n if (hidden[i] !== hide) {\n hidden[i] = hide;\n items[i]!.hidden = hide;\n }\n if (!hide) {\n shown++;\n const g = group[i];\n if (g) visible.set(g, (visible.get(g) ?? 0) + 1);\n }\n }\n for (const g of idx.groups) {\n const hide = !visible.has(g);\n if (g.hidden !== hide) g.hidden = hide;\n }\n const changed =\n query !== prevQuery || shown !== this.shownCount || items.length !== this.totalCount;\n this.shownCount = shown;\n this.totalCount = items.length;\n this.driveResultsCount();\n if (changed && (query || prevQuery))\n this.dispatchEvent(\n new CustomEvent<ListFilterChangeDetail>('uvalib-list-filter-change', {\n detail: { query, shown, total: items.length },\n bubbles: true,\n composed: true,\n }),\n );\n if (user) {\n clearTimeout(this.settleTimer);\n this.settleTimer = setTimeout(() => this.settle(), listFilterTiming.settle);\n clearTimeout(this.urlTimer);\n this.urlTimer = setTimeout(this.flushUrl, listFilterTiming.url);\n }\n }\n\n private showAll(): void {\n const idx = this.index;\n if (!idx) return;\n idx.items.forEach((el, i) => {\n if (idx.hidden[i]) el.hidden = idx.hidden[i] = false;\n });\n for (const g of idx.groups) g.hidden = false;\n }\n\n private externalCount(): (HTMLElement & { shown?: number; total?: number }) | null {\n return this.resultsCount ? this.lookupRoot().getElementById(this.resultsCount) : null;\n }\n\n private driveResultsCount(): void {\n const rc = this.externalCount();\n if (!rc) return;\n rc.total = this.totalCount;\n rc.shown = this.shownCount;\n }\n\n // ---- what the visitor sees and hears\n\n private word(n: number): string {\n const plural = this.noun.trim() || 'items';\n if (n !== 1) return plural;\n return this.singular.trim() || (plural === 'items' ? 'item' : plural);\n }\n\n /** The visible count: “Showing 12 of 473 texts”, “Showing all 473 texts”. */\n get countText(): string {\n const total = this.totalCount;\n const shown = this.shownCount;\n if (!total) return this.started && this.index ? `No ${this.word(0)}` : '';\n if (shown < total) return `Showing ${count(shown)} of ${count(total)} ${this.word(total)}`;\n if (total === 1) return `Showing 1 ${this.word(1)}`;\n return `Showing all ${count(total)} ${this.word(total)}`;\n }\n\n private get emptyText(): string {\n const q = this.appliedQuery.trim();\n return this.totalCount && !this.shownCount && q ? `No ${this.word(0)} match “${q}”.` : '';\n }\n\n /** The typing settled: announce the count, and report a new query. */\n private settle(): void {\n if (!this.externalCount()) this.announce(this.emptyText || this.countText);\n const key = queryKey(this.value);\n if (key === this.reported) return;\n if (key) trackEvent(this, [TAG, 'filter', '', this.shownCount]);\n else trackEvent(this, [TAG, 'clear']);\n this.reported = key;\n }\n\n private announce(text: string): void {\n if (!text) return;\n clearTimeout(this.clearing);\n const say = () => {\n this.announcement = text;\n this.clearing = setTimeout(() => (this.announcement = ''), CLEAR_MS);\n };\n // The same words still in the region would not be read again: empty it first.\n if (this.announcement === text) {\n this.announcement = '';\n void this.updateComplete.then(() => requestAnimationFrame(say));\n } else say();\n }\n\n private get input(): HTMLInputElement | null {\n return (this.renderRoot as ParentNode).querySelector<HTMLInputElement>(`#${this.uid}-input`);\n }\n\n private onInput = (e: Event): void => {\n e.stopPropagation();\n this.value = (e.target as HTMLInputElement).value;\n this.apply(true);\n };\n\n private onKeydown = (e: KeyboardEvent): void => {\n if (e.key !== 'Escape' || !this.value) return;\n e.preventDefault();\n this.clear();\n };\n\n private clear = (): void => {\n const input = this.input;\n if (input) input.value = '';\n this.value = '';\n this.apply(true);\n input?.focus();\n trackEvent(this, [TAG, 'clear']);\n this.reported = '';\n };\n\n // ---- the URL\n\n private get param(): string {\n const p = this.queryParam;\n return p === null ? '' : p.trim() || 'filter';\n }\n\n /** The filter in the URL, or null with `query-param` off or the parameter missing. */\n private urlQuery(): string | null {\n const name = this.param;\n return name ? paramFromLocation(location, name) : null;\n }\n\n private flushUrl = (): void => {\n if (this.urlTimer === undefined) return;\n clearTimeout(this.urlTimer);\n this.urlTimer = undefined;\n const name = this.param;\n if (!name) return;\n const q = this.value.trim();\n if ((paramFromLocation(location, name) ?? '') === q) return;\n try {\n history.replaceState(history.state, '', hrefWithParam(location, name, q || null));\n } catch {\n // A document whose URL cannot change (about:srcdoc), or too many changes: skip the URL.\n }\n };\n\n /** Back and Forward: follow the URL's filter. */\n private onPopState = (): void => {\n if (!this.started || !this.param) return;\n const q = this.urlQuery() ?? '';\n if (q === this.value) return;\n this.value = q;\n this.reported = queryKey(q);\n this.apply();\n };\n\n protected override render() {\n const id = this.uid;\n const label = this.label.trim() || 'Filter';\n const own = !this.resultsCount;\n const empty = this.emptyText;\n return html`<label\n class=\"label ${this.hideLabel ? 'visually-hidden' : ''}\"\n part=\"label\"\n for=\"${id}-input\"\n >${label}</label\n >\n <div class=\"field\" part=\"field\">\n <input\n id=\"${id}-input\"\n class=\"input\"\n part=\"input\"\n type=\"search\"\n autocomplete=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n enterkeyhint=\"search\"\n placeholder=${this.placeholder || nothing}\n .value=${this.value}\n @input=${this.onInput}\n @keydown=${this.onKeydown}\n @change=${(e: Event) => e.stopPropagation()}\n /><button\n type=\"button\"\n class=\"clear\"\n part=\"clear\"\n aria-label=\"Clear ${label}\"\n ?hidden=${!this.value}\n @mousedown=${(e: MouseEvent) => e.preventDefault()}\n @click=${this.clear}\n >\n ${CLEAR_ICON}\n </button>\n </div>\n ${own ? html`<p class=\"count\" part=\"count\">${this.countText}</p>` : nothing}\n <p class=\"uvalib-message\" part=\"empty\" ?hidden=${!empty}>${empty}</p>\n ${\n own\n ? html`<span class=\"visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n >${this.announcement}</span\n >`\n : nothing\n }`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibListFilter } from './UvalibListFilter.js';\n\ndefine('uvalib-list-filter', UvalibListFilter);\n"],"mappings":";;;;;AAmBA,IAAaoB,IAAU,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GCApBC,IAAM,sBAOCC,IAAmB;CAAE,QAAQ;CAAM,KAAK;AAAI,GAEnD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0C,EAAA,WAAA,cAAA,KAAA,CAAA,GAGnD3C,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA0C,EAAA,WAAA,SAAA,KAAA,CAAA,GAEzB3C,EAAA,CAAAE,EAAM,CAAA,GAAAyC,EAAA,WAAA,cAAA,KAAA,CAAA,GACN3C,EAAA,CAAAE,EAAM,CAAA,GAAAyC,EAAA,WAAA,cAAA,KAAA,CAAA,GAEN3C,EAAA,CAAAE,EAAM,CAAA,GAAAyC,EAAA,WAAA,gBAAA,KAAA,CAAA,GACN3C,EAAA,CAAAE,EAAM,CAAA,GAAAyC,EAAA,WAAA,gBAAA,KAAA,CAAA,GC9QTnC,EAAO,sBAAsBmC,CAAgB"}
@@ -1,10 +1,11 @@
1
1
  import { a as e, f as t, i as n, l as r, m as i, n as a, o, p as s, r as c, t as l } from "./chunks/UvalibElement-pGONDAwB.js";
2
2
  import { a as u } from "./chunks/analytics-DTTihuBD.js";
3
- import { n as d } from "./chunks/inline-copy-BANQSMIR.js";
4
- import { n as f, r as p, t as m } from "./chunks/source-children-BHsDwCvL.js";
5
- import { t as h } from "./chunks/accessible-DJv7YOtS.js";
3
+ import { n as d, t as f } from "./chunks/clipboard-CNG7Y_5X.js";
4
+ import { n as p } from "./chunks/inline-copy-BANQSMIR.js";
5
+ import { n as m, r as h, t as g } from "./chunks/source-children-BHsDwCvL.js";
6
+ import { t as _ } from "./chunks/accessible-DJv7YOtS.js";
6
7
  // src/components/uvalib-metadata/rights.ts
7
- var g = {
8
+ var v = {
8
9
  INC: "In Copyright",
9
10
  "INC-OW-EU": "In Copyright – EU Orphan Work",
10
11
  "INC-EDU": "In Copyright – Educational Use Permitted",
@@ -18,7 +19,7 @@ var g = {
18
19
  UND: "Copyright Undetermined",
19
20
  NKC: "No Known Copyright"
20
21
  };
21
- function _(e) {
22
+ function y(e) {
22
23
  let t;
23
24
  try {
24
25
  t = new URL(e);
@@ -28,7 +29,7 @@ function _(e) {
28
29
  let n = t.hostname.toLowerCase().replace(/^www\./, ""), r = t.pathname;
29
30
  if (n === "rightsstatements.org") {
30
31
  let e = /^\/(?:vocab|page|data)\/([a-z-]+)\/\d/i.exec(r);
31
- return e ? g[e[1].toUpperCase()] : void 0;
32
+ return e ? v[e[1].toUpperCase()] : void 0;
32
33
  }
33
34
  if (n === "creativecommons.org") {
34
35
  let e = /^\/licenses\/((?:by|nc|nd|sa)(?:-(?:by|nc|nd|sa))*)\/(\d+(?:\.\d+)*)/i.exec(r);
@@ -37,11 +38,11 @@ function _(e) {
37
38
  if (t) return t[1].toLowerCase() === "zero" ? `CC0 ${t[2]}` : `Public Domain Mark ${t[2]}`;
38
39
  }
39
40
  }
40
- var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, University of Virginia`, y = "More about rights and permissions", b = 5e3, x = ":scope > ul, :scope > ol", S = "a[href], button, input, select, textarea, [tabindex]:not([tabindex=\"-1\"])", C = (e) => {
41
+ var b = (e) => `${e}, Albert and Shirley Small Special Collections Library, University of Virginia`, x = "More about rights and permissions", S = 5e3, C = ":scope > ul, :scope > ol", w = "a[href], button, input, select, textarea, [tabindex]:not([tabindex=\"-1\"])", T = (e) => {
41
42
  if (e == null || typeof e == "string" && !e.trim()) return;
42
43
  let t = Math.trunc(Number(e));
43
44
  return Number.isFinite(t) ? Math.max(0, t) : void 0;
44
- }, w = 0, T = (e) => `
45
+ }, E = 0, D = (e) => `
45
46
  ${e} { display: block; }
46
47
  ${e} dl, ${e} dd { margin: 0; }
47
48
  ${e} dd :is(ul, ol) { list-style: none; margin: 0; padding: 0; }
@@ -54,11 +55,11 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
54
55
  margin-top: 0.25rem;
55
56
  }
56
57
  ${e}[hidden], ${e} [hidden] { display: none !important; }
57
- `, E = s(T(":host")), D = class extends l {
58
+ `, O = s(D(":host")), k = class extends l {
58
59
  static {
59
60
  this.styles = [
60
- h,
61
- E,
61
+ _,
62
+ O,
62
63
  t`
63
64
  :host {
64
65
  container-type: inline-size;
@@ -148,12 +149,12 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
148
149
  ];
149
150
  }
150
151
  constructor() {
151
- super(), this.childRows = [], this.open = /* @__PURE__ */ new Set(), this.hid = /* @__PURE__ */ new WeakSet(), this.uid = `uvalib-metadata-${++w}`, this.status = "", this.sourceKey = "", this.warned = /* @__PURE__ */ new Set(), this.clones = /* @__PURE__ */ new WeakMap(), new m(this, () => this.lightDom, (e) => this.read(e));
152
+ super(), this.childRows = [], this.open = /* @__PURE__ */ new Set(), this.hid = /* @__PURE__ */ new WeakSet(), this.uid = `uvalib-metadata-${++E}`, this.status = "", this.sourceKey = "", this.warned = /* @__PURE__ */ new Set(), this.clones = /* @__PURE__ */ new WeakMap(), new g(this, () => this.lightDom, (e) => this.read(e));
152
153
  }
153
154
  createRenderRoot() {
154
155
  let e = super.createRenderRoot();
155
156
  if (e instanceof ShadowRoot && this.noStyle) {
156
- let t = E.styleSheet;
157
+ let t = O.styleSheet;
157
158
  t && (e.adoptedStyleSheets = [t]);
158
159
  }
159
160
  return e;
@@ -161,7 +162,7 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
161
162
  connectedCallback() {
162
163
  if (super.connectedCallback(), this.lightDom && this.noStyle) {
163
164
  let e = this.getRootNode();
164
- c(`${this.localName}::structure`, s(T(this.localName)), {
165
+ c(`${this.localName}::structure`, s(D(this.localName)), {
165
166
  root: e instanceof ShadowRoot || e instanceof Document ? e : void 0,
166
167
  scope: !1
167
168
  });
@@ -182,12 +183,12 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
182
183
  parse(e) {
183
184
  let t = [...e.children].flatMap((e) => e.localName === "div" ? [...e.children] : [e]), n = [], r;
184
185
  for (let e of t) if (e.localName === "dt") {
185
- let t = f(e.textContent);
186
+ let t = m(e.textContent);
186
187
  if (!t) continue;
187
188
  r && !r.values.length ? r.label += ` / ${t}` : n.push(r = {
188
189
  label: t,
189
190
  values: [],
190
- ...d(e)
191
+ ...p(e)
191
192
  });
192
193
  } else if (e.localName === "dd") {
193
194
  if (!r) {
@@ -196,13 +197,13 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
196
197
  }
197
198
  let t = {
198
199
  source: [...e.childNodes].map((e) => this.copy(e)),
199
- ...d(e)
200
- }, n = e.querySelector(x);
200
+ ...p(e)
201
+ }, n = e.querySelector(C);
201
202
  if (n) {
202
203
  t.count = n.querySelectorAll(":scope > li").length;
203
- let r = C(e.getAttribute("data-limit") ?? n.getAttribute("data-limit"));
204
+ let r = T(e.getAttribute("data-limit") ?? n.getAttribute("data-limit"));
204
205
  r !== void 0 && (t.limit = r);
205
- let i = f(e.getAttribute("data-limit-label") ?? n.getAttribute("data-limit-label"));
206
+ let i = m(e.getAttribute("data-limit-label") ?? n.getAttribute("data-limit-label"));
206
207
  i && (t.limitLabel = i);
207
208
  }
208
209
  r.values.push(t);
@@ -216,9 +217,9 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
216
217
  for (let e of [t, ...t.querySelectorAll("*")]) {
217
218
  if (this.lightDom && e.removeAttribute("id"), e.removeAttribute("data-limit"), e.removeAttribute("data-limit-label"), e.localName !== "a") continue;
218
219
  let t = e.getAttribute("href");
219
- t !== null && !p(t, n) && (this.warnOnce("href", "showing a link as text: its href is not http(s), mailto, tel or relative."), r.push(e));
220
- let i = f(e.getAttribute("data-size"));
221
- e.removeAttribute("data-size"), i && !f(e.textContent).endsWith(i) && e.append(this.sizeNodes(i));
220
+ t !== null && !h(t, n) && (this.warnOnce("href", "showing a link as text: its href is not http(s), mailto, tel or relative."), r.push(e));
221
+ let i = m(e.getAttribute("data-size"));
222
+ e.removeAttribute("data-size"), i && !m(e.textContent).endsWith(i) && e.append(this.sizeNodes(i));
222
223
  }
223
224
  for (let e of r.reverse()) {
224
225
  if (e !== t) {
@@ -239,9 +240,9 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
239
240
  renderValue(e) {
240
241
  if (e == null) return "";
241
242
  if (typeof e != "object") return String(e);
242
- let t = f(e.label), n = e.href == null ? "" : String(e.href);
243
- if (!n || !p(n, this.ownerDocument.baseURI)) return n && this.warnOnce("href", "showing a link as text: its href is not http(s), mailto, tel or relative."), t;
244
- let i = f(e.size), a = e.download === !0 ? "" : e.download || void 0;
243
+ let t = m(e.label), n = e.href == null ? "" : String(e.href);
244
+ if (!n || !h(n, this.ownerDocument.baseURI)) return n && this.warnOnce("href", "showing a link as text: its href is not http(s), mailto, tel or relative."), t;
245
+ let i = m(e.size), a = e.download === !0 ? "" : e.download || void 0;
245
246
  return r`<a href=${n} download=${a ?? o}
246
247
  >${t}${i ? r`<span aria-hidden="true"> · </span><span class="visually-hidden">, </span>${i}` : o}</a
247
248
  >`;
@@ -249,7 +250,7 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
249
250
  fromItems(e) {
250
251
  let t = [];
251
252
  for (let n of e) {
252
- let e = f(n?.label);
253
+ let e = m(n?.label);
253
254
  if (!e) {
254
255
  this.warnOnce("label", "ignoring rows with no label.");
255
256
  continue;
@@ -259,9 +260,9 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
259
260
  </ul>` : this.renderValue(n.value) };
260
261
  if (Array.isArray(n.value)) {
261
262
  i.count = n.value.length;
262
- let e = C(n.limit);
263
+ let e = T(n.limit);
263
264
  e !== void 0 && (i.limit = e);
264
- let t = f(n.limitLabel);
265
+ let t = m(n.limitLabel);
265
266
  t && (i.limitLabel = t);
266
267
  }
267
268
  t.push({
@@ -272,17 +273,17 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
272
273
  return t;
273
274
  }
274
275
  get citationText() {
275
- let e = f(this.citation);
276
+ let e = m(this.citation);
276
277
  if (e) return e;
277
- let t = f(this.citationTitle);
278
- return t ? v(t) : "";
278
+ let t = m(this.citationTitle);
279
+ return t ? b(t) : "";
279
280
  }
280
281
  renderRights() {
281
- let e = f(this.rights);
282
+ let e = m(this.rights);
282
283
  if (!e) return o;
283
284
  let t = this.ownerDocument.baseURI, n = /^https?:\/\//i.test(e) ? r`<a href=${e} rel="license"
284
- >${f(this.rightsLabel) || _(e) || "Rights statement"}</a
285
- >` : e, i = f(this.rightsInfo), a = i && p(i, t) ? r`<div><a href=${i}>${y}</a></div>` : o;
285
+ >${m(this.rightsLabel) || y(e) || "Rights statement"}</a
286
+ >` : e, i = m(this.rightsInfo), a = i && h(i, t) ? r`<div><a href=${i}>${x}</a></div>` : o;
286
287
  return r`<div class="row">
287
288
  <dt>Rights</dt>
288
289
  <dd>
@@ -310,12 +311,11 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
310
311
  u(this, ["uvalib-metadata", "copy-citation"]), clearTimeout(this.timer), this.status = "", await this.updateComplete;
311
312
  let e = "Copied";
312
313
  try {
313
- await navigator.clipboard.writeText(this.citationText);
314
+ await f(this.citationText);
314
315
  } catch {
315
- let t = this.renderRoot.querySelector(".citation");
316
- t && this.ownerDocument.getSelection()?.selectAllChildren(t), e = "Could not copy: the citation is selected, copy it with your keyboard";
316
+ d(this.renderRoot.querySelector(".citation")), e = "Could not copy: the citation is selected, copy it with your keyboard";
317
317
  }
318
- this.status = e, this.timer = setTimeout(() => this.status = "", b);
318
+ this.status = e, this.timer = setTimeout(() => this.status = "", S);
319
319
  }
320
320
  get rows() {
321
321
  return this.items ? this.fromItems(this.items) : this.childRows;
@@ -334,7 +334,7 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
334
334
  applyLimits() {
335
335
  let e = this.list;
336
336
  if (e) for (let t of e.querySelectorAll(":scope > .row > dd")) {
337
- let e = t.querySelector(x);
337
+ let e = t.querySelector(C);
338
338
  if (!e) continue;
339
339
  let n = t.dataset.key, r = n === void 0 ? Infinity : Number(t.dataset.limit), i = n !== void 0 && this.open.has(n);
340
340
  [...e.children].forEach((e, t) => {
@@ -343,7 +343,7 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
343
343
  }
344
344
  }
345
345
  limitFor(e) {
346
- return e.limit ?? C(this.listLimit) ?? 0;
346
+ return e.limit ?? T(this.listLimit) ?? 0;
347
347
  }
348
348
  get locale() {
349
349
  return this.closest("[lang]")?.getAttribute("lang") || "en";
@@ -381,9 +381,9 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
381
381
  r.focus();
382
382
  return;
383
383
  }
384
- let s = r.parentElement?.querySelector(x)?.children[n];
384
+ let s = r.parentElement?.querySelector(C)?.children[n];
385
385
  if (!(s instanceof HTMLElement)) return;
386
- let c = s.querySelector(S);
386
+ let c = s.querySelector(w);
387
387
  c ||= (s.tabIndex = -1, s), c.focus();
388
388
  }
389
389
  renderToggle(e, t, n, i) {
@@ -399,7 +399,7 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
399
399
  }
400
400
  render() {
401
401
  let e = (e, t) => {
402
- let n = f(t);
402
+ let n = m(t);
403
403
  return n ? r`<div class="row">
404
404
  <dt>${e}</dt>
405
405
  <dd>${n}</dd>
@@ -426,18 +426,18 @@ var v = (e) => `${e}, Albert and Shirley Small Special Collections Library, Univ
426
426
  }
427
427
  };
428
428
  // src/components/uvalib-metadata/uvalib-metadata.ts
429
- a([e({ type: String })], D.prototype, "creator", void 0), a([e({ type: String })], D.prototype, "organization", void 0), a([e({ type: String })], D.prototype, "rights", void 0), a([e({
429
+ a([e({ type: String })], k.prototype, "creator", void 0), a([e({ type: String })], k.prototype, "organization", void 0), a([e({ type: String })], k.prototype, "rights", void 0), a([e({
430
430
  type: String,
431
431
  attribute: "rights-label"
432
- })], D.prototype, "rightsLabel", void 0), a([e({
432
+ })], k.prototype, "rightsLabel", void 0), a([e({
433
433
  type: String,
434
434
  attribute: "rights-info"
435
- })], D.prototype, "rightsInfo", void 0), a([e({ type: String })], D.prototype, "citation", void 0), a([e({
435
+ })], k.prototype, "rightsInfo", void 0), a([e({ type: String })], k.prototype, "citation", void 0), a([e({
436
436
  type: String,
437
437
  attribute: "citation-title"
438
- })], D.prototype, "citationTitle", void 0), a([e({ attribute: !1 })], D.prototype, "items", void 0), a([e({
438
+ })], k.prototype, "citationTitle", void 0), a([e({ attribute: !1 })], k.prototype, "items", void 0), a([e({
439
439
  type: Number,
440
440
  attribute: "list-limit"
441
- })], D.prototype, "listLimit", void 0), a([n()], D.prototype, "childRows", void 0), a([n()], D.prototype, "status", void 0), i("uvalib-metadata", D);
441
+ })], k.prototype, "listLimit", void 0), a([n()], k.prototype, "childRows", void 0), a([n()], k.prototype, "status", void 0), i("uvalib-metadata", k);
442
442
 
443
443
  //# sourceMappingURL=uvalib-metadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uvalib-metadata.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","langDir","normalize","safeHref","SourceChildren","accessible","STATEMENTS","rightsName","u","href","host","path","m","licence","tool","specialCollectionsCitation","title","RIGHTS_INFO_TEXT","STATUS_MS","LIST","FOCUSABLE","limitOf","v","instances","structuralRules","shadowStructure","UvalibMetadata","nodes","root","sheet","node","kind","message","dl","key","cells","c","rows","row","label","value","list","limit","noun","clone","base","unsafe","el","size","a","span","doc","frag","dot","comma","download","A","items","own","rights","statement","info","more","text","p","source","changed","dd","open","li","l","lower","first","button","place","target","shownFrom","ri","vi"],"sources":["../src/components/uvalib-metadata/rights.ts","../src/components/uvalib-metadata/UvalibMetadata.ts","../src/components/uvalib-metadata/uvalib-metadata.ts"],"sourcesContent":["/** rightsstatements.org's statements, by their id in the URL, with their short names. */\nconst STATEMENTS: Record<string, string> = {\n INC: 'In Copyright',\n 'INC-OW-EU': 'In Copyright – EU Orphan Work',\n 'INC-EDU': 'In Copyright – Educational Use Permitted',\n 'INC-NC': 'In Copyright – Non-Commercial Use Permitted',\n 'INC-RUU': 'In Copyright – Rights-holder(s) Unlocatable or Unidentifiable',\n 'NOC-CR': 'No Copyright – Contractual Restrictions',\n 'NOC-NC': 'No Copyright – Non-Commercial Use Only',\n 'NOC-OKLR': 'No Copyright – Other Known Legal Restrictions',\n 'NOC-US': 'No Copyright – United States',\n CNE: 'Copyright Not Evaluated',\n UND: 'Copyright Undetermined',\n NKC: 'No Known Copyright',\n};\n\n/**\n * The short name of a rightsstatements.org statement or Creative Commons licence or tool from\n * its URL (\"In Copyright\", \"CC BY-NC 4.0\", \"CC0 1.0\", \"Public Domain Mark 1.0\"), or\n * `undefined` for any other URL.\n */\nexport function rightsName(href: string): string | undefined {\n let u: URL;\n try {\n u = new URL(href);\n } catch {\n return undefined;\n }\n const host = u.hostname.toLowerCase().replace(/^www\\./, '');\n const path = u.pathname;\n if (host === 'rightsstatements.org') {\n const m = /^\\/(?:vocab|page|data)\\/([a-z-]+)\\/\\d/i.exec(path);\n return m ? STATEMENTS[m[1]!.toUpperCase()] : undefined;\n }\n if (host === 'creativecommons.org') {\n const licence = /^\\/licenses\\/((?:by|nc|nd|sa)(?:-(?:by|nc|nd|sa))*)\\/(\\d+(?:\\.\\d+)*)/i.exec(\n path,\n );\n if (licence) return `CC ${licence[1]!.toUpperCase()} ${licence[2]}`;\n const tool = /^\\/publicdomain\\/(zero|mark)\\/(\\d+(?:\\.\\d+)*)/i.exec(path);\n if (tool)\n return tool[1]!.toLowerCase() === 'zero' ? `CC0 ${tool[2]}` : `Public Domain Mark ${tool[2]}`;\n }\n return undefined;\n}\n\n/** The Albert and Shirley Small Special Collections Library's citation for a title or collection. */\nexport const specialCollectionsCitation = (title: string): string =>\n `${title}, Albert and Shirley Small Special Collections Library, University of Virginia`;\n","import { css, html, nothing, unsafeCSS, type PropertyValues, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { langDir } from '../../base/inline-copy.js';\nimport { normalize, safeHref, SourceChildren } from '../../base/source-children.js';\nimport { accessible } from '../../styles/accessible.js';\nimport { rightsName, specialCollectionsCitation } from './rights.js';\n\n/** A link value: a download when it has `download` or a `size` (\"EPUB · 184 KB\"). */\nexport interface MetadataLink {\n label: string;\n href: string;\n /** The file's size as shown, such as `184 KB`. */\n size?: string;\n /** The `download` attribute: `true` for an empty one, a string for a file name. */\n download?: boolean | string;\n}\n\n/** One value: text, or a link. */\nexport type MetadataValue = string | number | MetadataLink;\n\n/** A row: its label and one value, or several (shown as a list). */\nexport interface MetadataItem {\n label: string;\n value: MetadataValue | MetadataValue[];\n /** A list value: show this many and a “Show all N” button (0: no limit). Wins over `list-limit`. */\n limit?: number;\n /** The noun in “Show all 34 participants”, instead of the label with a lowercase first letter. */\n limitLabel?: string;\n}\n\n/**\n * A value as drawn: a template or text (from `items`), or `source`, prepared copies of an\n * author's `<dd>` content that are never inserted themselves (each render set clones them).\n * `lang`/`dir` come from the source `<dd>`.\n */\ninterface Value {\n content?: TemplateResult | string;\n source?: Node[];\n lang?: string;\n dir?: string;\n /** A list value: how many `<li>` it has. */\n count?: number;\n /** The row's own limit (`data-limit`), winning over `list-limit`. */\n limit?: number;\n /** The noun in the toggle (`data-limit-label`). */\n limitLabel?: string;\n}\n\n/** A row as drawn; `lang`/`dir` come from the source `<dt>`. */\ninterface Row {\n label: string;\n lang?: string;\n dir?: string;\n values: Value[];\n}\n\nconst RIGHTS_INFO_TEXT = 'More about rights and permissions';\nconst STATUS_MS = 5000;\n/** The list in a value: a `<ul>` or `<ol>` that is a direct child of the `<dd>`. */\nconst LIST = ':scope > ul, :scope > ol';\n/** What takes focus inside a revealed value, before the value itself. */\nconst FOCUSABLE = 'a[href], button, input, select, textarea, [tabindex]:not([tabindex=\"-1\"])';\n\n/** A limit: a whole number of at least 0, else undefined. */\nconst limitOf = (v: unknown): number | undefined => {\n if (v === null || v === undefined || (typeof v === 'string' && !v.trim())) return undefined;\n const n = Math.trunc(Number(v));\n return Number.isFinite(n) ? Math.max(0, n) : undefined;\n};\n\nlet instances = 0;\n\n/**\n * The rules kept with `no-style`: unmarked value lists, the terms and values stacked, the\n * visually hidden text hidden, and `[hidden]` hides.\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} dl, ${host} dd { margin: 0; }\n ${host} dd :is(ul, ol) { list-style: none; margin: 0; padding: 0; }\n ${host} :where(.more) {\n display: inline-flex;\n align-items: center;\n box-sizing: border-box;\n min-height: 24px;\n min-width: 24px;\n margin-top: 0.25rem;\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/**\n * A record's details as a description list, as on the library's digital collections: label\n * and value side by side on wide screens (the element's own width, 36rem and up), stacked on\n * narrow ones. Values may be text, links or lists (subjects).\n *\n * Give the rows as a `<dl>` child (so the page reads the same before the script loads):\n * `<dt>` labels and `<dd>` values, optionally wrapped in a `<div>` per row; several `<dd>`\n * after one `<dt>` are several values. The values are copied as written (links, lists,\n * `download` attributes kept); a link with `data-size=\"184 KB\"` is shown as a download,\n * \"EPUB · 184 KB\". The list follows changes to the children. Apps set the `items`\n * property instead (`{ label, value }`, winning over the children while set).\n *\n * Built-in rows for credit and rights (as Special Collections asks): `creator` and\n * `organization` come first; `rights` (a rightsstatements.org or Creative Commons URL, shown\n * as its short name linked to it, or plain text) and `citation` (\"How to cite\", with a Copy\n * citation button that announces \"Copied\" politely) come last. `citation-title` builds the\n * Special Collections citation, \"<title>, Albert and Shirley Small Special Collections\n * Library, University of Virginia\".\n *\n * Long lists: `list-limit=\"8\"` shortens every value that is a list (a `<ul>`/`<ol>` in the\n * `<dd>`) of more than 8 items to its first 8 and a “Show all 34 participants” button\n * (`aria-expanded`, `aria-controls`) that reveals the rest in place and moves focus to the\n * first one; it then reads “Show fewer”. `data-limit` on a `<dd>` or its list sets that row's\n * own limit (`0`: none); the noun is the label with a lowercase first letter, or\n * `data-limit-label`. Every value stays in the markup (the hidden ones `hidden`).\n *\n * @tagname uvalib-metadata\n * @fires uvalib-analytics-event - For `<site-analytics>`: the Copy citation button, `['uvalib-metadata', 'copy-citation']`, and a list's toggle, `['uvalib-metadata', 'show-all'|'show-fewer', 'row N']` (N from 1, the row's place in the list; never its label or values). Downloads are left to Matomo's own download tracking. Bubbles and is composed.\n * @cssprop [--uva-blue-alt-dark=#005679] - Link colour.\n * @cssprop [--uva-grey-darkest=#2b2b2b] - Value colour.\n * @cssprop --uva-color-utility-link - Dark-mode role token: link colour (else `--uva-blue-alt-dark`).\n * @cssprop --uva-color-text - Dark-mode role token: value colour (else `--uva-grey-darkest`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: label and status colour (else #4b5563).\n * @cssprop --uva-color-border - Dark-mode role token: row dividers (else #dadada).\n * @cssprop --uva-color-link - Dark-mode role token: the buttons' text and the Copy citation button's border (else `--uva-brand-blue`).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: the button's background (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibMetadata extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n container-type: inline-size;\n font-size: 1rem;\n line-height: 1.5;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n overflow-wrap: anywhere;\n }\n .row {\n display: grid;\n grid-template-columns: minmax(7rem, 12rem) minmax(0, 1fr);\n column-gap: 1.5rem;\n padding-block: 0.5rem;\n border-top: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n }\n .row:first-child {\n border-top: 0;\n }\n /* Short labels balanced; values and the citation without a one-word last line. */\n dt {\n grid-column: 1;\n color: var(--uva-color-text-muted, #4b5563);\n font-weight: 700;\n text-wrap: balance;\n }\n dd {\n grid-column: 2;\n text-wrap: pretty;\n }\n @container (width < 36rem) {\n .row {\n grid-template-columns: minmax(0, 1fr);\n }\n dt,\n dd {\n grid-column: 1;\n }\n }\n dd li + li {\n margin-top: 0.25rem;\n }\n a {\n color: var(--uva-color-utility-link, var(--uva-blue-alt-dark, #005679));\n text-decoration: underline;\n }\n .citation {\n margin: 0 0 0.5rem;\n }\n .copy {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.5rem 0.75rem;\n }\n .uvalib-button {\n min-height: 44px;\n padding: 0.25rem 0.75rem;\n border: 1px solid var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n border-radius: 0.3rem;\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n cursor: pointer;\n }\n .status {\n color: var(--uva-color-text-muted, #4b5563);\n }\n /* As <uvalib-tag-list>'s Show all: an underlined text button, 2rem square at least. */\n .more {\n min-height: 2rem;\n min-width: 2rem;\n padding: 0.15rem 0;\n border: 0;\n background: none;\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n text-align: start;\n text-decoration: underline;\n cursor: pointer;\n }\n @media (forced-colors: active) {\n .more {\n color: ButtonText;\n }\n }\n `,\n ];\n\n /** The creator (author, photographer…), shown first. */\n @property({ type: String }) creator?: string;\n\n /** The organization holding or crediting the item, shown after the creator. */\n @property({ type: String }) organization?: string;\n\n /**\n * The rights statement: a rightsstatements.org or Creative Commons URL (shown as its short\n * name, linked), another http(s) URL (shown as `rights-label`, or \"Rights statement\"), or\n * plain text.\n */\n @property({ type: String }) rights?: string;\n\n /** The link text for a `rights` URL, instead of its short name. */\n @property({ type: String, attribute: 'rights-label' }) rightsLabel?: string;\n\n /**\n * A \"More about rights and permissions\" link under the statement, such as\n * `https://www.library.virginia.edu/policies/use-of-materials`.\n */\n @property({ type: String, attribute: 'rights-info' }) rightsInfo?: string;\n\n /** \"How to cite\": the citation, as written. Wins over `citation-title`. */\n @property({ type: String }) citation?: string;\n\n /**\n * A title or collection name for the Special Collections citation: \"<title>, Albert and\n * Shirley Small Special Collections Library, University of Virginia\".\n */\n @property({ type: String, attribute: 'citation-title' }) citationTitle?: string;\n\n /**\n * The rows as data, for apps that build them in JavaScript: `{ label, value }`, a value\n * being text, a link `{ label, href, size?, download? }` or an array of them (a list).\n * Wins over the children while set; `undefined` goes back to them.\n */\n @property({ attribute: false }) items?: MetadataItem[];\n\n /**\n * Shorten every list value of more than this many items to its first ones and a “Show all\n * N” button. Zero or empty shows every item. A row's `data-limit` wins.\n */\n @property({ type: Number, attribute: 'list-limit' }) listLimit?: number;\n\n @state() private childRows: Row[] = [];\n /** The list values shown in full (after Show all), by `row-value` place. */\n private open = new Set<string>();\n /** The items this element hid, so that only those are shown again. */\n private hid = new WeakSet<Element>();\n private readonly uid = `uvalib-metadata-${++instances}`;\n /** The Copy citation button's result, announced politely. */\n @state() private status = '';\n\n private sourceKey = '';\n private warned = new Set<string>();\n private timer?: ReturnType<typeof setTimeout>;\n\n constructor() {\n super();\n new SourceChildren(\n this,\n () => this.lightDom,\n (nodes) => this.read(nodes),\n );\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n clearTimeout(this.timer);\n this.status = '';\n }\n\n private warnOnce(kind: string, message: string): void {\n if (this.warned.has(kind)) return;\n this.warned.add(kind);\n console.warn(`${this.localName}: ${message}`);\n }\n\n /** Read the rows from the first `<dl>` among the children. */\n private read(nodes: Node[]): void {\n let dl: Element | null = null;\n for (const n of nodes) {\n if (!(n instanceof Element)) continue;\n dl = n.localName === 'dl' ? n : n.querySelector('dl');\n if (dl) break;\n }\n const key = dl?.outerHTML ?? '';\n // Only a real change re-renders.\n if (key === this.sourceKey) return;\n this.sourceKey = key;\n this.childRows = dl ? this.parse(dl) : [];\n }\n\n private parse(dl: Element): Row[] {\n const cells = [...dl.children].flatMap((c) => (c.localName === 'div' ? [...c.children] : [c]));\n const rows: Row[] = [];\n let row: Row | undefined;\n for (const c of cells) {\n if (c.localName === 'dt') {\n const label = normalize(c.textContent);\n if (!label) continue;\n // Several <dt> before their values name one row.\n if (row && !row.values.length) row.label += ` / ${label}`;\n else rows.push((row = { label, values: [], ...langDir(c) }));\n } else if (c.localName === 'dd') {\n if (!row) {\n this.warnOnce('dd', 'ignoring a <dd> with no <dt> before it.');\n continue;\n }\n const value: Value = { source: [...c.childNodes].map((n) => this.copy(n)), ...langDir(c) };\n const list = c.querySelector(LIST);\n if (list) {\n value.count = list.querySelectorAll(':scope > li').length;\n const limit = limitOf(c.getAttribute('data-limit') ?? list.getAttribute('data-limit'));\n if (limit !== undefined) value.limit = limit;\n const noun = normalize(\n c.getAttribute('data-limit-label') ?? list.getAttribute('data-limit-label'),\n );\n if (noun) value.limitLabel = noun;\n }\n row.values.push(value);\n }\n }\n return rows.filter((r) => r.values.length);\n }\n\n /**\n * A copy of an author's node: links with an unsafe href (javascript:, data:, …) replaced\n * by their content, with one warning; sizes added to downloads once (not when the link's\n * text already ends with it), `data-size` dropped; ids dropped in light DOM.\n */\n private copy(n: Node): Node {\n const clone = n.cloneNode(true);\n if (!(clone instanceof Element)) return clone;\n const base = this.ownerDocument.baseURI;\n const unsafe: Element[] = [];\n for (const el of [clone, ...clone.querySelectorAll('*')]) {\n if (this.lightDom) el.removeAttribute('id');\n el.removeAttribute('data-limit');\n el.removeAttribute('data-limit-label');\n if (el.localName !== 'a') continue;\n const href = el.getAttribute('href');\n if (href !== null && !safeHref(href, base)) {\n this.warnOnce(\n 'href',\n 'showing a link as text: its href is not http(s), mailto, tel or relative.',\n );\n unsafe.push(el);\n }\n const size = normalize(el.getAttribute('data-size'));\n el.removeAttribute('data-size');\n if (size && !normalize(el.textContent).endsWith(size)) el.append(this.sizeNodes(size));\n }\n // An unsafe link keeps only its content (in a <span> when it is the copied node itself).\n for (const a of unsafe.reverse()) {\n if (a !== clone) {\n a.replaceWith(...a.childNodes);\n continue;\n }\n const span = this.ownerDocument.createElement('span');\n span.append(...a.childNodes);\n return span;\n }\n return clone;\n }\n\n /** \" · 184 KB\", read as \", 184 KB\". */\n private sizeNodes(size: string): DocumentFragment {\n const doc = this.ownerDocument;\n const frag = doc.createDocumentFragment();\n const dot = doc.createElement('span');\n dot.setAttribute('aria-hidden', 'true');\n dot.textContent = ' · ';\n const comma = doc.createElement('span');\n comma.className = 'visually-hidden';\n comma.textContent = ', ';\n frag.append(dot, comma, size);\n return frag;\n }\n\n private renderValue(v: MetadataValue): TemplateResult | string {\n if (v === null || v === undefined) return '';\n if (typeof v !== 'object') return String(v);\n const label = normalize(v.label);\n const href = v.href == null ? '' : String(v.href);\n if (!href || !safeHref(href, this.ownerDocument.baseURI)) {\n if (href)\n this.warnOnce(\n 'href',\n 'showing a link as text: its href is not http(s), mailto, tel or relative.',\n );\n return label;\n }\n const size = normalize(v.size);\n const download = v.download === true ? '' : v.download || undefined;\n return html`<a href=${href} download=${download ?? nothing}\n >${label}${\n size\n ? html`<span aria-hidden=\"true\"> · </span><span class=\"visually-hidden\">, </span>${size}`\n : nothing\n }</a\n >`;\n }\n\n private fromItems(items: readonly MetadataItem[]): Row[] {\n const rows: Row[] = [];\n for (const i of items) {\n const label = normalize(i?.label);\n if (!label) {\n this.warnOnce('label', 'ignoring rows with no label.');\n continue;\n }\n const value = Array.isArray(i.value)\n ? html`<ul role=\"list\">\n ${i.value.map((v) => html`<li>${this.renderValue(v)}</li>`)}\n </ul>`\n : this.renderValue(i.value);\n const v: Value = { content: value };\n if (Array.isArray(i.value)) {\n v.count = i.value.length;\n const limit = limitOf(i.limit);\n if (limit !== undefined) v.limit = limit;\n const noun = normalize(i.limitLabel);\n if (noun) v.limitLabel = noun;\n }\n rows.push({ label, values: [v] });\n }\n return rows;\n }\n\n /** The citation text: `citation`, else the Special Collections one for `citation-title`. */\n private get citationText(): string {\n const own = normalize(this.citation);\n if (own) return own;\n const title = normalize(this.citationTitle);\n return title ? specialCollectionsCitation(title) : '';\n }\n\n private renderRights(): TemplateResult | typeof nothing {\n const rights = normalize(this.rights);\n if (!rights) return nothing;\n const base = this.ownerDocument.baseURI;\n const isUrl = /^https?:\\/\\//i.test(rights);\n const statement = isUrl\n ? html`<a href=${rights} rel=\"license\"\n >${normalize(this.rightsLabel) || rightsName(rights) || 'Rights statement'}</a\n >`\n : rights;\n const info = normalize(this.rightsInfo);\n const more =\n info && safeHref(info, base)\n ? html`<div><a href=${info}>${RIGHTS_INFO_TEXT}</a></div>`\n : nothing;\n return html`<div class=\"row\">\n <dt>Rights</dt>\n <dd>\n <div>${statement}</div>\n ${more}\n </dd>\n </div>`;\n }\n\n private renderCitation(): TemplateResult | typeof nothing {\n const text = this.citationText;\n if (!text) return nothing;\n return html`<div class=\"row\">\n <dt>How to cite</dt>\n <dd>\n <p class=\"citation\">${text}</p>\n <div class=\"copy\">\n <button type=\"button\" class=\"uvalib-button\" @click=${this.copyCitation}>\n Copy citation\n </button>\n <span class=\"status\" role=\"status\">${this.status}</span>\n </div>\n </dd>\n </div>`;\n }\n\n /** Copy the citation; on failure select it, so the keyboard can copy it. */\n private async copyCitation(): Promise<void> {\n trackEvent(this, ['uvalib-metadata', 'copy-citation']);\n clearTimeout(this.timer);\n // Cleared first, so a second copy is announced again.\n this.status = '';\n await this.updateComplete;\n let message = 'Copied';\n try {\n await navigator.clipboard.writeText(this.citationText);\n } catch {\n const p = this.renderRoot.querySelector('.citation');\n if (p) this.ownerDocument.getSelection()?.selectAllChildren(p);\n message = 'Could not copy: the citation is selected, copy it with your keyboard';\n }\n this.status = message;\n this.timer = setTimeout(() => (this.status = ''), STATUS_MS);\n }\n\n private get rows(): Row[] {\n return this.items ? this.fromItems(this.items) : this.childRows;\n }\n\n /** The rows' source the clones below were made for. */\n private clonedFor?: unknown;\n private clones = new WeakMap<Node[], Node[]>();\n\n /**\n * A value's nodes: fresh clones of its prepared source whenever the rows shown change\n * (new markup, or back from `items`), reused by unrelated updates (the citation status) so\n * that focus in a value is not lost.\n */\n private nodesOf(source: Node[]): Node[] {\n let c = this.clones.get(source);\n if (!c) this.clones.set(source, (c = source.map((n) => n.cloneNode(true))));\n return c;\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.toggleAttribute('data-empty', !this.renderRoot.querySelector('.row'));\n this.applyLimits();\n }\n\n /** The rendered `<dl>` (in light DOM, not the author's source). */\n private get list(): HTMLElement | null {\n const root = this.renderRoot;\n return root instanceof ShadowRoot\n ? root.querySelector('dl')\n : (root as HTMLElement).querySelector(':scope > dl');\n }\n\n /**\n * Hide the items past each shortened list's limit (until Show all), and show again the\n * ones this element hid when the list is open or no longer shortened.\n */\n private applyLimits(): void {\n const dl = this.list;\n if (!dl) return;\n for (const dd of dl.querySelectorAll<HTMLElement>(':scope > .row > dd')) {\n const list = dd.querySelector(LIST);\n if (!list) continue;\n const key = dd.dataset.key;\n const limit = key === undefined ? Infinity : Number(dd.dataset.limit);\n const open = key !== undefined && this.open.has(key);\n [...list.children].forEach((li, i) => {\n if (!(li instanceof HTMLElement) || li.localName !== 'li') return;\n if (!open && i >= limit) {\n if (!li.hidden) this.hid.add(li);\n li.hidden = true;\n } else if (this.hid.has(li)) {\n li.hidden = false;\n this.hid.delete(li);\n }\n });\n if (key === undefined) continue;\n if (!list.id) list.id = `${this.uid}-list-${key}`;\n dd.querySelector(':scope > .more')?.setAttribute('aria-controls', list.id);\n }\n }\n\n /** A value's limit: its own, else `list-limit`; 0 for none. */\n private limitFor(v: Value): number {\n return v.limit ?? limitOf(this.listLimit) ?? 0;\n }\n\n private get locale(): string {\n return this.closest('[lang]')?.getAttribute('lang') || 'en';\n }\n\n /** The toggle's noun: `data-limit-label`, else the label with a lowercase first letter\n * (kept as written when it starts with an acronym, “ORCID iDs”). */\n private noun(r: Row, v: Value): TemplateResult | string {\n if (v.limitLabel) return v.limitLabel;\n const l = r.label;\n let lower = l;\n if (!/^\\p{Lu}{2}/u.test(l)) {\n const first = l.charAt(0);\n try {\n lower = first.toLocaleLowerCase(r.lang || this.locale) + l.slice(1);\n } catch {\n lower = first.toLowerCase() + l.slice(1);\n }\n }\n return r.lang || r.dir\n ? html`<span lang=${r.lang ?? nothing} dir=${r.dir ?? nothing}>${lower}</span>`\n : lower;\n }\n\n private formatCount(n: number): string {\n try {\n return n.toLocaleString(this.locale);\n } catch {\n return n.toLocaleString('en');\n }\n }\n\n private async toggleList(e: Event, key: string, limit: number): Promise<void> {\n const button = e.currentTarget as HTMLElement;\n const open = !this.open.has(key);\n if (open) this.open.add(key);\n else this.open.delete(key);\n const row = button.closest('.row');\n const place = row?.parentElement ? [...row.parentElement.children].indexOf(row) + 1 : 1;\n trackEvent(this, ['uvalib-metadata', open ? 'show-all' : 'show-fewer', `row ${place}`]);\n this.requestUpdate();\n await this.updateComplete;\n if (!button.isConnected) return;\n if (!open) {\n button.focus();\n return;\n }\n const li = button.parentElement?.querySelector(LIST)?.children[limit];\n if (!(li instanceof HTMLElement)) return;\n let target = li.querySelector<HTMLElement>(FOCUSABLE);\n if (!target) {\n li.tabIndex = -1;\n target = li;\n }\n target.focus();\n }\n\n private renderToggle(r: Row, v: Value, key: string, limit: number) {\n const open = this.open.has(key);\n const noun = this.noun(r, v);\n return html`<button\n type=\"button\"\n class=\"more\"\n aria-expanded=${open ? 'true' : 'false'}\n @click=${(e: Event) => this.toggleList(e, key, limit)}\n >\n ${\n open\n ? html`Show fewer<span class=\"visually-hidden\"> ${noun}</span>`\n : html`Show all ${this.formatCount(v.count ?? 0)} ${noun}`\n }\n </button>`;\n }\n\n protected override render() {\n const text = (label: string, value?: string) => {\n const v = normalize(value);\n return v\n ? html`<div class=\"row\">\n <dt>${label}</dt>\n <dd>${v}</dd>\n </div>`\n : nothing;\n };\n const shownFrom = this.items ?? this.childRows;\n if (shownFrom !== this.clonedFor) {\n this.clonedFor = shownFrom;\n this.clones = new WeakMap();\n this.open = new Set();\n }\n return html`<dl>\n ${text('Creator', this.creator)}${text('Organization', this.organization)}\n ${this.rows.map(\n (r, ri) =>\n html`<div class=\"row\">\n <dt lang=${r.lang ?? nothing} dir=${r.dir ?? nothing}>${r.label}</dt>\n ${r.values.map((v, vi) => {\n const limit = this.limitFor(v);\n const key = limit > 0 && (v.count ?? 0) > limit ? `${ri}-${vi}` : undefined;\n return html`<dd\n lang=${v.lang ?? nothing}\n dir=${v.dir ?? nothing}\n data-key=${key ?? nothing}\n data-limit=${key ? limit : nothing}\n >\n ${v.source ? this.nodesOf(v.source) : v.content}${\n key ? this.renderToggle(r, v, key, limit) : nothing\n }\n </dd>`;\n })}\n </div>`,\n )}\n ${this.renderRights()}${this.renderCitation()}\n </dl>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibMetadata } from './UvalibMetadata.js';\n\ndefine('uvalib-metadata', UvalibMetadata);\n"],"mappings":";;;;;;AACA,IAAMoB,IAAqC;CACzC,KAAK;CACL,aAAa;CACb,WAAW;CACX,UAAU;CACV,WAAW;CACX,UAAU;CACV,UAAU;CACV,YAAY;CACZ,UAAU;CACV,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAOA,SAAgBC,EAAW,GAAkC;CAC3D,IAAIC;CACJ,IAAI;EACF,IAAI,IAAI,IAAIC,CAAI;CAClB,QAAQ;EACN;CACF;CACA,IAAMC,IAAOF,EAAE,SAAS,YAAY,CAAC,CAAC,QAAQ,UAAU,EAAE,GACpDG,IAAOH,EAAE;CACf,IAAIE,MAAS,wBAAwB;EACnC,IAAME,IAAI,yCAAyC,KAAKD,CAAI;EAC5D,OAAOC,IAAIN,EAAWM,EAAE,EAAE,CAAE,YAAY,KAAK,KAAA;CAC/C;CACA,IAAIF,MAAS,uBAAuB;EAClC,IAAMG,IAAU,wEAAwE,KACtFF,CACF;EACA,IAAIE,GAAS,OAAO,MAAMA,EAAQ,EAA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AA,GCjRT/B,EAAO,mBAAmB+B,CAAc"}
1
+ {"version":3,"file":"uvalib-metadata.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","selectContents","copyText","langDir","normalize","safeHref","SourceChildren","accessible","STATEMENTS","rightsName","u","href","host","path","m","licence","tool","specialCollectionsCitation","title","RIGHTS_INFO_TEXT","STATUS_MS","LIST","FOCUSABLE","limitOf","v","instances","structuralRules","shadowStructure","UvalibMetadata","nodes","root","sheet","node","kind","message","dl","key","cells","c","rows","row","label","value","list","limit","noun","clone","base","unsafe","el","size","a","span","doc","frag","dot","comma","download","A","items","own","rights","statement","info","more","text","source","changed","dd","open","li","l","lower","first","button","place","target","shownFrom","ri","vi"],"sources":["../src/components/uvalib-metadata/rights.ts","../src/components/uvalib-metadata/UvalibMetadata.ts","../src/components/uvalib-metadata/uvalib-metadata.ts"],"sourcesContent":["/** rightsstatements.org's statements, by their id in the URL, with their short names. */\nconst STATEMENTS: Record<string, string> = {\n INC: 'In Copyright',\n 'INC-OW-EU': 'In Copyright – EU Orphan Work',\n 'INC-EDU': 'In Copyright – Educational Use Permitted',\n 'INC-NC': 'In Copyright – Non-Commercial Use Permitted',\n 'INC-RUU': 'In Copyright – Rights-holder(s) Unlocatable or Unidentifiable',\n 'NOC-CR': 'No Copyright – Contractual Restrictions',\n 'NOC-NC': 'No Copyright – Non-Commercial Use Only',\n 'NOC-OKLR': 'No Copyright – Other Known Legal Restrictions',\n 'NOC-US': 'No Copyright – United States',\n CNE: 'Copyright Not Evaluated',\n UND: 'Copyright Undetermined',\n NKC: 'No Known Copyright',\n};\n\n/**\n * The short name of a rightsstatements.org statement or Creative Commons licence or tool from\n * its URL (\"In Copyright\", \"CC BY-NC 4.0\", \"CC0 1.0\", \"Public Domain Mark 1.0\"), or\n * `undefined` for any other URL.\n */\nexport function rightsName(href: string): string | undefined {\n let u: URL;\n try {\n u = new URL(href);\n } catch {\n return undefined;\n }\n const host = u.hostname.toLowerCase().replace(/^www\\./, '');\n const path = u.pathname;\n if (host === 'rightsstatements.org') {\n const m = /^\\/(?:vocab|page|data)\\/([a-z-]+)\\/\\d/i.exec(path);\n return m ? STATEMENTS[m[1]!.toUpperCase()] : undefined;\n }\n if (host === 'creativecommons.org') {\n const licence = /^\\/licenses\\/((?:by|nc|nd|sa)(?:-(?:by|nc|nd|sa))*)\\/(\\d+(?:\\.\\d+)*)/i.exec(\n path,\n );\n if (licence) return `CC ${licence[1]!.toUpperCase()} ${licence[2]}`;\n const tool = /^\\/publicdomain\\/(zero|mark)\\/(\\d+(?:\\.\\d+)*)/i.exec(path);\n if (tool)\n return tool[1]!.toLowerCase() === 'zero' ? `CC0 ${tool[2]}` : `Public Domain Mark ${tool[2]}`;\n }\n return undefined;\n}\n\n/** The Albert and Shirley Small Special Collections Library's citation for a title or collection. */\nexport const specialCollectionsCitation = (title: string): string =>\n `${title}, Albert and Shirley Small Special Collections Library, University of Virginia`;\n","import { css, html, nothing, unsafeCSS, type PropertyValues, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { copyText, selectContents } from '../../base/clipboard.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { langDir } from '../../base/inline-copy.js';\nimport { normalize, safeHref, SourceChildren } from '../../base/source-children.js';\nimport { accessible } from '../../styles/accessible.js';\nimport { rightsName, specialCollectionsCitation } from './rights.js';\n\n/** A link value: a download when it has `download` or a `size` (\"EPUB · 184 KB\"). */\nexport interface MetadataLink {\n label: string;\n href: string;\n /** The file's size as shown, such as `184 KB`. */\n size?: string;\n /** The `download` attribute: `true` for an empty one, a string for a file name. */\n download?: boolean | string;\n}\n\n/** One value: text, or a link. */\nexport type MetadataValue = string | number | MetadataLink;\n\n/** A row: its label and one value, or several (shown as a list). */\nexport interface MetadataItem {\n label: string;\n value: MetadataValue | MetadataValue[];\n /** A list value: show this many and a “Show all N” button (0: no limit). Wins over `list-limit`. */\n limit?: number;\n /** The noun in “Show all 34 participants”, instead of the label with a lowercase first letter. */\n limitLabel?: string;\n}\n\n/**\n * A value as drawn: a template or text (from `items`), or `source`, prepared copies of an\n * author's `<dd>` content that are never inserted themselves (each render set clones them).\n * `lang`/`dir` come from the source `<dd>`.\n */\ninterface Value {\n content?: TemplateResult | string;\n source?: Node[];\n lang?: string;\n dir?: string;\n /** A list value: how many `<li>` it has. */\n count?: number;\n /** The row's own limit (`data-limit`), winning over `list-limit`. */\n limit?: number;\n /** The noun in the toggle (`data-limit-label`). */\n limitLabel?: string;\n}\n\n/** A row as drawn; `lang`/`dir` come from the source `<dt>`. */\ninterface Row {\n label: string;\n lang?: string;\n dir?: string;\n values: Value[];\n}\n\nconst RIGHTS_INFO_TEXT = 'More about rights and permissions';\nconst STATUS_MS = 5000;\n/** The list in a value: a `<ul>` or `<ol>` that is a direct child of the `<dd>`. */\nconst LIST = ':scope > ul, :scope > ol';\n/** What takes focus inside a revealed value, before the value itself. */\nconst FOCUSABLE = 'a[href], button, input, select, textarea, [tabindex]:not([tabindex=\"-1\"])';\n\n/** A limit: a whole number of at least 0, else undefined. */\nconst limitOf = (v: unknown): number | undefined => {\n if (v === null || v === undefined || (typeof v === 'string' && !v.trim())) return undefined;\n const n = Math.trunc(Number(v));\n return Number.isFinite(n) ? Math.max(0, n) : undefined;\n};\n\nlet instances = 0;\n\n/**\n * The rules kept with `no-style`: unmarked value lists, the terms and values stacked, the\n * visually hidden text hidden, and `[hidden]` hides.\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} dl, ${host} dd { margin: 0; }\n ${host} dd :is(ul, ol) { list-style: none; margin: 0; padding: 0; }\n ${host} :where(.more) {\n display: inline-flex;\n align-items: center;\n box-sizing: border-box;\n min-height: 24px;\n min-width: 24px;\n margin-top: 0.25rem;\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/**\n * A record's details as a description list, as on the library's digital collections: label\n * and value side by side on wide screens (the element's own width, 36rem and up), stacked on\n * narrow ones. Values may be text, links or lists (subjects).\n *\n * Give the rows as a `<dl>` child (so the page reads the same before the script loads):\n * `<dt>` labels and `<dd>` values, optionally wrapped in a `<div>` per row; several `<dd>`\n * after one `<dt>` are several values. The values are copied as written (links, lists,\n * `download` attributes kept); a link with `data-size=\"184 KB\"` is shown as a download,\n * \"EPUB · 184 KB\". The list follows changes to the children. Apps set the `items`\n * property instead (`{ label, value }`, winning over the children while set).\n *\n * Built-in rows for credit and rights (as Special Collections asks): `creator` and\n * `organization` come first; `rights` (a rightsstatements.org or Creative Commons URL, shown\n * as its short name linked to it, or plain text) and `citation` (\"How to cite\", with a Copy\n * citation button that announces \"Copied\" politely) come last. `citation-title` builds the\n * Special Collections citation, \"<title>, Albert and Shirley Small Special Collections\n * Library, University of Virginia\".\n *\n * Long lists: `list-limit=\"8\"` shortens every value that is a list (a `<ul>`/`<ol>` in the\n * `<dd>`) of more than 8 items to its first 8 and a “Show all 34 participants” button\n * (`aria-expanded`, `aria-controls`) that reveals the rest in place and moves focus to the\n * first one; it then reads “Show fewer”. `data-limit` on a `<dd>` or its list sets that row's\n * own limit (`0`: none); the noun is the label with a lowercase first letter, or\n * `data-limit-label`. Every value stays in the markup (the hidden ones `hidden`).\n *\n * @tagname uvalib-metadata\n * @fires uvalib-analytics-event - For `<site-analytics>`: the Copy citation button, `['uvalib-metadata', 'copy-citation']`, and a list's toggle, `['uvalib-metadata', 'show-all'|'show-fewer', 'row N']` (N from 1, the row's place in the list; never its label or values). Downloads are left to Matomo's own download tracking. Bubbles and is composed.\n * @cssprop [--uva-blue-alt-dark=#005679] - Link colour.\n * @cssprop [--uva-grey-darkest=#2b2b2b] - Value colour.\n * @cssprop --uva-color-utility-link - Dark-mode role token: link colour (else `--uva-blue-alt-dark`).\n * @cssprop --uva-color-text - Dark-mode role token: value colour (else `--uva-grey-darkest`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: label and status colour (else #4b5563).\n * @cssprop --uva-color-border - Dark-mode role token: row dividers (else #dadada).\n * @cssprop --uva-color-link - Dark-mode role token: the buttons' text and the Copy citation button's border (else `--uva-brand-blue`).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: the button's background (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibMetadata extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n container-type: inline-size;\n font-size: 1rem;\n line-height: 1.5;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n overflow-wrap: anywhere;\n }\n .row {\n display: grid;\n grid-template-columns: minmax(7rem, 12rem) minmax(0, 1fr);\n column-gap: 1.5rem;\n padding-block: 0.5rem;\n border-top: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n }\n .row:first-child {\n border-top: 0;\n }\n /* Short labels balanced; values and the citation without a one-word last line. */\n dt {\n grid-column: 1;\n color: var(--uva-color-text-muted, #4b5563);\n font-weight: 700;\n text-wrap: balance;\n }\n dd {\n grid-column: 2;\n text-wrap: pretty;\n }\n @container (width < 36rem) {\n .row {\n grid-template-columns: minmax(0, 1fr);\n }\n dt,\n dd {\n grid-column: 1;\n }\n }\n dd li + li {\n margin-top: 0.25rem;\n }\n a {\n color: var(--uva-color-utility-link, var(--uva-blue-alt-dark, #005679));\n text-decoration: underline;\n }\n .citation {\n margin: 0 0 0.5rem;\n }\n .copy {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.5rem 0.75rem;\n }\n .uvalib-button {\n min-height: 44px;\n padding: 0.25rem 0.75rem;\n border: 1px solid var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n border-radius: 0.3rem;\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n cursor: pointer;\n }\n .status {\n color: var(--uva-color-text-muted, #4b5563);\n }\n /* As <uvalib-tag-list>'s Show all: an underlined text button, 2rem square at least. */\n .more {\n min-height: 2rem;\n min-width: 2rem;\n padding: 0.15rem 0;\n border: 0;\n background: none;\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n text-align: start;\n text-decoration: underline;\n cursor: pointer;\n }\n @media (forced-colors: active) {\n .more {\n color: ButtonText;\n }\n }\n `,\n ];\n\n /** The creator (author, photographer…), shown first. */\n @property({ type: String }) creator?: string;\n\n /** The organization holding or crediting the item, shown after the creator. */\n @property({ type: String }) organization?: string;\n\n /**\n * The rights statement: a rightsstatements.org or Creative Commons URL (shown as its short\n * name, linked), another http(s) URL (shown as `rights-label`, or \"Rights statement\"), or\n * plain text.\n */\n @property({ type: String }) rights?: string;\n\n /** The link text for a `rights` URL, instead of its short name. */\n @property({ type: String, attribute: 'rights-label' }) rightsLabel?: string;\n\n /**\n * A \"More about rights and permissions\" link under the statement, such as\n * `https://www.library.virginia.edu/policies/use-of-materials`.\n */\n @property({ type: String, attribute: 'rights-info' }) rightsInfo?: string;\n\n /** \"How to cite\": the citation, as written. Wins over `citation-title`. */\n @property({ type: String }) citation?: string;\n\n /**\n * A title or collection name for the Special Collections citation: \"<title>, Albert and\n * Shirley Small Special Collections Library, University of Virginia\".\n */\n @property({ type: String, attribute: 'citation-title' }) citationTitle?: string;\n\n /**\n * The rows as data, for apps that build them in JavaScript: `{ label, value }`, a value\n * being text, a link `{ label, href, size?, download? }` or an array of them (a list).\n * Wins over the children while set; `undefined` goes back to them.\n */\n @property({ attribute: false }) items?: MetadataItem[];\n\n /**\n * Shorten every list value of more than this many items to its first ones and a “Show all\n * N” button. Zero or empty shows every item. A row's `data-limit` wins.\n */\n @property({ type: Number, attribute: 'list-limit' }) listLimit?: number;\n\n @state() private childRows: Row[] = [];\n /** The list values shown in full (after Show all), by `row-value` place. */\n private open = new Set<string>();\n /** The items this element hid, so that only those are shown again. */\n private hid = new WeakSet<Element>();\n private readonly uid = `uvalib-metadata-${++instances}`;\n /** The Copy citation button's result, announced politely. */\n @state() private status = '';\n\n private sourceKey = '';\n private warned = new Set<string>();\n private timer?: ReturnType<typeof setTimeout>;\n\n constructor() {\n super();\n new SourceChildren(\n this,\n () => this.lightDom,\n (nodes) => this.read(nodes),\n );\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n clearTimeout(this.timer);\n this.status = '';\n }\n\n private warnOnce(kind: string, message: string): void {\n if (this.warned.has(kind)) return;\n this.warned.add(kind);\n console.warn(`${this.localName}: ${message}`);\n }\n\n /** Read the rows from the first `<dl>` among the children. */\n private read(nodes: Node[]): void {\n let dl: Element | null = null;\n for (const n of nodes) {\n if (!(n instanceof Element)) continue;\n dl = n.localName === 'dl' ? n : n.querySelector('dl');\n if (dl) break;\n }\n const key = dl?.outerHTML ?? '';\n // Only a real change re-renders.\n if (key === this.sourceKey) return;\n this.sourceKey = key;\n this.childRows = dl ? this.parse(dl) : [];\n }\n\n private parse(dl: Element): Row[] {\n const cells = [...dl.children].flatMap((c) => (c.localName === 'div' ? [...c.children] : [c]));\n const rows: Row[] = [];\n let row: Row | undefined;\n for (const c of cells) {\n if (c.localName === 'dt') {\n const label = normalize(c.textContent);\n if (!label) continue;\n // Several <dt> before their values name one row.\n if (row && !row.values.length) row.label += ` / ${label}`;\n else rows.push((row = { label, values: [], ...langDir(c) }));\n } else if (c.localName === 'dd') {\n if (!row) {\n this.warnOnce('dd', 'ignoring a <dd> with no <dt> before it.');\n continue;\n }\n const value: Value = { source: [...c.childNodes].map((n) => this.copy(n)), ...langDir(c) };\n const list = c.querySelector(LIST);\n if (list) {\n value.count = list.querySelectorAll(':scope > li').length;\n const limit = limitOf(c.getAttribute('data-limit') ?? list.getAttribute('data-limit'));\n if (limit !== undefined) value.limit = limit;\n const noun = normalize(\n c.getAttribute('data-limit-label') ?? list.getAttribute('data-limit-label'),\n );\n if (noun) value.limitLabel = noun;\n }\n row.values.push(value);\n }\n }\n return rows.filter((r) => r.values.length);\n }\n\n /**\n * A copy of an author's node: links with an unsafe href (javascript:, data:, …) replaced\n * by their content, with one warning; sizes added to downloads once (not when the link's\n * text already ends with it), `data-size` dropped; ids dropped in light DOM.\n */\n private copy(n: Node): Node {\n const clone = n.cloneNode(true);\n if (!(clone instanceof Element)) return clone;\n const base = this.ownerDocument.baseURI;\n const unsafe: Element[] = [];\n for (const el of [clone, ...clone.querySelectorAll('*')]) {\n if (this.lightDom) el.removeAttribute('id');\n el.removeAttribute('data-limit');\n el.removeAttribute('data-limit-label');\n if (el.localName !== 'a') continue;\n const href = el.getAttribute('href');\n if (href !== null && !safeHref(href, base)) {\n this.warnOnce(\n 'href',\n 'showing a link as text: its href is not http(s), mailto, tel or relative.',\n );\n unsafe.push(el);\n }\n const size = normalize(el.getAttribute('data-size'));\n el.removeAttribute('data-size');\n if (size && !normalize(el.textContent).endsWith(size)) el.append(this.sizeNodes(size));\n }\n // An unsafe link keeps only its content (in a <span> when it is the copied node itself).\n for (const a of unsafe.reverse()) {\n if (a !== clone) {\n a.replaceWith(...a.childNodes);\n continue;\n }\n const span = this.ownerDocument.createElement('span');\n span.append(...a.childNodes);\n return span;\n }\n return clone;\n }\n\n /** \" · 184 KB\", read as \", 184 KB\". */\n private sizeNodes(size: string): DocumentFragment {\n const doc = this.ownerDocument;\n const frag = doc.createDocumentFragment();\n const dot = doc.createElement('span');\n dot.setAttribute('aria-hidden', 'true');\n dot.textContent = ' · ';\n const comma = doc.createElement('span');\n comma.className = 'visually-hidden';\n comma.textContent = ', ';\n frag.append(dot, comma, size);\n return frag;\n }\n\n private renderValue(v: MetadataValue): TemplateResult | string {\n if (v === null || v === undefined) return '';\n if (typeof v !== 'object') return String(v);\n const label = normalize(v.label);\n const href = v.href == null ? '' : String(v.href);\n if (!href || !safeHref(href, this.ownerDocument.baseURI)) {\n if (href)\n this.warnOnce(\n 'href',\n 'showing a link as text: its href is not http(s), mailto, tel or relative.',\n );\n return label;\n }\n const size = normalize(v.size);\n const download = v.download === true ? '' : v.download || undefined;\n return html`<a href=${href} download=${download ?? nothing}\n >${label}${\n size\n ? html`<span aria-hidden=\"true\"> · </span><span class=\"visually-hidden\">, </span>${size}`\n : nothing\n }</a\n >`;\n }\n\n private fromItems(items: readonly MetadataItem[]): Row[] {\n const rows: Row[] = [];\n for (const i of items) {\n const label = normalize(i?.label);\n if (!label) {\n this.warnOnce('label', 'ignoring rows with no label.');\n continue;\n }\n const value = Array.isArray(i.value)\n ? html`<ul role=\"list\">\n ${i.value.map((v) => html`<li>${this.renderValue(v)}</li>`)}\n </ul>`\n : this.renderValue(i.value);\n const v: Value = { content: value };\n if (Array.isArray(i.value)) {\n v.count = i.value.length;\n const limit = limitOf(i.limit);\n if (limit !== undefined) v.limit = limit;\n const noun = normalize(i.limitLabel);\n if (noun) v.limitLabel = noun;\n }\n rows.push({ label, values: [v] });\n }\n return rows;\n }\n\n /** The citation text: `citation`, else the Special Collections one for `citation-title`. */\n private get citationText(): string {\n const own = normalize(this.citation);\n if (own) return own;\n const title = normalize(this.citationTitle);\n return title ? specialCollectionsCitation(title) : '';\n }\n\n private renderRights(): TemplateResult | typeof nothing {\n const rights = normalize(this.rights);\n if (!rights) return nothing;\n const base = this.ownerDocument.baseURI;\n const isUrl = /^https?:\\/\\//i.test(rights);\n const statement = isUrl\n ? html`<a href=${rights} rel=\"license\"\n >${normalize(this.rightsLabel) || rightsName(rights) || 'Rights statement'}</a\n >`\n : rights;\n const info = normalize(this.rightsInfo);\n const more =\n info && safeHref(info, base)\n ? html`<div><a href=${info}>${RIGHTS_INFO_TEXT}</a></div>`\n : nothing;\n return html`<div class=\"row\">\n <dt>Rights</dt>\n <dd>\n <div>${statement}</div>\n ${more}\n </dd>\n </div>`;\n }\n\n private renderCitation(): TemplateResult | typeof nothing {\n const text = this.citationText;\n if (!text) return nothing;\n return html`<div class=\"row\">\n <dt>How to cite</dt>\n <dd>\n <p class=\"citation\">${text}</p>\n <div class=\"copy\">\n <button type=\"button\" class=\"uvalib-button\" @click=${this.copyCitation}>\n Copy citation\n </button>\n <span class=\"status\" role=\"status\">${this.status}</span>\n </div>\n </dd>\n </div>`;\n }\n\n /** Copy the citation; on failure select it, so the keyboard can copy it. */\n private async copyCitation(): Promise<void> {\n trackEvent(this, ['uvalib-metadata', 'copy-citation']);\n clearTimeout(this.timer);\n // Cleared first, so a second copy is announced again.\n this.status = '';\n await this.updateComplete;\n let message = 'Copied';\n try {\n await copyText(this.citationText);\n } catch {\n selectContents(this.renderRoot.querySelector('.citation'));\n message = 'Could not copy: the citation is selected, copy it with your keyboard';\n }\n this.status = message;\n this.timer = setTimeout(() => (this.status = ''), STATUS_MS);\n }\n\n private get rows(): Row[] {\n return this.items ? this.fromItems(this.items) : this.childRows;\n }\n\n /** The rows' source the clones below were made for. */\n private clonedFor?: unknown;\n private clones = new WeakMap<Node[], Node[]>();\n\n /**\n * A value's nodes: fresh clones of its prepared source whenever the rows shown change\n * (new markup, or back from `items`), reused by unrelated updates (the citation status) so\n * that focus in a value is not lost.\n */\n private nodesOf(source: Node[]): Node[] {\n let c = this.clones.get(source);\n if (!c) this.clones.set(source, (c = source.map((n) => n.cloneNode(true))));\n return c;\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.toggleAttribute('data-empty', !this.renderRoot.querySelector('.row'));\n this.applyLimits();\n }\n\n /** The rendered `<dl>` (in light DOM, not the author's source). */\n private get list(): HTMLElement | null {\n const root = this.renderRoot;\n return root instanceof ShadowRoot\n ? root.querySelector('dl')\n : (root as HTMLElement).querySelector(':scope > dl');\n }\n\n /**\n * Hide the items past each shortened list's limit (until Show all), and show again the\n * ones this element hid when the list is open or no longer shortened.\n */\n private applyLimits(): void {\n const dl = this.list;\n if (!dl) return;\n for (const dd of dl.querySelectorAll<HTMLElement>(':scope > .row > dd')) {\n const list = dd.querySelector(LIST);\n if (!list) continue;\n const key = dd.dataset.key;\n const limit = key === undefined ? Infinity : Number(dd.dataset.limit);\n const open = key !== undefined && this.open.has(key);\n [...list.children].forEach((li, i) => {\n if (!(li instanceof HTMLElement) || li.localName !== 'li') return;\n if (!open && i >= limit) {\n if (!li.hidden) this.hid.add(li);\n li.hidden = true;\n } else if (this.hid.has(li)) {\n li.hidden = false;\n this.hid.delete(li);\n }\n });\n if (key === undefined) continue;\n if (!list.id) list.id = `${this.uid}-list-${key}`;\n dd.querySelector(':scope > .more')?.setAttribute('aria-controls', list.id);\n }\n }\n\n /** A value's limit: its own, else `list-limit`; 0 for none. */\n private limitFor(v: Value): number {\n return v.limit ?? limitOf(this.listLimit) ?? 0;\n }\n\n private get locale(): string {\n return this.closest('[lang]')?.getAttribute('lang') || 'en';\n }\n\n /** The toggle's noun: `data-limit-label`, else the label with a lowercase first letter\n * (kept as written when it starts with an acronym, “ORCID iDs”). */\n private noun(r: Row, v: Value): TemplateResult | string {\n if (v.limitLabel) return v.limitLabel;\n const l = r.label;\n let lower = l;\n if (!/^\\p{Lu}{2}/u.test(l)) {\n const first = l.charAt(0);\n try {\n lower = first.toLocaleLowerCase(r.lang || this.locale) + l.slice(1);\n } catch {\n lower = first.toLowerCase() + l.slice(1);\n }\n }\n return r.lang || r.dir\n ? html`<span lang=${r.lang ?? nothing} dir=${r.dir ?? nothing}>${lower}</span>`\n : lower;\n }\n\n private formatCount(n: number): string {\n try {\n return n.toLocaleString(this.locale);\n } catch {\n return n.toLocaleString('en');\n }\n }\n\n private async toggleList(e: Event, key: string, limit: number): Promise<void> {\n const button = e.currentTarget as HTMLElement;\n const open = !this.open.has(key);\n if (open) this.open.add(key);\n else this.open.delete(key);\n const row = button.closest('.row');\n const place = row?.parentElement ? [...row.parentElement.children].indexOf(row) + 1 : 1;\n trackEvent(this, ['uvalib-metadata', open ? 'show-all' : 'show-fewer', `row ${place}`]);\n this.requestUpdate();\n await this.updateComplete;\n if (!button.isConnected) return;\n if (!open) {\n button.focus();\n return;\n }\n const li = button.parentElement?.querySelector(LIST)?.children[limit];\n if (!(li instanceof HTMLElement)) return;\n let target = li.querySelector<HTMLElement>(FOCUSABLE);\n if (!target) {\n li.tabIndex = -1;\n target = li;\n }\n target.focus();\n }\n\n private renderToggle(r: Row, v: Value, key: string, limit: number) {\n const open = this.open.has(key);\n const noun = this.noun(r, v);\n return html`<button\n type=\"button\"\n class=\"more\"\n aria-expanded=${open ? 'true' : 'false'}\n @click=${(e: Event) => this.toggleList(e, key, limit)}\n >\n ${\n open\n ? html`Show fewer<span class=\"visually-hidden\"> ${noun}</span>`\n : html`Show all ${this.formatCount(v.count ?? 0)} ${noun}`\n }\n </button>`;\n }\n\n protected override render() {\n const text = (label: string, value?: string) => {\n const v = normalize(value);\n return v\n ? html`<div class=\"row\">\n <dt>${label}</dt>\n <dd>${v}</dd>\n </div>`\n : nothing;\n };\n const shownFrom = this.items ?? this.childRows;\n if (shownFrom !== this.clonedFor) {\n this.clonedFor = shownFrom;\n this.clones = new WeakMap();\n this.open = new Set();\n }\n return html`<dl>\n ${text('Creator', this.creator)}${text('Organization', this.organization)}\n ${this.rows.map(\n (r, ri) =>\n html`<div class=\"row\">\n <dt lang=${r.lang ?? nothing} dir=${r.dir ?? nothing}>${r.label}</dt>\n ${r.values.map((v, vi) => {\n const limit = this.limitFor(v);\n const key = limit > 0 && (v.count ?? 0) > limit ? `${ri}-${vi}` : undefined;\n return html`<dd\n lang=${v.lang ?? nothing}\n dir=${v.dir ?? nothing}\n data-key=${key ?? nothing}\n data-limit=${key ? limit : nothing}\n >\n ${v.source ? this.nodesOf(v.source) : v.content}${\n key ? this.renderToggle(r, v, key, limit) : nothing\n }\n </dd>`;\n })}\n </div>`,\n )}\n ${this.renderRights()}${this.renderCitation()}\n </dl>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibMetadata } from './UvalibMetadata.js';\n\ndefine('uvalib-metadata', UvalibMetadata);\n"],"mappings":";;;;;;;AACA,IAAMsB,IAAqC;CACzC,KAAK;CACL,aAAa;CACb,WAAW;CACX,UAAU;CACV,WAAW;CACX,UAAU;CACV,UAAU;CACV,YAAY;CACZ,UAAU;CACV,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAOA,SAAgBC,EAAW,GAAkC;CAC3D,IAAIC;CACJ,IAAI;EACF,IAAI,IAAI,IAAIC,CAAI;CAClB,QAAQ;EACN;CACF;CACA,IAAMC,IAAOF,EAAE,SAAS,YAAY,CAAC,CAAC,QAAQ,UAAU,EAAE,GACpDG,IAAOH,EAAE;CACf,IAAIE,MAAS,wBAAwB;EACnC,IAAME,IAAI,yCAAyC,KAAKD,CAAI;EAC5D,OAAOC,IAAIN,EAAWM,EAAE,EAAE,CAAE,YAAY,KAAK,KAAA;CAC/C;CACA,IAAIF,MAAS,uBAAuB;EAClC,IAAMG,IAAU,wEAAwE,KACtFF,CACF;EACA,IAAIE,GAAS,OAAO,MAAMA,EAAQ,EAAE,CAAE,YAAY,EAAE,GAAGA,EAAQ;EAC/D,IAAMC,IAAO,iDAAiD,KAAKH,CAAI;EACvE,IAAIG,GACF,OAAOA,EAAK,EAAE,CAAE,YAAY,MAAM,SAAS,OAAOA,EAAK,OAAO,sBAAsBA,EAAK;CAC7F;AAEF;AAGA,IAAaC,KAA8B,MACzC,GAAGC,EAAM,iFCYLC,IAAmB,qCACnBC,IAAY,KAEZC,IAAO,4BAEPC,IAAY,+EAGZC,KAAW,MAAmC;CAClD,IAAIC,KAAM,QAA4B,OAAOA,KAAM,YAAY,CAACA,EAAE,KAAK,GAAI;CAC3E,IAAMjC,IAAI,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