layerchart 2.0.0-next.1 → 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.
Files changed (266) hide show
  1. package/dist/actions/movable.d.ts +28 -0
  2. package/dist/actions/movable.js +91 -0
  3. package/dist/components/AnnotationLine.svelte +155 -0
  4. package/dist/components/AnnotationLine.svelte.d.ts +28 -0
  5. package/dist/components/AnnotationPoint.svelte +121 -0
  6. package/dist/components/AnnotationPoint.svelte.d.ts +32 -0
  7. package/dist/components/AnnotationRange.svelte +147 -0
  8. package/dist/components/AnnotationRange.svelte.d.ts +40 -0
  9. package/dist/components/Arc.svelte +344 -151
  10. package/dist/components/Arc.svelte.d.ts +138 -0
  11. package/dist/components/Area.svelte +165 -149
  12. package/dist/components/Area.svelte.d.ts +45 -0
  13. package/dist/components/Axis.svelte +287 -174
  14. package/dist/components/Axis.svelte.d.ts +116 -0
  15. package/dist/components/Bar.svelte +163 -107
  16. package/dist/components/Bar.svelte.d.ts +48 -0
  17. package/dist/components/Bars.svelte +54 -68
  18. package/dist/components/Bars.svelte.d.ts +27 -0
  19. package/dist/components/Blur.svelte +31 -7
  20. package/dist/components/Blur.svelte.d.ts +23 -21
  21. package/dist/components/Bounds.svelte +49 -19
  22. package/dist/components/Bounds.svelte.d.ts +24 -50
  23. package/dist/components/BrushContext.svelte +296 -168
  24. package/dist/components/BrushContext.svelte.d.ts +97 -65
  25. package/dist/components/Calendar.svelte +116 -59
  26. package/dist/components/Calendar.svelte.d.ts +50 -31
  27. package/dist/components/Chart.svelte +1289 -398
  28. package/dist/components/Chart.svelte.d.ts +535 -410
  29. package/dist/components/ChartClipPath.svelte +37 -15
  30. package/dist/components/ChartClipPath.svelte.d.ts +21 -19
  31. package/dist/components/Circle.svelte +124 -85
  32. package/dist/components/Circle.svelte.d.ts +52 -0
  33. package/dist/components/CircleClipPath.svelte +76 -16
  34. package/dist/components/CircleClipPath.svelte.d.ts +46 -0
  35. package/dist/components/ClipPath.svelte +60 -15
  36. package/dist/components/ClipPath.svelte.d.ts +40 -27
  37. package/dist/components/ColorRamp.svelte +75 -9
  38. package/dist/components/ColorRamp.svelte.d.ts +37 -19
  39. package/dist/components/ComputedStyles.svelte +17 -5
  40. package/dist/components/ComputedStyles.svelte.d.ts +11 -19
  41. package/dist/components/Connector.svelte +149 -0
  42. package/dist/components/Connector.svelte.d.ts +51 -0
  43. package/dist/components/Dagre.svelte +211 -122
  44. package/dist/components/Dagre.svelte.d.ts +119 -56
  45. package/dist/components/ForceSimulation.svelte +215 -90
  46. package/dist/components/ForceSimulation.svelte.d.ts +82 -35
  47. package/dist/components/Frame.svelte +33 -13
  48. package/dist/components/Frame.svelte.d.ts +13 -17
  49. package/dist/components/GeoCircle.svelte +29 -16
  50. package/dist/components/GeoCircle.svelte.d.ts +22 -24
  51. package/dist/components/GeoContext.svelte +113 -72
  52. package/dist/components/GeoContext.svelte.d.ts +49 -41
  53. package/dist/components/GeoEdgeFade.svelte +47 -12
  54. package/dist/components/GeoEdgeFade.svelte.d.ts +17 -19
  55. package/dist/components/GeoPath.svelte +157 -127
  56. package/dist/components/GeoPath.svelte.d.ts +48 -36
  57. package/dist/components/GeoPoint.svelte +52 -20
  58. package/dist/components/GeoPoint.svelte.d.ts +25 -22
  59. package/dist/components/GeoSpline.svelte +75 -26
  60. package/dist/components/GeoSpline.svelte.d.ts +29 -20
  61. package/dist/components/GeoTile.svelte +100 -49
  62. package/dist/components/GeoTile.svelte.d.ts +38 -23
  63. package/dist/components/GeoVisible.svelte +17 -9
  64. package/dist/components/GeoVisible.svelte.d.ts +10 -18
  65. package/dist/components/Graticule.svelte +28 -13
  66. package/dist/components/Graticule.svelte.d.ts +11 -52
  67. package/dist/components/Grid.svelte +226 -114
  68. package/dist/components/Grid.svelte.d.ts +70 -0
  69. package/dist/components/Group.svelte +132 -105
  70. package/dist/components/Group.svelte.d.ts +53 -0
  71. package/dist/components/Highlight.svelte +409 -307
  72. package/dist/components/Highlight.svelte.d.ts +107 -0
  73. package/dist/components/Hull.svelte +96 -45
  74. package/dist/components/Hull.svelte.d.ts +40 -30
  75. package/dist/components/Labels.svelte +125 -46
  76. package/dist/components/Labels.svelte.d.ts +70 -27
  77. package/dist/components/Legend.svelte +374 -190
  78. package/dist/components/Legend.svelte.d.ts +95 -44
  79. package/dist/components/Line.svelte +163 -125
  80. package/dist/components/Line.svelte.d.ts +75 -0
  81. package/dist/components/LinearGradient.svelte +153 -78
  82. package/dist/components/LinearGradient.svelte.d.ts +66 -31
  83. package/dist/components/Link.svelte +160 -104
  84. package/dist/components/Link.svelte.d.ts +54 -0
  85. package/dist/components/Marker.svelte +100 -39
  86. package/dist/components/Marker.svelte.d.ts +59 -27
  87. package/dist/components/MarkerWrapper.svelte +35 -0
  88. package/dist/components/MarkerWrapper.svelte.d.ts +18 -0
  89. package/dist/components/MonthPath.svelte +65 -20
  90. package/dist/components/MonthPath.svelte.d.ts +23 -17
  91. package/dist/components/MotionPath.svelte +80 -24
  92. package/dist/components/MotionPath.svelte.d.ts +46 -27
  93. package/dist/components/Pack.svelte +53 -17
  94. package/dist/components/Pack.svelte.d.ts +42 -21
  95. package/dist/components/Partition.svelte +64 -22
  96. package/dist/components/Partition.svelte.d.ts +49 -26
  97. package/dist/components/Pattern.svelte +297 -11
  98. package/dist/components/Pattern.svelte.d.ts +103 -19
  99. package/dist/components/Pie.svelte +122 -76
  100. package/dist/components/Pie.svelte.d.ts +65 -51
  101. package/dist/components/Point.svelte +20 -9
  102. package/dist/components/Point.svelte.d.ts +16 -20
  103. package/dist/components/Points.svelte +148 -137
  104. package/dist/components/Points.svelte.d.ts +45 -34
  105. package/dist/components/RadialGradient.svelte +143 -70
  106. package/dist/components/RadialGradient.svelte.d.ts +69 -31
  107. package/dist/components/Rect.svelte +121 -102
  108. package/dist/components/Rect.svelte.d.ts +36 -0
  109. package/dist/components/RectClipPath.svelte +82 -18
  110. package/dist/components/RectClipPath.svelte.d.ts +55 -0
  111. package/dist/components/Rule.svelte +105 -62
  112. package/dist/components/Rule.svelte.d.ts +40 -19
  113. package/dist/components/Sankey.svelte +132 -55
  114. package/dist/components/Sankey.svelte.d.ts +61 -31
  115. package/dist/components/Spline.svelte +281 -218
  116. package/dist/components/Spline.svelte.d.ts +95 -0
  117. package/dist/components/Text.svelte +437 -176
  118. package/dist/components/Text.svelte.d.ts +130 -0
  119. package/dist/components/Threshold.svelte +48 -16
  120. package/dist/components/Threshold.svelte.d.ts +29 -31
  121. package/dist/components/TileImage.svelte +103 -30
  122. package/dist/components/TileImage.svelte.d.ts +48 -23
  123. package/dist/components/TransformContext.svelte +365 -171
  124. package/dist/components/TransformControls.svelte +50 -26
  125. package/dist/components/TransformControls.svelte.d.ts +27 -19
  126. package/dist/components/Tree.svelte +74 -33
  127. package/dist/components/Tree.svelte.d.ts +42 -30
  128. package/dist/components/Treemap.svelte +119 -42
  129. package/dist/components/Treemap.svelte.d.ts +75 -27
  130. package/dist/components/Voronoi.svelte +106 -75
  131. package/dist/components/Voronoi.svelte.d.ts +40 -41
  132. package/dist/components/charts/ArcChart.svelte +464 -0
  133. package/dist/components/charts/ArcChart.svelte.d.ts +90 -0
  134. package/dist/components/charts/AreaChart.svelte +450 -393
  135. package/dist/components/charts/AreaChart.svelte.d.ts +61 -0
  136. package/dist/components/charts/BarChart.svelte +454 -389
  137. package/dist/components/charts/BarChart.svelte.d.ts +76 -0
  138. package/dist/components/charts/ChartAnnotations.svelte +37 -0
  139. package/dist/components/charts/ChartAnnotations.svelte.d.ts +10 -0
  140. package/dist/components/charts/DefaultTooltip.svelte +60 -0
  141. package/dist/components/charts/DefaultTooltip.svelte.d.ts +10 -0
  142. package/dist/components/charts/LineChart.svelte +369 -314
  143. package/dist/components/charts/LineChart.svelte.d.ts +53 -0
  144. package/dist/components/charts/PieChart.svelte +458 -316
  145. package/dist/components/charts/PieChart.svelte.d.ts +137 -353
  146. package/dist/components/charts/ScatterChart.svelte +334 -296
  147. package/dist/components/charts/ScatterChart.svelte.d.ts +39 -0
  148. package/dist/components/charts/index.d.ts +8 -0
  149. package/dist/components/charts/index.js +7 -0
  150. package/dist/components/charts/types.d.ts +253 -0
  151. package/dist/components/charts/utils.svelte.d.ts +30 -0
  152. package/dist/components/charts/utils.svelte.js +55 -0
  153. package/dist/components/index.d.ts +76 -4
  154. package/dist/components/index.js +76 -5
  155. package/dist/components/layout/Canvas.svelte +321 -155
  156. package/dist/components/layout/Canvas.svelte.d.ts +104 -55
  157. package/dist/components/layout/Html.svelte +82 -42
  158. package/dist/components/layout/Html.svelte.d.ts +39 -28
  159. package/dist/components/layout/Layer.svelte +39 -0
  160. package/dist/components/layout/Layer.svelte.d.ts +17 -0
  161. package/dist/components/layout/Svg.svelte +122 -70
  162. package/dist/components/layout/Svg.svelte.d.ts +53 -34
  163. package/dist/components/layout/WebGL.svelte +135 -0
  164. package/dist/components/layout/WebGL.svelte.d.ts +50 -0
  165. package/dist/components/tooltip/Tooltip.svelte +246 -78
  166. package/dist/components/tooltip/Tooltip.svelte.d.ts +149 -31
  167. package/dist/components/tooltip/TooltipContext.svelte +409 -271
  168. package/dist/components/tooltip/TooltipContext.svelte.d.ts +86 -55
  169. package/dist/components/tooltip/TooltipHeader.svelte +100 -11
  170. package/dist/components/tooltip/TooltipHeader.svelte.d.ts +43 -23
  171. package/dist/components/tooltip/TooltipItem.svelte +167 -27
  172. package/dist/components/tooltip/TooltipItem.svelte.d.ts +63 -31
  173. package/dist/components/tooltip/TooltipList.svelte +22 -3
  174. package/dist/components/tooltip/TooltipList.svelte.d.ts +6 -17
  175. package/dist/components/tooltip/TooltipSeparator.svelte +27 -1
  176. package/dist/components/tooltip/TooltipSeparator.svelte.d.ts +6 -15
  177. package/dist/components/tooltip/index.d.ts +6 -0
  178. package/dist/components/tooltip/index.js +6 -0
  179. package/dist/components/tooltip/tooltipMetaContext.d.ts +79 -0
  180. package/dist/components/tooltip/tooltipMetaContext.js +139 -0
  181. package/dist/components/types.d.ts +1 -0
  182. package/dist/components/types.js +1 -0
  183. package/dist/docs/Blockquote.svelte.d.ts +18 -14
  184. package/dist/docs/Code.svelte.d.ts +26 -22
  185. package/dist/docs/ConnectorSweepMenuField.svelte +17 -0
  186. package/dist/docs/ConnectorSweepMenuField.svelte.d.ts +7 -0
  187. package/dist/docs/ConnectorTypeMenuField.svelte +17 -0
  188. package/dist/docs/ConnectorTypeMenuField.svelte.d.ts +7 -0
  189. package/dist/docs/CurveMenuField.svelte +14 -3
  190. package/dist/docs/CurveMenuField.svelte.d.ts +9 -18
  191. package/dist/docs/GeoDebug.svelte +47 -42
  192. package/dist/docs/GeoDebug.svelte.d.ts +4 -16
  193. package/dist/docs/Header1.svelte.d.ts +27 -16
  194. package/dist/docs/Json.svelte.d.ts +20 -16
  195. package/dist/docs/Layout.svelte.d.ts +18 -13
  196. package/dist/docs/Link.svelte.d.ts +33 -21
  197. package/dist/docs/PathDataMenuField.svelte +14 -10
  198. package/dist/docs/PathDataMenuField.svelte.d.ts +8 -18
  199. package/dist/docs/Preview.svelte +20 -7
  200. package/dist/docs/Preview.svelte.d.ts +12 -22
  201. package/dist/docs/TilesetField.svelte.d.ts +21 -17
  202. package/dist/docs/TransformDebug.svelte +5 -6
  203. package/dist/docs/TransformDebug.svelte.d.ts +18 -14
  204. package/dist/docs/ViewSourceButton.svelte.d.ts +21 -17
  205. package/dist/types/d3-shape-extentions.d.ts +7 -0
  206. package/dist/utils/afterTick.d.ts +5 -0
  207. package/dist/utils/afterTick.js +8 -0
  208. package/dist/utils/arcText.svelte.d.ts +57 -0
  209. package/dist/utils/arcText.svelte.js +262 -0
  210. package/dist/utils/array.d.ts +9 -1
  211. package/dist/utils/array.js +13 -0
  212. package/dist/utils/attributes.d.ts +29 -0
  213. package/dist/utils/attributes.js +40 -0
  214. package/dist/utils/canvas.js +47 -10
  215. package/dist/utils/chart.d.ts +78 -0
  216. package/dist/utils/chart.js +512 -0
  217. package/dist/utils/color.d.ts +1 -0
  218. package/dist/utils/color.js +8 -0
  219. package/dist/utils/common.d.ts +3 -5
  220. package/dist/utils/common.js +3 -2
  221. package/dist/utils/connectorUtils.d.ts +21 -0
  222. package/dist/utils/connectorUtils.js +111 -0
  223. package/dist/utils/createId.d.ts +7 -0
  224. package/dist/utils/createId.js +9 -0
  225. package/dist/utils/debug.d.ts +1 -0
  226. package/dist/utils/debug.js +84 -0
  227. package/dist/utils/filterObject.d.ts +9 -0
  228. package/dist/utils/filterObject.js +12 -0
  229. package/dist/utils/graph/dagre.d.ts +34 -0
  230. package/dist/utils/graph/dagre.js +78 -0
  231. package/dist/utils/graph/dagre.test.d.ts +1 -0
  232. package/dist/utils/{graph.test.js → graph/dagre.test.js} +19 -33
  233. package/dist/utils/graph/sankey.d.ts +28 -0
  234. package/dist/utils/{graph.js → graph/sankey.js} +13 -41
  235. package/dist/utils/index.d.ts +3 -1
  236. package/dist/utils/index.js +3 -1
  237. package/dist/utils/key.svelte.d.ts +3 -0
  238. package/dist/utils/key.svelte.js +11 -0
  239. package/dist/utils/legendPayload.d.ts +7 -0
  240. package/dist/utils/legendPayload.js +8 -0
  241. package/dist/utils/motion.svelte.d.ts +140 -0
  242. package/dist/utils/motion.svelte.js +180 -0
  243. package/dist/utils/motion.test.d.ts +1 -0
  244. package/dist/utils/motion.test.js +213 -0
  245. package/dist/utils/{rect.d.ts → rect.svelte.d.ts} +7 -4
  246. package/dist/utils/rect.svelte.js +105 -0
  247. package/dist/utils/scales.svelte.d.ts +90 -0
  248. package/dist/utils/{scales.js → scales.svelte.js} +100 -39
  249. package/dist/utils/stack.d.ts +2 -3
  250. package/dist/utils/stack.js +1 -1
  251. package/dist/utils/string.js +87 -0
  252. package/dist/utils/ticks.d.ts +8 -2
  253. package/dist/utils/ticks.js +28 -0
  254. package/dist/utils/ticks.test.d.ts +1 -0
  255. package/dist/utils/ticks.test.js +67 -0
  256. package/dist/utils/types.d.ts +81 -0
  257. package/package.json +21 -19
  258. package/dist/components/ChartContext.svelte +0 -295
  259. package/dist/components/ChartContext.svelte.d.ts +0 -139
  260. package/dist/components/TransformContext.svelte.d.ts +0 -158
  261. package/dist/stores/motionStore.d.ts +0 -30
  262. package/dist/stores/motionStore.js +0 -62
  263. package/dist/utils/graph.d.ts +0 -37
  264. package/dist/utils/rect.js +0 -107
  265. package/dist/utils/scales.d.ts +0 -66
  266. /package/dist/{utils/graph.test.d.ts → components/charts/types.js} +0 -0
