@indielayer/ui 1.15.1 → 1.15.2
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.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/docs/components/common/CodeSnippet.vue +4 -3
- package/lib/components/index.js +117 -116
- package/lib/components/popover/Popover.vue2.js +2 -3
- package/lib/components/popover/Popover.vue3.js +3 -2
- package/lib/components/select/Select.vue.js +1 -1
- package/lib/components/tooltip/ToggleTip.vue.js +7 -7
- package/lib/components/tooltip/Tooltip.vue.d.ts +29 -9
- package/lib/components/tooltip/Tooltip.vue.js +114 -35
- package/lib/components/tooltip/index.d.ts +1 -1
- package/lib/components/tooltip/theme/Tooltip.base.theme.d.ts +3 -0
- package/lib/components/tooltip/theme/Tooltip.base.theme.js +8 -0
- package/lib/components/tooltip/theme/Tooltip.carbon.theme.d.ts +3 -0
- package/lib/components/tooltip/theme/Tooltip.carbon.theme.js +5 -0
- package/lib/index.js +1 -1
- package/lib/index.umd.js +4 -4
- package/lib/theme.d.ts +2 -1
- package/lib/themes/base/components.d.ts +1 -0
- package/lib/themes/base/components.js +12 -10
- package/lib/themes/carbon/components.d.ts +1 -0
- package/lib/themes/carbon/components.js +12 -10
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/src/components/tooltip/ToggleTip.vue +1 -1
- package/src/components/tooltip/Tooltip.vue +185 -15
- package/src/components/tooltip/index.ts +1 -1
- package/src/components/tooltip/theme/Tooltip.base.theme.ts +9 -0
- package/src/components/tooltip/theme/Tooltip.carbon.theme.ts +7 -0
- package/src/theme.ts +2 -0
- package/src/themes/base/components.ts +1 -0
- package/src/themes/carbon/components.ts +1 -0
- package/src/version.ts +1 -1
package/lib/theme.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ColorLibrary } from './composables/useColors';
|
|
2
|
-
import type { AccordionTheme, AccordionItemTheme, AlertTheme, AvatarTheme, BadgeTheme, BreadcrumbsTheme, ButtonTheme, ButtonGroupTheme, CardTheme, CarouselTheme, CarouselSlideTheme, CheckboxTheme, ContainerTheme, DatepickerTheme, DividerTheme, DrawerTheme, FormTheme, FormGroupTheme, IconTheme, ImageTheme, InputTheme, InputFooterTheme, LabelTheme, LinkTheme, LoaderTheme, MenuTheme, MenuItemTheme, ModalTheme, NotificationsTheme, PaginationTheme, PaginationItemTheme, PopoverTheme, PopoverContainerTheme, ProgressTheme, QrCodeTheme, RadioTheme, ScrollTheme, SelectTheme, SkeletonTheme, SliderTheme, StepperTheme, TabTheme, TabGroupTheme, TableTheme, TableCellTheme, TableHeadTheme, TableHeaderTheme, TableRowTheme, TagTheme, TextareaTheme, ToggleTheme, UploadTheme } from './components';
|
|
2
|
+
import type { AccordionTheme, AccordionItemTheme, AlertTheme, AvatarTheme, BadgeTheme, BreadcrumbsTheme, ButtonTheme, ButtonGroupTheme, CardTheme, CarouselTheme, CarouselSlideTheme, CheckboxTheme, ContainerTheme, DatepickerTheme, DividerTheme, DrawerTheme, FormTheme, FormGroupTheme, IconTheme, ImageTheme, InputTheme, InputFooterTheme, LabelTheme, LinkTheme, LoaderTheme, MenuTheme, MenuItemTheme, ModalTheme, NotificationsTheme, PaginationTheme, PaginationItemTheme, PopoverTheme, PopoverContainerTheme, ProgressTheme, QrCodeTheme, RadioTheme, ScrollTheme, SelectTheme, SkeletonTheme, SliderTheme, StepperTheme, TabTheme, TabGroupTheme, TableTheme, TableCellTheme, TableHeadTheme, TableHeaderTheme, TableRowTheme, TagTheme, TextareaTheme, ToggleTheme, TooltipTheme, UploadTheme } from './components';
|
|
3
3
|
export type ComponentThemes = {
|
|
4
4
|
Accordion: AccordionTheme;
|
|
5
5
|
AccordionItem: AccordionItemTheme;
|
|
@@ -52,6 +52,7 @@ export type ComponentThemes = {
|
|
|
52
52
|
Tag: TagTheme;
|
|
53
53
|
Textarea: TextareaTheme;
|
|
54
54
|
Toggle: ToggleTheme;
|
|
55
|
+
Tooltip: TooltipTheme;
|
|
55
56
|
Upload: UploadTheme;
|
|
56
57
|
};
|
|
57
58
|
export type UITheme = {
|
|
@@ -49,4 +49,5 @@ export { default as TableRow } from '../../components/table/theme/TableRow.base.
|
|
|
49
49
|
export { default as Tag } from '../../components/tag/theme/Tag.base.theme';
|
|
50
50
|
export { default as Textarea } from '../../components/textarea/theme/Textarea.base.theme';
|
|
51
51
|
export { default as Toggle } from '../../components/toggle/theme/Toggle.base.theme';
|
|
52
|
+
export { default as Tooltip } from '../../components/tooltip/theme/Tooltip.base.theme';
|
|
52
53
|
export { default as Upload } from '../../components/upload/theme/Upload.base.theme';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { default as a } from "../../components/accordion/theme/Accordion.base.theme.js";
|
|
2
2
|
import { default as t } from "../../components/accordion/theme/AccordionItem.base.theme.js";
|
|
3
3
|
import { default as l } from "../../components/alert/theme/Alert.base.theme.js";
|
|
4
|
-
import { default as
|
|
4
|
+
import { default as p } from "../../components/avatar/theme/Avatar.base.theme.js";
|
|
5
5
|
import { default as m } from "../../components/badge/theme/Badge.base.theme.js";
|
|
6
6
|
import { default as x } from "../../components/breadcrumbs/theme/Breadcrumbs.base.theme.js";
|
|
7
7
|
import { default as i } from "../../components/button/theme/Button.base.theme.js";
|
|
8
|
-
import { default as
|
|
8
|
+
import { default as T } from "../../components/button/theme/ButtonGroup.base.theme.js";
|
|
9
9
|
import { default as g } from "../../components/card/theme/Card.base.theme.js";
|
|
10
10
|
import { default as I } from "../../components/carousel/theme/Carousel.base.theme.js";
|
|
11
11
|
import { default as P } from "../../components/carousel/theme/CarouselSlide.base.theme.js";
|
|
@@ -28,11 +28,11 @@ import { default as ee } from "../../components/menu/theme/MenuItem.base.theme.j
|
|
|
28
28
|
import { default as ae } from "../../components/modal/theme/Modal.base.theme.js";
|
|
29
29
|
import { default as te } from "../../components/notifications/theme/Notifications.base.theme.js";
|
|
30
30
|
import { default as le } from "../../components/pagination/theme/Pagination.base.theme.js";
|
|
31
|
-
import { default as
|
|
31
|
+
import { default as pe } from "../../components/pagination/theme/PaginationItem.base.theme.js";
|
|
32
32
|
import { default as me } from "../../components/popover/theme/Popover.base.theme.js";
|
|
33
33
|
import { default as xe } from "../../components/popover/theme/PopoverContainer.base.theme.js";
|
|
34
34
|
import { default as ie } from "../../components/progress/theme/Progress.base.theme.js";
|
|
35
|
-
import { default as
|
|
35
|
+
import { default as Te } from "../../components/qrCode/theme/QrCode.base.theme.js";
|
|
36
36
|
import { default as ge } from "../../components/radio/theme/Radio.base.theme.js";
|
|
37
37
|
import { default as Ie } from "../../components/scroll/theme/Scroll.base.theme.js";
|
|
38
38
|
import { default as Pe } from "../../components/select/theme/Select.base.theme.js";
|
|
@@ -49,16 +49,17 @@ import { default as ze } from "../../components/table/theme/TableRow.base.theme.
|
|
|
49
49
|
import { default as Je } from "../../components/tag/theme/Tag.base.theme.js";
|
|
50
50
|
import { default as Oe } from "../../components/textarea/theme/Textarea.base.theme.js";
|
|
51
51
|
import { default as We } from "../../components/toggle/theme/Toggle.base.theme.js";
|
|
52
|
-
import { default as Ye } from "../../components/
|
|
52
|
+
import { default as Ye } from "../../components/tooltip/theme/Tooltip.base.theme.js";
|
|
53
|
+
import { default as _e } from "../../components/upload/theme/Upload.base.theme.js";
|
|
53
54
|
export {
|
|
54
55
|
a as Accordion,
|
|
55
56
|
t as AccordionItem,
|
|
56
57
|
l as Alert,
|
|
57
|
-
|
|
58
|
+
p as Avatar,
|
|
58
59
|
m as Badge,
|
|
59
60
|
x as Breadcrumbs,
|
|
60
61
|
i as Button,
|
|
61
|
-
|
|
62
|
+
T as ButtonGroup,
|
|
62
63
|
g as Card,
|
|
63
64
|
I as Carousel,
|
|
64
65
|
P as CarouselSlide,
|
|
@@ -81,11 +82,11 @@ export {
|
|
|
81
82
|
ae as Modal,
|
|
82
83
|
te as Notifications,
|
|
83
84
|
le as Pagination,
|
|
84
|
-
|
|
85
|
+
pe as PaginationItem,
|
|
85
86
|
me as Popover,
|
|
86
87
|
xe as PopoverContainer,
|
|
87
88
|
ie as Progress,
|
|
88
|
-
|
|
89
|
+
Te as QrCode,
|
|
89
90
|
ge as Radio,
|
|
90
91
|
Ie as Scroll,
|
|
91
92
|
Pe as Select,
|
|
@@ -102,5 +103,6 @@ export {
|
|
|
102
103
|
Je as Tag,
|
|
103
104
|
Oe as Textarea,
|
|
104
105
|
We as Toggle,
|
|
105
|
-
Ye as
|
|
106
|
+
Ye as Tooltip,
|
|
107
|
+
_e as Upload
|
|
106
108
|
};
|
|
@@ -49,4 +49,5 @@ export { default as TableRow } from '../../components/table/theme/TableRow.carbo
|
|
|
49
49
|
export { default as Tag } from '../../components/tag/theme/Tag.carbon.theme';
|
|
50
50
|
export { default as Textarea } from '../../components/textarea/theme/Textarea.carbon.theme';
|
|
51
51
|
export { default as Toggle } from '../../components/toggle/theme/Toggle.carbon.theme';
|
|
52
|
+
export { default as Tooltip } from '../../components/tooltip/theme/Tooltip.carbon.theme';
|
|
52
53
|
export { default as Upload } from '../../components/upload/theme/Upload.carbon.theme';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { default as a } from "../../components/accordion/theme/Accordion.carbon.theme.js";
|
|
2
2
|
import { default as t } from "../../components/accordion/theme/AccordionItem.carbon.theme.js";
|
|
3
3
|
import { default as l } from "../../components/alert/theme/Alert.carbon.theme.js";
|
|
4
|
-
import { default as
|
|
4
|
+
import { default as p } from "../../components/avatar/theme/Avatar.carbon.theme.js";
|
|
5
5
|
import { default as m } from "../../components/badge/theme/Badge.carbon.theme.js";
|
|
6
6
|
import { default as x } from "../../components/breadcrumbs/theme/Breadcrumbs.carbon.theme.js";
|
|
7
7
|
import { default as i } from "../../components/button/theme/Button.carbon.theme.js";
|
|
8
|
-
import { default as
|
|
8
|
+
import { default as T } from "../../components/button/theme/ButtonGroup.carbon.theme.js";
|
|
9
9
|
import { default as g } from "../../components/card/theme/Card.carbon.theme.js";
|
|
10
10
|
import { default as I } from "../../components/carousel/theme/Carousel.carbon.theme.js";
|
|
11
11
|
import { default as P } from "../../components/carousel/theme/CarouselSlide.carbon.theme.js";
|
|
@@ -28,11 +28,11 @@ import { default as ee } from "../../components/menu/theme/MenuItem.carbon.theme
|
|
|
28
28
|
import { default as ae } from "../../components/modal/theme/Modal.carbon.theme.js";
|
|
29
29
|
import { default as te } from "../../components/notifications/theme/Notifications.carbon.theme.js";
|
|
30
30
|
import { default as le } from "../../components/pagination/theme/Pagination.carbon.theme.js";
|
|
31
|
-
import { default as
|
|
31
|
+
import { default as pe } from "../../components/pagination/theme/PaginationItem.carbon.theme.js";
|
|
32
32
|
import { default as me } from "../../components/popover/theme/Popover.carbon.theme.js";
|
|
33
33
|
import { default as xe } from "../../components/popover/theme/PopoverContainer.carbon.theme.js";
|
|
34
34
|
import { default as ie } from "../../components/progress/theme/Progress.carbon.theme.js";
|
|
35
|
-
import { default as
|
|
35
|
+
import { default as Te } from "../../components/qrCode/theme/QrCode.carbon.theme.js";
|
|
36
36
|
import { default as ge } from "../../components/radio/theme/Radio.carbon.theme.js";
|
|
37
37
|
import { default as Ie } from "../../components/scroll/theme/Scroll.carbon.theme.js";
|
|
38
38
|
import { default as Pe } from "../../components/select/theme/Select.carbon.theme.js";
|
|
@@ -49,16 +49,17 @@ import { default as ze } from "../../components/table/theme/TableRow.carbon.them
|
|
|
49
49
|
import { default as Je } from "../../components/tag/theme/Tag.carbon.theme.js";
|
|
50
50
|
import { default as Oe } from "../../components/textarea/theme/Textarea.carbon.theme.js";
|
|
51
51
|
import { default as We } from "../../components/toggle/theme/Toggle.carbon.theme.js";
|
|
52
|
-
import { default as Ye } from "../../components/
|
|
52
|
+
import { default as Ye } from "../../components/tooltip/theme/Tooltip.carbon.theme.js";
|
|
53
|
+
import { default as _e } from "../../components/upload/theme/Upload.carbon.theme.js";
|
|
53
54
|
export {
|
|
54
55
|
a as Accordion,
|
|
55
56
|
t as AccordionItem,
|
|
56
57
|
l as Alert,
|
|
57
|
-
|
|
58
|
+
p as Avatar,
|
|
58
59
|
m as Badge,
|
|
59
60
|
x as Breadcrumbs,
|
|
60
61
|
i as Button,
|
|
61
|
-
|
|
62
|
+
T as ButtonGroup,
|
|
62
63
|
g as Card,
|
|
63
64
|
I as Carousel,
|
|
64
65
|
P as CarouselSlide,
|
|
@@ -81,11 +82,11 @@ export {
|
|
|
81
82
|
ae as Modal,
|
|
82
83
|
te as Notifications,
|
|
83
84
|
le as Pagination,
|
|
84
|
-
|
|
85
|
+
pe as PaginationItem,
|
|
85
86
|
me as Popover,
|
|
86
87
|
xe as PopoverContainer,
|
|
87
88
|
ie as Progress,
|
|
88
|
-
|
|
89
|
+
Te as QrCode,
|
|
89
90
|
ge as Radio,
|
|
90
91
|
Ie as Scroll,
|
|
91
92
|
Pe as Select,
|
|
@@ -102,5 +103,6 @@ export {
|
|
|
102
103
|
Je as Tag,
|
|
103
104
|
Oe as Textarea,
|
|
104
105
|
We as Toggle,
|
|
105
|
-
Ye as
|
|
106
|
+
Ye as Tooltip,
|
|
107
|
+
_e as Upload
|
|
106
108
|
};
|
package/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.15.
|
|
1
|
+
declare const _default: "1.15.2";
|
|
2
2
|
export default _default;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indielayer/ui",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.2",
|
|
4
4
|
"description": "Indielayer UI Components with Tailwind CSS build for Vue 3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "João Teixeira",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"jsdom": "^22.1.0",
|
|
69
69
|
"postcss": "^8.4.4",
|
|
70
70
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
71
|
-
"shiki": "
|
|
71
|
+
"shiki": "^3.15.0",
|
|
72
72
|
"stylelint": "^14.16.1",
|
|
73
73
|
"tailwindcss": "^3.3.2",
|
|
74
74
|
"typescript": "^5.2.2",
|
|
@@ -22,7 +22,7 @@ const computedIcon = computed(() => props.icon || infoIcon)
|
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
24
|
<template>
|
|
25
|
-
<x-tooltip
|
|
25
|
+
<x-tooltip position="right">
|
|
26
26
|
<x-icon :icon="computedIcon" class="text-secondary-500 dark:text-secondary-300 cursor-pointer" />
|
|
27
27
|
<template #tooltip>
|
|
28
28
|
<div v-html="content"></div>
|
|
@@ -1,37 +1,207 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
const tooltipProps = {
|
|
3
|
+
tag: {
|
|
4
|
+
type: String,
|
|
5
|
+
default: 'div',
|
|
6
|
+
},
|
|
3
7
|
tooltip: String,
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
disabled: Boolean,
|
|
9
|
+
position: {
|
|
10
|
+
type: String as PropType<TooltipPosition>,
|
|
6
11
|
default: 'bottom',
|
|
7
12
|
},
|
|
8
13
|
}
|
|
9
14
|
|
|
10
|
-
export type
|
|
15
|
+
export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right'
|
|
11
16
|
|
|
12
17
|
export type TooltipProps = ExtractPublicPropTypes<typeof tooltipProps>
|
|
13
18
|
|
|
19
|
+
type InternalClasses = 'tooltip'
|
|
20
|
+
export interface TooltipTheme extends ThemeComponent<TooltipProps, InternalClasses> {}
|
|
21
|
+
|
|
14
22
|
export default { name: 'XTooltip' }
|
|
15
23
|
</script>
|
|
16
24
|
|
|
17
25
|
<script setup lang="ts">
|
|
26
|
+
import { computed, ref, useSlots } from 'vue'
|
|
18
27
|
import type { ExtractPublicPropTypes, PropType } from 'vue'
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
import { useTheme, type ThemeComponent } from '../../composables/useTheme'
|
|
29
|
+
|
|
30
|
+
const props = defineProps(tooltipProps)
|
|
31
|
+
|
|
32
|
+
const triggerRef = ref<HTMLElement | null>(null)
|
|
33
|
+
const tooltipRef = ref<HTMLElement | null>(null)
|
|
34
|
+
const isVisible = ref(false)
|
|
35
|
+
const tooltipStyle = ref<Record<string, string>>({})
|
|
36
|
+
const actualPosition = ref<TooltipPosition>(props.position)
|
|
37
|
+
|
|
38
|
+
const slots = useSlots()
|
|
39
|
+
const hasTooltip = computed(() => props.tooltip || slots.tooltip)
|
|
40
|
+
|
|
41
|
+
const computedDisabled = computed(() => props.disabled || !hasTooltip.value)
|
|
42
|
+
|
|
43
|
+
const arrowPositionClasses = computed(() => {
|
|
44
|
+
const placements = {
|
|
45
|
+
top: '-bottom-2.5 left-1/2 -translate-x-1/2 w-3.5',
|
|
46
|
+
bottom: '-top-2.5 left-1/2 -translate-x-1/2 w-3.5',
|
|
47
|
+
left: '-right-2.5 top-1/2 -translate-y-1/2 h-3.5',
|
|
48
|
+
right: '-left-2.5 top-1/2 -translate-y-1/2 h-3.5',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return placements[actualPosition.value]
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const arrowRotationClasses = computed(() => {
|
|
55
|
+
const placements = {
|
|
56
|
+
top: '-rotate-45 origin-top-left',
|
|
57
|
+
bottom: 'rotate-45 origin-bottom-left',
|
|
58
|
+
left: 'rotate-45 origin-top-left',
|
|
59
|
+
right: '-rotate-45 origin-top-right',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return placements[actualPosition.value]
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const animationOriginClasses = computed(() => {
|
|
66
|
+
const origins = {
|
|
67
|
+
top: 'origin-bottom',
|
|
68
|
+
bottom: 'origin-top',
|
|
69
|
+
left: 'origin-right',
|
|
70
|
+
right: 'origin-left',
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return origins[actualPosition.value]
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const calculatePosition = () => {
|
|
77
|
+
if (!triggerRef.value || !tooltipRef.value) return
|
|
22
78
|
|
|
23
|
-
|
|
79
|
+
const triggerRect = triggerRef.value.getBoundingClientRect()
|
|
80
|
+
const tooltipRect = tooltipRef.value.getBoundingClientRect()
|
|
81
|
+
const spacing = 8 // 0.5rem = 8px
|
|
82
|
+
const viewportWidth = window.innerWidth
|
|
83
|
+
const viewportHeight = window.innerHeight
|
|
84
|
+
|
|
85
|
+
let position = props.position
|
|
86
|
+
let top = 0
|
|
87
|
+
let left = 0
|
|
88
|
+
|
|
89
|
+
// Calculate initial position based on placement
|
|
90
|
+
switch (position) {
|
|
91
|
+
case 'top':
|
|
92
|
+
top = triggerRect.top - tooltipRect.height - spacing
|
|
93
|
+
left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2
|
|
94
|
+
// Check if tooltip goes off-screen top
|
|
95
|
+
if (top < 0) {
|
|
96
|
+
position = 'bottom'
|
|
97
|
+
top = triggerRect.bottom + spacing
|
|
98
|
+
}
|
|
99
|
+
break
|
|
100
|
+
case 'bottom':
|
|
101
|
+
top = triggerRect.bottom + spacing
|
|
102
|
+
left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2
|
|
103
|
+
// Check if tooltip goes off-screen bottom
|
|
104
|
+
if (top + tooltipRect.height > viewportHeight) {
|
|
105
|
+
position = 'top'
|
|
106
|
+
top = triggerRect.top - tooltipRect.height - spacing
|
|
107
|
+
}
|
|
108
|
+
break
|
|
109
|
+
case 'left':
|
|
110
|
+
top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2
|
|
111
|
+
left = triggerRect.left - tooltipRect.width - spacing
|
|
112
|
+
// Check if tooltip goes off-screen left
|
|
113
|
+
if (left < 0) {
|
|
114
|
+
position = 'right'
|
|
115
|
+
left = triggerRect.right + spacing
|
|
116
|
+
}
|
|
117
|
+
break
|
|
118
|
+
case 'right':
|
|
119
|
+
top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2
|
|
120
|
+
left = triggerRect.right + spacing
|
|
121
|
+
// Check if tooltip goes off-screen right
|
|
122
|
+
if (left + tooltipRect.width > viewportWidth) {
|
|
123
|
+
position = 'left'
|
|
124
|
+
left = triggerRect.left - tooltipRect.width - spacing
|
|
125
|
+
}
|
|
126
|
+
break
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Adjust horizontal position to stay within viewport
|
|
130
|
+
if (position === 'top' || position === 'bottom') {
|
|
131
|
+
if (left < 0) left = spacing
|
|
132
|
+
if (left + tooltipRect.width > viewportWidth) {
|
|
133
|
+
left = viewportWidth - tooltipRect.width - spacing
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Adjust vertical position to stay within viewport
|
|
138
|
+
if (position === 'left' || position === 'right') {
|
|
139
|
+
if (top < 0) top = spacing
|
|
140
|
+
if (top + tooltipRect.height > viewportHeight) {
|
|
141
|
+
top = viewportHeight - tooltipRect.height - spacing
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
actualPosition.value = position
|
|
146
|
+
tooltipStyle.value = {
|
|
147
|
+
top: `${top}px`,
|
|
148
|
+
left: `${left}px`,
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const showTooltip = () => {
|
|
153
|
+
if (computedDisabled.value) return
|
|
154
|
+
isVisible.value = true
|
|
155
|
+
setTimeout(calculatePosition, 0)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const hideTooltip = () => {
|
|
159
|
+
if (computedDisabled.value) return
|
|
160
|
+
isVisible.value = false
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const { classes, className } = useTheme('Tooltip', {}, props)
|
|
24
164
|
</script>
|
|
25
165
|
|
|
26
166
|
<template>
|
|
27
|
-
<
|
|
167
|
+
<component
|
|
168
|
+
:is="tag"
|
|
169
|
+
ref="triggerRef"
|
|
170
|
+
:class="[
|
|
171
|
+
className,
|
|
172
|
+
{
|
|
173
|
+
'inline-block': !$attrs.class,
|
|
174
|
+
}]"
|
|
175
|
+
@mouseenter="showTooltip"
|
|
176
|
+
@mouseleave="hideTooltip"
|
|
177
|
+
>
|
|
28
178
|
<slot></slot>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
179
|
+
</component>
|
|
180
|
+
|
|
181
|
+
<teleport v-if="!computedDisabled" to="body">
|
|
182
|
+
<transition
|
|
183
|
+
enter-active-class="transition-opacity duration-150 ease-out"
|
|
184
|
+
leave-active-class="transition-opacity duration-150 ease-in"
|
|
185
|
+
enter-from-class="opacity-0"
|
|
186
|
+
enter-to-class="opacity-100"
|
|
187
|
+
leave-from-class="opacity-100"
|
|
188
|
+
leave-to-class="opacity-0"
|
|
189
|
+
>
|
|
190
|
+
<div
|
|
191
|
+
v-if="isVisible"
|
|
192
|
+
ref="tooltipRef"
|
|
193
|
+
:style="tooltipStyle"
|
|
194
|
+
class="fixed z-[9999] pointer-events-none"
|
|
195
|
+
:class="[
|
|
196
|
+
classes.tooltip,
|
|
197
|
+
animationOriginClasses
|
|
198
|
+
]"
|
|
199
|
+
>
|
|
200
|
+
<slot name="tooltip">{{ tooltip }}</slot>
|
|
201
|
+
<div :class="['absolute overflow-hidden shadow-lg z-10', arrowPositionClasses]">
|
|
202
|
+
<div :class="['h-2.5 w-2.5 bg-secondary-700 transform border border-secondary-800', arrowRotationClasses]"></div>
|
|
203
|
+
</div>
|
|
34
204
|
</div>
|
|
35
|
-
</
|
|
36
|
-
</
|
|
205
|
+
</transition>
|
|
206
|
+
</teleport>
|
|
37
207
|
</template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as XTooltip } from './Tooltip.vue'
|
|
2
|
-
export type { TooltipProps } from './Tooltip.vue'
|
|
2
|
+
export type { TooltipProps, TooltipTheme } from './Tooltip.vue'
|
|
3
3
|
|
|
4
4
|
export { default as XToggleTip } from './ToggleTip.vue'
|
|
5
5
|
export type { ToggleTipProps } from './ToggleTip.vue'
|
package/src/theme.ts
CHANGED
|
@@ -51,6 +51,7 @@ import type {
|
|
|
51
51
|
TagTheme,
|
|
52
52
|
TextareaTheme,
|
|
53
53
|
ToggleTheme,
|
|
54
|
+
TooltipTheme,
|
|
54
55
|
UploadTheme,
|
|
55
56
|
} from './components'
|
|
56
57
|
|
|
@@ -106,6 +107,7 @@ export type ComponentThemes = {
|
|
|
106
107
|
Tag: TagTheme;
|
|
107
108
|
Textarea: TextareaTheme;
|
|
108
109
|
Toggle: ToggleTheme;
|
|
110
|
+
Tooltip: TooltipTheme;
|
|
109
111
|
Upload: UploadTheme;
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -49,4 +49,5 @@ export { default as TableRow } from '../../components/table/theme/TableRow.base.
|
|
|
49
49
|
export { default as Tag } from '../../components/tag/theme/Tag.base.theme'
|
|
50
50
|
export { default as Textarea } from '../../components/textarea/theme/Textarea.base.theme'
|
|
51
51
|
export { default as Toggle } from '../../components/toggle/theme/Toggle.base.theme'
|
|
52
|
+
export { default as Tooltip } from '../../components/tooltip/theme/Tooltip.base.theme'
|
|
52
53
|
export { default as Upload } from '../../components/upload/theme/Upload.base.theme'
|
|
@@ -49,4 +49,5 @@ export { default as TableRow } from '../../components/table/theme/TableRow.carbo
|
|
|
49
49
|
export { default as Tag } from '../../components/tag/theme/Tag.carbon.theme'
|
|
50
50
|
export { default as Textarea } from '../../components/textarea/theme/Textarea.carbon.theme'
|
|
51
51
|
export { default as Toggle } from '../../components/toggle/theme/Toggle.carbon.theme'
|
|
52
|
+
export { default as Tooltip } from '../../components/tooltip/theme/Tooltip.carbon.theme'
|
|
52
53
|
export { default as Upload } from '../../components/upload/theme/Upload.carbon.theme'
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.15.
|
|
1
|
+
export default '1.15.2'
|