{"version":3,"file":"panel.cjs","sources":["../../../src/types/panel.ts"],"sourcesContent":["import { EventBus } from '../events/types';\nimport { StandardEditorProps } from '../field/standardFieldConfigEditorRegistry';\nimport { Registry } from '../utils/Registry';\n\nimport { OptionsEditorItem } from './OptionsUIRegistryBuilder';\nimport { ScopedVars } from './ScopedVars';\nimport { AlertStateInfo } from './alerts';\nimport { PanelModel } from './dashboard';\nimport { LoadingState } from './data';\nimport { DataFrame } from './dataFrame';\nimport { DataQueryError, DataQueryRequest, DataQueryTimings } from './datasource';\nimport { FieldConfigSource } from './fieldOverrides';\nimport { IconName } from './icon';\nimport { LinkTarget } from './linkTarget';\nimport { OptionEditorConfig } from './options';\nimport { PluginMeta } from './plugin';\nimport { AbsoluteTimeRange, TimeRange, TimeZone } from './time';\n\nexport type InterpolateFunction = (value: string, scopedVars?: ScopedVars, format?: string | Function) => string;\n\nexport interface PanelPluginMeta extends PluginMeta {\n  /** Indicates that panel does not issue queries */\n  skipDataQuery?: boolean;\n  /** Indicates that the panel implements suggestions */\n  suggestions?: boolean;\n  /** Indicates that panel should not be available in visualisation picker */\n  hideFromList?: boolean;\n  /** Sort order */\n  sort: number;\n}\n\nexport interface PanelData {\n  /** State of the data (loading, done, error, streaming) */\n  state: LoadingState;\n\n  /** Contains data frames with field overrides applied */\n  series: DataFrame[];\n\n  /**\n   * This is a key that will change when the DataFrame[] structure changes.\n   * The revision is a useful way to know if only data has changed or data+structure\n   */\n  structureRev?: number;\n\n  /** A list of annotation items */\n  annotations?: DataFrame[];\n\n  /**\n   * @internal\n   */\n  alertState?: AlertStateInfo;\n\n  /** Request contains the queries and properties sent to the datasource */\n  request?: DataQueryRequest;\n\n  /** Timing measurements */\n  timings?: DataQueryTimings;\n\n  /** Any query errors */\n  errors?: DataQueryError[];\n  /**\n   * Single error for legacy reasons\n   * @deprecated use errors instead -- will be removed in Grafana 10+\n   */\n  error?: DataQueryError;\n\n  /** Contains the range from the request or a shifted time range if a request uses relative time */\n  timeRange: TimeRange;\n\n  /** traceIds collected during the processing of the requests */\n  traceIds?: string[];\n}\n\nexport interface PanelProps<T = any> {\n  /** Unique ID of the panel within the current dashboard */\n  id: number;\n\n  /** Data available as result of running panel queries, includes dataframes and loading state **/\n  data: PanelData;\n\n  /** Time range of the current dashboard */\n  timeRange: TimeRange;\n\n  /** Time zone of the current dashboard */\n  timeZone: TimeZone;\n\n  /** Panel options set by the user in the panel editor. Includes both default and custom panel options */\n  options: T;\n\n  /** Indicates whether or not panel should be rendered transparent */\n  transparent: boolean;\n\n  /** Current width of the panel in pixels */\n  width: number;\n\n  /** Current height of the panel in pixels */\n  height: number;\n\n  /** Field options configuration. Controls how field values are displayed (e.g., units, min, max, decimals, thresholds) */\n  fieldConfig: FieldConfigSource;\n\n  /** @internal */\n  renderCounter: number;\n\n  /** Panel title */\n  title: string;\n\n  /** Grafana EventBus  */\n  eventBus: EventBus;\n\n  /** Handler for options change. Invoke it to update the panel custom options. */\n  onOptionsChange: (options: T) => void;\n\n  /** Field config change handler. Invoke it to update the panel field config. */\n  onFieldConfigChange: (config: FieldConfigSource) => void;\n\n  /** Template variables interpolation function. Given a string containing template variables, it returns the string with interpolated values. */\n  replaceVariables: InterpolateFunction;\n\n  /** Time range change handler */\n  onChangeTimeRange: (timeRange: AbsoluteTimeRange) => void;\n}\n\nexport interface PanelEditorProps<T = any> {\n  /** Panel options */\n  options: T;\n  /** Panel options change handler */\n  onOptionsChange: (\n    options: T,\n    // callback can be used to run something right after update.\n    callback?: () => void\n  ) => void;\n  /** Result set of panel queries */\n  data?: PanelData;\n}\n\n/**\n * This type mirrors the required properties from PanelModel<TOptions> needed for migration handlers.\n *\n * By maintaining a separate type definition, we ensure that changes to PanelModel\n * that would break third-party migration handlers are caught at compile time,\n * rather than failing silently when third-party code attempts to use an incompatible panel.\n *\n * TOptions must be any to follow the same pattern as PanelModel<TOptions>\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface PanelMigrationModel<TOptions = any> {\n  id: number;\n  type: string;\n  title?: string;\n  options: TOptions;\n  fieldConfig: PanelModel<TOptions>['fieldConfig'];\n  pluginVersion?: string;\n  targets?: PanelModel<TOptions>['targets'];\n}\n\n/**\n * Called when a panel is first loaded with current panel model to migrate panel options if needed.\n * Can return panel options, or a Promise that resolves to panel options for async migrations\n */\nexport type PanelMigrationHandler<TOptions = any> = (\n  panel: PanelMigrationModel<TOptions>\n) => Partial<TOptions> | Promise<Partial<TOptions>>;\n\n/**\n * Called before a panel is initialized. Allows panel inspection for any updates before changing the panel type.\n */\nexport type PanelTypeChangedHandler<TOptions = any> = (\n  panel: PanelModel<TOptions>,\n  prevPluginId: string,\n  prevOptions: Record<string, any>,\n  prevFieldConfig: FieldConfigSource\n) => Partial<TOptions>;\n\nexport type PanelOptionEditorsRegistry = Registry<PanelOptionsEditorItem>;\n\nexport interface PanelOptionsEditorProps<TValue> extends StandardEditorProps<TValue> {}\n\nexport interface PanelOptionsEditorItem<TOptions = any, TValue = any, TSettings = any>\n  extends OptionsEditorItem<TOptions, TSettings, PanelOptionsEditorProps<TValue>, TValue> {}\n\nexport interface PanelOptionsEditorConfig<TOptions, TSettings = any, TValue = any>\n  extends OptionEditorConfig<TOptions, TSettings, TValue> {}\n\n/**\n * @internal\n */\nexport interface PanelMenuItem {\n  type?: 'submenu' | 'divider' | 'group';\n  text: string;\n  iconClassName?: IconName;\n  onClick?: (event: React.MouseEvent) => void;\n  shortcut?: string;\n  href?: string;\n  target?: LinkTarget;\n  subMenu?: PanelMenuItem[];\n}\n\n/**\n * @internal\n */\nexport interface AngularPanelMenuItem {\n  click: Function;\n  icon: string;\n  href: string;\n  divider: boolean;\n  text: string;\n  shortcut: string;\n  submenu: any[];\n}\n\nexport enum VizOrientation {\n  Auto = 'auto',\n  Vertical = 'vertical',\n  Horizontal = 'horizontal',\n}\n\nexport interface PanelPluginDataSupport {\n  annotations: boolean;\n  alertStates: boolean;\n}\n"],"names":["VizOrientation"],"mappings":";;;;;AAmNO,IAAK,cAAA,qBAAAA,eAAAA,KAAL;AACL,EAAAA,gBAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,gBAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,gBAAA,YAAA,CAAA,GAAa,YAAA;AAHH,EAAA,OAAAA,eAAAA;AAAA,CAAA,EAAA,cAAA,IAAA,EAAA;;;;"}