layerchart 2.0.0-next.43 → 2.0.0-next.45

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.
Files changed (179) hide show
  1. package/LICENSE +1 -1
  2. package/dist/components/AnnotationLine.svelte +1 -1
  3. package/dist/components/AnnotationPoint.svelte +1 -1
  4. package/dist/components/AnnotationRange.svelte +16 -15
  5. package/dist/components/Arc.svelte +10 -10
  6. package/dist/components/Arc.svelte.d.ts +4 -4
  7. package/dist/components/Arc.svelte.test.d.ts +1 -0
  8. package/dist/components/Arc.svelte.test.js +868 -0
  9. package/dist/components/Area.svelte +9 -7
  10. package/dist/components/Axis.svelte +2 -1
  11. package/dist/components/Axis.svelte.d.ts +1 -0
  12. package/dist/components/Bar.svelte +3 -3
  13. package/dist/components/Bars.svelte +1 -1
  14. package/dist/components/Blur.svelte +3 -3
  15. package/dist/components/Bounds.svelte +1 -1
  16. package/dist/components/BrushContext.svelte +1 -1
  17. package/dist/components/Calendar.svelte +2 -2
  18. package/dist/components/Calendar.svelte.d.ts +1 -1
  19. package/dist/components/Chart.svelte +63 -137
  20. package/dist/components/Chart.svelte.d.ts +23 -88
  21. package/dist/components/ChartClipPath.svelte +1 -1
  22. package/dist/components/Circle.svelte +17 -8
  23. package/dist/components/Circle.svelte.d.ts +3 -0
  24. package/dist/components/ClipPath.svelte +4 -4
  25. package/dist/components/Connector.svelte +4 -4
  26. package/dist/components/Connector.svelte.d.ts +3 -3
  27. package/dist/components/Ellipse.svelte +7 -7
  28. package/dist/components/Frame.svelte +1 -1
  29. package/dist/components/GeoContext.svelte +4 -20
  30. package/dist/components/GeoContext.svelte.d.ts +2 -6
  31. package/dist/components/GeoEdgeFade.svelte +1 -1
  32. package/dist/components/GeoPath.svelte +42 -107
  33. package/dist/components/GeoPath.svelte.d.ts +5 -4
  34. package/dist/components/GeoPoint.svelte +5 -5
  35. package/dist/components/GeoSpline.svelte +2 -14
  36. package/dist/components/GeoSpline.svelte.d.ts +1 -1
  37. package/dist/components/GeoTile.svelte +7 -6
  38. package/dist/components/GeoVisible.svelte +1 -1
  39. package/dist/components/Graticule.svelte +4 -7
  40. package/dist/components/Graticule.svelte.d.ts +2 -1
  41. package/dist/components/Grid.svelte +1 -1
  42. package/dist/components/Group.svelte +8 -8
  43. package/dist/components/Highlight.svelte +18 -16
  44. package/dist/components/Hull.svelte +2 -2
  45. package/dist/components/Labels.svelte +1 -1
  46. package/dist/components/Legend.svelte +1 -1
  47. package/dist/components/Line.svelte +9 -7
  48. package/dist/components/LinearGradient.svelte +8 -7
  49. package/dist/components/MonthPath.svelte +5 -11
  50. package/dist/components/MonthPath.svelte.d.ts +2 -2
  51. package/dist/components/Pack.svelte +4 -6
  52. package/dist/components/Pack.svelte.d.ts +2 -4
  53. package/dist/components/Partition.svelte +4 -3
  54. package/dist/components/Partition.svelte.d.ts +2 -1
  55. package/dist/components/Path.svelte +344 -0
  56. package/dist/components/Path.svelte.d.ts +72 -0
  57. package/dist/components/Pattern.svelte +6 -6
  58. package/dist/components/Pie.svelte +2 -2
  59. package/dist/components/Pie.svelte.d.ts +1 -1
  60. package/dist/components/Point.svelte +1 -1
  61. package/dist/components/Points.svelte +1 -1
  62. package/dist/components/Polygon.svelte +8 -6
  63. package/dist/components/RadialGradient.svelte +7 -7
  64. package/dist/components/Rect.svelte +32 -10
  65. package/dist/components/Rect.svelte.d.ts +4 -1
  66. package/dist/components/Rule.svelte +1 -1
  67. package/dist/components/Sankey.svelte +1 -1
  68. package/dist/components/Spline.svelte +13 -337
  69. package/dist/components/Spline.svelte.d.ts +10 -73
  70. package/dist/components/Text.svelte +9 -7
  71. package/dist/components/Threshold.svelte +3 -3
  72. package/dist/components/TransformContext.svelte +10 -143
  73. package/dist/components/TransformControls.svelte +2 -2
  74. package/dist/components/TransformControls.svelte.d.ts +1 -1
  75. package/dist/components/Tree.svelte +4 -3
  76. package/dist/components/Tree.svelte.d.ts +2 -1
  77. package/dist/components/Treemap.svelte +4 -3
  78. package/dist/components/Treemap.svelte.d.ts +2 -1
  79. package/dist/components/Voronoi.svelte +5 -5
  80. package/dist/components/charts/ArcChart.svelte +14 -6
  81. package/dist/components/charts/ArcChart.svelte.d.ts +1 -1
  82. package/dist/components/charts/AreaChart.svelte +12 -6
  83. package/dist/components/charts/BarChart.svelte +12 -6
  84. package/dist/components/charts/DefaultTooltip.svelte +1 -1
  85. package/dist/components/charts/LineChart.svelte +12 -6
  86. package/dist/components/charts/PieChart.svelte +14 -6
  87. package/dist/components/charts/PieChart.svelte.d.ts +1 -1
  88. package/dist/components/charts/ScatterChart.svelte +11 -9
  89. package/dist/components/charts/types.d.ts +7 -6
  90. package/dist/components/index.d.ts +14 -12
  91. package/dist/components/index.js +14 -12
  92. package/dist/components/{layout → layers}/Canvas.svelte +13 -60
  93. package/dist/components/{layout → layers}/Canvas.svelte.d.ts +2 -32
  94. package/dist/components/{layout → layers}/Html.svelte +18 -3
  95. package/dist/components/{layout → layers}/Html.svelte.d.ts +7 -0
  96. package/dist/components/layers/Layer.svelte +85 -0
  97. package/dist/components/{layout → layers}/Layer.svelte.d.ts +7 -3
  98. package/dist/components/{layout → layers}/Svg.svelte +18 -3
  99. package/dist/components/{layout → layers}/Svg.svelte.d.ts +7 -0
  100. package/dist/components/{layout → layers}/WebGL.svelte +1 -1
  101. package/dist/components/{layout → layers}/WebGL.svelte.d.ts +3 -3
  102. package/dist/components/tests/TestHarness.svelte +76 -0
  103. package/dist/components/tests/TestHarness.svelte.d.ts +19 -0
  104. package/dist/components/tooltip/Tooltip.svelte +3 -3
  105. package/dist/components/tooltip/Tooltip.svelte.d.ts +1 -1
  106. package/dist/components/tooltip/TooltipContext.svelte +13 -45
  107. package/dist/components/tooltip/TooltipContext.svelte.d.ts +2 -14
  108. package/dist/components/tooltip/tooltipMetaContext.d.ts +2 -2
  109. package/dist/components/tooltip/tooltipMetaContext.js +2 -2
  110. package/dist/contexts/canvas.d.ts +33 -0
  111. package/dist/contexts/canvas.js +14 -0
  112. package/dist/contexts/chart.d.ts +84 -0
  113. package/dist/contexts/chart.js +10 -0
  114. package/dist/contexts/geo.d.ts +6 -0
  115. package/dist/contexts/geo.js +12 -0
  116. package/dist/contexts/index.d.ts +6 -0
  117. package/dist/contexts/index.js +6 -0
  118. package/dist/contexts/layer.d.ts +3 -0
  119. package/dist/contexts/layer.js +8 -0
  120. package/dist/contexts/settings.d.ts +4 -0
  121. package/dist/contexts/settings.js +10 -0
  122. package/dist/contexts/tooltip.d.ts +15 -0
  123. package/dist/contexts/tooltip.js +8 -0
  124. package/dist/contexts/transform.d.ts +95 -0
  125. package/dist/contexts/transform.js +10 -0
  126. package/dist/index.d.ts +1 -0
  127. package/dist/index.js +1 -0
  128. package/dist/states/settings.svelte.d.ts +12 -0
  129. package/dist/states/settings.svelte.js +10 -0
  130. package/dist/states/transform.svelte.d.ts +9 -0
  131. package/dist/states/transform.svelte.js +31 -0
  132. package/dist/styles/skeleton-4.css +15 -0
  133. package/dist/utils/arcText.svelte.d.ts +1 -1
  134. package/dist/utils/canvas.d.ts +7 -3
  135. package/dist/utils/canvas.js +78 -11
  136. package/dist/utils/color.js +11 -8
  137. package/dist/utils/common.d.ts +8 -1
  138. package/dist/utils/common.js +9 -10
  139. package/dist/utils/index.d.ts +2 -0
  140. package/dist/utils/index.js +2 -0
  141. package/dist/utils/motion.svelte.js +0 -1
  142. package/dist/utils/rect.svelte.d.ts +1 -1
  143. package/dist/utils/rect.svelte.js +17 -9
  144. package/dist/utils/string.d.ts +3 -1
  145. package/package.json +32 -54
  146. package/README.md +0 -41
  147. package/dist/components/layout/Layer.svelte +0 -41
  148. package/dist/docs/Blockquote.svelte +0 -17
  149. package/dist/docs/Blockquote.svelte.d.ts +0 -5
  150. package/dist/docs/Code.svelte +0 -80
  151. package/dist/docs/Code.svelte.d.ts +0 -14
  152. package/dist/docs/ConnectorSweepMenuField.svelte +0 -17
  153. package/dist/docs/ConnectorSweepMenuField.svelte.d.ts +0 -7
  154. package/dist/docs/ConnectorTypeMenuField.svelte +0 -17
  155. package/dist/docs/ConnectorTypeMenuField.svelte.d.ts +0 -7
  156. package/dist/docs/CurveMenuField.svelte +0 -44
  157. package/dist/docs/CurveMenuField.svelte.d.ts +0 -9
  158. package/dist/docs/GeoDebug.svelte +0 -60
  159. package/dist/docs/GeoDebug.svelte.d.ts +0 -4
  160. package/dist/docs/Header1.svelte +0 -16
  161. package/dist/docs/Header1.svelte.d.ts +0 -5
  162. package/dist/docs/Json.svelte +0 -36
  163. package/dist/docs/Json.svelte.d.ts +0 -10
  164. package/dist/docs/Layout.svelte +0 -21
  165. package/dist/docs/Layout.svelte.d.ts +0 -8
  166. package/dist/docs/Link.svelte +0 -9
  167. package/dist/docs/Link.svelte.d.ts +0 -5
  168. package/dist/docs/PathDataMenuField.svelte +0 -78
  169. package/dist/docs/PathDataMenuField.svelte.d.ts +0 -9
  170. package/dist/docs/Preview.svelte +0 -104
  171. package/dist/docs/Preview.svelte.d.ts +0 -13
  172. package/dist/docs/TilesetField.svelte +0 -136
  173. package/dist/docs/TilesetField.svelte.d.ts +0 -6
  174. package/dist/docs/TransformDebug.svelte +0 -22
  175. package/dist/docs/TransformDebug.svelte.d.ts +0 -20
  176. package/dist/docs/ViewSourceButton.svelte +0 -53
  177. package/dist/docs/ViewSourceButton.svelte.d.ts +0 -11
  178. /package/dist/{utils → contexts}/legendPayload.d.ts +0 -0
  179. /package/dist/{utils → contexts}/legendPayload.js +0 -0
