@cloudron/pankow 3.5.2 → 3.5.4

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudron/pankow",
3
3
  "private": false,
4
- "version": "3.5.2",
4
+ "version": "3.5.4",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "types": "types/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "devDependencies": {
25
25
  "@vitejs/plugin-vue": "^6.0.1",
26
26
  "typescript": "^5.9.3",
27
- "vite": "^7.1.9",
27
+ "vite": "^7.1.10",
28
28
  "vue": "^3.5.22"
29
29
  }
30
30
  }
package/tooltip.js CHANGED
@@ -23,10 +23,30 @@ const RIGHT = 4;
23
23
  const padding = 10;
24
24
 
25
25
  const tooltips = {};
26
+ const intervals = {};
26
27
 
27
- function remove(key) {
28
+ function isElementHidden(element) {
29
+ if (!element) return true;
30
+
31
+ var rect = element.getBoundingClientRect();
32
+ var centerX = (rect.left + rect.right) / 2;
33
+ var centerY = (rect.top + rect.bottom) / 2;
34
+
35
+ const hit = document.elementFromPoint(centerX, centerY);
36
+
37
+ return hit !== element && !element.contains(hit);
38
+ }
39
+
40
+ function remove(key, target) {
28
41
  if (tooltips[key]) tooltips[key].remove();
42
+
29
43
  delete tooltips[key];
44
+ clearInterval(intervals[key]);
45
+
46
+ if (target) {
47
+ target.removeAttribute('aria-expanded');
48
+ target.removeAttribute('aria-describedby');
49
+ }
30
50
  }
31
51
 
32
52
  function update(target, value, modifiers, tooltip) {
@@ -50,28 +70,43 @@ function update(target, value, modifiers, tooltip) {
50
70
  }
51
71
 
52
72
  function mounted(el, binding, vnode) {
73
+ const key = vnode.ctx.uid;
74
+
53
75
  el.addEventListener('mouseenter', () => {
54
- if (!binding.value) return remove(vnode.ctx.uid);
76
+ if (!binding.value) return remove(key);
77
+
78
+ const tooltip = document.createElement('div');
79
+ tooltips[key] = tooltip;
55
80
 
56
- tooltips[vnode.ctx.uid] = document.createElement('div');
57
- tooltips[vnode.ctx.uid].classList.add('pankow-tooltip');
58
- window.document.body.appendChild(tooltips[vnode.ctx.uid]);
81
+ tooltip.setAttribute('id', key);
82
+ tooltip.setAttribute('role', 'tooltip');
83
+ tooltip.setAttribute('aria-hidden', 'false');
84
+ tooltip.classList.add('pankow-tooltip');
85
+ window.document.body.appendChild(tooltip);
59
86
 
60
- update(el, binding.value, binding.modifiers, tooltips[vnode.ctx.uid]);
87
+ el.setAttribute('aria-expanded', 'true');
88
+ el.setAttribute('aria-describedby', key);
89
+
90
+ update(el, binding.value, binding.modifiers, tooltip);
91
+
92
+ intervals[key] = setInterval(() => {
93
+ if (isElementHidden(el)) remove(key, el)
94
+ }, 1000);
61
95
  });
62
96
 
63
97
  el.addEventListener('mouseleave', () => {
64
- remove(vnode.ctx.uid);
98
+ remove(key, el);
65
99
  });
100
+
66
101
  }
67
102
 
68
103
  function updated(el, binding, vnode) {
69
- if (!binding.value) return remove(vnode.ctx.uid);
104
+ if (!binding.value) return remove(vnode.ctx.uid, el);
70
105
  update(el, binding.value, binding.modifiers, tooltips[vnode.ctx.uid]);
71
106
  }
72
107
 
73
108
  function beforeUnmount(el, binding, vnode) {
74
- remove(vnode.ctx.uid);
109
+ remove(vnode.ctx.uid, el);
75
110
  }
76
111
 
77
112
  const tooltip = {
package/types/utils.d.ts CHANGED
@@ -12,6 +12,7 @@ declare namespace _default {
12
12
  export { prettyLongDate };
13
13
  export { prettyFileSize };
14
14
  export { prettyEmailAddresses };
15
+ export { prettyDuration };
15
16
  export { sanitize };
16
17
  export { pathJoin };
17
18
  export { download };
@@ -39,6 +40,7 @@ export function formatDate(format: any, value: any): any;
39
40
  export function prettyLongDate(value: any): string;
40
41
  export function prettyFileSize(value: any): string;
41
42
  export function prettyEmailAddresses(addresses: any): any;
43
+ export function prettyDuration(ms: any): any;
42
44
  export function sanitize(path: any): any;
43
45
  export function pathJoin(...args: any[]): any;
44
46
  export function download(entries: any, name: any): void;
package/utils.js CHANGED
@@ -183,6 +183,17 @@ function prettyEmailAddresses(addresses) {
183
183
  return addresses.slice(1, -1);
184
184
  }
185
185
 
186
+ function prettyDuration(ms) {
187
+ const totalSeconds = Math.floor(ms / 1000);
188
+ const days = Math.floor(totalSeconds / 86400);
189
+ const hours = Math.floor((totalSeconds % 86400) / 3600);
190
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
191
+ const seconds = totalSeconds % 60;
192
+
193
+ const df = new Intl.DurationFormat(undefined, { style: 'narrow' });
194
+ return df.format({ days, hours, minutes, seconds });
195
+ }
196
+
186
197
  function sanitize(path) {
187
198
  path = '/' + path;
188
199
  return path.replace(/\/+/g, '/');
@@ -432,6 +443,7 @@ export {
432
443
  prettyLongDate,
433
444
  prettyFileSize,
434
445
  prettyEmailAddresses,
446
+ prettyDuration,
435
447
  sanitize,
436
448
  pathJoin,
437
449
  download,
@@ -460,6 +472,7 @@ export default {
460
472
  prettyLongDate,
461
473
  prettyFileSize,
462
474
  prettyEmailAddresses,
475
+ prettyDuration,
463
476
  sanitize,
464
477
  pathJoin,
465
478
  download,