diff --git a/packages/components/checkbox-group/type.ts b/packages/components/checkbox-group/type.ts index 9f0550df5..a970fd0f6 100644 --- a/packages/components/checkbox-group/type.ts +++ b/packages/components/checkbox-group/type.ts @@ -4,6 +4,7 @@ * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC * */ +import { CheckboxIconType } from '../checkbox/index'; import { KeysType } from '../common/common'; export interface TdCheckboxGroupProps { @@ -83,6 +84,7 @@ export interface CheckboxOptionObj { label?: string; value?: string | number; disabled?: boolean; + icon?: CheckboxIconType; checkAll?: true; } diff --git a/packages/components/checkbox/README.en-US.md b/packages/components/checkbox/README.en-US.md index 2e7ae46a2..a7ee74716 100644 --- a/packages/components/checkbox/README.en-US.md +++ b/packages/components/checkbox/README.en-US.md @@ -16,7 +16,7 @@ default-checked | Boolean | undefined | uncontrolled property | N content | String | - | \- | N content-disabled | Boolean | - | \- | N disabled | Boolean | undefined | \- | N -icon | String / Array | 'circle' | Typescript:`'circle' \| 'line' \| 'rectangle' \| string[]` | N +icon | String / Array | 'circle' | Typescript: `CheckboxIconType ` `type CheckboxIconType = 'circle' \| 'line' \| 'rectangle' \| string[] `。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox/type.ts) | N indeterminate | Boolean | false | \- | N label | String | - | \- | N max-content-row | Number | 5 | \- | N @@ -24,7 +24,7 @@ max-label-row | Number | 3 | \- | N name | String | - | \- | N placement | String | left | options: left/right | N readonly | Boolean | undefined | \- | N -value | String / Number / Boolean | - | value of checkbox。Typescript:`string \| number \| boolean` | N +value | String / Number / Boolean | - | value of checkbox。Typescript: `string \| number \| boolean` | N ### Checkbox Events @@ -59,13 +59,13 @@ style | Object | - | CSS(Cascading Style Sheets) | N custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N borderless | Boolean | false | \- | N disabled | Boolean | undefined | \- | N -keys | Object | - | Typescript:`KeysType`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/common/common.ts) | N +keys | Object | - | Typescript: `KeysType`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/common/common.ts) | N max | Number | undefined | \- | N name | String | - | \- | N -options | Array | [] | Typescript:`Array` `type CheckboxOption = string \| number \| CheckboxOptionObj` `interface CheckboxOptionObj { label?: string; value?: string \| number; disabled?: boolean; checkAll?: true }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox-group/type.ts) | N +options | Array | [] | Typescript: `Array` `type CheckboxOption = string \| number \| CheckboxOptionObj` `interface CheckboxOptionObj { label?: string; value?: string \| number; disabled?: boolean; icon?: CheckboxIconType; checkAll?: true }`,[Checkbox API Documents](./checkbox?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox-group/type.ts) | N readonly | Boolean | undefined | \- | N -value | Array | [] | Typescript:`T` `type CheckboxGroupValue = Array`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox-group/type.ts) | N -default-value | Array | undefined | uncontrolled property。Typescript:`T` `type CheckboxGroupValue = Array`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox-group/type.ts) | N +value | Array | [] | Typescript: `T` `type CheckboxGroupValue = Array`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox-group/type.ts) | N +default-value | Array | undefined | uncontrolled property。Typescript: `T` `type CheckboxGroupValue = Array`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox-group/type.ts) | N ### CheckboxGroup Events diff --git a/packages/components/checkbox/README.md b/packages/components/checkbox/README.md index b1b3dbe4d..00eb04007 100644 --- a/packages/components/checkbox/README.md +++ b/packages/components/checkbox/README.md @@ -81,7 +81,7 @@ default-checked | Boolean | undefined | 是否选中。非受控属性 | N content | String | - | 多选框内容 | N content-disabled | Boolean | - | 是否禁用组件内容(content)触发选中 | N disabled | Boolean | undefined | 是否禁用组件。如果父组件存在 CheckboxGroup,默认值由 CheckboxGroup.disabled 控制。优先级:Checkbox.disabled > CheckboxGroup.disabled > Form.disabled | N -icon | String / Array | 'circle' | 自定义选中图标和非选中图标。使用 Array 时表示:`[选中态图标,非选中态图标,半选中态图标]`。使用 String 时,值为 circle 表示填充圆形图标、值为 line 表示描边型图标、值为 rectangle 表示填充矩形图标。TS 类型:`'circle' \| 'line' \| 'rectangle' \| string[]` | N +icon | String / Array | 'circle' | 自定义选中图标和非选中图标。使用 Array 时表示:`[选中态图标,非选中态图标,半选中态图标]`。使用 String 时,值为 circle 表示填充圆形图标、值为 line 表示描边型图标、值为 rectangle 表示填充矩形图标。TS 类型:`CheckboxIconType ` `type CheckboxIconType = 'circle' \| 'line' \| 'rectangle' \| string[] `。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox/type.ts) | N indeterminate | Boolean | false | 是否为半选 | N label | String | - | 主文案 | N max-content-row | Number | 5 | 内容最大行数限制 | N @@ -127,7 +127,7 @@ disabled | Boolean | undefined | 是否禁用组件。优先级:Form.disabled keys | Object | - | 用来定义 value / label / disabled 在 `options` 中对应的字段别名。TS 类型:`KeysType`。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/common/common.ts) | N max | Number | undefined | 支持最多选中的数量 | N name | String | - | 统一设置内部复选框 HTML 属性 | N -options | Array | [] | 以配置形式设置子元素。示例1:`['北京', '上海']` ,示例2: `[{ label: '全选', checkAll: true }, { label: '上海', value: 'shanghai' }]`。checkAll 值为 true 表示当前选项为「全选选项」。TS 类型:`Array` `type CheckboxOption = string \| number \| CheckboxOptionObj` `interface CheckboxOptionObj { label?: string; value?: string \| number; disabled?: boolean; checkAll?: true }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox-group/type.ts) | N +options | Array | [] | 以配置形式设置子元素。示例1:`['北京', '上海']` ,示例2: `[{ label: '全选', checkAll: true }, { label: '上海', value: 'shanghai' }]`。checkAll 值为 true 表示当前选项为「全选选项」。TS 类型:`Array` `type CheckboxOption = string \| number \| CheckboxOptionObj` `interface CheckboxOptionObj { label?: string; value?: string \| number; disabled?: boolean; icon?: CheckboxIconType; checkAll?: true }`,[Checkbox API Documents](./checkbox?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox-group/type.ts) | N readonly | Boolean | undefined | 只读状态 | N value | Array | [] | 选中值。TS 类型:`T` `type CheckboxGroupValue = Array`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox-group/type.ts) | N default-value | Array | undefined | 选中值。非受控属性。TS 类型:`T` `type CheckboxGroupValue = Array`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/checkbox-group/type.ts) | N diff --git a/packages/components/checkbox/checkbox.ts b/packages/components/checkbox/checkbox.ts index 309612a9b..586da116d 100644 --- a/packages/components/checkbox/checkbox.ts +++ b/packages/components/checkbox/checkbox.ts @@ -1,9 +1,13 @@ import { SuperComponent, wxComponent, ComponentsOptionsType, RelationsOptions } from '../common/src/index'; import config from '../common/config'; +import { TdCheckboxProps } from './type'; import Props from './props'; const { prefix } = config; const name = `${prefix}-checkbox`; + +export type CheckboxProps = TdCheckboxProps; + @wxComponent() export default class CheckBox extends SuperComponent { externalClasses = [ diff --git a/packages/components/checkbox/index.ts b/packages/components/checkbox/index.ts new file mode 100644 index 000000000..5ee525ef9 --- /dev/null +++ b/packages/components/checkbox/index.ts @@ -0,0 +1,3 @@ +export * from './props'; +export * from './type'; +export * from './checkbox'; diff --git a/packages/components/checkbox/type.ts b/packages/components/checkbox/type.ts index 479bb3e69..580d76fc6 100644 --- a/packages/components/checkbox/type.ts +++ b/packages/components/checkbox/type.ts @@ -71,7 +71,7 @@ export interface TdCheckboxProps { */ icon?: { type: null; - value?: 'circle' | 'line' | 'rectangle' | string[]; + value?: CheckboxIconType; }; /** * 是否为半选 @@ -135,3 +135,5 @@ export interface TdCheckboxProps { value?: string | number | boolean; }; } + +export type CheckboxIconType = 'circle' | 'line' | 'rectangle' | string[];