@visuallyjs/browser-ui-svelte 1.1.3 → 1.2.0
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/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/ExportControlsComponent.svelte +15 -33
- package/GaugeChartComponent.svelte +2 -7
- package/InspectorComponent.svelte +24 -36
- package/LineChartComponent.svelte +23 -13
- package/MiniviewComponent.svelte +30 -46
- package/PaletteComponent.svelte +28 -41
- package/PieChartComponent.svelte +23 -8
- package/SankeyChartComponent.svelte +35 -14
- package/ScatterChartComponent.svelte +23 -11
- package/ShapePaletteComponent.svelte +11 -22
- package/SurfaceProvider.svelte +3 -1
- package/XYChartComponent.svelte +33 -12
- package/charts/definitions.d.ts +119 -0
- package/charts/definitions.js +1 -0
- package/definitions.d.ts +30 -256
- 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 +0 -5
- package/surface-store.js +5 -15
- 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
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
|
|
5
|
-
import {AreaChart, type BrowserElement} from "@visuallyjs/browser-ui"
|
|
6
|
-
import {type AreaChartComponentProps} from "./definitions";
|
|
5
|
+
import {AreaChart, type AreaChartOptions, type BrowserElement} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type AreaChartComponentProps} from "./charts/definitions";
|
|
7
|
+
import {useVisuallyJsModel} from "./surface-store";
|
|
7
8
|
|
|
8
9
|
let container:BrowserElement;
|
|
9
10
|
|
|
@@ -11,25 +12,33 @@
|
|
|
11
12
|
|
|
12
13
|
let chart:AreaChart;
|
|
13
14
|
|
|
14
|
-
export function getChart() {
|
|
15
|
-
return chart;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
15
|
$effect(() => {
|
|
19
16
|
if (chart) {
|
|
20
|
-
|
|
17
|
+
if (dataSourceFilter != null) {
|
|
18
|
+
chart.setDataSourceFilter(dataSourceFilter)
|
|
19
|
+
}
|
|
21
20
|
}
|
|
22
21
|
})
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
function init(opts:AreaChartOptions) {
|
|
24
|
+
chart = new AreaChart(container, opts)
|
|
25
|
+
if (url != null) {
|
|
26
|
+
chart.load({url});
|
|
27
|
+
} else if (data != null) {
|
|
28
|
+
chart.load({data});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
onMount(async () => {
|
|
33
|
+
const opts:AreaChartOptions = Object.assign({dataSourceFilter}, options)
|
|
34
|
+
if (url == null && data == null) {
|
|
35
|
+
useVisuallyJsModel().then(m => {
|
|
36
|
+
opts.dataSource = m
|
|
37
|
+
init(opts)
|
|
38
|
+
})
|
|
39
|
+
} else {
|
|
40
|
+
init(opts)
|
|
41
|
+
}
|
|
33
42
|
})
|
|
34
43
|
|
|
35
44
|
</script>
|
package/BarChartComponent.svelte
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
|
|
5
|
-
import {BarChart, type BrowserElement} from "@visuallyjs/browser-ui"
|
|
6
|
-
import {type BarChartComponentProps} from "./definitions";
|
|
5
|
+
import {type BarChartOptions, BarChart, type BrowserElement} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type BarChartComponentProps} from "./charts/definitions";
|
|
7
|
+
import {useVisuallyJsModel} from "./surface-store";
|
|
7
8
|
|
|
8
9
|
let container:BrowserElement;
|
|
9
10
|
|
|
@@ -16,21 +17,32 @@
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
$effect(() => {
|
|
19
|
-
if (chart) {
|
|
20
|
+
if (chart && dataSourceFilter != null) {
|
|
20
21
|
chart.setDataSourceFilter(dataSourceFilter)
|
|
21
22
|
}
|
|
22
|
-
})
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
})
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
function init(opts:BarChartOptions) {
|
|
27
|
+
chart = new BarChart(container, opts)
|
|
28
|
+
if (url != null) {
|
|
29
|
+
chart.load({url});
|
|
30
|
+
} else if (data != null) {
|
|
31
|
+
chart.load({data});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
onMount(async () => {
|
|
36
|
+
const opts:BarChartOptions = Object.assign({dataSourceFilter}, options)
|
|
37
|
+
if (url == null && data == null) {
|
|
38
|
+
useVisuallyJsModel().then(m => {
|
|
39
|
+
opts.dataSource = m
|
|
40
|
+
init(opts)
|
|
41
|
+
})
|
|
42
|
+
} else {
|
|
43
|
+
init(opts)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
34
46
|
|
|
35
47
|
</script>
|
|
36
48
|
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
|
|
5
|
-
import {type BrowserElement, BubbleChart} from "@visuallyjs/browser-ui"
|
|
6
|
-
import {type BubbleChartComponentProps} from "./definitions";
|
|
5
|
+
import {type BubbleChartOptions, type BrowserElement, BubbleChart} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type BubbleChartComponentProps} from "./charts/definitions";
|
|
7
|
+
import {useVisuallyJsModel} from "./surface-store";
|
|
7
8
|
|
|
8
9
|
let container:BrowserElement;
|
|
9
10
|
|
|
@@ -17,21 +18,32 @@
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
$effect(() => {
|
|
20
|
-
if (chart) {
|
|
21
|
+
if (chart && dataSourceFilter != null) {
|
|
21
22
|
chart.setDataSourceFilter(dataSourceFilter)
|
|
22
23
|
}
|
|
23
24
|
})
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
function init(opts:BubbleChartOptions) {
|
|
27
|
+
chart = new BubbleChart(container, opts)
|
|
28
|
+
if (url != null) {
|
|
29
|
+
chart.load({url});
|
|
30
|
+
} else if (data != null) {
|
|
31
|
+
chart.load({data});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
26
34
|
|
|
27
|
-
|
|
35
|
+
onMount(async () => {
|
|
36
|
+
const opts:BubbleChartOptions = Object.assign({dataSourceFilter}, options)
|
|
37
|
+
if (url == null && data == null) {
|
|
38
|
+
useVisuallyJsModel().then(m => {
|
|
39
|
+
opts.dataSource = m
|
|
40
|
+
init(opts)
|
|
41
|
+
})
|
|
42
|
+
} else {
|
|
43
|
+
init(opts)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
28
46
|
|
|
29
|
-
if (url != null) {
|
|
30
|
-
chart.load({url});
|
|
31
|
-
} else if (data != null) {
|
|
32
|
-
chart.load({data});
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
47
|
|
|
36
48
|
</script>
|
|
37
49
|
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
|
|
5
|
-
import {type BrowserElement, ColumnChart} from "@visuallyjs/browser-ui"
|
|
6
|
-
import {type ColumnChartComponentProps} from "./definitions";
|
|
5
|
+
import {type BrowserElement, type ColumnChartOptions, ColumnChart} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type ColumnChartComponentProps} from "./charts/definitions";
|
|
7
|
+
import {useVisuallyJsModel} from "./surface-store";
|
|
7
8
|
|
|
8
9
|
let container:BrowserElement;
|
|
9
10
|
|
|
@@ -17,21 +18,32 @@
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
$effect(() => {
|
|
20
|
-
if (chart) {
|
|
21
|
+
if (chart && dataSourceFilter != null) {
|
|
21
22
|
chart.setDataSourceFilter(dataSourceFilter)
|
|
22
23
|
}
|
|
23
24
|
})
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
function init(opts:ColumnChartOptions) {
|
|
27
|
+
chart = new ColumnChart(container, opts)
|
|
28
|
+
if (url != null) {
|
|
29
|
+
chart.load({url});
|
|
30
|
+
} else if (data != null) {
|
|
31
|
+
chart.load({data});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
26
34
|
|
|
27
|
-
|
|
35
|
+
onMount(async () => {
|
|
36
|
+
const opts:ColumnChartOptions = Object.assign({dataSourceFilter}, options)
|
|
37
|
+
if (url == null && data == null) {
|
|
38
|
+
useVisuallyJsModel().then(m => {
|
|
39
|
+
opts.dataSource = m
|
|
40
|
+
init(opts)
|
|
41
|
+
})
|
|
42
|
+
} else {
|
|
43
|
+
init(opts)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
28
46
|
|
|
29
|
-
if (url != null) {
|
|
30
|
-
chart.load({url});
|
|
31
|
-
} else if (data != null) {
|
|
32
|
-
chart.load({data});
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
47
|
|
|
36
48
|
</script>
|
|
37
49
|
|
package/ControlsComponent.svelte
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {type ControlsComponentProps} from "./definitions";
|
|
8
|
-
import {internal_getDiagramContext} from "./diagram-store";
|
|
3
|
+
import {type BrowserElement, ControlsComponent, Surface} from "@visuallyjs/browser-ui"
|
|
4
|
+
import {type ControlsComponentProps} from "./definitions";
|
|
5
|
+
import {useSurface} from "./use-surface.svelte";
|
|
6
|
+
import {useDiagram} from "./use-diagram.svelte";
|
|
9
7
|
|
|
10
8
|
let container:BrowserElement
|
|
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
|
clear,
|
|
@@ -21,26 +22,6 @@
|
|
|
21
22
|
className = ""
|
|
22
23
|
}:ControlsComponentProps = $props()
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
const sc = internal_getSurfaceContext(true)
|
|
26
|
-
if (sc != null) {
|
|
27
|
-
sc.listen(s => {
|
|
28
|
-
surface = s
|
|
29
|
-
_maybeInit()
|
|
30
|
-
})
|
|
31
|
-
} else {
|
|
32
|
-
const dc = internal_getDiagramContext(true)
|
|
33
|
-
if (dc != null) {
|
|
34
|
-
dc.listen(d => {
|
|
35
|
-
surface = d.$ui as Surface
|
|
36
|
-
_maybeInit()
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
log(`WARN: ControlsComponent did not find a Surface or Diagram context. Cannot mount.`)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
25
|
const options = {
|
|
45
26
|
clear:clear !== false,
|
|
46
27
|
undoRedo:undoRedo !== false,
|
|
@@ -50,16 +31,13 @@
|
|
|
50
31
|
orientation
|
|
51
32
|
}
|
|
52
33
|
|
|
53
|
-
|
|
54
|
-
if (!initialised &&
|
|
34
|
+
$effect(() => {
|
|
35
|
+
if (!initialised && container != null && surfaceRef != null) {
|
|
55
36
|
initialised = true
|
|
56
|
-
new ControlsComponent(container,
|
|
37
|
+
new ControlsComponent(container, surfaceRef, options)
|
|
57
38
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
onMount(async () => {
|
|
61
|
-
_maybeInit()
|
|
62
39
|
})
|
|
40
|
+
|
|
63
41
|
</script>
|
|
64
42
|
<div bind:this={container} class={className}>
|
|
65
43
|
|
|
@@ -3,53 +3,45 @@
|
|
|
3
3
|
import {log, Surface} from "@visuallyjs/browser-ui";
|
|
4
4
|
import {internal_getSurfaceContext} from "./surface-store";
|
|
5
5
|
import {type DecoratorComponentProps} from "./definitions";
|
|
6
|
+
import {useSurface} from "./use-surface.svelte";
|
|
7
|
+
import {useDiagram} from "./use-diagram.svelte";
|
|
6
8
|
|
|
7
9
|
let container: HTMLElement;
|
|
8
|
-
let surface: Surface | undefined;
|
|
9
10
|
let initialised = false
|
|
11
|
+
const surface = useSurface()
|
|
12
|
+
const diagram = useDiagram()
|
|
13
|
+
const surfaceRef = $derived(surface.current || diagram.current?.$ui as Surface)
|
|
10
14
|
|
|
11
15
|
let {
|
|
12
16
|
placement = 'floating',
|
|
13
17
|
position = { x: 0, y: 0 },
|
|
14
|
-
constraints
|
|
18
|
+
constraints,
|
|
19
|
+
children
|
|
15
20
|
}:DecoratorComponentProps = $props()
|
|
16
21
|
|
|
17
|
-
const sc = internal_getSurfaceContext(true)
|
|
18
|
-
if (sc != null) {
|
|
19
|
-
sc.listen(s => {
|
|
20
|
-
surface = s
|
|
21
|
-
_maybeInit()
|
|
22
|
-
})
|
|
23
|
-
}else {
|
|
24
|
-
log(`WARN: DecoratorComponent did not find a Surface context. Cannot mount.`)
|
|
25
|
-
}
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
if (!initialised &&
|
|
23
|
+
$effect(() => {
|
|
24
|
+
if (!initialised && surfaceRef != null && container != null) {
|
|
29
25
|
initialised = true
|
|
30
26
|
if (container.firstElementChild) {
|
|
31
27
|
const element = container.firstElementChild as HTMLElement;
|
|
32
28
|
|
|
33
29
|
if (placement === 'fixed') {
|
|
34
|
-
|
|
30
|
+
surfaceRef.fixElement(element, position, constraints);
|
|
35
31
|
} else {
|
|
36
|
-
|
|
32
|
+
surfaceRef.floatElement(element, position);
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
35
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
onMount(async () => {
|
|
43
|
-
_maybeInit()
|
|
44
|
-
})
|
|
36
|
+
})
|
|
45
37
|
|
|
46
38
|
onDestroy(() => {
|
|
47
|
-
if (
|
|
48
|
-
|
|
39
|
+
if (surfaceRef && placement === 'fixed' && container && container.firstElementChild) {
|
|
40
|
+
surfaceRef.unfixElement(container.firstElementChild as HTMLElement);
|
|
49
41
|
}
|
|
50
42
|
});
|
|
51
43
|
</script>
|
|
52
44
|
|
|
53
45
|
<div bind:this={container} style="display: inline-block;">
|
|
54
|
-
|
|
46
|
+
{@render children?.()}
|
|
55
47
|
</div>
|
package/DiagramComponent.svelte
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
let container:BrowserElement;
|
|
12
12
|
|
|
13
|
-
let {options, className = "", data, url, modelOptions }:DiagramComponentProps = $props();
|
|
13
|
+
let {options, className = "", data, url, modelOptions, children }:DiagramComponentProps = $props();
|
|
14
14
|
|
|
15
15
|
const diagramContext = internal_getDiagramContext(false)
|
|
16
16
|
const surfaceContext = internal_getSurfaceContext(false)
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
</script>
|
|
43
43
|
|
|
44
44
|
<div class={className} bind:this={container}>
|
|
45
|
-
|
|
45
|
+
{@render children?.()}
|
|
46
46
|
</div>
|
|
@@ -4,44 +4,37 @@
|
|
|
4
4
|
import {Diagram, DiagramPalette, log} from "@visuallyjs/browser-ui";
|
|
5
5
|
import {internal_getDiagramContext} from "./diagram-store";
|
|
6
6
|
import {onMount} from "svelte";
|
|
7
|
+
import {useDiagram} from "./use-diagram.svelte";
|
|
7
8
|
|
|
8
|
-
let
|
|
9
|
+
let initialised = false
|
|
10
|
+
const diagram = useDiagram()
|
|
9
11
|
let container:HTMLElement
|
|
10
12
|
const props:DiagramPaletteProps = $props()
|
|
13
|
+
const diagramRef = $derived(diagram.current)
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
$effect(() => {
|
|
16
|
+
if (!initialised && container != null && diagramRef != null) {
|
|
17
|
+
initialised = true
|
|
18
|
+
new DiagramPalette(container, diagramRef, {
|
|
19
|
+
fill:props.fill,
|
|
20
|
+
outline:props.outline,
|
|
21
|
+
dragSize:props.dragSize,
|
|
22
|
+
inspector:props.inspector,
|
|
23
|
+
iconSize:props.iconSize,
|
|
24
|
+
showLabels:props.showLabels,
|
|
25
|
+
paletteStrokeWidth:props.paletteStrokeWidth,
|
|
26
|
+
showAllMessage:props.showAllMessage,
|
|
27
|
+
onCellAdded:props.onCellAdded,
|
|
28
|
+
mode:props.mode,
|
|
29
|
+
allowClickToAdd:props.allowClickToAdd,
|
|
30
|
+
autoExitDrawMode:props.autoExitDrawMode,
|
|
31
|
+
selectAfterAdd:props.selectAfterAdd,
|
|
32
|
+
onVertexAdded:props.onVertexAdded,
|
|
33
|
+
preparedShapes:props.preparedShapes
|
|
18
34
|
})
|
|
19
|
-
|
|
20
|
-
log(`WARN: DiagramPaletteComponent could not find a Diagram context. Cannot mount.`)
|
|
21
|
-
}
|
|
35
|
+
}
|
|
22
36
|
})
|
|
23
37
|
|
|
24
|
-
|
|
25
|
-
function _init() {
|
|
26
|
-
new DiagramPalette(container, diagram, {
|
|
27
|
-
fill:props.fill,
|
|
28
|
-
outline:props.outline,
|
|
29
|
-
dragSize:props.dragSize,
|
|
30
|
-
inspector:props.inspector,
|
|
31
|
-
iconSize:props.iconSize,
|
|
32
|
-
showLabels:props.showLabels,
|
|
33
|
-
paletteStrokeWidth:props.paletteStrokeWidth,
|
|
34
|
-
showAllMessage:props.showAllMessage,
|
|
35
|
-
onCellAdded:props.onCellAdded,
|
|
36
|
-
mode:props.mode,
|
|
37
|
-
allowClickToAdd:props.allowClickToAdd,
|
|
38
|
-
autoExitDrawMode:props.autoExitDrawMode,
|
|
39
|
-
selectAfterAdd:props.selectAfterAdd,
|
|
40
|
-
onVertexAdded:props.onVertexAdded,
|
|
41
|
-
preparedShapes:props.preparedShapes
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
38
|
</script>
|
|
46
39
|
|
|
47
40
|
<div class={props.className} bind:this={container}></div>
|
package/DiagramProvider.svelte
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
|
|
3
|
-
import { internal_getSurfaceContext} from "./surface-store"
|
|
4
3
|
import {
|
|
5
4
|
CLASS_CONTROLS,
|
|
6
5
|
CLASS_EXPORT_CONTROLS,
|
|
7
6
|
SvgExportUI,
|
|
8
7
|
ImageExportUI,
|
|
9
|
-
|
|
8
|
+
Surface
|
|
10
9
|
} from "@visuallyjs/browser-ui"
|
|
11
10
|
import {type ExportControlsComponentProps} from "./definitions";
|
|
12
|
-
import {
|
|
11
|
+
import {useSurface} from "./use-surface.svelte";
|
|
12
|
+
import {useDiagram} from "./use-diagram.svelte";
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const surface = useSurface()
|
|
15
|
+
const diagram = useDiagram()
|
|
16
|
+
const surfaceRef = $derived(surface.current || diagram.current?.$ui as Surface)
|
|
16
17
|
|
|
17
18
|
let {
|
|
18
19
|
className = "",
|
|
@@ -28,48 +29,29 @@
|
|
|
28
29
|
|
|
29
30
|
className = `${className} ${CLASS_CONTROLS} ${CLASS_EXPORT_CONTROLS}`
|
|
30
31
|
|
|
31
|
-
const sc = internal_getSurfaceContext(true)
|
|
32
|
-
if (sc != null) {
|
|
33
|
-
sc.listen(s => {
|
|
34
|
-
surface = s
|
|
35
|
-
_maybeInit()
|
|
36
|
-
})
|
|
37
|
-
} else {
|
|
38
|
-
const dc = internal_getDiagramContext(true)
|
|
39
|
-
if (dc != null) {
|
|
40
|
-
dc.listen(d => {
|
|
41
|
-
surface = d.$ui as Surface
|
|
42
|
-
_maybeInit()
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
log(`WARN: ExportControlsComponent did not find a Surface or Diagram context. Cannot mount.`)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _maybeInit() {
|
|
51
|
-
if (!initialized && surface != null) {
|
|
52
|
-
initialized = true
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
32
|
function exportSVG() {
|
|
57
33
|
svgOptions = svgOptions || {}
|
|
58
|
-
|
|
34
|
+
if (surfaceRef != null) {
|
|
35
|
+
new SvgExportUI(surfaceRef).export(svgOptions)
|
|
36
|
+
}
|
|
59
37
|
}
|
|
60
38
|
|
|
61
39
|
function exportPNG() {
|
|
62
40
|
// show an image export ui, which will default to PNG. `dimensions` is optional - if not supplied the resulting PNG
|
|
63
41
|
// will have the same size as the content.
|
|
64
42
|
imageOptions = imageOptions || {}
|
|
65
|
-
|
|
43
|
+
if (surfaceRef != null) {
|
|
44
|
+
new ImageExportUI(surfaceRef).export(imageOptions)
|
|
45
|
+
}
|
|
66
46
|
}
|
|
67
47
|
|
|
68
48
|
function exportJPG() {
|
|
69
49
|
// show an image export ui targetting a JPG output. Here we show an alternative to providing a list of dimensions - we just mandate the
|
|
70
50
|
// width we want for the output. Again, this is optional. You don't need to provide this or `dimensions`. See note above.
|
|
71
51
|
imageOptions = imageOptions || {}
|
|
72
|
-
|
|
52
|
+
if (surfaceRef != null) {
|
|
53
|
+
new ImageExportUI(surfaceRef).export(Object.assign(imageOptions || {}, {type: "image/jpeg"}))
|
|
54
|
+
}
|
|
73
55
|
}
|
|
74
56
|
|
|
75
57
|
</script>
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
|
|
5
5
|
import {GaugeChart, type BrowserElement} from "@visuallyjs/browser-ui"
|
|
6
|
-
import {type GaugeChartComponentProps} from "./definitions";
|
|
6
|
+
import {type GaugeChartComponentProps} from "./charts/definitions";
|
|
7
7
|
|
|
8
8
|
let container:BrowserElement;
|
|
9
9
|
|
|
10
|
-
let {options, className = ""
|
|
10
|
+
let {options, className = "" }:GaugeChartComponentProps = $props();
|
|
11
11
|
|
|
12
12
|
let chart:GaugeChart;
|
|
13
13
|
|
|
@@ -19,11 +19,6 @@
|
|
|
19
19
|
|
|
20
20
|
chart = new GaugeChart(container, options)
|
|
21
21
|
|
|
22
|
-
if (url != null) {
|
|
23
|
-
chart.load({url});
|
|
24
|
-
} else if (data != null) {
|
|
25
|
-
chart.load({data});
|
|
26
|
-
}
|
|
27
22
|
})
|
|
28
23
|
|
|
29
24
|
</script>
|
|
@@ -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>
|