@grafana/components 0.0.15 → 0.0.16
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/cjs/index.cjs +393 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +142 -3
- package/dist/esm/components/ComparisonBadge/ComparisonBadge.styles.js +2 -2
- package/dist/esm/components/ComparisonBadge/ComparisonBadge.styles.js.map +1 -1
- package/dist/esm/components/ComparisonTooltip/ComparisonTooltip.styles.js +2 -2
- package/dist/esm/components/ComparisonTooltip/ComparisonTooltip.styles.js.map +1 -1
- package/dist/esm/components/GenericSkeleton/GenericSkeleton.js +14 -0
- package/dist/esm/components/GenericSkeleton/GenericSkeleton.js.map +1 -0
- package/dist/esm/components/GenericSkeleton/GenericSkeleton.styles.js +47 -0
- package/dist/esm/components/GenericSkeleton/GenericSkeleton.styles.js.map +1 -0
- package/dist/esm/components/Popover/Popover.styles.js +2 -2
- package/dist/esm/components/StackedChart/StackedChart.js +158 -0
- package/dist/esm/components/StackedChart/StackedChart.js.map +1 -0
- package/dist/esm/components/StackedChart/StackedChart.styles.js +19 -0
- package/dist/esm/components/StackedChart/StackedChart.styles.js.map +1 -0
- package/dist/esm/components/StackedChart/shared.styles.js +6 -0
- package/dist/esm/components/StackedChart/shared.styles.js.map +1 -0
- package/dist/esm/components/StackedChartSegment/StackedChartSegment.js +32 -0
- package/dist/esm/components/StackedChartSegment/StackedChartSegment.js.map +1 -0
- package/dist/esm/components/StackedChartSegment/StackedChartSegment.styles.js +45 -0
- package/dist/esm/components/StackedChartSegment/StackedChartSegment.styles.js.map +1 -0
- package/dist/esm/components/StackedChartSegmentTooltip/StackedChartSegmentTooltip.js +40 -0
- package/dist/esm/components/StackedChartSegmentTooltip/StackedChartSegmentTooltip.js.map +1 -0
- package/dist/esm/components/StackedChartSegmentTooltip/StackedChartSegmentTooltip.styles.js +53 -0
- package/dist/esm/components/StackedChartSegmentTooltip/StackedChartSegmentTooltip.styles.js.map +1 -0
- package/dist/esm/components/StackedChartSkeleton/StackedChartSkeleton.js +11 -0
- package/dist/esm/components/StackedChartSkeleton/StackedChartSkeleton.js.map +1 -0
- package/dist/esm/components/StackedChartSkeleton/StackedChartSkeleton.styles.js +13 -0
- package/dist/esm/components/StackedChartSkeleton/StackedChartSkeleton.styles.js.map +1 -0
- package/dist/esm/index.d.ts +142 -3
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
|
-
import React__default, { ReactNode, JSX } from 'react';
|
|
2
|
+
import React__default, { ReactNode, JSX, MouseEventHandler as MouseEventHandler$1 } from 'react';
|
|
3
3
|
import { EventBus, GrafanaTheme2 } from '@grafana/data';
|
|
4
4
|
import { ThemeColorMode } from '@grafana/design-tokens';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -109,6 +109,145 @@ interface ComparisonBadgeProps extends Pick<ComparisonTooltipProps, 'currentLabe
|
|
|
109
109
|
}
|
|
110
110
|
declare const ComparisonBadge: ({ current, previous, currentLabel, previousLabel, placement, highlight, timeframeLabel, tooltip, hideDelay, }: ComparisonBadgeProps) => react_jsx_runtime.JSX.Element;
|
|
111
111
|
|
|
112
|
+
interface GenericSkeletonProps {
|
|
113
|
+
/**
|
|
114
|
+
* Duration of animation in seconds
|
|
115
|
+
*/
|
|
116
|
+
animationDuration?: number;
|
|
117
|
+
}
|
|
118
|
+
declare const GenericSkeleton: ({ animationDuration }: GenericSkeletonProps) => react_jsx_runtime.JSX.Element;
|
|
119
|
+
|
|
120
|
+
interface StackedChartCategory {
|
|
121
|
+
title: string;
|
|
122
|
+
value: number;
|
|
123
|
+
}
|
|
124
|
+
type StackedChartCategories<T extends string> = Record<T, StackedChartCategory>;
|
|
125
|
+
type StackedChartSortOrder = 'largest-first' | 'smallest-first' | 'natural';
|
|
126
|
+
type MouseEventHandler = ({ categoryId, ref, }: {
|
|
127
|
+
categoryId: string;
|
|
128
|
+
ref: React.ForwardedRef<HTMLDivElement>;
|
|
129
|
+
}) => void;
|
|
130
|
+
interface CommonStackedChartProps<T extends string> {
|
|
131
|
+
/**
|
|
132
|
+
* How should category segments be sorted?
|
|
133
|
+
*/
|
|
134
|
+
sortOrder?: StackedChartSortOrder;
|
|
135
|
+
/**
|
|
136
|
+
* Height to render the stacked chart, in pixels
|
|
137
|
+
*/
|
|
138
|
+
height?: number;
|
|
139
|
+
/**
|
|
140
|
+
* initial category ID to highlight; if omitted then all segments will render
|
|
141
|
+
* in colour and highlight based on mouseover events.
|
|
142
|
+
*/
|
|
143
|
+
highlightedCategoryId?: T;
|
|
144
|
+
/**
|
|
145
|
+
* Should the whole StackedChart be dimmed, i.e. with a highlighted category
|
|
146
|
+
* not in color, all other categories faded out?
|
|
147
|
+
*/
|
|
148
|
+
isDimmed?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Event handler for whenever a segment gets a mouseover event
|
|
151
|
+
*/
|
|
152
|
+
onSegmentMouseOver?: MouseEventHandler;
|
|
153
|
+
/**
|
|
154
|
+
* Event handler for whenever a segment gets a mouseout event
|
|
155
|
+
*/
|
|
156
|
+
onSegmentMouseOut?: MouseEventHandler;
|
|
157
|
+
}
|
|
158
|
+
interface SkeletonStackedChartProps<T extends string> extends CommonStackedChartProps<T> {
|
|
159
|
+
isSkeleton: true;
|
|
160
|
+
/**
|
|
161
|
+
* Array of StackedChartCategory to build the chart from
|
|
162
|
+
*/
|
|
163
|
+
categories?: StackedChartCategories<T>;
|
|
164
|
+
}
|
|
165
|
+
interface LoadedStackedChartProps<T extends string> extends CommonStackedChartProps<T> {
|
|
166
|
+
isSkeleton?: false;
|
|
167
|
+
/**
|
|
168
|
+
* Array of StackedChartCategory to build the chart from
|
|
169
|
+
*/
|
|
170
|
+
categories: StackedChartCategories<T>;
|
|
171
|
+
}
|
|
172
|
+
type StackedChartProps<T extends string> = SkeletonStackedChartProps<T> | LoadedStackedChartProps<T>;
|
|
173
|
+
declare const StackedChart: <T extends string>({ categories: _categories, highlightedCategoryId: initialHighlightedCategoryId, isSkeleton, isDimmed, sortOrder, height, onSegmentMouseOver, onSegmentMouseOut, }: StackedChartProps<T>) => react_jsx_runtime.JSX.Element;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* A segment can be in one of four states:
|
|
177
|
+
*
|
|
178
|
+
* 1. Default — diagonal grey stripes, with a grey fill
|
|
179
|
+
* 2. Color — a bright coloured fill, with diagonal stripes. The actual hue is
|
|
180
|
+
* determined by its position in the chart and the primary theme hue.
|
|
181
|
+
* 3. Active — the same as Color, only with a drop shadow, i.e. when hovered (to
|
|
182
|
+
* also show a popover)
|
|
183
|
+
* 4. Dimmed — the same as Default, but faded out with reduced opacity
|
|
184
|
+
*/
|
|
185
|
+
type StackedChartSegmentState = 'default' | 'color' | 'active' | 'dimmed';
|
|
186
|
+
type SegmentMouseEventHandler = ({ categoryId, ref, }: {
|
|
187
|
+
categoryId: string;
|
|
188
|
+
ref: React.ForwardedRef<HTMLDivElement>;
|
|
189
|
+
}) => MouseEventHandler$1<HTMLDivElement>;
|
|
190
|
+
interface StackedChartSegmentProps<T extends string> {
|
|
191
|
+
/**
|
|
192
|
+
* Title to associate with this segment, e.g. for a popover
|
|
193
|
+
*/
|
|
194
|
+
title: string;
|
|
195
|
+
/**
|
|
196
|
+
* Unique ID for this segment
|
|
197
|
+
*/
|
|
198
|
+
categoryId: T;
|
|
199
|
+
/**
|
|
200
|
+
* Value for the segment relative to the overall chart
|
|
201
|
+
*/
|
|
202
|
+
value: number;
|
|
203
|
+
/**
|
|
204
|
+
* Value representing the overall scale of the chart; defaults to 100 (i.e.
|
|
205
|
+
* percentage)
|
|
206
|
+
*/
|
|
207
|
+
total?: number;
|
|
208
|
+
/**
|
|
209
|
+
* Index of the segment within the chart, i.e. to determine its fill color
|
|
210
|
+
*/
|
|
211
|
+
index: number;
|
|
212
|
+
/**
|
|
213
|
+
* Minimum value for this segment to display as, to avoid rendering very small
|
|
214
|
+
* segments for values below e.g. 1%. This will result in the total width of
|
|
215
|
+
* all segments exceeding 100%, but the browser layout engine will handle this
|
|
216
|
+
* for us (I think…??)
|
|
217
|
+
*/
|
|
218
|
+
minValue?: number;
|
|
219
|
+
/**
|
|
220
|
+
* Visual state of the segment
|
|
221
|
+
*/
|
|
222
|
+
state?: StackedChartSegmentState;
|
|
223
|
+
/**
|
|
224
|
+
* Event handler for whenever this segment gets a mouseover event
|
|
225
|
+
*/
|
|
226
|
+
onMouseOver?: SegmentMouseEventHandler;
|
|
227
|
+
/**
|
|
228
|
+
* Event handler for whenever this segment gets a mouseout event
|
|
229
|
+
*/
|
|
230
|
+
onMouseOut?: SegmentMouseEventHandler;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
declare const StackedChartSegment: React__default.ForwardRefExoticComponent<StackedChartSegmentProps<string> & React__default.RefAttributes<HTMLDivElement>>;
|
|
234
|
+
|
|
235
|
+
type ContentFormatter = (args: {
|
|
236
|
+
colorClassName: string;
|
|
237
|
+
} & Required<Pick<StackedChartSegmentProps<string>, 'value' | 'total' | 'index'>>) => React.ReactElement;
|
|
238
|
+
interface StackedChartSegmentTooltipProps<T extends string> extends Pick<StackedChartSegmentProps<T>, 'title' | 'value' | 'total' | 'index'>, Omit<PopoverProps, 'children'> {
|
|
239
|
+
formatContent?: ContentFormatter;
|
|
240
|
+
}
|
|
241
|
+
declare const StackedChartSegmentTooltip: <T extends string>({ trigger, placement, hideDelay, title, value, total, index, formatContent, virtualElement, }: StackedChartSegmentTooltipProps<T>) => react_jsx_runtime.JSX.Element;
|
|
242
|
+
|
|
243
|
+
interface StackedChartSkeletonProps {
|
|
244
|
+
/**
|
|
245
|
+
* Height to render the stacked chart skeleton, in pixels
|
|
246
|
+
*/
|
|
247
|
+
height?: number;
|
|
248
|
+
}
|
|
249
|
+
declare const StackedChartSkeleton: ({ height }: StackedChartSkeletonProps) => react_jsx_runtime.JSX.Element;
|
|
250
|
+
|
|
112
251
|
/**
|
|
113
252
|
* Shared utility functions for handling comparison calculations across components
|
|
114
253
|
*/
|
|
@@ -153,5 +292,5 @@ interface FormatNumberOptions {
|
|
|
153
292
|
*/
|
|
154
293
|
declare const formatNumber: (value: number | string | "loading", options?: FormatNumberOptions) => string;
|
|
155
294
|
|
|
156
|
-
export { ColorMode, ColorModeChangeHandler, ColorModeProvider, ComparisonBadge, ComparisonTooltip, Popover, calculateComparison, formatNumber, useColorMode, useColorModeChange };
|
|
157
|
-
export type { ColorModeChangeProps, ColorModeContextType, ColorModeProviderProps, ColorModeWrapper, ComparisonResult, ComparisonTooltipProps, FormatNumberOptions, PopoverProps };
|
|
295
|
+
export { ColorMode, ColorModeChangeHandler, ColorModeProvider, ComparisonBadge, ComparisonTooltip, GenericSkeleton, Popover, StackedChart, StackedChartSegment, StackedChartSegmentTooltip, StackedChartSkeleton, calculateComparison, formatNumber, useColorMode, useColorModeChange };
|
|
296
|
+
export type { ColorModeChangeProps, ColorModeContextType, ColorModeProviderProps, ColorModeWrapper, CommonStackedChartProps, ComparisonResult, ComparisonTooltipProps, ContentFormatter, FormatNumberOptions, GenericSkeletonProps, LoadedStackedChartProps, PopoverProps, SkeletonStackedChartProps, StackedChartCategories, StackedChartCategory, StackedChartProps, StackedChartSegmentTooltipProps, StackedChartSkeletonProps, StackedChartSortOrder };
|
package/dist/esm/index.js
CHANGED
|
@@ -3,7 +3,12 @@ export { ColorModeChangeHandler } from './components/ColorModeChangeHandler/Colo
|
|
|
3
3
|
export { ColorModeProvider, useColorMode } from './components/ColorModeProvider/ColorModeProvider.js';
|
|
4
4
|
export { ComparisonBadge } from './components/ComparisonBadge/ComparisonBadge.js';
|
|
5
5
|
export { ComparisonTooltip } from './components/ComparisonTooltip/ComparisonTooltip.js';
|
|
6
|
+
export { GenericSkeleton } from './components/GenericSkeleton/GenericSkeleton.js';
|
|
6
7
|
export { Popover } from './components/Popover/Popover.js';
|
|
8
|
+
export { StackedChart } from './components/StackedChart/StackedChart.js';
|
|
9
|
+
export { StackedChartSegment } from './components/StackedChartSegment/StackedChartSegment.js';
|
|
10
|
+
export { StackedChartSegmentTooltip } from './components/StackedChartSegmentTooltip/StackedChartSegmentTooltip.js';
|
|
11
|
+
export { StackedChartSkeleton } from './components/StackedChartSkeleton/StackedChartSkeleton.js';
|
|
7
12
|
export { useColorModeChange } from './hooks/useColorModeChange.js';
|
|
8
13
|
export { calculateComparison } from './utils/comparison.js';
|
|
9
14
|
export { formatNumber } from './utils/formatters.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|