@@ -1,28 +1,47 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- /** Id of path to move object along */ pathId?: string;
5
- /** Id of object to move along path */ objectId?: string;
6
- /** Duration of the animation */ duration: string;
7
- /** Number of times the animation will occur */ repeatCount?: number | "indefinite" | undefined;
8
- /** Final state of the animation. Freeze (last frame) or remove (first frame)
9
- * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill#animate
10
- * */ fill?: "freeze" | "remove";
11
- /** Rotation applied to the element animated along a path, usually to make it pointing in the direction of the animation */ rotate?: number | "auto" | "auto-reverse" | undefined;
12
- };
13
- events: {
14
- [evt: string]: CustomEvent<any>;
15
- };
16
- slots: {
17
- default: {
18
- pathId: string;
19
- objectId: string;
20
- };
21
- };
1
+ import type { Snippet } from 'svelte';
2
+ export type MotionPathPropsWithoutHTML = {
3
+ /**
4
+ * Id of path to move object along
5
+ */
6
+ pathId?: string;
7
+ /**
8
+ * Id of object to move along path
9
+ */
10
+ objectId?: string;
11
+ /**
12
+ * Duration of the animation
13
+ */
14
+ duration: string;
15
+ /**
16
+ * Number of times the animation will occur
17
+ */
18
+ repeatCount?: number | 'indefinite';
19
+ /**
20
+ * Final state of the animation. Freeze (last frame) or remove (first frame)
21
+ * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill#animate
22
+ *
23
+ * @default 'freeze'
24
+ */
25
+ fill?: 'freeze' | 'remove';
26
+ /**
27
+ * Rotation applied to the element animated along a path, usually to make it pointing
28
+ * in the direction of the animation
29
+ */
30
+ rotate?: number | 'auto' | 'auto-reverse';
31
+ /**
32
+ * A bindable reference to the underlying `<animateMotion>` element.
33
+ *
34
+ * @bindable
35
+ */
36
+ ref?: SVGAnimateMotionElement;
37
+ children?: Snippet<[{
38
+ pathId: string;
39
+ objectId: string;
40
+ }]>;
22
41
  };