@@ -6,7 +6,8 @@
6
6
  export type GraticulePropsWithoutHTML = {
7
7
  lines?: Partial<ComponentProps<typeof GeoPath>> | boolean | undefined;
8
8
  outline?: Partial<ComponentProps<typeof GeoPath>> | boolean | undefined;
9
- step?: [number, number];
9
+ stepX?: number;
10
+ stepY?: number;
10
11
  };
11
12
 
12
13
  export type GraticuleProps = GraticulePropsWithoutHTML &
@@ -18,13 +19,9 @@
18
19
  import { extractLayerProps } from '../utils/attributes.js';
19
20
  import Group from './Group.svelte';
20
21
 
21
- let { lines, outline, step = [10, 10], ...restProps }: GraticuleProps = $props();
22
+ let { lines, outline, stepX = 10, stepY = 10, ...restProps }: GraticuleProps = $props();
22
23
 
23
- const graticule = geoGraticule();
24
-
25
- $effect(() => {
26
- graticule.step(step);
27
- });
24
+ const graticule = $derived(geoGraticule().step([stepX, stepY]));
28
25
  </script>
29
26
 
30
27
  <Group class="lc-graticule-g">
@@ -4,7 +4,8 @@ import GeoPath, { type GeoPathProps } from './GeoPath.svelte';
4
4
  export type GraticulePropsWithoutHTML = {
5
5
  lines?: Partial<ComponentProps<typeof GeoPath>> | boolean | undefined;
6
6
  outline?: Partial<ComponentProps<typeof GeoPath>> | boolean | undefined;
7
- step?: [number, number];
7
+ stepX?: number;
8
+ stepY?: number;
8
9
  };
