{"version":3,"file":"fieldOverrides.cjs","sources":["../../../src/types/fieldOverrides.ts"],"sourcesContent":["import { ComponentType } from 'react';\n\nimport { FieldConfigOptionsRegistry } from '../field/FieldConfigOptionsRegistry';\nimport { StandardEditorContext, StandardEditorProps } from '../field/standardFieldConfigEditorRegistry';\nimport { GrafanaTheme2 } from '../themes/types';\n\nimport { OptionsEditorItem } from './OptionsUIRegistryBuilder';\nimport { ScopedVars } from './ScopedVars';\nimport { DataFrame, Field, FieldConfig, ValueLinkConfig } from './dataFrame';\nimport { DataLink, LinkModel } from './dataLink';\nimport { OptionEditorConfig } from './options';\nimport { InterpolateFunction } from './panel';\nimport { TimeZone } from './time';\nimport { MatcherConfig } from './transformations';\n\nexport interface DynamicConfigValue {\n  id: string;\n  value?: any;\n}\n\nexport interface ConfigOverrideRule {\n  matcher: MatcherConfig;\n  properties: DynamicConfigValue[];\n}\n\n/**\n * Describes config override rules created when interacting with Grafana.\n *\n * @internal\n */\nexport interface SystemConfigOverrideRule extends ConfigOverrideRule {\n  __systemRef: string;\n}\n\n/**\n * Guard functionality to check if an override rule is of type {@link SystemConfigOverrideRule}.\n * It will only return true if the {@link SystemConfigOverrideRule} has the passed systemRef.\n *\n * @param ref system override reference\n * @internal\n */\nexport function isSystemOverrideWithRef<T extends SystemConfigOverrideRule>(ref: string) {\n  return (override: ConfigOverrideRule): override is T => {\n    return '__systemRef' in override && override.__systemRef === ref;\n  };\n}\n\n/**\n * Guard functionality to check if an override rule is of type {@link SystemConfigOverrideRule}.\n * It will return true if the {@link SystemConfigOverrideRule} has any systemRef set.\n *\n * @internal\n */\nexport const isSystemOverride = (override: ConfigOverrideRule): override is SystemConfigOverrideRule => {\n  return '__systemRef' in override && typeof override.__systemRef === 'string';\n};\n\nexport interface FieldConfigSource<TOptions = any> {\n  // Defaults applied to all numeric fields\n  defaults: FieldConfig<TOptions>;\n\n  // Rules to override individual values\n  overrides: ConfigOverrideRule[];\n}\n\nexport interface FieldOverrideContext extends StandardEditorContext<any> {\n  field?: Field;\n  dataFrameIndex?: number; // The index for the selected field frame\n}\n\n/** @deprecated Use StandardEditorProps instead */\nexport type FieldConfigEditorProps<TValue, TSettings extends {}> = StandardEditorProps<TValue, TSettings>;\n\n/** @deprecated Use StandardEditorProps instead */\nexport type FieldOverrideEditorProps<TValue, TSettings extends {}> = StandardEditorProps<TValue, TSettings>;\n\nexport interface FieldConfigEditorConfig<TOptions, TSettings = any, TValue = any>\n  extends OptionEditorConfig<TOptions, TSettings, TValue> {\n  /**\n   * Function that allows specifying whether or not this field config should apply to a given field.\n   * @param field\n   */\n  shouldApply?: (field: Field) => boolean;\n\n  /** Indicates that option shoukd not be available in the Field config tab */\n  hideFromDefaults?: boolean;\n\n  /** Indicates that option should not be available for the overrides */\n  hideFromOverrides?: boolean;\n}\n\nexport interface FieldConfigPropertyItem<TOptions = any, TValue = any, TSettings extends {} = any>\n  extends OptionsEditorItem<TOptions, TSettings, StandardEditorProps<TValue, TSettings>, TValue> {\n  // An editor that can be filled in with context info (template variables etc)\n  override: ComponentType<StandardEditorProps<TValue, TSettings>>;\n\n  /** true for plugin field config properties */\n  isCustom?: boolean;\n\n  /** Hides option from the Field config tab */\n  hideFromDefaults?: boolean;\n\n  /** Indicates that option should not be available for the overrides */\n  hideFromOverrides?: boolean;\n\n  /** Convert the override value to a well typed value */\n  process: (value: any, context: FieldOverrideContext, settings?: TSettings) => TValue | undefined | null;\n\n  /** Checks if field should be processed */\n  shouldApply: (field: Field) => boolean;\n}\n\nexport type DataLinkPostProcessorOptions = {\n  frame: DataFrame;\n  field: Field;\n  dataLinkScopedVars: ScopedVars;\n  replaceVariables: InterpolateFunction;\n  timeZone?: TimeZone;\n  config: ValueLinkConfig;\n  link: DataLink;\n  linkModel: LinkModel;\n};\n\nexport type DataLinkPostProcessor = (options: DataLinkPostProcessorOptions) => LinkModel<Field> | undefined;\n\nexport interface ApplyFieldOverrideOptions {\n  data?: DataFrame[];\n  fieldConfig: FieldConfigSource;\n  fieldConfigRegistry?: FieldConfigOptionsRegistry;\n  replaceVariables: InterpolateFunction;\n  theme: GrafanaTheme2;\n  timeZone?: TimeZone;\n  dataLinkPostProcessor?: DataLinkPostProcessor;\n}\n\nexport enum FieldConfigProperty {\n  Unit = 'unit',\n  Min = 'min',\n  Max = 'max',\n  FieldMinMax = 'fieldMinMax',\n  Decimals = 'decimals',\n  DisplayName = 'displayName',\n  NoValue = 'noValue',\n  Thresholds = 'thresholds',\n  Mappings = 'mappings',\n  Links = 'links',\n  Actions = 'actions',\n  Color = 'color',\n  Filterable = 'filterable',\n}\n"],"names":["FieldConfigProperty"],"mappings":";;;;;AAyCO,SAAS,wBAA4D,GAAA,EAAa;AACvF,EAAA,OAAO,CAAC,QAAA,KAAgD;AACtD,IAAA,OAAO,aAAA,IAAiB,QAAA,IAAY,QAAA,CAAS,WAAA,KAAgB,GAAA;AAAA,EAC/D,CAAA;AACF;AAQO,MAAM,gBAAA,GAAmB,CAAC,QAAA,KAAuE;AACtG,EAAA,OAAO,aAAA,IAAiB,QAAA,IAAY,OAAO,QAAA,CAAS,WAAA,KAAgB,QAAA;AACtE;AAgFO,IAAK,mBAAA,qBAAAA,oBAAAA,KAAL;AACL,EAAAA,qBAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,qBAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,qBAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,qBAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,qBAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,qBAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,qBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,qBAAA,YAAA,CAAA,GAAa,YAAA;AACb,EAAAA,qBAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,qBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,qBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,qBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,qBAAA,YAAA,CAAA,GAAa,YAAA;AAbH,EAAA,OAAAA,oBAAAA;AAAA,CAAA,EAAA,mBAAA,IAAA,EAAA;;;;;;"}