@spectrum-web-components/iconset
Advanced tools
Comparing version 1.0.0 to 1.0.1-color-testing
{ | ||
"name": "@spectrum-web-components/iconset", | ||
"version": "1.0.0", | ||
"version": "1.0.1-color-testing", | ||
"publishConfig": { | ||
@@ -63,3 +63,3 @@ "access": "public" | ||
"dependencies": { | ||
"@spectrum-web-components/base": "^1.0.0" | ||
"@spectrum-web-components/base": "^1.0.1-color-testing" | ||
}, | ||
@@ -75,3 +75,3 @@ "types": "./src/index.d.ts", | ||
], | ||
"gitHead": "5cf5d34645bf9494ebd20f64c42d1619523d2d84" | ||
"gitHead": "17e14b4a9fa2c8b15df158ea7d77ce09bf50de82" | ||
} |
@@ -70,2 +70,3 @@ "use strict"; | ||
this.icons = []; | ||
this.filteredIcons = []; | ||
this.unsubscribeSystemContext = null; | ||
@@ -80,3 +81,2 @@ this.spectrumVersion = 1; | ||
super.connectedCallback(); | ||
this.requestSystemContext(); | ||
window.addEventListener("sp-iconset-added", this.handleIconSetAdded); | ||
@@ -92,15 +92,20 @@ } | ||
} | ||
requestSystemContext() { | ||
this.dispatchEvent( | ||
new CustomEvent("sp-system-context", { | ||
detail: { | ||
callback: (system, unsubscribe) => { | ||
this.spectrumVersion = system === "spectrum-two" ? 2 : 1; | ||
this.unsubscribeSystemContext = unsubscribe; | ||
} | ||
}, | ||
bubbles: true, | ||
composed: true | ||
}) | ||
); | ||
filterIconsBySpectrumVersion() { | ||
const iconVersion = this.spectrumVersion === 2 ? "s2" : "s1"; | ||
let filteredIcons = this.icons; | ||
if (this.name === "workflow") { | ||
filteredIcons = filteredIcons.filter((icon) => { | ||
const iconName = icon.name.replace(/\s/g, "").toLowerCase(); | ||
return iconsList[iconVersion].includes(iconName); | ||
}); | ||
} | ||
const iconSet = /* @__PURE__ */ new Set(); | ||
filteredIcons = filteredIcons.filter((icon) => { | ||
if (iconSet.has(icon.name)) { | ||
return false; | ||
} | ||
iconSet.add(icon.name); | ||
return true; | ||
}); | ||
this.filteredIcons = filteredIcons; | ||
} | ||
@@ -110,3 +115,7 @@ update(changes) { | ||
this.spectrumVersion = this.systemResolver.system === "spectrum-two" ? 2 : 1; | ||
this.filterIconsBySpectrumVersion(); | ||
} | ||
if (changes.has("icons")) { | ||
this.filterIconsBySpectrumVersion(); | ||
} | ||
super.update(changes); | ||
@@ -197,10 +206,5 @@ } | ||
renderSearch() { | ||
let matchingIcons = this.search ? this.icons.filter( | ||
const matchingIcons = this.search ? this.filteredIcons.filter( | ||
(icon) => icon.name.toLowerCase().includes(this.search.toLowerCase()) | ||
) : this.icons; | ||
const iconVersion = this.spectrumVersion === 2 ? "s2" : "s1"; | ||
matchingIcons = matchingIcons.filter((icon) => { | ||
const iconName = icon.name.replace(/\s/g, "").toLowerCase(); | ||
return iconsList[iconVersion].includes(iconName); | ||
}); | ||
) : this.filteredIcons; | ||
return html` | ||
@@ -219,4 +223,4 @@ <div class="search" part="search"> | ||
<sp-help-text slot="help-text"> | ||
Showing ${matchingIcons.length} of ${this.icons.length} | ||
available icons. | ||
Showing ${matchingIcons.length} of | ||
${this.filteredIcons.length} available icons. | ||
</sp-help-text> | ||
@@ -244,3 +248,3 @@ </sp-search> | ||
return html` | ||
${this.icons.length ? this.renderSearch() : html` | ||
${this.filteredIcons.length ? this.renderSearch() : html` | ||
<slot></slot> | ||
@@ -247,0 +251,0 @@ `} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102064
747
1