mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* Variables: Adds description field * Refactor: Adds new Form components * Refactor: Fixes aria labels * Refactor: removes skipped tests * Refactor: Breaks out smaller select components * Refactor: removes gf-form div * Refactor: Breaks up several more selects into smaller components * Chore: Fixes typings
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import React, { FormEvent, PropsWithChildren, ReactElement } from 'react';
|
|
import { InlineField, Input, PopoverContent } from '@grafana/ui';
|
|
|
|
interface VariableTextFieldProps {
|
|
value: string;
|
|
name: string;
|
|
placeholder: string;
|
|
onChange: (event: FormEvent<HTMLInputElement>) => void;
|
|
ariaLabel?: string;
|
|
tooltip?: PopoverContent;
|
|
required?: boolean;
|
|
width?: number;
|
|
labelWidth?: number;
|
|
grow?: boolean;
|
|
onBlur?: (event: FormEvent<HTMLInputElement>) => void;
|
|
}
|
|
|
|
export function VariableTextField({
|
|
value,
|
|
name,
|
|
placeholder,
|
|
onChange,
|
|
ariaLabel,
|
|
width,
|
|
labelWidth,
|
|
required,
|
|
onBlur,
|
|
tooltip,
|
|
grow,
|
|
}: PropsWithChildren<VariableTextFieldProps>): ReactElement {
|
|
return (
|
|
<InlineField label={name} labelWidth={labelWidth ?? 12} tooltip={tooltip} grow={grow}>
|
|
<Input
|
|
type="text"
|
|
id={name}
|
|
name={name}
|
|
placeholder={placeholder}
|
|
value={value}
|
|
onChange={onChange}
|
|
onBlur={onBlur}
|
|
width={grow ? undefined : width ?? 25}
|
|
aria-label={ariaLabel}
|
|
required={required}
|
|
/>
|
|
</InlineField>
|
|
);
|
|
}
|