@cnvx/nodal 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,28 +4,11 @@
|
|
|
4
4
|
type DiagramNodeDef,
|
|
5
5
|
type DiagramEdgeDef,
|
|
6
6
|
} from "./Diagram.svelte";
|
|
7
|
-
import {
|
|
8
|
-
createRawSnippet,
|
|
9
|
-
flushSync,
|
|
10
|
-
onMount,
|
|
11
|
-
setContext,
|
|
12
|
-
type Snippet,
|
|
13
|
-
} from "svelte";
|
|
7
|
+
import { onMount, setContext, type Snippet } from "svelte";
|
|
14
8
|
import type { HTMLAttributes } from "svelte/elements";
|
|
15
9
|
import PrerenderDiagram from "./PrerenderDiagram.svelte";
|
|
16
|
-
import { browser } from "./diagram-lib.js";
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
children,
|
|
20
|
-
eagerLoad = false,
|
|
21
|
-
scaleToFit,
|
|
22
|
-
width,
|
|
23
|
-
height,
|
|
24
|
-
rootMargin = "100px", // start a bit before it enters the viewport
|
|
25
|
-
figureAttributes = { inert: true, "aria-hidden": true },
|
|
26
|
-
...rest
|
|
27
|
-
}: ({
|
|
28
|
-
children: Snippet;
|
|
11
|
+
type PassthroughDiagramControllerProps = ({
|
|
29
12
|
eagerLoad?: boolean;
|
|
30
13
|
rootMargin?: string;
|
|
31
14
|
figureAttributes?: HTMLAttributes<HTMLElement>;
|
|
@@ -41,14 +24,25 @@
|
|
|
41
24
|
height: number;
|
|
42
25
|
}
|
|
43
26
|
)) &
|
|
44
|
-
Omit<HTMLAttributes<HTMLDivElement>, "width" | "height"
|
|
27
|
+
Omit<HTMLAttributes<HTMLDivElement>, "width" | "height">;
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
children,
|
|
31
|
+
eagerLoad = false,
|
|
32
|
+
scaleToFit,
|
|
33
|
+
width,
|
|
34
|
+
height,
|
|
35
|
+
rootMargin = "100px", // start a bit before it enters the viewport
|
|
36
|
+
figureAttributes = { inert: true, "aria-hidden": true },
|
|
37
|
+
...rest
|
|
38
|
+
}: PassthroughDiagramControllerProps & { children: Snippet } = $props();
|
|
45
39
|
|
|
46
40
|
const nodes = new SvelteMap<string, DiagramNodeDef>();
|
|
47
41
|
const layers = new SvelteMap<number, Record<string, DiagramNodeDef>>();
|
|
48
42
|
setContext("layerNodeMap", () => layers);
|
|
49
43
|
const edges = new SvelteMap<string, DiagramEdgeDef>();
|
|
50
44
|
|
|
51
|
-
let containerEl: HTMLDivElement | undefined;
|
|
45
|
+
let containerEl: HTMLDivElement | undefined = $state();
|
|
52
46
|
|
|
53
47
|
// If we're SSR (not browser), or eagerLoad is false, render immediately.
|
|
54
48
|
// Otherwise wait until after load + idle + intersection.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type Snippet } from "svelte";
|
|
2
2
|
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
-
type
|
|
4
|
-
children: Snippet;
|
|
3
|
+
type PassthroughDiagramControllerProps = ({
|
|
5
4
|
eagerLoad?: boolean;
|
|
6
5
|
rootMargin?: string;
|
|
7
6
|
figureAttributes?: HTMLAttributes<HTMLElement>;
|
|
@@ -14,6 +13,9 @@ type $$ComponentProps = ({
|
|
|
14
13
|
width: number;
|
|
15
14
|
height: number;
|
|
16
15
|
})) & Omit<HTMLAttributes<HTMLDivElement>, "width" | "height">;
|
|
16
|
+
type $$ComponentProps = PassthroughDiagramControllerProps & {
|
|
17
|
+
children: Snippet;
|
|
18
|
+
};
|
|
17
19
|
declare const DiagramController: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
18
20
|
type DiagramController = ReturnType<typeof DiagramController>;
|
|
19
21
|
export default DiagramController;
|