@modelform/react-native 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +103 -2
- package/dist/chunk-L4SQVIJV.js +10630 -0
- package/dist/chunk-PIHXMZ4G.mjs +10630 -0
- package/dist/core/configSchema.d.ts +29 -0
- package/dist/core/dashboardSettings.d.ts +34 -0
- package/dist/core/datasource.d.ts +61 -0
- package/dist/core/documents.d.ts +35 -0
- package/dist/core/editing.d.ts +129 -0
- package/dist/core/fieldconfig.d.ts +12 -0
- package/dist/core/format.d.ts +29 -0
- package/dist/core/frame.d.ts +51 -0
- package/dist/core/gazetteer.d.ts +25 -0
- package/dist/core/grafana.d.ts +85 -0
- package/dist/core/index.d.ts +27 -0
- package/dist/core/index.js +380 -0
- package/dist/core/index.mjs +380 -0
- package/dist/core/inputs.d.ts +99 -0
- package/dist/core/jsonEdit.d.ts +30 -0
- package/dist/core/layout.d.ts +49 -0
- package/dist/core/layoutEdit.d.ts +87 -0
- package/dist/core/links.d.ts +56 -0
- package/dist/core/local.d.ts +95 -0
- package/dist/core/manifest.d.ts +201 -0
- package/dist/core/mappings.d.ts +46 -0
- package/dist/core/navigation.d.ts +19 -0
- package/dist/core/panelOptions.d.ts +109 -0
- package/dist/core/reduce.d.ts +6 -0
- package/dist/core/resolveVariables.d.ts +38 -0
- package/dist/core/sample.d.ts +13 -0
- package/dist/core/schema.d.ts +202 -0
- package/dist/core/time.d.ts +66 -0
- package/dist/core/transform.d.ts +12 -0
- package/dist/core/variables.d.ts +76 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +4156 -0
- package/dist/index.mjs +4156 -0
- package/dist/ui/Chip.d.ts +5 -0
- package/dist/ui/DashboardView.d.ts +22 -0
- package/dist/ui/RenderBoundary.d.ts +25 -0
- package/dist/ui/TimeRangeSheet.d.ts +24 -0
- package/dist/ui/Toolbar.d.ts +6 -0
- package/dist/ui/chart.d.ts +69 -0
- package/dist/ui/context.d.ts +68 -0
- package/dist/ui/geomap.d.ts +157 -0
- package/dist/ui/inputs/InputForm.d.ts +36 -0
- package/dist/ui/inputs/InputPanels.d.ts +4 -0
- package/dist/ui/inputs/formContext.d.ts +14 -0
- package/dist/ui/links.d.ts +28 -0
- package/dist/ui/panels/GaugePanels.d.ts +5 -0
- package/dist/ui/panels/GeomapPanel.d.ts +6 -0
- package/dist/ui/panels/OtherPanels.d.ts +18 -0
- package/dist/ui/panels/StatPanel.d.ts +14 -0
- package/dist/ui/panels/TimeSeriesPanel.d.ts +8 -0
- package/dist/ui/panels/XYChartPanel.d.ts +6 -0
- package/dist/ui/panels/common.d.ts +78 -0
- package/dist/ui/panels/registry.d.ts +5 -0
- package/dist/ui/table.d.ts +62 -0
- package/dist/ui/theme.d.ts +21 -0
- package/dist/ui/xychart.d.ts +27 -0
- package/package.json +89 -3
- package/schema/app.schema.json +184 -0
- package/schema/dashboard.schema.json +940 -0
- package/tools/dashboards.js +90 -0
- package/tools/metro.js +21 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type LayoutMode } from '../core/layout';
|
|
3
|
+
import type { Panel } from '../core/schema';
|
|
4
|
+
export interface DashboardViewProps {
|
|
5
|
+
/** "auto" uses the phone layout below 700pt of usable width (e.g. phones in portrait) and the original grid above. */
|
|
6
|
+
mode?: LayoutMode | 'auto';
|
|
7
|
+
header?: ReactNode;
|
|
8
|
+
footer?: ReactNode;
|
|
9
|
+
/** Shows pull-to-refresh. Defaults to true when any panel has queries. */
|
|
10
|
+
refreshable?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Renders the dashboard from the nearest <DashboardProvider>. */
|
|
13
|
+
export declare function DashboardView({ mode, header, footer, refreshable }: DashboardViewProps): import("react").JSX.Element;
|
|
14
|
+
interface PanelCardProps {
|
|
15
|
+
panel: Panel;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
deferred?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** One panel in its card. A panel that fails to render shows why in its place; the rest of the dashboard carries on. */
|
|
21
|
+
export declare function PanelCard(props: PanelCardProps): import("react").JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Component, type ReactNode } from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Shown in place of the children after they throw while rendering. */
|
|
4
|
+
fallback(error: Error): ReactNode;
|
|
5
|
+
/** When any of these change (by identity), the children get another try, e.g. after the config is edited. */
|
|
6
|
+
resetKeys: readonly unknown[];
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
interface State {
|
|
10
|
+
error: Error | null;
|
|
11
|
+
keys: readonly unknown[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Keeps a render error in one part of the screen (a panel, a dashboard) from taking down the
|
|
15
|
+
* rest. Configs come from users at runtime, so anything the validator lets through has to
|
|
16
|
+
* fail here rather than crash the app.
|
|
17
|
+
*/
|
|
18
|
+
export declare class RenderBoundary extends Component<Props, State> {
|
|
19
|
+
state: State;
|
|
20
|
+
static getDerivedStateFromError(error: unknown): Partial<State>;
|
|
21
|
+
static getDerivedStateFromProps(props: Props, state: State): Partial<State> | null;
|
|
22
|
+
componentDidCatch(error: Error): void;
|
|
23
|
+
render(): ReactNode;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type Raw = {
|
|
2
|
+
from: string;
|
|
3
|
+
to: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Custom time range: From/To fields that take a date or a Grafana relative expression, a month
|
|
7
|
+
* calendar to fill them by tapping days, and more relative ranges than fit in the toolbar.
|
|
8
|
+
*/
|
|
9
|
+
export declare function TimeRangeSheet({ visible, value, onApply, onClose }: {
|
|
10
|
+
visible: boolean;
|
|
11
|
+
value: Raw;
|
|
12
|
+
onApply(r: Raw): void;
|
|
13
|
+
onClose(): void;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
/** A month of days to pick from; `from`..`to` are highlighted (pass the same day for one). */
|
|
16
|
+
export declare function Calendar({ month, onMonth, from, to, today, onPick, }: {
|
|
17
|
+
month: Date;
|
|
18
|
+
onMonth(d: Date): void;
|
|
19
|
+
from: number | null;
|
|
20
|
+
to: number | null;
|
|
21
|
+
today: number;
|
|
22
|
+
onPick(dayStart: number): void;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TIME_PRESETS } from '../core/time';
|
|
2
|
+
export { Chip } from './Chip';
|
|
3
|
+
/** Time range presets as a segmented control, a button for a custom range, and a filter button that opens the template variables in a sheet. */
|
|
4
|
+
export declare function DashboardToolbar({ presets }: {
|
|
5
|
+
presets?: typeof TIME_PRESETS;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type DataFrame, type Field, type Series } from '../core/frame';
|
|
2
|
+
import type { FieldConfig, MappingResult, Panel } from '../core/schema';
|
|
3
|
+
/** Clean tick values spanning [min, max]: 0 / 250 / 500 rather than 0 / 233 / 466. */
|
|
4
|
+
export declare function niceTicks(min: number, max: number, count?: number): number[];
|
|
5
|
+
/** Decimals needed so adjacent tick labels never collide (step 0.05 → 2). */
|
|
6
|
+
export declare function tickDecimals(ticks: number[]): number;
|
|
7
|
+
export declare function linearScale(d0: number, d1: number, r0: number, r1: number): (v: number) => number;
|
|
8
|
+
export declare function formatTimeTick(t: number, spanMs: number): string;
|
|
9
|
+
/** The field a bar chart groups by: `options.xField`, else the first string field, else the first time field. */
|
|
10
|
+
export declare function barCategory(panel: Panel, frame: DataFrame): Field | undefined;
|
|
11
|
+
/** Bar chart category labels. Times are dates, or times of day when the bars are less than a day apart. */
|
|
12
|
+
export declare function categoryLabels(field: Field): string[];
|
|
13
|
+
export interface BarAxis {
|
|
14
|
+
side: 'left' | 'right';
|
|
15
|
+
/** Indexes of the fields scaled against this axis. */
|
|
16
|
+
fields: number[];
|
|
17
|
+
ticks: number[];
|
|
18
|
+
/** The value at the top of the plot. */
|
|
19
|
+
top: number;
|
|
20
|
+
/** The value at the bottom of the plot: 0 unless a value or `min` is negative, or `min` raises it. */
|
|
21
|
+
bottom: number;
|
|
22
|
+
/** Config of the axis's first field, for tick formatting. */
|
|
23
|
+
config: FieldConfig;
|
|
24
|
+
/** `custom.axisLabel` of the axis's first field that has one. */
|
|
25
|
+
label?: string;
|
|
26
|
+
/** False when every field on the axis has `custom.axisPlacement: "hidden"`. */
|
|
27
|
+
show: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Bar chart y axes. Fields with `custom.axisPlacement: "right"` share a right axis with its own scale; every other
|
|
31
|
+
* field shares the left one. Each axis runs from 0 (or min) to a round number above its tallest bar (or max).
|
|
32
|
+
*/
|
|
33
|
+
export declare function barAxes(configs: FieldConfig[], values: (number | null)[][], tickCount: number): BarAxis[];
|
|
34
|
+
export declare function formatTooltipTime(t: number): string;
|
|
35
|
+
export interface StyledSeries extends Series {
|
|
36
|
+
color: string;
|
|
37
|
+
config: FieldConfig;
|
|
38
|
+
}
|
|
39
|
+
/** Time series with resolved config and colors in fixed palette order. */
|
|
40
|
+
export declare function styledSeries(panel: Panel, frames: DataFrame[], scheme: 'light' | 'dark'): StyledSeries[];
|
|
41
|
+
/** Series against the panel's numeric x field (`options.xField`), with that field's resolved config for axis labels. */
|
|
42
|
+
export declare function styledXYSeries(panel: Panel, frames: DataFrame[], scheme: 'light' | 'dark'): {
|
|
43
|
+
series: StyledSeries[];
|
|
44
|
+
xConfig: FieldConfig;
|
|
45
|
+
};
|
|
46
|
+
export interface ReducedValue {
|
|
47
|
+
key: string;
|
|
48
|
+
name: string;
|
|
49
|
+
value: number | null;
|
|
50
|
+
config: FieldConfig;
|
|
51
|
+
/** Series color (palette or fixed). */
|
|
52
|
+
color: string;
|
|
53
|
+
/** The value as shown: its value mapping's text, else formatted with the field's unit. */
|
|
54
|
+
text: string;
|
|
55
|
+
/** The value mapping that matched, if any. */
|
|
56
|
+
mapped?: MappingResult;
|
|
57
|
+
/** A matching value mapping's color, else the threshold color when thresholds are configured, else the series color. */
|
|
58
|
+
stateColor: string;
|
|
59
|
+
sparkline: (number | null)[];
|
|
60
|
+
/** Where the value came from, for data links. */
|
|
61
|
+
field: Field;
|
|
62
|
+
frame: DataFrame;
|
|
63
|
+
}
|
|
64
|
+
/** One value per numeric field, reduced with the panel's reduceOptions.calcs. Used by stat/gauge/bargauge/pie. */
|
|
65
|
+
export declare function reducedValues(panel: Panel, frames: DataFrame[], scheme: 'light' | 'dark'): ReducedValue[];
|
|
66
|
+
/** y-domain from config min/max, falling back to the data (including 0 for bars). */
|
|
67
|
+
export declare function yDomain(series: StyledSeries[], includeZero: boolean): [number, number];
|
|
68
|
+
/** Where a value sits on a bar axis, from 0 (bottom of the plot) to 1 (top). */
|
|
69
|
+
export declare function barFraction(axis: Pick<BarAxis, 'top' | 'bottom'>, v: number): number;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { DataSourceResolver } from '../core/datasource';
|
|
3
|
+
import type { DataFrame } from '../core/frame';
|
|
4
|
+
import { type LinkData, type ResolvedLink } from '../core/links';
|
|
5
|
+
import type { Dashboard, DataLink, Panel } from '../core/schema';
|
|
6
|
+
import { type TimeRange } from '../core/time';
|
|
7
|
+
import { type VariableInfo, type VariableValues } from '../core/variables';
|
|
8
|
+
interface DashboardState {
|
|
9
|
+
dashboard: Dashboard;
|
|
10
|
+
resolve?: DataSourceResolver;
|
|
11
|
+
rawRange: {
|
|
12
|
+
from: string;
|
|
13
|
+
to: string;
|
|
14
|
+
};
|
|
15
|
+
setRawRange(r: {
|
|
16
|
+
from: string;
|
|
17
|
+
to: string;
|
|
18
|
+
}): void;
|
|
19
|
+
/** Re-evaluated on every refresh so "now" moves forward. */
|
|
20
|
+
range: TimeRange;
|
|
21
|
+
variables: VariableValues;
|
|
22
|
+
/** Options and multi/All settings per variable, with query variables' options as last resolved. */
|
|
23
|
+
variableInfo: Record<string, VariableInfo>;
|
|
24
|
+
/** Query variables whose last refresh failed, by name. */
|
|
25
|
+
variableErrors: Record<string, string>;
|
|
26
|
+
/** False while query variables are being re-run; panels wait for it so they never query with stale values. */
|
|
27
|
+
variablesReady: boolean;
|
|
28
|
+
setVariable(name: string, value: string | string[]): void;
|
|
29
|
+
refresh(): void;
|
|
30
|
+
refreshKey: number;
|
|
31
|
+
/** Results that `-- Dashboard --` panels reuse; a new map whenever the range or variables change. */
|
|
32
|
+
shared: Map<string, Promise<DataFrame[]>>;
|
|
33
|
+
/** Open a single link straight away, or offer a choice of several. */
|
|
34
|
+
openLinks(links: ResolvedLink[], title?: string): void;
|
|
35
|
+
/** The one panel whose tooltip is pinned open (showing its links), so pinning another closes it. */
|
|
36
|
+
pinned: string | null;
|
|
37
|
+
setPinned(id: string | null): void;
|
|
38
|
+
}
|
|
39
|
+
export interface DashboardProviderProps {
|
|
40
|
+
dashboard: Dashboard;
|
|
41
|
+
/** Required to render data panels; input-only forms can omit it. */
|
|
42
|
+
resolve?: DataSourceResolver;
|
|
43
|
+
/** Bump to force all panels to re-query (e.g. after the local store changes). */
|
|
44
|
+
refreshKey?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Called to open a data or panel link, e.g. to show a linked Grafana dashboard in the app
|
|
47
|
+
* (see parseDashboardLink). Without it, links open with React Native's Linking.
|
|
48
|
+
*/
|
|
49
|
+
onLink?: (link: ResolvedLink) => void;
|
|
50
|
+
children: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
export declare function DashboardProvider({ dashboard, resolve, refreshKey: externalKey, onLink, children }: DashboardProviderProps): import("react").JSX.Element;
|
|
53
|
+
export declare function useDashboard(): DashboardState;
|
|
54
|
+
export interface PanelData {
|
|
55
|
+
frames: DataFrame[];
|
|
56
|
+
loading: boolean;
|
|
57
|
+
error?: string;
|
|
58
|
+
}
|
|
59
|
+
export declare function usePanelData(panel: Panel, widthPx: number, enabled?: boolean): PanelData;
|
|
60
|
+
/**
|
|
61
|
+
* Resolve a panel's data links (or, without `data`, its panel links) against the dashboard's
|
|
62
|
+
* current variables and time range.
|
|
63
|
+
*/
|
|
64
|
+
export declare function usePanelLinks(panel: Panel): {
|
|
65
|
+
resolve: (links: DataLink[] | undefined, data?: LinkData) => ResolvedLink[];
|
|
66
|
+
openLinks: (links: ResolvedLink[], title?: string) => void;
|
|
67
|
+
};
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { type DataFrame } from '../core/frame';
|
|
2
|
+
import { type Gazetteer } from '../core/gazetteer';
|
|
3
|
+
import type { Panel } from '../core/schema';
|
|
4
|
+
/** Tile edge in px. Zoom z shows the world 256 · 2^z px wide, as in OpenLayers (which Grafana uses). */
|
|
5
|
+
export declare const TILE = 256;
|
|
6
|
+
/** Web Mercator: degrees to world coordinates, both in [0, 1] with y growing south. */
|
|
7
|
+
export declare function project(lon: number, lat: number): [number, number];
|
|
8
|
+
export declare function unproject(x: number, y: number): {
|
|
9
|
+
lon: number;
|
|
10
|
+
lat: number;
|
|
11
|
+
};
|
|
12
|
+
export interface TileSource {
|
|
13
|
+
url: (z: number, x: number, y: number) => string;
|
|
14
|
+
/** Deepest zoom the server has tiles for; closer views scale those up. */
|
|
15
|
+
maxZoom: number;
|
|
16
|
+
attribution: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Tiles for one of Grafana's raster layer types. `default` (and anything modelform can't draw, such as vector
|
|
20
|
+
* `maplibre` styles) is CARTO, Grafana's own default basemap. `retina` asks CARTO for 512px tiles.
|
|
21
|
+
*/
|
|
22
|
+
export declare function tileSource(layer: {
|
|
23
|
+
type?: string;
|
|
24
|
+
config?: Record<string, any>;
|
|
25
|
+
} | undefined, scheme: 'light' | 'dark', retina?: boolean): TileSource;
|
|
26
|
+
/** One tile to draw, positioned in panel px. */
|
|
27
|
+
export interface PlacedTile {
|
|
28
|
+
key: string;
|
|
29
|
+
url: string;
|
|
30
|
+
left: number;
|
|
31
|
+
top: number;
|
|
32
|
+
size: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The tiles covering a width × height panel centred on `view`. Tiles come from the nearest whole zoom (never past
|
|
36
|
+
* the source's max) and are scaled to the fractional zoom; they repeat sideways when the world is narrower than the panel.
|
|
37
|
+
*/
|
|
38
|
+
export declare function visibleTiles(source: TileSource, view: MapView, width: number, height: number): PlacedTile[];
|
|
39
|
+
export interface MapView {
|
|
40
|
+
lon: number;
|
|
41
|
+
lat: number;
|
|
42
|
+
zoom: number;
|
|
43
|
+
}
|
|
44
|
+
export declare function zoomLimits(panel: Panel): [number, number];
|
|
45
|
+
/**
|
|
46
|
+
* Where the map starts, from `options.view`: fixed coordinates, a named region, or `fit` to the data (padded by
|
|
47
|
+
* `padding` percent and no closer than the saved zoom). Fit uses every data layer unless `allLayers` is false,
|
|
48
|
+
* then only the layer named `layer`; `lastOnly` fits the last point of each frame.
|
|
49
|
+
*/
|
|
50
|
+
export declare function initialView(panel: Panel, layers: GeoLayer[], width: number, height: number): MapView;
|
|
51
|
+
/** Located rows of one frame, with per-point styling. Arrays are parallel to `rows`. */
|
|
52
|
+
export interface GeoPoints {
|
|
53
|
+
frame: DataFrame;
|
|
54
|
+
rows: number[];
|
|
55
|
+
/** World coordinates (see project). */
|
|
56
|
+
xs: number[];
|
|
57
|
+
ys: number[];
|
|
58
|
+
colors: string[];
|
|
59
|
+
/** Marker radius (markers), or heatmap weight. */
|
|
60
|
+
sizes: number[];
|
|
61
|
+
labels?: string[];
|
|
62
|
+
}
|
|
63
|
+
export type MarkerSymbol = 'circle' | 'square' | 'triangle' | 'star' | 'cross' | 'x';
|
|
64
|
+
export interface LegendEntry {
|
|
65
|
+
key: string;
|
|
66
|
+
name: string;
|
|
67
|
+
color: string;
|
|
68
|
+
}
|
|
69
|
+
interface LayerBase {
|
|
70
|
+
key: string;
|
|
71
|
+
name: string;
|
|
72
|
+
/** The whole layer's opacity. */
|
|
73
|
+
opacity: number;
|
|
74
|
+
}
|
|
75
|
+
export interface MarkersLayer extends LayerBase {
|
|
76
|
+
type: 'markers';
|
|
77
|
+
points: GeoPoints[];
|
|
78
|
+
symbol: MarkerSymbol;
|
|
79
|
+
fillOpacity: number;
|
|
80
|
+
fontSize: number;
|
|
81
|
+
labelOffset: [number, number];
|
|
82
|
+
tooltip: boolean;
|
|
83
|
+
legend: LegendEntry[];
|
|
84
|
+
}
|
|
85
|
+
export interface RouteLayer extends LayerBase {
|
|
86
|
+
type: 'route';
|
|
87
|
+
points: GeoPoints[];
|
|
88
|
+
lineWidth: number;
|
|
89
|
+
tooltip: boolean;
|
|
90
|
+
legend: LegendEntry[];
|
|
91
|
+
}
|
|
92
|
+
export interface HeatmapLayer extends LayerBase {
|
|
93
|
+
type: 'heatmap';
|
|
94
|
+
points: GeoPoints[];
|
|
95
|
+
radius: number;
|
|
96
|
+
blur: number;
|
|
97
|
+
tooltip: false;
|
|
98
|
+
}
|
|
99
|
+
export interface TilesLayer extends LayerBase {
|
|
100
|
+
type: 'tiles';
|
|
101
|
+
source: TileSource;
|
|
102
|
+
}
|
|
103
|
+
export type DataLayer = MarkersLayer | RouteLayer | HeatmapLayer;
|
|
104
|
+
export type GeoLayer = DataLayer | TilesLayer;
|
|
105
|
+
interface Location {
|
|
106
|
+
mode?: string;
|
|
107
|
+
latitude?: string;
|
|
108
|
+
longitude?: string;
|
|
109
|
+
geohash?: string;
|
|
110
|
+
lookup?: string;
|
|
111
|
+
/** Lookup mode: the gazetteer's path on the Grafana server, or a URL. */
|
|
112
|
+
gazetteer?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The basemap and data layers of a geomap panel, bottom first. Data layers are `markers`, `heatmap`, `route` and
|
|
116
|
+
* `lastPointTracker`; raster layers (`xyz`, `carto`, …) draw over the basemap. Other layer types (geojson,
|
|
117
|
+
* photos, day/night, …) are skipped. Lookup layers find places in `gazetteers`, keyed by path.
|
|
118
|
+
*/
|
|
119
|
+
export declare function geomapLayers(panel: Panel, frames: DataFrame[], scheme: 'light' | 'dark', retina?: boolean, gazetteers?: Record<string, Gazetteer>): GeoLayer[];
|
|
120
|
+
/**
|
|
121
|
+
* The gazetteers a panel's layers need: the one each lookup layer names (countries by default), and the default
|
|
122
|
+
* for auto layers when a frame has a field called "lookup". Load these and pass them to geomapLayers.
|
|
123
|
+
*/
|
|
124
|
+
export declare function gazetteerPaths(panel: Panel, frames: DataFrame[]): string[];
|
|
125
|
+
/**
|
|
126
|
+
* Rows of a frame that have a location, as world coordinates. `coords` reads named latitude/longitude fields,
|
|
127
|
+
* `geohash` decodes a geohash field, and `auto` (the default) looks for fields called lat/latitude and
|
|
128
|
+
* lon/lng/long/longitude, else geohash, else a field called "lookup". `lookup` finds each row's value of the
|
|
129
|
+
* `lookup` field in a gazetteer from `gazetteers` (by path, see gazetteerPaths); rows it doesn't know are skipped.
|
|
130
|
+
*/
|
|
131
|
+
export declare function locate(frame: DataFrame, location?: Location, gazetteers?: Record<string, Gazetteer>): {
|
|
132
|
+
rows: number[];
|
|
133
|
+
xs: number[];
|
|
134
|
+
ys: number[];
|
|
135
|
+
} | undefined;
|
|
136
|
+
/** The centre of a geohash cell. */
|
|
137
|
+
export declare function decodeGeohash(hash: string): {
|
|
138
|
+
lon: number;
|
|
139
|
+
lat: number;
|
|
140
|
+
} | undefined;
|
|
141
|
+
/** Panel px of world coordinates, using the copy of the world nearest the centre. */
|
|
142
|
+
export declare function screenProjector(view: MapView, width: number, height: number): (x: number, y: number) => [number, number];
|
|
143
|
+
/** The view after dragging the map by (dx, dy) px. */
|
|
144
|
+
export declare function panView(view: MapView, dx: number, dy: number): MapView;
|
|
145
|
+
/** SVG path of a marker centred on (x, y) with radius r. */
|
|
146
|
+
export declare function symbolPath(symbol: MarkerSymbol, x: number, y: number, r: number): string;
|
|
147
|
+
/**
|
|
148
|
+
* A heatmap as OpenLayers draws it: each point is a disc of `radius` px blurred by `blur` px with its weight as
|
|
149
|
+
* alpha, the alphas composite, and the total picks a color from blue to red. Computed on a grid of `cell` px
|
|
150
|
+
* squares and returned as one path per color level, so thousands of points stay a handful of SVG elements.
|
|
151
|
+
*/
|
|
152
|
+
export declare function heatmapCells(px: number[], py: number[], weights: number[], radius: number, blur: number, width: number, height: number, cell?: number): {
|
|
153
|
+
color: string;
|
|
154
|
+
opacity: number;
|
|
155
|
+
d: string;
|
|
156
|
+
}[];
|
|
157
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type Entry, type InputChoice, type InputValue, type NewEntry } from '../../core/inputs';
|
|
3
|
+
import type { EntryStore } from '../../core/local';
|
|
4
|
+
import type { Dashboard } from '../../core/schema';
|
|
5
|
+
export interface InputFormProps {
|
|
6
|
+
dashboard: Dashboard;
|
|
7
|
+
store: EntryStore;
|
|
8
|
+
/** Called after Save with the entries just recorded. */
|
|
9
|
+
onSaved?(count: number, entries: Entry[]): void;
|
|
10
|
+
/** Choice lists for input-select panels that set `choicesFrom`, keyed by that name. */
|
|
11
|
+
choices?: Record<string, InputChoice[]>;
|
|
12
|
+
/** Shown above the panels in place of the "Recording for" time picker. */
|
|
13
|
+
header?: ReactNode;
|
|
14
|
+
/** With `header`: the time to record a Save at (default now). */
|
|
15
|
+
timestamp?(): number;
|
|
16
|
+
/** Initial values supplied by the app, keyed by metric. They take the place of the panels' own `default`. */
|
|
17
|
+
defaults?: Record<string, InputValue>;
|
|
18
|
+
/**
|
|
19
|
+
* Called on Save before anything is recorded, with the time it will be recorded at.
|
|
20
|
+
* Resolve with entries to record alongside the form's (e.g. asked for in a dialog), or
|
|
21
|
+
* null to cancel the save and keep the edits.
|
|
22
|
+
*/
|
|
23
|
+
beforeSave?(ts: number): Promise<NewEntry[] | null>;
|
|
24
|
+
/**
|
|
25
|
+
* The entries of an earlier Save, to edit it. The form starts from their values (inputs
|
|
26
|
+
* without one start empty, not from defaults), and Save records every input again at
|
|
27
|
+
* their timestamp in place of them.
|
|
28
|
+
*/
|
|
29
|
+
editing?: Entry[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A data entry form laid out from dashboard JSON with input-* panels. Edited values are
|
|
33
|
+
* staged until Save, then recorded together at the chosen timestamp, along with any
|
|
34
|
+
* `record: "always"` inputs. Counters record immediately on tap.
|
|
35
|
+
*/
|
|
36
|
+
export declare function InputForm({ dashboard, store, onSaved, choices, header, timestamp, defaults: given, beforeSave, editing }: InputFormProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InputChoice, InputValue } from '../../core/inputs';
|
|
2
|
+
import type { EntryStore } from '../../core/local';
|
|
3
|
+
export interface InputFormState {
|
|
4
|
+
value(metric: string): InputValue;
|
|
5
|
+
setValue(metric: string, v: InputValue): void;
|
|
6
|
+
isDirty(metric: string): boolean;
|
|
7
|
+
store: EntryStore;
|
|
8
|
+
/** Runtime choice lists for input-select panels with `choicesFrom`. */
|
|
9
|
+
choices: Record<string, InputChoice[]>;
|
|
10
|
+
/** Why the input's value can't be saved, once that's worth showing. */
|
|
11
|
+
problem?(metric: string): string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare const InputFormContext: import("react").Context<InputFormState | null>;
|
|
14
|
+
export declare function useInputForm(): InputFormState;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ResolvedLink } from '../core/links';
|
|
2
|
+
/** Without an `onLink` handler, hand the URL to the OS. Relative URLs have nowhere to go, so they're skipped. */
|
|
3
|
+
export declare function openLinkDefault(link: ResolvedLink): void;
|
|
4
|
+
/**
|
|
5
|
+
* Links from several series in one tooltip, each once. Where series share a link title but
|
|
6
|
+
* point at different places, the series name tells them apart.
|
|
7
|
+
*/
|
|
8
|
+
export declare function mergeLinks(groups: {
|
|
9
|
+
name: string;
|
|
10
|
+
links: ResolvedLink[];
|
|
11
|
+
}[]): ResolvedLink[];
|
|
12
|
+
export declare const LinkIcon: ({ color, size }: {
|
|
13
|
+
color: string;
|
|
14
|
+
size?: number;
|
|
15
|
+
}) => import("react").JSX.Element;
|
|
16
|
+
/** Link rows at the bottom of a pinned tooltip. */
|
|
17
|
+
export declare function TooltipLinks({ links, onOpen }: {
|
|
18
|
+
links: ResolvedLink[];
|
|
19
|
+
onOpen(l: ResolvedLink): void;
|
|
20
|
+
}): import("react").JSX.Element | null;
|
|
21
|
+
/** A bottom sheet to choose between several links. */
|
|
22
|
+
export declare function LinkMenu({ links, title, visible, onOpen, onClose, }: {
|
|
23
|
+
links: ResolvedLink[];
|
|
24
|
+
title?: string;
|
|
25
|
+
visible: boolean;
|
|
26
|
+
onOpen(l: ResolvedLink): void;
|
|
27
|
+
onClose(): void;
|
|
28
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type PanelProps } from './common';
|
|
2
|
+
/** Grafana "gauge": an arc per series, filled to the value and colored by threshold. */
|
|
3
|
+
export declare function GaugePanel({ panel, frames }: PanelProps): import("react").JSX.Element;
|
|
4
|
+
/** Grafana "bargauge": one horizontal meter per series. The track is a lighter step of the fill. */
|
|
5
|
+
export declare function BarGaugePanel({ panel, frames }: PanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PanelProps } from './common';
|
|
2
|
+
/**
|
|
3
|
+
* Grafana "geomap": a basemap of raster tiles with markers, heatmap, route and last-point layers drawn over it.
|
|
4
|
+
* Drag to pan, pinch or use +/− to zoom, tap a point to see its row.
|
|
5
|
+
*/
|
|
6
|
+
export declare function GeomapPanel({ panel, frames }: PanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type PanelProps } from './common';
|
|
2
|
+
/** Grafana "piechart": a donut of reduced values. Legend always shows values, so identity never rests on color. */
|
|
3
|
+
export declare function PieChartPanel({ panel, frames }: PanelProps): import("react").JSX.Element;
|
|
4
|
+
/**
|
|
5
|
+
* Grafana "table". Each column follows its field config: display name, width, alignment, unit, decimals, value
|
|
6
|
+
* mappings and `noValue`; `custom.hidden` columns are left out. Cells can be colored text, colored backgrounds
|
|
7
|
+
* (optionally the whole row) or gauges.
|
|
8
|
+
*/
|
|
9
|
+
export declare function TablePanel({ panel, frames }: PanelProps): import("react").JSX.Element;
|
|
10
|
+
/** Grafana "text": markdown is rendered as plain paragraphs with headings and bold stripped to weight. */
|
|
11
|
+
export declare function TextPanel({ panel }: PanelProps): import("react").JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* Grafana "barchart": one group of bars per category, one bar per numeric field. Categories come from `xField`,
|
|
14
|
+
* else the first string field, else the first time field, as in Grafana. Fields placed on the right axis
|
|
15
|
+
* (`custom.axisPlacement: "right"`) get their own scale there.
|
|
16
|
+
*/
|
|
17
|
+
export declare function BarChartPanel({ panel, frames, width }: PanelProps): import("react").JSX.Element;
|
|
18
|
+
export declare function UnsupportedPanel({ panel }: PanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PanelProps } from './common';
|
|
2
|
+
/**
|
|
3
|
+
* Grafana "stat": one big number per series. Threshold color is shown as an accent bar
|
|
4
|
+
* (and a tinted background in colorMode "background") rather than on the text itself,
|
|
5
|
+
* so the value stays legible whatever the threshold color is.
|
|
6
|
+
*/
|
|
7
|
+
export declare function StatPanel({ panel, frames }: PanelProps): import("react").JSX.Element;
|
|
8
|
+
export declare function Sparkline({ values, width, height, color }: {
|
|
9
|
+
values: (number | null)[];
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
color: string;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
export declare function withAlpha(hex: string, alpha: number): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PanelProps } from './common';
|
|
2
|
+
/**
|
|
3
|
+
* Grafana "timeseries" (and legacy "graph") panels: lines, points, bars and area fills.
|
|
4
|
+
* Also "trend" panels, which are the same chart against a numeric x field (`options.xField`).
|
|
5
|
+
* Pinching a time axis previews the zoomed range locally, then sets the dashboard's range on release.
|
|
6
|
+
* Pinching a trend's numeric axis zooms just that chart, until "Reset zoom".
|
|
7
|
+
*/
|
|
8
|
+
export declare function TimeSeriesPanel({ panel, frames }: PanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PanelProps } from './common';
|
|
2
|
+
/**
|
|
3
|
+
* Grafana "xychart": points (and/or lines) of one numeric field against another, optionally colored and sized
|
|
4
|
+
* by further fields. Touch a point to see its row.
|
|
5
|
+
*/
|
|
6
|
+
export declare function XYChartPanel({ panel, frames }: PanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type LayoutChangeEvent } from 'react-native';
|
|
2
|
+
import { type DataFrame } from '../../core/frame';
|
|
3
|
+
import type { LinkData, ResolvedLink } from '../../core/links';
|
|
4
|
+
import type { DataLink, FieldConfig, Panel } from '../../core/schema';
|
|
5
|
+
import { type ReducedValue } from '../chart';
|
|
6
|
+
export interface PanelProps {
|
|
7
|
+
panel: Panel;
|
|
8
|
+
frames: DataFrame[];
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function useLayout(): [{
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}, (e: LayoutChangeEvent) => void];
|
|
16
|
+
export declare function Legend({ items }: {
|
|
17
|
+
items: {
|
|
18
|
+
key: string;
|
|
19
|
+
name: string;
|
|
20
|
+
color: string;
|
|
21
|
+
value?: string;
|
|
22
|
+
}[];
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
/** Room an axis title takes beside the left axis or below the x tick labels. */
|
|
25
|
+
export declare const AXIS_TITLE_SPACE = 14;
|
|
26
|
+
/** A field's `custom.axisLabel`, if it has a non-empty one. */
|
|
27
|
+
export declare const axisTitle: (config: FieldConfig | undefined) => string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Axis titles for an SVG chart, as Grafana draws them: the y title turned to read upwards along the left edge,
|
|
30
|
+
* the x title centred under the tick labels. `plot` is the plotting area inside the padding.
|
|
31
|
+
*/
|
|
32
|
+
export declare function AxisTitles({ x, y, plot, height }: {
|
|
33
|
+
x?: string;
|
|
34
|
+
y?: string;
|
|
35
|
+
plot: {
|
|
36
|
+
left: number;
|
|
37
|
+
top: number;
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
};
|
|
41
|
+
height: number;
|
|
42
|
+
}): import("react").JSX.Element;
|
|
43
|
+
export declare function NoData({ message }: {
|
|
44
|
+
message?: string;
|
|
45
|
+
}): import("react").JSX.Element;
|
|
46
|
+
/** Every field of a row, as Grafana's single-point tooltip shows it, except fields hidden from tooltips. */
|
|
47
|
+
export declare function rowTooltipItems(panel: Panel, frame: DataFrame, row: number, multiple: boolean): {
|
|
48
|
+
name: string;
|
|
49
|
+
value: string;
|
|
50
|
+
}[];
|
|
51
|
+
/** Data links of every field in a row, each resolved against that field and row. */
|
|
52
|
+
export declare function rowLinks(panel: Panel, frame: DataFrame, row: number, multiple: boolean, resolve: (links: DataLink[] | undefined, data?: LinkData) => ResolvedLink[]): ResolvedLink[];
|
|
53
|
+
/** Data links of a stat, gauge or bar gauge value. */
|
|
54
|
+
export declare function valueLinks(panel: Panel, v: ReducedValue, resolve: (links: DataLink[] | undefined, data?: LinkData) => ResolvedLink[]): ResolvedLink[];
|
|
55
|
+
/**
|
|
56
|
+
* A tooltip beside the point `at` (panel px), on whichever side has more room in a panel of `size`:
|
|
57
|
+
* a colored dot and title, then name/value rows.
|
|
58
|
+
*/
|
|
59
|
+
export declare function RowTooltip({ at, size, color, title, rows, links, onOpenLink, }: {
|
|
60
|
+
at: {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
};
|
|
64
|
+
size: {
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
};
|
|
68
|
+
color: string;
|
|
69
|
+
title: string;
|
|
70
|
+
rows: {
|
|
71
|
+
name: string;
|
|
72
|
+
value: string;
|
|
73
|
+
}[];
|
|
74
|
+
/** Shown, and tappable, when the tooltip is pinned. */
|
|
75
|
+
links?: ResolvedLink[];
|
|
76
|
+
onOpenLink?(l: ResolvedLink): void;
|
|
77
|
+
}): import("react").JSX.Element;
|
|
78
|
+
export declare const showLegend: (panel: Panel, seriesCount: number) => boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { PanelProps } from './common';
|
|
3
|
+
/** Add or replace a panel type, e.g. registerPanel('my-heatmap', HeatmapPanel). */
|
|
4
|
+
export declare function registerPanel(type: string, component: ComponentType<PanelProps>): void;
|
|
5
|
+
export declare function panelComponent(type: string): ComponentType<PanelProps>;
|