23
- export type MotionPathProps = typeof __propDef.props;
24
- export type MotionPathEvents = typeof __propDef.events;
25
- export type MotionPathSlots = typeof __propDef.slots;
26
- export default class MotionPath extends SvelteComponentTyped<MotionPathProps, MotionPathEvents, MotionPathSlots> {
27
- }
28
- export {};
42
+ export type MotionPathProps = MotionPathPropsWithoutHTML & Without<Omit<SVGAttributes<SVGAnimateMotionElement>, 'dir' | 'href'>, MotionPathPropsWithoutHTML>;
43
+ import type { Without } from '../utils/types.js';
44
+ import type { SVGAttributes } from 'svelte/elements';
45
+ declare const MotionPath: import("svelte").Component<MotionPathPropsWithoutHTML, {}, "ref">;
46
+ type MotionPath = ReturnType<typeof MotionPath>;
47
+ export default MotionPath;
@@ -1,27 +1,63 @@
1
- <script lang="ts">
2
- import { pack as d3Pack } from 'd3-hierarchy';
3
- import { chartContext } from './ChartContext.svelte';
1
+ <script lang="ts" module>
2
+ import { pack as d3Pack, type HierarchyCircularNode, type HierarchyNode } from 'd3-hierarchy';
3
+ import type { Snippet } from 'svelte';
4
4
 
