@dschz/solid-uplot 0.1.7 → 0.2.0

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/README.md CHANGED
@@ -462,26 +462,35 @@ const MyDashboard = () => {
462
462
  ### SolidUplot Component
463
463
 
464
464
  ```tsx
465
+ type SolidUplotEvents = {
466
+ /** Callback fired when the uPlot instance is created */
467
+ readonly onCreate?: (u: uPlot, meta: OnCreateMeta) => void;
468
+ /** Callback fired when the cursor moves */
469
+ readonly onCursorMove?: (params: OnCursorMoveParams) => void;
470
+ };
471
+
465
472
  // Main component props (extends all uPlot.Options except plugins, width, height)
466
- type SolidUplotProps<T extends VoidStruct = VoidStruct> = SolidUplotOptions<T> & {
467
- // Ref callback to access the chart container element
468
- ref?: (el: HTMLDivElement) => void;
473
+ type SolidUplotProps<T extends VoidStruct = VoidStruct> = SolidUplotOptions<T> &
474
+ SolidUplotEvents & {
475
+ // Ref callback to access the chart container element
476
+ ref?: Ref<HTMLDivElement>;
469
477
 
470
- // Callback fired when the uPlot instance is created
471
- onCreate?: (u: uPlot, meta: { seriesData: SeriesDatum[] }) => void;
478
+ // CSS class name for the chart container (default: "solid-uplot")
479
+ // Additional classes will be appended to the default class
480
+ class?: string;
472
481
 
473
- // Whether to reset scales when chart data is updated (default: true)
474
- resetScales?: boolean;
482
+ // CSS styles for the chart container (position is managed internally)
483
+ style?: Omit<JSX.CSSProperties, "position">;
475
484
 
476
- // CSS styles for the chart container (position is managed internally)
477
- style?: Omit<JSX.CSSProperties, "position">;
485
+ // Enable automatic resizing to fit container (default: false)
486
+ autoResize?: boolean;
478
487
 
479
- // Where to place children components relative to the chart (default: "top")
480
- childrenPlacement?: "top" | "bottom";
488
+ // Whether to reset scales when chart data is updated (default: true)
489
+ resetScales?: boolean;
481
490
 
482
- // Enable automatic resizing to fit container (default: false)
483
- autoResize?: boolean;
484
- };
491
+ // Where to place children components relative to the chart (default: "top")
492
+ childrenPlacement?: "top" | "bottom";
493
+ };
485
494
 
486
495
  // Configuration options extending uPlot.Options with SolidJS enhancements
487
496
  type SolidUplotOptions<T extends VoidStruct = VoidStruct> = Omit<
@@ -0,0 +1,24 @@
1
+ import 'uplot';
2
+
3
+ // src/utils/getColorString.ts
4
+ var getColorString = (fillOrStroke, fallback = "#888") => {
5
+ return typeof fillOrStroke === "string" ? fillOrStroke : fallback;
6
+ };
7
+ function getNewCalendarDayIndices(u) {
8
+ const xValues = u.data[0];
9
+ if (!xValues || !xValues.length) return [];
10
+ const seen = /* @__PURE__ */ new Set();
11
+ const indices = [];
12
+ for (let i = 0; i < xValues.length; i++) {
13
+ const ts = xValues[i];
14
+ const date = new Date(ts);
15
+ const dayString = date.toISOString().split("T")[0];
16
+ if (!seen.has(dayString)) {
17
+ seen.add(dayString);
18
+ indices.push(i);
19
+ }
20
+ }
21
+ return indices;
22
+ }
23
+
24
+ export { getColorString, getNewCalendarDayIndices };
@@ -1,3 +1,17 @@
1
+ // src/utils/getCursorData.ts
2
+ var getCursorData = (u) => {
3
+ const idx = u.cursor.idx;
4
+ const xValues = u.data[0];
5
+ const isValid = idx != null && xValues && idx < xValues.length;
6
+ return !isValid ? void 0 : {
7
+ plotId: u.root.id,
8
+ idx,
9
+ xValue: xValues[idx],
10
+ visible: Boolean(u.cursor.show),
11
+ position: { left: u.cursor.left || 0, top: u.cursor.top || 0 }
12
+ };
13
+ };
14
+
1
15
  // src/utils/getSeriesData.ts
2
16
  var getSeriesData = (u, options = {}) => {
3
17
  const series = [];
@@ -22,4 +36,4 @@ var getSeriesData = (u, options = {}) => {
22
36
  };
23
37
  // istanbul ignore next -- @preserve
24
38
 
25
- export { getSeriesData };
39
+ export { getCursorData, getSeriesData };
@@ -1,3 +1,17 @@
1
+ // src/utils/getCursorData.ts
2
+ var getCursorData = (u) => {
3
+ const idx = u.cursor.idx;
4
+ const xValues = u.data[0];
5
+ const isValid = idx != null && xValues && idx < xValues.length;
6
+ return !isValid ? void 0 : {
7
+ plotId: u.root.id,
8
+ idx,
9
+ xValue: xValues[idx],
10
+ visible: Boolean(u.cursor.show),
11
+ position: { left: u.cursor.left || 0, top: u.cursor.top || 0 }
12
+ };
13
+ };
14
+
1
15
  // src/utils/getSeriesData.ts
2
16
  var getSeriesData = (u, options = {}) => {
3
17
  const series = [];
@@ -22,6 +36,7 @@ var getSeriesData = (u, options = {}) => {
22
36
  };
23
37
 
24
38
  export {
39
+ getCursorData,
25
40
  getSeriesData
26
41
  };
27
42
  // istanbul ignore next -- @preserve
@@ -1,3 +1,46 @@
1
+ type CursorPosition = {
2
+ /**
3
+ * The cursor position left offset in CSS pixels (relative to plotting area)
4
+ */
5
+ readonly left: number;
6
+ /**
7
+ * The cursor position top offset in CSS pixels (relative to plotting area)
8
+ */
9
+ readonly top: number;
10
+ };
11
+ /**
12
+ * The cursor index data for a given uPlot instance.
13
+ */
14
+ type CursorData = {
15
+ /**
16
+ * The id of the plot instance that the cursor message originates from.
17
+ */
18
+ readonly plotId: string;
19
+ /**
20
+ * The closest x-axis data index to cursor (closestIdx)
21
+ */
22
+ readonly idx: number;
23
+ /**
24
+ * The x-axis value of the cursor idx.
25
+ */
26
+ readonly xValue: number;
27
+ /**
28
+ * The position of the cursor.
29
+ */
30
+ readonly position: CursorPosition;
31
+ /**
32
+ * The visibility of the cursor.
33
+ */
34
+ readonly visible: boolean;
35
+ };
36
+ /**
37
+ * Get the cursor index data for a given uPlot instance.
38
+ *
39
+ * @param u - The uPlot instance.
40
+ * @returns The cursor data.
41
+ */
42
+ declare const getCursorData: (u: uPlot) => CursorData | undefined;
43
+
1
44
  /**
2
45
  * Summary data for a given series.
3
46
  */
@@ -34,4 +77,4 @@ type GetSeriesDataOptions = {
34
77
  */
35
78
  declare const getSeriesData: (u: uPlot, options?: GetSeriesDataOptions) => SeriesDatum[];
36
79
 
37
- export { type SeriesDatum as S, getSeriesData as g };
80
+ export { type CursorData as C, type SeriesDatum as S, getSeriesData as a, getCursorData as g };
@@ -1,10 +1,20 @@
1
1
  import { V as VoidStruct, S as SolidUplotPluginBus, U as UplotPluginFactory } from '../createPluginBus-DdrjQANs.js';
2
2
  export { a as UplotPluginFactoryContext, c as createPluginBus } from '../createPluginBus-DdrjQANs.js';
3
+ import { Ref } from '@solid-primitives/refs';
3
4
  import { ParentProps, JSX } from 'solid-js';
4
- import uPlot from 'uplot';
5
- import { S as SeriesDatum } from '../getSeriesData-D1zBqQ9Y.js';
5
+ import uPlot$1 from 'uplot';
6
+ import { C as CursorData, S as SeriesDatum } from '../getSeriesData-04wGQord.js';
6
7
  import 'solid-js/store';
7
8
 
9
+ type OnCursorMoveParams = {
10
+ /** The uPlot instance */
11
+ readonly u: uPlot;
12
+ /** The cursor data */
13
+ readonly cursor: CursorData;
14
+ /** Array of series data extracted from the chart configuration */
15
+ readonly seriesData: SeriesDatum[];
16
+ };
17
+
8
18
  /** Placement options for children components relative to the chart */
9
19
  type ChildrenPlacement = "top" | "bottom";
10
20
  /**
@@ -13,14 +23,14 @@ type ChildrenPlacement = "top" | "bottom";
13
23
  *
14
24
  * @template T - The type of the plugin bus data structure
15
25
  */
16
- type SolidUplotPlugin<T extends VoidStruct = VoidStruct> = uPlot.Plugin | UplotPluginFactory<T>;
26
+ type SolidUplotPlugin<T extends VoidStruct = VoidStruct> = uPlot$1.Plugin | UplotPluginFactory<T>;
17
27
  /**
18
28
  * Configuration options for the SolidUplot component, extending uPlot.Options
19
29
  * with SolidJS-specific enhancements
20
30
  *
21
31
  * @template T - The type of the plugin bus data structure
22
32
  */
23
- type SolidUplotOptions<T extends VoidStruct = VoidStruct> = Omit<uPlot.Options, "plugins" | "width" | "height"> & {
33
+ type SolidUplotOptions<T extends VoidStruct = VoidStruct> = Omit<uPlot$1.Options, "plugins" | "width" | "height"> & {
24
34
  /** Chart width in pixels */
25
35
  readonly width?: number;
26
36
  /** Chart height in pixels */
@@ -37,28 +47,27 @@ type OnCreateMeta = {
37
47
  /** Array of series data extracted from the chart configuration */
38
48
  readonly seriesData: SeriesDatum[];
39
49
  };
50
+ /**
51
+ * Events that can be passed to the SolidUplot component
52
+ */
53
+ type SolidUplotEvents = {
54
+ /** Callback fired when the uPlot instance is created */
55
+ readonly onCreate?: (u: uPlot$1, meta: OnCreateMeta) => void;
56
+ /** Callback fired when the cursor moves */
57
+ readonly onCursorMove?: (params: OnCursorMoveParams) => void;
58
+ };
40
59
  /**
41
60
  * Props for the SolidUplot component
42
61
  *
43
62
  * @template T - The type of the plugin bus data structure
44
63
  */
45
- type SolidUplotProps<T extends VoidStruct = VoidStruct> = SolidUplotOptions<T> & {
46
- /** Ref callback to access the chart container element */
47
- readonly ref?: (el: HTMLDivElement) => void;
48
- /** Callback fired when the uPlot instance is created */
49
- readonly onCreate?: (u: uPlot, meta: OnCreateMeta) => void;
50
- /**
51
- * Whether to reset scales when chart data is updated
52
- * @default true
53
- */
54
- readonly resetScales?: boolean;
64
+ type SolidUplotProps<T extends VoidStruct = VoidStruct> = SolidUplotOptions<T> & SolidUplotEvents & {
65
+ /** Class name for the chart container */
66
+ readonly class?: string;
55
67
  /** CSS styles for the chart container (position is managed internally) */
56
68
  readonly style?: Omit<JSX.CSSProperties, "position">;
57
- /**
58
- * Where to place children components relative to the chart
59
- * @default "top"
60
- */
61
- readonly childrenPlacement?: ChildrenPlacement;
69
+ /** Ref callback to access the chart container element */
70
+ readonly ref?: Ref<HTMLDivElement>;
62
71
  /**
63
72
  * Enable automatic resizing to fit container.
64
73
  *
@@ -70,6 +79,16 @@ type SolidUplotProps<T extends VoidStruct = VoidStruct> = SolidUplotOptions<T> &
70
79
  * @default false
71
80
  */
72
81
  readonly autoResize?: boolean;
82
+ /**
83
+ * Whether to reset scales when chart data is updated
84
+ * @default true
85
+ */
86
+ readonly resetScales?: boolean;
87
+ /**
88
+ * Where to place children components relative to the chart
89
+ * @default "top"
90
+ */
91
+ readonly childrenPlacement?: ChildrenPlacement;
73
92
  };
74
93
  /**
75
94
  * A SolidJS wrapper component for uPlot charts with enhanced features
@@ -1,7 +1,9 @@
1
- import { getSeriesData } from '../chunk/ZISGD6FJ.js';
1
+ import '../chunk/IV6D7K4M.js';
2
+ import { getSeriesData, getCursorData } from '../chunk/QELYARMN.js';
2
3
  import { createStore } from 'solid-js/store';
3
- import { template, use, insert, effect, style } from 'solid-js/web';
4
+ import { template, use, insert, effect, className, style } from 'solid-js/web';
4
5
  import 'uplot/dist/uPlot.min.css';
6
+ import { mergeRefs } from '@solid-primitives/refs';
5
7
  import { mergeProps, createUniqueId, splitProps, createMemo, createEffect, untrack, onCleanup } from 'solid-js';
6
8
  import uPlot from 'uplot';
7
9
 
@@ -12,6 +14,21 @@ var createPluginBus = (initialData = {}) => {
12
14
  setData
13
15
  };
14
16
  };
17
+
18
+ // src/eventPlugins.ts
19
+ var createCursorMovePlugin = (onCursorMove) => {
20
+ return {
21
+ hooks: {
22
+ setCursor: (u) => {
23
+ const cursor = getCursorData(u);
24
+ if (!cursor) return;
25
+ onCursorMove?.({ u, cursor, seriesData: getSeriesData(u) });
26
+ }
27
+ }
28
+ };
29
+ };
30
+
31
+ // src/SolidUplot.tsx
15
32
  var _tmpl$ = /* @__PURE__ */ template(`<div id=solid-uplot-root>`);
16
33
  var SolidUplot = (props) => {
17
34
  let container;
@@ -28,7 +45,7 @@ var SolidUplot = (props) => {
28
45
  show: false
29
46
  }
30
47
  }, props);
31
- const [local, options] = splitProps(_props, ["children", "childrenPlacement", "autoResize", "onCreate", "style", "ref"]);
48
+ const [local, options] = splitProps(_props, ["children", "childrenPlacement", "class", "autoResize", "onCreate", "onCursorMove", "style", "ref"]);
32
49
  const [updateableOptions, newChartOptions] = splitProps(options, ["data", "width", "height", "resetScales"]);
33
50
  const [system, chartOptions] = splitProps(newChartOptions, ["pluginBus", "plugins"]);
34
51
  const size = () => ({
@@ -36,9 +53,13 @@ var SolidUplot = (props) => {
36
53
  height: updateableOptions.height
37
54
  });
38
55
  const chartPlugins = createMemo(() => {
39
- return system.plugins.map((plugin) => typeof plugin === "function" ? plugin({
56
+ const plugins = system.plugins.map((plugin) => typeof plugin === "function" ? plugin({
40
57
  bus: system.pluginBus
41
58
  }) : plugin);
59
+ if (local.onCursorMove) {
60
+ plugins.push(createCursorMovePlugin(local.onCursorMove));
61
+ }
62
+ return plugins;
42
63
  });
43
64
  createEffect(() => {
44
65
  const getInitialSize = () => {
@@ -91,25 +112,32 @@ var SolidUplot = (props) => {
91
112
  chart.destroy();
92
113
  });
93
114
  });
115
+ const classes = () => local.class ? `solid-uplot ${local.class}` : "solid-uplot";
94
116
  return (() => {
95
117
  var _el$ = _tmpl$();
96
- use((el) => {
97
- container = el;
98
- local.ref?.(el);
99
- }, _el$);
118
+ var _ref$ = mergeRefs(local.ref, (el) => container = el);
119
+ typeof _ref$ === "function" && use(_ref$, _el$);
100
120
  insert(_el$, () => local.children);
101
- effect((_$p) => style(_el$, {
102
- display: "flex",
103
- "flex-direction": local.childrenPlacement === "top" ? "column" : "column-reverse",
104
- // When autoResize is enabled, fill the parent container
105
- ...local.autoResize && {
106
- width: "100%",
107
- height: "100%",
108
- "min-width": "0",
109
- "min-height": "0"
110
- },
111
- ...local.style
112
- }, _$p));
121
+ effect((_p$) => {
122
+ var _v$ = classes(), _v$2 = {
123
+ display: "flex",
124
+ "flex-direction": local.childrenPlacement === "top" ? "column" : "column-reverse",
125
+ // When autoResize is enabled, fill the parent container
126
+ ...local.autoResize && {
127
+ width: "100%",
128
+ height: "100%",
129
+ "min-width": "0",
130
+ "min-height": "0"
131
+ },
132
+ ...local.style
133
+ };
134
+ _v$ !== _p$.e && className(_el$, _p$.e = _v$);
135
+ _p$.t = style(_el$, _v$2, _p$.t);
136
+ return _p$;
137
+ }, {
138
+ e: void 0,
139
+ t: void 0
140
+ });
113
141
  return _el$;
114
142
  })();
115
143
  };
@@ -1,6 +1,7 @@
1
1
  import {
2
+ getCursorData,
2
3
  getSeriesData
3
- } from "../chunk/A3AZKFSW.jsx";
4
+ } from "../chunk/X3NAOFDO.jsx";
4
5
 
5
6
  // src/createPluginBus.tsx
6
7
  import { createStore } from "solid-js/store";
@@ -11,6 +12,7 @@ var createPluginBus = (initialData = {}) => {
11
12
 
12
13
  // src/SolidUplot.tsx
13
14
  import "uplot/dist/uPlot.min.css";
15
+ import { mergeRefs } from "@solid-primitives/refs";
14
16
  import {
15
17
  createEffect,
16
18
  createMemo,
@@ -20,7 +22,25 @@ import {
20
22
  splitProps,
21
23
  untrack
22
24
  } from "solid-js";
23
- import uPlot from "uplot";
25
+ import uPlot2 from "uplot";
26
+
27
+ // src/utils/getNewCalendarDayIndices.ts
28
+ import "uplot";
29
+
30
+ // src/eventPlugins.ts
31
+ var createCursorMovePlugin = (onCursorMove) => {
32
+ return {
33
+ hooks: {
34
+ setCursor: (u) => {
35
+ const cursor = getCursorData(u);
36
+ if (!cursor) return;
37
+ onCursorMove?.({ u, cursor, seriesData: getSeriesData(u) });
38
+ }
39
+ }
40
+ };
41
+ };
42
+
43
+ // src/SolidUplot.tsx
24
44
  var SolidUplot = (props) => {
25
45
  let container;
26
46
  const _props = mergeProps(
@@ -42,8 +62,10 @@ var SolidUplot = (props) => {
42
62
  const [local, options] = splitProps(_props, [
43
63
  "children",
44
64
  "childrenPlacement",
65
+ "class",
45
66
  "autoResize",
46
67
  "onCreate",
68
+ "onCursorMove",
47
69
  "style",
48
70
  "ref"
49
71
  ]);
@@ -56,9 +78,13 @@ var SolidUplot = (props) => {
56
78
  const [system, chartOptions] = splitProps(newChartOptions, ["pluginBus", "plugins"]);
57
79
  const size = () => ({ width: updateableOptions.width, height: updateableOptions.height });
58
80
  const chartPlugins = createMemo(() => {
59
- return system.plugins.map(
81
+ const plugins = system.plugins.map(
60
82
  (plugin) => typeof plugin === "function" ? plugin({ bus: system.pluginBus }) : plugin
61
83
  );
84
+ if (local.onCursorMove) {
85
+ plugins.push(createCursorMovePlugin(local.onCursorMove));
86
+ }
87
+ return plugins;
62
88
  });
63
89
  createEffect(() => {
64
90
  const getInitialSize = () => {
@@ -73,7 +99,7 @@ var SolidUplot = (props) => {
73
99
  };
74
100
  const initialSize = getInitialSize();
75
101
  const initialData = untrack(() => updateableOptions.data);
76
- const chart = new uPlot(
102
+ const chart = new uPlot2(
77
103
  {
78
104
  ...chartOptions,
79
105
  ...initialSize,
@@ -107,8 +133,11 @@ var SolidUplot = (props) => {
107
133
  chart.destroy();
108
134
  });
109
135
  });
136
+ const classes = () => local.class ? `solid-uplot ${local.class}` : "solid-uplot";
110
137
  return <div
111
138
  id="solid-uplot-root"
139
+ ref={mergeRefs(local.ref, (el) => container = el)}
140
+ class={classes()}
112
141
  style={{
113
142
  display: "flex",
114
143
  "flex-direction": local.childrenPlacement === "top" ? "column" : "column-reverse",
@@ -121,10 +150,6 @@ var SolidUplot = (props) => {
121
150
  },
122
151
  ...local.style
123
152
  }}
124
- ref={(el) => {
125
- container = el;
126
- local.ref?.(el);
127
- }}
128
153
  >
129
154
  {local.children}
130
155
  </div>;
@@ -1,8 +1,7 @@
1
1
  import { U as UplotPluginFactory, S as SolidUplotPluginBus } from '../createPluginBus-DdrjQANs.js';
2
- import { C as CursorData } from '../getCursorData-2qxURGuZ.js';
2
+ import { C as CursorData, S as SeriesDatum } from '../getSeriesData-04wGQord.js';
3
3
  import { Component, JSX } from 'solid-js';
4
4
  import uPlot from 'uplot';
5
- import { S as SeriesDatum } from '../getSeriesData-D1zBqQ9Y.js';
6
5
  import 'solid-js/store';
7
6
 
8
7
  /**
@@ -1,5 +1,4 @@
1
- import { getCursorData } from '../chunk/3TJS44N7.js';
2
- import { getSeriesData } from '../chunk/ZISGD6FJ.js';
1
+ import { getCursorData, getSeriesData } from '../chunk/QELYARMN.js';
3
2
  import { createRoot, createEffect, mergeProps, splitProps, Show } from 'solid-js';
4
3
  import { render, createComponent, template, use, insert, effect, setAttribute, className, style } from 'solid-js/web';
5
4
 
@@ -1,20 +1,7 @@
1
1
  import {
2
+ getCursorData,
2
3
  getSeriesData
3
- } from "../chunk/A3AZKFSW.jsx";
4
-
5
- // src/utils/getCursorData.ts
6
- var getCursorData = (u) => {
7
- const idx = u.cursor.idx;
8
- const xValues = u.data[0];
9
- const isValid = idx != null && xValues && idx < xValues.length;
10
- return !isValid ? void 0 : {
11
- plotId: u.root.id,
12
- idx,
13
- xValue: xValues[idx],
14
- visible: Boolean(u.cursor.show),
15
- position: { left: u.cursor.left || 0, top: u.cursor.top || 0 }
16
- };
17
- };
4
+ } from "../chunk/X3NAOFDO.jsx";
18
5
 
19
6
  // src/plugins/cursor.ts
20
7
  var cursor = () => {
@@ -1,6 +1,5 @@
1
- export { C as CursorData, g as getCursorData } from '../getCursorData-2qxURGuZ.js';
1
+ export { C as CursorData, S as SeriesDatum, g as getCursorData, a as getSeriesData } from '../getSeriesData-04wGQord.js';
2
2
  import uPlot from 'uplot';
3
- export { S as SeriesDatum, g as getSeriesData } from '../getSeriesData-D1zBqQ9Y.js';
4
3
 
5
4
  /**
6
5
  * Utility to get a color string from uPlot stroke or fill values
@@ -1,26 +1,2 @@
1
- export { getCursorData } from '../chunk/3TJS44N7.js';
2
- export { getSeriesData } from '../chunk/ZISGD6FJ.js';
3
- import 'uplot';
4
-
5
- // src/utils/getColorString.ts
6
- var getColorString = (fillOrStroke, fallback = "#888") => {
7
- return typeof fillOrStroke === "string" ? fillOrStroke : fallback;
8
- };
9
- function getNewCalendarDayIndices(u) {
10
- const xValues = u.data[0];
11
- if (!xValues || !xValues.length) return [];
12
- const seen = /* @__PURE__ */ new Set();
13
- const indices = [];
14
- for (let i = 0; i < xValues.length; i++) {
15
- const ts = xValues[i];
16
- const date = new Date(ts);
17
- const dayString = date.toISOString().split("T")[0];
18
- if (!seen.has(dayString)) {
19
- seen.add(dayString);
20
- indices.push(i);
21
- }
22
- }
23
- return indices;
24
- }
25
-
26
- export { getColorString, getNewCalendarDayIndices };
1
+ export { getColorString, getNewCalendarDayIndices } from '../chunk/IV6D7K4M.js';
2
+ export { getCursorData, getSeriesData } from '../chunk/QELYARMN.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dschz/solid-uplot",
3
- "version": "0.1.7",
3
+ "version": "0.2.0",
4
4
  "description": "SolidJS wrapper for uPlot — ultra-fast, tiny time-series & charting library",
5
5
  "type": "module",
6
6
  "author": "Daniel Sanchez <dsanc89@pm.me>",
@@ -146,5 +146,7 @@
146
146
  "solid-js": ">=1.6.0",
147
147
  "uplot": ">=1.6.32"
148
148
  },
149
- "dependencies": {}
149
+ "dependencies": {
150
+ "@solid-primitives/refs": "^1.1.1"
151
+ }
150
152
  }
@@ -1,15 +0,0 @@
1
- // src/utils/getCursorData.ts
2
- var getCursorData = (u) => {
3
- const idx = u.cursor.idx;
4
- const xValues = u.data[0];
5
- const isValid = idx != null && xValues && idx < xValues.length;
6
- return !isValid ? void 0 : {
7
- plotId: u.root.id,
8
- idx,
9
- xValue: xValues[idx],
10
- visible: Boolean(u.cursor.show),
11
- position: { left: u.cursor.left || 0, top: u.cursor.top || 0 }
12
- };
13
- };
14
-
15
- export { getCursorData };
@@ -1,44 +0,0 @@
1
- type CursorPosition = {
2
- /**
3
- * The cursor position left offset in CSS pixels (relative to plotting area)
4
- */
5
- readonly left: number;
6
- /**
7
- * The cursor position top offset in CSS pixels (relative to plotting area)
8
- */
9
- readonly top: number;
10
- };
11
- /**
12
- * The cursor index data for a given uPlot instance.
13
- */
14
- type CursorData = {
15
- /**
16
- * The id of the plot instance that the cursor message originates from.
17
- */
18
- readonly plotId: string;
19
- /**
20
- * The closest x-axis data index to cursor (closestIdx)
21
- */
22
- readonly idx: number;
23
- /**
24
- * The x-axis value of the cursor idx.
25
- */
26
- readonly xValue: number;
27
- /**
28
- * The position of the cursor.
29
- */
30
- readonly position: CursorPosition;
31
- /**
32
- * The visibility of the cursor.
33
- */
34
- readonly visible: boolean;
35
- };
36
- /**
37
- * Get the cursor index data for a given uPlot instance.
38
- *
39
- * @param u - The uPlot instance.
40
- * @returns The cursor data.
41
- */
42
- declare const getCursorData: (u: uPlot) => CursorData | undefined;
43
-
44
- export { type CursorData as C, getCursorData as g };