Ir al contenido

co-option-list

Núcleo de lista de opciones y única fuente del look & behavior de los dropdowns Cobalt (co-ref-field, co-combobox, co-autocomplete, co-command-search) y de los pickers de celda de suite-v2. No renderiza trigger ni chrome de panel: eso lo aporta el host. Es 100% controlada — no muta value, emite eventos y el host decide. Recibe las opciones por la propiedad items (array de OptionListItem o su equivalente en JSON string).

Ver código
<co-option-list searchable items='[{"_id":"1","label":"Opción uno"},{"_id":"2","label":"Opción dos"},{"_id":"3","label":"Opción tres"}]'></co-option-list>

Props

PropAtributoTipoDefaultDescripción
autoHighlightauto-highlightbooleanfalseAuto-resalta la primera fila navegable al montar y en cada cambio de items (paridad command-palette: tipear + Enter = primer resultado). Salta filas disabled vía nextActiveIndex.
avatarShapeavatar-shape"circle" | "square"'circle'
clearOptionLabelclear-option-labelstring''Si se setea y hay selección, fila "quitar selección" al tope.
emptyMessageempty-messagestring'No results found'
hasMorehas-morebooleanfalseFallback cuando el host no conoce totales (⌘K). total>0 manda.
highlightMatcheshighlight-matchesbooleanfalseResalta el match del término en los labels.
highlightTermhighlight-termstring''Término externo para highlight (input en el host, p.ej. ⌘K).
initialTerminitial-termstring''Pre-seed del término (modo convert de las celdas).
itemsitemsOptionListItem[] | string'[]'JSON string o array de OptionListItem.
loadingloadingbooleanfalse
multiplemultiplebooleanfalse
removableItemsremovable-itemsbooleanfalseBotón remove por fila seleccionada en multiple (tags de combobox).
searchDebouncesearch-debouncenumber350
searchPlaceholdersearch-placeholderstring'Search…'
searchablesearchablebooleanfalse
selectedAffordanceselected-affordance"check" | "deselect"'check'Afford. del seleccionado: check (combobox/autocomplete) o X deselect (ref-field).
selectedFirstselected-firstbooleanfalsePartición selected-first (snapshot al llamar snapshotOrder()).
selectedItemsselected-itemsOptionListItem[] | string'[]'Display-items de la selección (para selected-first con ids fuera de página).
totaltotalnumber0Total del server: deriva hasMore + hint "N more results".
valuevaluestring''Selección actual: id single o JSON array de ids.
virtualvirtualbooleanfalseLista virtualizada (autocomplete/combobox). Ignora `group`.

Eventos

EventoDetailBubblesCancelableDescripción
coChange{ value: string | string[]; item: OptionListItem; }
coClearSelectionvoid
coLoadMorevoid
coRemoveItemstring
coSearchstring

Slots

SlotDescripción
footerFooter del panel (normalmente <co-list-footer>).

CSS Parts

PartDescripción
::part(options)
::part(search)

CSS Custom Properties

Este componente no expone CSS custom properties.