ink-checkbox
Version:
Checkbox component for Ink
33 lines (32 loc) • 952 B
TypeScript
/// <reference types="react" />
import { ForegroundColorName } from 'chalk';
import figureSet from 'figures';
import { Box } from 'ink';
type Status = 'checked' | 'focused' | 'normal';
export type Icon = keyof typeof figureSet;
export type Color = ForegroundColorName;
type Props = React.ComponentProps<typeof Box>;
export type CheckboxEventParams = {
checked: boolean;
label: string;
index: number;
};
export type CheckboxProps = {
index?: number;
label: string;
focused: boolean;
checked?: boolean;
wrapperStyles?: Props;
styles?: {
gap?: number;
icon?: Record<Status, Icon>;
color?: {
bullet?: Record<Status, Color>;
label?: Record<Status, Color>;
};
};
disableInputHandler?: boolean;
onChanged?: ({ checked, index, label }: CheckboxEventParams) => void;
onSubmitted?: ({ checked, index, label }: CheckboxEventParams) => void;
};
export {};