5
- const { data, width, height } = chartContext();
5
+ export type PackProps<T> = {
6
+ /**
7
+ * The size of the pack layout.
8
+ */
9
+ size?: [number, number];
6
10
 
7
- export let size: [number, number] | undefined = undefined;
11
+ /**
12
+ * The padding between nodes in the pack layout.
13
+ *
14
+ * @see https://github.com/d3/d3-hierarchy#pack_padding
15
+ */
16
+ padding?: number;
8
17
 
9
- /**
10
- * see: https://github.com/d3/d3-hierarchy#pack_padding
11
- */
12
- export let padding: number | undefined = undefined;
18
+ /**
19
+ * The hierarchy data to be packed.
20
+ */
21
+ hierarchy: HierarchyNode<T>;
13
22
 
14
- let pack: ReturnType<typeof d3Pack>;
15
- $: {
16
- pack = d3Pack().size(size ?? [$width, $height]);
23
+ /**
24
+ * A bindable reference to the computed packed nodes.
25
+ *
26
+ * @bindable
27
+ */
28
+ nodes?: HierarchyCircularNode<T>[];
17
29
 
30
+ children?: Snippet<[{ nodes: HierarchyCircularNode<T>[] }]>;
31
+ };
32
+ </script>
33
+
34
+ <script lang="ts" generics="T">
35
+ import { getChartContext } from './Chart.svelte';
36
+
37
+ const ctx = getChartContext();
38
+
39
+ let {
40
+ size,
41
+ padding,
42
+ children,
43
+ hierarchy: hierarchyProp,
44
+ nodes = $bindable(),
45
+ }: PackProps<T> = $props();
46
+
47
+ const packedData = $derived.by(() => {
48
+ const h = hierarchyProp.copy();
49
+ const _pack = d3Pack<T>().size(size ?? [ctx.width, ctx.height]);
18
50
  if (padding) {
19
- pack.padding(padding);
51
+ _pack.padding(padding);
20
52
  }
21
- }
53
+ return _pack(h).descendants();
54
+ });
22
55
 
