ant-design/components/checkbox/GroupContext.ts
dally_G 0647f56856
type: Checkbox.Group type infer (#46423)
* feat: CheckboxGroup type infer

fix: fix type error

fix: define type infer

chore: opti type

* Update type.test.tsx

Signed-off-by: lijianan <574980606@qq.com>

* Update Group.tsx

Signed-off-by: lijianan <574980606@qq.com>

---------

Signed-off-by: lijianan <574980606@qq.com>
Co-authored-by: gushuo <gushuo@yoycol.com>
Co-authored-by: lijianan <574980606@qq.com>
2023-12-22 17:07:34 +08:00

16 lines
474 B
TypeScript

import React from 'react';
import type { CheckboxOptionType, CheckboxValueType } from './Group';
export interface CheckboxGroupContext<T extends CheckboxValueType = CheckboxValueType> {
name?: string;
toggleOption?: (option: CheckboxOptionType) => void;
value?: any;
disabled?: boolean;
registerValue: (val: T) => void;
cancelValue: (val: T) => void;
}
const GroupContext = React.createContext<CheckboxGroupContext | null>(null);
export default GroupContext;