layerchart 2.0.0-next.0 → 2.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +25 -24
  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,13 +1,32 @@
1
1
  <script lang="ts">
2
2
  import { cls } from '@layerstack/tailwind';
3
+ import { layerClass } from '../../utils/attributes.js';
4
+ import type { HTMLAttributes } from 'svelte/elements';
5
+
6
+ let {
7
+ ref: refProp = $bindable(),
8
+ class: className,
9
+ children,
10
+ ...restProps
11
+ }: HTMLAttributes<HTMLElement> & {
12
+ ref?: HTMLElement;
13
+ } = $props();
14
+
15
+ let ref = $state<HTMLElement>();
16
+
17
+ $effect.pre(() => {
18
+ refProp = ref;
19
+ });
3
20
  </script>
4
21
 
5
22
  <div
23
+ bind:this={ref}
6
24
  class={cls(
7
- 'TooltipList',
25
+ layerClass('tooltip-list'),
8
26
  'grid grid-cols-[1fr_auto] gap-x-2 gap-y-1 items-center',
9
- $$props.class
27
+ className
10
28
  )}
29
+ {...restProps}
11
30
  >
12
- <slot />
31
+ {@render children?.()}
13
32
  </div>
@@ -1,18 +1,7 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- [x: string]: any;
5
- };
6
- events: {
7
- [evt: string]: CustomEvent<any>;
8
- };
9
- slots: {
10
- default: {};
11
- };
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ type $$ComponentProps = HTMLAttributes<HTMLElement> & {
3
+ ref?: HTMLElement;
12
4
  };
13
- export type TooltipListProps = typeof __propDef.props;
14
- export type TooltipListEvents = typeof __propDef.events;
15
- export type TooltipListSlots = typeof __propDef.slots;
16
- export default class TooltipList extends SvelteComponentTyped<TooltipListProps, TooltipListEvents, TooltipListSlots> {
17
- }
18
- export {};
5
+ declare const TooltipList: import("svelte").Component<$$ComponentProps, {}, "ref">;
6
+ type TooltipList = ReturnType<typeof TooltipList>;
7
+ export default TooltipList;
@@ -1,5 +1,31 @@
1
1
  <script lang="ts">
2
2
  import { cls } from '@layerstack/tailwind';
3
+ import { layerClass } from '../../utils/attributes.js';
4
+ import type { HTMLAttributes } from 'svelte/elements';
5
+
6
+ let {
7
+ ref: refProp = $bindable(),
8
+ class: className,
9
+ children,
10
+ ...restProps
11
+ }: HTMLAttributes<HTMLElement> & {
12
+ ref?: HTMLElement;
13
+ } = $props();
14
+
15
+ let ref = $state<HTMLElement>();
16
+ $effect.pre(() => {
17
+ refProp = ref;
18
+ });
3
19
  </script>
4
20
 
5
- <div class={cls('rounded-sm bg-surface-content/20 my-1 col-span-full h-px', $$props.class)}></div>
21
+ <div
22
+ bind:this={ref}
23
+ class={cls(
24
+ layerClass('tooltip-separator'),
25
+ 'rounded-sm bg-surface-content/20 my-1 col-span-full h-px',
26
+ className
27
+ )}
28
+ {...restProps}
29
+ >
30
+ {@render children?.()}
31
+ </div>
@@ -1,16 +1,7 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- [x: string]: any;
5
- };
6
- events: {
7
- [evt: string]: CustomEvent<any>;
8
- };
9
- slots: {};
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ type $$ComponentProps = HTMLAttributes<HTMLElement> & {
3
+ ref?: HTMLElement;
10
4
  };
