@veritree/ui 0.19.2 → 0.20.0-0
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/index.js +64 -68
- package/mixins/floating-ui-content.js +81 -0
- package/mixins/floating-ui-item.js +266 -0
- package/mixins/floating-ui.js +67 -0
- package/mixins/form-control-icon.js +53 -0
- package/mixins/form-control.js +71 -0
- package/nuxt.js +30 -23
- package/package.json +9 -4
- package/src/components/Alert/VTAlert.vue +55 -14
- package/src/components/Avatar/VTAvatar.vue +32 -29
- package/src/components/Button/VTButton.vue +9 -6
- package/src/components/Checkbox/VTCheckbox.vue +134 -0
- package/src/components/Checkbox/VTCheckboxLabel.vue +3 -0
- package/src/components/Checkbox/VTCheckboxText.vue +20 -0
- package/src/components/Dialog/VTDialog.vue +22 -32
- package/src/components/Dialog/VTDialogClose.vue +19 -25
- package/src/components/Dialog/VTDialogContent.vue +24 -19
- package/src/components/Dialog/VTDialogFooter.vue +11 -16
- package/src/components/Dialog/VTDialogHeader.vue +16 -18
- package/src/components/Dialog/VTDialogMain.vue +11 -18
- package/src/components/Dialog/VTDialogOverlay.vue +14 -18
- package/src/components/Dialog/VTDialogTitle.vue +10 -7
- package/src/components/Disclosure/VTDisclosureContent.vue +1 -1
- package/src/components/Disclosure/VTDisclosureDetails.vue +1 -1
- package/src/components/Disclosure/VTDisclosureHeader.vue +2 -2
- package/src/components/Disclosure/VTDisclosureIcon.vue +1 -1
- package/src/components/Drawer/VTDrawer.vue +14 -16
- package/src/components/Drawer/VTDrawerClose.vue +9 -9
- package/src/components/Drawer/VTDrawerContent.vue +8 -8
- package/src/components/Drawer/VTDrawerFooter.vue +3 -3
- package/src/components/Drawer/VTDrawerHeader.vue +4 -4
- package/src/components/Drawer/VTDrawerMain.vue +5 -5
- package/src/components/Drawer/VTDrawerOverlay.vue +6 -6
- package/src/components/Drawer/VTDrawerTitle.vue +5 -5
- package/src/components/DropdownMenu/VTDropdownMenu.vue +45 -28
- package/src/components/DropdownMenu/VTDropdownMenuContent.vue +29 -64
- package/src/components/DropdownMenu/VTDropdownMenuDivider.vue +8 -14
- package/src/components/DropdownMenu/VTDropdownMenuItem.vue +11 -124
- package/src/components/DropdownMenu/VTDropdownMenuLabel.vue +3 -12
- package/src/components/DropdownMenu/VTDropdownMenuTrigger.vue +91 -121
- package/src/components/Form/VTFormFeedback.vue +39 -22
- package/src/components/Form/VTFormGroup.vue +5 -7
- package/src/components/Form/VTFormLabel.vue +22 -0
- package/src/components/Form/VTFormRow.vue +5 -0
- package/src/components/Form/VTInput.vue +40 -0
- package/src/components/Form/VTInputIcon.vue +35 -0
- package/src/components/Form/VTInputPassword.vue +55 -0
- package/src/components/Form/VTTextarea.vue +22 -0
- package/src/components/Listbox/VTListbox.vue +122 -50
- package/src/components/Listbox/VTListboxContent.vue +20 -116
- package/src/components/Listbox/VTListboxItem.vue +115 -166
- package/src/components/Listbox/VTListboxLabel.vue +3 -14
- package/src/components/Listbox/VTListboxList.vue +10 -40
- package/src/components/Listbox/VTListboxSearch.vue +76 -68
- package/src/components/Listbox/VTListboxTrigger.vue +75 -86
- package/src/components/Popover/VTPopover.vue +42 -29
- package/src/components/Popover/VTPopoverContent.vue +24 -59
- package/src/components/Popover/VTPopoverDivider.vue +4 -11
- package/src/components/Popover/VTPopoverItem.vue +21 -14
- package/src/components/Popover/VTPopoverTrigger.vue +126 -21
- package/src/components/ProgressBar/VTProgressBar.vue +21 -3
- package/src/components/Skeleton/VTSkeleton.vue +11 -0
- package/src/components/Skeleton/VTSkeletonItem.vue +9 -0
- package/src/components/Tabs/VTTab.vue +4 -3
- package/src/components/Tabs/VTTabGroup.vue +9 -7
- package/src/components/Tabs/VTTabPanel.vue +4 -5
- package/src/components/Tooltip/VTTooltip.vue +65 -0
- package/src/components/Tooltip/VTTooltipContent.vue +59 -0
- package/src/components/Tooltip/VTTooltipTrigger.vue +98 -0
- package/src/components/Transitions/FadeInOut.vue +2 -2
- package/src/components/Utils/FloatingUi.vue +93 -0
- package/package-lock.json +0 -13
- package/src/components/Input/VTInput.vue +0 -82
- package/src/components/Input/VTInputDate.vue +0 -36
- package/src/components/Input/VTInputFile.vue +0 -60
- package/src/components/Input/VTInputUpload.vue +0 -54
- package/src/components/Modal/VTModal.vue +0 -69
- package/src/utils/genId.js +0 -13
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div @keydown.esc.prevent="
|
|
2
|
+
<div :id="id" @keydown.esc.prevent="onKeyEsc">
|
|
3
3
|
<slot></slot>
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
@@ -8,43 +8,148 @@
|
|
|
8
8
|
export default {
|
|
9
9
|
name: 'VTPopoverTrigger',
|
|
10
10
|
|
|
11
|
-
inject: ['
|
|
11
|
+
inject: ['apiPopover'],
|
|
12
|
+
|
|
13
|
+
data() {
|
|
14
|
+
return {
|
|
15
|
+
expanded: false,
|
|
16
|
+
hasPopup: false,
|
|
17
|
+
controls: null,
|
|
18
|
+
trigger: null,
|
|
19
|
+
};
|
|
20
|
+
},
|
|
12
21
|
|
|
13
22
|
computed: {
|
|
14
|
-
|
|
15
|
-
return this.
|
|
23
|
+
id() {
|
|
24
|
+
return `popover-trigger-${this.apiPopover().id}`;
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
componentContent() {
|
|
28
|
+
return this.apiPopover().componentContent;
|
|
16
29
|
},
|
|
17
30
|
},
|
|
18
31
|
|
|
19
32
|
mounted() {
|
|
20
|
-
|
|
21
|
-
|
|
33
|
+
const trigger = {
|
|
34
|
+
id: this.id,
|
|
35
|
+
el: this.$el,
|
|
36
|
+
cancel: this.cancel,
|
|
37
|
+
focus: this.focus,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
this.apiPopover().registerTrigger(trigger);
|
|
41
|
+
|
|
42
|
+
this.setTrigger();
|
|
43
|
+
this.addTriggerEvents();
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
destroyed() {
|
|
47
|
+
this.trigger.removeEventListener('click', this.onClick);
|
|
22
48
|
},
|
|
23
49
|
|
|
24
50
|
methods: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
51
|
+
setTrigger() {
|
|
52
|
+
this.trigger = this.$el.querySelector(':first-child');
|
|
53
|
+
},
|
|
28
54
|
|
|
29
|
-
|
|
30
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Add event listener to slot element
|
|
57
|
+
*
|
|
58
|
+
* The click event has to be added to the slot child element
|
|
59
|
+
* since we are not setting the onclick on the component
|
|
60
|
+
* itself.
|
|
61
|
+
*
|
|
62
|
+
* Slot must have only one child element. It avoids
|
|
63
|
+
* errors related to adding the event listener.
|
|
64
|
+
*/
|
|
65
|
+
addTriggerEvents() {
|
|
66
|
+
this.trigger.addEventListener('click', (e) => {
|
|
67
|
+
this.onClick(e);
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
init(e) {
|
|
72
|
+
if (!this.componentContent) {
|
|
31
73
|
return;
|
|
32
74
|
}
|
|
33
75
|
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
}
|
|
76
|
+
if (this.expanded) {
|
|
77
|
+
this.cancel();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
this.expanded = true;
|
|
82
|
+
|
|
83
|
+
// delay stop propagation to close other visible
|
|
84
|
+
// dropdowns and delay click event to control
|
|
85
|
+
// this dropdown visibility
|
|
86
|
+
setTimeout(() => e.stopImmediatePropagation(), 50);
|
|
87
|
+
setTimeout(() => this.showComponentContent(), 100);
|
|
38
88
|
},
|
|
39
89
|
|
|
40
|
-
|
|
41
|
-
if (this.
|
|
42
|
-
|
|
90
|
+
cancel() {
|
|
91
|
+
if (!this.componentContent) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
this.expanded = false;
|
|
96
|
+
|
|
97
|
+
this.hideComponentContent();
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
focus() {
|
|
101
|
+
if (this.trigger) this.trigger.focus();
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
showComponentContent() {
|
|
105
|
+
this.componentContent.show();
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
hideComponentContent() {
|
|
109
|
+
this.componentContent.hide();
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
toggleAriaHasPopup() {
|
|
113
|
+
if (this.expanded) {
|
|
114
|
+
this.hasPopup = this.componentContent !== null;
|
|
115
|
+
this.controls = this.hasPopup ? this.componentContent.id : null;
|
|
116
|
+
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.hasPopup = null;
|
|
121
|
+
this.controls = null;
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
onClick(e) {
|
|
125
|
+
this.init(e);
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
onKeyDownOrUp(e) {
|
|
129
|
+
if (!this.expanded) {
|
|
130
|
+
this.$el.click(e);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const keyCode = e.code;
|
|
134
|
+
const listItemPosition =
|
|
135
|
+
keyCode === 'ArrowDown'
|
|
136
|
+
? 'firstMenuItem'
|
|
137
|
+
: keyCode === 'ArrowUp'
|
|
138
|
+
? 'lastMenuItem'
|
|
139
|
+
: null;
|
|
140
|
+
|
|
141
|
+
// settimeout here is delaying the focusing the element
|
|
142
|
+
// since it is not rendered yet. All items will only
|
|
143
|
+
// be available when the content is fully visible.
|
|
144
|
+
this.$nextTick(() => {
|
|
145
|
+
setTimeout(() => this[listItemPosition].focus(), 100);
|
|
146
|
+
});
|
|
43
147
|
},
|
|
44
148
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this.
|
|
149
|
+
// change it to a better name or move the methods inside to another function
|
|
150
|
+
onKeyEsc() {
|
|
151
|
+
this.cancel();
|
|
152
|
+
this.focus();
|
|
48
153
|
},
|
|
49
154
|
},
|
|
50
155
|
};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
]"
|
|
8
8
|
role="progressbar"
|
|
9
9
|
aria-valuemin="0"
|
|
10
|
-
aria-valuemax="
|
|
10
|
+
:aria-valuemax="max"
|
|
11
11
|
:aria-valuenow="value"
|
|
12
12
|
:aria-label="label"
|
|
13
13
|
>
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
:class="[
|
|
16
16
|
headless
|
|
17
17
|
? 'progress-bar__indicator'
|
|
18
|
-
: 'absolute left-0 h-full
|
|
18
|
+
: 'bg-secondary-200 absolute left-0 h-full transition-all',
|
|
19
19
|
]"
|
|
20
|
-
:style="{ width: `${
|
|
20
|
+
:style="{ width: `${percentageComputed}%` }"
|
|
21
21
|
></div>
|
|
22
22
|
</div>
|
|
23
23
|
</template>
|
|
@@ -37,6 +37,24 @@ export default {
|
|
|
37
37
|
type: [String, Number],
|
|
38
38
|
default: 0,
|
|
39
39
|
},
|
|
40
|
+
max: {
|
|
41
|
+
type: [String, Number],
|
|
42
|
+
default: 100,
|
|
43
|
+
},
|
|
44
|
+
percentage: {
|
|
45
|
+
type: [String, Number],
|
|
46
|
+
default: null,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
computed: {
|
|
51
|
+
percentageComputed() {
|
|
52
|
+
if (typeof this.percentage !== 'undefined' && this.percentage !== null) {
|
|
53
|
+
return this.percentage;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (this.value / this.max) * 100;
|
|
57
|
+
},
|
|
40
58
|
},
|
|
41
59
|
};
|
|
42
60
|
</script>
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
]"
|
|
19
19
|
role="tab"
|
|
20
20
|
type="button"
|
|
21
|
-
@click.stop="onClick"
|
|
21
|
+
@click.prevent.stop="onClick"
|
|
22
22
|
@keydown="onKeyDown"
|
|
23
23
|
@blur="onBlur"
|
|
24
24
|
>
|
|
25
|
-
<slot></slot>
|
|
25
|
+
<slot :selected="selected"></slot>
|
|
26
26
|
</button>
|
|
27
27
|
</template>
|
|
28
28
|
|
|
@@ -60,7 +60,7 @@ export default {
|
|
|
60
60
|
this.api.registerTab(this);
|
|
61
61
|
},
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
beforeUnmount() {
|
|
64
64
|
this.api.unregisterTab(this.index);
|
|
65
65
|
},
|
|
66
66
|
|
|
@@ -106,6 +106,7 @@ export default {
|
|
|
106
106
|
onClick() {
|
|
107
107
|
this.api.selectTab(this.index);
|
|
108
108
|
this.$emit('change');
|
|
109
|
+
this.$emit('click');
|
|
109
110
|
},
|
|
110
111
|
|
|
111
112
|
onKeyDown(event) {
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<style scoped>
|
|
8
|
-
.TabGroup.vertical{
|
|
8
|
+
.TabGroup.vertical {
|
|
9
9
|
display: flex;
|
|
10
10
|
}
|
|
11
|
-
.TabGroup.vertical .TabList{
|
|
11
|
+
.TabGroup.vertical .TabList {
|
|
12
12
|
display: flex;
|
|
13
13
|
flex-direction: column;
|
|
14
14
|
}
|
|
@@ -17,15 +17,17 @@
|
|
|
17
17
|
<script>
|
|
18
18
|
export default {
|
|
19
19
|
name: 'VTTabGroup',
|
|
20
|
+
|
|
20
21
|
props: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
vertical: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false,
|
|
25
|
+
},
|
|
25
26
|
},
|
|
27
|
+
|
|
26
28
|
provide() {
|
|
27
29
|
return {
|
|
28
|
-
|
|
30
|
+
apiTabs: () => {
|
|
29
31
|
const registerTab = (tab) => {
|
|
30
32
|
_register(this.tabs, tab);
|
|
31
33
|
if (tab.index === 0) tab.select();
|
|
@@ -14,11 +14,10 @@
|
|
|
14
14
|
export default {
|
|
15
15
|
name: 'VTTabPanel',
|
|
16
16
|
|
|
17
|
-
inject: ['
|
|
17
|
+
inject: ['apiTabs'],
|
|
18
18
|
|
|
19
19
|
data() {
|
|
20
20
|
return {
|
|
21
|
-
api: this.api(),
|
|
22
21
|
index: null,
|
|
23
22
|
visible: false,
|
|
24
23
|
};
|
|
@@ -31,11 +30,11 @@ export default {
|
|
|
31
30
|
},
|
|
32
31
|
|
|
33
32
|
mounted() {
|
|
34
|
-
this.
|
|
33
|
+
this.apiTabs().registerTabPanel(this);
|
|
35
34
|
},
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
this.
|
|
36
|
+
beforeUnmount() {
|
|
37
|
+
this.apiTabs().unregisterTabPanel(this.id);
|
|
39
38
|
},
|
|
40
39
|
|
|
41
40
|
methods: {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<slot />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { floatingUiMixin } from '../../../mixins/floating-ui';
|
|
9
|
+
import { genId } from '../../utils/ids';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
name: 'VTTooltip',
|
|
13
|
+
|
|
14
|
+
mixins: [floatingUiMixin],
|
|
15
|
+
|
|
16
|
+
props: {
|
|
17
|
+
delayDuration: {
|
|
18
|
+
type: [String, Number],
|
|
19
|
+
default: 500,
|
|
20
|
+
},
|
|
21
|
+
placement: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: 'bottom',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
data() {
|
|
28
|
+
return {
|
|
29
|
+
floatingUiMinWidth: 0,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
provide() {
|
|
34
|
+
return {
|
|
35
|
+
apiTooltip: () => {
|
|
36
|
+
const registerTrigger = (trigger) => {
|
|
37
|
+
if (!trigger) return;
|
|
38
|
+
this.componentTrigger = trigger;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const registerContent = (content) => {
|
|
42
|
+
if (!content) return;
|
|
43
|
+
this.componentContent = content;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
id: this.componentId,
|
|
48
|
+
component: this.component,
|
|
49
|
+
componentTrigger: this.componentTrigger,
|
|
50
|
+
componentContent: this.componentContent,
|
|
51
|
+
delayDuration: this.delayDuration,
|
|
52
|
+
registerTrigger,
|
|
53
|
+
registerContent,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
data() {
|
|
60
|
+
return {
|
|
61
|
+
componentId: genId(),
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FloatingUi
|
|
3
|
+
:id="id"
|
|
4
|
+
:visible="visible"
|
|
5
|
+
:headless="headless"
|
|
6
|
+
component="tooltip"
|
|
7
|
+
>
|
|
8
|
+
<slot></slot>
|
|
9
|
+
</FloatingUi>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
import { floatingUiContentMixin } from '../../../mixins/floating-ui-content';
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
name: 'VTTooltipContent',
|
|
17
|
+
|
|
18
|
+
inheritAttrs: false,
|
|
19
|
+
|
|
20
|
+
mixins: [floatingUiContentMixin],
|
|
21
|
+
|
|
22
|
+
inject: ['apiTooltip'],
|
|
23
|
+
|
|
24
|
+
data() {
|
|
25
|
+
return {
|
|
26
|
+
visible: false,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
computed: {
|
|
31
|
+
id() {
|
|
32
|
+
return `tooltip-content-${this.apiTooltip().id}`;
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
component() {
|
|
36
|
+
return this.apiTooltip().component;
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
componentTrigger() {
|
|
40
|
+
return this.apiTooltip().componentTrigger;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
ariaLabelledby() {
|
|
44
|
+
if (!this.componentTrigger) return null;
|
|
45
|
+
return this.visible ? this.componentTrigger.id : null;
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
mounted() {
|
|
50
|
+
const content = {
|
|
51
|
+
id: this.id,
|
|
52
|
+
hide: this.hide,
|
|
53
|
+
show: this.show,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
this.apiTooltip().registerContent(content);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
</script>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="id"
|
|
4
|
+
:aria-describedby="ariaDescribedBy"
|
|
5
|
+
@mouseenter="onMouseenter"
|
|
6
|
+
@mouseleave="onmouseout"
|
|
7
|
+
>
|
|
8
|
+
<slot />
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
let tooltipTriggerTimeout = null;
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
name: 'VTTooltipTrigger',
|
|
17
|
+
|
|
18
|
+
inject: ['apiTooltip'],
|
|
19
|
+
|
|
20
|
+
data() {
|
|
21
|
+
return {
|
|
22
|
+
expanded: false,
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
computed: {
|
|
27
|
+
id() {
|
|
28
|
+
return `tooltip-trigger-${this.apiTooltip().id}`;
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
componentContent() {
|
|
32
|
+
return this.apiTooltip().componentContent;
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
ariaDescribedBy() {
|
|
36
|
+
if (!this.componentContent) return null;
|
|
37
|
+
return this.expanded ? this.componentContent.id : null;
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
mounted() {
|
|
42
|
+
const trigger = {
|
|
43
|
+
cancel: this.cancel,
|
|
44
|
+
id: this.id,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
this.apiTooltip().registerTrigger(trigger);
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
methods: {
|
|
51
|
+
onMouseenter(e) {
|
|
52
|
+
tooltipTriggerTimeout = setTimeout(() => {
|
|
53
|
+
this.init(e);
|
|
54
|
+
}, this.apiTooltip().delayDuration);
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
onmouseout() {
|
|
58
|
+
clearTimeout(tooltipTriggerTimeout);
|
|
59
|
+
this.cancel();
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
init(e) {
|
|
63
|
+
if (!this.componentContent) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (this.expanded) {
|
|
68
|
+
this.cancel();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.expanded = true;
|
|
73
|
+
|
|
74
|
+
// delay stop propagation to close other visible
|
|
75
|
+
// dropdowns and delay click event to control
|
|
76
|
+
// this dropdown visibility
|
|
77
|
+
this.showComponentContent();
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
cancel() {
|
|
81
|
+
if (!this.componentContent) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this.expanded = false;
|
|
86
|
+
this.hideComponentContent();
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
showComponentContent() {
|
|
90
|
+
this.componentContent.show();
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
hideComponentContent() {
|
|
94
|
+
this.componentContent.hide();
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
</script>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<transition
|
|
3
3
|
enter-active-class="duration-300 ease-out"
|
|
4
|
-
enter-class="transform opacity-0"
|
|
4
|
+
enter-from-class="transform opacity-0"
|
|
5
5
|
enter-to-class="opacity-100"
|
|
6
6
|
leave-active-class="duration-300 ease-in"
|
|
7
|
-
leave-class="opacity-100"
|
|
7
|
+
leave-from-class="opacity-100"
|
|
8
8
|
leave-to-class="transform opacity-0"
|
|
9
9
|
@after-enter="afterEnter"
|
|
10
10
|
@after-leave="afterLeave"
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Teleport to="body">
|
|
3
|
+
<transition
|
|
4
|
+
enter-active-class="duration-200 ease-out"
|
|
5
|
+
:enter-from-class="transitionEnterClass"
|
|
6
|
+
:enter-to-class="transitionEnterToClass"
|
|
7
|
+
leave-active-class="duration-200 ease-in"
|
|
8
|
+
:leave-from-class="transitionLeaveClass"
|
|
9
|
+
:leave-to-class="transitionLeaveToClass"
|
|
10
|
+
@after-leave="hidden"
|
|
11
|
+
@after-enter="shown"
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
v-if="visible"
|
|
15
|
+
:class="[
|
|
16
|
+
headless
|
|
17
|
+
? `${this.component}-content`
|
|
18
|
+
: `absolute z-50 grid overflow-hidden rounded-md shadow-md ${this.classes} ${this.portalClass}`,
|
|
19
|
+
]"
|
|
20
|
+
v-bind="$attrs"
|
|
21
|
+
>
|
|
22
|
+
<slot />
|
|
23
|
+
</div>
|
|
24
|
+
</transition>
|
|
25
|
+
</Teleport>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
export default {
|
|
30
|
+
inheritAttrs: false,
|
|
31
|
+
|
|
32
|
+
props: {
|
|
33
|
+
component: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: null,
|
|
36
|
+
},
|
|
37
|
+
headless: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false,
|
|
40
|
+
},
|
|
41
|
+
visible: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
45
|
+
ariaActivedescendant: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: null,
|
|
48
|
+
},
|
|
49
|
+
portalClass: {
|
|
50
|
+
type: [String, Function],
|
|
51
|
+
default: null,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
computed: {
|
|
56
|
+
isTooltip() {
|
|
57
|
+
return this.component === 'tooltip';
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
classes() {
|
|
61
|
+
return this.isTooltip
|
|
62
|
+
? 'bg-gray-800 text-sm text-white py-1 px-2'
|
|
63
|
+
: 'bg-white py-2 px-3';
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
transitionEnterClass() {
|
|
67
|
+
return this.isTooltip ? 'opacity-0' : 'translate-y-[15px] opacity-0';
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
transitionEnterToClass() {
|
|
71
|
+
return this.isTooltip ? 'opacity-100' : 'translate-y-0 opacity-100';
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
transitionLeaveClass() {
|
|
75
|
+
return this.transitionEnterToClass;
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
transitionLeaveToClass() {
|
|
79
|
+
return this.transitionEnterClass;
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
methods: {
|
|
84
|
+
shown() {
|
|
85
|
+
this.$emit('shown');
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
hidden() {
|
|
89
|
+
this.$emit('hidden');
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
</script>
|
package/package-lock.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@veritree/ui",
|
|
3
|
-
"version": "0.1.9",
|
|
4
|
-
"lockfileVersion": 1,
|
|
5
|
-
"requires": true,
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"@veritree/icons": {
|
|
8
|
-
"version": "0.12.0",
|
|
9
|
-
"resolved": "https://registry.npmjs.org/@veritree/icons/-/icons-0.12.0.tgz",
|
|
10
|
-
"integrity": "sha512-vunUKzvS9neslSf3R3y6RYQrcfRpxmp8PnhWWe2peYiyElLIJcb7zAsfCZ+I0Fg5PQ6GZG6StqWy0WF7MJ7VOg=="
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|