Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kselect): add before slot #2481

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions docs/components/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ A slot alternative for [`dropdownFooterText` prop](#dropdownfootertext).

### loading

Content to be displayed when [`loading` prop](#loading-1) is `true`. Note that this prop only applies when `enableFiltering` is `true`.
Content to be displayed when [`loading` prop](#loading-1) is `true`. Note that this slot only applies when `enableFiltering` is `true`.

<ClientOnly>
<KToggle toggled v-slot="{ isToggled, toggle }">
Expand Down Expand Up @@ -642,7 +642,7 @@ Slot to display custom content when items is empty or no items match filter quer

### label-tooltip

Use this prop to pass any custom content to label tooltip.
Use this slot to pass any custom content to label tooltip.

<ClientOnly>
<KSelect label="Label" :items="selectItems">
Expand All @@ -656,6 +656,18 @@ Use this prop to pass any custom content to label tooltip.
</KSelect>
```

### before

Use this slot for inserting icons before the input field.

<ClientOnly>
<KSelect :items="selectItems">
<template #before>
<SearchIcon />
</template>
</KSelect>
</ClientOnly>

## Events

### selected
Expand Down Expand Up @@ -684,7 +696,7 @@ Event payload is removed [item](#items).

<script setup lang="ts">
import { ref } from 'vue'
import { KongIcon } from '@kong/icons'
import { KongIcon, SearchIcon } from '@kong/icons'

const selectItems: SelectItem[] = [{
label: 'Service A',
Expand Down Expand Up @@ -774,4 +786,4 @@ const vModel = ref<string>('f')
font-size: $kui-font-size-20;
}
}
</style>
</style>
9 changes: 9 additions & 0 deletions sandbox/pages/SandboxSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@
</template>
</KSelect>
</SandboxSectionComponent>
<SandboxSectionComponent
title="before"
>
<KSelect :items="selectItems">
<template #before>
<KongIcon />
</template>
</KSelect>
</SandboxSectionComponent>
<SandboxSectionComponent title="itemTemplate">
<KSelect
:items="selectItems"
Expand Down
6 changes: 6 additions & 0 deletions src/components/KSelect/KSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
@keyup.enter.stop
@update:model-value="onQueryChange"
>
<template
v-if="slots.before"
#before
>
<slot name="before" />
</template>
<template #after>
<button
v-if="isClearVisible"
Expand Down