import { SceneDataQuery, SceneQueryRunner, CustomTransformerDefinition, SceneDataProvider, SceneDataTransformer, SceneObjectBase, SceneObjectState, SceneObject, SceneVariable, SceneTimeRangeState, VizConfig, VizPanelMenu, VizPanel as VizPanel$1, VariableValueSingle, QueryVariable as QueryVariable$1, EmbeddedScene, EmbeddedSceneState, SceneComponentProps, SceneTimeRangeLike } from '@grafana/scenes'; import type { ControlsLayout, VariableValue, AdHocFilterWithLabels, SceneFlexItemPlacement } from '@grafana/scenes'; import { DataTransformerConfig, VariableHide, VariableRefresh, VariableSort } from '@grafana/schema'; import type { DataSourceRef } from '@grafana/schema'; import React from 'react'; import { PanelContext } from '@grafana/ui'; import { NavModelItem, AnnotationQuery, TimeRange } from '@grafana/data'; import type { MetricFindValue, AdHocVariableFilter } from '@grafana/data'; type CacheKey = CacheKeyPart | CacheKeyPart[]; type CacheKeyPart = string | number | object | boolean; interface UseQueryOptions { queries: SceneDataQuery[]; maxDataPoints?: number; datasource?: DataSourceRef; cacheKey?: CacheKey; liveStreaming?: boolean; maxDataPointsFromWidth?: boolean; minInterval?: string; /** * Optional prefix for the requestId. When set, request IDs will be formatted as `{requestIdPrefix}{counter}`. * Useful for identifying requests from specific panels or components. */ requestIdPrefix?: string; } /** * Maintains the state of SceneQueryRunner in the scene * * @example // To access query results do * const query = useQueryRunner(...); * const { data } = query.useState(); */ declare function useQueryRunner(options: UseQueryOptions): SceneQueryRunner; interface UseDataTransformerOptions { transformations: Array; data: SceneDataProvider; } declare function useDataTransformer(options: UseDataTransformerOptions): SceneDataTransformer; interface SceneContextObjectState extends SceneObjectState { childContexts?: SceneContextObject[]; children: SceneObject[]; } declare class SceneContextObject extends SceneObjectBase { constructor(state?: Partial); addToScene(obj: SceneObject): () => void; findByKey(key: string): T | undefined; findVariable(name: string): T | undefined; addVariable(variable: SceneVariable): () => void; addChildContext(ctx: SceneContextObject): void; removeChildContext(ctx: SceneContextObject): void; } declare const SceneContext: React.Context; interface SceneContextProviderProps { /** * Only the initial time range, cannot be used to update time range **/ timeRange?: Partial; /** * This makes it possbile to view running state of queries via * refresh picker and also cancel all queries in the scene. */ withQueryController?: boolean; /** * Children */ children: React.ReactNode; } /** * Wrapps the react children in a SceneContext */ declare function SceneContextProvider({ children, timeRange, withQueryController }: SceneContextProviderProps): React.JSX.Element | null; interface Props$4 { } declare function TimeRangePicker(props: Props$4): React.JSX.Element; interface Props$3 { name: string; hideLabel?: boolean; layout?: ControlsLayout; } declare function VariableControl({ name, hideLabel, layout }: Props$3): React.JSX.Element; interface VizPanelProps { title: string; description?: string; dataProvider?: SceneDataProvider; viz: VizConfig; displayMode?: 'default' | 'transparent'; hoverHeader?: boolean; hoverHeaderOffset?: number; menu?: VizPanelMenu; titleItems?: React.ReactNode; seriesLimit?: number; seriesLimitShowAll?: boolean; headerActions?: React.ReactNode; extendPanelContext?: (vizPanel: VizPanel$1, context: PanelContext) => void; collapsible?: boolean; collapsed?: boolean; } declare function VizPanel(props: VizPanelProps): React.JSX.Element; interface Props$2 { refresh?: string; withText?: boolean; } declare function RefreshPicker(props: Props$2): React.JSX.Element; interface Props$1 { name: string; } declare function DataLayerControl({ name }: Props$1): React.JSX.Element; interface VariableProps { name: string; label?: string; hide?: VariableHide; initialValue?: VariableValue; skipUrlSync?: boolean; allValue?: string; } interface CustomVariableProps extends VariableProps { query: string; isMulti?: boolean; includeAll?: boolean; children: React.ReactNode; } declare function CustomVariable({ query, name, label, hide, initialValue, isMulti, includeAll, skipUrlSync, allValue, children, }: CustomVariableProps): React.ReactNode; interface AdHocFiltersVariableProps extends VariableProps { datasource?: DataSourceRef | null; filters?: AdHocFilterWithLabels[]; baseFilters?: AdHocFilterWithLabels[]; originFilters?: AdHocFilterWithLabels[]; readOnly?: boolean; layout?: ControlsLayout | 'combobox'; addFilterButtonText?: string; tagKeyRegexFilter?: RegExp; defaultKeys?: MetricFindValue[]; filterExpression?: string; expressionBuilder?: (filters: AdHocFilterWithLabels[]) => string; getTagKeysProvider?: any; getTagValuesProvider?: any; supportsMultiValueOperators?: boolean; useQueriesAsFilterForOptions?: boolean; allowCustomValue?: boolean; onAddCustomValue?: any; collapsible?: boolean; drilldownRecommendationsEnabled?: boolean; /** * `applyMode` is only used during variable construction. * If you need to change it, remount this component. */ applyMode?: 'auto' | 'manual'; children: React.ReactNode; } declare function AdHocFiltersVariable({ name, label, hide, skipUrlSync, children, datasource, filters, baseFilters, originFilters, readOnly, layout, addFilterButtonText, tagKeyRegexFilter, defaultKeys, filterExpression, expressionBuilder, getTagKeysProvider, getTagValuesProvider, supportsMultiValueOperators, useQueriesAsFilterForOptions, allowCustomValue, onAddCustomValue, collapsible, drilldownRecommendationsEnabled, applyMode, }: AdHocFiltersVariableProps): React.ReactNode; interface DataSourceVariableProps extends VariableProps { pluginId: string; regex?: string; refresh?: VariableRefresh; sort?: VariableSort; isMulti?: boolean; includeAll?: boolean; children: React.ReactNode; } declare function DataSourceVariable({ pluginId, regex, name, label, hide, initialValue, isMulti, includeAll, skipUrlSync, allValue, children, }: DataSourceVariableProps): React.ReactNode; interface QueryVariableProps extends VariableProps { query: string | SceneDataQuery; datasource: DataSourceRef | null; regex?: string; refresh?: VariableRefresh; sort?: VariableSort; isMulti?: boolean; includeAll?: boolean; children: React.ReactNode; } declare function QueryVariable({ query, name, datasource, label, hide, regex, refresh, sort, initialValue, isMulti, includeAll, skipUrlSync, allValue, children, }: QueryVariableProps): React.ReactNode; interface LocalValueVariableProps extends VariableProps { value?: VariableValue; text?: VariableValue; properties?: Record; isMulti?: boolean; includeAll?: boolean; children: React.ReactNode; } declare function LocalValueVariable({ name, label, hide, skipUrlSync, value, text, properties, isMulti, includeAll, children, }: LocalValueVariableProps): React.ReactNode; interface GroupByVariableProps extends VariableProps { datasource?: DataSourceRef | null; baseFilters?: AdHocVariableFilter[]; defaultOptions?: MetricFindValue[]; defaultValue?: { text: VariableValue; value: VariableValue; }; restorable?: boolean; readOnly?: boolean; layout?: ControlsLayout; applyMode?: 'auto' | 'manual'; tagKeyRegexFilter?: RegExp; getTagKeysProvider?: any; drilldownRecommendationsEnabled?: boolean; /** Allow typing custom values in the selector. Defaults to true in scenes. */ allowCustomValue?: boolean; /** Allow selecting multiple keys. Defaults to true in scenes. */ isMulti?: boolean; /** Include an "All" option. */ includeAll?: boolean; /** How many values to show before collapsing to +N. Defaults to 5 in scenes. */ maxVisibleValues?: number; /** When clearing selection, set value to [] instead of keeping previous. Defaults to true in scenes. */ noValueOnClear?: boolean; children: React.ReactNode; } declare function GroupByVariable({ name, label, hide, skipUrlSync, initialValue, datasource, baseFilters, defaultOptions, defaultValue, restorable, readOnly, layout, applyMode, tagKeyRegexFilter, getTagKeysProvider, drilldownRecommendationsEnabled, allowCustomValue, isMulti, includeAll, maxVisibleValues, noValueOnClear, children, }: GroupByVariableProps): React.ReactNode; /** * Code and concepts copied from https://github.com/grafana/hackathon-2023-12-grafana-react/blob/main/src/grafana-react * * These contexts & components needs some more thought and naming considerations, just a quick proof of concept for now. */ type BreadcrumbItem = Pick; interface BreadcrumbContextValue { breadcrumbs: BreadcrumbItem[]; addBreadcrumb(breadcrumb: BreadcrumbItem): void; removeBreadcrumb(breadcrumb: BreadcrumbItem): void; } declare const BreadcrumbContext: React.Context; declare function BreadcrumbProvider({ children }: { children: React.ReactNode; }): React.JSX.Element; interface BreadcrumbProps { text: string; path: string; extraKeys?: string[]; } declare function Breadcrumb({ text, path, extraKeys }: BreadcrumbProps): React.ReactNode; declare function useVariableValues(name: string): [T[] | undefined, boolean]; interface QueryVariableOptions { name: string; datasource: string; query: string | SceneDataQuery; regex?: string; } /** * A custom hook that creates or updates a `QueryVariable` in the scene context. * * @param {QueryVariableOptions} options - Options for configuring the `QueryVariable`. * @returns {QueryVariable | null} The `QueryVariable` instance or `null`. * * @example * // Usage example * const variable = useQueryVariable({ * name: "myQueryVariable", * datasource: "gdev-testdata", * query: "*", * regex: ".*someFilter.*" * }); * * // Returns a QueryVariable instance or null if not a valid QueryVariable * if (variable) { * console.log("Variable added to the scene:", variable); * } */ declare function useQueryVariable(options: QueryVariableOptions): QueryVariable$1 | null; declare function useVariableValue(name: string): [T | undefined, boolean]; interface AnnotationLayerSetProps { name: string; query: AnnotationQuery; children: React.ReactNode; } declare function AnnotationLayer({ name, query, children }: AnnotationLayerSetProps): React.ReactNode; declare class EmbeddedSceneWithContext extends EmbeddedScene { constructor(state: EmbeddedSceneState); static Component: ({ model }: SceneComponentProps) => React.JSX.Element; } interface Props { minWidth?: number; minHeight?: number; children: React.ReactNode; } /** * Simple css grid layout for visualizations */ declare function VizGridLayout({ children, minWidth, minHeight }: Props): React.JSX.Element; interface SceneFlexLayoutProps extends SceneFlexItemPlacement { children: React.ReactNode; } declare function SceneFlexLayout(props: SceneFlexLayoutProps): React.JSX.Element; interface SceneFlexItemProps extends SceneFlexItemPlacement { children: React.ReactNode; } declare function SceneFlexItem(props: SceneFlexItemProps): null; declare function useSceneContext(): SceneContextObject; declare function useTimeRange(): [TimeRange, SceneTimeRangeLike]; /** * Only returns the variables on the closest context level. * We could modify it to extract all variables from the full context tree. */ declare function useVariables(): SceneVariable[]; interface UseUpdateWhenSceneChangesOptions { /** Variable names */ variables?: string[]; timeRange?: boolean; } interface UseUpdateWhenSceneChangesReason { variableName?: string; variableValue?: VariableValue | undefined | null; timeRange?: TimeRange; } /** * A utility hook to re-render the calling react component when specified variables or time range changes */ declare function useUpdateWhenSceneChanges({ timeRange, variables }: UseUpdateWhenSceneChangesOptions): UseUpdateWhenSceneChangesReason | undefined; /** * Mainly a utility hook to re-render the calling react component when specified variables or time range changes */ declare function useVariableInterpolator(options: UseUpdateWhenSceneChangesOptions): (str: string) => string; export { AdHocFiltersVariable, AnnotationLayer, Breadcrumb, BreadcrumbContext, BreadcrumbProvider, CustomVariable, DataLayerControl, DataSourceVariable, EmbeddedSceneWithContext, GroupByVariable, LocalValueVariable, QueryVariable, RefreshPicker, SceneContext, SceneContextObject, SceneContextProvider, SceneFlexItem, SceneFlexLayout, TimeRangePicker, VariableControl, VizGridLayout, VizPanel, useDataTransformer, useQueryRunner, useQueryVariable, useSceneContext, useTimeRange, useUpdateWhenSceneChanges, useVariableInterpolator, useVariableValue, useVariableValues, useVariables }; export type { SceneContextProviderProps, UseUpdateWhenSceneChangesOptions, UseUpdateWhenSceneChangesReason };