23
- // @ts-expect-error
24
- $: packData = pack($data);
56
+ $effect.pre(() => {
57
+ nodes = packedData;
58
+ });
25
59
  </script>
26
60
 
27
- <slot nodes={packData.descendants()} />
61
+ {@render children?.({
62
+ nodes: packedData,
63
+ })}
@@ -1,23 +1,44 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- size?: [number, number] | undefined;
5
- /**
6
- * see: https://github.com/d3/d3-hierarchy#pack_padding
7
- */ padding?: number | undefined;
8
- };
9
- events: {
10
- [evt: string]: CustomEvent<any>;
11
- };
12
- slots: {
13
- default: {
14
- nodes: import("d3-hierarchy").HierarchyCircularNode<unknown>[];
15
- };
16
- };
1
+ import { type HierarchyCircularNode, type HierarchyNode } from 'd3-hierarchy';
2
+ import type { Snippet } from 'svelte';
3
+ export type PackProps<T> = {
4
+ /**
5
+ * The size of the pack layout.
6
+ */
7
+ size?: [number, number];
8
+ /**
9
+ * The padding between nodes in the pack layout.
10
+ *
11
+ * @see https://github.com/d3/d3-hierarchy#pack_padding
12
+ */
13
+ padding?: number;
14
+ /**
15
+ * The hierarchy data to be packed.
16
+ */
17
+ hierarchy: HierarchyNode<T>;
18
+ /**
19
+ * A bindable reference to the computed packed nodes.
20
+ *
21
+ * @bindable
22
+ */
23
+ nodes?: HierarchyCircularNode<T>[];
24
+ children?: Snippet<[{
25
+ nodes: HierarchyCircularNode<T>[];
26
+ }]>;
17
27
  };
