2024-09-25 20:46:10 +00:00
|
|
|
<script lang="ts">
|
2024-10-15 19:02:11 +00:00
|
|
|
import "tippy.js/animations/shift-away.css"
|
2024-10-14 19:35:08 +00:00
|
|
|
|
2025-02-03 23:40:00 +00:00
|
|
|
import tippy from "tippy.js"
|
2025-02-04 01:21:46 +00:00
|
|
|
import {onMount, mount} from "svelte"
|
2024-09-25 20:46:10 +00:00
|
|
|
|
2025-02-03 23:50:19 +00:00
|
|
|
let {
|
|
|
|
|
component,
|
|
|
|
|
children = undefined,
|
|
|
|
|
props = {},
|
|
|
|
|
params = {},
|
|
|
|
|
popover = $bindable(),
|
|
|
|
|
instance = $bindable(),
|
|
|
|
|
...restProps
|
|
|
|
|
} = $props()
|
|
|
|
|
|
2025-02-03 23:40:00 +00:00
|
|
|
let element: Element
|
2024-09-25 20:46:10 +00:00
|
|
|
|
|
|
|
|
onMount(() => {
|
2025-02-03 23:50:19 +00:00
|
|
|
const target = document.createElement("div")
|
|
|
|
|
|
|
|
|
|
popover = tippy(element, {
|
|
|
|
|
content: target,
|
|
|
|
|
animation: "shift-away",
|
|
|
|
|
appendTo: document.querySelector(".tippy-target")!,
|
|
|
|
|
...params,
|
|
|
|
|
})
|
|
|
|
|
|
2025-05-29 21:30:22 +00:00
|
|
|
instance = mount(component, {target, props})
|
2025-02-03 23:50:19 +00:00
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
popover?.destroy()
|
2024-09-25 20:46:10 +00:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
2025-02-03 23:40:00 +00:00
|
|
|
<div bind:this={element} class={restProps.class}>
|
|
|
|
|
{@render children?.()}
|
2024-10-03 21:32:55 +00:00
|
|
|
</div>
|