@avakhula/ui 0.0.33 → 0.0.34-4.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/.eslintrc.cjs +17 -10
- package/.storybook/preview-head.html +1 -0
- package/dist/index.js +9042 -7752
- package/dist/index.umd.cjs +87 -88
- package/dist/style.css +1 -1
- package/package.json +15 -15
- package/src/App.vue +138 -25
- package/src/assets/scss/mixins/dropdown-list-item.scss +8 -1
- package/src/assets/scss/mixins/tooltip-position.scss +1 -1
- package/src/assets/scss/variables/shadows.json +14 -30
- package/src/assets/scss/variables/shadows.scss +10 -15
- package/src/components/Accordion/Accordion.scss +4 -1
- package/src/components/Accordion/Accordion.vue +20 -3
- package/src/components/Accordion/Acordion.spec.js +75 -0
- package/src/components/Alert/Alert.spec.js +69 -0
- package/src/components/Alert/Alert.stories.js +1 -4
- package/src/components/Alert/Alert.vue +22 -3
- package/src/components/Alert/alert.scss +22 -0
- package/src/components/Alert/constants.js +1 -0
- package/src/components/Avatar/Avatar.stories.js +23 -0
- package/src/components/Avatar/Avatar.vue +125 -0
- package/src/components/Avatar/constants.js +4 -0
- package/src/components/Badge/Badge.spec.js +37 -0
- package/src/components/Badge/Badge.vue +1 -1
- package/src/components/Button/Button.spec.js +85 -0
- package/src/components/Button/Button.vue +14 -3
- package/src/components/Button/button.scss +5 -0
- package/src/components/Dropdown/Dropdown.vue +3 -3
- package/src/components/Dropdown/DropdownItem.vue +9 -3
- package/src/components/Form/Checkbox/Checkbox.scss +79 -53
- package/src/components/Form/Checkbox/Checkbox.stories.js +4 -2
- package/src/components/Form/Checkbox/Checkbox.vue +70 -48
- package/src/components/Form/CheckboxGroup/CheckboxGroup.vue +11 -0
- package/src/components/Form/CheckboxGroup/readme.mdx +2 -0
- package/src/components/Form/DatePicker/DatePicker.scss +259 -261
- package/src/components/Form/DatePicker/DatePicker.vue +1 -1
- package/src/components/Form/Input/Input.vue +69 -15
- package/src/components/Form/Input/constants.js +1 -0
- package/src/components/Form/Input/input.scss +33 -6
- package/src/components/Form/Label/Label.stories.js +7 -0
- package/src/components/Form/Label/Label.vue +43 -4
- package/src/components/Form/Label/readme.mdx +1 -0
- package/src/components/Form/PhoneInput/phoneInput.scss +3 -2
- package/src/components/Form/Radio/Radio.vue +31 -38
- package/src/components/Form/Radio/radio.scss +6 -3
- package/src/components/Form/Toggle/Toggle.vue +5 -1
- package/src/components/Form/Toggle/toggle.scss +4 -4
- package/src/components/IconButton/IconButton.scss +7 -0
- package/src/components/IconButton/IconButton.vue +10 -9
- package/src/components/List.vue +1 -1
- package/src/components/Modal/Modal.stories.js +6 -4
- package/src/components/Modal/Modal.vue +56 -11
- package/src/components/Pagination/LimitSelector.vue +3 -5
- package/src/components/Pagination/Pagination.vue +3 -0
- package/src/components/Pagination/pagination.scss +8 -14
- package/src/components/Panel/Panel.stories.js +0 -7
- package/src/components/Panel/Panel.vue +30 -29
- package/src/components/Popover/Popover.vue +43 -17
- package/src/components/Popover/constants.js +1 -1
- package/src/components/Popover/popover.scss +28 -8
- package/src/components/ProgressBar/ProgressBar.vue +14 -1
- package/src/components/ProgressBar/constants.js +1 -0
- package/src/components/ProgressBar/progressBar.scss +7 -0
- package/src/components/Sorting/Sorting.stories.js +12 -2
- package/src/components/Sorting/Sorting.vue +125 -37
- package/src/components/Sorting/sorting.scss +17 -14
- package/src/components/SplitButton/SplitButton.vue +8 -1
- package/src/components/SplitButton/splitButton.scss +3 -0
- package/src/components/StatusIndicator/icons.js +11 -11
- package/src/components/Tabs/Tabs.vue +25 -2
- package/src/components/Tabs/tabs.scss +1 -1
- package/src/components/ToggleTip/constants.js +1 -1
- package/src/components/ToggleTip/toggleTip.scss +2 -2
- package/src/components/Tooltip/Tooltip.vue +120 -4
- package/src/components/TreeSelect/Option.vue +36 -27
- package/src/components/TreeSelect/Select.stories.js +5 -90
- package/src/components/TreeSelect/Select.vue +256 -121
- package/src/components/TreeSelect/scss/option.scss +8 -0
- package/src/components/TreeSelect/scss/select.scss +51 -6
- package/src/directives/tooltip/TooltipController.js +184 -0
- package/src/directives/tooltip/readme.mdx +17 -0
- package/src/directives/tooltip/textOverflowTooltip.js +21 -49
- package/src/directives/tooltip/tooltip.js +57 -45
- package/src/directives/tooltip/tooltip.stories.js +39 -0
- package/src/helpers/removeEvents.js +2 -2
- package/src/index.js +1 -0
- package/src/main.js +1 -0
- package/src/scripts/parseScssVariables.js +23 -7
- package/src/components/Panel/constants.js +0 -4
|
@@ -17,10 +17,34 @@ $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
|
+
.disable {
|
|
24
|
+
.tree-choice {
|
|
25
|
+
background-color: $gray-100 !important;
|
|
26
|
+
color: $neutral-500 !important;
|
|
27
|
+
border-bottom: 1px solid $neutral-500 !important;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.tree-select-error {
|
|
32
|
+
margin-bottom: 5px;
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
.tree-select {
|
|
36
|
+
width: 100%;
|
|
37
|
+
|
|
38
|
+
&.tree-select-custom-trigger-content {
|
|
39
|
+
width: fit-content;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.ib-dropdown {
|
|
43
|
+
width: 100%;
|
|
44
|
+
}
|
|
45
|
+
|
|
23
46
|
.dropdown-trigger {
|
|
47
|
+
width: inherit;
|
|
24
48
|
display: inline-block;
|
|
25
49
|
position: relative;
|
|
26
50
|
|
|
@@ -39,6 +63,7 @@ $tree-search-border-color: $gray-600;
|
|
|
39
63
|
display: flex;
|
|
40
64
|
align-items: center;
|
|
41
65
|
justify-content: center;
|
|
66
|
+
font-size: 16px;
|
|
42
67
|
}
|
|
43
68
|
|
|
44
69
|
&:hover {
|
|
@@ -60,18 +85,21 @@ $tree-search-border-color: $gray-600;
|
|
|
60
85
|
background-color: $choice-bg;
|
|
61
86
|
color: $choice-text-color;
|
|
62
87
|
border-radius: 4px 4px 0 0;
|
|
63
|
-
width: 280px;
|
|
64
88
|
display: flex;
|
|
65
89
|
align-items: center;
|
|
66
90
|
justify-content: space-between;
|
|
67
91
|
overflow: hidden;
|
|
68
92
|
position: relative;
|
|
69
|
-
padding-right:
|
|
93
|
+
padding-right: 30px;
|
|
70
94
|
border-bottom: 1px solid $choice-border-color;
|
|
71
95
|
transition: background-color 0.3s, border-color 0.3s, border-radius 0.3s;
|
|
72
96
|
|
|
73
97
|
&.has-clear-button {
|
|
74
|
-
padding-right:
|
|
98
|
+
padding-right: 60px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&.tree-choice-custom-content {
|
|
102
|
+
width: fit-content;
|
|
75
103
|
}
|
|
76
104
|
|
|
77
105
|
span {
|
|
@@ -80,8 +108,8 @@ $tree-search-border-color: $gray-600;
|
|
|
80
108
|
|
|
81
109
|
&:focus {
|
|
82
110
|
border-radius: 4px;
|
|
83
|
-
border-bottom
|
|
84
|
-
@include outline();
|
|
111
|
+
border-bottom: 0px;
|
|
112
|
+
@include outline(0px);
|
|
85
113
|
}
|
|
86
114
|
|
|
87
115
|
&.tree-choice-opened {
|
|
@@ -92,12 +120,29 @@ $tree-search-border-color: $gray-600;
|
|
|
92
120
|
color: $choice-opened-icon-color;
|
|
93
121
|
}
|
|
94
122
|
}
|
|
123
|
+
|
|
124
|
+
&.tree-choice-error {
|
|
125
|
+
border-radius: 4px;
|
|
126
|
+
border-color: transparent;
|
|
127
|
+
@include outline(-2px, $choice-border-error-color);
|
|
128
|
+
|
|
129
|
+
&:focus {
|
|
130
|
+
@include outline(0px);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
95
133
|
}
|
|
96
134
|
|
|
97
135
|
.button-clear {
|
|
98
136
|
margin-left: auto;
|
|
99
137
|
}
|
|
100
138
|
|
|
139
|
+
.dropdown-top {
|
|
140
|
+
.tree-drop {
|
|
141
|
+
bottom: 42px;
|
|
142
|
+
top: auto;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
101
146
|
.tree-drop {
|
|
102
147
|
z-index: 9998;
|
|
103
148
|
box-shadow: $menu-shadow;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { createApp } from "vue";
|
|
2
|
+
import { popoverPosition } from "../../components/Popover/constants";
|
|
3
|
+
import IbTooltip from "../../components/Tooltip/Tooltip.vue";
|
|
4
|
+
import generateUID from "../../helpers/generateUID";
|
|
5
|
+
|
|
6
|
+
export default class Tooltip {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.tooltipInstance = null;
|
|
9
|
+
this.tooltipContainer = null;
|
|
10
|
+
this.uuid = null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getTooltipInstance() {
|
|
14
|
+
return this.getTooltipInstance;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getTooltipContainer() {
|
|
18
|
+
return this.tooltipContainer;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getId() {
|
|
22
|
+
return this.uuid;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
generateUID() {
|
|
26
|
+
this.uuid = "tooltip_" + generateUID();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
createTooltip(el, content, position) {
|
|
30
|
+
if (!content.text?.length) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.generateUID();
|
|
35
|
+
|
|
36
|
+
const tooltipContainerStyles = `
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: 0px;
|
|
39
|
+
left: 0px;
|
|
40
|
+
opacity: 0;
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
this.tooltipContainer = document.createElement("div");
|
|
44
|
+
this.tooltipContainer.setAttribute("style", tooltipContainerStyles);
|
|
45
|
+
|
|
46
|
+
document.body.appendChild(this.tooltipContainer);
|
|
47
|
+
this.tooltipInstance = createApp(IbTooltip, {
|
|
48
|
+
title: content.title,
|
|
49
|
+
text: content.text,
|
|
50
|
+
alwaysVisible: true,
|
|
51
|
+
for: this.uuid,
|
|
52
|
+
class: this.getClassList(position),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
this.tooltipInstance.mount(this.tooltipContainer);
|
|
56
|
+
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
if (this.tooltipContainer?.firstChild) {
|
|
59
|
+
el.setAttribute("aria-describedby", this.uuid);
|
|
60
|
+
|
|
61
|
+
const tooltipStyles = this.getPositionStyle(el, position);
|
|
62
|
+
this.tooltipContainer.firstChild.setAttribute("style", tooltipStyles);
|
|
63
|
+
this.tooltipContainer.setAttribute("style", {'opacity': 1});
|
|
64
|
+
}
|
|
65
|
+
}, 100);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
destroyTooltip(el) {
|
|
69
|
+
el?.removeAttribute("aria-describedby");
|
|
70
|
+
this.uuid = null;
|
|
71
|
+
this.tooltipInstance?.unmount();
|
|
72
|
+
this.tooltipInstance = null;
|
|
73
|
+
this.tooltipContainer?.remove();
|
|
74
|
+
this.tooltipContainer = null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getPositionStyle(el, position) {
|
|
78
|
+
const { top, bottom, left, right, width, height } = el.getBoundingClientRect();
|
|
79
|
+
const { width: tooltipWidth, height: tooltipHeight } =
|
|
80
|
+
this.tooltipContainer.firstChild.getBoundingClientRect();
|
|
81
|
+
|
|
82
|
+
const scrollTop = document.documentElement.scrollTop;
|
|
83
|
+
|
|
84
|
+
let styles = `
|
|
85
|
+
bottom: auto!important;
|
|
86
|
+
right: auto!important;
|
|
87
|
+
transform: none!important;
|
|
88
|
+
`;
|
|
89
|
+
|
|
90
|
+
switch (position) {
|
|
91
|
+
case "bottomCenter":
|
|
92
|
+
styles =
|
|
93
|
+
styles +
|
|
94
|
+
`left: ${left + width / 2 - tooltipWidth / 2}px!important;
|
|
95
|
+
top: ${bottom + scrollTop + 5}px!important;`;
|
|
96
|
+
break;
|
|
97
|
+
case "bottomLeft":
|
|
98
|
+
styles =
|
|
99
|
+
styles +
|
|
100
|
+
`left: ${right - tooltipWidth - width / 2 + 14}px!important;
|
|
101
|
+
top: ${bottom + scrollTop + 5}px!important;`;
|
|
102
|
+
break;
|
|
103
|
+
case "bottomRight":
|
|
104
|
+
styles =
|
|
105
|
+
styles +
|
|
106
|
+
`left: ${left + width / 2 - 14}px!important;
|
|
107
|
+
top: ${bottom + scrollTop + 5}px!important;`;
|
|
108
|
+
break;
|
|
109
|
+
case "topLeft":
|
|
110
|
+
styles =
|
|
111
|
+
styles +
|
|
112
|
+
`left: ${right - tooltipWidth - width / 2 + 14}px!important;
|
|
113
|
+
top: ${top - tooltipHeight + scrollTop - 5}px!important;`;
|
|
114
|
+
break;
|
|
115
|
+
case "topRight":
|
|
116
|
+
styles =
|
|
117
|
+
styles +
|
|
118
|
+
`left: ${left + width / 2 - 14}px!important;
|
|
119
|
+
top: ${top - tooltipHeight + scrollTop - 5}px!important;`;
|
|
120
|
+
break;
|
|
121
|
+
case "leftTop":
|
|
122
|
+
styles =
|
|
123
|
+
styles +
|
|
124
|
+
`left: ${left - tooltipWidth - 5}px!important;
|
|
125
|
+
top: ${
|
|
126
|
+
bottom - tooltipHeight - height / 2 + scrollTop + 12
|
|
127
|
+
}px!important`;
|
|
128
|
+
break;
|
|
129
|
+
case "leftCenter":
|
|
130
|
+
styles =
|
|
131
|
+
styles +
|
|
132
|
+
`left: ${left - tooltipWidth - 5}px!important;
|
|
133
|
+
top: ${
|
|
134
|
+
bottom + scrollTop - tooltipHeight / 2 - height / 2
|
|
135
|
+
}px!important;`;
|
|
136
|
+
break;
|
|
137
|
+
case "leftBottom":
|
|
138
|
+
styles =
|
|
139
|
+
styles +
|
|
140
|
+
`left: ${left - tooltipWidth - 5}px!important;
|
|
141
|
+
top: ${bottom + scrollTop - height / 2 - 12}px!important;`;
|
|
142
|
+
break;
|
|
143
|
+
case "rightTop":
|
|
144
|
+
styles =
|
|
145
|
+
styles +
|
|
146
|
+
`left: ${right + 5}px!important;
|
|
147
|
+
top: ${
|
|
148
|
+
bottom - tooltipHeight - height / 2 + scrollTop + 12
|
|
149
|
+
}px!important`;
|
|
150
|
+
break;
|
|
151
|
+
case "rightCenter":
|
|
152
|
+
styles =
|
|
153
|
+
styles +
|
|
154
|
+
`left: ${right + 5}px!important;
|
|
155
|
+
top: ${
|
|
156
|
+
bottom + scrollTop - tooltipHeight / 2 - height / 2
|
|
157
|
+
}px!important;`;
|
|
158
|
+
break;
|
|
159
|
+
|
|
160
|
+
case "rightBottom":
|
|
161
|
+
styles =
|
|
162
|
+
styles +
|
|
163
|
+
`left: ${right + 5}px!important;
|
|
164
|
+
top: ${bottom + scrollTop - height / 2 - 12}px!important`;
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
styles =
|
|
168
|
+
styles +
|
|
169
|
+
`left: ${left + width / 2 - tooltipWidth / 2}px!important;
|
|
170
|
+
top: ${top - tooltipHeight + scrollTop - 5}px!important`;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return styles;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
getClassList(position) {
|
|
178
|
+
if (!position) {
|
|
179
|
+
return popoverPosition.topCenter;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return popoverPosition[position];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# TooltipDirectives
|
|
2
|
+
Use the v-tooltip directive on any element or component where you would like a tooltip to appear.
|
|
3
|
+
|
|
4
|
+
## Usage
|
|
5
|
+
```html
|
|
6
|
+
<script>
|
|
7
|
+
import { TooltipDirective as Tooltip } from "ib/ui";// change when we deployed on npm
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
directives: { Tooltip },
|
|
11
|
+
};
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<div v-tooltip="'Tooltip Content'">Hover to me</div>
|
|
16
|
+
</template>
|
|
17
|
+
```
|
|
@@ -1,61 +1,33 @@
|
|
|
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
|
-
position: absolute;
|
|
11
|
-
top: 0px;
|
|
12
|
-
left: 0px;
|
|
13
|
-
`;
|
|
14
|
-
tooltipContainer = document.createElement("div");
|
|
15
|
-
tooltipContainer.setAttribute("style", tooltipContainerStyles);
|
|
6
|
+
const createTooltip = (el, binding) => {
|
|
7
|
+
if (multiLineOverflows(el)) {
|
|
16
8
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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;
|
|
9
|
+
const content = {
|
|
10
|
+
title: binding.value.title || '',
|
|
11
|
+
text: typeof(binding.value) === 'object' ? binding.value.text : binding.value,
|
|
12
|
+
}
|
|
31
13
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
bottom: auto!important;
|
|
36
|
-
right: auto!important;
|
|
37
|
-
transform: none!important;
|
|
38
|
-
`;
|
|
14
|
+
tooltip.createTooltip(el, content);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
39
17
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
18
|
+
const destroyTooltip = () => {
|
|
19
|
+
tooltip.destroyTooltip();
|
|
20
|
+
};
|
|
44
21
|
|
|
45
22
|
export const TextOverflowTooltipDirective = {
|
|
46
23
|
mounted(el, binding) {
|
|
47
|
-
el.addEventListener("mouseenter", () =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
});
|
|
24
|
+
el.addEventListener("mouseenter", () => createTooltip(el, binding));
|
|
25
|
+
el.addEventListener("mouseleave", destroyTooltip);
|
|
26
|
+
},
|
|
52
27
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
tooltipContainer = null;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
28
|
+
beforeUnmount(el, binding) {
|
|
29
|
+
tooltip.destroyTooltip();
|
|
30
|
+
el.removeEventListener("mouseenter", () => createTooltip(el, binding));
|
|
31
|
+
el.removeEventListener("mouseleave", destroyTooltip);
|
|
60
32
|
},
|
|
61
33
|
};
|
|
@@ -1,50 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import Tooltip from "./TooltipController";
|
|
2
|
+
|
|
3
|
+
const tooltip = new Tooltip();
|
|
4
|
+
const createTooltip = (el, binding) => {
|
|
5
|
+
if (tooltip.getTooltipContainer()) {
|
|
6
|
+
tooltip.destroyTooltip();
|
|
7
|
+
}
|
|
8
|
+
const position = Object.keys(binding.modifiers)[0] || binding.arg;
|
|
9
|
+
|
|
10
|
+
const content = {
|
|
11
|
+
title: binding.value?.title || '',
|
|
12
|
+
text: typeof(binding.value) === 'object' ? binding.value.text : binding.value,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
tooltip.createTooltip(el, content, position);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const destroyTooltip = (event, el) => {
|
|
19
|
+
const uuid = tooltip.getId();
|
|
20
|
+
|
|
21
|
+
if (el.getAttribute("aria-describedby") !== uuid) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const tooltipContainer = tooltip.getTooltipContainer();
|
|
26
|
+
|
|
27
|
+
const isMouseOverEl = el !== event.target && !el.contains(event.target);
|
|
28
|
+
const isMouseOverTooltip =
|
|
29
|
+
tooltipContainer !== event.target &&
|
|
30
|
+
!tooltipContainer?.contains(event.target);
|
|
31
|
+
|
|
32
|
+
if (isMouseOverEl && isMouseOverTooltip) {
|
|
33
|
+
tooltip.destroyTooltip(el);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const attachTooltipListeners = (el, binding) => {
|
|
38
|
+
el.__tooltip_create = () => createTooltip(el, binding);
|
|
39
|
+
el.__tooltip_destroy = (e) => destroyTooltip(e, el);
|
|
40
|
+
|
|
41
|
+
el.addEventListener("mouseenter", el.__tooltip_create);
|
|
42
|
+
document.addEventListener("mousemove", el.__tooltip_destroy);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const removeTooltipListeners = (el) => {
|
|
46
|
+
tooltip.destroyTooltip(el);
|
|
47
|
+
el.removeEventListener("mouseenter", el.__tooltip_create);
|
|
48
|
+
document.removeEventListener("mousemove", el.__tooltip_destroy);
|
|
49
|
+
};
|
|
3
50
|
|
|
4
51
|
export const TooltipDirective = {
|
|
5
52
|
mounted(el, binding) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
el
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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;
|
|
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
|
-
el.addEventListener("mouseleave", () => {
|
|
46
|
-
tooltipInstance.unmount();
|
|
47
|
-
document.body.removeChild(tooltipContainer);
|
|
48
|
-
});
|
|
53
|
+
attachTooltipListeners(el, binding);
|
|
54
|
+
},
|
|
55
|
+
updated(el, binding) {
|
|
56
|
+
removeTooltipListeners(el);
|
|
57
|
+
attachTooltipListeners(el, binding);
|
|
58
|
+
},
|
|
59
|
+
beforeUnmount(el) {
|
|
60
|
+
removeTooltipListeners(el);
|
|
49
61
|
},
|
|
50
62
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import IbButton from "../../components/Button/Button.vue";
|
|
2
|
+
|
|
3
|
+
import { TooltipDirective } from "./tooltip";
|
|
4
|
+
import readme from "./readme.mdx";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: "directives/tooltip",
|
|
8
|
+
component: TooltipDirective,
|
|
9
|
+
parameters: {
|
|
10
|
+
docs: {
|
|
11
|
+
page: readme,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Template = (args) => ({
|
|
17
|
+
components: { IbButton },
|
|
18
|
+
directives: { tooltip: TooltipDirective },
|
|
19
|
+
setup() {
|
|
20
|
+
return { args };
|
|
21
|
+
},
|
|
22
|
+
template: `
|
|
23
|
+
<div style="display:flex;flex-wrap:wrap;margin-top: 100px;">
|
|
24
|
+
<ib-button v-tooltip="'Tooltip Content Content Content Content Tooltip Content Content Content Content Tooltip Content Content Content Content Tooltip Content Content Content Content Tooltip Content Content Content Content Tooltip Content Content Content Content'" v-bind="args">Tooltip</ib-button>
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
<ib-button v-tooltip="{text: 'antonushkoeliseyantonushkoelisey@gmail.com', title: 'test'}" v-bind="args">Tooltip</ib-button>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
`,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const Default = Template.bind({});
|
|
34
|
+
Default.decorators = [
|
|
35
|
+
() => ({
|
|
36
|
+
template:
|
|
37
|
+
'<div style="display: flex; align-items:center; justify-content: center; width: 600px; height: auto; margin: 0 auto"><story /></div>',
|
|
38
|
+
}),
|
|
39
|
+
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export default function removeEvents(attrList) {
|
|
1
|
+
export default function removeEvents(attrList, eventsToRemove = []) {
|
|
2
2
|
for (let prop in attrList) {
|
|
3
|
-
if (prop.startsWith("on")) {
|
|
3
|
+
if (prop.startsWith("on") && (eventsToRemove.length === 0 || eventsToRemove.includes(prop))) {
|
|
4
4
|
delete attrList[prop];
|
|
5
5
|
}
|
|
6
6
|
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as IbIcon } from "./components/Icon.vue";
|
|
2
2
|
export { default as IbAccordion } from "./components/Accordion/Accordion.vue";
|
|
3
3
|
export { default as IbAlert } from "./components/Alert/Alert.vue";
|
|
4
|
+
export { default as IbAvatar } from "./components/Avatar/Avatar.vue";
|
|
4
5
|
export { default as IbBadge } from "./components/Badge/Badge.vue";
|
|
5
6
|
export { default as IbButton } from "./components/Button/Button.vue";
|
|
6
7
|
export { default as IbButtonGroup } from "./components/ButtonGroup/ButtonGroup.vue";
|
package/src/main.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createApp } from "vue";
|
|
|
2
2
|
import App from "./App.vue";
|
|
3
3
|
import EventEmitter from "./EventEmmiter";
|
|
4
4
|
|
|
5
|
+
window.lang = (key, component, params = {}) => key;
|
|
5
6
|
const app = createApp(App);
|
|
6
7
|
app.config.globalProperties.$globalEvents = new EventEmitter();
|
|
7
8
|
app.config.globalProperties.$emitEvent = function (event, ...args) {
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path, { dirname } from "node:path";
|
|
3
|
+
|
|
4
|
+
const __filename = new URL(import.meta.url).pathname;
|
|
5
|
+
const __dirname = dirname(__filename);
|
|
6
|
+
|
|
7
|
+
const shadowFilePath = path.join(
|
|
8
|
+
__dirname,
|
|
9
|
+
"../assets/scss/variables/shadows.scss"
|
|
10
|
+
);
|
|
11
|
+
const shadowOutputFile = path.join(
|
|
12
|
+
__dirname,
|
|
13
|
+
"../assets/scss/variables/shadows.json"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const colorFilePath = path.join(
|
|
17
|
+
__dirname,
|
|
18
|
+
"../assets/scss/variables/colors.scss"
|
|
19
|
+
);
|
|
20
|
+
const colorOutputFile = path.join(
|
|
21
|
+
__dirname,
|
|
22
|
+
"../assets/scss/variables/colors.json"
|
|
23
|
+
);
|
|
8
24
|
|
|
9
25
|
parseFile(colorFilePath, colorOutputFile);
|
|
10
26
|
parseFile(shadowFilePath, shadowOutputFile);
|