package.src.vaadin-multi-select-combo-box-scroller.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multi-select-combo-box Show documentation
Show all versions of multi-select-combo-box Show documentation
vaadin-multi-select-combo-box
/**
* @license
* Copyright (c) 2021 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
import { ComboBoxPlaceholder } from '@vaadin/combo-box/src/vaadin-combo-box-placeholder.js';
import { ComboBoxScrollerMixin } from '@vaadin/combo-box/src/vaadin-combo-box-scroller-mixin.js';
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
/**
* An element used internally by ``. Not intended to be used separately.
*
* @customElement
* @extends HTMLElement
* @mixes ComboBoxScrollerMixin
* @private
*/
export class MultiSelectComboBoxScroller extends ComboBoxScrollerMixin(PolymerElement) {
static get is() {
return 'vaadin-multi-select-combo-box-scroller';
}
static get template() {
return html`
`;
}
/** @protected */
ready() {
super.ready();
this.setAttribute('aria-multiselectable', 'true');
}
/**
* @protected
* @override
*/
_isItemSelected(item, _selectedItem, itemIdPath) {
if (item instanceof ComboBoxPlaceholder) {
return false;
}
if (this.owner.readonly) {
return false;
}
return this.owner._findIndex(item, this.owner.selectedItems, itemIdPath) > -1;
}
/**
* @param {HTMLElement} el
* @param {number} index
* @protected
* @override
*/
_updateElement(el, index) {
super._updateElement(el, index);
el.toggleAttribute('readonly', this.owner.readonly);
}
}
defineCustomElement(MultiSelectComboBoxScroller);