Skip to content

Commit

Permalink
fix(checkbox): change 类型错误
Browse files Browse the repository at this point in the history
  • Loading branch information
liweijie0812 committed Nov 15, 2024
1 parent 573873e commit 4df11e7
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 6 deletions.
Binary file modified db/TDesign.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ name | String | - | \- | N
options | Array | - | Typescript:`Array<CheckboxOption>` `type CheckboxOption = string \| number \| CheckboxOptionObj` `interface CheckboxOptionObj extends TdCheckboxProps { text?: string; }`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/checkbox/type.ts) | N
value | Array | [] | Typescript:`T` `type CheckboxGroupValue = Array<string \| number \| boolean>`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/checkbox/type.ts) | N
defaultValue | Array | [] | uncontrolled property。Typescript:`T` `type CheckboxGroupValue = Array<string \| number \| boolean>`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/checkbox/type.ts) | N
onChange | Function | | Typescript:`(value: T, context: CheckboxGroupChangeContext) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/checkbox/type.ts)。<br/>`interface CheckboxGroupChangeContext { e: ChangeEvent; current: CheckboxOption \| TdCheckboxProps; option: current: CheckboxOption \| TdCheckboxProps; type: 'check' \| 'uncheck' }`<br/> | N
onChange | Function | | Typescript:`(value: T, context: CheckboxGroupChangeContext) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/checkbox/type.ts)。<br/>`interface CheckboxGroupChangeContext { e: ChangeEvent; current: CheckboxOption \| TdCheckboxProps; option: CheckboxOption \| TdCheckboxProps; type: 'check' \| 'uncheck' }`<br/> | N
4 changes: 2 additions & 2 deletions packages/products/tdesign-react/src/checkbox/checkbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ readonly | Boolean | false | 只读状态 | N
title | String | - | HTML 原生属性 | N
value | String / Number / Boolean | - | 多选框的值。TS 类型:`string \| number \| boolean` | N
onChange | Function | | TS 类型:`(checked: boolean, context: { e: ChangeEvent }) => void`<br/>值变化时触发 | N
onClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>点击时出发,一般用于外层阻止冒泡场景 | N
onClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>点击时触发,一般用于外层阻止冒泡场景 | N


### CheckboxGroup Props
Expand All @@ -37,4 +37,4 @@ name | String | - | 统一设置内部复选框 HTML 属性 | N
options | Array | - | 以配置形式设置子元素。示例1:`['北京', '上海']` ,示例2: `[{ label: '全选', checkAll: true }, { label: '上海', value: 'shanghai' }]`。checkAll 值为 true 表示当前选项为「全选选项」。TS 类型:`Array<CheckboxOption>` `type CheckboxOption = string \| number \| CheckboxOptionObj` `interface CheckboxOptionObj extends TdCheckboxProps { text?: string; }`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/checkbox/type.ts) | N
value | Array | [] | 选中值。TS 类型:`T` `type CheckboxGroupValue = Array<string \| number \| boolean>`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/checkbox/type.ts) | N
defaultValue | Array | [] | 选中值。非受控属性。TS 类型:`T` `type CheckboxGroupValue = Array<string \| number \| boolean>`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/checkbox/type.ts) | N
onChange | Function | | TS 类型:`(value: T, context: CheckboxGroupChangeContext) => void`<br/>值变化时触发,`context.current` 表示当前变化的数据值,如果是全选则为空;`context.type` 表示引起选中数据变化的是选中或是取消选中;`context.option` 表示当前变化的数据项;`context.current` 即将废弃,请勿使用。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/checkbox/type.ts)。<br/>`interface CheckboxGroupChangeContext { e: ChangeEvent; current: CheckboxOption \| TdCheckboxProps; option: current: CheckboxOption \| TdCheckboxProps; type: 'check' \| 'uncheck' }`<br/> | N
onChange | Function | | TS 类型:`(value: T, context: CheckboxGroupChangeContext) => void`<br/>值变化时触发,`context.current` 表示当前变化的数据值,如果是全选则为空;`context.type` 表示引起选中数据变化的是选中或是取消选中;`context.option` 表示当前变化的数据项;`context.current` 即将废弃,请勿使用。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/checkbox/type.ts)。<br/>`interface CheckboxGroupChangeContext { e: ChangeEvent; current: CheckboxOption \| TdCheckboxProps; option: CheckboxOption \| TdCheckboxProps; type: 'check' \| 'uncheck' }`<br/> | N
124 changes: 123 additions & 1 deletion packages/products/tdesign-react/src/checkbox/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,126 @@
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

[object Object]
import { TNode } from '../common';
import { MouseEvent, ChangeEvent } from 'react';

