{"version":3,"file":"VizLegendSeriesIcon.mjs","sources":["../../../../src/components/VizLegend/VizLegendSeriesIcon.tsx"],"sourcesContent":["import { memo, useCallback } from 'react';\n\nimport { t } from '@grafana/i18n';\nimport { type LineStyle } from '@grafana/schema';\n\nimport { SeriesColorPicker } from '../ColorPicker/ColorPicker';\nimport { usePanelContext } from '../PanelChrome';\n\nimport { SeriesIcon } from './SeriesIcon';\n\ninterface Props {\n  seriesName: string;\n  color?: string;\n  gradient?: string;\n  readonly?: boolean;\n  lineStyle?: LineStyle;\n}\n\n/**\n * @internal\n */\nexport const VizLegendSeriesIcon = memo(({ seriesName, color, gradient, readonly, lineStyle }: Props) => {\n  const { onSeriesColorChange } = usePanelContext();\n  const onChange = useCallback(\n    (color: string) => {\n      return onSeriesColorChange!(seriesName, color);\n    },\n    [seriesName, onSeriesColorChange]\n  );\n\n  if (seriesName && onSeriesColorChange && color && !readonly) {\n    return (\n      <SeriesColorPicker color={color} onChange={onChange} enableNamedColors>\n        {({ ref, showColorPicker, hideColorPicker, isOpen }) => {\n          function handleKeyDown(e: React.KeyboardEvent<HTMLSpanElement>) {\n            if (e.key === ' ' || e.key === 'Enter') {\n              e.preventDefault();\n              showColorPicker();\n            }\n          }\n          return (\n            <SeriesIcon\n              tabIndex={0}\n              role=\"button\"\n              aria-label={t('grafana-ui.viz-legend.color-picker', 'Edit color for {{seriesName}}', { seriesName })}\n              aria-haspopup=\"menu\"\n              aria-expanded={isOpen}\n              color={color}\n              className=\"pointer\"\n              ref={ref}\n              onClick={showColorPicker}\n              onKeyDown={handleKeyDown}\n              onMouseLeave={hideColorPicker}\n              lineStyle={lineStyle}\n            />\n          );\n        }}\n      </SeriesColorPicker>\n    );\n  }\n  return <SeriesIcon color={color} gradient={gradient} lineStyle={lineStyle} />;\n});\n\nVizLegendSeriesIcon.displayName = 'VizLegendSeriesIcon';\n"],"names":["color"],"mappings":";;;;;;;;;AAqBO,MAAM,mBAAA,GAAsB,KAAK,CAAC,EAAE,YAAY,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