mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-10 08:07:03 +00:00
* Remove $$props.field usage * Rename slots to ensure no hyphen * _props * _trigger * OnSelectedIteration type correct capitalization * rename _content * Remove afterUpdate * Migrate everything to svelte 5 * array bind * Fix popover * type never * nit fixes * Fixed many trivial errors * onClick * Fix errors * use let: * nit typing * fix: wrap state_referenced_locally vars with untrack() Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add untrack import * Fix all syntax errors due to untrack migration * Fix undefined errors * Fix more undefined errors * untrack(() => initialOpen) * svelte-ignore * Fix state_descriptors_fixed error in Chart.svelte Use $state.snapshot() to pass plain copies of data/options to Chart.js instead of $state proxies. Chart.js's listenArrayEvents tries to define property descriptors on data arrays, which Svelte 5 proxies reject. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * nit typing * Merge issue * Fix "path is not set" error in resource picker / editor * Fix InputTransformForm error when rerunning some flows * fix npm run check --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
129 lines
3.1 KiB
Svelte
129 lines
3.1 KiB
Svelte
<script lang="ts">
|
|
/**
|
|
* @deprecated Use `$lib/components/meltComponents/Popover.svelte` instead.
|
|
* This legacy popover component will be removed in a future version.
|
|
*/
|
|
import { createPopperActions, type PopperOptions } from 'svelte-popperjs'
|
|
import type { PopoverPlacement } from './Popover.model'
|
|
import Portal from '$lib/components/Portal.svelte'
|
|
import { twMerge } from 'tailwind-merge'
|
|
|
|
import { ExternalLink } from 'lucide-svelte'
|
|
import { untrack } from 'svelte'
|
|
|
|
interface Props {
|
|
placement?: PopoverPlacement
|
|
notClickable?: boolean
|
|
popupClass?: string
|
|
disablePopup?: boolean
|
|
disappearTimeout?: number
|
|
appearTimeout?: number
|
|
documentationLink?: string | undefined
|
|
style?: string | undefined
|
|
forceOpen?: boolean
|
|
class?: string
|
|
children?: import('svelte').Snippet
|
|
text?: import('svelte').Snippet
|
|
onClick?: () => void
|
|
}
|
|
|
|
let {
|
|
placement = 'bottom-end',
|
|
notClickable = false,
|
|
popupClass = '',
|
|
disablePopup = false,
|
|
disappearTimeout = 100,
|
|
appearTimeout = 300,
|
|
documentationLink = undefined,
|
|
style = undefined,
|
|
forceOpen = false,
|
|
class: classNames = '',
|
|
children,
|
|
text,
|
|
onClick
|
|
}: Props = $props()
|
|
|
|
const [popperRef, popperContent] = createPopperActions({ placement: untrack(() => placement) })
|
|
|
|
const popperOptions: PopperOptions<{}> = {
|
|
placement: untrack(() => placement),
|
|
strategy: 'fixed',
|
|
modifiers: [
|
|
{ name: 'offset', options: { offset: [8, 8] } },
|
|
{
|
|
name: 'arrow',
|
|
options: {
|
|
padding: 10
|
|
}
|
|
}
|
|
]
|
|
}
|
|
|
|
let showTooltip = $state(false)
|
|
let timeout: number | undefined = undefined
|
|
let inTimeout: number | undefined = undefined
|
|
|
|
function open() {
|
|
clearTimeout(timeout)
|
|
if (appearTimeout == 0) {
|
|
showTooltip = true
|
|
} else {
|
|
inTimeout = setTimeout(() => (showTooltip = true), appearTimeout)
|
|
}
|
|
}
|
|
function close() {
|
|
inTimeout && clearTimeout(inTimeout)
|
|
inTimeout = undefined
|
|
timeout = setTimeout(() => (showTooltip = false), disappearTimeout)
|
|
}
|
|
|
|
$effect(() => {
|
|
;[forceOpen]
|
|
untrack(() => (forceOpen ? open() : close()))
|
|
})
|
|
</script>
|
|
|
|
{#if notClickable}
|
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
<span {style} use:popperRef onmouseenter={open} onmouseleave={close} class={classNames}>
|
|
{@render children?.()}
|
|
</span>
|
|
{:else}
|
|
<button
|
|
{style}
|
|
use:popperRef
|
|
onmouseenter={open}
|
|
onmouseleave={close}
|
|
onclick={onClick}
|
|
class={classNames}
|
|
>
|
|
{@render children?.()}
|
|
</button>
|
|
{/if}
|
|
{#if showTooltip && !disablePopup}
|
|
<Portal name="popover">
|
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
<div
|
|
use:popperContent={popperOptions}
|
|
onmouseenter={open}
|
|
onmouseleave={close}
|
|
class={twMerge(
|
|
'z-[5001] p-4 rounded-md text-xs font-normal bg-surface-secondary whitespace-normal text-left shadow-lg',
|
|
popupClass
|
|
)}
|
|
>
|
|
<div class="max-w-sm break-words">
|
|
{@render text?.()}
|
|
{#if documentationLink}
|
|
<a href={documentationLink} target="_blank">
|
|
<div class="flex flex-row gap-2 mt-4">
|
|
See documentation
|
|
<ExternalLink size="16" />
|
|
</div>
|
|
</a>
|
|
{/if}
|
|
</div>
|
|
</div>
|
|
</Portal>
|
|
{/if}
|