@cfasim-ui/docs 0.4.1 → 0.4.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,49 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, useTemplateRef } from "vue";
|
|
3
|
+
|
|
4
|
+
export interface ChoroplethTooltipData {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
value?: number | string;
|
|
8
|
+
feature: unknown;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
defineSlots<{
|
|
12
|
+
default?(props: ChoroplethTooltipData): unknown;
|
|
13
|
+
}>();
|
|
14
|
+
|
|
15
|
+
// Local reactive state. Held inside the child so the parent's render scope
|
|
16
|
+
// never subscribes to it — hover updates re-render only this small tree,
|
|
17
|
+
// not the parent's 3,000+ paths.
|
|
18
|
+
const data = ref<ChoroplethTooltipData | null>(null);
|
|
19
|
+
const rootRef = useTemplateRef<HTMLDivElement>("root");
|
|
20
|
+
|
|
21
|
+
defineExpose({
|
|
22
|
+
setData(next: ChoroplethTooltipData | null) {
|
|
23
|
+
data.value = next;
|
|
24
|
+
},
|
|
25
|
+
getEl(): HTMLDivElement | null {
|
|
26
|
+
return rootRef.value;
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<Teleport to="body">
|
|
33
|
+
<div
|
|
34
|
+
ref="root"
|
|
35
|
+
class="chart-tooltip-content"
|
|
36
|
+
style="
|
|
37
|
+
position: fixed;
|
|
38
|
+
left: 0;
|
|
39
|
+
top: 0;
|
|
40
|
+
visibility: hidden;
|
|
41
|
+
will-change: transform;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
transform: translateY(-50%);
|
|
44
|
+
"
|
|
45
|
+
>
|
|
46
|
+
<slot v-if="data" v-bind="data" />
|
|
47
|
+
</div>
|
|
48
|
+
</Teleport>
|
|
49
|
+
</template>
|
package/index.json
CHANGED