@avakhula/ui 0.0.79 → 0.0.81
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 +1470 -1476
- package/dist/index.umd.cjs +43 -53
- package/package.json +1 -1
- package/src/App.vue +46 -8
- package/src/components/Form/Checkbox/Checkbox.vue +1 -1
- package/src/components/TreeSelect/Select.vue +1 -1
- 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,59 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<div class="hello">
|
|
3
|
+
<div v-for="item in items" :key="item.id">
|
|
4
|
+
{{ item.name }}
|
|
5
|
+
|
|
6
|
+
<ib-icon-button @click="deleteItem(item.id)" v-tooltip="'DELETE'">
|
|
7
|
+
<ib-icon name="close-outline" />
|
|
8
|
+
</ib-icon-button>
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
3
11
|
</template>
|
|
4
12
|
|
|
5
13
|
<script>
|
|
6
|
-
import
|
|
14
|
+
import { TextOverflowTooltipDirective as TextOverflowTooltip } from "./directives/tooltip/textOverflowTooltip";
|
|
15
|
+
import { TooltipDirective as Tooltip } from "./directives/tooltip/tooltip";
|
|
7
16
|
|
|
17
|
+
import IbIconButton from "./components/IconButton/IconButton.vue";
|
|
18
|
+
import IbIcon from "./components/Icon.vue"
|
|
8
19
|
export default {
|
|
9
20
|
data() {
|
|
10
21
|
return {
|
|
11
|
-
|
|
12
|
-
|
|
22
|
+
items: [
|
|
23
|
+
{ id: 1, name: "Item 1" },
|
|
24
|
+
{ id: 2, name: "Item 2" },
|
|
25
|
+
{ id: 3, name: "Item 3" },
|
|
26
|
+
{ id: 4, name: "Item 4" },
|
|
27
|
+
{ id: 5, name: "Item 5" },
|
|
28
|
+
],
|
|
29
|
+
};
|
|
13
30
|
},
|
|
14
|
-
|
|
15
|
-
|
|
31
|
+
methods: {
|
|
32
|
+
deleteItem(id) {
|
|
33
|
+
const idx = this.items.findIndex((item) => item.id === id);
|
|
34
|
+
this.items.splice(idx, 1);
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
directives: {
|
|
38
|
+
TextOverflowTooltip,
|
|
39
|
+
Tooltip
|
|
16
40
|
},
|
|
41
|
+
components: {
|
|
42
|
+
IbIconButton,
|
|
43
|
+
IbIcon
|
|
44
|
+
}
|
|
17
45
|
};
|
|
18
46
|
</script>
|
|
19
47
|
|
|
20
|
-
<style>
|
|
21
|
-
|
|
48
|
+
<style lang="scss">
|
|
49
|
+
@import "./assets/scss/mixins.scss";
|
|
50
|
+
|
|
51
|
+
.hello {
|
|
52
|
+
padding: 200px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.test {
|
|
56
|
+
max-width: 20px;
|
|
57
|
+
@include lineClamp(1);
|
|
58
|
+
}
|
|
59
|
+
</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
|
+
beforeUnmount(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
|
+
beforeUnmount(el, binding) {
|
|
19
|
+
tooltip.destroyTooltip();
|
|
20
|
+
el.removeEventListener("mouseenter", () => createTooltip(el, binding));
|
|
21
|
+
el.removeEventListener("mouseleave", destroyTooltip);
|
|
49
22
|
},
|
|
50
23
|
};
|