@policystudio/policy-studio-ui-vue 1.2.0-access.90 → 1.2.0-access.92

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": "@policystudio/policy-studio-ui-vue",
3
- "version": "1.2.0-access.90",
3
+ "version": "1.2.0-access.92",
4
4
  "description": "Policy Studio UI",
5
5
  "author": "Policy Studio Team",
6
6
  "scripts": {
@@ -52,7 +52,7 @@
52
52
  "webpack": "^5.89.0"
53
53
  },
54
54
  "engines": {
55
- "node": "20.11.0"
55
+ "node": ">=20.11.0"
56
56
  },
57
57
  "keywords": [
58
58
  "vue",
@@ -6,6 +6,7 @@
6
6
  :position="position"
7
7
  :ignore-dialog="ignoreDialog"
8
8
  :custom-position="customPosition"
9
+ :delay="delay"
9
10
  >
10
11
  <template #trigger>
11
12
  <slot name="trigger" />
@@ -52,5 +53,12 @@ defineProps({
52
53
  type: String,
53
54
  default: '',
54
55
  },
56
+ /**
57
+ * It delays showing the tooltip on hover, in milliseconds.
58
+ */
59
+ delay: {
60
+ type: Number,
61
+ default: 0,
62
+ },
55
63
  })
56
64
  </script>
@@ -87,6 +87,13 @@ const props = defineProps({
87
87
  type: String,
88
88
  default: '',
89
89
  },
90
+ /**
91
+ * It delays showing the tooltip on hover, in milliseconds.
92
+ */
93
+ delay: {
94
+ type: Number,
95
+ default: 0,
96
+ },
90
97
  })
91
98
 
92
99
  const emit = defineEmits(['show', 'close'])
@@ -95,6 +102,7 @@ const show = ref(false)
95
102
  const PsTooltip = ref(null)
96
103
  const PsTooltipTrigger = ref(null)
97
104
  const PsTooltipDialog = ref(null)
105
+ let openTimer = null
98
106
 
99
107
  const getComponentClass = computed(() => {
100
108
  return `layout-${props.layout}`
@@ -106,12 +114,24 @@ onMounted(() => {
106
114
  })
107
115
 
108
116
  onBeforeUnmount(() => {
117
+ if (openTimer) clearTimeout(openTimer)
109
118
  document.removeEventListener('resize', updatePosition)
110
119
  document.removeEventListener('keydown', handleKeyDown)
111
120
  })
112
121
 
113
122
  const open = () => {
114
- if (show.value || props.ignoreDialog) return
123
+ if (show.value || props.ignoreDialog || openTimer) return
124
+ if (props.delay > 0) {
125
+ openTimer = setTimeout(() => {
126
+ openTimer = null
127
+ showTooltip()
128
+ }, props.delay)
129
+ } else {
130
+ showTooltip()
131
+ }
132
+ }
133
+
134
+ const showTooltip = () => {
115
135
  emit('show')
116
136
  show.value = true
117
137
 
@@ -126,6 +146,10 @@ const open = () => {
126
146
  }
127
147
 
128
148
  const close = () => {
149
+ if (openTimer) {
150
+ clearTimeout(openTimer)
151
+ openTimer = null
152
+ }
129
153
  const dialog = PsTooltipDialog.value
130
154
  if (show.value && dialog) {
131
155
  emit('close')