18
- export type PackProps = typeof __propDef.props;
19
- export type PackEvents = typeof __propDef.events;
20
- export type PackSlots = typeof __propDef.slots;
21
- export default class Pack extends SvelteComponentTyped<PackProps, PackEvents, PackSlots> {
28
+ declare class __sveltets_Render<T> {
29
+ props(): PackProps<T>;
30
+ events(): {};
31
+ slots(): {};
32
+ bindings(): "nodes";
33
+ exports(): {};
22
34
  }
23
- export {};
35
+ interface $$IsomorphicComponent {
36
+ new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
37
+ $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
38
+ } & ReturnType<__sveltets_Render<T>['exports']>;
39
+ <T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
40
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
41
+ }
42
+ declare const Pack: $$IsomorphicComponent;
43
+ type Pack<T> = InstanceType<typeof Pack<T>>;
44
+ export default Pack;
@@ -1,42 +1,84 @@
1
- <script lang="ts">
1
+ <script lang="ts" module>
2
2
  import {
3
3
  partition as d3Partition,
4
4
  type HierarchyNode,
5
5
  type HierarchyRectangularNode,
6
6
  } from 'd3-hierarchy';
7
- import { chartContext } from './ChartContext.svelte';
7
+ import type { Snippet } from 'svelte';
8
8
 
