@grafana/ui
Version:
Grafana Components Library
38 lines (35 loc) • 1.52 kB
JavaScript
import { jsx } from 'react/jsx-runtime';
import { memo, useState } from 'react';
import { FieldMatcherID, fieldMatchers } from '@grafana/data';
import { t } from '@grafana/i18n';
import { Input } from '../Input/Input.mjs';
import { Stack } from '../Layout/Stack/Stack.mjs';
;
const FieldNameByRegexMatcherEditor = memo((props) => {
const { id, options, onChange, scope = "series" } = props;
const [regexp, setRegexp] = useState(options);
return /* @__PURE__ */ jsx(Stack, { gap: 1, direction: "column", children: /* @__PURE__ */ jsx(
Input,
{
id,
placeholder: t("grafana-ui.field-name-by-regex-matcher.input-placeholder", "Enter regular expression"),
value: regexp,
onChange: (e) => setRegexp(e.currentTarget.value),
onBlur: () => onChange(regexp, scope)
}
) });
});
FieldNameByRegexMatcherEditor.displayName = "FieldNameByRegexMatcherEditor";
const getFieldNameByRegexMatcherItem = () => ({
id: FieldMatcherID.byRegexp,
component: FieldNameByRegexMatcherEditor,
matcher: fieldMatchers.get(FieldMatcherID.byRegexp),
name: t("grafana-ui.matchers-ui.name-field-name-by-regex-matcher", "Fields with name matching regex"),
description: t(
"grafana-ui.matchers-ui.description-field-name-by-regex-matcher",
"Set properties for fields with names matching a regex"
),
optionsToLabel: (options) => options
});
export { FieldNameByRegexMatcherEditor, getFieldNameByRegexMatcherItem };
//# sourceMappingURL=FieldNameByRegexMatcherEditor.mjs.map