@visuallyjs/browser-ui-svelte 1.1.4 → 1.2.1
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/AreaChartComponent.svelte +24 -15
- package/BarChartComponent.svelte +24 -12
- package/BubbleChartComponent.svelte +23 -11
- package/ColorPickerComponent.svelte +2 -2
- package/ColumnChartComponent.svelte +23 -11
- package/ControlsComponent.svelte +12 -34
- package/DecoratorComponent.svelte +15 -23
- package/DiagramComponent.svelte +2 -2
- package/DiagramPaletteComponent.svelte +24 -31
- package/DiagramProvider.svelte +3 -1
- package/EdgeTypePickerComponent.svelte +1 -1
- package/ExportControlsComponent.svelte +15 -33
- package/GaugeChartComponent.svelte +2 -7
- package/InspectorComponent.svelte +24 -36
- package/LineChartComponent.svelte +23 -13
- package/MiniviewComponent.svelte +28 -48
- package/OverlayWrapperComponent.svelte +35 -0
- package/PaletteComponent.svelte +28 -41
- package/PaperComponent.svelte +365 -0
- package/PaperProvider.svelte +11 -0
- package/PieChartComponent.svelte +23 -8
- package/SankeyChartComponent.svelte +35 -14
- package/ScatterChartComponent.svelte +23 -11
- package/ShapePaletteComponent.svelte +11 -22
- package/SurfaceComponent.svelte +100 -5
- package/SurfacePopup.svelte +32 -0
- package/SurfaceProvider.svelte +3 -1
- package/WrapperComponent.svelte +3 -1
- package/XYChartComponent.svelte +33 -12
- package/charts/definitions.d.ts +119 -0
- package/charts/definitions.js +1 -0
- package/components.d.ts +4 -0
- package/components.js +4 -0
- package/definitions.d.ts +111 -259
- package/diagram-store.d.ts +0 -5
- package/diagram-store.js +0 -15
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/package.json +1 -1
- package/surface-store.d.ts +19 -4
- package/surface-store.js +43 -12
- package/use-diagram.svelte.d.ts +8 -0
- package/use-diagram.svelte.js +18 -0
- package/use-surface.svelte.d.ts +7 -0
- package/use-surface.svelte.js +18 -0
- package/use-visuallyjs-update.svelte.d.ts +19 -0
- package/use-visuallyjs-update.svelte.js +37 -0
- package/use-zoom.svelte.d.ts +1 -3
- package/use-zoom.svelte.js +14 -11
|
@@ -5,13 +5,19 @@
|
|
|
5
5
|
import {type InspectorComponentProps} from "./definitions";
|
|
6
6
|
import {getInspectorContext} from "./inspector-store";
|
|
7
7
|
import {internal_getDiagramContext} from "./diagram-store";
|
|
8
|
+
import {useSurface} from "./use-surface.svelte";
|
|
9
|
+
import {useDiagram} from "./use-diagram.svelte";
|
|
8
10
|
|
|
9
11
|
let container:HTMLElement
|
|
10
12
|
let inspector:Inspector
|
|
11
|
-
let surface:Surface
|
|
12
|
-
let initialized = false
|
|
13
13
|
|
|
14
|
-
let
|
|
14
|
+
let initialised = false
|
|
15
|
+
const surface = useSurface()
|
|
16
|
+
const diagram = useDiagram()
|
|
17
|
+
const surfaceRef = $derived(surface.current || diagram.current?.$ui as Surface)
|
|
18
|
+
|
|
19
|
+
// let currentType:string|null = $state(null)
|
|
20
|
+
// let current:Base|null = $state(null)
|
|
15
21
|
|
|
16
22
|
let {
|
|
17
23
|
className = "",
|
|
@@ -19,27 +25,29 @@
|
|
|
19
25
|
multipleSelections = false,
|
|
20
26
|
filter,
|
|
21
27
|
refresh,
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
style = "",
|
|
29
|
+
current = $bindable(),
|
|
30
|
+
children
|
|
24
31
|
}:InspectorComponentProps = $props()
|
|
25
32
|
|
|
26
33
|
|
|
27
34
|
const _refresh = (obj:Base, cb:Function) => {
|
|
28
|
-
|
|
35
|
+
current = obj
|
|
36
|
+
// currentType = obj.objectType
|
|
29
37
|
refresh && refresh(obj)
|
|
30
38
|
setTimeout(cb)
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function _maybeInit() {
|
|
37
|
-
if (!initialized && surface != null && container != null) {
|
|
38
|
-
initialized = true
|
|
41
|
+
$effect(() => {
|
|
42
|
+
if (!initialised && surfaceRef != null && container != null) {
|
|
43
|
+
initialised = true
|
|
39
44
|
inspector = new Inspector({
|
|
40
45
|
container,
|
|
41
|
-
ui:
|
|
42
|
-
renderEmptyContainer:
|
|
46
|
+
ui:surfaceRef,
|
|
47
|
+
renderEmptyContainer:(() => {
|
|
48
|
+
// currentType = null
|
|
49
|
+
current = null
|
|
50
|
+
}),
|
|
43
51
|
refresh:_refresh,
|
|
44
52
|
autoCommit,
|
|
45
53
|
multipleSelections,
|
|
@@ -49,31 +57,11 @@
|
|
|
49
57
|
// set on the context
|
|
50
58
|
getInspectorContext(false).set(inspector)
|
|
51
59
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
onMount(async () => {
|
|
55
|
-
const sc = internal_getSurfaceContext(true)
|
|
56
|
-
if(sc != null) {
|
|
57
|
-
sc.listen(s => {
|
|
58
|
-
surface = s
|
|
59
|
-
_maybeInit()
|
|
60
|
-
})
|
|
61
|
-
} else {
|
|
62
|
-
const dc = internal_getDiagramContext(true)
|
|
63
|
-
if (dc != null) {
|
|
64
|
-
dc.listen(d => {
|
|
65
|
-
surface = d.$ui as Surface
|
|
66
|
-
_maybeInit()
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
log(`WARN: InspectorComponent did not find a Surface or Diagram context. Cannot mount.`)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
60
|
})
|
|
74
61
|
|
|
62
|
+
|
|
75
63
|
</script>
|
|
76
64
|
|
|
77
65
|
<div class={className} bind:this={container} style={style}>
|
|
78
|
-
|
|
66
|
+
{@render children?.()}
|
|
79
67
|
</div>
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
|
|
5
|
-
import {LineChart, type BrowserElement} from "@visuallyjs/browser-ui"
|
|
6
|
-
import {type LineChartComponentProps} from "./definitions";
|
|
5
|
+
import {LineChart, type BrowserElement, type LineChartOptions} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type LineChartComponentProps} from "./charts/definitions";
|
|
7
|
+
import {useVisuallyJsModel} from "./surface-store";
|
|
7
8
|
|
|
8
9
|
let container:BrowserElement;
|
|
9
10
|
|
|
10
|
-
// BarChartOptions
|
|
11
11
|
let {options, className = "", data, url, dataSourceFilter }:LineChartComponentProps = $props();
|
|
12
12
|
|
|
13
13
|
let chart:LineChart;
|
|
@@ -17,21 +17,31 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
$effect(() => {
|
|
20
|
-
if (chart) {
|
|
20
|
+
if (chart && dataSourceFilter != null) {
|
|
21
21
|
chart.setDataSourceFilter(dataSourceFilter)
|
|
22
22
|
}
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
function init(opts:LineChartOptions) {
|
|
26
|
+
chart = new LineChart(container, opts)
|
|
27
|
+
if (url != null) {
|
|
28
|
+
chart.load({url});
|
|
29
|
+
} else if (data != null) {
|
|
30
|
+
chart.load({data});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
onMount(async () => {
|
|
35
|
+
const opts:LineChartOptions = Object.assign({dataSourceFilter}, options)
|
|
36
|
+
if (url == null && data == null) {
|
|
37
|
+
useVisuallyJsModel().then(m => {
|
|
38
|
+
opts.dataSource = m
|
|
39
|
+
init(opts)
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
init(opts)
|
|
43
|
+
}
|
|
44
|
+
})
|
|
35
45
|
|
|
36
46
|
</script>
|
|
37
47
|
|
package/MiniviewComponent.svelte
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {type MiniviewComponentProps} from "./definitions";
|
|
8
|
-
import {internal_getDiagramContext} from "./diagram-store";
|
|
3
|
+
import {MiniviewPlugin, Surface} from "@visuallyjs/browser-ui"
|
|
4
|
+
import {type MiniviewComponentProps} from "./definitions";
|
|
5
|
+
import {useSurface} from "./use-surface.svelte";
|
|
6
|
+
import {useDiagram} from "./use-diagram.svelte";
|
|
9
7
|
|
|
10
8
|
let container:HTMLElement
|
|
11
|
-
|
|
9
|
+
|
|
12
10
|
let initialised = false
|
|
11
|
+
const surface = useSurface()
|
|
12
|
+
const diagram = useDiagram()
|
|
13
|
+
const surfaceRef = $derived(surface.current || diagram.current?.$ui as Surface)
|
|
13
14
|
|
|
14
15
|
let {
|
|
15
16
|
collapsible,
|
|
@@ -26,51 +27,30 @@
|
|
|
26
27
|
className = ""
|
|
27
28
|
}:MiniviewComponentProps = $props()
|
|
28
29
|
|
|
29
|
-
const sc = internal_getSurfaceContext(true)
|
|
30
|
-
if (sc != null) {
|
|
31
|
-
sc.listen(s => {
|
|
32
|
-
surface = s
|
|
33
|
-
_maybeInit()
|
|
34
|
-
})
|
|
35
|
-
} else {
|
|
36
|
-
const dc = internal_getDiagramContext(true)
|
|
37
|
-
if (dc != null) {
|
|
38
|
-
dc.listen(d => {
|
|
39
|
-
surface = d.$ui as Surface
|
|
40
|
-
_maybeInit()
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
log(`WARN: MiniviewComponent did not find a Surface or Diagram context. Cannot mount.`)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
30
|
|
|
48
|
-
|
|
49
|
-
if (!initialised &&
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
31
|
+
$effect(() => {
|
|
32
|
+
if (!initialised && container != null && surfaceRef != null) {
|
|
33
|
+
initialised = true
|
|
34
|
+
surfaceRef.addPlugin({
|
|
35
|
+
type:MiniviewPlugin.type,
|
|
36
|
+
options:{
|
|
54
37
|
collapsible,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
38
|
+
visible,
|
|
39
|
+
container,
|
|
40
|
+
typeFunction,
|
|
41
|
+
elementFilter,
|
|
42
|
+
wheelSensitivity,
|
|
43
|
+
wheelReverse,
|
|
44
|
+
enableWheelZoom,
|
|
45
|
+
activeTracking,
|
|
46
|
+
clickToCenter,
|
|
47
|
+
showLasso,
|
|
48
|
+
trackSelection
|
|
49
|
+
}
|
|
50
|
+
})
|
|
68
51
|
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
onMount(async () => {
|
|
72
|
-
_maybeInit()
|
|
73
52
|
})
|
|
53
|
+
|
|
74
54
|
</script>
|
|
75
55
|
<div bind:this={container} class={className}>
|
|
76
56
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
// This is a placeholder component that the surface uses to render each Svelte overlay,
|
|
4
|
+
// via a portal
|
|
5
|
+
import {type BrowserElement, BrowserUI} from "@visuallyjs/browser-ui";
|
|
6
|
+
|
|
7
|
+
let {component, edge, ui, data, className, el} = $props()
|
|
8
|
+
|
|
9
|
+
// svelte wants uppercase here. So we just assign to an uppercase var, which we use in the
|
|
10
|
+
// template
|
|
11
|
+
const ComponentToRender = component
|
|
12
|
+
|
|
13
|
+
// Define the portal action
|
|
14
|
+
function portal(node: BrowserElement, target: BrowserElement) {
|
|
15
|
+
if (!target) return; // Ensure target exists
|
|
16
|
+
|
|
17
|
+
target.appendChild(node);
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
destroy() {
|
|
21
|
+
if (target.contains(node)) {
|
|
22
|
+
target.removeChild(node);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const _ui = $state.raw(ui) as BrowserUI
|
|
29
|
+
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<!-- Use the portal action on the root div -->
|
|
33
|
+
<div use:portal={el} class={className}>
|
|
34
|
+
<ComponentToRender this={component} data={data} ui={_ui} edge={edge} model={_ui.model}/>
|
|
35
|
+
</div>
|
package/PaletteComponent.svelte
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {internal_getSurfaceContext} from "./surface-store";
|
|
6
|
-
import {log, Palette, Surface} from "@visuallyjs/browser-ui"
|
|
3
|
+
import {Palette, Surface} from "@visuallyjs/browser-ui"
|
|
7
4
|
import {type PaletteComponentProps} from "./definitions";
|
|
5
|
+
import {useSurface} from "./use-surface.svelte";
|
|
6
|
+
import {useDiagram} from "./use-diagram.svelte";
|
|
8
7
|
|
|
9
8
|
let container:HTMLElement
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
let initialised = false
|
|
10
|
+
const surface = useSurface()
|
|
11
|
+
const diagram = useDiagram()
|
|
12
|
+
const surfaceRef = $derived(surface.current || diagram.current?.$ui as Surface)
|
|
12
13
|
|
|
13
14
|
let {
|
|
14
15
|
selector = "[data-vjs-type]",
|
|
@@ -29,42 +30,28 @@
|
|
|
29
30
|
ignoreDropOnNode = false
|
|
30
31
|
}:PaletteComponentProps = $props()
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
clickToAddOnly,
|
|
54
|
-
dragSize,
|
|
55
|
-
canvasDropFilter,
|
|
56
|
-
mode,
|
|
57
|
-
allowDropOnNode,
|
|
58
|
-
allowDropOnEdge,
|
|
59
|
-
allowDropOnCanvas,
|
|
60
|
-
allowDropOnGroup,
|
|
61
|
-
ignoreDropOnNode
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
}
|
|
33
|
+
$effect(() => {
|
|
34
|
+
if (!initialised && container != null && surfaceRef != null) {
|
|
35
|
+
initialised = true
|
|
36
|
+
new Palette(surfaceRef, {
|
|
37
|
+
source:container,
|
|
38
|
+
selector,
|
|
39
|
+
dataGenerator,
|
|
40
|
+
onVertexAdded,
|
|
41
|
+
selectAfterAdd,
|
|
42
|
+
allowClickToAdd,
|
|
43
|
+
clickToAddOnly,
|
|
44
|
+
dragSize,
|
|
45
|
+
canvasDropFilter,
|
|
46
|
+
mode,
|
|
47
|
+
allowDropOnNode,
|
|
48
|
+
allowDropOnEdge,
|
|
49
|
+
allowDropOnCanvas,
|
|
50
|
+
allowDropOnGroup,
|
|
51
|
+
ignoreDropOnNode
|
|
52
|
+
})
|
|
53
|
+
}
|
|
65
54
|
|
|
66
|
-
onMount(async () => {
|
|
67
|
-
_maybeInit()
|
|
68
55
|
})
|
|
69
56
|
|
|
70
57
|
</script>
|