2022-12-11 13:52:36 +03:00
|
|
|
<script setup lang="ts">
|
2024-02-24 15:24:21 +03:00
|
|
|
import type { CommonRouteTabMoreOption, CommonRouteTabOption } from '~/types'
|
2022-12-11 13:52:36 +03:00
|
|
|
|
2024-02-21 18:20:08 +03:00
|
|
|
const { options, command, replace, preventScrollTop = false, moreOptions } = defineProps<{
|
|
|
|
options: CommonRouteTabOption[]
|
|
|
|
moreOptions?: CommonRouteTabMoreOption
|
|
|
|
command?: boolean
|
|
|
|
replace?: boolean
|
|
|
|
preventScrollTop?: boolean
|
|
|
|
}>()
|
|
|
|
|
2023-09-06 12:13:16 +03:00
|
|
|
const { t } = useI18n()
|
2022-12-11 13:52:36 +03:00
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
useCommands(() => command
|
|
|
|
? options.map(tab => ({
|
|
|
|
scope: 'Tabs',
|
|
|
|
name: tab.display,
|
|
|
|
icon: tab.icon ?? 'i-ri:file-list-2-line',
|
|
|
|
onActivate: () => router.replace(tab.to),
|
|
|
|
}))
|
|
|
|
: [])
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-03-07 23:43:23 +03:00
|
|
|
<div flex w-full items-center lg:text-lg of-x-auto scrollbar-hide border="b base">
|
2022-12-26 08:39:18 +03:00
|
|
|
<template
|
2023-04-28 10:38:44 +03:00
|
|
|
v-for="(option, index) in options.filter(item => !item.hide)"
|
2022-12-11 13:52:36 +03:00
|
|
|
:key="option?.name || index"
|
|
|
|
>
|
2022-12-26 08:39:18 +03:00
|
|
|
<NuxtLink
|
|
|
|
v-if="!option.disabled"
|
|
|
|
:to="option.to"
|
|
|
|
:replace="replace"
|
|
|
|
relative flex flex-auto cursor-pointer sm:px6 px2 rounded transition-all
|
2024-02-24 21:13:12 +03:00
|
|
|
tabindex="0"
|
2022-12-26 08:39:18 +03:00
|
|
|
hover:bg-active transition-100
|
2023-01-03 14:53:40 +03:00
|
|
|
exact-active-class="children:(text-secondary !border-primary !op100 !text-base)"
|
2022-12-26 08:39:18 +03:00
|
|
|
@click="!preventScrollTop && $scrollToTop()"
|
|
|
|
>
|
2023-01-11 17:50:47 +03:00
|
|
|
<span ws-nowrap mxa sm:px2 sm:py3 xl:pb4 xl:pt5 py2 text-center border-b-3 text-secondary-light hover:text-secondary border-transparent>{{ option.display || ' ' }}</span>
|
2022-12-26 08:39:18 +03:00
|
|
|
</NuxtLink>
|
2023-01-06 13:52:58 +03:00
|
|
|
<div v-else flex flex-auto sm:px6 px2 xl:pb4 xl:pt5>
|
2022-12-26 08:39:18 +03:00
|
|
|
<span ws-nowrap mxa sm:px2 sm:py3 py2 text-center text-secondary-light op50>{{ option.display }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
2024-02-24 15:24:21 +03:00
|
|
|
<template v-if="isHydrated && moreOptions?.options?.length">
|
2023-09-06 12:13:16 +03:00
|
|
|
<CommonDropdown placement="bottom" flex cursor-pointer mx-1.25rem>
|
2024-04-06 06:58:50 +03:00
|
|
|
<CommonTooltip placement="top" :content="moreOptions.tooltip || t('action.more')">
|
2023-09-06 12:13:16 +03:00
|
|
|
<button
|
|
|
|
cursor-pointer
|
|
|
|
flex
|
|
|
|
gap-1
|
|
|
|
w-12
|
|
|
|
rounded
|
|
|
|
hover:bg-active
|
|
|
|
btn-action-icon
|
|
|
|
op75
|
|
|
|
px4
|
|
|
|
group
|
|
|
|
:aria-label="t('action.more')"
|
|
|
|
:class="moreOptions.match ? 'text-primary' : 'text-secondary'"
|
|
|
|
>
|
|
|
|
<span v-if="moreOptions.icon" :class="moreOptions.icon" text-sm me--1 block />
|
|
|
|
<span i-ri:arrow-down-s-line text-sm me--1 block />
|
|
|
|
</button>
|
|
|
|
</CommonTooltip>
|
|
|
|
<template #popper>
|
|
|
|
<NuxtLink
|
|
|
|
v-for="(option, index) in moreOptions.options.filter(item => !item.hide)"
|
|
|
|
:key="option?.name || index"
|
|
|
|
:to="option.to"
|
|
|
|
>
|
|
|
|
<CommonDropdownItem>
|
|
|
|
<span flex="~ row" gap-x-4 items-center :class="option.match ? 'text-primary' : ''">
|
|
|
|
<span v-if="option.icon" :class="[option.icon, option.match ? 'text-primary' : 'text.secondary']" text-md me--1 block />
|
|
|
|
<span v-else block> </span>
|
|
|
|
<span>{{ option.display }}</span>
|
|
|
|
</span>
|
|
|
|
</CommonDropdownItem>
|
|
|
|
</NuxtLink>
|
|
|
|
</template>
|
|
|
|
</commondropdown>
|
|
|
|
</template>
|
2022-12-11 13:52:36 +03:00
|
|
|
</div>
|
|
|
|
</template>
|