export interface TdCheckboxProps {
/**
* 用于标识是否为「全选选项」。单独使用无效,需在 CheckboxGroup 中使用
* @default false
*/
checkAll?: boolean;
/**
* 是否选中
* @default false
*/
checked?: boolean;
/**
* 是否选中,非受控属性
* @default false
*/
defaultChecked?: boolean;
/**
* 多选框内容,同 label
*/
children?: TNode;
/**
* 是否禁用组件。如果父组件存在 CheckboxGroup,默认值由 CheckboxGroup.disabled 控制。优先级:Checkbox.disabled > CheckboxGroup.disabled > Form.disabled
*/
disabled?: boolean;
/**
* 是否为半选
* @default false
*/
indeterminate?: boolean;
/**
* 主文案
*/
label?: TNode;
/**
* 是否启用懒加载。数据量大时建议开启;加载复杂内容或大量图片时建议开启
* @default false
*/
lazyLoad?: boolean;
/**
* HTML 元素原生属性
* @default ''
*/
name?: string;
/**
* 只读状态
* @default false
*/
readonly?: boolean;
/**
* HTML 原生属性
* @default ''
*/
title?: string;
/**
* 多选框的值
*/
value?: string | number | boolean;
/**
* 值变化时触发
*/
onChange?: (checked: boolean, context: { e: ChangeEvent<HTMLInputElement> }) => void;
/**
* 点击时触发,一般用于外层阻止冒泡场景
*/
onClick?: (context: { e: MouseEvent<HTMLLabelElement> }) => void;
}

export interface TdCheckboxGroupProps<T = CheckboxGroupValue> {
/**
* 是否禁用组件。优先级:Form.disabled < CheckboxGroup.disabled < Checkbox.disabled
*/
disabled?: boolean;
/**
* 是否启用懒加载。子组件 Checkbox 数据量大时建议开启;加载复杂内容或大量图片时建议开启
* @default false
*/
lazyLoad?: boolean;
/**
* 支持最多选中的数量
*/
max?: number;
/**
* 统一设置内部复选框 HTML 属性
* @default ''
*/
name?: string;
/**
* 以配置形式设置子元素。示例1:`['北京', '上海']` ,示例2: `[{ label: '全选', checkAll: true }, { label: '上海', value: 'shanghai' }]`。checkAll 值为 true 表示当前选项为「全选选项」
*/
options?: Array<CheckboxOption>;
/**
* 选中值
* @default []
*/
value?: T;
/**
* 选中值,非受控属性
* @default []
*/
defaultValue?: T;
/**
* 值变化时触发,`context.current` 表示当前变化的数据值,如果是全选则为空;`context.type` 表示引起选中数据变化的是选中或是取消选中;`context.option` 表示当前变化的数据项;`context.current` 即将废弃,请勿使用
*/
onChange?: (value: T, context: CheckboxGroupChangeContext) => void;
}

export type CheckboxOption = string | number | CheckboxOptionObj;

export interface CheckboxOptionObj extends TdCheckboxProps {
text?: string;
}

export type CheckboxGroupValue = Array<string | number | boolean>;

export interface CheckboxGroupChangeContext {
e: ChangeEvent<HTMLDivElement>;
current: CheckboxOption | TdCheckboxProps;
option: CheckboxOption | TdCheckboxProps;
type: 'check' | 'uncheck';
}
4 changes: 2 additions & 2 deletions packages/scripts/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -26151,7 +26151,7 @@
"field_type": [],
"field_default_value": "",
"field_enum": "",
"field_desc_zh": "点击时出发,一般用于外层阻止冒泡场景",
"field_desc_zh": "点击时触发,一般用于外层阻止冒泡场景",
"field_desc_en": "trigger on click",
"field_required": 0,
"event_input": "(context: { e: MouseEvent })",
Expand Down Expand Up @@ -26792,7 +26792,7 @@
"field_desc_zh": "值变化时触发,`context.current` 表示当前变化的数据值,如果是全选则为空;`context.type` 表示引起选中数据变化的是选中或是取消选中;`context.option` 表示当前变化的数据项;`context.current` 即将废弃,请勿使用",
"field_desc_en": null,
"field_required": 0,
"event_input": "(value: T, context: CheckboxGroupChangeContext)【interface CheckboxGroupChangeContext { e: ChangeEvent; current: CheckboxOption | TdCheckboxProps; option: current: CheckboxOption | TdCheckboxProps; type: 'check' | 'uncheck' }】",
"event_input": "(value: T, context: CheckboxGroupChangeContext)【interface CheckboxGroupChangeContext { e: ChangeEvent; current: CheckboxOption | TdCheckboxProps; option: CheckboxOption | TdCheckboxProps; type: 'check' | 'uncheck' }】",
"create_time": "2021-05-17 03:00:53",
"update_time": "2022-04-03 09:17:34",
"event_output": null,
Expand Down

0 comments on commit 4df11e7

Please sign in to comment.