mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 03:26:36 +00:00
feat(header-search): pass index as a slot prop
This commit is contained in:
parent
3585b9ca48
commit
38e6985926
2 changed files with 7 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
|||
* @event {any} inactive
|
||||
* @event {any} clear
|
||||
* @event {{ value: string; selectedResultIndex: number; selectedResult: HeaderSearchResult }} select
|
||||
* @slot {{ result: HeaderSearchResult; index: number }}
|
||||
*/
|
||||
|
||||
/** Specify the search input value */
|
||||
|
@ -271,7 +272,7 @@
|
|||
class:selected="{selectedId === `search-menuitem-${i}`}"
|
||||
on:click|preventDefault="{selectResult}"
|
||||
>
|
||||
<slot result="{result}">
|
||||
<slot result="{result}" index="{i}">
|
||||
{result.text}
|
||||
{#if result.description}<span>– {result.description}</span>{/if}
|
||||
</slot>
|
||||
|
|
|
@ -73,7 +73,11 @@
|
|||
on:select="{(e) => {
|
||||
console.log('on:select', e.detail);
|
||||
}}"
|
||||
/>
|
||||
let:result
|
||||
let:index
|
||||
>
|
||||
<div>{result.text}{index}</div>
|
||||
</HeaderSearch>
|
||||
<HeaderAction bind:isOpen>
|
||||
<HeaderPanelLinks>
|
||||
<HeaderPanelDivider>Switcher subject 1</HeaderPanelDivider>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue