mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* cloud-datasources mob! :shipit: * cloud-datasources mob! :shipit: lastFile:public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/VariableQueryEditor.tsx * mob next [ci-skip] [ci skip] [skip ci] lastFile:public/app/plugins/datasource/cloudwatch/variables.ts * cloud-datasources mob! 👶 lastFile:public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/VariableQueryEditor.test.tsx * cloud-datasources mob! 👶 lastFile:public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/VariableQueryEditor.test.tsx * mob next [ci-skip] [ci skip] [skip ci] lastFile:public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/VariableQueryEditor.test.tsx * cloud-datasources mob! :shipit: lastFile:public/app/plugins/datasource/cloudwatch/variables.test.ts * cloud-datasources mob! ☕ * prettier md Co-authored-by: Kevin Yu <kevinwcyu@users.noreply.github.com> Co-authored-by: Andres <andres.martinez@grafana.com> Co-authored-by: Erik Sundell <erik.sundell87@gmail.com> Co-authored-by: Adam Simpson <adam@adamsimpson.net>
37 lines
877 B
TypeScript
37 lines
877 B
TypeScript
import React, { FC, useState } from 'react';
|
|
|
|
import { InlineField, Input, PopoverContent } from '@grafana/ui';
|
|
|
|
const LABEL_WIDTH = 20;
|
|
|
|
interface VariableTextFieldProps {
|
|
onBlur: (value: string) => void;
|
|
value: string;
|
|
label: string;
|
|
placeholder?: string;
|
|
tooltip?: PopoverContent;
|
|
interactive?: boolean;
|
|
}
|
|
|
|
export const VariableTextField: FC<VariableTextFieldProps> = ({
|
|
interactive,
|
|
label,
|
|
onBlur,
|
|
placeholder,
|
|
value,
|
|
tooltip,
|
|
}) => {
|
|
const [localValue, setLocalValue] = useState(value);
|
|
return (
|
|
<InlineField interactive={interactive} label={label} labelWidth={LABEL_WIDTH} tooltip={tooltip} grow>
|
|
<Input
|
|
aria-label={label}
|
|
placeholder={placeholder}
|
|
value={localValue}
|
|
onChange={(e) => setLocalValue(e.currentTarget.value)}
|
|
onBlur={() => onBlur(localValue)}
|
|
/>
|
|
</InlineField>
|
|
);
|
|
};
|