UNPKG

1.84 kBTypeScriptView Raw
1import * as React from 'react';
2import { CheckboxChangeEvent } from './Checkbox';
3import { ConfigConsumerProps } from '../config-provider';
4export declare type CheckboxValueType = string | number | boolean;
5export interface CheckboxOptionType {
6 label: React.ReactNode;
7 value: CheckboxValueType;
8 style?: React.CSSProperties;
9 disabled?: boolean;
10 onChange?: (e: CheckboxChangeEvent) => void;
11}
12export interface AbstractCheckboxGroupProps {
13 prefixCls?: string;
14 className?: string;
15 options?: Array<CheckboxOptionType | string>;
16 disabled?: boolean;
17 style?: React.CSSProperties;
18}
19export interface CheckboxGroupProps extends AbstractCheckboxGroupProps {
20 name?: string;
21 defaultValue?: Array<CheckboxValueType>;
22 value?: Array<CheckboxValueType>;
23 onChange?: (checkedValue: Array<CheckboxValueType>) => void;
24}
25export interface CheckboxGroupState {
26 value: CheckboxValueType[];
27 registeredValues: CheckboxValueType[];
28}
29export interface CheckboxGroupContext {
30 toggleOption?: (option: CheckboxOptionType) => void;
31 value?: any;
32 disabled?: boolean;
33}
34export declare const GroupContext: React.Context<CheckboxGroupContext | null>;
35declare class CheckboxGroup extends React.PureComponent<CheckboxGroupProps, CheckboxGroupState> {
36 static defaultProps: {
37 options: never[];
38 };
39 static getDerivedStateFromProps(nextProps: CheckboxGroupProps): {
40 value: CheckboxValueType[];
41 } | null;
42 constructor(props: CheckboxGroupProps);
43 getOptions(): CheckboxOptionType[];
44 cancelValue: (value: string) => void;
45 registerValue: (value: string) => void;
46 toggleOption: (option: CheckboxOptionType) => void;
47 renderGroup: ({ getPrefixCls, direction }: ConfigConsumerProps) => JSX.Element;
48 render(): JSX.Element;
49}
50export default CheckboxGroup;