feat(combo-box): make ComboBox slottable (#1181)

Closes #1176
This commit is contained in:
metonym 2022-03-19 09:15:41 -07:00 committed by GitHub
commit 2858776367
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 5 deletions

View file

@ -3,6 +3,7 @@
* @typedef {any} ComboBoxItemId
* @typedef {{ id: ComboBoxItemId; text: string; }} ComboBoxItem
* @event {{ selectedId: ComboBoxItemId; selectedItem: ComboBoxItem }} select
* @slot {{ item: ComboBoxItem; index: number }}
*/
/**
@ -363,7 +364,9 @@
highlightedIndex = i;
}}"
>
{itemToString(item)}
<slot item="{item}" index="{i}">
{itemToString(item)}
</slot>
{#if selectedItem && selectedItem.id === item.id}
<Checkmark16 class="bx--list-box__menu-item__selected-icon" />
{/if}