mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
34 lines
721 B
TypeScript
34 lines
721 B
TypeScript
import { useId } from '@react-aria/utils';
|
|
import React, { ChangeEvent, PropsWithChildren, ReactElement } from 'react';
|
|
|
|
import { Checkbox } from '@grafana/ui';
|
|
|
|
interface VariableCheckboxFieldProps {
|
|
value: boolean;
|
|
name: string;
|
|
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
description?: string;
|
|
ariaLabel?: string;
|
|
}
|
|
|
|
export function VariableCheckboxField({
|
|
value,
|
|
name,
|
|
description,
|
|
onChange,
|
|
ariaLabel,
|
|
}: PropsWithChildren<VariableCheckboxFieldProps>): ReactElement {
|
|
const uniqueId = useId();
|
|
|
|
return (
|
|
<Checkbox
|
|
id={uniqueId}
|
|
label={name}
|
|
description={description}
|
|
value={value}
|
|
onChange={onChange}
|
|
aria-label={ariaLabel}
|
|
/>
|
|
);
|
|
}
|