grafana-ui: Add checkbox value field (#48436)

* grafana-ui: Add checkbox value field

* better naming + comment
This commit is contained in:
Agnès Toulet 2022-04-29 09:06:01 +02:00 committed by GitHub
parent 62cd722726
commit 49491bc73e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,10 +12,12 @@ export interface CheckboxProps extends Omit<HTMLProps<HTMLInputElement>, 'value'
label?: string;
description?: string;
value?: boolean;
// htmlValue allows to specify the input "value" attribute
htmlValue?: string | number;
}
export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
({ label, description, value, onChange, disabled, className, ...inputProps }, ref) => {
({ label, description, value, htmlValue, onChange, disabled, className, ...inputProps }, ref) => {
const handleOnChange = useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
if (onChange) {
@ -34,6 +36,7 @@ export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
checked={value}
disabled={disabled}
onChange={handleOnChange}
value={htmlValue}
{...inputProps}
ref={ref}
/>