@visuallyjs/browser-ui-svelte 1.2.0 → 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/ColorPickerComponent.svelte +2 -2
- package/EdgeTypePickerComponent.svelte +1 -1
- package/GridBackgroundComponent.svelte +39 -0
- package/ImageBackgroundComponent.svelte +37 -0
- package/OverlayWrapperComponent.svelte +35 -0
- package/PaperComponent.svelte +367 -0
- package/PaperProvider.svelte +11 -0
- package/SurfaceComponent.svelte +109 -11
- package/SurfacePopup.svelte +37 -0
- package/TiledImageBackgroundComponent.svelte +36 -0
- package/WrapperComponent.svelte +3 -1
- package/ambient.d.ts +7 -0
- package/components.d.ts +7 -0
- package/components.js +7 -0
- package/definitions.d.ts +214 -6
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/surface-store.d.ts +21 -1
- package/surface-store.js +41 -0
- 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
package/SurfaceComponent.svelte
CHANGED
|
@@ -13,21 +13,29 @@
|
|
|
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
|
-
type SurfaceOptions
|
|
24
|
+
type SurfaceOptions,
|
|
25
|
+
OVERLAY_TYPE_CUSTOM,
|
|
26
|
+
type Connection,
|
|
27
|
+
type EdgeUpdatedParams,
|
|
28
|
+
type EdgeRemovedParams,
|
|
29
|
+
EVENT_EDGE_UPDATED,
|
|
30
|
+
EVENT_EDGE_REMOVED,
|
|
31
|
+
ELEMENT_DIV, Edge
|
|
25
32
|
} from "@visuallyjs/browser-ui";
|
|
26
33
|
import { internal_getSurfaceContext } from "./surface-store";
|
|
27
34
|
|
|
28
35
|
import DefaultNodeComponent from './DefaultNodeComponent.svelte'
|
|
29
36
|
import DefaultGroupComponent from './DefaultGroupComponent.svelte'
|
|
30
37
|
import WrapperComponent from "./WrapperComponent.svelte";
|
|
38
|
+
import OverlayWrapperComponent from "./OverlayWrapperComponent.svelte";
|
|
31
39
|
|
|
32
40
|
let container:HTMLElement;
|
|
33
41
|
|
|
@@ -70,17 +78,78 @@
|
|
|
70
78
|
// list of vertices to render
|
|
71
79
|
let _vertices:Array<ComponentHolder> = []
|
|
72
80
|
|
|
81
|
+
type OverlayHolder = {
|
|
82
|
+
component: any,
|
|
83
|
+
props: any,
|
|
84
|
+
edge: any,
|
|
85
|
+
id: string,
|
|
86
|
+
el:BrowserElement
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let _overlays: Array<OverlayHolder> = []
|
|
90
|
+
|
|
73
91
|
// state wrapper around the vertex list
|
|
74
92
|
let vertexState = $state({
|
|
75
93
|
vertices:_vertices
|
|
76
94
|
})
|
|
77
95
|
|
|
96
|
+
let overlayState = $state({
|
|
97
|
+
overlays: _overlays
|
|
98
|
+
})
|
|
99
|
+
|
|
78
100
|
// manages updating the vertex state cleanly.
|
|
79
101
|
function _updateVertexState() {
|
|
80
102
|
vertexState.vertices.length = 0
|
|
81
103
|
vertexState.vertices.push(..._vertices.slice())
|
|
82
104
|
}
|
|
83
105
|
|
|
106
|
+
function _updateOverlayState() {
|
|
107
|
+
overlayState.overlays.length = 0
|
|
108
|
+
overlayState.overlays.push(..._overlays.slice())
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function _initialiseSvelteOverlays() {
|
|
112
|
+
const edgeTypes = viewOptions?.edges || {}
|
|
113
|
+
for (let type in edgeTypes) {
|
|
114
|
+
const edgeDefinition = edgeTypes[type];
|
|
115
|
+
if (edgeDefinition.overlays) {
|
|
116
|
+
edgeDefinition.overlays = edgeDefinition.overlays.map((ov: any) => {
|
|
117
|
+
if (ov.component != null) {
|
|
118
|
+
return {
|
|
119
|
+
type: OVERLAY_TYPE_CUSTOM,
|
|
120
|
+
options: {
|
|
121
|
+
create: (c: Connection<BrowserElement>) => {
|
|
122
|
+
const el = document.createElement(ELEMENT_DIV);
|
|
123
|
+
const overlayProps = {
|
|
124
|
+
data: c.edge.data,
|
|
125
|
+
model: surface.model,
|
|
126
|
+
ui: surface,
|
|
127
|
+
edge: c.edge,
|
|
128
|
+
vertex: c.edge, // Some components might expect vertex
|
|
129
|
+
...ov.props
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const holder: OverlayHolder = {
|
|
133
|
+
component: ov.component,
|
|
134
|
+
props: overlayProps,
|
|
135
|
+
edge: c.edge,
|
|
136
|
+
id: uuid(),
|
|
137
|
+
el
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
_overlays.push(holder);
|
|
141
|
+
_updateOverlayState();
|
|
142
|
+
return el;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return ov;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
84
153
|
function render ( id:string, data:ObjectData, model:BrowserUISvelteModel, type:string,
|
|
85
154
|
surface:Surface, def:any, modelObject:Vertex, eventInfo:any) {
|
|
86
155
|
|
|
@@ -179,7 +248,7 @@
|
|
|
179
248
|
};
|
|
180
249
|
|
|
181
250
|
const params = (renderOptions || {}) as SurfaceOptions;
|
|
182
|
-
params.view = viewOptions || {};
|
|
251
|
+
params.view = (viewOptions || {}) as any;
|
|
183
252
|
params.id = id;
|
|
184
253
|
|
|
185
254
|
if (shapeLibrary != null) {
|
|
@@ -188,6 +257,8 @@
|
|
|
188
257
|
};
|
|
189
258
|
}
|
|
190
259
|
|
|
260
|
+
_initialiseSvelteOverlays();
|
|
261
|
+
|
|
191
262
|
surface = renderSurface(model, container, templateRenderer, params);
|
|
192
263
|
|
|
193
264
|
// with continuous anchors it's necessary to do this, for
|
|
@@ -214,6 +285,8 @@
|
|
|
214
285
|
if (entry != null) {
|
|
215
286
|
entry.props.data = mergeData()
|
|
216
287
|
_updateVertexState()
|
|
288
|
+
|
|
289
|
+
entry.vertex.getAllEdges().forEach((edge:Edge) => updateOverlays(edge.id, {edge}))
|
|
217
290
|
}
|
|
218
291
|
}
|
|
219
292
|
|
|
@@ -238,15 +311,32 @@
|
|
|
238
311
|
removeVertex(p.group.id)
|
|
239
312
|
});
|
|
240
313
|
|
|
314
|
+
const updateOverlays = (edgeId: string, eventPayload: { edge:Edge } ) => {
|
|
315
|
+
_overlays.forEach(o => {
|
|
316
|
+
if (o.edge.id === edgeId) {
|
|
317
|
+
o.props.data = eventPayload.edge.data;
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
_updateOverlayState();
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const removeOverlays = (edgeId: string) => {
|
|
324
|
+
_overlays = _overlays.filter(o => o.edge.id !== edgeId);
|
|
325
|
+
_updateOverlayState();
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
model.bind<EdgeUpdatedParams>(EVENT_EDGE_UPDATED, (p) => updateOverlays(p.edge.id, p));
|
|
329
|
+
model.bind<EdgeRemovedParams>(EVENT_EDGE_REMOVED, (p) => removeOverlays(p.edge.id));
|
|
330
|
+
|
|
241
331
|
|
|
242
332
|
model.bind(EVENT_GRAPH_CLEARED, () => {
|
|
243
333
|
_vertices = []
|
|
244
334
|
_updateVertexState()
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
// _updateOverlayState()
|
|
335
|
+
_overlays = []
|
|
336
|
+
_updateOverlayState()
|
|
248
337
|
})
|
|
249
338
|
|
|
339
|
+
// TODO how can this be made reactive
|
|
250
340
|
if (url != null) {
|
|
251
341
|
model.load({ url });
|
|
252
342
|
} else if (data != null) {
|
|
@@ -264,7 +354,15 @@
|
|
|
264
354
|
def={vertex.def}
|
|
265
355
|
vertex={vertex.vertex}
|
|
266
356
|
className={vertex.props.className}/>
|
|
357
|
+
{/each}
|
|
267
358
|
|
|
359
|
+
{#each overlayState.overlays as overlay (overlay.id)}
|
|
360
|
+
<OverlayWrapperComponent component={overlay.component}
|
|
361
|
+
data={overlay.props.data}
|
|
362
|
+
ui={surface}
|
|
363
|
+
edge={overlay.edge}
|
|
364
|
+
className="vjs-svelte-overlay"
|
|
365
|
+
el={overlay.el}/>
|
|
268
366
|
{/each}
|
|
269
367
|
{@render children?.()}
|
|
270
368
|
</div>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {PopupHandler, type Vertex, CLASS_SURFACE_POPUP} from "@visuallyjs/browser-ui";
|
|
3
|
+
import {useSurface} from "./use-surface.svelte";
|
|
4
|
+
import type {SurfacePopupProps} from "./definitions";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
selector,
|
|
8
|
+
anchor,
|
|
9
|
+
popup
|
|
10
|
+
}:SurfacePopupProps = $props()
|
|
11
|
+
|
|
12
|
+
const surface = useSurface()
|
|
13
|
+
let container:HTMLElement
|
|
14
|
+
let initialized = false
|
|
15
|
+
|
|
16
|
+
let handler:PopupHandler
|
|
17
|
+
let current = $state<Vertex|null>(null)
|
|
18
|
+
let display = $derived(current == null ? "none" : "block")
|
|
19
|
+
|
|
20
|
+
function hide() {
|
|
21
|
+
handler?.$hide()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
$effect(() => {
|
|
25
|
+
if (!initialized && surface.current && container) {
|
|
26
|
+
initialized = true
|
|
27
|
+
handler = new PopupHandler(selector, container, surface.current, (v:Vertex|null) => current = v, anchor)
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<div bind:this={container} class={CLASS_SURFACE_POPUP} style:display={display} style:position="absolute">
|
|
34
|
+
{#if current != null && surface.current != null}
|
|
35
|
+
{@render popup(current, surface.current.model, surface.current, hide)}
|
|
36
|
+
{/if}
|
|
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/WrapperComponent.svelte
CHANGED
package/ambient.d.ts
ADDED
package/components.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* list of exported Svelte components.
|
|
3
3
|
*/
|
|
4
4
|
export { default as SurfaceComponent } from "./SurfaceComponent.svelte";
|
|
5
|
+
export { default as PaperComponent } from "./PaperComponent.svelte";
|
|
5
6
|
export { default as DiagramComponent } from "./DiagramComponent.svelte";
|
|
6
7
|
export { default as ControlsComponent } from "./ControlsComponent.svelte";
|
|
7
8
|
export { default as ExportControlsComponent } from "./ExportControlsComponent.svelte";
|
|
@@ -14,6 +15,7 @@ export { default as DiagramPaletteComponent } from "./DiagramPaletteComponent.sv
|
|
|
14
15
|
export { default as ShapeComponent } from "./ShapeComponent.svelte";
|
|
15
16
|
export { default as EdgeTypePickerComponent } from "./EdgeTypePickerComponent.svelte";
|
|
16
17
|
export { default as ColorPickerComponent } from "./ColorPickerComponent.svelte";
|
|
18
|
+
export { default as SurfacePopup } from "./SurfacePopup.svelte";
|
|
17
19
|
export { default as ColumnChartComponent } from "./ColumnChartComponent.svelte";
|
|
18
20
|
export { default as BarChartComponent } from "./BarChartComponent.svelte";
|
|
19
21
|
export { default as XYChartComponent } from "./XYChartComponent.svelte";
|
|
@@ -25,5 +27,10 @@ export { default as BubbleChartComponent } from "./BubbleChartComponent.svelte";
|
|
|
25
27
|
export { default as GaugeChartComponent } from "./GaugeChartComponent.svelte";
|
|
26
28
|
export { default as SankeyChartComponent } from "./SankeyChartComponent.svelte";
|
|
27
29
|
export { default as WrapperComponent } from "./WrapperComponent.svelte";
|
|
30
|
+
export { default as OverlayWrapperComponent } from "./OverlayWrapperComponent.svelte";
|
|
28
31
|
export { default as DiagramProvider } from "./DiagramProvider.svelte";
|
|
29
32
|
export { default as SurfaceProvider } from "./SurfaceProvider.svelte";
|
|
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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* list of exported Svelte components.
|
|
3
3
|
*/
|
|
4
4
|
export { default as SurfaceComponent } from "./SurfaceComponent.svelte";
|
|
5
|
+
export { default as PaperComponent } from "./PaperComponent.svelte";
|
|
5
6
|
export { default as DiagramComponent } from "./DiagramComponent.svelte";
|
|
6
7
|
export { default as ControlsComponent } from "./ControlsComponent.svelte";
|
|
7
8
|
export { default as ExportControlsComponent } from "./ExportControlsComponent.svelte";
|
|
@@ -14,6 +15,7 @@ export { default as DiagramPaletteComponent } from "./DiagramPaletteComponent.sv
|
|
|
14
15
|
export { default as ShapeComponent } from "./ShapeComponent.svelte";
|
|
15
16
|
export { default as EdgeTypePickerComponent } from "./EdgeTypePickerComponent.svelte";
|
|
16
17
|
export { default as ColorPickerComponent } from "./ColorPickerComponent.svelte";
|
|
18
|
+
export { default as SurfacePopup } from "./SurfacePopup.svelte";
|
|
17
19
|
export { default as ColumnChartComponent } from "./ColumnChartComponent.svelte";
|
|
18
20
|
export { default as BarChartComponent } from "./BarChartComponent.svelte";
|
|
19
21
|
export { default as XYChartComponent } from "./XYChartComponent.svelte";
|
|
@@ -25,5 +27,10 @@ export { default as BubbleChartComponent } from "./BubbleChartComponent.svelte";
|
|
|
25
27
|
export { default as GaugeChartComponent } from "./GaugeChartComponent.svelte";
|
|
26
28
|
export { default as SankeyChartComponent } from "./SankeyChartComponent.svelte";
|
|
27
29
|
export { default as WrapperComponent } from "./WrapperComponent.svelte";
|
|
30
|
+
export { default as OverlayWrapperComponent } from "./OverlayWrapperComponent.svelte";
|
|
28
31
|
export { default as DiagramProvider } from "./DiagramProvider.svelte";
|
|
29
32
|
export { default as SurfaceProvider } from "./SurfaceProvider.svelte";
|
|
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,11 +1,16 @@
|
|
|
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 } 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
|
*/
|
|
7
7
|
export interface SvelteSurfaceRenderOptions extends Omit<SurfaceOptions, "directRender" | "enhancedView" | "view" | "templates"> {
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Render options for a PaperComponent. This interface is the same as PaperOptions but with several vanilla-only options removed.
|
|
11
|
+
*/
|
|
12
|
+
export interface SveltePaperRenderOptions extends Omit<PaperOptions, "directRender" | "enhancedView" | "view" | "templates"> {
|
|
13
|
+
}
|
|
9
14
|
/**
|
|
10
15
|
* Definition of a node - its component, and behaviour.
|
|
11
16
|
*/
|
|
@@ -40,15 +45,23 @@ export type RefObject<T> = {
|
|
|
40
45
|
current: T | null;
|
|
41
46
|
};
|
|
42
47
|
/**
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
* Edge mappings for a view.
|
|
48
|
+
* Definition for an overlay when using Svelte components.
|
|
47
49
|
*/
|
|
50
|
+
export interface SvelteOverlaySpec {
|
|
51
|
+
/**
|
|
52
|
+
* Component used to render this overlay.
|
|
53
|
+
*/
|
|
54
|
+
component: any;
|
|
55
|
+
/**
|
|
56
|
+
* Props to pass to the component.
|
|
57
|
+
*/
|
|
58
|
+
props?: Record<string, any>;
|
|
59
|
+
}
|
|
48
60
|
/**
|
|
49
61
|
* Mapping definition for edges in a Svelte view.
|
|
50
62
|
*/
|
|
51
|
-
export interface SvelteEdgeMapping extends EdgeMapping {
|
|
63
|
+
export interface SvelteEdgeMapping extends Omit<EdgeMapping, "overlays"> {
|
|
64
|
+
overlays?: Array<OverlaySpec | SvelteOverlaySpec>;
|
|
52
65
|
}
|
|
53
66
|
/**
|
|
54
67
|
* Options for the view in the Svelte surface component. Maps node/group/port/edge types to components and behaviour.
|
|
@@ -71,6 +84,11 @@ export interface SvelteSurfaceViewOptions {
|
|
|
71
84
|
*/
|
|
72
85
|
edges?: Record<string, SvelteEdgeMapping>;
|
|
73
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Options for the view in the Svelte paper component. Maps node/group/port/edge types to components and behaviour.
|
|
89
|
+
*/
|
|
90
|
+
export interface SveltePaperViewOptions extends SvelteSurfaceViewOptions {
|
|
91
|
+
}
|
|
74
92
|
/**
|
|
75
93
|
* @group Props
|
|
76
94
|
*/
|
|
@@ -115,6 +133,56 @@ export interface SurfaceComponentProps extends DOMAttributes<HTMLDivElement> {
|
|
|
115
133
|
* Shape library to use to render SVG shapes. Optional.
|
|
116
134
|
*/
|
|
117
135
|
shapeLibrary?: ShapeLibraryImpl<ObjectData>;
|
|
136
|
+
/**
|
|
137
|
+
* An optional array of reactive objects. The properties from these objects will be
|
|
138
|
+
* merged into the props passed to each WrapperComponent, preserving reactivity.
|
|
139
|
+
*/
|
|
140
|
+
additionalProps?: Array<Record<string, any>>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @group Props
|
|
144
|
+
*/
|
|
145
|
+
export interface PaperComponentProps extends DOMAttributes<HTMLDivElement> {
|
|
146
|
+
/**
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
children?: Snippet;
|
|
150
|
+
/**
|
|
151
|
+
* Optional class name to set on the paper component's container
|
|
152
|
+
*/
|
|
153
|
+
className?: string;
|
|
154
|
+
/**
|
|
155
|
+
* Render options for the Paper.
|
|
156
|
+
*/
|
|
157
|
+
renderOptions?: SveltePaperRenderOptions;
|
|
158
|
+
/**
|
|
159
|
+
* View options for the Paper.
|
|
160
|
+
*/
|
|
161
|
+
viewOptions?: SveltePaperViewOptions;
|
|
162
|
+
/**
|
|
163
|
+
* Options for the underlying model instance.
|
|
164
|
+
*/
|
|
165
|
+
modelOptions?: ModelOptions;
|
|
166
|
+
/**
|
|
167
|
+
* Optional Visually JS instance to use. If this is not provided, a Visually JS instance will be created, with `modelOptions` if you provide them.
|
|
168
|
+
*/
|
|
169
|
+
model?: BrowserUIModel;
|
|
170
|
+
/**
|
|
171
|
+
* Optional function that is used to generate a set of props for a given vertex before rendering it. This provides a mechanism for you to inject specific items into the components you use to render your vertices. The return value of this function should be `Record<string, any>`. It may be null.
|
|
172
|
+
*/
|
|
173
|
+
injector?: (v: Vertex) => Record<string, any>;
|
|
174
|
+
/**
|
|
175
|
+
* Optional data to load after the component has been mounted.
|
|
176
|
+
*/
|
|
177
|
+
data?: any;
|
|
178
|
+
/**
|
|
179
|
+
* Optional url from which to load data after the component has been mounted. If you provide this and also data, this will take precedence.
|
|
180
|
+
*/
|
|
181
|
+
url?: string;
|
|
182
|
+
/**
|
|
183
|
+
* Shape library to use to render SVG shapes. Optional.
|
|
184
|
+
*/
|
|
185
|
+
shapeLibrary?: ShapeLibraryImpl<ObjectData>;
|
|
118
186
|
}
|
|
119
187
|
/**
|
|
120
188
|
* @group Props
|
|
@@ -461,6 +529,128 @@ export interface ExportControlsComponentProps extends DOMAttributes<HTMLDivEleme
|
|
|
461
529
|
*/
|
|
462
530
|
allowJpgExport?: boolean;
|
|
463
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
|
+
}
|
|
464
654
|
/**
|
|
465
655
|
* @group Props
|
|
466
656
|
*/
|
|
@@ -613,3 +803,21 @@ export interface DecoratorComponentProps extends DOMAttributes<HTMLDivElement> {
|
|
|
613
803
|
*/
|
|
614
804
|
children?: Snippet;
|
|
615
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* Props for the SurfacePopup component.
|
|
808
|
+
* @group Props
|
|
809
|
+
*/
|
|
810
|
+
export interface SurfacePopupProps {
|
|
811
|
+
/**
|
|
812
|
+
* CSS3 selector identifying elements from which this popup is launched.
|
|
813
|
+
*/
|
|
814
|
+
selector: string;
|
|
815
|
+
/**
|
|
816
|
+
* Optional position to place this popup. Defaults to "bottom", and can also be overridden on a per-launcher basis via a DOM attribute.
|
|
817
|
+
*/
|
|
818
|
+
anchor?: PopupPosition;
|
|
819
|
+
/**
|
|
820
|
+
* The snippet that renders the content for the popup.
|
|
821
|
+
*/
|
|
822
|
+
popup: Snippet<[Vertex | null, BrowserUIModel, BrowserUI, (() => any)]>;
|
|
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"}
|