11
- export type TooltipSeparatorProps = typeof __propDef.props;
12
- export type TooltipSeparatorEvents = typeof __propDef.events;
13
- export type TooltipSeparatorSlots = typeof __propDef.slots;
14
- export default class TooltipSeparator extends SvelteComponentTyped<TooltipSeparatorProps, TooltipSeparatorEvents, TooltipSeparatorSlots> {
15
- }
16
- export {};
5
+ declare const TooltipSeparator: import("svelte").Component<$$ComponentProps, {}, "ref">;
6
+ type TooltipSeparator = ReturnType<typeof TooltipSeparator>;
7
+ export default TooltipSeparator;
@@ -1,6 +1,12 @@
1
1
  export { default as Context } from './TooltipContext.svelte';
2
+ export * from './TooltipContext.svelte';
2
3
  export { default as Header } from './TooltipHeader.svelte';
4
+ export * from './TooltipHeader.svelte';
3
5
  export { default as Item } from './TooltipItem.svelte';
6
+ export * from './TooltipItem.svelte';
4
7
  export { default as List } from './TooltipList.svelte';
8
+ export * from './TooltipList.svelte';
5
9
  export { default as Separator } from './TooltipSeparator.svelte';
10
+ export * from './TooltipSeparator.svelte';
6
11
  export { default as Root } from './Tooltip.svelte';
12
+ export * from './Tooltip.svelte';
@@ -1,6 +1,12 @@
1
1
  export { default as Context } from './TooltipContext.svelte';
2
+ export * from './TooltipContext.svelte';
2
3
  export { default as Header } from './TooltipHeader.svelte';
4
+ export * from './TooltipHeader.svelte';
3
5
  export { default as Item } from './TooltipItem.svelte';
6
+ export * from './TooltipItem.svelte';
4
7
  export { default as List } from './TooltipList.svelte';
8
+ export * from './TooltipList.svelte';
5
9
  export { default as Separator } from './TooltipSeparator.svelte';
10
+ export * from './TooltipSeparator.svelte';
6
11
  export { default as Root } from './Tooltip.svelte';
