@visuallyjs/browser-ui-svelte 1.2.4 → 1.2.6
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/DiagramPaletteComponent.svelte +8 -4
- package/PaletteComponent.svelte +8 -2
- package/PaperComponent.svelte +26 -10
- package/ShapeComponent.svelte +1 -0
- package/ShapePaletteComponent.svelte +14 -3
- package/SurfaceComponent.svelte +24 -11
- package/definitions.d.ts +75 -5
- package/package.json +1 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
|
|
3
3
|
import {type DiagramPaletteProps} from "./definitions";
|
|
4
|
-
import {
|
|
5
|
-
import {internal_getDiagramContext} from "./diagram-store";
|
|
6
|
-
import {onMount} from "svelte";
|
|
4
|
+
import {DiagramPalette} from "@visuallyjs/browser-ui";
|
|
7
5
|
import {useDiagram} from "./use-diagram.svelte";
|
|
8
6
|
|
|
9
7
|
let initialised = false
|
|
@@ -30,7 +28,13 @@
|
|
|
30
28
|
autoExitDrawMode:props.autoExitDrawMode,
|
|
31
29
|
selectAfterAdd:props.selectAfterAdd,
|
|
32
30
|
onVertexAdded:props.onVertexAdded,
|
|
33
|
-
preparedShapes:props.preparedShapes
|
|
31
|
+
preparedShapes:props.preparedShapes,
|
|
32
|
+
allowDropOnEdge:props.allowDropOnEdge,
|
|
33
|
+
allowRotation:props.allowRotation,
|
|
34
|
+
rotationSpeed:props.rotationSpeed,
|
|
35
|
+
autoEdgeConnect:props.autoEdgeConnect,
|
|
36
|
+
showGroups:props.showGroups !== false,
|
|
37
|
+
updateTypeOnPaletteTap:props.updateTypeOnPaletteTap
|
|
34
38
|
})
|
|
35
39
|
}
|
|
36
40
|
})
|
package/PaletteComponent.svelte
CHANGED
|
@@ -27,7 +27,10 @@
|
|
|
27
27
|
allowDropOnGroup = true,
|
|
28
28
|
allowDropOnCanvas = true,
|
|
29
29
|
allowDropOnNode = false,
|
|
30
|
-
ignoreDropOnNode = false
|
|
30
|
+
ignoreDropOnNode = false,
|
|
31
|
+
allowRotation = true,
|
|
32
|
+
rotationSpeed = 2000,
|
|
33
|
+
autoEdgeConnect = false
|
|
31
34
|
}:PaletteComponentProps = $props()
|
|
32
35
|
|
|
33
36
|
$effect(() => {
|
|
@@ -48,7 +51,10 @@
|
|
|
48
51
|
allowDropOnEdge,
|
|
49
52
|
allowDropOnCanvas,
|
|
50
53
|
allowDropOnGroup,
|
|
51
|
-
ignoreDropOnNode
|
|
54
|
+
ignoreDropOnNode,
|
|
55
|
+
allowRotation,
|
|
56
|
+
rotationSpeed,
|
|
57
|
+
autoEdgeConnect
|
|
52
58
|
})
|
|
53
59
|
}
|
|
54
60
|
|
package/PaperComponent.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { onMount, type Snippet } from "svelte";
|
|
2
|
+
import { onMount, untrack, type Snippet } from "svelte";
|
|
3
3
|
import {
|
|
4
4
|
BrowserUISvelteModel,
|
|
5
5
|
newInstance,
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
|
|
56
56
|
const paperContext = internal_getPaperContext(false);
|
|
57
57
|
|
|
58
|
-
let paper
|
|
58
|
+
let paper = $state<Paper>();
|
|
59
59
|
|
|
60
60
|
export function getPaper() {
|
|
61
61
|
return paper
|
|
@@ -201,6 +201,30 @@
|
|
|
201
201
|
el.parentNode && el.parentNode.removeChild(el);
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
$effect(() => {
|
|
205
|
+
if (url != null && paper != null) {
|
|
206
|
+
untrack(() => {
|
|
207
|
+
paper.model.clear();
|
|
208
|
+
requestAnimationFrame(() => {
|
|
209
|
+
paper.model.load({ url, dataType });
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
$effect(() => {
|
|
217
|
+
if (data != null && paper != null) {
|
|
218
|
+
untrack(() => {
|
|
219
|
+
paper.model.clear();
|
|
220
|
+
requestAnimationFrame(() => {
|
|
221
|
+
paper.model.load({ data, dataType });
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
204
228
|
onMount(async () => {
|
|
205
229
|
model = model || newInstance(modelOptions || {});
|
|
206
230
|
|
|
@@ -336,14 +360,6 @@
|
|
|
336
360
|
_overlays = []
|
|
337
361
|
_updateOverlayState()
|
|
338
362
|
})
|
|
339
|
-
|
|
340
|
-
$effect(() => {
|
|
341
|
-
if (url != null && model != null) {
|
|
342
|
-
model.load({ url, dataType });
|
|
343
|
-
} else if (data != null && model != null) {
|
|
344
|
-
model.load({ data, dataType });
|
|
345
|
-
}
|
|
346
|
-
})
|
|
347
363
|
});
|
|
348
364
|
|
|
349
365
|
</script>
|
package/ShapeComponent.svelte
CHANGED
|
@@ -22,7 +22,13 @@
|
|
|
22
22
|
allowClickToAdd,
|
|
23
23
|
autoExitDrawMode,
|
|
24
24
|
inspector = true,
|
|
25
|
-
|
|
25
|
+
updateTypeOnPaletteTap = false,
|
|
26
|
+
preparedShapes,
|
|
27
|
+
allowDropOnEdge,
|
|
28
|
+
allowRotation = true,
|
|
29
|
+
rotationSpeed = 2000,
|
|
30
|
+
autoEdgeConnect,
|
|
31
|
+
showGroups = true
|
|
26
32
|
}:ShapePaletteComponentProps = $props()
|
|
27
33
|
|
|
28
34
|
let container:HTMLElement
|
|
@@ -57,8 +63,13 @@
|
|
|
57
63
|
fill,
|
|
58
64
|
dragSize,
|
|
59
65
|
inspector,
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
updateTypeOnPaletteTap,
|
|
67
|
+
preparedShapes,
|
|
68
|
+
allowDropOnEdge,
|
|
69
|
+
allowRotation,
|
|
70
|
+
rotationSpeed,
|
|
71
|
+
autoEdgeConnect,
|
|
72
|
+
showGroups
|
|
62
73
|
})
|
|
63
74
|
|
|
64
75
|
}
|
package/SurfaceComponent.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import {onMount, type Snippet, untrack} from "svelte";
|
|
3
3
|
import {
|
|
4
4
|
BrowserUISvelteModel, internal_createDiagramContext,
|
|
5
5
|
newInstance,
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
|
|
56
56
|
const surfaceContext = internal_getSurfaceContext(false);
|
|
57
57
|
|
|
58
|
-
let surface
|
|
58
|
+
let surface = $state<Surface>();
|
|
59
59
|
|
|
60
60
|
export function getSurface() {
|
|
61
61
|
return surface
|
|
@@ -201,6 +201,28 @@
|
|
|
201
201
|
el.parentNode && el.parentNode.removeChild(el);
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
$effect(() => {
|
|
205
|
+
if (url != null && surface != null) {
|
|
206
|
+
untrack(() => {
|
|
207
|
+
surface.model.clear();
|
|
208
|
+
requestAnimationFrame(() => {
|
|
209
|
+
surface.model.load({url, dataType});
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
$effect(() => {
|
|
216
|
+
if (data != null && surface != null) {
|
|
217
|
+
untrack(() => {
|
|
218
|
+
surface.model.clear();
|
|
219
|
+
requestAnimationFrame(() => {
|
|
220
|
+
surface.model.load({data, dataType});
|
|
221
|
+
})
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
204
226
|
onMount(async () => {
|
|
205
227
|
model = model || newInstance(modelOptions || {});
|
|
206
228
|
|
|
@@ -329,7 +351,6 @@
|
|
|
329
351
|
model.bind<EdgeUpdatedParams>(EVENT_EDGE_UPDATED, (p) => updateOverlays(p.edge.id, p));
|
|
330
352
|
model.bind<EdgeRemovedParams>(EVENT_EDGE_REMOVED, (p) => removeOverlays(p.edge.id));
|
|
331
353
|
|
|
332
|
-
|
|
333
354
|
model.bind(EVENT_GRAPH_CLEARED, () => {
|
|
334
355
|
_vertices = []
|
|
335
356
|
_updateVertexState()
|
|
@@ -337,14 +358,6 @@
|
|
|
337
358
|
_updateOverlayState()
|
|
338
359
|
})
|
|
339
360
|
|
|
340
|
-
// TODO how can this be made reactive
|
|
341
|
-
$effect(() => {
|
|
342
|
-
if (url != null && model != null) {
|
|
343
|
-
model.load({ url, dataType });
|
|
344
|
-
} else if (data != null && model != null) {
|
|
345
|
-
model.load({ data, dataType });
|
|
346
|
-
}
|
|
347
|
-
})
|
|
348
361
|
});
|
|
349
362
|
|
|
350
363
|
</script>
|
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,
|
|
3
|
+
import { SurfaceOptions, Vertex, Group, Node, ControlsComponentButtons, DataGeneratorFunction, type BrowserElement, Base, Size, ObjectData, PaletteMode, SvgExportUIOptions, ImageExportUIOptions, ShapeLibraryImpl, ModelOptions, DiagramOptions, Diagram, DiagramCell, NodeMapping, GroupMapping, PortMapping, BrowserUI, EdgeMapping, OnVertexAddedCallback, CanvasDropFilter, FontSpec, BrowserUIModel, PreparedShape, PointXY, FixedElementConstraints, PopupPosition, OverlaySpec, PaperOptions, TilingStrategy, type GridType, Grid, type AutoEdgeConnectOptions, CanDropOnEdgeFilter, LabelPosition } 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
|
*/
|
|
@@ -334,7 +334,7 @@ export interface PaletteComponentProps extends DOMAttributes<HTMLDivElement> {
|
|
|
334
334
|
/**
|
|
335
335
|
* Whether or not to allow drop on edge. Defaults to false.
|
|
336
336
|
*/
|
|
337
|
-
allowDropOnEdge?: boolean
|
|
337
|
+
allowDropOnEdge?: boolean | CanDropOnEdgeFilter<any>;
|
|
338
338
|
/**
|
|
339
339
|
* Whether or not to allow drop on whitespace in the canvas. Defaults to true.
|
|
340
340
|
*/
|
|
@@ -351,6 +351,22 @@ export interface PaletteComponentProps extends DOMAttributes<HTMLDivElement> {
|
|
|
351
351
|
* Defaults to false. When true, the palette treats nodes as if they are part of the canvas - a user can drag new items on top of existing nodes and the new item will be added to the canvas. If you want to force your users to drop on canvas whitespace, don't set this. Note that this flag will force `allowDropOnNode` to `false`.
|
|
352
352
|
*/
|
|
353
353
|
ignoreDropOnNode?: boolean;
|
|
354
|
+
/**
|
|
355
|
+
* Whether or not to allow rotation of elements being dragged. Defaults to true.
|
|
356
|
+
*/
|
|
357
|
+
allowRotation?: boolean;
|
|
358
|
+
/**
|
|
359
|
+
* The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
|
|
360
|
+
*/
|
|
361
|
+
rotationSpeed?: number;
|
|
362
|
+
/**
|
|
363
|
+
* Controls whether the palette will automatically connect a new vertex being dragged onto the canvas to existing vertices, if the shape definitions for the new vertex and/or the existing vertices have source/target elements. You can set this to simply 'true', and use defaults, or you can provide values for various options.
|
|
364
|
+
*/
|
|
365
|
+
autoEdgeConnect?: boolean | AutoEdgeConnectOptions;
|
|
366
|
+
/**
|
|
367
|
+
* Whether or not to show groups in the palette. Defaults to true.
|
|
368
|
+
*/
|
|
369
|
+
showGroups?: boolean;
|
|
354
370
|
}
|
|
355
371
|
/**
|
|
356
372
|
* @group Props
|
|
@@ -444,7 +460,7 @@ export interface ShapePaletteComponentProps extends DOMAttributes<HTMLDivElement
|
|
|
444
460
|
* @param v
|
|
445
461
|
* @param dropTarget
|
|
446
462
|
*/
|
|
447
|
-
onVertexAdded?:
|
|
463
|
+
onVertexAdded?: OnVertexAddedCallback;
|
|
448
464
|
/**
|
|
449
465
|
* Mode to operate in - 'drag' or 'tap'. Defaults to 'drag' (DROP_MANAGER_MODE_DRAG).
|
|
450
466
|
*/
|
|
@@ -458,13 +474,38 @@ export interface ShapePaletteComponentProps extends DOMAttributes<HTMLDivElement
|
|
|
458
474
|
*/
|
|
459
475
|
autoExitDrawMode?: boolean;
|
|
460
476
|
/**
|
|
461
|
-
*
|
|
477
|
+
* When `true`, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
|
|
462
478
|
*/
|
|
463
479
|
inspector?: boolean;
|
|
480
|
+
/**
|
|
481
|
+
* When `true`, clicking on an entry in the palette will change the type of any selected vertices to that type. Defaults to `false`.
|
|
482
|
+
* This is a potentially destructive operation if the properties of the new shape type are not compatible with the old one.
|
|
483
|
+
*/
|
|
484
|
+
updateTypeOnPaletteTap?: boolean;
|
|
464
485
|
/**
|
|
465
486
|
* Optional set of prepared shapes to show in the palette. When this is provided, the palette will only render these shapes, and not the contents of the shape library.
|
|
466
487
|
*/
|
|
467
488
|
preparedShapes?: Array<PreparedShape>;
|
|
489
|
+
/**
|
|
490
|
+
* Whether or not to allow drop on edge. Defaults to false.
|
|
491
|
+
*/
|
|
492
|
+
allowDropOnEdge?: boolean | CanDropOnEdgeFilter<any>;
|
|
493
|
+
/**
|
|
494
|
+
* Whether or not to allow rotation of elements being dragged. Defaults to true.
|
|
495
|
+
*/
|
|
496
|
+
allowRotation?: boolean;
|
|
497
|
+
/**
|
|
498
|
+
* The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
|
|
499
|
+
*/
|
|
500
|
+
rotationSpeed?: number;
|
|
501
|
+
/**
|
|
502
|
+
* Controls whether the palette will automatically connect a new vertex being dragged onto the canvas to existing vertices, if the shape definitions for the new vertex and/or the existing vertices have source/target elements. You can set this to simply 'true', and use defaults, or you can provide values for various options.
|
|
503
|
+
*/
|
|
504
|
+
autoEdgeConnect?: boolean | AutoEdgeConnectOptions;
|
|
505
|
+
/**
|
|
506
|
+
* Whether or not to show groups in the palette. Defaults to true.
|
|
507
|
+
*/
|
|
508
|
+
showGroups?: boolean;
|
|
468
509
|
}
|
|
469
510
|
/**
|
|
470
511
|
* @group Props
|
|
@@ -486,6 +527,10 @@ export interface ShapeComponentProps extends DOMAttributes<HTMLDivElement> {
|
|
|
486
527
|
* Stroke width to use on the text element rendering a label. Defaults to "0.25px".
|
|
487
528
|
*/
|
|
488
529
|
labelStrokeWidth: string;
|
|
530
|
+
/**
|
|
531
|
+
* Defaults to "center". Use "top" or "bottom" to set the label above or below the shape.
|
|
532
|
+
*/
|
|
533
|
+
labelPosition?: LabelPosition;
|
|
489
534
|
/**
|
|
490
535
|
* Optional font size/style.
|
|
491
536
|
*/
|
|
@@ -707,9 +752,14 @@ export interface DiagramPaletteProps extends DOMAttributes<HTMLDivElement> {
|
|
|
707
752
|
*/
|
|
708
753
|
dragSize?: Size;
|
|
709
754
|
/**
|
|
710
|
-
*
|
|
755
|
+
* When `true`, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
|
|
711
756
|
*/
|
|
712
757
|
inspector?: boolean;
|
|
758
|
+
/**
|
|
759
|
+
* When `true`, clicking on an entry in the palette will change the type of any selected vertices to that type. Defaults to `false`.
|
|
760
|
+
* This is a potentially destructive operation if the properties of the new shape type are not compatible with the old one.
|
|
761
|
+
*/
|
|
762
|
+
updateTypeOnPaletteTap?: boolean;
|
|
713
763
|
/**
|
|
714
764
|
* Optional size to use for icons. Defaults to 150x100 pixels. If you provide this but not `dragSize` this size will also be used for an icon that is being dragged.
|
|
715
765
|
*/
|
|
@@ -764,6 +814,26 @@ export interface DiagramPaletteProps extends DOMAttributes<HTMLDivElement> {
|
|
|
764
814
|
* Optional set of prepared shapes to show in the palette. When this is provided, the palette will only render these shapes, and not the contents of the shape library.
|
|
765
815
|
*/
|
|
766
816
|
preparedShapes?: Array<PreparedShape>;
|
|
817
|
+
/**
|
|
818
|
+
* Whether or not to allow drop on edge. Defaults to false.
|
|
819
|
+
*/
|
|
820
|
+
allowDropOnEdge?: boolean | CanDropOnEdgeFilter<any>;
|
|
821
|
+
/**
|
|
822
|
+
* Whether or not to allow rotation of elements being dragged. Defaults to true.
|
|
823
|
+
*/
|
|
824
|
+
allowRotation?: boolean;
|
|
825
|
+
/**
|
|
826
|
+
* The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
|
|
827
|
+
*/
|
|
828
|
+
rotationSpeed?: number;
|
|
829
|
+
/**
|
|
830
|
+
* Controls whether the palette will automatically connect a new vertex being dragged onto the canvas to existing vertices, if the shape definitions for the new vertex and/or the existing vertices have source/target elements. You can set this to simply 'true', and use defaults, or you can provide values for various options.
|
|
831
|
+
*/
|
|
832
|
+
autoEdgeConnect?: boolean | AutoEdgeConnectOptions;
|
|
833
|
+
/**
|
|
834
|
+
* Whether or not to show groups in the palette. Defaults to true.
|
|
835
|
+
*/
|
|
836
|
+
showGroups?: boolean;
|
|
767
837
|
}
|
|
768
838
|
/**
|
|
769
839
|
* Props for the ColorPicker inspector component.
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@visuallyjs/browser-ui-svelte","version":"1.2.
|
|
1
|
+
{"name":"@visuallyjs/browser-ui-svelte","version":"1.2.6","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.6"},"homepage":"https://visuallyjs.com/svelte","bugs":"https://github.com/visuallyjs/visuallyjs/issues"}
|