@avakhula/ui 0.0.78 → 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 +3178 -3167
- package/dist/index.umd.cjs +59 -69
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/App.vue +24 -8
- package/src/components/Form/Input/input.scss +2 -2
- package/src/components/TreeSelect/Select.stories.js +3 -0
- package/src/components/TreeSelect/Select.vue +11 -0
- package/src/components/TreeSelect/scss/select.scss +19 -2
- 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>
|
|
@@ -14,7 +14,7 @@ $input-hover-color: $neutral-900;
|
|
|
14
14
|
$input-hover-bg: $blue-200;
|
|
15
15
|
$input-hover-border-color: $blue-700;
|
|
16
16
|
$input-hover-placeholder-color: $neutral-600;
|
|
17
|
-
$input-
|
|
17
|
+
$input-border-error-color: $red-800;
|
|
18
18
|
|
|
19
19
|
.ib-input-wrapper {
|
|
20
20
|
position: relative;
|
|
@@ -123,7 +123,7 @@ $input-hover-error-color: $red-800;
|
|
|
123
123
|
&.ib-error {
|
|
124
124
|
border-radius: 4px;
|
|
125
125
|
border-color: transparent;
|
|
126
|
-
@include outline(-2px, $input-
|
|
126
|
+
@include outline(-2px, $input-border-error-color);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
+
<ib-alert class="tree-select-error" v-if="errorMessage">
|
|
3
|
+
{{ errorMessage }}
|
|
4
|
+
</ib-alert>
|
|
5
|
+
|
|
2
6
|
<div class="tree-select">
|
|
3
7
|
<ib-dropdown
|
|
4
8
|
:disabled="isLoading"
|
|
@@ -22,6 +26,7 @@
|
|
|
22
26
|
:class="{
|
|
23
27
|
'tree-choice-opened': isOpened,
|
|
24
28
|
'has-clear-button': !showClearButton,
|
|
29
|
+
'tree-choice-error': errorMessage,
|
|
25
30
|
}"
|
|
26
31
|
>
|
|
27
32
|
<template v-if="htmlOptionTitle">
|
|
@@ -232,6 +237,7 @@ import generateUID from "../../helpers/generateUID";
|
|
|
232
237
|
import IbDropdown from "../Dropdown/Dropdown.vue";
|
|
233
238
|
import IbIcon from "../Icon.vue";
|
|
234
239
|
import IbIconButton from "../IconButton/IconButton.vue";
|
|
240
|
+
import IbAlert from "../Alert/Alert.vue";
|
|
235
241
|
import List from "../List.vue";
|
|
236
242
|
|
|
237
243
|
export default {
|
|
@@ -359,6 +365,10 @@ export default {
|
|
|
359
365
|
type: String,
|
|
360
366
|
default: "",
|
|
361
367
|
},
|
|
368
|
+
errorMessage: {
|
|
369
|
+
type: String,
|
|
370
|
+
default: "",
|
|
371
|
+
},
|
|
362
372
|
allOptions: {
|
|
363
373
|
type: Boolean,
|
|
364
374
|
default: true,
|
|
@@ -938,6 +948,7 @@ export default {
|
|
|
938
948
|
},
|
|
939
949
|
},
|
|
940
950
|
components: {
|
|
951
|
+
IbAlert,
|
|
941
952
|
IbIconButton,
|
|
942
953
|
IbIcon,
|
|
943
954
|
IbDropdown,
|
|
@@ -17,10 +17,22 @@ $choice-hover-icon-color: $blue-700;
|
|
|
17
17
|
$choice-opened-bg: $blue-50;
|
|
18
18
|
$choice-opened-border-color: $blue-900;
|
|
19
19
|
$choice-opened-icon-color: $blue-900;
|
|
20
|
-
|
|
20
|
+
$choice-border-error-color: $red-800;
|
|
21
21
|
$tree-search-border-color: $gray-600;
|
|
22
|
+
|
|
23
|
+
.tree-select-error {
|
|
24
|
+
margin-bottom: 5px;
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
.tree-select {
|
|
28
|
+
width: 100%;
|
|
29
|
+
|
|
30
|
+
.ib-dropdown {
|
|
31
|
+
width: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
.dropdown-trigger {
|
|
35
|
+
width: inherit;
|
|
24
36
|
display: inline-block;
|
|
25
37
|
position: relative;
|
|
26
38
|
|
|
@@ -60,7 +72,6 @@ $tree-search-border-color: $gray-600;
|
|
|
60
72
|
background-color: $choice-bg;
|
|
61
73
|
color: $choice-text-color;
|
|
62
74
|
border-radius: 4px 4px 0 0;
|
|
63
|
-
width: 280px;
|
|
64
75
|
display: flex;
|
|
65
76
|
align-items: center;
|
|
66
77
|
justify-content: space-between;
|
|
@@ -92,6 +103,12 @@ $tree-search-border-color: $gray-600;
|
|
|
92
103
|
color: $choice-opened-icon-color;
|
|
93
104
|
}
|
|
94
105
|
}
|
|
106
|
+
|
|
107
|
+
&.tree-choice-error {
|
|
108
|
+
border-radius: 4px;
|
|
109
|
+
border-color: transparent;
|
|
110
|
+
@include outline(-2px, $choice-border-error-color);
|
|
111
|
+
}
|
|
95
112
|
}
|
|
96
113
|
|
|
97
114
|
.button-clear {
|
|
@@ -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
|
};
|