@avakhula/ui 0.0.28 → 0.0.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avakhula/ui",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.umd.cjs",
6
6
  "source": "src/index.js",
package/src/App.vue CHANGED
@@ -26,11 +26,16 @@
26
26
  <ib-button style="margin-bottom: 1020px;" v-tooltip="'test'" >HOVER ME</ib-button>
27
27
  <ib-button style="margin-bottom: 20px;" v-tooltip="'second test'" >HOVER ME</ib-button>
28
28
 
29
+ <p class="test" v-TextOverflowTooltipTooltip="'test'">
30
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Earum inventore maxime porro exercitationem. Deserunt temporibus quasi rerum numquam tenetur dolor illum nemo
31
+ </p>
32
+
29
33
  </template>
30
34
 
31
35
  <script>
32
36
  import IbButton from "./components/Button/Button.vue"
33
37
  import { TooltipDirective as Tooltip} from "./directives/tooltip/tooltip"
38
+ import { TextOverflowTooltipDirective as TextOverflowTooltipTooltip} from "./directives/tooltip/textOverflowTooltip"
34
39
 
35
40
  import IbSelect from "./components/TreeSelect/Select.vue";
36
41
  import IbCheckbox from "./components/Form/Checkbox/Checkbox.vue";
@@ -95,6 +100,7 @@ export default {
95
100
  },
96
101
  directives: {
97
102
  Tooltip,
103
+ TextOverflowTooltipTooltip,
98
104
  },
99
105
  watch: {
100
106
  test(val) {
@@ -128,4 +134,11 @@ export default {
128
134
  </script>
129
135
 
130
136
  <style>
137
+ .test {
138
+ overflow: hidden;
139
+ display: -webkit-box;
140
+ -webkit-line-clamp: 1;
141
+ -webkit-box-orient: vertical;
142
+
143
+ }
131
144
  </style>
@@ -0,0 +1,61 @@
1
+ import { createApp } from "vue";
2
+ import IbTooltip from "../../components/Tooltip/Tooltip.vue";
3
+ import multiLineOverflows from "../../helpers/multiLineOverflows";
4
+
5
+ let tooltipInstance = null;
6
+ let tooltipContainer = null;
7
+
8
+ function createTooltipInstance(el, binding) {
9
+ const tooltipContainerStyles = `
10
+ position: absolute;
11
+ top: 0px;
12
+ left: 0px;
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
+ `;
39
+
40
+ tooltipContainer.firstChild.setAttribute("style", tooltipStyles);
41
+ }
42
+ }, 100);
43
+ }
44
+
45
+ export const TextOverflowTooltipDirective = {
46
+ mounted(el, binding) {
47
+ el.addEventListener("mouseenter", () => {
48
+ if (multiLineOverflows(el)) {
49
+ createTooltipInstance(el, binding);
50
+ }
51
+ });
52
+
53
+ el.addEventListener("mouseleave", () => {
54
+ tooltipInstance?.unmount();
55
+ if (tooltipContainer) {
56
+ document.body.removeChild(tooltipContainer);
57
+ tooltipContainer = null;
58
+ }
59
+ });
60
+ },
61
+ };
package/src/index.js CHANGED
@@ -48,3 +48,4 @@ export { default as IbCheckboxCell } from "./components/Table/Cells/CheckboxCell
48
48
  // Directives
49
49
  export { OutsideDirective } from "./directives/outside/outside";
50
50
  export { TooltipDirective } from "./directives/tooltip/tooltip";
51
+ export { TextOverflowTooltipDirective } from "./directives/tooltip/textOverflowTooltip";