rename hideOnSSR
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
export { portal } from './portal.svelte';
|
export { portal } from './portal.svelte';
|
||||||
export { hideDuringSSR } from './utils.svelte';
|
export { hideOnSSR } from './utils.svelte';
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
export function hideDuringSSR(): { display: 'none' | undefined } {
|
export function hideOnSSR(): { value: boolean } {
|
||||||
let display = $state(typeof window === 'undefined' ? ('none' as const) : undefined);
|
let hide = $state(typeof window === 'undefined');
|
||||||
if (display) {
|
if (hide) {
|
||||||
const destroyEffect = $effect.root(() => {
|
const destroyEffect = $effect.root(() => {
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
display = undefined;
|
hide = false;
|
||||||
destroyEffect?.();
|
destroyEffect?.();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
get display() {
|
get value() {
|
||||||
return display;
|
return hide;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
import { hideDuringSSR, portal } from '$lib/actions/portal';
|
import { hideOnSSR, portal } from '$lib/actions/portal';
|
||||||
|
|
||||||
import { useStore } from '$lib/store';
|
import { useStore } from '$lib/store';
|
||||||
import type { EdgeLabelProps } from './types';
|
import type { EdgeLabelProps } from './types';
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
use:portal={'edge-labels'}
|
use:portal={'edge-labels'}
|
||||||
style:display={hideDuringSSR().display}
|
style:display={hideOnSSR().value ? 'none' : undefined}
|
||||||
class={['svelte-flow__edge-label', { transparent }, className]}
|
class={['svelte-flow__edge-label', { transparent }, className]}
|
||||||
style:cursor={selectEdgeOnClick ? 'pointer' : undefined}
|
style:cursor={selectEdgeOnClick ? 'pointer' : undefined}
|
||||||
style:transform="translate(-50%, -50%) translate({x}px,{y}px)"
|
style:transform="translate(-50%, -50%) translate({x}px,{y}px)"
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { hideDuringSSR, portal } from '$lib/actions/portal';
|
import { hideOnSSR, portal } from '$lib/actions/portal';
|
||||||
import type { ViewportPortalProps } from './types';
|
import type { ViewportPortalProps } from './types';
|
||||||
|
|
||||||
let { target = 'front', children, ...rest }: ViewportPortalProps = $props();
|
let { target = 'front', children, ...rest }: ViewportPortalProps = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div use:portal={`viewport-${target}`} style:display={hideDuringSSR().display} {...rest}>
|
<div
|
||||||
|
use:portal={`viewport-${target}`}
|
||||||
|
style:display={hideOnSSR().value ? 'none' : undefined}
|
||||||
|
{...rest}
|
||||||
|
>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
import { Position, getNodeToolbarTransform } from '@xyflow/system';
|
import { Position, getNodeToolbarTransform } from '@xyflow/system';
|
||||||
|
|
||||||
import { hideDuringSSR, portal } from '$lib/actions/portal';
|
import { hideOnSSR, portal } from '$lib/actions/portal';
|
||||||
import { useStore } from '$lib/store';
|
import { useStore } from '$lib/store';
|
||||||
import { useSvelteFlow } from '$lib/hooks/useSvelteFlow.svelte';
|
import { useSvelteFlow } from '$lib/hooks/useSvelteFlow.svelte';
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
{#if store.domNode && isActive && toolbarNodes}
|
{#if store.domNode && isActive && toolbarNodes}
|
||||||
<div
|
<div
|
||||||
use:portal={'root'}
|
use:portal={'root'}
|
||||||
style:display={hideDuringSSR().display}
|
style:display={hideOnSSR().value ? 'none' : undefined}
|
||||||
class="svelte-flow__node-toolbar"
|
class="svelte-flow__node-toolbar"
|
||||||
data-id={toolbarNodes.reduce((acc, node) => `${acc}${node.id} `, '').trim()}
|
data-id={toolbarNodes.reduce((acc, node) => `${acc}${node.id} `, '').trim()}
|
||||||
style:position="absolute"
|
style:position="absolute"
|
||||||
|
|||||||
Reference in New Issue
Block a user