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AAKF,MAAMM,eAAX,eAAoBC,SAApB,UAA6BgC,EAAUjC,eAAvC,aAA6B,EAAmBC,QAClDL,KAAKmC,YAAYE,GACjBC,GAAU,GAELA,EAGTC,SACE,MAAM,MAAE9B,EAAF,OAASC,GAAWV,KAAKF,MAC/B,OAAO,gBAAK0C,MAAO,CAAE/B,MAAAA,EAAOC,OAAAA,EAAQ+B,SAAU,SAAUC,SAAU,YAA3D,SAA0E1C,KAAKC,QAAQsC,YCvE3F,MAAMI,EAAoC,CAC/CtC,KAAM,CACJuC,OAAQ,CACNC,KAAM,CACJC,KAAMC,EAAAA,GAAAA,MACNC,MAAO,kCAETC,KAAM,CACJD,MAAO,YCZFE,EAAS,IAAIC,EAAAA,YAA0BxD,GACjDyD,eACAC,eAAe,CACdC,gBAAiB,CACf,CAACC,EAAAA,oBAAAA,UAA+B,CAC9BC,SAAU,CACRC,MAAM,OAKbC,iBAAiBC,IAChBA,EAAQC,iBAAmD,CACzDC,SAAU,CAAC,QACXhB,KAAM,OAGNiB,MAAO,CAACH,EAASI,KACf5D,EAAAA,EAAAA,kBAA4BwD,EAASI,GAErCC,EAAAA,EAAAA,cAA4BL,EAASI,GACrCC,EAAAA,EAAAA,UAAwBL,EAASI,IAGnCE,aAActB,EAAoBtC","sources":["webpack://grafana/./public/app/plugins/panel/icon/IconPanel.tsx","webpack://grafana/./public/app/plugins/panel/icon/models.gen.ts","webpack://grafana/./public/app/plugins/panel/icon/module.tsx"],"sourcesContent":["import React, { Component } from 'react';\n\nimport { PanelProps } from '@grafana/data';\nimport { HorizontalConstraint, VerticalConstraint } from 'app/features/canvas';\nimport { iconItem } from 'app/features/canvas/elements/icon';\nimport { ElementState } from 'app/features/canvas/runtime/element';\nimport {\n ColorDimensionConfig,\n DimensionContext,\n getColorDimensionFromData,\n getResourceDimensionFromData,\n getScalarDimensionFromData,\n getScaleDimensionFromData,\n getTextDimensionFromData,\n ResourceDimensionConfig,\n ScalarDimensionConfig,\n ScaleDimensionConfig,\n TextDimensionConfig,\n} from 'app/features/dimensions';\n\nimport { PanelOptions } from './models.gen';\n\ninterface Props extends PanelProps<PanelOptions> {}\n\nexport class IconPanel extends Component<Props> {\n private element: ElementState;\n\n constructor(props: Props) {\n super(props);\n this.element = this.initElement(props);\n }\n\n initElement = (props: Props) => {\n this.element = new ElementState(iconItem, props.options.root as any);\n this.updateSize(props);\n this.element.updateData(this.dims);\n return this.element;\n };\n\n updateSize = (props: Props) => {\n const { width, height } = props;\n this.element.options.constraint = {\n vertical: VerticalConstraint.Top,\n horizontal: HorizontalConstraint.Left,\n };\n this.element.options.placement = {\n left: 0,\n top: 0,\n width,\n height,\n };\n };\n\n dims: DimensionContext = {\n getColor: (color: ColorDimensionConfig) => getColorDimensionFromData(this.props.data, color),\n getScale: (scale: ScaleDimensionConfig) => getScaleDimensionFromData(this.props.data, scale),\n getScalar: (scalar: ScalarDimensionConfig) => getScalarDimensionFromData(this.props.data, scalar),\n getText: (text: TextDimensionConfig) => getTextDimensionFromData(this.props.data, text),\n getResource: (res: ResourceDimensionConfig) => getResourceDimensionFromData(this.props.data, res),\n };\n\n shouldComponentUpdate(nextProps: Props) {\n const { width, height, data } = this.props;\n let changed = false;\n\n if (width !== nextProps.width || height !== nextProps.height) {\n this.updateSize(nextProps);\n changed = true;\n }\n if (data !== nextProps.data) {\n this.element.updateData(this.dims);\n changed = true;\n }\n\n // Reload the element when options change\n if (this.props.options?.root !== nextProps.options?.root) {\n this.initElement(nextProps);\n changed = true;\n }\n return changed;\n }\n\n render() {\n const { width, height } = this.props;\n return <div style={{ width, height, overflow: 'hidden', position: 'relative' }}>{this.element.render()}</div>;\n }\n}\n","//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n// NOTE: This file will be auto generated from models.cue\n// It is currenty hand written but will serve as the target for cuetsy\n//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nimport { CanvasElementOptions } from 'app/features/canvas';\nimport { IconConfig } from 'app/features/canvas/elements/icon';\nimport { ResourceDimensionMode } from 'app/features/dimensions';\n\nexport interface PanelOptions {\n root: Omit<CanvasElementOptions<IconConfig>, 'type' | 'name'>; // type is forced\n}\n\nexport const defaultPanelOptions: PanelOptions = {\n root: {\n config: {\n path: {\n mode: ResourceDimensionMode.Fixed,\n fixed: 'img/icons/unicons/analysis.svg',\n },\n fill: {\n fixed: 'green'\n }\n },\n },\n};\n","import { FieldConfigProperty, PanelPlugin } from '@grafana/data';\nimport { CanvasElementOptions } from 'app/features/canvas';\nimport { IconConfig, iconItem } from 'app/features/canvas/elements/icon';\n\nimport { optionBuilder } from '../canvas/editor/options';\n\nimport { IconPanel } from './IconPanel';\nimport { defaultPanelOptions, PanelOptions } from './models.gen';\n\nexport const plugin = new PanelPlugin<PanelOptions>(IconPanel)\n .setNoPadding() // extend to panel edges\n .useFieldConfig({\n standardOptions: {\n [FieldConfigProperty.Mappings]: {\n settings: {\n icon: true,\n },\n },\n },\n })\n .setPanelOptions((builder) => {\n builder.addNestedOptions<CanvasElementOptions<IconConfig>>({\n category: ['Icon'],\n path: 'root',\n\n // Dynamically fill the selected element\n build: (builder, ctx) => {\n iconItem.registerOptionsUI!(builder, ctx);\n\n optionBuilder.addBackground(builder, ctx);\n optionBuilder.addBorder(builder, ctx);\n },\n\n defaultValue: defaultPanelOptions.root as any,\n });\n });\n"],"names":["IconPanel","Component","constructor","props","super","this","element","ElementState","iconItem","options","root","updateSize","updateData","dims","width","height","constraint","vertical","VerticalConstraint","horizontal","HorizontalConstraint","placement","left","top","getColor","color","getColorDimensionFromData","data","getScale","scale","getScaleDimensionFromData","getScalar","scalar","getScalarDimensionFromData","getText","text","getTextDimensionFromData","getResource","res","getResourceDimensionFromData","initElement","shouldComponentUpdate","nextProps","changed","render","style","overflow","position","defaultPanelOptions","config","path","mode","ResourceDimensionMode","fixed","fill","plugin","PanelPlugin","setNoPadding","useFieldConfig","standardOptions","FieldConfigProperty","settings","icon","setPanelOptions","builder","addNestedOptions","category","build","ctx","optionBuilder","defaultValue"],"sourceRoot":""}