12
+ export * from './Tooltip.svelte';
@@ -0,0 +1,79 @@
1
+ import { type Accessor } from '../../utils/common.js';
2
+ import type { SeriesData } from '../charts/index.js';
3
+ import type { ChartContextValue } from '../Chart.svelte';
4
+ import { type FormatType } from '@layerstack/utils';
5
+ export type SimplifiedChartType = 'bar' | 'area' | 'line' | 'pie' | 'scatter';
6
+ export type BarTooltipMetaContextValue = {
7
+ type: 'bar';
8
+ orientation: 'horizontal' | 'vertical';
9
+ stackSeries: boolean;
10
+ visibleSeries: SeriesData<any, any>[];
11
+ };
12
+ export type AreaTooltipMetaContextValue = {
13
+ type: 'area';
14
+ stackSeries: boolean;
15
+ visibleSeries: SeriesData<any, any>[];
16
+ };
17
+ export type LineTooltipMetaContextValue = {
18
+ type: 'line';
19
+ visibleSeries: SeriesData<any, any>[];
20
+ };
21
+ export type PieTooltipMetaContextValue = {
22
+ type: 'pie';
23
+ visibleSeries: SeriesData<any, any>[];
24
+ key: Accessor<any>;
25
+ label: Accessor<any>;
26
+ value: Accessor<any>;
27
+ color: Accessor<any>;
28
+ };
29
+ export type ArcTooltipMetaContextValue = {
30
+ type: 'arc';
31
+ visibleSeries: SeriesData<any, any>[];
32
+ key: Accessor<any>;
33
+ label: Accessor<any>;
34
+ value: Accessor<any>;
35
+ color: Accessor<any>;
36
+ };
37
+ export type ScatterTooltipMetaContextValue = {
38
+ type: 'scatter';
39
+ visibleSeries: SeriesData<any, any>[];
40
+ };
41
+ export type TooltipMetaContextValue = BarTooltipMetaContextValue | AreaTooltipMetaContextValue | LineTooltipMetaContextValue | PieTooltipMetaContextValue | ScatterTooltipMetaContextValue | ArcTooltipMetaContextValue;
42
+ export type TooltipPayload = {
43
+ color?: string;
44
+ name?: string;
45
+ key: string;
46
+ label?: string;
47
+ value?: any;
48
+ keyAccessor?: Accessor<any>;
49
+ valueAccessor?: Accessor<any>;
50
+ labelAccessor?: Accessor<any>;
51
+ colorAccessor?: Accessor<any>;
52
+ chartType?: SimplifiedChartType;
53
+ payload: any;
54
+ rawSeriesData?: SeriesData<any, any>;
55
+ formatter?: FormatType;
56
+ };
57
+ type BasePayloadHandlerProps = {
58
+ ctx: ChartContextValue;
59
+ data: any;
60
+ };
61
+ export declare function handleScatterTooltipPayload({ ctx, data, metaCtx, }: BasePayloadHandlerProps & {
62
+ metaCtx: ScatterTooltipMetaContextValue;
63
+ }): TooltipPayload[];
64
+ /**
65
+ * Retrieves the current tooltip meta context value, or null if not set.
66
+ */
67
+ export declare function getTooltipMetaContext(): TooltipMetaContextValue | null;
68
+ /**
69
+ * Sets the tooltip meta context value, used to provide additional payload data to the tooltip.
70
+ * This is typically set by the various simplified chart components, such as BarChart, AreaChart,
71
+ * etc.
72
+ */
73
+ export declare function setTooltipMetaContext(v: TooltipMetaContextValue | null): TooltipMetaContextValue | null;
74
+ export declare function getTooltipPayload({ ctx, tooltipData, metaCtx, }: {
75
+ ctx: ChartContextValue;
76
+ tooltipData: any;
77
+ metaCtx: TooltipMetaContextValue | null;
78
+ }): TooltipPayload[];
79
+ export {};
@@ -0,0 +1,139 @@
1
+ // Additional meta data that can be set by the various simplified chart components
2
+ // to provide additional payload data to the tooltip for ease of composition.
3
+ import { accessor, findRelatedData } from '../../utils/common.js';
4
+ import { asAny } from '../../utils/types.js';
5
+ import { format } from '@layerstack/utils';
6
+ import { Context } from 'runed';
7
+ function handleBarTooltipPayload({ ctx, data, metaCtx, }) {
8
+ const seriesItems = metaCtx.stackSeries
9
+ ? [...metaCtx.visibleSeries].reverse()
10
+ : metaCtx.visibleSeries;
11
+ const payload = seriesItems.map((s) => {
12
+ const seriesTooltipData = s.data ? findRelatedData(s.data, data, ctx.x) : data;
13
+ const valueAccessor = accessor(s.value ?? (s.data ? ctx.y : s.key));
14
+ const label = metaCtx.orientation === 'vertical' ? ctx.x(data) : ctx.y(data);
15
+ const name = s.label ?? (s.key !== 'default' ? s.key : 'value');
16
+ const value = seriesTooltipData ? valueAccessor(seriesTooltipData) : undefined;
17
+ const color = s.color ?? ctx.cScale?.(ctx.c(data));
18
+ return {
19
+ ...s.data,
20
+ chartType: 'bar',
21
+ color,
22
+ label,
23
+ name,
24
+ value,
25
+ valueAccessor,
26
+ key: s.key,
27
+ payload: data,
28
+ rawSeriesData: s,
29
+ formatter: format,
30
+ };
31
+ });
32
+ return payload;
33
+ }
34
+ function handleAreaTooltipPayload({ ctx, data, metaCtx, }) {
35
+ const seriesItems = metaCtx.stackSeries
36
+ ? [...metaCtx.visibleSeries].reverse()
37
+ : metaCtx.visibleSeries;
38
+ const payload = seriesItems.map((s) => {
39
+ const seriesTooltipData = s.data ? findRelatedData(s.data, data, ctx.x) : data;
40
+ const valueAccessor = accessor(s.value ?? (s.data ? asAny(ctx.y) : s.key));
41
+ const label = ctx.x(data);
42
+ const name = s.label ?? (s.key !== 'default' ? s.key : 'value');
43
+ const value = seriesTooltipData ? valueAccessor(seriesTooltipData) : undefined;
44
+ const color = s.color ?? ctx.cScale?.(ctx.c(data));
45
+ return {
46
+ ...s.data,
47
+ chartType: 'area',
48
+ color,
49
+ label,
50
+ name,
51
+ value,
52
+ valueAccessor,
53
+ key: s.key,
54
+ payload: data,
55
+ rawSeriesData: s,
56
+ formatter: format,
57
+ };
58
+ });
59
+ return payload;
60
+ }
61
+ function handleLineTooltipPayload({ ctx, data, metaCtx, }) {
62
+ return metaCtx.visibleSeries.map((s) => {
63
+ const seriesTooltipData = s.data ? findRelatedData(s.data, data, ctx.x) : data;
64
+ const label = ctx.x(data);
65
+ const valueAccessor = accessor(s.value ?? (s.data ? asAny(ctx.y) : s.key));
66
+ const name = s.label ?? (s.key !== 'default' ? s.key : 'value');
67
+ const value = seriesTooltipData ? valueAccessor(seriesTooltipData) : undefined;
68
+ const color = s.color ?? ctx.cScale?.(ctx.c(data));
69
+ return {
70
+ ...s.data,
71
+ chartType: 'line',
72
+ color,
73
+ label,
74
+ name,
75
+ value,
76
+ valueAccessor,
77
+ key: s.key,
78
+ payload: data,
79
+ rawSeriesData: s,
80
+ formatter: format,
81
+ };
82
+ });
83
+ }
84
+ function handlePieOrArcTooltipPayload({ ctx, data, metaCtx, }) {
85
+ const keyAccessor = accessor(metaCtx.key);
86
+ const labelAccessor = accessor(metaCtx.label);
87
+ const valueAccessor = accessor(metaCtx.value);
88
+ const colorAccessor = accessor(metaCtx.color);
89
+ return [
90
+ {
91
+ key: keyAccessor(data),
92
+ label: labelAccessor(data) || keyAccessor(data),
93
+ value: valueAccessor(data),
94
+ color: colorAccessor(data) ?? ctx.cScale?.(ctx.c(data)),
95
+ payload: data,
96
+ chartType: 'pie',
97
+ labelAccessor,
98
+ keyAccessor,
99
+ valueAccessor,
100
+ colorAccessor,
101
+ },
102
+ ];
103
+ }
104
+ export function handleScatterTooltipPayload({ ctx, data, metaCtx, }) {
105
+ // TODO: implement scatter tooltip payload handling
106
+ return [{ payload: data, key: '' }];
107
+ }
108
+ const _TooltipMetaContext = new Context('TooltipMetaContext');
109
+ /**
110
+ * Retrieves the current tooltip meta context value, or null if not set.
111
+ */
112
+ export function getTooltipMetaContext() {
113
+ return _TooltipMetaContext.getOr(null);
114
+ }
115
+ /**
116
+ * Sets the tooltip meta context value, used to provide additional payload data to the tooltip.
117
+ * This is typically set by the various simplified chart components, such as BarChart, AreaChart,
118
+ * etc.
119
+ */
120
+ export function setTooltipMetaContext(v) {
121
+ return _TooltipMetaContext.set(v);
122
+ }
123
+ export function getTooltipPayload({ ctx, tooltipData, metaCtx, }) {
124
+ if (!metaCtx)
125
+ return [{ payload: tooltipData, key: '' }];
126
+ switch (metaCtx.type) {
127
+ case 'bar':
128
+ return handleBarTooltipPayload({ ctx, data: tooltipData, metaCtx });
129
+ case 'area':
130
+ return handleAreaTooltipPayload({ ctx, data: tooltipData, metaCtx });
131
+ case 'line':
132
+ return handleLineTooltipPayload({ ctx, data: tooltipData, metaCtx });
133
+ case 'pie':
134
+ case 'arc':
135
+ return handlePieOrArcTooltipPayload({ ctx, data: tooltipData, metaCtx });
136
+ case 'scatter':
137
+ return handleScatterTooltipPayload({ ctx, data: tooltipData, metaCtx });
138
+ }
139
+ }
@@ -0,0 +1 @@
1
+ export type Placement = 'top-left' | 'top' | 'top-right' | 'left' | 'center' | 'right' | 'bottom-left' | 'bottom' | 'bottom-right';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,16 +1,20 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: Record<string, never>;
4
- events: {
5
- [evt: string]: CustomEvent<any>;
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
6
11
  };
