@avakhula/ui 0.0.79 → 0.0.80
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/dist/index.js +1469 -1475
- package/dist/index.umd.cjs +43 -53
- package/package.json +1 -1
- package/src/App.vue +24 -8
- package/src/directives/tooltip/TooltipController.js +55 -0
- package/src/directives/tooltip/textOverflowTooltip.js +17 -51
- package/src/directives/tooltip/tooltip.js +17 -44
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<div class="hello">
|
|
3
|
+
<p class="test" v-text-overflow-tooltip="test">
|
|
4
|
+
{{ test }}
|
|
5
|
+
</p>
|
|
6
|
+
</div>
|
|
3
7
|
</template>
|
|
4
8
|
|
|
5
9
|
<script>
|
|
6
|
-
import
|
|
7
|
-
|
|
10
|
+
import { TextOverflowTooltipDirective as TextOverflowTooltip } from "./directives/tooltip/textOverflowTooltip";
|
|
8
11
|
export default {
|
|
9
12
|
data() {
|
|
10
13
|
return {
|
|
11
|
-
test:
|
|
14
|
+
test: `Lorem ipsum, dolor sit amet consectetur adipisicing elit. Sit inventore
|
|
15
|
+
quos, ratione veniam delectus, repellat voluptate maiores quo laudantium
|
|
16
|
+
nostrum fugiat! Reiciendis rem ipsum itaque quas molestiae ex doloribus
|
|
17
|
+
ullam!`
|
|
12
18
|
}
|
|
13
19
|
},
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
directives: {
|
|
21
|
+
TextOverflowTooltip,
|
|
16
22
|
},
|
|
17
23
|
};
|
|
18
24
|
</script>
|
|
19
25
|
|
|
20
|
-
<style>
|
|
21
|
-
|
|
26
|
+
<style lang="scss">
|
|
27
|
+
@import "./assets/scss/mixins.scss";
|
|
28
|
+
|
|
29
|
+
.hello {
|
|
30
|
+
padding: 200px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.test {
|
|
34
|
+
max-width: 20px;
|
|
35
|
+
@include lineClamp(1);
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createApp } from "vue";
|
|
2
|
+
import IbTooltip from "../../components/Tooltip/Tooltip.vue";
|
|
3
|
+
|
|
4
|
+
export default class Tooltip {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.tooltipInstance = null;
|
|
7
|
+
this.tooltipContainer = null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
createTooltip(el, text) {
|
|
11
|
+
const tooltipContainerStyles = `
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: 0px;
|
|
14
|
+
left: 0px;
|
|
15
|
+
`;
|
|
16
|
+
this.tooltipContainer = document.createElement("div");
|
|
17
|
+
this.tooltipContainer.setAttribute("style", tooltipContainerStyles);
|
|
18
|
+
|
|
19
|
+
document.body.appendChild(this.tooltipContainer);
|
|
20
|
+
this.tooltipInstance = createApp(IbTooltip, {
|
|
21
|
+
text: text,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
this.tooltipInstance.mount(this.tooltipContainer);
|
|
25
|
+
this.tooltipContainer.firstChild.setAttribute("style", "display: block");
|
|
26
|
+
|
|
27
|
+
setTimeout(() => {
|
|
28
|
+
if (this.tooltipContainer?.firstChild) {
|
|
29
|
+
const { top, left, width } = el.getBoundingClientRect();
|
|
30
|
+
const { width: tooltipWidth, height: tooltipHeight } =
|
|
31
|
+
this.tooltipContainer.firstChild.getBoundingClientRect();
|
|
32
|
+
const scrollTop = document.documentElement.scrollTop;
|
|
33
|
+
|
|
34
|
+
const tooltipStyles = `
|
|
35
|
+
left: ${left + width / 2 - tooltipWidth / 2}px!important;
|
|
36
|
+
top: ${top - tooltipHeight + scrollTop - 5}px!important;
|
|
37
|
+
bottom: auto!important;
|
|
38
|
+
right: auto!important;
|
|
39
|
+
transform: none!important;
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
this.tooltipContainer.firstChild.setAttribute("style", tooltipStyles);
|
|
43
|
+
}
|
|
44
|
+
}, 100);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
destroyTooltip() {
|
|
48
|
+
if (this.tooltipInstance && this.tooltipContainer) {
|
|
49
|
+
this.tooltipInstance.unmount();
|
|
50
|
+
this.tooltipInstance = null;
|
|
51
|
+
this.tooltipContainer.remove();
|
|
52
|
+
this.tooltipContainer = null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,61 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import IbTooltip from "../../components/Tooltip/Tooltip.vue";
|
|
1
|
+
import Tooltip from "./TooltipController";
|
|
3
2
|
import multiLineOverflows from "../../helpers/multiLineOverflows";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
let tooltipContainer = null;
|
|
4
|
+
const tooltip = new Tooltip();
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
`;
|
|
14
|
-
tooltipContainer = document.createElement("div");
|
|
15
|
-
tooltipContainer.setAttribute("style", tooltipContainerStyles);
|
|
16
|
-
|
|
17
|
-
document.body.appendChild(tooltipContainer);
|
|
18
|
-
tooltipInstance = createApp(IbTooltip, {
|
|
19
|
-
text: binding.value,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
tooltipInstance.mount(tooltipContainer);
|
|
23
|
-
tooltipContainer.firstChild.setAttribute("style", "display: block");
|
|
24
|
-
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
if (tooltipContainer?.firstChild) {
|
|
27
|
-
const { top, left, width } = el.getBoundingClientRect();
|
|
28
|
-
const { width: tooltipWidth, height: tooltipHeight } =
|
|
29
|
-
tooltipContainer.firstChild.getBoundingClientRect();
|
|
30
|
-
const scrollTop = document.documentElement.scrollTop;
|
|
31
|
-
|
|
32
|
-
const tooltipStyles = `
|
|
33
|
-
left: ${left + width / 2 - tooltipWidth / 2}px!important;
|
|
34
|
-
top: ${top - tooltipHeight + scrollTop - 5}px!important;
|
|
35
|
-
bottom: auto!important;
|
|
36
|
-
right: auto!important;
|
|
37
|
-
transform: none!important;
|
|
38
|
-
`;
|
|
6
|
+
const createTooltip = (el, binding) => {
|
|
7
|
+
if (multiLineOverflows(el)) {
|
|
8
|
+
tooltip.createTooltip(el, binding.value);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
39
11
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
12
|
+
const destroyTooltip = () => {
|
|
13
|
+
tooltip.destroyTooltip();
|
|
14
|
+
};
|
|
44
15
|
|
|
45
16
|
export const TextOverflowTooltipDirective = {
|
|
46
17
|
mounted(el, binding) {
|
|
47
|
-
el.addEventListener("mouseenter", () =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
});
|
|
18
|
+
el.addEventListener("mouseenter", () => createTooltip(el, binding));
|
|
19
|
+
el.addEventListener("mouseleave", destroyTooltip);
|
|
20
|
+
},
|
|
52
21
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
tooltipContainer = null;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
22
|
+
onBeforeUnmount(el, binding) {
|
|
23
|
+
tooltip.destroyTooltip();
|
|
24
|
+
el.removeEventListener("mouseenter", () => createTooltip(el, binding));
|
|
25
|
+
el.removeEventListener("mouseleave", destroyTooltip);
|
|
60
26
|
},
|
|
61
27
|
};
|
|
@@ -1,50 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import IbTooltip from "../../components/Tooltip/Tooltip.vue";
|
|
1
|
+
import Tooltip from "./TooltipController";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
el.addEventListener("mouseenter", () => {
|
|
10
|
-
const tooltipContainerStyles = `
|
|
11
|
-
position: absolute;
|
|
12
|
-
top: 0px;
|
|
13
|
-
left: 0px;
|
|
14
|
-
`;
|
|
15
|
-
tooltipContainer.setAttribute("style", tooltipContainerStyles);
|
|
16
|
-
|
|
17
|
-
document.body.appendChild(tooltipContainer);
|
|
18
|
-
tooltipInstance = createApp(IbTooltip, {
|
|
19
|
-
text: binding.value,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
tooltipInstance.mount(tooltipContainer);
|
|
23
|
-
tooltipContainer.firstChild.setAttribute("style", "display: block");
|
|
24
|
-
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
if (tooltipContainer.firstChild) {
|
|
27
|
-
const { top, left, width } = el.getBoundingClientRect();
|
|
28
|
-
const { width: tooltipWidth, height: tooltipHeight } =
|
|
29
|
-
tooltipContainer.firstChild.getBoundingClientRect();
|
|
30
|
-
const scrollTop = document.documentElement.scrollTop;
|
|
3
|
+
const tooltip = new Tooltip();
|
|
4
|
+
const createTooltip = (el, binding) => {
|
|
5
|
+
tooltip.createTooltip(el, binding.value);
|
|
6
|
+
};
|
|
31
7
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
bottom: auto!important;
|
|
36
|
-
right: auto!important;
|
|
37
|
-
transform: none!important;
|
|
38
|
-
`;
|
|
8
|
+
const destroyTooltip = () => {
|
|
9
|
+
tooltip.destroyTooltip();
|
|
10
|
+
};
|
|
39
11
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
12
|
+
export const TooltipDirective = {
|
|
13
|
+
mounted(el, binding) {
|
|
14
|
+
el.addEventListener("mouseenter", () => createTooltip(el, binding));
|
|
15
|
+
el.addEventListener("mouseleave", destroyTooltip);
|
|
16
|
+
},
|
|
44
17
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
18
|
+
onBeforeUnmount(el, binding) {
|
|
19
|
+
tooltip.destroyTooltip();
|
|
20
|
+
el.removeEventListener("mouseenter", () => createTooltip(el, binding));
|
|
21
|
+
el.removeEventListener("mouseleave", destroyTooltip);
|
|
49
22
|
},
|
|
50
23
|
};
|