|
|
@ -214,7 +214,6 @@ class TpDropdown extends BaseElement {
|
|
|
|
|
|
|
|
|
|
|
|
:host(:not([not-responsive])) #itemList {
|
|
|
|
:host(:not([not-responsive])) #itemList {
|
|
|
|
max-height: none !important;
|
|
|
|
max-height: none !important;
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:host(:not([not-responsive])) #filter {
|
|
|
|
:host(:not([not-responsive])) #filter {
|
|
|
@ -235,7 +234,7 @@ class TpDropdown extends BaseElement {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
const { label, isOpen, errorMessage, filterPlaceholder, extensible, filterable, items} = this;
|
|
|
|
const { label, isOpen, errorMessage, filterPlaceholder, extensible, filterable, items } = this;
|
|
|
|
|
|
|
|
|
|
|
|
return html`
|
|
|
|
return html`
|
|
|
|
<tp-media-query query="(min-width: 0) and (max-width: 480px)" @media-query-update=${this._queryUpdated}></tp-media-query>
|
|
|
|
<tp-media-query query="(min-width: 0) and (max-width: 480px)" @media-query-update=${this._queryUpdated}></tp-media-query>
|
|
|
@ -349,6 +348,10 @@ class TpDropdown extends BaseElement {
|
|
|
|
this._itemsChanged();
|
|
|
|
this._itemsChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (changes.has('isOpen')) {
|
|
|
|
|
|
|
|
this.dispatchEvent(new CustomEvent('is-open-changed', { detail: this.isOpen, bubbles: true, composed: true }));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -522,6 +525,12 @@ class TpDropdown extends BaseElement {
|
|
|
|
this.label = this.items[idx].label;
|
|
|
|
this.label = this.items[idx].label;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.isOpen) {
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
|
|
this.focus();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.isOpen = false;
|
|
|
|
this.isOpen = false;
|
|
|
|
window.removeEventListener('resize', this._boundSetListPosition);
|
|
|
|
window.removeEventListener('resize', this._boundSetListPosition);
|
|
|
|
document.removeEventListener('scroll', this._boundSetListPosition);
|
|
|
|
document.removeEventListener('scroll', this._boundSetListPosition);
|
|
|
@ -673,6 +682,7 @@ class TpDropdown extends BaseElement {
|
|
|
|
}, 20);
|
|
|
|
}, 20);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.value = itemEl.value;
|
|
|
|
this.value = itemEl.value;
|
|
|
|
|
|
|
|
this.dispatchEvent(new CustomEvent('selection-changed', { detail: this.value, bubbles: true, composed: true }));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var rootTarget = e.composedPath()[0];
|
|
|
|
var rootTarget = e.composedPath()[0];
|
|
|
@ -693,7 +703,6 @@ class TpDropdown extends BaseElement {
|
|
|
|
if (this.isOpen) {
|
|
|
|
if (this.isOpen) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
this.close();
|
|
|
|
this.close();
|
|
|
|
this.focus();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -782,7 +791,7 @@ class TpDropdown extends BaseElement {
|
|
|
|
var label = this.$.filter.value;
|
|
|
|
var label = this.$.filter.value;
|
|
|
|
if (label !== '') {
|
|
|
|
if (label !== '') {
|
|
|
|
if (!this._selectByLabel(label)) {
|
|
|
|
if (!this._selectByLabel(label)) {
|
|
|
|
this.fire('add-item', { label: label });
|
|
|
|
this.dispatchEvent(new CustomEvent('add-item', { detail: { label }, bubbles: true, composed: true }));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -806,6 +815,7 @@ class TpDropdown extends BaseElement {
|
|
|
|
|
|
|
|
|
|
|
|
if (item) {
|
|
|
|
if (item) {
|
|
|
|
this.value = item.value;
|
|
|
|
this.value = item.value;
|
|
|
|
|
|
|
|
this.dispatchEvent(new CustomEvent('selection-changed', { detail: this.value, bubbles: true, composed: true }));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|