7
- slots: {
8
- default: {};
9
- };
10
- };
11
- export type BlockquoteProps = typeof __propDef.props;
12
- export type BlockquoteEvents = typeof __propDef.events;
13
- export type BlockquoteSlots = typeof __propDef.slots;
14
- export default class Blockquote extends SvelteComponentTyped<BlockquoteProps, BlockquoteEvents, BlockquoteSlots> {
12
+ z_$$bindings?: Bindings;
15
13
  }
16
- export {};
14
+ declare const Blockquote: $$__sveltets_2_IsomorphicComponent<any, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {
17
+ default: {};
18
+ }, {}, string>;
19
+ type Blockquote = InstanceType<typeof Blockquote>;
20
+ export default Blockquote;
@@ -1,25 +1,29 @@
1
- import { SvelteComponentTyped } from "svelte";
2
1
  import 'prism-svelte';
3
- declare const __propDef: {
4
- props: {
5
- [x: string]: any;
6
- source?: string | null | undefined;
7
- language?: string | undefined;
8
- highlightedSource?: string | undefined;
9
- classes?: {
10
- root?: string;
11
- pre?: string;
12
- code?: string;
13
- } | undefined;
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
14
12
  };
15
- events: {
16
- [evt: string]: CustomEvent<any>;
17
- };
18
- slots: {};
19
- };
20
- export type CodeProps = typeof __propDef.props;
21
- export type CodeEvents = typeof __propDef.events;
22
- export type CodeSlots = typeof __propDef.slots;
23
- export default class Code extends SvelteComponentTyped<CodeProps, CodeEvents, CodeSlots> {
13
+ z_$$bindings?: Bindings;
24
14
  }
