diff --git a/src/app/components/ChatMessage.svelte b/src/app/components/ChatMessage.svelte index 2e036a74..e205ef51 100644 --- a/src/app/components/ChatMessage.svelte +++ b/src/app/components/ChatMessage.svelte @@ -1,7 +1,7 @@ @@ -71,20 +64,10 @@ class={cx("group flex items-center justify-end gap-1 px-2", {"flex-row-reverse": !isOwn})}> {#if !isMobile} + props={{event, pubkeys, tippy, replyTo, edit}} + params={{interactive: true, trigger: "manual"}}> diff --git a/src/app/components/TopicMultiSelect.svelte b/src/app/components/TopicMultiSelect.svelte index 54d370cd..6a0156bc 100644 --- a/src/app/components/TopicMultiSelect.svelte +++ b/src/app/components/TopicMultiSelect.svelte @@ -3,6 +3,7 @@ import type {Writable} from "svelte/store" import type {Instance} from "tippy.js" import {remove, reject, spec, uniq} from "@welshman/lib" + import type {Maybe} from "@welshman/lib" import {Topics, createSearch} from "@welshman/app" import {normalizeTopic} from "@lib/util" import Suggestions from "@lib/components/Suggestions.svelte" @@ -10,6 +11,7 @@ import Magnifier from "@assets/icons/magnifier.svg?dataurl" import Icon from "@lib/components/Icon.svelte" import Tippy from "@lib/components/Tippy.svelte" + import type {TippyController} from "@lib/components/Tippy.svelte" import Button from "@lib/components/Button.svelte" import TopicSuggestion from "@app/components/TopicSuggestion.svelte" import {app} from "@app/core" @@ -41,7 +43,7 @@ } term.set("") - popover?.hide() + tippy?.hide() } const removeTopic = (topic: string) => { @@ -49,7 +51,7 @@ } const onKeyDown = (e: KeyboardEvent) => { - if (instance?.onKeyDown(e)) { + if (tippy?.content?.onKeyDown(e)) { e.preventDefault() return } @@ -62,19 +64,17 @@ const onBlur = () => { term.set("") - popover?.hide() + tippy?.hide() } let label: Element | undefined = $state() - let popover: Instance | undefined = $state() - let showPopover: () => void = $state(() => {}) - let instance: any = $state() + let tippy: Maybe = $state() $effect(() => { if ($term.trim()) { - showPopover() + tippy?.show() } else { - popover?.hide() + tippy?.hide() } }) @@ -101,9 +101,7 @@ onblur={onBlur} /> - import {type Instance} from "tippy.js" import type {NativeEmoji} from "emoji-picker-element/shared" import {between, throttle} from "@welshman/lib" + import type {Maybe} from "@welshman/lib" import Button from "@lib/components/Button.svelte" import Tippy from "@lib/components/Tippy.svelte" + import type {TippyController} from "@lib/components/Tippy.svelte" import EmojiPicker from "@lib/components/EmojiPicker.svelte" const {tippyParams = {}, ...props} = $props() + const open = () => tippy?.show() + const onClick = (emoji: NativeEmoji) => { props.onEmoji(emoji) - popover?.hide() - } - - const onShow = () => { - visible = true - } - - const onHidden = () => { - visible = false + tippy?.hide() } const onMouseMove = throttle(300, ({clientX, clientY}: MouseEvent) => { - if (popover) { - const {x, y, width, height} = popover.popper.getBoundingClientRect() + const rect = tippy?.rect() + + if (rect) { + const {x, y, width, height} = rect if (!between([x, x + width], clientX) || !between([y - 100, y + height + 100], clientY)) { - popover.hide() + tippy!.hide() } } }) - let popover: Instance | undefined = $state() - let open: () => void = $state(() => {}) - let visible = $state(false) + let tippy: Maybe = $state() - + diff --git a/src/lib/components/IconPickerButton.svelte b/src/lib/components/IconPickerButton.svelte index f3dcf7f5..0764151c 100644 --- a/src/lib/components/IconPickerButton.svelte +++ b/src/lib/components/IconPickerButton.svelte @@ -1,9 +1,10 @@ diff --git a/src/lib/components/MenuButton.svelte b/src/lib/components/MenuButton.svelte index aa944e2a..2832d71b 100644 --- a/src/lib/components/MenuButton.svelte +++ b/src/lib/components/MenuButton.svelte @@ -1,9 +1,10 @@