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