{"version":3,"file":"FieldNameMatcherEditor.mjs","sources":["../../../../src/components/MatchersUI/FieldNameMatcherEditor.tsx"],"sourcesContent":["import { memo, useCallback } from 'react';\n\nimport { FieldMatcherID, fieldMatchers, SelectableValue } from '@grafana/data';\nimport { t } from '@grafana/i18n';\n\nimport { Select } from '../Select/Select';\n\nimport { MatcherUIProps, FieldMatcherUIRegistryItem } from './types';\nimport { useFieldDisplayNames, useSelectOptions, frameHasName } from './utils';\n\nexport const FieldNameMatcherEditor = memo<MatcherUIProps<string>>((props) => {\n  const { data, options, onChange: onChangeFromProps, id } = props;\n  const names = useFieldDisplayNames(data);\n  const selectOptions = useSelectOptions(names, options);\n\n  const onChange = useCallback(\n    (selection: SelectableValue<string>) => {\n      if (!frameHasName(selection.value, names)) {\n        return;\n      }\n      return onChangeFromProps(selection.value!);\n    },\n    [names, onChangeFromProps]\n  );\n\n  const selectedOption = selectOptions.find((v) => v.value === options);\n  return <Select value={selectedOption} options={selectOptions} onChange={onChange} inputId={id} />;\n});\nFieldNameMatcherEditor.displayName = 'FieldNameMatcherEditor';\n\nexport const getFieldNameMatcherItem: () => FieldMatcherUIRegistryItem<string> = () => ({\n  id: FieldMatcherID.byName,\n  component: FieldNameMatcherEditor,\n  matcher: fieldMatchers.get(FieldMatcherID.byName),\n  name: t('grafana-ui.matchers-ui.name-fields-with-name', 'Fields with name'),\n  description: t('grafana-ui.matchers-ui.description-fields-with-name', 'Set properties for a specific field'),\n  optionsToLabel: (options) => options,\n});\n"],"names":[],"mappings":";;;;;;;;AAUO,MAAM,sBAAA,GAAyB,IAAA,CAA6B,CAAC,KAAA,KAAU;AAC5E,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAS,QAAA,EAAU,iBAAA,EAAmB,IAAG,GAAI,KAAA;AAC3D,EAAA,MAAM,KAAA,GAAQ,qBAAqB,IAAI,CAAA;AACvC,EAAA,MAAM,aAAA,GAAgB,gBAAA,CAAiB,KAAA,EAAO,OAAO,CAAA;AAErD,EAA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