9
10
  export type GraticuleProps = GraticulePropsWithoutHTML & Without<GeoPathProps, Omit<GraticulePropsWithoutHTML, 'ref'>>;
10
11
  declare const Graticule: import("svelte").Component<GraticuleProps, {}, "">;
@@ -97,7 +97,7 @@
97
97
  import Line from './Line.svelte';
98
98
  import Rule from './Rule.svelte';
99
99
  import Spline from './Spline.svelte';
100
- import { getChartContext } from './Chart.svelte';
100
+ import { getChartContext } from '../contexts/chart.js';
101
101
  import { extractLayerProps } from '../utils/attributes.js';
102
102
  import { autoTickVals, type TicksConfig } from '../utils/ticks.js';
103
103
 
@@ -83,10 +83,10 @@
83
83
  import { fade } from 'svelte/transition';
84
84
  import { cubicIn } from 'svelte/easing';
85
85
 
86
- import { getRenderContext } from './Chart.svelte';
87
- import { registerCanvasComponent } from './layout/Canvas.svelte';
86
+ import { getLayerContext } from '../contexts/layer.js';
87
+ import { registerCanvasComponent } from './layers/Canvas.svelte';
88
88
 
89
- import { getChartContext } from './Chart.svelte';
89
+ import { getChartContext } from '../contexts/chart.js';
90
90
 
