|
|
|
@ -1,24 +1,21 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<el-tooltip |
|
|
|
<el-tooltip |
|
|
|
v-if="props.tooltip" |
|
|
|
|
|
|
|
:content="props.tooltip" |
|
|
|
:content="props.tooltip" |
|
|
|
:disabled="props.disabled" |
|
|
|
:disabled="props.disabled || !props.tooltip" |
|
|
|
:show-after="0" |
|
|
|
:show-after="0" |
|
|
|
:hide-after="0" |
|
|
|
:hide-after="0" |
|
|
|
:popper-options="{ modifiers: [{ name: 'eventListeners', enabled: false }] }" |
|
|
|
:popper-options="{ modifiers: [{ name: 'eventListeners', enabled: false }] }" |
|
|
|
popper-class="non-interactive-tooltip" |
|
|
|
popper-class="non-interactive-tooltip" |
|
|
|
> |
|
|
|
> |
|
|
|
<NoobButton :disabled="props.disabled" v-bind="buttonProps"> |
|
|
|
<NoobButton v-if="!hasSlotContent" :disabled="props.disabled" v-bind="buttonProps" /> |
|
|
|
|
|
|
|
<NoobButton v-else :disabled="props.disabled" v-bind="buttonProps"> |
|
|
|
<slot /> |
|
|
|
<slot /> |
|
|
|
</NoobButton> |
|
|
|
</NoobButton> |
|
|
|
</el-tooltip> |
|
|
|
</el-tooltip> |
|
|
|
<NoobButton v-else :disabled="props.disabled" v-bind="buttonProps"> |
|
|
|
|
|
|
|
<slot /> |
|
|
|
|
|
|
|
</NoobButton> |
|
|
|
|
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
<script setup lang="ts"> |
|
|
|
import { useAttrs } from "vue"; |
|
|
|
import { useAttrs, useSlots } from "vue"; |
|
|
|
import { ElTooltip } from "element-plus"; |
|
|
|
import { ElTooltip } from "element-plus"; |
|
|
|
import { computed } from "vue"; |
|
|
|
import { computed } from "vue"; |
|
|
|
import { NoobButton } from "noob-mengyxu"; |
|
|
|
import { NoobButton } from "noob-mengyxu"; |
|
|
|
@ -32,15 +29,39 @@ interface Props { |
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps<Props>(); |
|
|
|
const props = defineProps<Props>(); |
|
|
|
const attrs = useAttrs(); |
|
|
|
const attrs = useAttrs(); |
|
|
|
|
|
|
|
const slots = useSlots(); |
|
|
|
|
|
|
|
|
|
|
|
const buttonProps = computed(() => { |
|
|
|
const buttonProps = computed(() => { |
|
|
|
const { class: _, ...rest } = attrs; |
|
|
|
const { class: _, ...rest } = attrs; |
|
|
|
return rest; |
|
|
|
return rest; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const hasSlotContent = computed(() => { |
|
|
|
|
|
|
|
if (!slots.default) return false; |
|
|
|
|
|
|
|
const content = slots.default(); |
|
|
|
|
|
|
|
// Filter out comments and empty text nodes |
|
|
|
|
|
|
|
const meaningfulContent = content.filter(vnode => { |
|
|
|
|
|
|
|
// Comment nodes |
|
|
|
|
|
|
|
if (vnode.type === Symbol.for('v-cmt')) return false; |
|
|
|
|
|
|
|
// Text nodes that are empty or whitespace only |
|
|
|
|
|
|
|
if (vnode.type === Symbol.for('v-txt') && (!vnode.children || String(vnode.children).trim() === '')) return false; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return meaningfulContent.length > 0; |
|
|
|
|
|
|
|
}); |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<style> |
|
|
|
<style> |
|
|
|
.non-interactive-tooltip { |
|
|
|
.non-interactive-tooltip { |
|
|
|
pointer-events: none !important; |
|
|
|
pointer-events: none !important; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Hide empty span in circle buttons - use !important to override element-plus styles */ |
|
|
|
|
|
|
|
.el-button.is-circle > span:empty, |
|
|
|
|
|
|
|
.el-button.is-circle > span.el-button__text:empty, |
|
|
|
|
|
|
|
.el-button.is-circle > span[class=""]:empty { |
|
|
|
|
|
|
|
display: none !important; |
|
|
|
|
|
|
|
width: 0 !important; |
|
|
|
|
|
|
|
height: 0 !important; |
|
|
|
|
|
|
|
} |
|
|
|
</style> |
|
|
|
</style> |
|
|
|
|