venny
Version:
Declarative Venn diagrams
47 lines (46 loc) • 1.23 kB
JavaScript
import { VennElement } from './base-element';
export class VennIntersection extends VennElement {
constructor() {
super(...arguments);
this._sets = [];
this._size = 2;
}
static get observedAttributes() {
return ['sets', 'size', 'label'];
}
get sets() {
return [...this._sets];
}
set sets(value) {
if (typeof value === 'string') {
this._sets = value.trim().split(' ').filter((d) => !!d);
}
else {
this._sets = [...value];
}
this._firePropChange('sets');
}
attributeChangedCallback(name, oldValue, newValue) {
if (name === 'sets') {
this.sets = newValue;
}
else {
super.attributeChangedCallback(name, oldValue, newValue);
}
}
computeAreas() {
const sets = this.sets;
if (sets.length > 1) {
return [
{
sets: [...this.sets].sort(),
size: this.size,
label: this.label,
component: this,
},
];
}
return [];
}
}
customElements.define('venn-n', VennIntersection);