layerchart 2.0.0-next.1 → 2.0.0-next.3
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 +143 -0
- package/dist/components/AnnotationLine.svelte.d.ts +30 -0
- package/dist/components/AnnotationPoint.svelte +119 -0
- package/dist/components/AnnotationPoint.svelte.d.ts +34 -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 +283 -180
- package/dist/components/Axis.svelte.d.ts +117 -0
- package/dist/components/Bar.svelte +166 -107
- package/dist/components/Bar.svelte.d.ts +51 -0
- package/dist/components/Bars.svelte +56 -67
- package/dist/components/Bars.svelte.d.ts +27 -0
- package/dist/components/Blur.svelte +42 -12
- 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 +71 -21
- 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 +49 -13
- 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 +30 -14
- package/dist/components/Graticule.svelte.d.ts +11 -52
- package/dist/components/Grid.svelte +230 -117
- package/dist/components/Grid.svelte.d.ts +71 -0
- package/dist/components/Group.svelte +173 -106
- package/dist/components/Group.svelte.d.ts +81 -0
- package/dist/components/Highlight.svelte +410 -308
- package/dist/components/Highlight.svelte.d.ts +107 -0
- package/dist/components/Hull.svelte +97 -46
- package/dist/components/Hull.svelte.d.ts +40 -30
- package/dist/components/Labels.svelte +127 -47
- 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 +107 -63
- 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 +108 -76
- 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 +21 -19
- 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
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { MarkerOptions } from './MarkerWrapper.svelte';
|
|
2
|
+
import type { Without } from '../utils/types.js';
|
|
3
|
+
import type { MotionNoneOption, MotionTweenOption } from '../utils/motion.svelte.js';
|
|
4
|
+
import { type CurveFactory } from 'd3-shape';
|
|
5
|
+
export type LinkPropsWithoutHTML = {
|
|
6
|
+
data?: any;
|
|
7
|
+
/**
|
|
8
|
+
* Update source and target accessors to be compatible with d3-sankey. see: https://github.com/d3/d3-sankey#sankeyLinkHorizontal
|
|
9
|
+
*
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
sankey?: boolean;
|
|
13
|
+
source?: (d: any) => any;
|
|
14
|
+
target?: (d: any) => any;
|
|
15
|
+
/**
|
|
16
|
+
* Convenient property to swap x/y accessor logic
|
|
17
|
+
*/
|
|
18
|
+
orientation?: 'vertical' | 'horizontal';
|
|
19
|
+
x?: (d: any) => any;
|
|
20
|
+
y?: (d: any) => any;
|
|
21
|
+
curve?: CurveFactory;
|
|
22
|
+
/**
|
|
23
|
+
* Marker to attach to both start and end points of the line
|
|
24
|
+
*/
|
|
25
|
+
marker?: MarkerOptions;
|
|
26
|
+
/**
|
|
27
|
+
* Marker to attach to the middle point of the line
|
|
28
|
+
*/
|
|
29
|
+
markerMid?: MarkerOptions;
|
|
30
|
+
/**
|
|
31
|
+
* Marker to attach to the start point of the line
|
|
32
|
+
*/
|
|
33
|
+
markerStart?: MarkerOptions;
|
|
34
|
+
/**
|
|
35
|
+
* Marker to attach to the end point of the line
|
|
36
|
+
*/
|
|
37
|
+
markerEnd?: MarkerOptions;
|
|
38
|
+
/**
|
|
39
|
+
* Apply explicit coordinates to the line. Useful when dealing with
|
|
40
|
+
* force simulation links.
|
|
41
|
+
*/
|
|
42
|
+
explicitCoords?: {
|
|
43
|
+
x1: number;
|
|
44
|
+
y1: number;
|
|
45
|
+
x2: number;
|
|
46
|
+
y2: number;
|
|
47
|
+
};
|
|
48
|
+
motion?: MotionTweenOption | MotionNoneOption;
|
|
49
|
+
};
|
|
50
|
+
export type LinkProps = LinkPropsWithoutHTML & Without<ConnectorProps, LinkPropsWithoutHTML>;
|
|
51
|
+
import { type ConnectorProps } from './Connector.svelte';
|
|
52
|
+
declare const Link: import("svelte").Component<LinkProps, {}, "">;
|
|
53
|
+
type Link = ReturnType<typeof Link>;
|
|
54
|
+
export default Link;
|
|
@@ -1,37 +1,97 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Without } from '../utils/types.js';
|
|
3
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
export type MarkerPropsWithoutHTML = {
|
|
6
|
+
/**
|
|
7
|
+
* The type of marker to render (e.g., arrow, triangle, etc.)
|
|
8
|
+
*
|
|
9
|
+
* Pass `children` to render a custom element/component inside the marker instead.
|
|
10
|
+
*/
|
|
11
|
+
type?: 'arrow' | 'triangle' | 'line' | 'circle' | 'circle-stroke' | 'dot';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Unique identifier for the marker
|
|
15
|
+
*/
|
|
16
|
+
id?: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Size of the marker
|
|
20
|
+
* (used as default for width and height if not overridden)
|
|
21
|
+
* @default 10
|
|
22
|
+
*/
|
|
23
|
+
size?: number;
|
|
4
24
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Width of the marker (can be a string or number)
|
|
27
|
+
* @default size
|
|
28
|
+
*/
|
|
29
|
+
markerWidth?: string | number;
|
|
8
30
|
|
|
9
|
-
|
|
10
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Height of the marker (can be a string or number)
|
|
33
|
+
* @default size
|
|
34
|
+
*/
|
|
35
|
+
markerHeight?: string | number;
|
|
11
36
|
|
|
12
|
-
|
|
13
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Units for marker dimensions ('userSpaceOnUse' or 'strokeWidth')
|
|
39
|
+
* @default 'userSpaceOnUse'
|
|
40
|
+
*/
|
|
41
|
+
markerUnits?: 'userSpaceOnUse' | 'strokeWidth';
|
|
14
42
|
|
|
15
|
-
|
|
16
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Orientation of the marker
|
|
45
|
+
* ('auto', 'auto-start-reverse', or a specific angle in degrees)
|
|
46
|
+
* @default 'auto-start-reverse'
|
|
47
|
+
*/
|
|
48
|
+
orient?: 'auto' | 'auto-start-reverse' | number;
|
|
17
49
|
|
|
18
|
-
|
|
19
|
-
|
|
50
|
+
/**
|
|
51
|
+
* X-coordinate offset of the marker's reference point
|
|
52
|
+
* @default 9 if type is 'arrow' or 'triangle', otherwise 5
|
|
53
|
+
*/
|
|
54
|
+
refX?: string | number;
|
|
20
55
|
|
|
21
|
-
|
|
22
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Y-coordinate offset of the marker's reference point
|
|
58
|
+
* @default 5
|
|
59
|
+
*/
|
|
60
|
+
refY?: string | number;
|
|
23
61
|
|
|
24
|
-
|
|
25
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Viewbox defining the coordinate system for the marker (e.g., '0 0 10 10')
|
|
64
|
+
* @default '0 0 10 10'
|
|
65
|
+
*/
|
|
66
|
+
viewBox?: string;
|
|
67
|
+
};
|
|
26
68
|
|
|
27
|
-
|
|
28
|
-
|
|
69
|
+
export type MarkerProps = MarkerPropsWithoutHTML &
|
|
70
|
+
Without<SVGAttributes<SVGMarkerElement>, MarkerPropsWithoutHTML>;
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<script lang="ts">
|
|
74
|
+
import { cls } from '@layerstack/tailwind';
|
|
75
|
+
import { createId } from '../utils/createId.js';
|
|
76
|
+
import { layerClass } from '../utils/attributes.js';
|
|
29
77
|
|
|
30
|
-
|
|
31
|
-
export let refY: string | number = 5;
|
|
78
|
+
const uid = $props.id();
|
|
32
79
|
|
|
33
|
-
|
|
34
|
-
|
|
80
|
+
let {
|
|
81
|
+
type,
|
|
82
|
+
id = createId('marker-', uid),
|
|
83
|
+
size = 10,
|
|
84
|
+
markerWidth = size,
|
|
85
|
+
markerHeight = size,
|
|
86
|
+
markerUnits = 'userSpaceOnUse',
|
|
87
|
+
orient = 'auto-start-reverse',
|
|
88
|
+
refX = ['arrow', 'triangle'].includes(type ?? '') ? 9 : 5,
|
|
89
|
+
refY = 5,
|
|
90
|
+
viewBox = '0 0 10 10',
|
|
91
|
+
class: className,
|
|
92
|
+
children,
|
|
93
|
+
...restProps
|
|
94
|
+
}: MarkerProps = $props();
|
|
35
95
|
</script>
|
|
36
96
|
|
|
37
97
|
<defs>
|
|
@@ -44,11 +104,12 @@
|
|
|
44
104
|
{refX}
|
|
45
105
|
{refY}
|
|
46
106
|
{viewBox}
|
|
47
|
-
{
|
|
107
|
+
{...restProps}
|
|
48
108
|
class={cls(
|
|
109
|
+
layerClass('marker'),
|
|
49
110
|
'overflow-visible',
|
|
50
111
|
// stroke
|
|
51
|
-
|
|
112
|
+
restProps.stroke == null &&
|
|
52
113
|
(['arrow', 'circle-stroke', 'line'].includes(type ?? '')
|
|
53
114
|
? 'stroke-[context-stroke]'
|
|
54
115
|
: type === 'circle'
|
|
@@ -57,25 +118,25 @@
|
|
|
57
118
|
// extra stroke attrs
|
|
58
119
|
'[stroke-linecap:round] [stroke-linejoin:round]',
|
|
59
120
|
//fill
|
|
60
|
-
|
|
121
|
+
restProps.fill == null &&
|
|
61
122
|
(['triangle', 'dot', 'circle'].includes(type ?? '')
|
|
62
123
|
? 'fill-[context-stroke]'
|
|
63
124
|
: type === 'circle-stroke'
|
|
64
125
|
? 'fill-surface-100'
|
|
65
126
|
: 'fill-none'),
|
|
66
|
-
|
|
127
|
+
className
|
|
67
128
|
)}
|
|
68
129
|
>
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
|
|
130
|
+
{#if children}
|
|
131
|
+
{@render children()}
|
|
132
|
+
{:else if type === 'triangle'}
|
|
133
|
+
<path d="M 0 0 L 10 5 L 0 10 z" class={layerClass('marker-triangle')} />
|
|
134
|
+
{:else if type === 'arrow'}
|
|
135
|
+
<polyline points="0 0, 10 5, 0 10" class={layerClass('marker-arrow')} />
|
|
136
|
+
{:else if type === 'circle' || type === 'circle-stroke' || type === 'dot'}
|
|
137
|
+
<circle cx={5} cy={5} r={5} class={layerClass('marker-circle')} />
|
|
138
|
+
{:else if type === 'line'}
|
|
139
|
+
<polyline points="5 0, 5 10" class={layerClass('marker-line')} />
|
|
140
|
+
{/if}
|
|
80
141
|
</marker>
|
|
81
142
|
</defs>
|
|
@@ -1,28 +1,60 @@
|
|
|
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 { SVGAttributes } from 'svelte/elements';
|
|
3
|
+
export type MarkerPropsWithoutHTML = {
|
|
4
|
+
/**
|
|
5
|
+
* The type of marker to render (e.g., arrow, triangle, etc.)
|
|
6
|
+
*
|
|
7
|
+
* Pass `children` to render a custom element/component inside the marker instead.
|
|
8
|
+
*/
|
|
9
|
+
type?: 'arrow' | 'triangle' | 'line' | 'circle' | 'circle-stroke' | 'dot';
|
|
10
|
+
/**
|
|
11
|
+
* Unique identifier for the marker
|
|
12
|
+
*/
|
|
13
|
+
id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Size of the marker
|
|
16
|
+
* (used as default for width and height if not overridden)
|
|
17
|
+
* @default 10
|
|
18
|
+
*/
|
|
19
|
+
size?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Width of the marker (can be a string or number)
|
|
22
|
+
* @default size
|
|
23
|
+
*/
|
|
24
|
+
markerWidth?: string | number;
|
|
25
|
+
/**
|
|
26
|
+
* Height of the marker (can be a string or number)
|
|
27
|
+
* @default size
|
|
28
|
+
*/
|
|
29
|
+
markerHeight?: string | number;
|
|
30
|
+
/**
|
|
31
|
+
* Units for marker dimensions ('userSpaceOnUse' or 'strokeWidth')
|
|
32
|
+
* @default 'userSpaceOnUse'
|
|
33
|
+
*/
|
|
34
|
+
markerUnits?: 'userSpaceOnUse' | 'strokeWidth';
|
|
35
|
+
/**
|
|
36
|
+
* Orientation of the marker
|
|
37
|
+
* ('auto', 'auto-start-reverse', or a specific angle in degrees)
|
|
38
|
+
* @default 'auto-start-reverse'
|
|
39
|
+
*/
|
|
40
|
+
orient?: 'auto' | 'auto-start-reverse' | number;
|
|
41
|
+
/**
|
|
42
|
+
* X-coordinate offset of the marker's reference point
|
|
43
|
+
* @default 9 if type is 'arrow' or 'triangle', otherwise 5
|
|
44
|
+
*/
|
|
45
|
+
refX?: string | number;
|
|
46
|
+
/**
|
|
47
|
+
* Y-coordinate offset of the marker's reference point
|
|
48
|
+
* @default 5
|
|
49
|
+
*/
|
|
50
|
+
refY?: string | number;
|
|
51
|
+
/**
|
|
52
|
+
* Viewbox defining the coordinate system for the marker (e.g., '0 0 10 10')
|
|
53
|
+
* @default '0 0 10 10'
|
|
54
|
+
*/
|
|
55
|
+
viewBox?: string;
|
|
22
56
|
};
|
|
23
|
-
export type MarkerProps =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export default
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
57
|
+
export type MarkerProps = MarkerPropsWithoutHTML & Without<SVGAttributes<SVGMarkerElement>, MarkerPropsWithoutHTML>;
|
|
58
|
+
declare const Marker: import("svelte").Component<MarkerProps, {}, "">;
|
|
59
|
+
type Marker = ReturnType<typeof Marker>;
|
|
60
|
+
export default Marker;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import Marker from './Marker.svelte';
|
|
3
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
export type MarkerProps = {
|
|
6
|
+
/**
|
|
7
|
+
* A unique identifier for the marker.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The marker or marker options to render
|
|
13
|
+
*/
|
|
14
|
+
marker?: MarkerOptions;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type MarkerOptions =
|
|
18
|
+
| ComponentProps<typeof Marker>['type']
|
|
19
|
+
| ComponentProps<typeof Marker>
|
|
20
|
+
| Snippet<[{ id: string }]>;
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<script lang="ts">
|
|
24
|
+
let { id, marker }: MarkerProps = $props();
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
{#if typeof marker === 'function'}
|
|
28
|
+
{@render marker({ id })}
|
|
29
|
+
{:else if marker}
|
|
30
|
+
<Marker
|
|
31
|
+
{id}
|
|
32
|
+
type={typeof marker === 'string' ? marker : undefined}
|
|
33
|
+
{...typeof marker === 'object' ? marker : null}
|
|
34
|
+
/>
|
|
35
|
+
{/if}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Marker from './Marker.svelte';
|
|
2
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
3
|
+
export type MarkerProps = {
|
|
4
|
+
/**
|
|
5
|
+
* A unique identifier for the marker.
|
|
6
|
+
*/
|
|
7
|
+
id: string;
|
|
8
|
+
/**
|
|
9
|
+
* The marker or marker options to render
|
|
10
|
+
*/
|
|
11
|
+
marker?: MarkerOptions;
|
|
12
|
+
};
|
|
13
|
+
export type MarkerOptions = ComponentProps<typeof Marker>['type'] | ComponentProps<typeof Marker> | Snippet<[{
|
|
14
|
+
id: string;
|
|
15
|
+
}]>;
|
|
16
|
+
declare const MarkerWrapper: import("svelte").Component<MarkerProps, {}, "">;
|
|
17
|
+
type MarkerWrapper = ReturnType<typeof MarkerWrapper>;
|
|
18
|
+
export default MarkerWrapper;
|
|
@@ -1,32 +1,77 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Without } from '../utils/types.js';
|
|
3
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
export type MonthPathPropsWithoutHTML = {
|
|
6
|
+
/**
|
|
7
|
+
* The date to use for the month path.
|
|
8
|
+
*/
|
|
9
|
+
date: Date;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Size of cell.
|
|
13
|
+
* - `number` - sets width/height as same.
|
|
14
|
+
* - array - sets [width, height].
|
|
15
|
+
*/
|
|
16
|
+
cellSize: number | [number, number];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A bindable reference to the underlying `<path>` element.
|
|
20
|
+
*
|
|
21
|
+
* @bindable
|
|
22
|
+
*/
|
|
23
|
+
ref?: SVGPathElement;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type MonthPathProps = MonthPathPropsWithoutHTML &
|
|
27
|
+
Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML>;
|
|
28
|
+
</script>
|
|
29
|
+
|
|
1
30
|
<script lang="ts">
|
|
2
31
|
import { timeWeek, timeYear } from 'd3-time';
|
|
3
32
|
import { endOfMonth } from 'date-fns';
|
|
33
|
+
import { cls } from '@layerstack/tailwind';
|
|
34
|
+
import { layerClass } from '../utils/attributes.js';
|
|
4
35
|
|
|
5
|
-
|
|
36
|
+
let {
|
|
37
|
+
date,
|
|
38
|
+
cellSize: cellSizeProp,
|
|
39
|
+
ref: refProp = $bindable(),
|
|
40
|
+
class: className,
|
|
41
|
+
...restProps
|
|
42
|
+
}: MonthPathProps = $props();
|
|
6
43
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
44
|
+
let ref = $state<SVGPathElement>();
|
|
45
|
+
$effect.pre(() => {
|
|
46
|
+
refProp = ref;
|
|
47
|
+
});
|
|
11
48
|
|
|
12
|
-
|
|
49
|
+
const cellSize = $derived(
|
|
50
|
+
Array.isArray(cellSizeProp) ? cellSizeProp : [cellSizeProp, cellSizeProp]
|
|
51
|
+
);
|
|
13
52
|
|
|
14
53
|
// start of month
|
|
15
|
-
|
|
16
|
-
|
|
54
|
+
const startDayOfWeek = $derived(date.getDay());
|
|
55
|
+
const startWeek = $derived(timeWeek.count(timeYear(date), date));
|
|
17
56
|
|
|
18
57
|
// end of month
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
M${(startWeek + 1) *
|
|
25
|
-
H${startWeek *
|
|
26
|
-
H${endWeek *
|
|
27
|
-
H${(endWeek + 1) *
|
|
28
|
-
H${(startWeek + 1) *
|
|
29
|
-
|
|
58
|
+
const monthEnd = $derived(endOfMonth(date));
|
|
59
|
+
const endDayOfWeek = $derived(monthEnd.getDay());
|
|
60
|
+
const endWeek = $derived(timeWeek.count(timeYear(monthEnd), monthEnd));
|
|
61
|
+
|
|
62
|
+
const pathData = $derived(`
|
|
63
|
+
M${(startWeek + 1) * cellSize[0]},${startDayOfWeek * cellSize[1]}
|
|
64
|
+
H${startWeek * cellSize[0]} V${cellSize[1] * 7}
|
|
65
|
+
H${endWeek * cellSize[0]} V${(endDayOfWeek + 1) * cellSize[1]}
|
|
66
|
+
H${(endWeek + 1) * cellSize[0]} V0
|
|
67
|
+
H${(startWeek + 1) * cellSize[0]}Z
|
|
68
|
+
`);
|
|
30
69
|
</script>
|
|
31
70
|
|
|
32
|
-
<path
|
|
71
|
+
<path
|
|
72
|
+
bind:this={ref}
|
|
73
|
+
d={pathData}
|
|
74
|
+
fill="none"
|
|
75
|
+
class={cls(layerClass('month-path'), 'stroke-surface-content/20', className)}
|
|
76
|
+
{...restProps}
|
|
77
|
+
/>
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import type { Without } from '../utils/types.js';
|
|
2
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
3
|
+
export type MonthPathPropsWithoutHTML = {
|
|
4
|
+
/**
|
|
5
|
+
* The date to use for the month path.
|
|
6
|
+
*/
|
|
7
|
+
date: Date;
|
|
8
|
+
/**
|
|
9
|
+
* Size of cell.
|
|
10
|
+
* - `number` - sets width/height as same.
|
|
11
|
+
* - array - sets [width, height].
|
|
12
|
+
*/
|
|
13
|
+
cellSize: number | [number, number];
|
|
14
|
+
/**
|
|
15
|
+
* A bindable reference to the underlying `<path>` element.
|
|
16
|
+
*
|
|
17
|
+
* @bindable
|
|
18
|
+
*/
|
|
19
|
+
ref?: SVGPathElement;
|
|
12
20
|
};
|
|
13
|
-
export type MonthPathProps =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export default
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
21
|
+
export type MonthPathProps = MonthPathPropsWithoutHTML & Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML>;
|
|
22
|
+
declare const MonthPath: import("svelte").Component<MonthPathProps, {}, "ref">;
|
|
23
|
+
type MonthPath = ReturnType<typeof MonthPath>;
|
|
24
|
+
export default MonthPath;
|
|
@@ -1,26 +1,82 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export type MotionPathPropsWithoutHTML = {
|
|
5
|
+
/**
|
|
6
|
+
* Id of path to move object along
|
|
7
|
+
*/
|
|
8
|
+
pathId?: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Id of object to move along path
|
|
12
|
+
*/
|
|
13
|
+
objectId?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Duration of the animation
|
|
17
|
+
*/
|
|
18
|
+
duration: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Number of times the animation will occur
|
|
22
|
+
*/
|
|
23
|
+
repeatCount?: number | 'indefinite';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Final state of the animation. Freeze (last frame) or remove (first frame)
|
|
27
|
+
* https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill#animate
|
|
28
|
+
*
|
|
29
|
+
* @default 'freeze'
|
|
30
|
+
*/
|
|
31
|
+
fill?: 'freeze' | 'remove';
|
|
4
32
|
|
|
5
|
-
|
|
6
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Rotation applied to the element animated along a path, usually to make it pointing
|
|
35
|
+
* in the direction of the animation
|
|
36
|
+
*/
|
|
37
|
+
rotate?: number | 'auto' | 'auto-reverse';
|
|
7
38
|
|
|
8
|
-
|
|
9
|
-
|
|
39
|
+
/**
|
|
40
|
+
* A bindable reference to the underlying `<animateMotion>` element.
|
|
41
|
+
*
|
|
42
|
+
* @bindable
|
|
43
|
+
*/
|
|
44
|
+
ref?: SVGAnimateMotionElement;
|
|
10
45
|
|
|
11
|
-
|
|
12
|
-
|
|
46
|
+
children?: Snippet<[{ pathId: string; objectId: string }]>;
|
|
47
|
+
};
|
|
13
48
|
|
|
14
|
-
|
|
15
|
-
|
|
49
|
+
export type MotionPathProps = MotionPathPropsWithoutHTML &
|
|
50
|
+
Without<
|
|
51
|
+
Omit<SVGAttributes<SVGAnimateMotionElement>, 'dir' | 'href'>,
|
|
52
|
+
MotionPathPropsWithoutHTML
|
|
53
|
+
>;
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<script lang="ts">
|
|
57
|
+
import type { Without } from '../utils/types.js';
|
|
58
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
59
|
+
import { createId } from '../utils/createId.js';
|
|
60
|
+
import { extractLayerProps } from '../utils/attributes.js';
|
|
16
61
|
|
|
17
|
-
|
|
18
|
-
* https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill#animate
|
|
19
|
-
* */
|
|
20
|
-
export let fill: 'freeze' | 'remove' = 'freeze';
|
|
62
|
+
const uid = $props.id();
|
|
21
63
|
|
|
22
|
-
|
|
23
|
-
|
|
64
|
+
let {
|
|
65
|
+
pathId = createId('motionPathId-', uid),
|
|
66
|
+
objectId = createId('motionObjectId-', uid),
|
|
67
|
+
duration,
|
|
68
|
+
repeatCount,
|
|
69
|
+
fill = 'freeze',
|
|
70
|
+
rotate,
|
|
71
|
+
ref: refProp = $bindable(),
|
|
72
|
+
children,
|
|
73
|
+
...restProps
|
|
74
|
+
}: MotionPathPropsWithoutHTML = $props();
|
|
75
|
+
|
|
76
|
+
let ref = $state<SVGAnimateMotionElement>();
|
|
77
|
+
$effect.pre(() => {
|
|
78
|
+
refProp = ref;
|
|
79
|
+
});
|
|
24
80
|
|
|
25
81
|
// TODO: Investigate `calcMode:spline`, `keyTimes`, and `keySplines` to work with `svelte/easing`
|
|
26
82
|
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/calcMode
|
|
@@ -29,9 +85,10 @@
|
|
|
29
85
|
// https://medium.com/javarevisited/animate-your-scalable-vector-graphics-svg-56f5800cd34b
|
|
30
86
|
|
|
31
87
|
// Restart animation anytime the component is remounted (otherwise it only ever plays once)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
88
|
+
|
|
89
|
+
$effect(() => {
|
|
90
|
+
if (!ref) return;
|
|
91
|
+
ref.beginElement();
|
|
35
92
|
});
|
|
36
93
|
</script>
|
|
37
94
|
|
|
@@ -42,12 +99,11 @@
|
|
|
42
99
|
{repeatCount}
|
|
43
100
|
{fill}
|
|
44
101
|
{rotate}
|
|
45
|
-
bind:this={
|
|
102
|
+
bind:this={ref}
|
|
103
|
+
{...extractLayerProps(restProps, 'motion-path')}
|
|
46
104
|
>
|
|
47
105
|
<mpath href="#{pathId}" />
|
|
48
106
|
</animateMotion>
|
|
49
107
|
</defs>
|
|
50
108
|
|
|
51
|
-
{
|
|
52
|
-
<slot {pathId} {objectId} />
|
|
53
|
-
{/if}
|
|
109
|
+
{@render children?.({ pathId, objectId })}
|