Sha256: 82e903d89ab91caa20a271a3b1769f33aaf38f640d0854a1088a400a691853cb
Contents?: true
Size: 1.24 KB
Versions: 18
Compression:
Stored size: 1.24 KB
Contents
import Combobox from "models/combobox/base" import { visible, startsWith } from "helpers" Combobox.Options = Base => class extends Base { _resetOptions() { this._deselect() this.hiddenFieldTarget.name = this.originalNameValue } _isValidNewOption(query, { ignoreAutocomplete = false } = {}) { const typedValue = this._actingCombobox.value const autocompletedValue = this._visibleOptionElements[0]?.getAttribute(this.autocompletableAttributeValue) const insufficientAutocomplete = !autocompletedValue || !startsWith(autocompletedValue, typedValue) return query.length > 0 && this._allowNew && (ignoreAutocomplete || insufficientAutocomplete) } get _allowNew() { return !!this.nameWhenNewValue } get _allOptions() { return Array.from(this._allOptionElements) } get _allOptionElements() { return this._actingListbox.querySelectorAll(`[${this.filterableAttributeValue}]`) } get _visibleOptionElements() { return [ ...this._allOptionElements ].filter(visible) } get _selectedOptionElement() { return this._actingListbox.querySelector("[role=option][aria-selected=true]") } get _selectedOptionIndex() { return [ ...this._visibleOptionElements ].indexOf(this._selectedOptionElement) } }
Version data entries
18 entries across 18 versions & 1 rubygems