layerchart 2.0.0-next.16 → 2.0.0-next.17
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/components/Arc.svelte +2 -2
- package/dist/components/Blur.svelte +5 -3
- package/dist/components/Blur.svelte.d.ts +2 -5
- package/dist/components/Connector.svelte +2 -2
- package/dist/components/Connector.svelte.d.ts +1 -1
- package/dist/components/Ellipse.svelte +187 -0
- package/dist/components/Ellipse.svelte.d.ts +64 -0
- package/dist/components/ForceSimulation.svelte +68 -22
- package/dist/components/ForceSimulation.svelte.d.ts +24 -11
- package/dist/components/GeoPath.svelte +5 -4
- package/dist/components/GeoPoint.svelte +1 -2
- package/dist/components/GeoSpline.svelte +4 -4
- package/dist/components/GeoSpline.svelte.d.ts +1 -1
- package/dist/components/MonthPath.svelte +11 -8
- package/dist/components/MonthPath.svelte.d.ts +4 -3
- package/dist/components/Polygon.svelte +285 -0
- package/dist/components/Polygon.svelte.d.ts +115 -0
- package/dist/components/Spline.svelte +29 -17
- package/dist/components/Spline.svelte.d.ts +12 -4
- package/dist/components/Treemap.svelte +63 -26
- package/dist/components/Treemap.svelte.d.ts +11 -11
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/layout/Layer.svelte +6 -4
- package/dist/components/layout/Layer.svelte.d.ts +6 -4
- package/dist/components/tooltip/TooltipList.svelte +1 -1
- package/dist/utils/canvas.js +15 -0
- package/dist/utils/path.d.ts +10 -0
- package/dist/utils/path.js +30 -0
- package/dist/utils/shape.d.ts +43 -0
- package/dist/utils/shape.js +59 -0
- package/dist/utils/treemap.d.ts +1 -1
- package/package.json +1 -1
|
@@ -16,9 +16,10 @@ export type MonthPathPropsWithoutHTML = {
|
|
|
16
16
|
*
|
|
17
17
|
* @bindable
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
pathRef?: SVGPathElement;
|
|
20
20
|
};
|
|
21
|
-
export type MonthPathProps = MonthPathPropsWithoutHTML & Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML>;
|
|
22
|
-
|
|
21
|
+
export type MonthPathProps = MonthPathPropsWithoutHTML & Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML & SplinePropsWithoutHTML>;
|
|
22
|
+
import { type SplinePropsWithoutHTML } from './Spline.svelte';
|
|
23
|
+
declare const MonthPath: import("svelte").Component<MonthPathProps, {}, "pathRef">;
|
|
23
24
|
type MonthPath = ReturnType<typeof MonthPath>;
|
|
24
25
|
export default MonthPath;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { CommonStyleProps, Without } from '../utils/types.js';
|
|
3
|
+
|
|
4
|
+
export type PolygonPropsWithoutHTML = {
|
|
5
|
+
/**
|
|
6
|
+
* The center x position of the polygon.
|
|
7
|
+
*
|
|
8
|
+
* @default 0
|
|
9
|
+
*/
|
|
10
|
+
cx?: number;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The initial center x position of the polygon.
|
|
14
|
+
*
|
|
15
|
+
* @default cx
|
|
16
|
+
*/
|
|
17
|
+
initialCx?: number;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The center y position of the polygon.
|
|
21
|
+
*
|
|
22
|
+
* @default 0
|
|
23
|
+
*/
|
|
24
|
+
cy?: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The initial center y position of the polygon.
|
|
28
|
+
*
|
|
29
|
+
* @default cy
|
|
30
|
+
*/
|
|
31
|
+
initialCy?: number;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The radius of the polygon.
|
|
35
|
+
*
|
|
36
|
+
* @default 1
|
|
37
|
+
*/
|
|
38
|
+
r?: number;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The initial radius of the polygon.
|
|
42
|
+
*
|
|
43
|
+
* @default r
|
|
44
|
+
*/
|
|
45
|
+
initialR?: number;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The number of points or explicit points to create the polygon.
|
|
49
|
+
*
|
|
50
|
+
* @default 4
|
|
51
|
+
*/
|
|
52
|
+
points?: number | { x: number; y: number }[];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The radius of the curve for rounded corners.
|
|
56
|
+
*
|
|
57
|
+
* @default 0
|
|
58
|
+
*/
|
|
59
|
+
cornerRadius?: number;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The rotation of the polygon.
|
|
63
|
+
*
|
|
64
|
+
* @default 0
|
|
65
|
+
*/
|
|
66
|
+
rotate?: number;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The percent to inset the odd points of the star (<1 inset, >1 outset)
|
|
70
|
+
*
|
|
71
|
+
* @default 0
|
|
72
|
+
*/
|
|
73
|
+
inset?: number;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The horizontal stretch factor of the polygon.
|
|
77
|
+
*
|
|
78
|
+
* @default 1
|
|
79
|
+
*/
|
|
80
|
+
scaleX?: number;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The vertical stretch factor of the polygon.
|
|
84
|
+
*
|
|
85
|
+
* @default 1
|
|
86
|
+
*/
|
|
87
|
+
scaleY?: number;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The skew angle in degrees along the X axis.
|
|
91
|
+
*
|
|
92
|
+
* @default 0
|
|
93
|
+
*/
|
|
94
|
+
skewX?: number;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The skew angle in degrees along the Y axis.
|
|
98
|
+
*
|
|
99
|
+
* @default 0
|
|
100
|
+
*/
|
|
101
|
+
skewY?: number;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The tilt factor for x-coordinates.
|
|
105
|
+
*
|
|
106
|
+
* @default 1
|
|
107
|
+
*/
|
|
108
|
+
tiltX?: number;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The tilt factor for y-coordinates.
|
|
112
|
+
*
|
|
113
|
+
* @default 1
|
|
114
|
+
*/
|
|
115
|
+
tiltY?: number;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A bindable reference to the `<path>` element
|
|
119
|
+
*
|
|
120
|
+
* @bindable
|
|
121
|
+
*/
|
|
122
|
+
ref?: SVGPathElement;
|
|
123
|
+
|
|
124
|
+
motion?: MotionProp;
|
|
125
|
+
} & CommonStyleProps;
|
|
126
|
+
|
|
127
|
+
export type PolygonProps = PolygonPropsWithoutHTML &
|
|
128
|
+
Without<SVGAttributes<Element>, PolygonPropsWithoutHTML>;
|
|
129
|
+
</script>
|
|
130
|
+
|
|
131
|
+
<script lang="ts">
|
|
132
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
133
|
+
import { cls } from '@layerstack/tailwind';
|
|
134
|
+
import { merge } from 'lodash-es';
|
|
135
|
+
import { interpolatePath } from 'd3-interpolate-path';
|
|
136
|
+
|
|
137
|
+
import { getRenderContext } from './Chart.svelte';
|
|
138
|
+
import {
|
|
139
|
+
createMotion,
|
|
140
|
+
extractTweenConfig,
|
|
141
|
+
type MotionProp,
|
|
142
|
+
type ResolvedMotion,
|
|
143
|
+
} from '../utils/motion.svelte.js';
|
|
144
|
+
import { registerCanvasComponent } from './layout/Canvas.svelte';
|
|
145
|
+
import { renderPathData, type ComputedStylesOptions } from '../utils/canvas.js';
|
|
146
|
+
import { createKey } from '../utils/key.svelte.js';
|
|
147
|
+
import { layerClass } from '../utils/attributes.js';
|
|
148
|
+
import { polygon } from '../utils/shape.js';
|
|
149
|
+
import { roundedPolygonPath } from '../utils/path.js';
|
|
150
|
+
|
|
151
|
+
let {
|
|
152
|
+
cx = 0,
|
|
153
|
+
initialCx: initialCxProp,
|
|
154
|
+
cy = 0,
|
|
155
|
+
initialCy: initialCyProp,
|
|
156
|
+
r = 1,
|
|
157
|
+
initialR: initialRProp,
|
|
158
|
+
points = 4,
|
|
159
|
+
cornerRadius = 0,
|
|
160
|
+
rotate = 0,
|
|
161
|
+
inset = 0,
|
|
162
|
+
scaleX = 1,
|
|
163
|
+
scaleY = 1,
|
|
164
|
+
skewX = 0,
|
|
165
|
+
skewY = 0,
|
|
166
|
+
tiltX = 0,
|
|
167
|
+
tiltY = 0,
|
|
168
|
+
motion,
|
|
169
|
+
fill,
|
|
170
|
+
fillOpacity,
|
|
171
|
+
stroke,
|
|
172
|
+
strokeWidth,
|
|
173
|
+
opacity,
|
|
174
|
+
class: className,
|
|
175
|
+
ref: refProp = $bindable(),
|
|
176
|
+
...restProps
|
|
177
|
+
}: PolygonProps = $props();
|
|
178
|
+
|
|
179
|
+
let ref = $state<SVGPathElement>();
|
|
180
|
+
|
|
181
|
+
$effect.pre(() => {
|
|
182
|
+
refProp = ref;
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const initialCx = initialCxProp ?? cx;
|
|
186
|
+
const initialCy = initialCyProp ?? cy;
|
|
187
|
+
const initialR = initialRProp ?? r;
|
|
188
|
+
|
|
189
|
+
const motionCx = createMotion(initialCx, () => cx, motion);
|
|
190
|
+
const motionCy = createMotion(initialCy, () => cy, motion);
|
|
191
|
+
const motionR = createMotion(initialR, () => r, motion);
|
|
192
|
+
|
|
193
|
+
let polygonPoints = $derived(
|
|
194
|
+
typeof points === 'number'
|
|
195
|
+
? polygon({
|
|
196
|
+
cx: motionCx.current,
|
|
197
|
+
cy: motionCy.current,
|
|
198
|
+
count: points,
|
|
199
|
+
radius: motionR.current,
|
|
200
|
+
rotate,
|
|
201
|
+
inset,
|
|
202
|
+
scaleX,
|
|
203
|
+
scaleY,
|
|
204
|
+
skewX,
|
|
205
|
+
skewY,
|
|
206
|
+
tiltX,
|
|
207
|
+
tiltY,
|
|
208
|
+
})
|
|
209
|
+
: points
|
|
210
|
+
);
|
|
211
|
+
let d = $derived(roundedPolygonPath(polygonPoints, cornerRadius));
|
|
212
|
+
|
|
213
|
+
const extractedTween = extractTweenConfig(motion);
|
|
214
|
+
|
|
215
|
+
const tweenedOptions: ResolvedMotion | undefined = extractedTween
|
|
216
|
+
? {
|
|
217
|
+
type: extractedTween.type,
|
|
218
|
+
options: { interpolate: interpolatePath, ...extractedTween.options },
|
|
219
|
+
}
|
|
220
|
+
: undefined;
|
|
221
|
+
|
|
222
|
+
const tweenedState = createMotion(null, () => d, tweenedOptions);
|
|
223
|
+
|
|
224
|
+
const renderCtx = getRenderContext();
|
|
225
|
+
|
|
226
|
+
function render(
|
|
227
|
+
ctx: CanvasRenderingContext2D,
|
|
228
|
+
styleOverrides: ComputedStylesOptions | undefined
|
|
229
|
+
) {
|
|
230
|
+
renderPathData(
|
|
231
|
+
ctx,
|
|
232
|
+
tweenedState.current,
|
|
233
|
+
styleOverrides
|
|
234
|
+
? merge({ styles: { strokeWidth } }, styleOverrides)
|
|
235
|
+
: {
|
|
236
|
+
styles: { fill, fillOpacity, stroke, strokeWidth, opacity },
|
|
237
|
+
classes: cls(layerClass('polygon'), fill == null && 'fill-surface-content', className),
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// TODO: Use objectId to work around Svelte 4 reactivity issue (even when memoizing gradients)
|
|
243
|
+
const fillKey = createKey(() => fill);
|
|
244
|
+
const strokeKey = createKey(() => stroke);
|
|
245
|
+
|
|
246
|
+
if (renderCtx === 'canvas') {
|
|
247
|
+
registerCanvasComponent({
|
|
248
|
+
name: 'Polygon',
|
|
249
|
+
render,
|
|
250
|
+
events: {
|
|
251
|
+
click: restProps.onclick,
|
|
252
|
+
pointerenter: restProps.onpointerenter,
|
|
253
|
+
pointermove: restProps.onpointermove,
|
|
254
|
+
pointerleave: restProps.onpointerleave,
|
|
255
|
+
pointerdown: restProps.onpointerdown,
|
|
256
|
+
pointerover: restProps.onpointerover,
|
|
257
|
+
pointerout: restProps.onpointerout,
|
|
258
|
+
touchmove: restProps.ontouchmove,
|
|
259
|
+
},
|
|
260
|
+
deps: () => [
|
|
261
|
+
fillKey.current,
|
|
262
|
+
fillOpacity,
|
|
263
|
+
strokeKey.current,
|
|
264
|
+
strokeWidth,
|
|
265
|
+
opacity,
|
|
266
|
+
className,
|
|
267
|
+
tweenedState.current,
|
|
268
|
+
],
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
</script>
|
|
272
|
+
|
|
273
|
+
{#if renderCtx === 'svg'}
|
|
274
|
+
<path
|
|
275
|
+
d={tweenedState.current}
|
|
276
|
+
{fill}
|
|
277
|
+
fill-opacity={fillOpacity}
|
|
278
|
+
{stroke}
|
|
279
|
+
stroke-width={strokeWidth}
|
|
280
|
+
{opacity}
|
|
281
|
+
class={cls(layerClass('polygon'), fill == null && 'fill-surface-content', className)}
|
|
282
|
+
{...restProps}
|
|
283
|
+
bind:this={ref}
|
|
284
|
+
/>
|
|
285
|
+
{/if}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { CommonStyleProps, Without } from '../utils/types.js';
|
|
2
|
+
export type PolygonPropsWithoutHTML = {
|
|
3
|
+
/**
|
|
4
|
+
* The center x position of the polygon.
|
|
5
|
+
*
|
|
6
|
+
* @default 0
|
|
7
|
+
*/
|
|
8
|
+
cx?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The initial center x position of the polygon.
|
|
11
|
+
*
|
|
12
|
+
* @default cx
|
|
13
|
+
*/
|
|
14
|
+
initialCx?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The center y position of the polygon.
|
|
17
|
+
*
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
cy?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The initial center y position of the polygon.
|
|
23
|
+
*
|
|
24
|
+
* @default cy
|
|
25
|
+
*/
|
|
26
|
+
initialCy?: number;
|
|
27
|
+
/**
|
|
28
|
+
* The radius of the polygon.
|
|
29
|
+
*
|
|
30
|
+
* @default 1
|
|
31
|
+
*/
|
|
32
|
+
r?: number;
|
|
33
|
+
/**
|
|
34
|
+
* The initial radius of the polygon.
|
|
35
|
+
*
|
|
36
|
+
* @default r
|
|
37
|
+
*/
|
|
38
|
+
initialR?: number;
|
|
39
|
+
/**
|
|
40
|
+
* The number of points or explicit points to create the polygon.
|
|
41
|
+
*
|
|
42
|
+
* @default 4
|
|
43
|
+
*/
|
|
44
|
+
points?: number | {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
}[];
|
|
48
|
+
/**
|
|
49
|
+
* The radius of the curve for rounded corners.
|
|
50
|
+
*
|
|
51
|
+
* @default 0
|
|
52
|
+
*/
|
|
53
|
+
cornerRadius?: number;
|
|
54
|
+
/**
|
|
55
|
+
* The rotation of the polygon.
|
|
56
|
+
*
|
|
57
|
+
* @default 0
|
|
58
|
+
*/
|
|
59
|
+
rotate?: number;
|
|
60
|
+
/**
|
|
61
|
+
* The percent to inset the odd points of the star (<1 inset, >1 outset)
|
|
62
|
+
*
|
|
63
|
+
* @default 0
|
|
64
|
+
*/
|
|
65
|
+
inset?: number;
|
|
66
|
+
/**
|
|
67
|
+
* The horizontal stretch factor of the polygon.
|
|
68
|
+
*
|
|
69
|
+
* @default 1
|
|
70
|
+
*/
|
|
71
|
+
scaleX?: number;
|
|
72
|
+
/**
|
|
73
|
+
* The vertical stretch factor of the polygon.
|
|
74
|
+
*
|
|
75
|
+
* @default 1
|
|
76
|
+
*/
|
|
77
|
+
scaleY?: number;
|
|
78
|
+
/**
|
|
79
|
+
* The skew angle in degrees along the X axis.
|
|
80
|
+
*
|
|
81
|
+
* @default 0
|
|
82
|
+
*/
|
|
83
|
+
skewX?: number;
|
|
84
|
+
/**
|
|
85
|
+
* The skew angle in degrees along the Y axis.
|
|
86
|
+
*
|
|
87
|
+
* @default 0
|
|
88
|
+
*/
|
|
89
|
+
skewY?: number;
|
|
90
|
+
/**
|
|
91
|
+
* The tilt factor for x-coordinates.
|
|
92
|
+
*
|
|
93
|
+
* @default 1
|
|
94
|
+
*/
|
|
95
|
+
tiltX?: number;
|
|
96
|
+
/**
|
|
97
|
+
* The tilt factor for y-coordinates.
|
|
98
|
+
*
|
|
99
|
+
* @default 1
|
|
100
|
+
*/
|
|
101
|
+
tiltY?: number;
|
|
102
|
+
/**
|
|
103
|
+
* A bindable reference to the `<path>` element
|
|
104
|
+
*
|
|
105
|
+
* @bindable
|
|
106
|
+
*/
|
|
107
|
+
ref?: SVGPathElement;
|
|
108
|
+
motion?: MotionProp;
|
|
109
|
+
} & CommonStyleProps;
|
|
110
|
+
export type PolygonProps = PolygonPropsWithoutHTML & Without<SVGAttributes<Element>, PolygonPropsWithoutHTML>;
|
|
111
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
112
|
+
import { type MotionProp } from '../utils/motion.svelte.js';
|
|
113
|
+
declare const Polygon: import("svelte").Component<PolygonProps, {}, "ref">;
|
|
114
|
+
type Polygon = ReturnType<typeof Polygon>;
|
|
115
|
+
export default Polygon;
|
|
@@ -87,23 +87,23 @@
|
|
|
87
87
|
/**
|
|
88
88
|
* Add additional content at the start of the line.
|
|
89
89
|
*
|
|
90
|
-
* Receives `{ point: DOMPoint }` as a snippet prop.
|
|
90
|
+
* Receives `{ point: DOMPoint; value: { x: number; y: number } }` as a snippet prop.
|
|
91
91
|
*/
|
|
92
|
-
startContent?: Snippet<[{ point: DOMPoint }]>;
|
|
92
|
+
startContent?: Snippet<[{ point: DOMPoint; value: { x: number; y: number } }]>;
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* Add additional content at the end of the line.
|
|
96
96
|
*
|
|
97
|
-
* Receives `{ point: DOMPoint }` as a snippet prop.
|
|
97
|
+
* Receives `{ point: DOMPoint; value: { x: number; y: number } }` as a snippet prop.
|
|
98
98
|
*/
|
|
99
|
-
endContent?: Snippet<[{ point: DOMPoint }]>;
|
|
99
|
+
endContent?: Snippet<[{ point: DOMPoint; value: { x: number; y: number } }]>;
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* A reference to the `<path>` element.
|
|
103
103
|
*
|
|
104
104
|
* @bindable
|
|
105
105
|
*/
|
|
106
|
-
|
|
106
|
+
pathRef?: SVGPathElement;
|
|
107
107
|
|
|
108
108
|
motion?: MotionProp;
|
|
109
109
|
} & CommonStyleProps;
|
|
@@ -159,14 +159,14 @@
|
|
|
159
159
|
startContent,
|
|
160
160
|
endContent,
|
|
161
161
|
opacity,
|
|
162
|
-
|
|
162
|
+
pathRef: pathRefProp = $bindable(),
|
|
163
163
|
...restProps
|
|
164
164
|
}: SplineProps = $props();
|
|
165
165
|
|
|
166
|
-
let
|
|
166
|
+
let pathRef = $state<SVGPathElement>();
|
|
167
167
|
|
|
168
168
|
$effect.pre(() => {
|
|
169
|
-
|
|
169
|
+
pathRefProp = pathRef;
|
|
170
170
|
});
|
|
171
171
|
|
|
172
172
|
const markerStart = $derived(markerStartProp ?? marker);
|
|
@@ -331,8 +331,8 @@
|
|
|
331
331
|
easing: typeof draw === 'object' && draw.easing ? draw.easing : cubicInOut,
|
|
332
332
|
interpolate() {
|
|
333
333
|
return (t: number) => {
|
|
334
|
-
const totalLength =
|
|
335
|
-
const point =
|
|
334
|
+
const totalLength = pathRef?.getTotalLength() ?? 0;
|
|
335
|
+
const point = pathRef?.getPointAtLength(totalLength * t);
|
|
336
336
|
return point;
|
|
337
337
|
};
|
|
338
338
|
},
|
|
@@ -343,10 +343,10 @@
|
|
|
343
343
|
$effect(() => {
|
|
344
344
|
if (!startContent && !endContent) return;
|
|
345
345
|
d;
|
|
346
|
-
if (!
|
|
347
|
-
startPoint =
|
|
348
|
-
const totalLength =
|
|
349
|
-
endPoint.target =
|
|
346
|
+
if (!pathRef || !pathRef.getTotalLength()) return;
|
|
347
|
+
startPoint = pathRef.getPointAtLength(0);
|
|
348
|
+
const totalLength = pathRef.getTotalLength();
|
|
349
|
+
endPoint.target = pathRef.getPointAtLength(totalLength);
|
|
350
350
|
});
|
|
351
351
|
|
|
352
352
|
$effect(() => {
|
|
@@ -377,7 +377,7 @@
|
|
|
377
377
|
marker-mid={markerMidId ? `url(#${markerMidId})` : undefined}
|
|
378
378
|
marker-end={markerEndId ? `url(#${markerEndId})` : undefined}
|
|
379
379
|
in:drawTransition|global={typeof draw === 'object' ? draw : undefined}
|
|
380
|
-
bind:this={
|
|
380
|
+
bind:this={pathRef}
|
|
381
381
|
/>
|
|
382
382
|
<MarkerWrapper id={markerStartId} marker={markerStart} />
|
|
383
383
|
<MarkerWrapper id={markerMidId} marker={markerMid} />
|
|
@@ -385,13 +385,25 @@
|
|
|
385
385
|
|
|
386
386
|
{#if startContent && startPoint}
|
|
387
387
|
<Group x={startPoint.x} y={startPoint.y} class={layerClass('spline-g-start')}>
|
|
388
|
-
{@render startContent({
|
|
388
|
+
{@render startContent({
|
|
389
|
+
point: startPoint,
|
|
390
|
+
value: {
|
|
391
|
+
x: ctx.xScale?.invert?.(startPoint.x),
|
|
392
|
+
y: ctx.yScale?.invert?.(startPoint.y),
|
|
393
|
+
},
|
|
394
|
+
})}
|
|
389
395
|
</Group>
|
|
390
396
|
{/if}
|
|
391
397
|
|
|
392
398
|
{#if endContent && endPoint.current}
|
|
393
399
|
<Group x={endPoint.current.x} y={endPoint.current.y} class={layerClass('spline-g-end')}>
|
|
394
|
-
{@render endContent({
|
|
400
|
+
{@render endContent({
|
|
401
|
+
point: endPoint.current,
|
|
402
|
+
value: {
|
|
403
|
+
x: ctx.xScale?.invert?.(endPoint.current.x),
|
|
404
|
+
y: ctx.yScale?.invert?.(endPoint.current.y),
|
|
405
|
+
},
|
|
406
|
+
})}
|
|
395
407
|
</Group>
|
|
396
408
|
{/if}
|
|
397
409
|
{/key}
|
|
@@ -67,29 +67,37 @@ export type SplinePropsWithoutHTML = {
|
|
|
67
67
|
/**
|
|
68
68
|
* Add additional content at the start of the line.
|
|
69
69
|
*
|
|
70
|
-
* Receives `{ point: DOMPoint }` as a snippet prop.
|
|
70
|
+
* Receives `{ point: DOMPoint; value: { x: number; y: number } }` as a snippet prop.
|
|
71
71
|
*/
|
|
72
72
|
startContent?: Snippet<[{
|
|
73
73
|
point: DOMPoint;
|
|
74
|
+
value: {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
};
|
|
74
78
|
}]>;
|
|
75
79
|
/**
|
|
76
80
|
* Add additional content at the end of the line.
|
|
77
81
|
*
|
|
78
|
-
* Receives `{ point: DOMPoint }` as a snippet prop.
|
|
82
|
+
* Receives `{ point: DOMPoint; value: { x: number; y: number } }` as a snippet prop.
|
|
79
83
|
*/
|
|
80
84
|
endContent?: Snippet<[{
|
|
81
85
|
point: DOMPoint;
|
|
86
|
+
value: {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
};
|
|
82
90
|
}]>;
|
|
83
91
|
/**
|
|
84
92
|
* A reference to the `<path>` element.
|
|
85
93
|
*
|
|
86
94
|
* @bindable
|
|
87
95
|
*/
|
|
88
|
-
|
|
96
|
+
pathRef?: SVGPathElement;
|
|
89
97
|
motion?: MotionProp;
|
|
90
98
|
} & CommonStyleProps;
|
|
91
99
|
export type SplineProps = SplinePropsWithoutHTML & Without<SVGAttributes<SVGPathElement>, SplinePropsWithoutHTML>;
|
|
92
100
|
import { draw as _drawTransition } from 'svelte/transition';
|
|
93
|
-
declare const Spline: import("svelte").Component<SplineProps, {}, "
|
|
101
|
+
declare const Spline: import("svelte").Component<SplineProps, {}, "pathRef">;
|
|
94
102
|
type Spline = ReturnType<typeof Spline>;
|
|
95
103
|
export default Spline;
|