@visuallyjs/browser-ui-svelte 1.2.1 → 1.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.
- package/GridBackgroundComponent.svelte +39 -0
- package/ImageBackgroundComponent.svelte +37 -0
- package/PaperComponent.svelte +10 -8
- package/SurfaceComponent.svelte +11 -8
- package/SurfacePopup.svelte +8 -3
- package/TiledImageBackgroundComponent.svelte +36 -0
- package/ambient.d.ts +7 -0
- package/components.d.ts +3 -0
- package/components.js +3 -0
- package/definitions.d.ts +124 -2
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/use-diagram.svelte.d.ts +1 -1
- package/use-diagram.svelte.js +1 -1
- package/use-paper.svelte.d.ts +7 -0
- package/use-paper.svelte.js +18 -0
- package/use-surface.svelte.d.ts +1 -1
- package/use-surface.svelte.js +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {BackgroundPlugin, GeneratedGridBackground} from "@visuallyjs/browser-ui"
|
|
3
|
+
import {useSurface} from "./use-surface.svelte";
|
|
4
|
+
import {usePaper} from "./use-paper.svelte";
|
|
5
|
+
import {type GridBackgroundComponentProps} from "./definitions";
|
|
6
|
+
|
|
7
|
+
let initialized = false
|
|
8
|
+
const surface = useSurface()
|
|
9
|
+
const paper = usePaper()
|
|
10
|
+
|
|
11
|
+
const props:GridBackgroundComponentProps = $props()
|
|
12
|
+
|
|
13
|
+
const o = props || {}
|
|
14
|
+
|
|
15
|
+
$effect(() => {
|
|
16
|
+
if (!initialized) {
|
|
17
|
+
if (surface.current) {
|
|
18
|
+
initialized = true
|
|
19
|
+
surface.current.addPlugin({
|
|
20
|
+
type: BackgroundPlugin.type,
|
|
21
|
+
options: {
|
|
22
|
+
type: GeneratedGridBackground.type,
|
|
23
|
+
...o
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
if (paper.current) {
|
|
28
|
+
initialized = true
|
|
29
|
+
paper.current.addPlugin({
|
|
30
|
+
type: BackgroundPlugin.type,
|
|
31
|
+
options: {
|
|
32
|
+
type: GeneratedGridBackground.type,
|
|
33
|
+
...o
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
</script>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {useSurface} from "./use-surface.svelte";
|
|
3
|
+
import { BackgroundPlugin, SimpleBackground } from "@visuallyjs/browser-ui"
|
|
4
|
+
import {usePaper} from "./use-paper.svelte";
|
|
5
|
+
import {ImageBackgroundComponentProps} from "./definitions";
|
|
6
|
+
|
|
7
|
+
let initialized = false
|
|
8
|
+
const surface = useSurface()
|
|
9
|
+
const paper = usePaper()
|
|
10
|
+
|
|
11
|
+
const { url }:ImageBackgroundComponentProps = $props()
|
|
12
|
+
|
|
13
|
+
$effect(() => {
|
|
14
|
+
if (!initialized) {
|
|
15
|
+
if (surface.current) {
|
|
16
|
+
initialized = true
|
|
17
|
+
surface.current.addPlugin({
|
|
18
|
+
type: BackgroundPlugin.type,
|
|
19
|
+
options: {
|
|
20
|
+
type: SimpleBackground.type,
|
|
21
|
+
url
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
if (paper.current) {
|
|
26
|
+
initialized = true
|
|
27
|
+
paper.current.addPlugin({
|
|
28
|
+
type: BackgroundPlugin.type,
|
|
29
|
+
options: {
|
|
30
|
+
type: SimpleBackground.type,
|
|
31
|
+
url
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
</script>
|
package/PaperComponent.svelte
CHANGED
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
EVENT_RENDER_END,
|
|
14
14
|
CLASS_DEFAULT_GROUP,
|
|
15
15
|
CLASS_DEFAULT_NODE, Paper,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
type BrowserElement,
|
|
17
|
+
type ObjectData,
|
|
18
|
+
Vertex,
|
|
19
|
+
partition,
|
|
20
|
+
type VertexUpdatedParams,
|
|
21
21
|
extend, EVENT_GRAPH_CLEARED, EVENT_NODE_UPDATED, EVENT_GROUP_UPDATED,
|
|
22
|
-
|
|
22
|
+
type NodeRemovedParams, EVENT_NODE_REMOVED,
|
|
23
23
|
type GroupRemovedParams, EVENT_GROUP_REMOVED,
|
|
24
24
|
type PaperOptions,
|
|
25
25
|
OVERLAY_TYPE_CUSTOM,
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
type EdgeRemovedParams,
|
|
29
29
|
EVENT_EDGE_UPDATED,
|
|
30
30
|
EVENT_EDGE_REMOVED,
|
|
31
|
-
ELEMENT_DIV
|
|
31
|
+
ELEMENT_DIV, Edge
|
|
32
32
|
} from "@visuallyjs/browser-ui";
|
|
33
33
|
import { internal_getPaperContext } from "./surface-store";
|
|
34
34
|
|
|
@@ -285,6 +285,8 @@
|
|
|
285
285
|
if (entry != null) {
|
|
286
286
|
entry.props.data = mergeData()
|
|
287
287
|
_updateVertexState()
|
|
288
|
+
|
|
289
|
+
entry.vertex.getAllEdges().forEach((edge:Edge) => updateOverlays(edge.id, {edge}))
|
|
288
290
|
}
|
|
289
291
|
}
|
|
290
292
|
|
|
@@ -309,7 +311,7 @@
|
|
|
309
311
|
removeVertex(p.group.id)
|
|
310
312
|
});
|
|
311
313
|
|
|
312
|
-
const updateOverlays = (edgeId: string, eventPayload:
|
|
314
|
+
const updateOverlays = (edgeId: string, eventPayload: { edge:Edge} ) => {
|
|
313
315
|
_overlays.forEach(o => {
|
|
314
316
|
if (o.edge.id === edgeId) {
|
|
315
317
|
o.props.data = eventPayload.edge.data;
|
package/SurfaceComponent.svelte
CHANGED
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
EVENT_RENDER_END,
|
|
14
14
|
CLASS_DEFAULT_GROUP,
|
|
15
15
|
CLASS_DEFAULT_NODE, Surface,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
type BrowserElement,
|
|
17
|
+
type ObjectData,
|
|
18
|
+
Vertex,
|
|
19
|
+
partition,
|
|
20
|
+
type VertexUpdatedParams,
|
|
21
21
|
extend, EVENT_GRAPH_CLEARED, EVENT_NODE_UPDATED, EVENT_GROUP_UPDATED,
|
|
22
|
-
|
|
22
|
+
type NodeRemovedParams, EVENT_NODE_REMOVED,
|
|
23
23
|
type GroupRemovedParams, EVENT_GROUP_REMOVED,
|
|
24
24
|
type SurfaceOptions,
|
|
25
25
|
OVERLAY_TYPE_CUSTOM,
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
type EdgeRemovedParams,
|
|
29
29
|
EVENT_EDGE_UPDATED,
|
|
30
30
|
EVENT_EDGE_REMOVED,
|
|
31
|
-
ELEMENT_DIV
|
|
31
|
+
ELEMENT_DIV, Edge
|
|
32
32
|
} from "@visuallyjs/browser-ui";
|
|
33
33
|
import { internal_getSurfaceContext } from "./surface-store";
|
|
34
34
|
|
|
@@ -285,6 +285,8 @@
|
|
|
285
285
|
if (entry != null) {
|
|
286
286
|
entry.props.data = mergeData()
|
|
287
287
|
_updateVertexState()
|
|
288
|
+
|
|
289
|
+
entry.vertex.getAllEdges().forEach((edge:Edge) => updateOverlays(edge.id, {edge}))
|
|
288
290
|
}
|
|
289
291
|
}
|
|
290
292
|
|
|
@@ -309,7 +311,7 @@
|
|
|
309
311
|
removeVertex(p.group.id)
|
|
310
312
|
});
|
|
311
313
|
|
|
312
|
-
const updateOverlays = (edgeId: string, eventPayload:
|
|
314
|
+
const updateOverlays = (edgeId: string, eventPayload: { edge:Edge } ) => {
|
|
313
315
|
_overlays.forEach(o => {
|
|
314
316
|
if (o.edge.id === edgeId) {
|
|
315
317
|
o.props.data = eventPayload.edge.data;
|
|
@@ -334,6 +336,7 @@
|
|
|
334
336
|
_updateOverlayState()
|
|
335
337
|
})
|
|
336
338
|
|
|
339
|
+
// TODO how can this be made reactive
|
|
337
340
|
if (url != null) {
|
|
338
341
|
model.load({ url });
|
|
339
342
|
} else if (data != null) {
|
package/SurfacePopup.svelte
CHANGED
|
@@ -13,20 +13,25 @@
|
|
|
13
13
|
let container:HTMLElement
|
|
14
14
|
let initialized = false
|
|
15
15
|
|
|
16
|
+
let handler:PopupHandler
|
|
16
17
|
let current = $state<Vertex|null>(null)
|
|
17
18
|
let display = $derived(current == null ? "none" : "block")
|
|
18
19
|
|
|
20
|
+
function hide() {
|
|
21
|
+
handler?.$hide()
|
|
22
|
+
}
|
|
23
|
+
|
|
19
24
|
$effect(() => {
|
|
20
25
|
if (!initialized && surface.current && container) {
|
|
21
26
|
initialized = true
|
|
22
|
-
new PopupHandler(selector, container, surface.current, (v:Vertex|null) => current = v, anchor)
|
|
27
|
+
handler = new PopupHandler(selector, container, surface.current, (v:Vertex|null) => current = v, anchor)
|
|
23
28
|
}
|
|
24
29
|
})
|
|
25
30
|
|
|
26
31
|
</script>
|
|
27
32
|
|
|
28
33
|
<div bind:this={container} class={CLASS_SURFACE_POPUP} style:display={display} style:position="absolute">
|
|
29
|
-
{#if surface.current != null}
|
|
30
|
-
{@render popup(current, surface.current.model, surface.current)}
|
|
34
|
+
{#if current != null && surface.current != null}
|
|
35
|
+
{@render popup(current, surface.current.model, surface.current, hide)}
|
|
31
36
|
{/if}
|
|
32
37
|
</div>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {useSurface} from "./use-surface.svelte";
|
|
3
|
+
import { BackgroundPlugin, TiledBackground } from "@visuallyjs/browser-ui"
|
|
4
|
+
import {usePaper} from "./use-paper.svelte";
|
|
5
|
+
import {TiledImageBackgroundComponentProps} from "./definitions";
|
|
6
|
+
|
|
7
|
+
let initialized = false
|
|
8
|
+
const surface = useSurface()
|
|
9
|
+
const paper = usePaper()
|
|
10
|
+
|
|
11
|
+
const props:TiledImageBackgroundComponentProps = $props()
|
|
12
|
+
|
|
13
|
+
$effect(() => {
|
|
14
|
+
if (!initialized) {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
if (surface.current) {
|
|
18
|
+
initialized = true
|
|
19
|
+
surface.current.addPlugin({
|
|
20
|
+
type: BackgroundPlugin.type,
|
|
21
|
+
options: {type: TiledBackground.type, ...props}
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
if (paper.current) {
|
|
25
|
+
initialized = true
|
|
26
|
+
paper.current.addPlugin({
|
|
27
|
+
type: BackgroundPlugin.type,
|
|
28
|
+
options: {
|
|
29
|
+
type: TiledBackground.type,
|
|
30
|
+
...props
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
</script>
|
package/ambient.d.ts
ADDED
package/components.d.ts
CHANGED
|
@@ -31,3 +31,6 @@ export { default as OverlayWrapperComponent } from "./OverlayWrapperComponent.sv
|
|
|
31
31
|
export { default as DiagramProvider } from "./DiagramProvider.svelte";
|
|
32
32
|
export { default as SurfaceProvider } from "./SurfaceProvider.svelte";
|
|
33
33
|
export { default as PaperProvider } from "./PaperProvider.svelte";
|
|
34
|
+
export { default as GridBackgroundComponent } from "./GridBackgroundComponent.svelte";
|
|
35
|
+
export { default as ImageBackgroundComponent } from "./ImageBackgroundComponent.svelte";
|
|
36
|
+
export { default as TiledImageBackgroundComponent } from "./TiledImageBackgroundComponent.svelte";
|
package/components.js
CHANGED
|
@@ -31,3 +31,6 @@ export { default as OverlayWrapperComponent } from "./OverlayWrapperComponent.sv
|
|
|
31
31
|
export { default as DiagramProvider } from "./DiagramProvider.svelte";
|
|
32
32
|
export { default as SurfaceProvider } from "./SurfaceProvider.svelte";
|
|
33
33
|
export { default as PaperProvider } from "./PaperProvider.svelte";
|
|
34
|
+
export { default as GridBackgroundComponent } from "./GridBackgroundComponent.svelte";
|
|
35
|
+
export { default as ImageBackgroundComponent } from "./ImageBackgroundComponent.svelte";
|
|
36
|
+
export { default as TiledImageBackgroundComponent } from "./TiledImageBackgroundComponent.svelte";
|
package/definitions.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Snippet } from "svelte";
|
|
2
2
|
import type { DOMAttributes } from "svelte/elements";
|
|
3
|
-
import { SurfaceOptions, Vertex, Group, Node, ControlsComponentButtons, DataGeneratorFunction, type BrowserElement, Base, Size, ObjectData, DropTargetInfo, PaletteMode, SvgExportUIOptions, ImageExportUIOptions, ShapeLibraryImpl, ModelOptions, DiagramOptions, Diagram, DiagramCell, NodeMapping, GroupMapping, PortMapping, BrowserUI, EdgeMapping, OnVertexAddedCallback, CanvasDropFilter, FontSpec, BrowserUIModel, PreparedShape, PointXY, FixedElementConstraints, PopupPosition, OverlaySpec, PaperOptions } from "@visuallyjs/browser-ui";
|
|
3
|
+
import { SurfaceOptions, Vertex, Group, Node, ControlsComponentButtons, DataGeneratorFunction, type BrowserElement, Base, Size, ObjectData, DropTargetInfo, PaletteMode, SvgExportUIOptions, ImageExportUIOptions, ShapeLibraryImpl, ModelOptions, DiagramOptions, Diagram, DiagramCell, NodeMapping, GroupMapping, PortMapping, BrowserUI, EdgeMapping, OnVertexAddedCallback, CanvasDropFilter, FontSpec, BrowserUIModel, PreparedShape, PointXY, FixedElementConstraints, PopupPosition, OverlaySpec, PaperOptions, TilingStrategy, GridType, Grid } from "@visuallyjs/browser-ui";
|
|
4
4
|
/**
|
|
5
5
|
* Render options for a SurfaceComponent. This interface is the same as SurfaceOptions but with several vanilla-only options removed.
|
|
6
6
|
*/
|
|
@@ -529,6 +529,128 @@ export interface ExportControlsComponentProps extends DOMAttributes<HTMLDivEleme
|
|
|
529
529
|
*/
|
|
530
530
|
allowJpgExport?: boolean;
|
|
531
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* Props for the GridBackgroundComponent
|
|
534
|
+
* @group Props
|
|
535
|
+
*/
|
|
536
|
+
export interface GridBackgroundComponentProps {
|
|
537
|
+
/**
|
|
538
|
+
* The grid to use. This is optional; if you do not supply one the background will attempt to read the grid definition from the Surface. If that is also not set then a default grid of 50x50 pixels will be used.
|
|
539
|
+
*/
|
|
540
|
+
grid?: Grid;
|
|
541
|
+
/**
|
|
542
|
+
* Whether or not to show a thick border around the entire background. Defaults to false.
|
|
543
|
+
*/
|
|
544
|
+
showBorder?: boolean;
|
|
545
|
+
/**
|
|
546
|
+
* The minimum width for the grid. The value you provided is divided by 2 and then the grid is guaranteed to always at least span the range of (-minWidth / 2) - (minWidth / 2). Defaults to 20 000.
|
|
547
|
+
*/
|
|
548
|
+
minWidth?: number;
|
|
549
|
+
/**
|
|
550
|
+
* The minimum height for the grid. The value you provided is divided by 2 and then the grid is guaranteed to always at least span the range of (-minHeight / 2) - (minHeight / 2). Defaults to 20 000.
|
|
551
|
+
*/
|
|
552
|
+
minHeight?: number;
|
|
553
|
+
/**
|
|
554
|
+
* Defaults to false. If true, the grid will also draw tick marks between the grid lines.
|
|
555
|
+
*/
|
|
556
|
+
showTickMarks?: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Number of tick marks to draw per cell. Defaults to 2.
|
|
559
|
+
*/
|
|
560
|
+
tickMarksPerCell?: number;
|
|
561
|
+
/**
|
|
562
|
+
* The maximum width for the grid. The value you provided is divided by 2 and then the grid is guaranteed to never exceed the range of (-maxWidth / 2) - (maxWidth / 2). maxWidth takes precedence over minWidth.
|
|
563
|
+
*/
|
|
564
|
+
maxWidth?: number;
|
|
565
|
+
/**
|
|
566
|
+
* The maximum height for the grid. The value you provided is divided by 2 and then the grid is guaranteed to never exceed the range of (-maxHeight / 2) - (maxHeight / 2). maxHeight takes precedence over minHeight.
|
|
567
|
+
*/
|
|
568
|
+
maxHeight?: number;
|
|
569
|
+
/**
|
|
570
|
+
* Defaults to true, and instructs the grid that if the grid has grown beyond any minimum value set in either axis, if the content bounds subsequently shrink in that axis below the minimum, the grid should shrink back to the minimum. If you set this to false the grid will never shrink back to its minimum values once they have been exceeded.
|
|
571
|
+
*/
|
|
572
|
+
autoShrink?: boolean;
|
|
573
|
+
/**
|
|
574
|
+
* Type of grid - lines or dots. Defaults to lines.
|
|
575
|
+
*/
|
|
576
|
+
gridType?: GridType;
|
|
577
|
+
/**
|
|
578
|
+
* The radius for dots representing grid positions (when gridType id GridTypes.dotted). Defaults to 2.
|
|
579
|
+
*/
|
|
580
|
+
dotRadius?: number;
|
|
581
|
+
/**
|
|
582
|
+
* The radius for dots representing grid tick marks (when gridType id GridTypes.dotted). Defaults to 1.
|
|
583
|
+
*/
|
|
584
|
+
tickDotRadius?: number;
|
|
585
|
+
/**
|
|
586
|
+
* Whether or not the background is initially visible. Defaults to true.
|
|
587
|
+
*/
|
|
588
|
+
visible?: boolean;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Props for the ImageBackgroundComponent
|
|
592
|
+
* @group Props
|
|
593
|
+
*/
|
|
594
|
+
export interface ImageBackgroundComponentProps {
|
|
595
|
+
/**
|
|
596
|
+
* URL of the image to load.
|
|
597
|
+
*/
|
|
598
|
+
url: string;
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Props for the tiled image background component
|
|
602
|
+
* @group Props
|
|
603
|
+
*/
|
|
604
|
+
export interface TiledImageBackgroundComponentProps {
|
|
605
|
+
/**
|
|
606
|
+
* URL for the background. You can supply this, or you can supply a `urlGenerator` function instead. If you supply `url` and no `urlGenerator`, the url you supply is treated as a template for the url for any given tile, and is expected to contain `{z}`, `{x}` and `{y}` placeholders. The form of the URL can be anything you like as long as it has the placeholders for z, x and y. For instance:
|
|
607
|
+
*
|
|
608
|
+
* http://foo.com/{z}/{x}/{y}
|
|
609
|
+
* https://bar.com?zoom={z}&x={x}&y={y}
|
|
610
|
+
*
|
|
611
|
+
* etc
|
|
612
|
+
*/
|
|
613
|
+
url?: string;
|
|
614
|
+
/**
|
|
615
|
+
* For tiled backgrounds, an optional function you can supply to generate the URL for a given tile. See `url` for
|
|
616
|
+
* an explanation of the default syntax for urls when using a tiled background.
|
|
617
|
+
* @param z zoom level
|
|
618
|
+
* @param x x coordinate of tile
|
|
619
|
+
* @param y y coordinate of tile
|
|
620
|
+
*/
|
|
621
|
+
urlGenerator?: (z: number, x: number, y: number) => string;
|
|
622
|
+
/**
|
|
623
|
+
* Provides the width and height of tiles. Every tile is assumed to have these dimensions,
|
|
624
|
+
* even if the tile has whitespace in it. Required.
|
|
625
|
+
*/
|
|
626
|
+
tileSize: Size;
|
|
627
|
+
/**
|
|
628
|
+
* Required. Indicates the width of the full image.
|
|
629
|
+
*/
|
|
630
|
+
width: number;
|
|
631
|
+
/**
|
|
632
|
+
* Required. Indicates the height of the full image.
|
|
633
|
+
*/
|
|
634
|
+
height: number;
|
|
635
|
+
/**
|
|
636
|
+
* Required. Indicates the maximum zoom level. Zoom starts at 0 - fully zoomed out - and
|
|
637
|
+
* increases in integer values from there. Each successive zoom level is twice the zoom of the previous level,
|
|
638
|
+
* meaning two times as many tiles in each direction.
|
|
639
|
+
*/
|
|
640
|
+
maxZoom: number;
|
|
641
|
+
/**
|
|
642
|
+
* Default is TilingStrategies.logarithmic. See notes for `TilingStrategies` enum.
|
|
643
|
+
*/
|
|
644
|
+
tiling?: TilingStrategy;
|
|
645
|
+
/**
|
|
646
|
+
* How long to wait after a pan before reloading tiles.
|
|
647
|
+
*/
|
|
648
|
+
panDebounceTimeout?: number;
|
|
649
|
+
/**
|
|
650
|
+
* How long to wait after a zoom before reloading tiles.
|
|
651
|
+
*/
|
|
652
|
+
zoomDebounceTimeout?: number;
|
|
653
|
+
}
|
|
532
654
|
/**
|
|
533
655
|
* @group Props
|
|
534
656
|
*/
|
|
@@ -697,5 +819,5 @@ export interface SurfacePopupProps {
|
|
|
697
819
|
/**
|
|
698
820
|
* The snippet that renders the content for the popup.
|
|
699
821
|
*/
|
|
700
|
-
popup: Snippet<[Vertex | null, BrowserUIModel, BrowserUI]>;
|
|
822
|
+
popup: Snippet<[Vertex | null, BrowserUIModel, BrowserUI, (() => any)]>;
|
|
701
823
|
}
|
package/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './definitions';
|
|
|
14
14
|
export * from './charts/definitions';
|
|
15
15
|
export * from './use-zoom.svelte';
|
|
16
16
|
export * from './use-surface.svelte';
|
|
17
|
+
export * from './use-paper.svelte';
|
|
17
18
|
export * from './use-diagram.svelte';
|
|
18
19
|
export * from './use-visuallyjs-update.svelte';
|
|
19
20
|
import { BrowserElement, BrowserUIModel, BrowserUIOptions, TemplateRenderer, ModelOptions } from "@visuallyjs/browser-ui";
|
package/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from './definitions';
|
|
|
14
14
|
export * from './charts/definitions';
|
|
15
15
|
export * from './use-zoom.svelte';
|
|
16
16
|
export * from './use-surface.svelte';
|
|
17
|
+
export * from './use-paper.svelte';
|
|
17
18
|
export * from './use-diagram.svelte';
|
|
18
19
|
export * from './use-visuallyjs-update.svelte';
|
|
19
20
|
import { BrowserUIModel, log } from "@visuallyjs/browser-ui";
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@visuallyjs/browser-ui-svelte","version":"1.2.
|
|
1
|
+
{"name":"@visuallyjs/browser-ui-svelte","version":"1.2.2","description":"VisuallyJS Svelte integration for Browser UI renderer","module":"index.js","main":"index.js","types":"index.d.ts","svelte":"index.js","files":["**/*.d.ts","**/*.js","SurfaceComponent.svelte","PaperComponent.svelte","DecoratorComponent.svelte","DefaultGroupComponent.svelte","DefaultNodeComponent.svelte","MiniviewComponent.svelte","ControlsComponent.svelte","SurfaceProvider.svelte","PaperProvider.svelte","PaletteComponent.svelte","InspectorComponent.svelte","EdgeTypePickerComponent.svelte","ShapePaletteComponent.svelte","ExportControlsComponent.svelte","ShapeComponent.svelte","DiagramComponent.svelte","BarChartComponent.svelte","ColumnChartComponent.svelte","XYChartComponent.svelte","LineChartComponent.svelte","AreaChartComponent.svelte","PieChartComponent.svelte","WrapperComponent.svelte","OverlayWrapperComponent.svelte","DiagramProvider.svelte","DiagramPaletteComponent.svelte","ColorPickerComponent.svelte","ScatterChartComponent.svelte","BubbleChartComponent.svelte","GaugeChartComponent.svelte","SankeyChartComponent.svelte","SurfacePopup.svelte","GridBackgroundComponent.svelte","ImageBackgroundComponent.svelte","TiledImageBackgroundComponent.svelte"],"author":"VisuallyJs <hello@visuallyjs.com> (https://visuallyjs.com)","license":"Commercial","dependencies":{"@visuallyjs/browser-ui":"1.2.2"},"homepage":"https://visuallyjs.com/svelte","bugs":"https://github.com/visuallyjs/visuallyjs/issues"}
|
package/use-diagram.svelte.d.ts
CHANGED
package/use-diagram.svelte.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { internal_getPaperContext } from "./surface-store";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to access the current Paper.
|
|
4
|
+
* @group Hooks
|
|
5
|
+
*/
|
|
6
|
+
export function usePaper() {
|
|
7
|
+
const ctx = internal_getPaperContext(true);
|
|
8
|
+
let paper = $state(null);
|
|
9
|
+
if (ctx != null) {
|
|
10
|
+
ctx.listen((s) => paper = s);
|
|
11
|
+
}
|
|
12
|
+
// Return an object with a getter to maintain reactivity across function boundaries
|
|
13
|
+
return {
|
|
14
|
+
get current() {
|
|
15
|
+
return paper;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
package/use-surface.svelte.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Surface } from '@visuallyjs/browser-ui';
|
|
2
2
|
import { RefObject } from "./definitions";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Hook to access the current Surface
|
|
5
5
|
* @group Hooks
|
|
6
6
|
*/
|
|
7
7
|
export declare function useSurface(): RefObject<Surface>;
|