@dschz/solid-uplot 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index/index.d.ts +67 -6
- package/dist/plugins/index.d.ts +7 -0
- package/package.json +1 -1
package/dist/index/index.d.ts
CHANGED
|
@@ -5,27 +5,59 @@ import uPlot from 'uplot';
|
|
|
5
5
|
import { S as SeriesDatum } from '../getSeriesData-D1zBqQ9Y.js';
|
|
6
6
|
import 'solid-js/store';
|
|
7
7
|
|
|
8
|
+
/** Placement options for children components relative to the chart */
|
|
8
9
|
type ChildrenPlacement = "top" | "bottom";
|
|
10
|
+
/**
|
|
11
|
+
* A SolidJS-compatible uPlot plugin that can be either a standard uPlot plugin
|
|
12
|
+
* or a factory function that creates a plugin with access to the plugin bus
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type of the plugin bus data structure
|
|
15
|
+
*/
|
|
9
16
|
type SolidUplotPlugin<T extends VoidStruct = VoidStruct> = uPlot.Plugin | PluginFactory<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Configuration options for the SolidUplot component, extending uPlot.Options
|
|
19
|
+
* with SolidJS-specific enhancements
|
|
20
|
+
*
|
|
21
|
+
* @template T - The type of the plugin bus data structure
|
|
22
|
+
*/
|
|
10
23
|
type SolidUplotOptions<T extends VoidStruct = VoidStruct> = Omit<uPlot.Options, "plugins" | "width" | "height"> & {
|
|
24
|
+
/** Chart width in pixels */
|
|
11
25
|
readonly width?: number;
|
|
26
|
+
/** Chart height in pixels */
|
|
12
27
|
readonly height?: number;
|
|
28
|
+
/** Plugin communication bus for coordinating between plugins */
|
|
13
29
|
readonly pluginBus?: SolidUplotPluginBus<T>;
|
|
30
|
+
/** Array of plugins to apply to the chart */
|
|
14
31
|
readonly plugins?: SolidUplotPlugin<T>[];
|
|
15
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Metadata provided to the onCreate callback when the chart is initialized
|
|
35
|
+
*/
|
|
16
36
|
type OnCreateMeta = {
|
|
37
|
+
/** Array of series data extracted from the chart configuration */
|
|
17
38
|
readonly seriesData: SeriesDatum[];
|
|
18
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Props for the SolidUplot component
|
|
42
|
+
*
|
|
43
|
+
* @template T - The type of the plugin bus data structure
|
|
44
|
+
*/
|
|
19
45
|
type SolidUplotProps<T extends VoidStruct = VoidStruct> = SolidUplotOptions<T> & {
|
|
20
|
-
/**
|
|
46
|
+
/** Ref callback to access the chart container element */
|
|
21
47
|
readonly ref?: (el: HTMLDivElement) => void;
|
|
22
|
-
/** Callback when uPlot instance is created */
|
|
48
|
+
/** Callback fired when the uPlot instance is created */
|
|
23
49
|
readonly onCreate?: (u: uPlot, meta: OnCreateMeta) => void;
|
|
24
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Whether to reset scales when chart data is updated
|
|
52
|
+
* @default true
|
|
53
|
+
*/
|
|
25
54
|
readonly resetScales?: boolean;
|
|
26
|
-
/**
|
|
55
|
+
/** CSS styles for the chart container (position is managed internally) */
|
|
27
56
|
readonly style?: Omit<JSX.CSSProperties, "position">;
|
|
28
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Where to place children components relative to the chart
|
|
59
|
+
* @default "top"
|
|
60
|
+
*/
|
|
29
61
|
readonly childrenPlacement?: ChildrenPlacement;
|
|
30
62
|
/**
|
|
31
63
|
* Enable automatic resizing to fit container.
|
|
@@ -39,6 +71,35 @@ type SolidUplotProps<T extends VoidStruct = VoidStruct> = SolidUplotOptions<T> &
|
|
|
39
71
|
*/
|
|
40
72
|
readonly autoResize?: boolean;
|
|
41
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* A SolidJS wrapper component for uPlot charts with enhanced features
|
|
76
|
+
*
|
|
77
|
+
* This component provides:
|
|
78
|
+
* - Reactive data updates
|
|
79
|
+
* - Plugin system with communication bus
|
|
80
|
+
* - Automatic resizing capabilities
|
|
81
|
+
* - Flexible children placement
|
|
82
|
+
* - TypeScript support with generics
|
|
83
|
+
*
|
|
84
|
+
* @template T - The type of the plugin bus data structure for type-safe plugin communication
|
|
85
|
+
*
|
|
86
|
+
* @param props - Component props extending uPlot options with SolidJS enhancements
|
|
87
|
+
* @returns JSX element containing the chart and any children components
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```tsx
|
|
91
|
+
* <SolidUplot
|
|
92
|
+
* data={chartData}
|
|
93
|
+
* height={400}
|
|
94
|
+
* autoResize
|
|
95
|
+
* series={[
|
|
96
|
+
* {},
|
|
97
|
+
* { label: "Series 1", stroke: "red" }
|
|
98
|
+
* ]}
|
|
99
|
+
* onCreate={(chart) => console.log("Chart created:", chart)}
|
|
100
|
+
* />
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
42
103
|
declare const SolidUplot: <T extends VoidStruct = VoidStruct>(props: ParentProps<SolidUplotProps<T>>) => JSX.Element;
|
|
43
104
|
|
|
44
|
-
export { SolidUplot
|
|
105
|
+
export { SolidUplot };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -226,6 +226,13 @@ declare const focusSeries: (options?: FocusSeriesPluginOptions) => PluginFactory
|
|
|
226
226
|
* Simple legend placement options - only top corners to avoid axis conflicts
|
|
227
227
|
*/
|
|
228
228
|
type LegendPlacement = "top-left" | "top-right";
|
|
229
|
+
/**
|
|
230
|
+
* Props passed to the custom legend SolidJS component.
|
|
231
|
+
*
|
|
232
|
+
* The legend plugin automatically provides these props to your custom component, ensuring it always
|
|
233
|
+
* receives the latest series data from the chart via the plugin bus system. This creates a reactive
|
|
234
|
+
* data flow where series data changes immediately trigger legend updates with fresh data information.
|
|
235
|
+
*/
|
|
229
236
|
type LegendProps = {
|
|
230
237
|
readonly u: uPlot;
|
|
231
238
|
readonly seriesData: SeriesDatum[];
|
package/package.json
CHANGED