layerchart 2.0.0-next.0 → 2.0.0-next.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/dist/actions/movable.d.ts +28 -0
- package/dist/actions/movable.js +91 -0
- package/dist/components/AnnotationLine.svelte +155 -0
- package/dist/components/AnnotationLine.svelte.d.ts +28 -0
- package/dist/components/AnnotationPoint.svelte +121 -0
- package/dist/components/AnnotationPoint.svelte.d.ts +32 -0
- package/dist/components/AnnotationRange.svelte +147 -0
- package/dist/components/AnnotationRange.svelte.d.ts +40 -0
- package/dist/components/Arc.svelte +344 -151
- package/dist/components/Arc.svelte.d.ts +138 -0
- package/dist/components/Area.svelte +165 -149
- package/dist/components/Area.svelte.d.ts +45 -0
- package/dist/components/Axis.svelte +287 -174
- package/dist/components/Axis.svelte.d.ts +116 -0
- package/dist/components/Bar.svelte +163 -107
- package/dist/components/Bar.svelte.d.ts +48 -0
- package/dist/components/Bars.svelte +54 -68
- package/dist/components/Bars.svelte.d.ts +27 -0
- package/dist/components/Blur.svelte +31 -7
- package/dist/components/Blur.svelte.d.ts +23 -21
- package/dist/components/Bounds.svelte +49 -19
- package/dist/components/Bounds.svelte.d.ts +24 -50
- package/dist/components/BrushContext.svelte +296 -168
- package/dist/components/BrushContext.svelte.d.ts +97 -65
- package/dist/components/Calendar.svelte +116 -59
- package/dist/components/Calendar.svelte.d.ts +50 -31
- package/dist/components/Chart.svelte +1289 -398
- package/dist/components/Chart.svelte.d.ts +535 -410
- package/dist/components/ChartClipPath.svelte +37 -15
- package/dist/components/ChartClipPath.svelte.d.ts +21 -19
- package/dist/components/Circle.svelte +124 -85
- package/dist/components/Circle.svelte.d.ts +52 -0
- package/dist/components/CircleClipPath.svelte +76 -16
- package/dist/components/CircleClipPath.svelte.d.ts +46 -0
- package/dist/components/ClipPath.svelte +60 -15
- package/dist/components/ClipPath.svelte.d.ts +40 -27
- package/dist/components/ColorRamp.svelte +75 -9
- package/dist/components/ColorRamp.svelte.d.ts +37 -19
- package/dist/components/ComputedStyles.svelte +17 -5
- package/dist/components/ComputedStyles.svelte.d.ts +11 -19
- package/dist/components/Connector.svelte +149 -0
- package/dist/components/Connector.svelte.d.ts +51 -0
- package/dist/components/Dagre.svelte +211 -122
- package/dist/components/Dagre.svelte.d.ts +119 -56
- package/dist/components/ForceSimulation.svelte +215 -90
- package/dist/components/ForceSimulation.svelte.d.ts +82 -35
- package/dist/components/Frame.svelte +33 -13
- package/dist/components/Frame.svelte.d.ts +13 -17
- package/dist/components/GeoCircle.svelte +29 -16
- package/dist/components/GeoCircle.svelte.d.ts +22 -24
- package/dist/components/GeoContext.svelte +113 -72
- package/dist/components/GeoContext.svelte.d.ts +49 -41
- package/dist/components/GeoEdgeFade.svelte +47 -12
- package/dist/components/GeoEdgeFade.svelte.d.ts +17 -19
- package/dist/components/GeoPath.svelte +157 -127
- package/dist/components/GeoPath.svelte.d.ts +48 -36
- package/dist/components/GeoPoint.svelte +52 -20
- package/dist/components/GeoPoint.svelte.d.ts +25 -22
- package/dist/components/GeoSpline.svelte +75 -26
- package/dist/components/GeoSpline.svelte.d.ts +29 -20
- package/dist/components/GeoTile.svelte +100 -49
- package/dist/components/GeoTile.svelte.d.ts +38 -23
- package/dist/components/GeoVisible.svelte +17 -9
- package/dist/components/GeoVisible.svelte.d.ts +10 -18
- package/dist/components/Graticule.svelte +28 -13
- package/dist/components/Graticule.svelte.d.ts +11 -52
- package/dist/components/Grid.svelte +226 -114
- package/dist/components/Grid.svelte.d.ts +70 -0
- package/dist/components/Group.svelte +132 -105
- package/dist/components/Group.svelte.d.ts +53 -0
- package/dist/components/Highlight.svelte +409 -307
- package/dist/components/Highlight.svelte.d.ts +107 -0
- package/dist/components/Hull.svelte +96 -45
- package/dist/components/Hull.svelte.d.ts +40 -30
- package/dist/components/Labels.svelte +125 -46
- package/dist/components/Labels.svelte.d.ts +70 -27
- package/dist/components/Legend.svelte +374 -190
- package/dist/components/Legend.svelte.d.ts +95 -44
- package/dist/components/Line.svelte +163 -125
- package/dist/components/Line.svelte.d.ts +75 -0
- package/dist/components/LinearGradient.svelte +153 -78
- package/dist/components/LinearGradient.svelte.d.ts +66 -31
- package/dist/components/Link.svelte +160 -104
- package/dist/components/Link.svelte.d.ts +54 -0
- package/dist/components/Marker.svelte +100 -39
- package/dist/components/Marker.svelte.d.ts +59 -27
- package/dist/components/MarkerWrapper.svelte +35 -0
- package/dist/components/MarkerWrapper.svelte.d.ts +18 -0
- package/dist/components/MonthPath.svelte +65 -20
- package/dist/components/MonthPath.svelte.d.ts +23 -17
- package/dist/components/MotionPath.svelte +80 -24
- package/dist/components/MotionPath.svelte.d.ts +46 -27
- package/dist/components/Pack.svelte +53 -17
- package/dist/components/Pack.svelte.d.ts +42 -21
- package/dist/components/Partition.svelte +64 -22
- package/dist/components/Partition.svelte.d.ts +49 -26
- package/dist/components/Pattern.svelte +297 -11
- package/dist/components/Pattern.svelte.d.ts +103 -19
- package/dist/components/Pie.svelte +122 -76
- package/dist/components/Pie.svelte.d.ts +65 -51
- package/dist/components/Point.svelte +20 -9
- package/dist/components/Point.svelte.d.ts +16 -20
- package/dist/components/Points.svelte +148 -137
- package/dist/components/Points.svelte.d.ts +45 -34
- package/dist/components/RadialGradient.svelte +143 -70
- package/dist/components/RadialGradient.svelte.d.ts +69 -31
- package/dist/components/Rect.svelte +121 -102
- package/dist/components/Rect.svelte.d.ts +36 -0
- package/dist/components/RectClipPath.svelte +82 -18
- package/dist/components/RectClipPath.svelte.d.ts +55 -0
- package/dist/components/Rule.svelte +105 -62
- package/dist/components/Rule.svelte.d.ts +40 -19
- package/dist/components/Sankey.svelte +132 -55
- package/dist/components/Sankey.svelte.d.ts +61 -31
- package/dist/components/Spline.svelte +281 -218
- package/dist/components/Spline.svelte.d.ts +95 -0
- package/dist/components/Text.svelte +437 -176
- package/dist/components/Text.svelte.d.ts +130 -0
- package/dist/components/Threshold.svelte +48 -16
- package/dist/components/Threshold.svelte.d.ts +29 -31
- package/dist/components/TileImage.svelte +103 -30
- package/dist/components/TileImage.svelte.d.ts +48 -23
- package/dist/components/TransformContext.svelte +365 -171
- package/dist/components/TransformControls.svelte +50 -26
- package/dist/components/TransformControls.svelte.d.ts +27 -19
- package/dist/components/Tree.svelte +74 -33
- package/dist/components/Tree.svelte.d.ts +42 -30
- package/dist/components/Treemap.svelte +119 -42
- package/dist/components/Treemap.svelte.d.ts +75 -27
- package/dist/components/Voronoi.svelte +106 -75
- package/dist/components/Voronoi.svelte.d.ts +40 -41
- package/dist/components/charts/ArcChart.svelte +464 -0
- package/dist/components/charts/ArcChart.svelte.d.ts +90 -0
- package/dist/components/charts/AreaChart.svelte +450 -393
- package/dist/components/charts/AreaChart.svelte.d.ts +61 -0
- package/dist/components/charts/BarChart.svelte +454 -389
- package/dist/components/charts/BarChart.svelte.d.ts +76 -0
- package/dist/components/charts/ChartAnnotations.svelte +37 -0
- package/dist/components/charts/ChartAnnotations.svelte.d.ts +10 -0
- package/dist/components/charts/DefaultTooltip.svelte +60 -0
- package/dist/components/charts/DefaultTooltip.svelte.d.ts +10 -0
- package/dist/components/charts/LineChart.svelte +369 -314
- package/dist/components/charts/LineChart.svelte.d.ts +53 -0
- package/dist/components/charts/PieChart.svelte +458 -316
- package/dist/components/charts/PieChart.svelte.d.ts +137 -353
- package/dist/components/charts/ScatterChart.svelte +334 -296
- package/dist/components/charts/ScatterChart.svelte.d.ts +39 -0
- package/dist/components/charts/index.d.ts +8 -0
- package/dist/components/charts/index.js +7 -0
- package/dist/components/charts/types.d.ts +253 -0
- package/dist/components/charts/utils.svelte.d.ts +30 -0
- package/dist/components/charts/utils.svelte.js +55 -0
- package/dist/components/index.d.ts +76 -4
- package/dist/components/index.js +76 -5
- package/dist/components/layout/Canvas.svelte +321 -155
- package/dist/components/layout/Canvas.svelte.d.ts +104 -55
- package/dist/components/layout/Html.svelte +82 -42
- package/dist/components/layout/Html.svelte.d.ts +39 -28
- package/dist/components/layout/Layer.svelte +39 -0
- package/dist/components/layout/Layer.svelte.d.ts +17 -0
- package/dist/components/layout/Svg.svelte +122 -70
- package/dist/components/layout/Svg.svelte.d.ts +53 -34
- package/dist/components/layout/WebGL.svelte +135 -0
- package/dist/components/layout/WebGL.svelte.d.ts +50 -0
- package/dist/components/tooltip/Tooltip.svelte +246 -78
- package/dist/components/tooltip/Tooltip.svelte.d.ts +149 -31
- package/dist/components/tooltip/TooltipContext.svelte +409 -271
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +86 -55
- package/dist/components/tooltip/TooltipHeader.svelte +100 -11
- package/dist/components/tooltip/TooltipHeader.svelte.d.ts +43 -23
- package/dist/components/tooltip/TooltipItem.svelte +167 -27
- package/dist/components/tooltip/TooltipItem.svelte.d.ts +63 -31
- package/dist/components/tooltip/TooltipList.svelte +22 -3
- package/dist/components/tooltip/TooltipList.svelte.d.ts +6 -17
- package/dist/components/tooltip/TooltipSeparator.svelte +27 -1
- package/dist/components/tooltip/TooltipSeparator.svelte.d.ts +6 -15
- package/dist/components/tooltip/index.d.ts +6 -0
- package/dist/components/tooltip/index.js +6 -0
- package/dist/components/tooltip/tooltipMetaContext.d.ts +79 -0
- package/dist/components/tooltip/tooltipMetaContext.js +139 -0
- package/dist/components/types.d.ts +1 -0
- package/dist/components/types.js +1 -0
- package/dist/docs/Blockquote.svelte.d.ts +18 -14
- package/dist/docs/Code.svelte.d.ts +26 -22
- package/dist/docs/ConnectorSweepMenuField.svelte +17 -0
- package/dist/docs/ConnectorSweepMenuField.svelte.d.ts +7 -0
- package/dist/docs/ConnectorTypeMenuField.svelte +17 -0
- package/dist/docs/ConnectorTypeMenuField.svelte.d.ts +7 -0
- package/dist/docs/CurveMenuField.svelte +14 -3
- package/dist/docs/CurveMenuField.svelte.d.ts +9 -18
- package/dist/docs/GeoDebug.svelte +47 -42
- package/dist/docs/GeoDebug.svelte.d.ts +4 -16
- package/dist/docs/Header1.svelte.d.ts +27 -16
- package/dist/docs/Json.svelte.d.ts +20 -16
- package/dist/docs/Layout.svelte.d.ts +18 -13
- package/dist/docs/Link.svelte.d.ts +33 -21
- package/dist/docs/PathDataMenuField.svelte +14 -10
- package/dist/docs/PathDataMenuField.svelte.d.ts +8 -18
- package/dist/docs/Preview.svelte +20 -7
- package/dist/docs/Preview.svelte.d.ts +12 -22
- package/dist/docs/TilesetField.svelte.d.ts +21 -17
- package/dist/docs/TransformDebug.svelte +5 -6
- package/dist/docs/TransformDebug.svelte.d.ts +18 -14
- package/dist/docs/ViewSourceButton.svelte.d.ts +21 -17
- package/dist/types/d3-shape-extentions.d.ts +7 -0
- package/dist/utils/afterTick.d.ts +5 -0
- package/dist/utils/afterTick.js +8 -0
- package/dist/utils/arcText.svelte.d.ts +57 -0
- package/dist/utils/arcText.svelte.js +262 -0
- package/dist/utils/array.d.ts +9 -1
- package/dist/utils/array.js +13 -0
- package/dist/utils/attributes.d.ts +29 -0
- package/dist/utils/attributes.js +40 -0
- package/dist/utils/canvas.js +47 -10
- package/dist/utils/chart.d.ts +78 -0
- package/dist/utils/chart.js +512 -0
- package/dist/utils/color.d.ts +1 -0
- package/dist/utils/color.js +8 -0
- package/dist/utils/common.d.ts +3 -5
- package/dist/utils/common.js +3 -2
- package/dist/utils/connectorUtils.d.ts +21 -0
- package/dist/utils/connectorUtils.js +111 -0
- package/dist/utils/createId.d.ts +7 -0
- package/dist/utils/createId.js +9 -0
- package/dist/utils/debug.d.ts +1 -0
- package/dist/utils/debug.js +84 -0
- package/dist/utils/filterObject.d.ts +9 -0
- package/dist/utils/filterObject.js +12 -0
- package/dist/utils/graph/dagre.d.ts +34 -0
- package/dist/utils/graph/dagre.js +78 -0
- package/dist/utils/graph/dagre.test.d.ts +1 -0
- package/dist/utils/{graph.test.js → graph/dagre.test.js} +19 -33
- package/dist/utils/graph/sankey.d.ts +28 -0
- package/dist/utils/{graph.js → graph/sankey.js} +13 -41
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/key.svelte.d.ts +3 -0
- package/dist/utils/key.svelte.js +11 -0
- package/dist/utils/legendPayload.d.ts +7 -0
- package/dist/utils/legendPayload.js +8 -0
- package/dist/utils/motion.svelte.d.ts +140 -0
- package/dist/utils/motion.svelte.js +180 -0
- package/dist/utils/motion.test.d.ts +1 -0
- package/dist/utils/motion.test.js +213 -0
- package/dist/utils/{rect.d.ts → rect.svelte.d.ts} +7 -4
- package/dist/utils/rect.svelte.js +105 -0
- package/dist/utils/scales.svelte.d.ts +90 -0
- package/dist/utils/{scales.js → scales.svelte.js} +100 -39
- package/dist/utils/stack.d.ts +2 -3
- package/dist/utils/stack.js +1 -1
- package/dist/utils/string.js +87 -0
- package/dist/utils/ticks.d.ts +8 -2
- package/dist/utils/ticks.js +28 -0
- package/dist/utils/ticks.test.d.ts +1 -0
- package/dist/utils/ticks.test.js +67 -0
- package/dist/utils/types.d.ts +81 -0
- package/package.json +25 -24
- package/dist/components/ChartContext.svelte +0 -295
- package/dist/components/ChartContext.svelte.d.ts +0 -139
- package/dist/components/TransformContext.svelte.d.ts +0 -158
- package/dist/stores/motionStore.d.ts +0 -30
- package/dist/stores/motionStore.js +0 -62
- package/dist/utils/graph.d.ts +0 -37
- package/dist/utils/rect.js +0 -107
- package/dist/utils/scales.d.ts +0 -66
- /package/dist/{utils/graph.test.d.ts → components/charts/types.js} +0 -0
|
@@ -1,28 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import type { Without } from '../utils/types.js';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
4
|
+
export type ClipPathPropsWithoutHTML = {
|
|
5
|
+
/**
|
|
6
|
+
* A unique id for the clipPath.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
id?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Use existing path or shape (by id) for clipPath
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
useId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to disable clipping (show all).
|
|
17
|
+
*
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* A snippet to insert content into the clipPath.
|
|
23
|
+
* Provides the id for the clipPath as a snippet prop.
|
|
24
|
+
*/
|
|
25
|
+
clip?: Snippet<[{
|
|
26
|
+
id: string;
|
|
27
|
+
}]>;
|
|
28
|
+
/**
|
|
29
|
+
* Children to render in the `<g>` element that links to the clipPath (if not disabled).
|
|
30
|
+
* Provides the id, url, and useId for the clipPath as snippet props.
|
|
31
|
+
*/
|
|
32
|
+
children?: Snippet<[{
|
|
33
|
+
id: string;
|
|
34
|
+
url: string;
|
|
35
|
+
useId?: string;
|
|
36
|
+
}]>;
|
|
22
37
|
};
|
|
23
|
-
export type ClipPathProps =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export default
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
38
|
+
export type ClipPathProps = ClipPathPropsWithoutHTML & Without<SVGAttributes<SVGClipPathElement>, ClipPathPropsWithoutHTML>;
|
|
39
|
+
declare const ClipPath: import("svelte").Component<ClipPathPropsWithoutHTML, {}, "">;
|
|
40
|
+
type ClipPath = ReturnType<typeof ClipPath>;
|
|
41
|
+
export default ClipPath;
|
|
@@ -1,21 +1,87 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { extractLayerProps } from '../utils/attributes.js';
|
|
3
|
+
import type { Without } from '../utils/types.js';
|
|
4
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
5
|
+
|
|
6
|
+
export type ColorRampPropsWithoutHTML = {
|
|
7
|
+
/**
|
|
8
|
+
* The interpolator function to use for the color ramp.
|
|
9
|
+
*
|
|
10
|
+
* @default (t: number) => `hsl(${t * 360}, 100%, 50%)`
|
|
11
|
+
*/
|
|
12
|
+
interpolator?: (t: number) => string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The number of steps in the color ramp.
|
|
16
|
+
*
|
|
17
|
+
* @default 10
|
|
18
|
+
*/
|
|
19
|
+
steps?: number;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The height of the color ramp.
|
|
23
|
+
*
|
|
24
|
+
* @default '20px'
|
|
25
|
+
*/
|
|
26
|
+
height?: string | number;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The width of the color ramp.
|
|
30
|
+
*
|
|
31
|
+
* @default '100%'
|
|
32
|
+
*/
|
|
33
|
+
width?: string | number;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A bindable reference to the underlying `<image>` element.
|
|
37
|
+
*
|
|
38
|
+
* @bindable
|
|
39
|
+
*/
|
|
40
|
+
ref?: SVGImageElement;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type ColorRampProps = ColorRampPropsWithoutHTML &
|
|
44
|
+
Without<SVGAttributes<SVGImageElement>, ColorRampPropsWithoutHTML>;
|
|
45
|
+
</script>
|
|
46
|
+
|
|
1
47
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
48
|
+
let {
|
|
49
|
+
interpolator,
|
|
50
|
+
steps = 10,
|
|
51
|
+
height = '20px',
|
|
52
|
+
width = '100%',
|
|
53
|
+
ref: refProp = $bindable(),
|
|
54
|
+
...restProps
|
|
55
|
+
}: ColorRampProps = $props();
|
|
56
|
+
|
|
57
|
+
let ref = $state<SVGImageElement>();
|
|
58
|
+
|
|
59
|
+
$effect.pre(() => {
|
|
60
|
+
refProp = ref;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
let href = $state('');
|
|
6
64
|
|
|
7
|
-
|
|
8
|
-
$: {
|
|
65
|
+
$effect(() => {
|
|
9
66
|
const canvas = document.createElement('canvas');
|
|
10
67
|
canvas.width = steps;
|
|
11
68
|
canvas.height = 1;
|
|
12
69
|
const context = canvas.getContext('2d')!;
|
|
13
70
|
for (let i = 0; i < steps; ++i) {
|
|
14
|
-
|
|
71
|
+
if (interpolator) {
|
|
72
|
+
context.fillStyle = interpolator(i / (steps - 1));
|
|
73
|
+
}
|
|
15
74
|
context.fillRect(i, 0, 1, 1);
|
|
16
75
|
}
|
|
17
76
|
href = canvas.toDataURL();
|
|
18
|
-
}
|
|
77
|
+
});
|
|
19
78
|
</script>
|
|
20
79
|
|
|
21
|
-
<image
|
|
80
|
+
<image
|
|
81
|
+
bind:this={ref}
|
|
82
|
+
{href}
|
|
83
|
+
preserveAspectRatio="none"
|
|
84
|
+
{height}
|
|
85
|
+
{width}
|
|
86
|
+
{...extractLayerProps(restProps, 'color-ramp')}
|
|
87
|
+
/>
|
|
@@ -1,20 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import type { Without } from '../utils/types.js';
|
|
2
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
3
|
+
export type ColorRampPropsWithoutHTML = {
|
|
4
|
+
/**
|
|
5
|
+
* The interpolator function to use for the color ramp.
|
|
6
|
+
*
|
|
7
|
+
* @default (t: number) => `hsl(${t * 360}, 100%, 50%)`
|
|
8
|
+
*/
|
|
9
|
+
interpolator?: (t: number) => string;
|
|
10
|
+
/**
|
|
11
|
+
* The number of steps in the color ramp.
|
|
12
|
+
*
|
|
13
|
+
* @default 10
|
|
14
|
+
*/
|
|
15
|
+
steps?: number;
|
|
16
|
+
/**
|
|
17
|
+
* The height of the color ramp.
|
|
18
|
+
*
|
|
19
|
+
* @default '20px'
|
|
20
|
+
*/
|
|
21
|
+
height?: string | number;
|
|
22
|
+
/**
|
|
23
|
+
* The width of the color ramp.
|
|
24
|
+
*
|
|
25
|
+
* @default '100%'
|
|
26
|
+
*/
|
|
27
|
+
width?: string | number;
|
|
28
|
+
/**
|
|
29
|
+
* A bindable reference to the underlying `<image>` element.
|
|
30
|
+
*
|
|
31
|
+
* @bindable
|
|
32
|
+
*/
|
|
33
|
+
ref?: SVGImageElement;
|
|
14
34
|
};
|
|
15
|
-
export type ColorRampProps =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export default
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
35
|
+
export type ColorRampProps = ColorRampPropsWithoutHTML & Without<SVGAttributes<SVGImageElement>, ColorRampPropsWithoutHTML>;
|
|
36
|
+
declare const ColorRamp: import("svelte").Component<ColorRampProps, {}, "ref">;
|
|
37
|
+
type ColorRamp = ReturnType<typeof ColorRamp>;
|
|
38
|
+
export default ColorRamp;
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
export type ComputedStylesPropsWithoutHTML = {
|
|
6
|
+
class?: HTMLAttributes<HTMLElement>['class'];
|
|
7
|
+
children?: Snippet<[{ styles: CSSStyleDeclaration }]>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type ComputedStylesProps = ComputedStylesPropsWithoutHTML;
|
|
11
|
+
</script>
|
|
12
|
+
|
|
1
13
|
<script lang="ts">
|
|
2
14
|
import { computedStyles } from '@layerstack/svelte-actions';
|
|
3
15
|
import { cls } from '@layerstack/tailwind';
|
|
16
|
+
import { layerClass } from '../utils/attributes.js';
|
|
4
17
|
|
|
5
|
-
let
|
|
6
|
-
export { className as class };
|
|
18
|
+
let { class: className, children }: ComputedStylesProps = $props();
|
|
7
19
|
|
|
8
|
-
let styles: CSSStyleDeclaration;
|
|
20
|
+
let styles: CSSStyleDeclaration = $state({}) as CSSStyleDeclaration;
|
|
9
21
|
</script>
|
|
10
22
|
|
|
11
23
|
<div
|
|
12
|
-
class={cls('
|
|
24
|
+
class={cls(layerClass('computed-styles'), 'hidden', className)}
|
|
13
25
|
use:computedStyles={(_styles) => (styles = _styles)}
|
|
14
26
|
></div>
|
|
15
27
|
|
|
16
|
-
|
|
28
|
+
{@render children?.({ styles })}
|
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
slots: {
|
|
10
|
-
default: {
|
|
11
|
-
styles: CSSStyleDeclaration;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
export type ComputedStylesPropsWithoutHTML = {
|
|
4
|
+
class?: HTMLAttributes<HTMLElement>['class'];
|
|
5
|
+
children?: Snippet<[{
|
|
6
|
+
styles: CSSStyleDeclaration;
|
|
7
|
+
}]>;
|
|
14
8
|
};
|
|
15
|
-
export type ComputedStylesProps =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export default
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
9
|
+
export type ComputedStylesProps = ComputedStylesPropsWithoutHTML;
|
|
10
|
+
declare const ComputedStyles: import("svelte").Component<ComputedStylesPropsWithoutHTML, {}, "">;
|
|
11
|
+
type ComputedStyles = ReturnType<typeof ComputedStyles>;
|
|
12
|
+
export default ComputedStyles;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type ConnectorPropsWithoutHTML = {
|
|
3
|
+
/**
|
|
4
|
+
* The coordinates of the start point of the connector.
|
|
5
|
+
* @default { x: 0, y: 0 }
|
|
6
|
+
*/
|
|
7
|
+
source: ConnectorCoords;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The coordinates of the end point of the connector.
|
|
11
|
+
*
|
|
12
|
+
* @default { x: 100, y: 100 }
|
|
13
|
+
*/
|
|
14
|
+
target: ConnectorCoords;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The sweep direction of the connector.
|
|
18
|
+
*
|
|
19
|
+
* @default 'horizontal-vertical'
|
|
20
|
+
*/
|
|
21
|
+
sweep?: ConnectorSweep;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The type of the connector.
|
|
25
|
+
*
|
|
26
|
+
* Set to `'d3'` to use a D3 curve function via the `curve` prop.
|
|
27
|
+
*
|
|
28
|
+
* @default 'rounded'
|
|
29
|
+
*/
|
|
30
|
+
type?: ConnectorType;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The radius of the connector.
|
|
34
|
+
*
|
|
35
|
+
* Only used when type is `'beveled'` or `'rounded'`
|
|
36
|
+
*
|
|
37
|
+
* @default 20
|
|
38
|
+
*/
|
|
39
|
+
radius?: number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The D3 curve function to use for the connector.
|
|
43
|
+
*
|
|
44
|
+
* Only used when type is `'d3'`
|
|
45
|
+
*
|
|
46
|
+
* @default `d3.curveLinear`
|
|
47
|
+
*/
|
|
48
|
+
curve?: CurveFactory;
|
|
49
|
+
} & SplinePropsWithoutHTML;
|
|
50
|
+
|
|
51
|
+
export type ConnectorProps = ConnectorPropsWithoutHTML &
|
|
52
|
+
Without<SplineProps, ConnectorPropsWithoutHTML>;
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<script lang="ts">
|
|
56
|
+
import { type CurveFactory, curveLinear } from 'd3-shape';
|
|
57
|
+
import {
|
|
58
|
+
getConnectorD3Path,
|
|
59
|
+
getConnectorPresetPath,
|
|
60
|
+
type ConnectorCoords,
|
|
61
|
+
type ConnectorSweep,
|
|
62
|
+
type ConnectorType,
|
|
63
|
+
} from '../utils/connectorUtils.js';
|
|
64
|
+
import Spline, { type SplineProps, type SplinePropsWithoutHTML } from './Spline.svelte';
|
|
65
|
+
import type { Without } from '../utils/types.js';
|
|
66
|
+
import { createId } from '../utils/createId.js';
|
|
67
|
+
import { extractLayerProps } from '../utils/attributes.js';
|
|
68
|
+
import MarkerWrapper from './MarkerWrapper.svelte';
|
|
69
|
+
import {
|
|
70
|
+
createMotion,
|
|
71
|
+
extractTweenConfig,
|
|
72
|
+
type ResolvedMotion,
|
|
73
|
+
} from '../utils/motion.svelte.js';
|
|
74
|
+
import { interpolatePath } from 'd3-interpolate-path';
|
|
75
|
+
|
|
76
|
+
const uid = $props.id();
|
|
77
|
+
|
|
78
|
+
let {
|
|
79
|
+
source = { x: 0, y: 0 },
|
|
80
|
+
target = { x: 100, y: 100 },
|
|
81
|
+
sweep: sweepProp,
|
|
82
|
+
type = 'rounded',
|
|
83
|
+
radius = 20,
|
|
84
|
+
curve = curveLinear,
|
|
85
|
+
splineRef = $bindable(),
|
|
86
|
+
pathData: pathDataProp,
|
|
87
|
+
marker,
|
|
88
|
+
markerStart,
|
|
89
|
+
markerMid,
|
|
90
|
+
markerEnd,
|
|
91
|
+
motion,
|
|
92
|
+
...restProps
|
|
93
|
+
}: ConnectorProps = $props();
|
|
94
|
+
|
|
95
|
+
const sweep = $derived.by(() => {
|
|
96
|
+
if (sweepProp) return sweepProp;
|
|
97
|
+
if (type === 'd3') return 'none';
|
|
98
|
+
return 'horizontal-vertical';
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const markerStartId = $derived(markerStart || marker ? createId('marker-start', uid) : '');
|
|
102
|
+
const markerMidId = $derived(markerMid || marker ? createId('marker-mid', uid) : '');
|
|
103
|
+
const markerEndId = $derived(markerEnd || marker ? createId('marker-end', uid) : '');
|
|
104
|
+
|
|
105
|
+
const extractedTween = extractTweenConfig(motion);
|
|
106
|
+
|
|
107
|
+
const tweenOptions: ResolvedMotion | undefined = extractedTween
|
|
108
|
+
? {
|
|
109
|
+
type: extractedTween.type,
|
|
110
|
+
options: {
|
|
111
|
+
interpolate: interpolatePath,
|
|
112
|
+
...extractedTween.options,
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
: undefined;
|
|
116
|
+
|
|
117
|
+
const pathData = $derived.by(() => {
|
|
118
|
+
if (pathDataProp) return pathDataProp;
|
|
119
|
+
if (type === 'd3') {
|
|
120
|
+
return getConnectorD3Path({
|
|
121
|
+
source,
|
|
122
|
+
target,
|
|
123
|
+
sweep,
|
|
124
|
+
curve,
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
return getConnectorPresetPath({ source, target, sweep, type, radius });
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const motionPath = createMotion(
|
|
132
|
+
'',
|
|
133
|
+
() => pathData,
|
|
134
|
+
tweenOptions ? tweenOptions : { type: 'none' }
|
|
135
|
+
);
|
|
136
|
+
</script>
|
|
137
|
+
|
|
138
|
+
<Spline
|
|
139
|
+
pathData={motionPath.current}
|
|
140
|
+
bind:splineRef
|
|
141
|
+
marker-start={markerStartId ? `url(#${markerStartId})` : undefined}
|
|
142
|
+
marker-mid={markerMidId ? `url(#${markerMidId})` : undefined}
|
|
143
|
+
marker-end={markerEndId ? `url(#${markerEndId})` : undefined}
|
|
144
|
+
{...extractLayerProps(restProps, 'connector')}
|
|
145
|
+
{...restProps}
|
|
146
|
+
/>
|
|
147
|
+
<MarkerWrapper id={markerStartId} marker={markerStart} />
|
|
148
|
+
<MarkerWrapper id={markerMidId} marker={markerMid} />
|
|
149
|
+
<MarkerWrapper id={markerEndId} marker={markerEnd} />
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type ConnectorPropsWithoutHTML = {
|
|
2
|
+
/**
|
|
3
|
+
* The coordinates of the start point of the connector.
|
|
4
|
+
* @default { x: 0, y: 0 }
|
|
5
|
+
*/
|
|
6
|
+
source: ConnectorCoords;
|
|
7
|
+
/**
|
|
8
|
+
* The coordinates of the end point of the connector.
|
|
9
|
+
*
|
|
10
|
+
* @default { x: 100, y: 100 }
|
|
11
|
+
*/
|
|
12
|
+
target: ConnectorCoords;
|
|
13
|
+
/**
|
|
14
|
+
* The sweep direction of the connector.
|
|
15
|
+
*
|
|
16
|
+
* @default 'horizontal-vertical'
|
|
17
|
+
*/
|
|
18
|
+
sweep?: ConnectorSweep;
|
|
19
|
+
/**
|
|
20
|
+
* The type of the connector.
|
|
21
|
+
*
|
|
22
|
+
* Set to `'d3'` to use a D3 curve function via the `curve` prop.
|
|
23
|
+
*
|
|
24
|
+
* @default 'rounded'
|
|
25
|
+
*/
|
|
26
|
+
type?: ConnectorType;
|
|
27
|
+
/**
|
|
28
|
+
* The radius of the connector.
|
|
29
|
+
*
|
|
30
|
+
* Only used when type is `'beveled'` or `'rounded'`
|
|
31
|
+
*
|
|
32
|
+
* @default 20
|
|
33
|
+
*/
|
|
34
|
+
radius?: number;
|
|
35
|
+
/**
|
|
36
|
+
* The D3 curve function to use for the connector.
|
|
37
|
+
*
|
|
38
|
+
* Only used when type is `'d3'`
|
|
39
|
+
*
|
|
40
|
+
* @default `d3.curveLinear`
|
|
41
|
+
*/
|
|
42
|
+
curve?: CurveFactory;
|
|
43
|
+
} & SplinePropsWithoutHTML;
|
|
44
|
+
export type ConnectorProps = ConnectorPropsWithoutHTML & Without<SplineProps, ConnectorPropsWithoutHTML>;
|
|
45
|
+
import { type CurveFactory } from 'd3-shape';
|
|
46
|
+
import { type ConnectorCoords, type ConnectorSweep, type ConnectorType } from '../utils/connectorUtils.js';
|
|
47
|
+
import { type SplineProps, type SplinePropsWithoutHTML } from './Spline.svelte';
|
|
48
|
+
import type { Without } from '../utils/types.js';
|
|
49
|
+
declare const Connector: import("svelte").Component<ConnectorProps, {}, "splineRef">;
|
|
50
|
+
type Connector = ReturnType<typeof Connector>;
|
|
51
|
+
export default Connector;
|