9
- const { data, width, height } = chartContext();
9
+ export type PartitionProps<T> = {
10
+ /**
11
+ * The orientation of the partition layout.
12
+ *
13
+ * @default 'horizontal'
14
+ */
15
+ orientation?: 'vertical' | 'horizontal';
10
16
 
11
- export let orientation: 'vertical' | 'horizontal' = 'horizontal';
17
+ /**
18
+ * The size of the partition layout.
19
+ */
20
+ size?: [number, number];
12
21
 
13
- export let size: [number, number] | undefined = undefined;
22
+ /**
23
+ * The padding between nodes in the partition layout.
24
+ * see: https://github.com/d3/d3-hierarchy#tree_nodeSize
25
+ */
26
+ padding?: number;
14
27
 
15
- /**
16
- * see: https://github.com/d3/d3-hierarchy#tree_nodeSize
17
- */
18
- export let padding: number | undefined = undefined;
28
+ /**
29
+ * The round property of the partition layout.
30
+ * see: https://github.com/d3/d3-hierarchy#tree_nodeSize
31
+ */
32
+ round?: boolean;
19
33
 
20
- /**
21
- * see: https://github.com/d3/d3-hierarchy#tree_nodeSize
22
- */
23
- export let round: boolean | undefined = undefined;
34
+ hierarchy: HierarchyNode<T>;
24
35
 
25
- let partition: ReturnType<typeof d3Partition>;
26
- $: {
27
- partition = d3Partition().size(
28
- size ?? (orientation === 'horizontal' ? [$height, $width] : [$width, $height])
36
+ /**
37
+ * A bindable reference to the descendants of the partition layout.
38
+ *
39
+ * @bindable
40
+ */
41
+ nodes?: HierarchyRectangularNode<T>[];
42
+
43
+ children?: Snippet<[{ nodes: HierarchyRectangularNode<T>[] }]>;
44
+ };
45
+ </script>
46
+
47
+ <script lang="ts" generics="T">
48
+ import { getChartContext } from './Chart.svelte';
49
+
50
+ let {
51
+ size,
52
+ padding,
53
+ round,
54
+ orientation = 'horizontal',
55
+ hierarchy,
56
+ children,
57
+ nodes = $bindable(),
58
+ }: PartitionProps<T> = $props();
59
+
60
+ const ctx = getChartContext();
61
+
62
+ const partitionData = $derived.by(() => {
63
+ const h = hierarchy.copy();
64
+ const _partition = d3Partition<T>().size(
65
+ size ?? (orientation === 'horizontal' ? [ctx.height, ctx.width] : [ctx.width, ctx.height])
29
66
  );
30
67
 
31
68
  if (padding) {
32
- partition.padding(padding);
69
+ _partition.padding(padding);
33
70
  }
71
+
34
72
  if (round) {
35
- partition.round(round);
73
+ _partition.round(round);
36
74
  }
37
- }
38
75
 
39
- $: partitionData = partition($data as HierarchyNode<any>) as HierarchyRectangularNode<any>;
76
+ return _partition(h).descendants();
77
+ });
78
+
79
+ $effect.pre(() => {
80
+ nodes = partitionData;
81
+ });
40
82
  </script>
41
83
 
42
- <slot nodes={partitionData.descendants()} />
84
+ {@render children?.({ nodes: partitionData })}
@@ -1,28 +1,51 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- import { type HierarchyRectangularNode } from 'd3-hierarchy';
3
- declare const __propDef: {
4
- props: {
5
- orientation?: "vertical" | "horizontal";
6
- size?: [number, number] | undefined;
7
- /**
8
- * see: https://github.com/d3/d3-hierarchy#tree_nodeSize
9
- */ padding?: number | undefined;
10
- /**
11
- * see: https://github.com/d3/d3-hierarchy#tree_nodeSize
12
- */ round?: boolean | undefined;
13
- };
14
- events: {
15
- [evt: string]: CustomEvent<any>;
16
- };
17
- slots: {
18
- default: {
19
- nodes: HierarchyRectangularNode<any>[];
20
- };
21
- };
1
+ import { type HierarchyNode, type HierarchyRectangularNode } from 'd3-hierarchy';
2
+ import type { Snippet } from 'svelte';
3
+ export type PartitionProps<T> = {
4
+ /**
5
+ * The orientation of the partition layout.
6
+ *
7
+ * @default 'horizontal'
8
+ */
9
+ orientation?: 'vertical' | 'horizontal';
10
+ /**
11
+ * The size of the partition layout.
12
+ */
13
+ size?: [number, number];
14
+ /**
15
+ * The padding between nodes in the partition layout.
16
+ * see: https://github.com/d3/d3-hierarchy#tree_nodeSize
17
+ */
18
+ padding?: number;
19
+ /**
20
+ * The round property of the partition layout.
21
+ * see: https://github.com/d3/d3-hierarchy#tree_nodeSize
22
+ */
23
+ round?: boolean;
24
+ hierarchy: HierarchyNode<T>;
25
+ /**
26
+ * A bindable reference to the descendants of the partition layout.
27
+ *
28
+ * @bindable
29
+ */
30
+ nodes?: HierarchyRectangularNode<T>[];
31
+ children?: Snippet<[{
32
+ nodes: HierarchyRectangularNode<T>[];
33
+ }]>;
22
34
  };
23
- export type PartitionProps = typeof __propDef.props;
24
- export type PartitionEvents = typeof __propDef.events;
25
- export type PartitionSlots = typeof __propDef.slots;
26
- export default class Partition extends SvelteComponentTyped<PartitionProps, PartitionEvents, PartitionSlots> {
35
+ declare class __sveltets_Render<T> {
36
+ props(): PartitionProps<T>;
37
+ events(): {};
38
+ slots(): {};
39
+ bindings(): "nodes";
40
+ exports(): {};
27
41
  }
28
- export {};
42
+ interface $$IsomorphicComponent {
43
+ new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
44
+ $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
45
+ } & ReturnType<__sveltets_Render<T>['exports']>;
46
+ <T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
47
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
48
+ }
49
+ declare const Partition: $$IsomorphicComponent;
50
+ type Partition<T> = InstanceType<typeof Partition<T>>;
51
+ export default Partition;