@cloudron/pankow 3.5.2 → 3.5.3

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.
@@ -0,0 +1,40 @@
1
+ <script setup>
2
+
3
+ import { computed } from 'vue';
4
+
5
+ const props = defineProps({
6
+ values: Array,
7
+ });
8
+
9
+ // const normalizedValue = computed(() => {
10
+ // if (props.value < 0) return 0;
11
+ // if (props.value > 100) return 100;
12
+ // return props.value;
13
+ // });
14
+
15
+ // we want 100 to be the circumverence so we can neatly use percentage: radius = 100 / ( 3,14159 * 2 ) = 15,9155
16
+ const radius = 15.9155;
17
+ const stroke = 10;
18
+
19
+ function calculateViewbox() {
20
+ return `0 0 ${radius*2+stroke} ${radius*2+stroke}`;
21
+ }
22
+
23
+ function calculateArcPath() {
24
+ return `M${radius+stroke/2} ${stroke/2} a ${radius} ${radius} 0 0 1 0 ${radius*2} a ${radius} ${radius} 0 0 1 0 -${radius*2}`;
25
+ }
26
+
27
+ </script>
28
+
29
+ <template>
30
+ <div class="pankow-circle-chart">
31
+ <svg :viewBox="calculateViewbox()" xmlns="http://www.w3.org/2000/svg">
32
+ <path :d="calculateArcPath()" fill="none" stroke="red" :stroke-width="stroke" stroke-dasharray="75, 100" @click.stop="onClick('red')" />
33
+ <path :d="calculateArcPath()" fill="none" stroke="green" :stroke-width="stroke" stroke-dasharray="30, 100" @click.stop="onClick('green') "/>
34
+ </svg>
35
+ </div>
36
+ </template>
37
+
38
+ <style>
39
+
40
+ </style>
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.3",
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 = {