25
- export {};
15
+ declare const Code: $$__sveltets_2_IsomorphicComponent<{
16
+ [x: string]: any;
17
+ source?: string | null | undefined;
18
+ language?: string | undefined;
19
+ highlightedSource?: string | undefined;
20
+ classes?: {
21
+ root?: string;
22
+ pre?: string;
23
+ code?: string;
24
+ } | undefined;
25
+ }, {
26
+ [evt: string]: CustomEvent<any>;
27
+ }, {}, {}, string>;
28
+ type Code = InstanceType<typeof Code>;
29
+ export default Code;
@@ -0,0 +1,17 @@
1
+ <script lang="ts">
2
+ import { MenuField } from 'svelte-ux';
3
+ import type { ConnectorSweep } from '../utils/connectorUtils.js';
4
+
5
+ let {
6
+ value = $bindable('horizontal-vertical'),
7
+ }: {
8
+ value?: ConnectorSweep;
9
+ } = $props();
10
+
11
+ const options = ['horizontal-vertical', 'vertical-horizontal', 'none'].map((type) => ({
12
+ label: type,
13
+ value: type,
14
+ }));
15
+ </script>
16
+
17
+ <MenuField label="Connector Sweep" {options} bind:value stepper classes={{ menuIcon: 'hidden' }} />
@@ -0,0 +1,7 @@
1
+ import type { ConnectorSweep } from '../utils/connectorUtils.js';
2
+ type $$ComponentProps = {
3
+ value?: ConnectorSweep;
4
+ };
5
+ declare const ConnectorSweepMenuField: import("svelte").Component<$$ComponentProps, {}, "value">;
6
+ type ConnectorSweepMenuField = ReturnType<typeof ConnectorSweepMenuField>;
7
+ export default ConnectorSweepMenuField;
@@ -0,0 +1,17 @@
1
+ <script lang="ts">
2
+ import { MenuField } from 'svelte-ux';
3
+ import type { ConnectorType } from '../utils/connectorUtils.js';
4
+
5
+ let {
6
+ value = $bindable('rounded'),
7
+ }: {
8
+ value?: ConnectorType;
9
+ } = $props();
10
+
11
+ const options = ['straight', 'square', 'beveled', 'rounded', 'd3'].map((type) => ({
12
+ label: type,
13
+ value: type,
14
+ }));
15
+ </script>
16
+
17
+ <MenuField label="Connector Type" {options} bind:value stepper classes={{ menuIcon: 'hidden' }} />
@@ -0,0 +1,7 @@
1
+ import type { ConnectorType } from '../utils/connectorUtils.js';
2
+ type $$ComponentProps = {
3
+ value?: ConnectorType;
4
+ };
5
+ declare const ConnectorTypeMenuField: import("svelte").Component<$$ComponentProps, {}, "value">;
6
+ type ConnectorTypeMenuField = ReturnType<typeof ConnectorTypeMenuField>;
7
+ export default ConnectorTypeMenuField;
@@ -3,9 +3,20 @@
3
3
 
