@octopusdeploy/design-system-components
Version:
The design systems component library.
72 lines (71 loc) • 2.63 kB
TypeScript
import * as React from "react";
import type { PopoverBasicHelpProps } from "../../Popover";
import type { DescriptionContent } from "../utils/descriptionWithLinks";
interface CheckboxNewBaseProps<T extends string | boolean> {
/**
* The value of the checkbox button.
* For singular usage: the current state value
* For group usage: the value that gets returned when checked
*/
value: T;
/**
* The name of the checkbox group. If not provided, will use the name from CheckboxGroup context.
*/
name?: string;
/**
* onChange handler for singular usage.
* When provided, this checkbox manages its own state instead of using the context.
*/
onChange?: (newValue: T) => void;
/**
* Controls whether the checkbox button is disabled.
*/
disabled?: boolean;
/**
* Renders the checkbox in the visual “indeterminate” (mixed) state.
* Set `aria-checked="mixed"`.
*/
isIndeterminate?: boolean;
/**
* Controls whether the checkbox button should be automatically focused.
*/
autoFocus?: boolean;
}
/** Props when using a visible label (preferred for accessibility). */
interface CheckboxWithLabel<T extends string | boolean> extends CheckboxNewBaseProps<T> {
/**
* The label of the checkbox button. Prefer always providing a label for accessibility.
*/
label: string;
/**
* Controls whether the checkbox button should be the default selected option.
*/
hasDefaultMarker?: boolean;
/**
* The description of the checkbox button.
*/
description?: string | DescriptionContent;
/**
* PopoverBasicHelp component to display additional help information
* displays the Information icon next to the checkbox label
*/
popover?: React.ReactElement<PopoverBasicHelpProps>;
}
/** Props when the checkbox has no visible label (e.g. in a table row). You must provide an accessible name. */
interface CheckboxWithoutLabel<T extends string | boolean> extends CheckboxNewBaseProps<T> {
label?: never;
/**
* Accessible name for screen readers when no visible label is shown.
* Required when omitting `label` so the checkbox remains accessible.
*/
ariaLabel: string;
description?: never;
hasDefaultMarker?: never;
popover?: never;
}
export type CheckboxNewProps<T extends string | boolean> = CheckboxWithLabel<T> | CheckboxWithoutLabel<T>;
/**
* CheckboxNew component
*/
export declare function Checkbox<T extends string | boolean>(props: CheckboxNewProps<T>): import("react/jsx-runtime").JSX.Element;
export {};