UNPKG

@grafana/ui

Version:
60 lines (59 loc) 2.44 kB
import { type DataFrame, type Field, FieldNamePickerBaseNameMode } from '@grafana/data'; import { type MatcherScope } from '@grafana/schema'; import { type ComboboxOption } from '../Combobox/types'; /** * @internal */ export interface FrameFieldsDisplayNames { display: Set<string>; raw: Set<string>; fields: Map<string, Field>; scopes: Map<string, MatcherScope>; } /** * @internal */ export declare function frameHasName(name: string | undefined, names: FrameFieldsDisplayNames): boolean; /** * Returns the distinct names in a set of frames */ export declare function getFrameFieldsDisplayNames(data: DataFrame[], filter?: (field: Field) => boolean, existingNames?: FrameFieldsDisplayNames, parentData?: DataFrame[], scope?: MatcherScope): FrameFieldsDisplayNames; /** * @internal */ export declare function getGroupLabelForScope(scope?: MatcherScope): string | undefined; /** * @internal */ export declare function getGroupDescriptionForScope(scope: MatcherScope): string | undefined; /** * @internal */ export declare function useFieldDisplayNames(data: DataFrame[], filter?: (field: Field) => boolean, scope?: MatcherScope): FrameFieldsDisplayNames; interface UseMatcherSelectOptionsProps { /** * An additional first option to add to the beginning of the list. This is useful for an "All" option, for example. */ firstItem?: ComboboxOption; /** * if set, filter the options by field type. */ fieldType?: string; /** * this controls whether and how entries are added to the combobox fo the base field name of a field with a display name. */ baseNameMode?: FieldNamePickerBaseNameMode; /** * if set, filter the options by matcher scope. */ scope?: MatcherScope; } /** * @internal * given the FrameFieldsDisplayNames object other configuration options, this builds the options for the combobox, grouped by matcher scope. * this is intended to be used by consumers of the MatchersUI, like FieldNamePicker and FieldTypeMatcherEditor. There are optional configuration * options to augment and control the contents of the list. */ export declare function useMatcherSelectOptions(displayNames: FrameFieldsDisplayNames, currentName?: string, { firstItem, fieldType, baseNameMode, scope }?: UseMatcherSelectOptionsProps): ComboboxOption[]; export declare function getUniqueMatcherScopes(data: DataFrame[]): Set<MatcherScope>; export {};