@visuallyjs/browser-ui-svelte 1.0.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 +37 -0
- package/BarChartComponent.svelte +37 -0
- package/BubbleChartComponent.svelte +38 -0
- package/ColorPickerComponent.svelte +94 -0
- package/ColumnChartComponent.svelte +38 -0
- package/ControlsComponent.svelte +66 -0
- package/DecoratorComponent.svelte +55 -0
- package/DefaultGroupComponent.svelte +5 -0
- package/DefaultNodeComponent.svelte +5 -0
- package/DiagramComponent.svelte +46 -0
- package/DiagramPaletteComponent.svelte +47 -0
- package/DiagramProvider.svelte +9 -0
- package/EdgeTypePickerComponent.svelte +47 -0
- package/ExportControlsComponent.svelte +94 -0
- package/GaugeChartComponent.svelte +31 -0
- package/InspectorComponent.svelte +79 -0
- package/LineChartComponent.svelte +38 -0
- package/MiniviewComponent.svelte +73 -0
- package/PaletteComponent.svelte +73 -0
- package/PieChartComponent.svelte +37 -0
- package/SankeyChartComponent.svelte +44 -0
- package/ScatterChartComponent.svelte +38 -0
- package/ShapeComponent.svelte +66 -0
- package/ShapePaletteComponent.svelte +82 -0
- package/SurfaceComponent.svelte +270 -0
- package/SurfaceProvider.svelte +9 -0
- package/WrapperComponent.svelte +27 -0
- package/XYChartComponent.svelte +32 -0
- package/components.d.ts +29 -0
- package/components.js +29 -0
- package/definitions.d.ts +841 -0
- package/definitions.js +1 -0
- package/diagram-store.d.ts +30 -0
- package/diagram-store.js +58 -0
- package/index.d.ts +27 -0
- package/index.js +33 -0
- package/inspector-store.d.ts +24 -0
- package/inspector-store.js +42 -0
- package/package.json +1 -0
- package/store-adapter.d.ts +15 -0
- package/store-adapter.js +47 -0
- package/surface-store.d.ts +41 -0
- package/surface-store.js +73 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {Base, Inspector, log, Surface} from "@visuallyjs/browser-ui"
|
|
3
|
+
import {internal_getSurfaceContext} from "./surface-store"
|
|
4
|
+
import {onMount} from "svelte"
|
|
5
|
+
import {type InspectorComponentProps} from "./definitions";
|
|
6
|
+
import {getInspectorContext} from "./inspector-store";
|
|
7
|
+
import {internal_getDiagramContext} from "./diagram-store";
|
|
8
|
+
|
|
9
|
+
let container:HTMLElement
|
|
10
|
+
let inspector:Inspector
|
|
11
|
+
let surface:Surface
|
|
12
|
+
let initialized = false
|
|
13
|
+
|
|
14
|
+
let currentType = ''
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
className = "",
|
|
18
|
+
autoCommit = true,
|
|
19
|
+
multipleSelections = false,
|
|
20
|
+
filter,
|
|
21
|
+
refresh,
|
|
22
|
+
renderEmptyContainer,
|
|
23
|
+
style = ""
|
|
24
|
+
}:InspectorComponentProps = $props()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const _refresh = (obj:Base, cb:Function) => {
|
|
28
|
+
currentType = obj.objectType
|
|
29
|
+
refresh && refresh(obj)
|
|
30
|
+
setTimeout(cb)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const _renderEmptyContainer = renderEmptyContainer || (() => currentType = '')
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function _maybeInit() {
|
|
37
|
+
if (!initialized && surface != null && container != null) {
|
|
38
|
+
initialized = true
|
|
39
|
+
inspector = new Inspector({
|
|
40
|
+
container,
|
|
41
|
+
ui:surface,
|
|
42
|
+
renderEmptyContainer:_renderEmptyContainer,
|
|
43
|
+
refresh:_refresh,
|
|
44
|
+
autoCommit,
|
|
45
|
+
multipleSelections,
|
|
46
|
+
filter
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// set on the context
|
|
50
|
+
getInspectorContext(false).set(inspector)
|
|
51
|
+
}
|
|
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
|
+
})
|
|
74
|
+
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<div class={className} bind:this={container} style={style}>
|
|
78
|
+
<slot/>
|
|
79
|
+
</div>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { onMount } from "svelte";
|
|
4
|
+
|
|
5
|
+
import {LineChart, type BrowserElement} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type LineChartComponentProps} from "./definitions";
|
|
7
|
+
|
|
8
|
+
let container:BrowserElement;
|
|
9
|
+
|
|
10
|
+
// BarChartOptions
|
|
11
|
+
let {options, className = "", data, url, dataSourceFilter }:LineChartComponentProps = $props();
|
|
12
|
+
|
|
13
|
+
let chart:LineChart;
|
|
14
|
+
|
|
15
|
+
export function getChart() {
|
|
16
|
+
return chart;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
$effect(() => {
|
|
20
|
+
if (chart) {
|
|
21
|
+
chart.setDataSourceFilter(dataSourceFilter)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
onMount(async () => {
|
|
26
|
+
|
|
27
|
+
chart = new LineChart(container, Object.assign({dataSourceFilter}, options))
|
|
28
|
+
|
|
29
|
+
if (url != null) {
|
|
30
|
+
chart.load({url});
|
|
31
|
+
} else if (data != null) {
|
|
32
|
+
chart.load({data});
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<div class={className} bind:this={container}></div>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { onMount } from "svelte"
|
|
4
|
+
|
|
5
|
+
import {log, MiniviewPlugin, Surface} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {internal_getSurfaceContext} from "./surface-store";
|
|
7
|
+
import {type MiniviewComponentProps} from "./definitions";
|
|
8
|
+
import {internal_getDiagramContext} from "./diagram-store";
|
|
9
|
+
|
|
10
|
+
let container:HTMLElement
|
|
11
|
+
let surface:Surface
|
|
12
|
+
let initialised = false
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
collapsible,
|
|
16
|
+
typeFunction,
|
|
17
|
+
wheelSensitivity,
|
|
18
|
+
elementFilter,
|
|
19
|
+
enableWheelZoom,
|
|
20
|
+
visible,
|
|
21
|
+
wheelReverse,
|
|
22
|
+
activeTracking,
|
|
23
|
+
clickToCenter,
|
|
24
|
+
className = ""
|
|
25
|
+
}:MiniviewComponentProps = $props()
|
|
26
|
+
|
|
27
|
+
const sc = internal_getSurfaceContext(true)
|
|
28
|
+
if (sc != null) {
|
|
29
|
+
sc.listen(s => {
|
|
30
|
+
surface = s
|
|
31
|
+
_maybeInit()
|
|
32
|
+
})
|
|
33
|
+
} else {
|
|
34
|
+
const dc = internal_getDiagramContext(true)
|
|
35
|
+
if (dc != null) {
|
|
36
|
+
dc.listen(d => {
|
|
37
|
+
surface = d.$ui as Surface
|
|
38
|
+
_maybeInit()
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
log(`WARN: MiniviewComponent did not find a Surface or Diagram context. Cannot mount.`)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function _maybeInit() {
|
|
47
|
+
if (!initialised && surface != null && container != null) {
|
|
48
|
+
initialised = true
|
|
49
|
+
surface.addPlugin({
|
|
50
|
+
type:MiniviewPlugin.type,
|
|
51
|
+
options:{
|
|
52
|
+
collapsible,
|
|
53
|
+
visible,
|
|
54
|
+
container,
|
|
55
|
+
typeFunction,
|
|
56
|
+
elementFilter,
|
|
57
|
+
wheelSensitivity,
|
|
58
|
+
wheelReverse,
|
|
59
|
+
enableWheelZoom,
|
|
60
|
+
activeTracking,
|
|
61
|
+
clickToCenter
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
onMount(async () => {
|
|
68
|
+
_maybeInit()
|
|
69
|
+
})
|
|
70
|
+
</script>
|
|
71
|
+
<div bind:this={container} class={className}>
|
|
72
|
+
|
|
73
|
+
</div>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { onMount } from "svelte"
|
|
4
|
+
|
|
5
|
+
import {internal_getSurfaceContext} from "./surface-store";
|
|
6
|
+
import {log, Palette, Surface} from "@visuallyjs/browser-ui"
|
|
7
|
+
import {type PaletteComponentProps} from "./definitions";
|
|
8
|
+
|
|
9
|
+
let container:HTMLElement
|
|
10
|
+
let surface:Surface
|
|
11
|
+
let initialised = false
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
selector = "[data-vjs-type]",
|
|
15
|
+
dataGenerator = undefined,
|
|
16
|
+
className = "",
|
|
17
|
+
onVertexAdded = undefined,
|
|
18
|
+
dragSize = undefined,
|
|
19
|
+
canvasDropFilter = undefined,
|
|
20
|
+
children,
|
|
21
|
+
mode,
|
|
22
|
+
selectAfterAdd = false,
|
|
23
|
+
allowClickToAdd = false,
|
|
24
|
+
clickToAddOnly = false,
|
|
25
|
+
allowDropOnEdge = false,
|
|
26
|
+
allowDropOnGroup = true,
|
|
27
|
+
allowDropOnCanvas = true,
|
|
28
|
+
allowDropOnNode = false,
|
|
29
|
+
ignoreDropOnNode = false
|
|
30
|
+
}:PaletteComponentProps = $props()
|
|
31
|
+
|
|
32
|
+
const sc = internal_getSurfaceContext(true)
|
|
33
|
+
if(sc != null) {
|
|
34
|
+
sc.listen(s => {
|
|
35
|
+
surface = s
|
|
36
|
+
_maybeInit()
|
|
37
|
+
})
|
|
38
|
+
} else {
|
|
39
|
+
log(`WARN: PaletteComponent did not find a Surface context - ensure the PaletteComponent is declared inside a SurfaceComponent or SurfaceProvider`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function _maybeInit() {
|
|
43
|
+
if (!initialised && surface != null && container != null) {
|
|
44
|
+
initialised = true
|
|
45
|
+
|
|
46
|
+
new Palette(surface, {
|
|
47
|
+
source:container,
|
|
48
|
+
selector,
|
|
49
|
+
dataGenerator,
|
|
50
|
+
onVertexAdded,
|
|
51
|
+
selectAfterAdd,
|
|
52
|
+
allowClickToAdd,
|
|
53
|
+
clickToAddOnly,
|
|
54
|
+
dragSize,
|
|
55
|
+
canvasDropFilter,
|
|
56
|
+
mode,
|
|
57
|
+
allowDropOnNode,
|
|
58
|
+
allowDropOnEdge,
|
|
59
|
+
allowDropOnCanvas,
|
|
60
|
+
allowDropOnGroup,
|
|
61
|
+
ignoreDropOnNode
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
onMount(async () => {
|
|
67
|
+
_maybeInit()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
</script>
|
|
71
|
+
<div bind:this={container} class={className}>
|
|
72
|
+
{@render children?.()}
|
|
73
|
+
</div>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { onMount } from "svelte";
|
|
4
|
+
|
|
5
|
+
import {PieChart, type BrowserElement} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type PieChartComponentProps} from "./definitions";
|
|
7
|
+
|
|
8
|
+
let container:BrowserElement;
|
|
9
|
+
|
|
10
|
+
let {options, className = "", data, url, dataSourceFilter }:PieChartComponentProps = $props();
|
|
11
|
+
|
|
12
|
+
let chart:PieChart;
|
|
13
|
+
|
|
14
|
+
export function getChart() {
|
|
15
|
+
return chart;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
$effect(() => {
|
|
19
|
+
if (chart) {
|
|
20
|
+
chart.setDataSourceFilter(dataSourceFilter)
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
onMount(async () => {
|
|
25
|
+
|
|
26
|
+
chart = new PieChart(container, Object.assign({dataSourceFilter}, options))
|
|
27
|
+
|
|
28
|
+
if (url != null) {
|
|
29
|
+
chart.load({url});
|
|
30
|
+
} else if (data != null) {
|
|
31
|
+
chart.load({data});
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<div class={className} bind:this={container}></div>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { onMount } from "svelte";
|
|
4
|
+
|
|
5
|
+
import {SankeyChart, type BrowserElement} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type SankeyChartComponentProps} from "./definitions";
|
|
7
|
+
|
|
8
|
+
let container:BrowserElement;
|
|
9
|
+
|
|
10
|
+
let {options, className = "", jsonData, csvData, url, interactive, pivot }:SankeyChartComponentProps = $props();
|
|
11
|
+
|
|
12
|
+
let chart:SankeyChart;
|
|
13
|
+
|
|
14
|
+
$effect(() => {
|
|
15
|
+
chart && chart.pivot(pivot)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export function getChart() {
|
|
19
|
+
return chart;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
onMount(async () => {
|
|
23
|
+
|
|
24
|
+
const _options = Object.assign({}, options)
|
|
25
|
+
if (interactive != null) {
|
|
26
|
+
_options.interactive = interactive
|
|
27
|
+
}
|
|
28
|
+
if (pivot != null) {
|
|
29
|
+
_options.pivot = pivot
|
|
30
|
+
}
|
|
31
|
+
chart = new SankeyChart(container, _options)
|
|
32
|
+
|
|
33
|
+
if (url != null) {
|
|
34
|
+
chart.load({url});
|
|
35
|
+
} else if (csvData != null) {
|
|
36
|
+
chart.load({csvData});
|
|
37
|
+
} else if (jsonData != null) {
|
|
38
|
+
chart.load({jsonData})
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<div class={className} bind:this={container}></div>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { onMount } from "svelte";
|
|
4
|
+
|
|
5
|
+
import {type BrowserElement, ScatterChart} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type ScatterChartComponentProps} from "./definitions";
|
|
7
|
+
|
|
8
|
+
let container:BrowserElement;
|
|
9
|
+
|
|
10
|
+
// ScatterChartOptions
|
|
11
|
+
let {options, className = "", data, url, dataSourceFilter }:ScatterChartComponentProps = $props();
|
|
12
|
+
|
|
13
|
+
let chart:ScatterChart;
|
|
14
|
+
|
|
15
|
+
export function getChart() {
|
|
16
|
+
return chart;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
$effect(() => {
|
|
20
|
+
if (chart) {
|
|
21
|
+
chart.setDataSourceFilter(dataSourceFilter)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
onMount(async () => {
|
|
26
|
+
|
|
27
|
+
chart = new ScatterChart(container, Object.assign({dataSourceFilter}, options))
|
|
28
|
+
|
|
29
|
+
if (url != null) {
|
|
30
|
+
chart.load({url});
|
|
31
|
+
} else if (data != null) {
|
|
32
|
+
chart.load({data});
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<div class={className} bind:this={container}></div>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import {DEFAULT_LABEL_PROPERTY, log, Surface} from "@visuallyjs/browser-ui"
|
|
4
|
+
|
|
5
|
+
import { onMount } from "svelte"
|
|
6
|
+
import {internal_getSurfaceContext} from "./surface-store";
|
|
7
|
+
import {type ShapeComponentProps} from "./definitions";
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
data,
|
|
11
|
+
showLabels = false,
|
|
12
|
+
labelProperty = DEFAULT_LABEL_PROPERTY,
|
|
13
|
+
labelStrokeWidth = "0.25px",
|
|
14
|
+
font
|
|
15
|
+
}:ShapeComponentProps = $props()
|
|
16
|
+
|
|
17
|
+
let group:SVGGElement
|
|
18
|
+
let surface:Surface
|
|
19
|
+
|
|
20
|
+
let label = $derived(data[labelProperty])
|
|
21
|
+
let outlineWidth = $derived(data.outlineWidth || 2)
|
|
22
|
+
let fill = $derived(data.fill || "#FFFFFF")
|
|
23
|
+
let outline = $derived(data.outline || "#000000")
|
|
24
|
+
|
|
25
|
+
let fontSize = $derived(data.fontSize || font?.size || 14)
|
|
26
|
+
let fontStyle = $derived(data.fontStyle || font?.style || "normal")
|
|
27
|
+
|
|
28
|
+
function _render() {
|
|
29
|
+
const shapeLibrary = surface.getShapeLibrary()
|
|
30
|
+
if (shapeLibrary != null && group != null) {
|
|
31
|
+
const el = shapeLibrary.renderCompiledShape(data, outlineWidth)
|
|
32
|
+
group.replaceChildren(el)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
onMount(async () => {
|
|
38
|
+
const sc = internal_getSurfaceContext(true)
|
|
39
|
+
if (sc != null) {
|
|
40
|
+
sc.listen(s => {
|
|
41
|
+
surface = s
|
|
42
|
+
_render()
|
|
43
|
+
})
|
|
44
|
+
} else {
|
|
45
|
+
log(`WARN: ShapeComponent did not find a Surface context.`)
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
</script>
|
|
52
|
+
<svg class="vjs-shape" stroke-width={outlineWidth} fill={fill} stroke={outline}
|
|
53
|
+
style="width:100%;height:100%;inset:0;position:absolute;" preserveAspectRatio="none" viewBox="0 0 {data.width} {data.height}">
|
|
54
|
+
<g bind:this={group}></g>
|
|
55
|
+
{#if showLabels}
|
|
56
|
+
<text x="50%" y="50%"
|
|
57
|
+
fill="currentColor"
|
|
58
|
+
stroke="currentColor"
|
|
59
|
+
text-anchor="middle"
|
|
60
|
+
dominant-baseline="middle"
|
|
61
|
+
class="vjs-shape-label"
|
|
62
|
+
font-size={fontSize}
|
|
63
|
+
font-style={fontStyle}
|
|
64
|
+
stroke-width={labelStrokeWidth}>{label}</text>
|
|
65
|
+
{/if}
|
|
66
|
+
</svg>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { internal_getSurfaceContext } from "./surface-store"
|
|
3
|
+
import { onMount } from "svelte"
|
|
4
|
+
import {log, ShapePalette, Surface} from "@visuallyjs/browser-ui"
|
|
5
|
+
import {type ShapePaletteComponentProps} from "./definitions";
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
className = "",
|
|
9
|
+
dragSize,
|
|
10
|
+
fill,
|
|
11
|
+
outline,
|
|
12
|
+
showAllMessage,
|
|
13
|
+
selectAfterDrop,
|
|
14
|
+
paletteStrokeWidth,
|
|
15
|
+
dataGenerator,
|
|
16
|
+
iconSize,
|
|
17
|
+
initialSet,
|
|
18
|
+
showLabels,
|
|
19
|
+
onVertexAdded,
|
|
20
|
+
mode,
|
|
21
|
+
allowClickToAdd,
|
|
22
|
+
autoExitDrawMode,
|
|
23
|
+
inspector = true,
|
|
24
|
+
preparedShapes
|
|
25
|
+
}:ShapePaletteComponentProps = $props()
|
|
26
|
+
|
|
27
|
+
let surface:Surface
|
|
28
|
+
let container:HTMLElement
|
|
29
|
+
let initialised = false
|
|
30
|
+
|
|
31
|
+
const sc = internal_getSurfaceContext(true)
|
|
32
|
+
if(sc != null) {
|
|
33
|
+
sc.listen(s => {
|
|
34
|
+
surface = s
|
|
35
|
+
_maybeInit()
|
|
36
|
+
})
|
|
37
|
+
} else {
|
|
38
|
+
log(`WARN: ShapePaletteComponent did not find a Surface context - ensure the ShapePaletteComponent is declared inside a SurfaceComponent or SurfaceProvider`)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _maybeInit() {
|
|
42
|
+
if (!initialised && surface != null && container != null) {
|
|
43
|
+
initialised = true
|
|
44
|
+
|
|
45
|
+
const shapeLibrary = surface.getShapeLibrary()
|
|
46
|
+
if (shapeLibrary == null) {
|
|
47
|
+
log("WARN: no shape library set on surface; ShapePaletteComponent cannot render")
|
|
48
|
+
} else {
|
|
49
|
+
|
|
50
|
+
new ShapePalette(surface, {
|
|
51
|
+
container,
|
|
52
|
+
dataGenerator,
|
|
53
|
+
autoExitDrawMode,
|
|
54
|
+
allowClickToAdd,
|
|
55
|
+
mode,
|
|
56
|
+
onVertexAdded,
|
|
57
|
+
showLabels,
|
|
58
|
+
initialSet,
|
|
59
|
+
iconSize,
|
|
60
|
+
paletteStrokeWidth,
|
|
61
|
+
selectAfterDrop,
|
|
62
|
+
showAllMessage,
|
|
63
|
+
outline,
|
|
64
|
+
fill,
|
|
65
|
+
dragSize,
|
|
66
|
+
inspector,
|
|
67
|
+
preparedShapes
|
|
68
|
+
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
onMount(async () => {
|
|
77
|
+
_maybeInit()
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
</script>
|
|
82
|
+
<div class={className} bind:this={container}></div>
|