@antify/ui 4.1.18 → 4.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,20 +10,31 @@ import {
|
|
|
10
10
|
faChevronDown, faChevronUp,
|
|
11
11
|
} from '@fortawesome/free-solid-svg-icons';
|
|
12
12
|
import AntTransitionCollapseHeight from '../transitions/AntTransitionCollapseHeight.vue';
|
|
13
|
+
import AntTooltip from '../AntTooltip.vue';
|
|
13
14
|
|
|
14
15
|
const props = defineProps<{
|
|
15
16
|
navbarItem: NavbarItemTypes;
|
|
16
17
|
}>();
|
|
17
18
|
|
|
19
|
+
const shouldRenderTooltip = computed(() =>
|
|
20
|
+
props.navbarItem.disabled && !!props.navbarItem.tooltipMessage
|
|
21
|
+
);
|
|
22
|
+
|
|
18
23
|
const itemClasses = computed(() => ({
|
|
19
24
|
'w-full text-sm p-1.5 rounded-md cursor-pointer flex items-center flex-nowrap gap-1': true,
|
|
20
25
|
'transition-colors hover:bg-base-100': true,
|
|
21
26
|
'text-primary-500': props.navbarItem.active,
|
|
27
|
+
'cursor-default opacity-50': props.navbarItem.disabled,
|
|
28
|
+
'transition-colors hover:bg-base-100 cursor-pointer': !props.navbarItem.disabled,
|
|
22
29
|
}));
|
|
23
30
|
|
|
24
31
|
const open = ref(false);
|
|
25
32
|
|
|
26
33
|
function itemClick(): void {
|
|
34
|
+
if (props.navbarItem.disabled) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
if (props.navbarItem.click) {
|
|
28
39
|
props.navbarItem.click();
|
|
29
40
|
}
|
|
@@ -36,38 +47,37 @@ function itemClick(): void {
|
|
|
36
47
|
|
|
37
48
|
<template>
|
|
38
49
|
<component
|
|
39
|
-
:is="
|
|
40
|
-
:to="navbarItem.to"
|
|
41
|
-
v-bind="$attrs"
|
|
42
|
-
:class="itemClasses"
|
|
43
|
-
@click="itemClick"
|
|
44
|
-
data-e2e="navbar-item"
|
|
50
|
+
:is="shouldRenderTooltip ? AntTooltip : 'div'"
|
|
45
51
|
>
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{{ navbarItem.label }}
|
|
54
|
-
</div>
|
|
55
|
-
|
|
56
|
-
<div
|
|
57
|
-
v-if="navbarItem.children && navbarItem.children.length > 0"
|
|
52
|
+
<component
|
|
53
|
+
:is="navbarItem.to && !navbarItem.disabled ? 'router-link' : 'div'"
|
|
54
|
+
:to="navbarItem.to && !navbarItem.disabled ? navbarItem.to : undefined"
|
|
55
|
+
v-bind="$attrs"
|
|
56
|
+
:class="itemClasses"
|
|
57
|
+
@click.stop="itemClick"
|
|
58
|
+
data-e2e="navbar-item"
|
|
58
59
|
>
|
|
59
60
|
<AntIcon
|
|
60
|
-
v-if="
|
|
61
|
-
:icon="
|
|
61
|
+
v-if="navbarItem.icon"
|
|
62
|
+
:icon="navbarItem.icon"
|
|
62
63
|
:color="navbarItem.active ? 'text-primary-500' : 'text-for-white-bg-font'"
|
|
63
64
|
/>
|
|
64
65
|
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
<div class="grow select-none">
|
|
67
|
+
{{ navbarItem.label }}
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div v-if="navbarItem.children && navbarItem.children.length > 0">
|
|
71
|
+
<AntIcon
|
|
72
|
+
:icon="open ? faChevronUp : faChevronDown"
|
|
73
|
+
:color="navbarItem.active ? 'text-primary-500' : 'text-for-white-bg-font'"
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
</component>
|
|
77
|
+
|
|
78
|
+
<template #content v-if="shouldRenderTooltip">
|
|
79
|
+
<div>{{ navbarItem.tooltipMessage }}</div>
|
|
80
|
+
</template>
|
|
71
81
|
</component>
|
|
72
82
|
|
|
73
83
|
<AntTransitionCollapseHeight
|