quasar-ui-danx 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@ import { RenderVnode } from '../Utility';
18
18
  defineProps({
19
19
  activePanel: {
20
20
  type: String,
21
- required: true
21
+ default: null
22
22
  },
23
23
  panels: {
24
24
  type: Array,
@@ -0,0 +1,66 @@
1
+ <template>
2
+ <QTooltip
3
+ class="interactive-tooltip"
4
+ ref="tooltipBox"
5
+ v-model="show"
6
+ no-parent-event
7
+ @mouseenter="onEnterTooltip"
8
+ @mouseleave="onLeaveTooltip"
9
+ :transition-duration="200"
10
+ >
11
+ <slot>{{ tooltip }}</slot>
12
+ </QTooltip>
13
+ </template>
14
+ <script setup>
15
+ import { onMounted, ref } from 'vue';
16
+
17
+ defineProps({ tooltip: { type: String, default: '' } });
18
+ const show = ref(false);
19
+ const tooltipBox = ref(null);
20
+ const isHovering = ref(false);
21
+ const isHoveringParent = ref(false);
22
+ let timeout = null;
23
+ onMounted(() => {
24
+ tooltipBox.value.$el.parentNode.addEventListener('mouseover', onEnterParent);
25
+ tooltipBox.value.$el.parentNode.addEventListener('mouseleave', onLeaveParent);
26
+ });
27
+ function onEnterParent() {
28
+ show.value = true;
29
+ isHoveringParent.value = true;
30
+ if (timeout) clearTimeout(timeout);
31
+ }
32
+ function onLeaveParent() {
33
+ isHoveringParent.value = false;
34
+ if (show.value) delayClose();
35
+ }
36
+ function onEnterTooltip() {
37
+ isHovering.value = true;
38
+ show.value = true;
39
+ if (timeout) clearTimeout(timeout);
40
+ }
41
+ function onLeaveTooltip() {
42
+ isHovering.value = false;
43
+ if (show.value) delayClose();
44
+ }
45
+ function delayClose() {
46
+ if (timeout) clearTimeout(timeout);
47
+ timeout = setTimeout(() => {
48
+ if (isHovering.value || isHoveringParent.value) {
49
+ delayClose();
50
+ } else {
51
+ show.value = false;
52
+ }
53
+ }, 200);
54
+ }
55
+
56
+ </script>
57
+ <style lang="scss">
58
+ body .q-tooltip {
59
+ &.interactive-tooltip {
60
+ pointer-events: auto !important;
61
+ background: white;
62
+ color: inherit;
63
+ box-shadow: 0 0 10px 3px rgba(0, 0, 0, 0.2);
64
+ }
65
+ }
66
+ </style>
@@ -1 +1,2 @@
1
1
  export { default as PopoverMenu } from "./PopoverMenu.vue";
2
+ export { default as InteractiveTooltip } from "./InteractiveTooltip.vue";