2022-11-24 08:04:20 +03:00
|
|
|
<script setup lang="ts">
|
2023-01-08 16:24:59 +03:00
|
|
|
const { as = 'button', command, disabled, content, icon } = defineProps<{
|
2022-11-24 08:04:20 +03:00
|
|
|
text?: string | number
|
2022-11-27 18:11:34 +03:00
|
|
|
content: string
|
2022-11-24 08:04:20 +03:00
|
|
|
color: string
|
|
|
|
icon: string
|
2022-11-24 11:34:05 +03:00
|
|
|
activeIcon?: string
|
2022-11-24 08:04:20 +03:00
|
|
|
hover: string
|
|
|
|
groupHover: string
|
|
|
|
active?: boolean
|
|
|
|
disabled?: boolean
|
2022-11-26 02:46:25 +03:00
|
|
|
as?: string
|
2022-11-29 11:15:05 +03:00
|
|
|
command?: boolean
|
2022-11-24 08:04:20 +03:00
|
|
|
}>()
|
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
inheritAttrs: false,
|
|
|
|
})
|
2022-11-29 11:15:05 +03:00
|
|
|
|
2023-01-02 00:45:46 +03:00
|
|
|
defineSlots<{
|
|
|
|
text: {}
|
|
|
|
}>()
|
|
|
|
|
2022-11-29 11:15:05 +03:00
|
|
|
const el = ref<HTMLDivElement>()
|
|
|
|
|
|
|
|
useCommand({
|
|
|
|
scope: 'Actions',
|
|
|
|
|
|
|
|
order: -2,
|
2023-01-08 16:24:59 +03:00
|
|
|
visible: () => command && !disabled,
|
2022-11-29 11:15:05 +03:00
|
|
|
|
2023-01-08 16:24:59 +03:00
|
|
|
name: () => content,
|
|
|
|
icon: () => icon,
|
2022-11-29 11:15:05 +03:00
|
|
|
|
|
|
|
onActivate() {
|
2022-12-02 05:18:57 +03:00
|
|
|
if (!checkLogin())
|
|
|
|
return
|
2022-11-29 11:15:05 +03:00
|
|
|
const clickEvent = new MouseEvent('click', {
|
|
|
|
view: window,
|
|
|
|
bubbles: true,
|
|
|
|
cancelable: true,
|
|
|
|
})
|
|
|
|
el.value?.dispatchEvent(clickEvent)
|
|
|
|
},
|
|
|
|
})
|
2022-11-24 08:04:20 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-11-26 02:46:25 +03:00
|
|
|
<component
|
2023-01-08 16:24:59 +03:00
|
|
|
:is="as"
|
2022-11-29 11:15:05 +03:00
|
|
|
v-bind="$attrs" ref="el"
|
2023-01-29 01:17:26 +03:00
|
|
|
w-fit flex gap-1 items-center transition-all select-none
|
2023-01-08 16:24:59 +03:00
|
|
|
rounded group
|
|
|
|
:hover=" !disabled ? hover : undefined"
|
|
|
|
focus:outline-none
|
2022-11-29 11:15:05 +03:00
|
|
|
:focus-visible="hover"
|
2023-01-08 16:24:59 +03:00
|
|
|
:class="active ? color : 'text-secondary'"
|
2022-11-30 16:00:54 +03:00
|
|
|
:aria-label="content"
|
2023-01-08 16:24:59 +03:00
|
|
|
:disabled="disabled"
|
2022-11-24 11:34:05 +03:00
|
|
|
>
|
2022-11-27 18:11:34 +03:00
|
|
|
<CommonTooltip placement="bottom" :content="content">
|
2023-01-08 16:24:59 +03:00
|
|
|
<div
|
|
|
|
rounded-full p2
|
|
|
|
v-bind="disabled ? {} : {
|
|
|
|
'group-hover': groupHover,
|
|
|
|
'group-focus-visible': groupHover,
|
|
|
|
'group-focus-visible:ring': '2 current',
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
<div :class="active && activeIcon ? activeIcon : icon" />
|
2022-11-27 18:11:34 +03:00
|
|
|
</div>
|
|
|
|
</CommonTooltip>
|
2022-11-24 08:04:20 +03:00
|
|
|
|
2023-01-02 00:45:46 +03:00
|
|
|
<CommonAnimateNumber v-if="text !== undefined || $slots.text" :increased="active" text-sm>
|
|
|
|
<span text-secondary-light>
|
|
|
|
<slot name="text">{{ text }}</slot>
|
|
|
|
</span>
|
2022-11-30 09:21:11 +03:00
|
|
|
<template #next>
|
2023-01-02 00:45:46 +03:00
|
|
|
<span :class="[color]">
|
|
|
|
<slot name="text">{{ text }}</slot>
|
|
|
|
</span>
|
2022-11-30 09:21:11 +03:00
|
|
|
</template>
|
|
|
|
</CommonAnimateNumber>
|
2022-11-26 02:46:25 +03:00
|
|
|
</component>
|
2022-11-24 08:04:20 +03:00
|
|
|
</template>
|