@grafana/ui
Version:
Grafana Components Library
43 lines (38 loc) • 1.72 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var data = require('@grafana/data');
var i18n = require('@grafana/i18n');
var Input = require('../Input/Input.cjs');
var Stack = require('../Layout/Stack/Stack.cjs');
;
const FieldNameByRegexMatcherEditor = React.memo((props) => {
const { id, options, onChange, scope = "series" } = props;
const [regexp, setRegexp] = React.useState(options);
return /* @__PURE__ */ jsxRuntime.jsx(Stack.Stack, { gap: 1, direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(
Input.Input,
{
id,
placeholder: i18n.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: data.FieldMatcherID.byRegexp,
component: FieldNameByRegexMatcherEditor,
matcher: data.fieldMatchers.get(data.FieldMatcherID.byRegexp),
name: i18n.t("grafana-ui.matchers-ui.name-field-name-by-regex-matcher", "Fields with name matching regex"),
description: i18n.t(
"grafana-ui.matchers-ui.description-field-name-by-regex-matcher",
"Set properties for fields with names matching a regex"
),
optionsToLabel: (options) => options
});
exports.FieldNameByRegexMatcherEditor = FieldNameByRegexMatcherEditor;
exports.getFieldNameByRegexMatcherItem = getFieldNameByRegexMatcherItem;
//# sourceMappingURL=FieldNameByRegexMatcherEditor.cjs.map