mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-30 11:47:55 +01:00
feat(Tabs): add list-leading and list-trailing slots (#3837)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -59,6 +59,14 @@ const items = [{
|
|||||||
<template #custom="{ item }">
|
<template #custom="{ item }">
|
||||||
<span class="text-(--ui-text-muted)">Custom: {{ item.content }}</span>
|
<span class="text-(--ui-text-muted)">Custom: {{ item.content }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template #list-trailing>
|
||||||
|
<UButton
|
||||||
|
icon="lucide:refresh-cw"
|
||||||
|
variant="soft"
|
||||||
|
class="ml-2"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</UTabs>
|
</UTabs>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -73,10 +73,12 @@ export interface TabsEmits extends TabsRootEmits<string | number> {}
|
|||||||
type SlotProps<T extends TabsItem> = (props: { item: T, index: number }) => any
|
type SlotProps<T extends TabsItem> = (props: { item: T, index: number }) => any
|
||||||
|
|
||||||
export type TabsSlots<T extends TabsItem = TabsItem> = {
|
export type TabsSlots<T extends TabsItem = TabsItem> = {
|
||||||
leading: SlotProps<T>
|
'leading': SlotProps<T>
|
||||||
default: SlotProps<T>
|
'default': SlotProps<T>
|
||||||
trailing: SlotProps<T>
|
'trailing': SlotProps<T>
|
||||||
content: SlotProps<T>
|
'content': SlotProps<T>
|
||||||
|
'list-leading': (props?: {}) => any
|
||||||
|
'list-trailing': (props?: {}) => any
|
||||||
} & DynamicSlots<T, undefined, { index: number }>
|
} & DynamicSlots<T, undefined, { index: number }>
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -114,6 +116,8 @@ const ui = computed(() => tabs({
|
|||||||
<TabsList :class="ui.list({ class: props.ui?.list })">
|
<TabsList :class="ui.list({ class: props.ui?.list })">
|
||||||
<TabsIndicator :class="ui.indicator({ class: props.ui?.indicator })" />
|
<TabsIndicator :class="ui.indicator({ class: props.ui?.indicator })" />
|
||||||
|
|
||||||
|
<slot name="list-leading" />
|
||||||
|
|
||||||
<TabsTrigger v-for="(item, index) of items" :key="index" :value="item.value || String(index)" :disabled="item.disabled" :class="ui.trigger({ class: props.ui?.trigger })">
|
<TabsTrigger v-for="(item, index) of items" :key="index" :value="item.value || String(index)" :disabled="item.disabled" :class="ui.trigger({ class: props.ui?.trigger })">
|
||||||
<slot name="leading" :item="item" :index="index">
|
<slot name="leading" :item="item" :index="index">
|
||||||
<UIcon v-if="item.icon" :name="item.icon" :class="ui.leadingIcon({ class: props.ui?.leadingIcon })" />
|
<UIcon v-if="item.icon" :name="item.icon" :class="ui.leadingIcon({ class: props.ui?.leadingIcon })" />
|
||||||
@@ -126,6 +130,8 @@ const ui = computed(() => tabs({
|
|||||||
|
|
||||||
<slot name="trailing" :item="item" :index="index" />
|
<slot name="trailing" :item="item" :index="index" />
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
|
|
||||||
|
<slot name="list-trailing" />
|
||||||
</TabsList>
|
</TabsList>
|
||||||
|
|
||||||
<template v-if="!!content">
|
<template v-if="!!content">
|
||||||
|
|||||||
Reference in New Issue
Block a user