4
4
  import { MenuField } from 'svelte-ux';
5
5
  import { entries } from '@layerstack/utils';
6
+ import type { ComponentProps } from 'svelte';
6
7
 
7
- export let value: any | undefined = d3shapes['curveLinear'];
8
- export let showOpenClosed = false;
8
+ let {
9
+ value = $bindable(),
10
+ showOpenClosed = false,
11
+ ...restProps
12
+ }: {
13
+ value?: any;
14
+ showOpenClosed?: boolean;
15
+ } & ComponentProps<MenuField> = $props();
16
+
17
+ if (value === undefined) {
18
+ value = d3shapes['curveLinear'];
19
+ }
9
20
 
10
21
  const options = entries(d3shapes)
11
22
  .filter(([key]) => {
@@ -29,5 +40,5 @@
29
40
  bind:value
30
41
  stepper
31
42
  classes={{ menuIcon: 'hidden' }}
32
- {...$$restProps}
43
+ {...restProps}
33
44
  />
@@ -1,18 +1,9 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- [x: string]: any;
5
- value?: any | undefined;
6
- showOpenClosed?: boolean | undefined;
7
- };
8
- events: {
9
- [evt: string]: CustomEvent<any>;
10
- };
11
- slots: {};
12
- };
13
- export type CurveMenuFieldProps = typeof __propDef.props;
14
- export type CurveMenuFieldEvents = typeof __propDef.events;
15
- export type CurveMenuFieldSlots = typeof __propDef.slots;
16
- export default class CurveMenuField extends SvelteComponentTyped<CurveMenuFieldProps, CurveMenuFieldEvents, CurveMenuFieldSlots> {
17
- }
18
- export {};
1
+ import { MenuField } from 'svelte-ux';
2
+ import type { ComponentProps } from 'svelte';
3
+ type $$ComponentProps = {
4
+ value?: any;
5
+ showOpenClosed?: boolean;
6
+ } & ComponentProps<MenuField>;
7
+ declare const CurveMenuField: import("svelte").Component<$$ComponentProps, {}, "value">;
8
+ type CurveMenuField = ReturnType<typeof CurveMenuField>;
9
+ export default CurveMenuField;