qds-combobox is an editable native form control for choosing a string identity from local or asynchronous suggestions. It uses the input as the focus target and a same-root, top-layer listbox. It imports shared form, option and overlay modules; it does not load the component catalog or a framework runtime.
<script type="module" src="/assets/components/combobox/qds-combobox.js"></script>
<qds-combobox id="owner" label="Deal owner" name="owner" required clearable></qds-combobox>
<script type="module">
const owner = document.querySelector('#owner');
owner.options = [{ value: 'usr-rivera', label: 'Alex Rivera', group: 'Investments', description: 'Houston' }];
owner.value = 'usr-rivera';
</script>
value is the submitted identity; query is the readonly displayed text. A suggestion’s label is presentation and may be duplicated across identities. Typing an exact label does not silently choose an identity.badInput) even on an optional control. Empty optional controls are valid. required also rejects an empty identity.allow-custom explicitly permits arbitrary typed text as the submitted string. Turning it off makes an existing custom entry invalid until the user chooses a suggestion.value assignment is silent and trusted, including an identity absent from the current options. An unknown identity displays itself until metadata arrives. It never causes a provider request. Application code owns authorization and server validation.selectedOption is a cloned readonly snapshot. It survives remote result replacement and local metadata removal. Matching new local metadata silently updates the label and disabled state. A known disabled selection is invalid; merely filtering a committed result out does not invalidate it.options clones and normalizes plain string identities, labels, optional descriptions and contiguous group names. Empty/duplicate identities are dropped; content is always text. Descriptions cannot contain interactive elements.owner.suggestionProvider = async (query, { signal }) => {
const response = await fetch(`/api/owners?q=${encodeURIComponent(query)}`, { signal });
if (!response.ok) throw new Error('Directory unavailable');
return response.json(); // Array of { value, label, disabled?, group?, description? }
};
suggestionProvider receives the query and an AbortSignal. null uses case-insensitive local label/description filtering. The application owns endpoint, credentials, caching and persistence.min-chars defaults to 0; debounce defaults to 150 milliseconds. Typed drafts respect the minimum. Explicit browsing with a committed label requests an empty query so the label does not constrain available replacements. Arrow navigation never changes the canonical value.status is idle, loading, ready, empty, error or minimum. A live status announces feedback; a named retry action repeats the current request immediately. Provider messages are not rendered into the document. Non-array responses are errors.show(), hide(), retry() and clear() expose the same lifecycle. clear() behaves as a user action and emits input/change only when something was cleared. Other owner writes are silent.aria-activedescendant references a visible same-root option; aria-selected represents the active suggestion, separately from the submitted identity. Group and option descriptions are plain text.value attribute / defaultValue define the native reset default. The value property changes current state. Reset closes and cancels work, clears displayed errors and restores the default identity/label.name; disabled controls are omitted. form can associate an external native form. No draft label is submitted in forced-selection mode.input carries { component, value, query, option } for each completed user edit or suggestion choice. change carries the same detail once on explicit choice or committed editing. Internal native input/change events are contained so consumers do not receive duplicates.open-change carries { component, open, reason }; suggestions-error carries { component, query, error }. Validation transitions emit qds-validity-change.