feat(combo-box): make ComboBox slottable

Closes #1176
This commit is contained in:
Eric Liu 2022-03-19 08:36:17 -07:00
commit 5ce4ec58fe

View file

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