('svelteflow__node_id')
+ );
let resizeControlRef: HTMLDivElement;
- let resizer: XYResizerInstance | null = null;
+ let resizer: XYResizerInstance | null = $state(null);
- $: defaultPosition = (
- variant === ResizeControlVariant.Line ? 'right' : 'bottom-right'
- ) as ControlPosition;
- $: controlPosition = position ?? defaultPosition;
+ let controlPosition = $derived.by(() => {
+ let defaultPosition = (
+ variant === ResizeControlVariant.Line ? 'right' : 'bottom-right'
+ ) as ControlPosition;
+ return position ?? defaultPosition;
+ });
- $: positionClassNames = controlPosition.split('-');
+ let positionClassNames = $derived(controlPosition.split('-'));
- $: colorStyleProp = variant === ResizeControlVariant.Line ? 'border-color' : 'background-color';
- $: _style = style ?? '';
- $: controlStyle = color ? `${_style} ${colorStyleProp}: ${color};` : _style;
+ let controlStyle = $derived.by(() => {
+ let colorStyleProp =
+ variant === ResizeControlVariant.Line ? 'border-color' : 'background-color';
+ return color ? `${style} ${colorStyleProp}: ${color};` : style;
+ });
onMount(() => {
if (resizeControlRef) {
@@ -100,14 +101,14 @@
};
});
- $: {
+ $effect.pre(() => {
resizer?.update({
controlPosition,
boundaries: {
- minWidth: _minWidth,
- minHeight: _minHeight,
- maxWidth: _maxWidth,
- maxHeight: _maxHeight
+ minWidth,
+ minHeight,
+ maxWidth,
+ maxHeight
},
keepAspectRatio: !!keepAspectRatio,
onResizeStart,
@@ -115,7 +116,7 @@
onResizeEnd,
shouldResize
});
- }
+ });
-
+ {@render children?.()}
diff --git a/packages/svelte/src/lib/plugins/NodeResizer/types.ts b/packages/svelte/src/lib/plugins/NodeResizer/types.ts
index ebe44b8b..bcb924ae 100644
--- a/packages/svelte/src/lib/plugins/NodeResizer/types.ts
+++ b/packages/svelte/src/lib/plugins/NodeResizer/types.ts
@@ -6,6 +6,7 @@ import type {
OnResize,
OnResizeEnd
} from '@xyflow/system';
+import type { Snippet } from 'svelte';
export type NodeResizerProps = {
/** Id of the node it is resizing
@@ -69,4 +70,5 @@ export type ResizeControlProps = Pick<
variant?: ResizeControlVariant;
class?: string;
style?: string;
+ children?: Snippet;
};