@living-papers/components
Advanced tools
+3
-3
| { | ||
| "name": "@living-papers/components", | ||
| "description": "Built-in Living Papers web components.", | ||
| "version": "0.0.9", | ||
| "version": "0.1.0", | ||
| "license": "BSD-3-Clause", | ||
@@ -15,3 +15,3 @@ "repository": "uwdata/living-papers", | ||
| "dependencies": { | ||
| "@living-papers/runtime": "^0.0.9", | ||
| "@living-papers/runtime": "^0.1.0", | ||
| "d3-require": "^1.3.0", | ||
@@ -71,3 +71,3 @@ "lit": "^2.6.1" | ||
| }, | ||
| "gitHead": "03a17742a62f4f57dc725b3d6931a387e0e3d43b" | ||
| "gitHead": "9bc98e74688c1e895c2466ffcc5b95d586026708" | ||
| } |
@@ -17,3 +17,5 @@ import { LitElement } from 'lit'; | ||
| this.__initchildnodes = true; | ||
| this.initialChildNodes(Array.from(this.childNodes)); | ||
| this.initialChildNodes( | ||
| Array.from(this.childNodes, node => (node.__element = this, node)) | ||
| ); | ||
| removeChildren(this); | ||
@@ -28,2 +30,8 @@ } | ||
| } | ||
| articleData() { | ||
| let el = this; | ||
| for (; el.tagName !== 'ARTICLE'; el = el.parentNode || el.__element); | ||
| return el?.__data; | ||
| } | ||
| } |
+34
-25
@@ -10,4 +10,3 @@ import { html } from 'lit'; | ||
| mode: {type: String}, | ||
| index: {type: Number}, | ||
| data: {type: Object} | ||
| index: {type: Number} | ||
| }; | ||
@@ -55,3 +54,3 @@ } | ||
| event.target.open | ||
| ? summary.textContent = summary.getAttribute('data-longtext') | ||
| ? summary.textContent = summary.getAttribute('data-longtext') | ||
| : summary.textContent = summary.getAttribute('data-shorttext'); | ||
@@ -66,4 +65,10 @@ } | ||
| citeData() { | ||
| return this.data || ( | ||
| this.data = this.articleData()?.citations?.data[this.index - 1] | ||
| ); | ||
| } | ||
| render() { | ||
| const { key, data, index, mode} = this; | ||
| const { key, index, mode, data = this.citeData() } = this; | ||
| const wrapper = html`<div class='cite-info-wrapper'></div>`; | ||
@@ -73,3 +78,4 @@ | ||
| if (data == null) { | ||
| return html`<span class='cite-ref unresolved'>??${wrapper}<div class='cite-info'> | ||
| const ref = index ?? '??'; | ||
| return html`<span class='cite-ref unresolved'>${ref}${wrapper}<div class='cite-info'> | ||
| <b>Unresolved citation</b><br>"${key}"</div></span>`; | ||
@@ -83,3 +89,3 @@ } | ||
| const subtitle = data.venue ? html`<div class='cite-head-subtitle'>${data.venue}</div>` : null; | ||
| const info = shortInfo | ||
| const info = shortInfo | ||
| ? html`<details class='cite-body-auth' @toggle=${this.toggleContent}> | ||
@@ -89,3 +95,3 @@ <summary data-shorttext=${shortInfo} data-longtext=${fullInfo}>${shortInfo}</summary> | ||
| : html`<div class='cite-body-auth'>${fullInfo}</div>`; | ||
| const desc = data.abstract && data.abstract !== desctext | ||
| const desc = data.abstract && data.abstract !== desctext | ||
| ? html`<details class='cite-body-desc' @toggle=${this.toggleContent}> | ||
@@ -111,4 +117,5 @@ <summary data-shorttext=${desctext} data-longtext=${data.abstract}>${desctext}</summary> | ||
| // Returns inline authors, or abbrev. if there are more than etal authors | ||
| function inlineContent(data, index, etal=2) { | ||
| const { author } = data; | ||
| function inlineContent(data, index, etal = 2) { | ||
| const { author, title } = data; | ||
| if (!author || !author.length) return `${title} [${index}]`; | ||
@@ -121,28 +128,30 @@ let authors = author[0].family; | ||
| } | ||
| return `${authors} [${index}]`; | ||
| } | ||
| function infoBody(data, maxAuthors=2) { | ||
| const { author, year } = data; | ||
| const aMap = author.map(({ given, family }) => given | ||
| ? `${given.includes('.') ? given : given[0] + '.'} ${family}` | ||
| : family); | ||
| const fullInfo = `${year} \u2022 ${aMap.join(', ')}`; | ||
| const shortInfo = aMap.length > maxAuthors | ||
| ? `${year} \u2022 ${aMap.slice(0, maxAuthors).join(', ')} +${aMap.length - maxAuthors}` | ||
| function infoBody(data, maxAuthors = 2) { | ||
| const { author, year } = data; | ||
| const aMap = (author || []).map(({ given, family }) => { | ||
| return given | ||
| ? `${given.includes('.') ? given : given[0] + '.'} ${family}` | ||
| : family; | ||
| }); | ||
| const fullInfo = `${year}` + (aMap.length ? ` \u2022 ${aMap.join(', ')}` : ''); | ||
| const shortInfo = aMap.length > maxAuthors | ||
| ? `${year} \u2022 ${aMap.slice(0, maxAuthors).join(', ')} +${aMap.length - maxAuthors}` | ||
| : null; | ||
| return {fullInfo, shortInfo}; | ||
| return { fullInfo, shortInfo }; | ||
| } | ||
| function descBody(data, charLimit=300, defaultDesc='No description is available for this article.') { | ||
| function descBody( | ||
| data, | ||
| charLimit = 300, | ||
| defaultDesc = 'No description is available for this article.' | ||
| ) { | ||
| const { abstract, tldr } = data; | ||
| const shortDesc = tldr || abstract || defaultDesc; | ||
| return shortDesc.length > charLimit | ||
| ? shortDesc.substring(0, shortDesc.substring(0, charLimit).lastIndexOf(' ')) + '... ' | ||
| return shortDesc.length > charLimit | ||
| ? shortDesc.substring(0, shortDesc.substring(0, charLimit).lastIndexOf(' ')) + '... ' | ||
| : shortDesc; | ||
| } |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
27675
1.74%668
2.93%+ Added
+ Added
- Removed
- Removed
- Removed
- Removed