91
91
  const ctx = getChartContext();
92
92
 
@@ -134,9 +134,9 @@
134
134
  }
135
135
  });
136
136
 
137
- const renderCtx = getRenderContext();
137
+ const layerCtx = getLayerContext();
138
138
 
139
- if (renderCtx === 'canvas') {
139
+ if (layerCtx === 'canvas') {
140
140
  registerCanvasComponent({
141
141
  name: 'Group',
142
142
  render: (ctx) => {
@@ -170,9 +170,9 @@
170
170
  };
171
171
  </script>
172
172
 
173
- {#if renderCtx === 'canvas'}
173
+ {#if layerCtx === 'canvas'}
174
174
  {@render children?.()}
175
- {:else if renderCtx === 'svg'}
175
+ {:else if layerCtx === 'svg'}
176
176
  <g
177
177
  style:transform
178
178
  class={['lc-group-g', className]}
@@ -184,7 +184,7 @@
184
184
  >
185
185
  {@render children?.()}
186
186
  </g>
187
- {:else if renderCtx === 'html'}
187
+ {:else if layerCtx === 'html'}
188
188
  <div
189
189
  bind:this={ref}
190
190
  style:transform
@@ -122,8 +122,8 @@
122
122
 
123
123
  import { isScaleBand, isScaleTime } from '../utils/scales.svelte.js';
124
124
  import { asAny } from '../utils/types.js';
125
- import { getChartContext } from './Chart.svelte';
126
- import { getTooltipContext } from './tooltip/TooltipContext.svelte';
125
+ import { getChartContext } from '../contexts/chart.js';
126
+ import { getTooltipContext } from '../contexts/tooltip.js';
127
127
  import { extractLayerProps } from '../utils/attributes.js';
128
128
  import type { MotionProp } from '../utils/motion.svelte.js';
129
129
  import Arc from './Arc.svelte';
@@ -261,27 +261,28 @@
261
261
  // x area
262
262
  if (Array.isArray(xCoord)) {
263
263
  // `x` accessor with multiple properties (ex. `x={['start', 'end']})`)
264
+ tmpArea.x = min(xCoord);
264
265
  tmpArea.width = max(xCoord) - min(xCoord); // Use first/last values for width
265
266
  } else if (isScaleBand(ctx.xScale)) {
267
+ tmpArea.x = xCoord - (ctx.xScale.padding() * ctx.xScale.step()) / 2;
266
268
  tmpArea.width = ctx.xScale.step();
267
269
  } else if (ctx.xInterval) {
268
270
  // x-axis time scale with interval
269
271
  const start = ctx.xInterval.floor(xValue);
270
272
  const end = ctx.xInterval.offset(start);
271
- tmpArea.width = ctx.xScale(end) - ctx.xScale(start);
273
+ const xStart = ctx.xScale(start);
274
+ const xEnd = ctx.xScale(end);
275
+ tmpArea.x = Math.min(xStart, xEnd);
276
+ tmpArea.width = Math.abs(xEnd - xStart);
272
277
  } else {
273
278
  // Find width to next data point
274
279
  const index = ctx.flatData.findIndex((d) => Number(x(d)) === Number(x(highlightData)));
275
280
  const isLastPoint = index + 1 === ctx.flatData.length;
276
281
  const nextDataPoint = isLastPoint ? max(ctx.xDomain) : x(ctx.flatData[index + 1]);
282
+ tmpArea.x = xCoord;
277
283
  tmpArea.width = (ctx.xScale(nextDataPoint) ?? 0) - (xCoord ?? 0);
278
284
  }
279
285
 
280
- // If array, use left-most value for top left of rect
281
- tmpArea.x =
282
- (Array.isArray(xCoord) ? min(xCoord) : xCoord) -
283
- (isScaleBand(ctx.xScale) ? (ctx.xScale.padding() * ctx.xScale.step()) / 2 : 0);
284
-
285
286
  if (axis === 'x') {
286
287
  tmpArea.y = min(ctx.yRange) as unknown as number;
287
288
  tmpArea.height = (max(ctx.yRange) - min(ctx.yRange)) as unknown as number;
@@ -292,27 +293,28 @@
292
293
  // y area
293
294
  if (Array.isArray(yCoord)) {
294
295
  // `y` accessor with multiple properties (ex. `y={['start', 'end']})`)
295
- tmpArea.height = max(yCoord) - min(yCoord); // Use first/last values for width
296
+ tmpArea.y = min(yCoord);
297
+ tmpArea.height = max(yCoord) - min(yCoord); // Use first/last values for height
296
298
  } else if (isScaleBand(ctx.yScale)) {
299
+ tmpArea.y = yCoord - (ctx.yScale.padding() * ctx.yScale.step()) / 2;
297
300
  tmpArea.height = ctx.yScale.step();
298
301
  } else if (ctx.yInterval) {
299
302
  // y-axis time scale with interval
300
303
  const start = ctx.yInterval.floor(yValue);
301
304
  const end = ctx.yInterval.offset(start);
302
- tmpArea.height = ctx.yScale(end) - ctx.yScale(start);
305
+ const yStart = ctx.yScale(start);
306
+ const yEnd = ctx.yScale(end);
307
+ tmpArea.y = Math.min(yStart, yEnd);
308
+ tmpArea.height = Math.abs(yEnd - yStart);
303
309
  } else {
304
- // Find width to next data point
310
+ // Find height to next data point
305
311
  const index = ctx.flatData.findIndex((d) => Number(y(d)) === Number(y(highlightData)));
306
312
  const isLastPoint = index + 1 === ctx.flatData.length;
307
313
  const nextDataPoint = isLastPoint ? max(ctx.yDomain) : y(ctx.flatData[index + 1]);
314
+ tmpArea.y = yCoord;
308
315
  tmpArea.height = (ctx.yScale(nextDataPoint) ?? 0) - (yCoord ?? 0);
309
316
  }
310
317
 
311
- // If array, use left-most value for top left of rect
312
- tmpArea.y =
313
- (Array.isArray(yCoord) ? min(yCoord) : yCoord) -
314
- (isScaleBand(ctx.yScale) ? (ctx.yScale.padding() * ctx.yScale.step()) / 2 : 0);
315
-
316
318
  if (axis === 'y') {
317
319
  tmpArea.width = max(ctx.xRange) as unknown as number;
318
320
  }
@@ -63,8 +63,8 @@
63
63
  import GeoPath from './GeoPath.svelte';
64
64
  import Group, { type GroupProps } from './Group.svelte';
65
65
  import Spline from './Spline.svelte';
66
- import { getChartContext } from './Chart.svelte';
67
- import { getGeoContext } from './GeoContext.svelte';
66
+ import { getChartContext } from '../contexts/chart.js';
67
+ import { getGeoContext } from '../contexts/geo.js';
68
68
 
69
69
  let {
70
70
  data,
@@ -72,7 +72,7 @@
72
72
  import { cls } from '@layerstack/tailwind';
73
73
 
74
74
  import { isScaleBand } from '../utils/scales.svelte.js';
75
- import { getChartContext } from './Chart.svelte';
75
+ import { getChartContext } from '../contexts/chart.js';
76
76
  import Group from './Group.svelte';
77
77
  import { extractLayerProps } from '../utils/attributes.js';
78
78
 
@@ -120,7 +120,7 @@
120
120
  import ColorRamp from './ColorRamp.svelte';
121
121
  import { cls } from '@layerstack/tailwind';
122
122
  import type { AnyScale } from '../utils/scales.svelte.js';
123
- import { getChartContext } from './Chart.svelte';
123
+ import { getChartContext } from '../contexts/chart.js';
124
124
  import { extractLayerProps } from '../utils/attributes.js';
125
125
  import { resolveMaybeFn } from '../utils/common.js';
126
126
 
@@ -92,10 +92,10 @@
92
92
 
93
93
  <script lang="ts">
94
94
  import { cls } from '@layerstack/tailwind';
95
- import { merge } from 'lodash-es';
95
+ import { merge } from '@layerstack/utils';
96
96
 
97
- import { registerCanvasComponent } from './layout/Canvas.svelte';
98
- import { getRenderContext } from './Chart.svelte';
97
+ import { registerCanvasComponent } from './layers/Canvas.svelte';
98
+ import { getLayerContext } from '../contexts/layer.js';
99
99
 
100
100
  import { createKey } from '../utils/key.svelte.js';
101
101
  import { createId } from '../utils/createId.js';
@@ -134,7 +134,7 @@
134
134
  const motionX2 = createMotion(initialX2, () => x2, motion);
135
135
  const motionY2 = createMotion(initialY2, () => y2, motion);
136
136
 
137
- const renderCtx = getRenderContext();
137
+ const layerCtx = getLayerContext();
138
138
 
139
139
  function render(
140
140
  ctx: CanvasRenderingContext2D,
@@ -149,6 +149,7 @@
149
149
  : {
150
150
  styles: { fill, stroke, strokeWidth, opacity },
151
151
  classes: cls('lc-line', className),
152
+ style: restProps.style as string | undefined,
152
153
  }
153
154
  );
154
155
  }
@@ -156,7 +157,7 @@
156
157
  const fillKey = createKey(() => fill);
157
158
  const strokeKey = createKey(() => stroke);
158
159
 
159
- if (renderCtx === 'canvas') {
160
+ if (layerCtx === 'canvas') {
160
161
  registerCanvasComponent({
161
162
  name: 'Line',
162
163
  render,
@@ -176,12 +177,13 @@
176
177
  strokeWidth,
177
178
  opacity,
178
179
  className,
180
+ restProps.style,
179
181
  ],
180
182
  });
181
183
  }
182
184
  </script>
183
185
 
184
- {#if renderCtx === 'svg'}
186
+ {#if layerCtx === 'svg'}
185
187
  <line
186
188
  x1={motionX1.current}
187
189
  y1={motionY1.current}
@@ -201,7 +203,7 @@
201
203
  <MarkerWrapper id={markerStartId} marker={markerStart ?? marker} />
202
204
  <MarkerWrapper id={markerMidId} marker={markerMid ?? marker} />
203
205
  <MarkerWrapper id={markerEndId} marker={markerEnd ?? marker} />
204
- {:else if renderCtx === 'html'}
206
+ {:else if layerCtx === 'html'}
205
207
  {@const { angle, length } = pointsToAngleAndLength(
206
208
  { x: motionX1.current, y: motionY1.current },
207
209
  { x: motionX2.current, y: motionY2.current }
@@ -76,8 +76,9 @@
76
76
  </script>
77
77
 
78
78
  <script lang="ts">
79
- import { getChartContext, getRenderContext } from './Chart.svelte';
80
- import { registerCanvasComponent } from './layout/Canvas.svelte';
79
+ import { getLayerContext } from '../contexts/layer.js';
80
+ import { getChartContext } from '../contexts/chart.js';
81
+ import { registerCanvasComponent } from './layers/Canvas.svelte';
81
82
  import { createLinearGradient, getComputedStyles } from '../utils/canvas.js';
82
83
  import { parsePercent } from '../utils/math.js';
83
84
  import { createId } from '../utils/createId.js';
@@ -109,7 +110,7 @@
109
110
  });
110
111
 
111
112
  const ctx = getChartContext();
112
- const renderCtx = getRenderContext();
113
+ const layerCtx = getLayerContext();
113
114
 
114
115
  let canvasGradient = $state<CanvasGradient>();
115
116
 
@@ -173,7 +174,7 @@
173
174
  canvasGradient = gradient;
174
175
  }
175
176
 
176
- if (renderCtx === 'canvas') {
177
+ if (layerCtx === 'canvas') {
177
178
  registerCanvasComponent({
178
179
  name: 'Gradient',
179
180
  render,
@@ -182,13 +183,13 @@
182
183
  }
183
184
  </script>
184
185
 
185
- {#if renderCtx === 'canvas'}
186
+ {#if layerCtx === 'canvas'}
186
187
  <!--
187
188
  TODO: we can probably pass the context to coerce this type so we don't need a bunch
188
189
  of predicates to check if the gradient is a CanvasGradient or not...
189
190
  -->
190
191
  {@render children?.({ id, gradient: asAny(canvasGradient) })}
191
- {:else if renderCtx === 'svg'}
192
+ {:else if layerCtx === 'svg'}
192
193
  <defs>
193
194
  <linearGradient
194
195
  bind:this={ref}
@@ -224,6 +225,6 @@
224
225
  </defs>
225
226
 
226
227
  {@render children?.({ id, gradient: `url(#${id})` })}
227
- {:else if renderCtx === 'html'}
228
+ {:else if layerCtx === 'html'}
228
229
  {@render children?.({ id, gradient: createCSSGradient() })}
229
230
  {/if}
@@ -29,16 +29,16 @@
29
29
  };
30
30
 
31
31
  export type MonthPathProps = MonthPathPropsWithoutHTML &
32
- // we omit the spline props to avoid conflicts with attribute names since we are
33
- // passing them through to `<Spline />`
34
- Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML & SplinePropsWithoutHTML>;
32
+ // we omit the path props to avoid conflicts with attribute names since we are
33
+ // passing them through to `<Path />`
34
+ Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML & PathPropsWithoutHTML>;
35
35
  </script>
36
36
 
37
37
  <script lang="ts">
38
38
  import { timeWeek } from 'd3-time';
39
39
  import { cls } from '@layerstack/tailwind';
40
40
  import { endOfInterval } from '@layerstack/utils';
41
- import Spline, { type SplinePropsWithoutHTML } from './Spline.svelte';
41
+ import Path, { type PathPropsWithoutHTML } from './Path.svelte';
42
42
 
43
43
  let {
44
44
  date,
@@ -76,13 +76,7 @@
76
76
  `);
77
77
  </script>
78
78
 
79
- <Spline
80
- bind:pathRef
81
- {pathData}
82
- fill="none"
83
- class={cls('lc-month-path', className)}
84
- {...restProps}
85
- />
79
+ <Path bind:pathRef {pathData} fill="none" class={cls('lc-month-path', className)} {...restProps} />
86
80
 
87
81
  <style>
88
82
  @layer components {
@@ -22,8 +22,8 @@ export type MonthPathPropsWithoutHTML = {
22
22
  */
23
23
  pathRef?: SVGPathElement;
24
24
  };
25
- export type MonthPathProps = MonthPathPropsWithoutHTML & Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML & SplinePropsWithoutHTML>;
26
- import { type SplinePropsWithoutHTML } from './Spline.svelte';
25
+ export type MonthPathProps = MonthPathPropsWithoutHTML & Without<SVGAttributes<SVGPathElement>, MonthPathPropsWithoutHTML & PathPropsWithoutHTML>;
26
+ import { type PathPropsWithoutHTML } from './Path.svelte';
27
27
  declare const MonthPath: import("svelte").Component<MonthPathProps, {}, "pathRef">;
28
28
  type MonthPath = ReturnType<typeof MonthPath>;
29
29
  export default MonthPath;
@@ -3,6 +3,9 @@
3
3
  import type { Snippet } from 'svelte';
4
4
 
5
5
  export type PackProps<T> = {
6
+ /** d3 hierarchy node */
7
+ hierarchy: HierarchyNode<T>;
8
+
6
9
  /**
7
10
  * The size of the pack layout.
8
11
  */
@@ -15,11 +18,6 @@
15
18
  */
16
19
  padding?: number;
17
20
 
18
- /**
19
- * The hierarchy data to be packed.
20
- */
21
- hierarchy: HierarchyNode<T>;
22
-
23
21
  /**
24
22
  * A bindable reference to the computed packed nodes.
25
23
  *
@@ -32,7 +30,7 @@
32
30
  </script>
33
31
 
34
32
  <script lang="ts" generics="T">
35
- import { getChartContext } from './Chart.svelte';
33
+ import { getChartContext } from '../contexts/chart.js';
36
34
 
37
35
  const ctx = getChartContext();
38
36
 
@@ -1,6 +1,8 @@
1
1
  import { type HierarchyCircularNode, type HierarchyNode } from 'd3-hierarchy';
2
2
  import type { Snippet } from 'svelte';
3
3
  export type PackProps<T> = {
4
+ /** d3 hierarchy node */
5
+ hierarchy: HierarchyNode<T>;
4
6
  /**
5
7
  * The size of the pack layout.
6
8
  */
@@ -11,10 +13,6 @@ export type PackProps<T> = {
11
13
  * @see https://github.com/d3/d3-hierarchy#pack_padding
12
14
  */
13
15
  padding?: number;
14
- /**
15
- * The hierarchy data to be packed.
16
- */
17
- hierarchy: HierarchyNode<T>;
18
16
  /**
19
17
  * A bindable reference to the computed packed nodes.
20
18
  *
@@ -7,6 +7,9 @@
7
7
  import type { Snippet } from 'svelte';
8
8
 
9
9
  export type PartitionProps<T> = {
10
+ /** d3 hierarchy node */
11
+ hierarchy: HierarchyNode<T>;
12
+
10
13
  /**
11
14
  * The orientation of the partition layout.
12
15
  *
@@ -31,8 +34,6 @@
31
34
  */
32
35
  round?: boolean;
33
36
 
34
- hierarchy: HierarchyNode<T>;
35
-
36
37
  /**
37
38
  * A bindable reference to the descendants of the partition layout.
38
39
  *
@@ -45,7 +46,7 @@
45
46
  </script>
46
47
 
47
48
  <script lang="ts" generics="T">
48
- import { getChartContext } from './Chart.svelte';
49
+ import { getChartContext } from '../contexts/chart.js';
49
50
 
50
51
  let {
51
52
  size,
@@ -1,6 +1,8 @@
1
1
  import { type HierarchyNode, type HierarchyRectangularNode } from 'd3-hierarchy';
2
2
  import type { Snippet } from 'svelte';
3
3
  export type PartitionProps<T> = {
4
+ /** d3 hierarchy node */
5
+ hierarchy: HierarchyNode<T>;
4
6
  /**
5
7
  * The orientation of the partition layout.
6
8
  *
@@ -21,7 +23,6 @@ export type PartitionProps<T> = {
21
23
  * see: https://github.com/d3/d3-hierarchy#tree_nodeSize
22
24
  */
23
25
  round?: boolean;
24
- hierarchy: HierarchyNode<T>;
25
26
  /**
26
27
  * A bindable reference to the descendants of the partition layout.
27
28
  *