Skip to content

Commit

Permalink
docs(Switch): generate api docs (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao authored Sep 19, 2024
1 parent 230f9b7 commit b95fcd0
Show file tree
Hide file tree
Showing 21 changed files with 165 additions and 42 deletions.
Binary file modified db/TDesign.db
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/products/tdesign-miniprogram/src/switch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场
custom-value | Array | [true, false] | 用于自定义开关的值,[打开时的值,关闭时的值]。默认为 [true, false]。示例:[1, 0]['open', 'close']。TS 类型:`Array<SwitchValue>` | N
disabled | Boolean | undefined | 是否禁用组件。优先级:Switch.disabled > Form.disabled | N
icon | Array | [] | `0.27.0`。开关的图标;[打开时的图标,关闭时的图标]。TS 类型:`string[]` | N
label | Array | [] | `0.27.0`开关的标签;[打开时的标签,关闭时的标签]。TS 类型:`string[]` | N
label | Array | [] | `0.27.0`开关内容,[开启时内容,关闭时内容]。示例:['开', '关'] 。TS 类型:`string[]` | N
loading | Boolean | false | `0.27.0`。是否处于加载中状态 | N
size | String | medium | `0.27.0`。开关尺寸。可选项:small/medium/large | N
value | String / Number / Boolean | null | 开关值。TS 类型:`SwitchValue` `type SwitchValue = string \| number \| boolean`[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/switch/type.ts) | N
Expand Down
2 changes: 1 addition & 1 deletion packages/products/tdesign-miniprogram/src/switch/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const props: TdSwitchProps = {
type: Array,
value: [],
},
/** 开关的标签;[打开时的标签,关闭时的标签] */
/** 开关内容,[开启时内容,关闭时内容]。示例:['开', '关'] */
label: {
type: Array,
value: [],
Expand Down
2 changes: 1 addition & 1 deletion packages/products/tdesign-miniprogram/src/switch/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface TdSwitchProps<T = SwitchValue> {
value?: string[];
};
/**
* 开关的标签;[打开时的标签,关闭时的标签]
* 开关内容,[开启时内容,关闭时内容]。示例:['开', '关']
* @default []
*/
label?: {
Expand Down
13 changes: 13 additions & 0 deletions packages/products/tdesign-mobile-react/src/switch/defaultProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdSwitchProps } from './type';

export const switchDefaultProps: TdSwitchProps = {
disabled: undefined,
icon: [],
label: [],
loading: false,
size: 'medium',
};
20 changes: 20 additions & 0 deletions packages/products/tdesign-mobile-react/src/switch/switch.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
:: BASE_DOC ::

## API

### Switch Props

name | type | default | description | required
-- | -- | -- | -- | --
className | String | - | className of component | N
style | Object | - | CSS(Cascading Style Sheets),Typescript:`React.CSSProperties` | N
colors | Array | - | `deprecated`。Typescript:`string[]` | N
customValue | Array | - | Typescript:`Array<SwitchValue>` | N
disabled | Boolean | undefined | \- | N
icon | Array | [] | Typescript:`TNode[]`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
label | TNode | [] | Typescript:`Array<string \| TNode> \| TNode<{ value: SwitchValue }>`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
loading | Boolean | false | \- | N
size | String | medium | options: small/medium/large | N
value | String / Number / Boolean | - | Typescript:`T` `type SwitchValue = string \| number \| boolean`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/switch/type.ts) | N
defaultValue | String / Number / Boolean | - | uncontrolled property。Typescript:`T` `type SwitchValue = string \| number \| boolean`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/switch/type.ts) | N
onChange | Function | | Typescript:`(value: T, context: { e: MouseEvent }) => void`<br/> | N
20 changes: 20 additions & 0 deletions packages/products/tdesign-mobile-react/src/switch/switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
:: BASE_DOC ::

## API

### Switch Props

名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
colors | Array | - | 已废弃。自定义颜色,[打开时的颜色,关闭时的颜色]。组件默认颜色为 ['#0052d9', 'rgba(0, 0, 0, .26']。示例:[blue, gray]。TS 类型:`string[]` | N
customValue | Array | - | 用于自定义开关的值,[打开时的值,关闭时的值]。默认为 [true, false]。示例:[1, 0]['open', 'close']。TS 类型:`Array<SwitchValue>` | N
disabled | Boolean | undefined | 是否禁用组件。优先级:Switch.disabled > Form.disabled | N
icon | Array | [] | 开关的图标;[打开时的图标,关闭时的图标]。TS 类型:`TNode[]`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
label | TNode | [] | 开关内容,[开启时内容,关闭时内容]。示例:['开', '关'] 或 (value) => value ? '开' : '关'。TS 类型:`Array<string \| TNode> \| TNode<{ value: SwitchValue }>`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
loading | Boolean | false | 是否处于加载中状态 | N
size | String | medium | 开关尺寸。可选项:small/medium/large | N
value | String / Number / Boolean | - | 开关值。TS 类型:`T` `type SwitchValue = string \| number \| boolean`[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/switch/type.ts) | N
defaultValue | String / Number / Boolean | - | 开关值。非受控属性。TS 类型:`T` `type SwitchValue = string \| number \| boolean`[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/switch/type.ts) | N
onChange | Function | | TS 类型:`(value: T, context: { e: MouseEvent }) => void`<br/>数据发生变化时触发 | N
53 changes: 53 additions & 0 deletions packages/products/tdesign-mobile-react/src/switch/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TNode } from '../common';
import { MouseEvent } from 'react';

export interface TdSwitchProps<T = SwitchValue> {
/**
* 用于自定义开关的值,[打开时的值,关闭时的值]。默认为 [true, false]。示例:[1, 0]、['open', 'close']
*/
customValue?: Array<SwitchValue>;
/**
* 是否禁用组件。优先级:Switch.disabled > Form.disabled
*/
disabled?: boolean;
/**
* 开关的图标;[打开时的图标,关闭时的图标]
* @default []
*/
icon?: TNode[];
/**
* 开关内容,[开启时内容,关闭时内容]。示例:['开', '关'] 或 (value) => value ? '开' : '关'
* @default []
*/
label?: Array<string | TNode> | TNode<{ value: SwitchValue }>;
/**
* 是否处于加载中状态
* @default false
*/
loading?: boolean;
/**
* 开关尺寸
* @default medium
*/
size?: 'small' | 'medium' | 'large';
/**
* 开关值
*/
value?: T;
/**
* 开关值,非受控属性
*/
defaultValue?: T;
/**
* 数据发生变化时触发
*/
onChange?: (value: T, context: { e: MouseEvent<HTMLButtonElement> }) => void;
}

export type SwitchValue = string | number | boolean;
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import { TdToastProps } from './type';

export const toastDefaultProps: TdToastProps = {
attach: 'body',
direction: 'row',
duration: 2000,
overlayProps: {},
placement: 'middle',
preventScrollThrough: false,
showOverlay: false,
Expand Down
15 changes: 11 additions & 4 deletions packages/products/tdesign-mobile-react/src/toast/toast.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@

## API


### Toast Props

name | type | default | description | required
-- | -- | -- | -- | --
className | String | - | className of component | N
style | Object | - | CSS(Cascading Style Sheets),Typescript:`React.CSSProperties` | N
attach | String / Function | 'body' | Typescript:`AttachNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
direction | String | row | options: row/column | N
duration | Number | 2000 | \- | N
icon | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
icon | TElement | - | Typescript:`TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
message | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
overlayProps | Object | {} | Typescript:`OverlayProps `[Overlay API Documents](./overlay?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/toast/type.ts) | N
overlayProps | Object | - | Typescript:`OverlayProps `[Overlay API Documents](./overlay?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/toast/type.ts) | N
placement | String | middle | options: top/middle/bottom | N
preventScrollThrough | Boolean | false | \- | N
showOverlay | Boolean | false | \- | N
theme | String | - | options: loading/success/error | N
onClose | Function | | Typescript:`() => void`<br/> | N
onDestroy | Function | | Typescript:`() => void`<br/> | N

### ToastOptions

name | type | default | description | required
-- | -- | -- | -- | --
attach | String / Function | 'body' | Typescript:`AttachNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
className | String | - | \- | N
style | Object | - | Typescript:`Styles`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
`ToastProps` | \- | - | extends `ToastProps` | N
15 changes: 11 additions & 4 deletions packages/products/tdesign-mobile-react/src/toast/toast.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@

## API


### Toast Props

名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
attach | String / Function | 'body' | 指定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body。TS 类型:`AttachNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
direction | String | row | 图标排列方式。可选项:row/column | N
duration | Number | 2000 | 弹窗显示毫秒数 | N
icon | TNode | - | 自定义图标。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
icon | TElement | - | 自定义图标。TS 类型:`TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
message | TNode | - | 弹窗显示文字。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
overlayProps | Object | {} | 遮罩层属性,透传至 Overlay。TS 类型:`OverlayProps `[Overlay API Documents](./overlay?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/toast/type.ts) | N
overlayProps | Object | - | 遮罩层属性,透传至 Overlay。TS 类型:`OverlayProps `[Overlay API Documents](./overlay?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/toast/type.ts) | N
placement | String | middle | 弹窗展示位置。可选项: top/middle/bottom | N
preventScrollThrough | Boolean | false | 防止滚动穿透,即不允许点击和滚动 | N
showOverlay | Boolean | false | 是否显示遮罩层 | N
theme | String | - | 提示类型。可选项:loading/success/error | N
onClose | Function | | TS 类型:`() => void`<br/>轻提示隐藏的时候触发 | N
onDestroy | Function | | TS 类型:`() => void`<br/>轻提示销毁的时候触发 | N

### ToastOptions

名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
attach | String / Function | 'body' | 指定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body。TS 类型:`AttachNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
className | String | - | 弹框类名,示例:'t-class-toast-first t-class-toast-second' | N
style | Object | - | 弹框 style 属性,输入 [CSSStyleDeclaration.cssText](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/cssText)。TS 类型:`Styles`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
`ToastProps` | \- | - | 继承 `ToastProps` 中的全部属性 | N
27 changes: 19 additions & 8 deletions packages/products/tdesign-mobile-react/src/toast/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
* */

import { OverlayProps } from '../overlay';
import { TNode, AttachNode } from '../common';
import { TNode, TElement, Styles, AttachNode } from '../common';

export interface TdToastProps {
/**
* 指定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body
* @default 'body'
*/
attach?: AttachNode;
/**
* 图标排列方式
* @default row
Expand All @@ -26,14 +21,13 @@ export interface TdToastProps {
/**
* 自定义图标
*/
icon?: TNode;
icon?: TElement;
/**
* 弹窗显示文字
*/
message?: TNode;
/**
* 遮罩层属性,透传至 Overlay
* @default {}
*/
overlayProps?: OverlayProps;
/**
Expand Down Expand Up @@ -64,3 +58,20 @@ export interface TdToastProps {
*/
onDestroy?: () => void;
}

export interface ToastOptions extends TdToastProps {
/**
* 指定挂载节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body
* @default 'body'
*/
attach?: AttachNode;
/**
* 弹框类名,示例:'t-class-toast-first t-class-toast-second'
* @default ''
*/
className?: string;
/**
* 弹框 style 属性,输入 [CSSStyleDeclaration.cssText](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/cssText)
*/
style?: Styles;
}
4 changes: 2 additions & 2 deletions packages/products/tdesign-mobile-vue/src/switch/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export default {
type: Array as PropType<TdSwitchProps['icon']>,
default: (): TdSwitchProps['icon'] => [],
},
/** 开关的标签;[打开时的标签,关闭时的标签] */
/** 开关内容,[开启时内容,关闭时内容]。示例:['开', '关'] 或 (value) => value ? '开' : '关' */
label: {
type: Array as PropType<TdSwitchProps['label']>,
type: [Array, Function] as PropType<TdSwitchProps['label']>,
default: (): TdSwitchProps['label'] => [],
},
/** 是否处于加载中状态 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name | type | default | description | required
customValue | Array | - | Typescript:`Array<SwitchValue>` | N
disabled | Boolean | undefined | \- | N
icon | Array | [] | Typescript:`TNode[]`[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
label | Array | [] | Typescript:`string[]` | N
label | Array / Slot / Function | [] | Typescript:`Array<string \| TNode> \| TNode<{ value: SwitchValue }>`[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
loading | Boolean | false | \- | N
size | String | medium | options: small/medium/large | N
value | String / Number / Boolean | - | `v-model` and `v-model:value` is supported。Typescript:`T` `type SwitchValue = string \| number \| boolean`[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/switch/type.ts) | N
Expand Down
2 changes: 1 addition & 1 deletion packages/products/tdesign-mobile-vue/src/switch/switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
customValue | Array | - | 用于自定义开关的值,[打开时的值,关闭时的值]。默认为 [true, false]。示例:[1, 0]['open', 'close']。TS 类型:`Array<SwitchValue>` | N
disabled | Boolean | undefined | 是否禁用组件。优先级:Switch.disabled > Form.disabled | N
icon | Array | [] | 开关的图标;[打开时的图标,关闭时的图标]。TS 类型:`TNode[]`[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
label | Array | [] | 开关的标签;[打开时的标签,关闭时的标签]TS 类型:`string[]` | N
label | Array / Slot / Function | [] | 开关内容,[开启时内容,关闭时内容]。示例:['开', '关'] 或 (value) => value ? '开' : '关'。TS 类型:`Array<string \| TNode> \| TNode<{ value: SwitchValue }>`[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
loading | Boolean | false | 是否处于加载中状态 | N
size | String | medium | 开关尺寸。可选项:small/medium/large | N
value | String / Number / Boolean | - | 开关值。支持语法糖 `v-model``v-model:value`。TS 类型:`T` `type SwitchValue = string \| number \| boolean`[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/switch/type.ts) | N
Expand Down
4 changes: 2 additions & 2 deletions packages/products/tdesign-mobile-vue/src/switch/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export interface TdSwitchProps<T = SwitchValue> {
*/
icon?: TNode[];
/**
* 开关的标签;[打开时的标签,关闭时的标签]
* 开关内容,[开启时内容,关闭时内容]。示例:['开', '关'] 或 (value) => value ? '开' : '关'
* @default []
*/
label?: string[];
label?: Array<string | TNode> | TNode<{ value: SwitchValue }>;
/**
* 是否处于加载中状态
* @default false
Expand Down
3 changes: 1 addition & 2 deletions packages/products/tdesign-mobile-vue/src/toast/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default {
},
/** 自定义图标 */
icon: {
type: [String, Function] as PropType<TdToastProps['icon']>,
type: Function as PropType<TdToastProps['icon']>,
},
/** 弹窗显示文字 */
message: {
Expand All @@ -33,7 +33,6 @@ export default {
/** 遮罩层属性,透传至 Overlay */
overlayProps: {
type: Object as PropType<TdToastProps['overlayProps']>,
default: () => ({}),
},
/** 弹窗展示位置 */
placement: {
Expand Down
4 changes: 2 additions & 2 deletions packages/products/tdesign-mobile-vue/src/toast/toast.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ name | type | default | description | required
-- | -- | -- | -- | --
direction | String | row | options: row/column | N
duration | Number | 2000 | \- | N
icon | String / Slot / Function | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
icon | Slot / Function | - | Typescript:`TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
message | String / Slot / Function | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
overlayProps | Object | {} | Typescript:`OverlayProps `[Overlay API Documents](./overlay?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/toast/type.ts) | N
overlayProps | Object | - | Typescript:`OverlayProps `[Overlay API Documents](./overlay?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/toast/type.ts) | N
placement | String | middle | options: top/middle/bottom | N
preventScrollThrough | Boolean | false | \- | N
showOverlay | Boolean | false | \- | N
Expand Down
4 changes: 2 additions & 2 deletions packages/products/tdesign-mobile-vue/src/toast/toast.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
-- | -- | -- | -- | --
direction | String | row | 图标排列方式。可选项:row/column | N
duration | Number | 2000 | 弹窗显示毫秒数 | N
icon | String / Slot / Function | - | 自定义图标。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
icon | Slot / Function | - | 自定义图标。TS 类型:`TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
message | String / Slot / Function | - | 弹窗显示文字。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
overlayProps | Object | {} | 遮罩层属性,透传至 Overlay。TS 类型:`OverlayProps `[Overlay API Documents](./overlay?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/toast/type.ts) | N
overlayProps | Object | - | 遮罩层属性,透传至 Overlay。TS 类型:`OverlayProps `[Overlay API Documents](./overlay?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/toast/type.ts) | N
placement | String | middle | 弹窗展示位置。可选项: top/middle/bottom | N
preventScrollThrough | Boolean | false | 防止滚动穿透,即不允许点击和滚动 | N
showOverlay | Boolean | false | 是否显示遮罩层 | N
Expand Down
Loading

0 comments on commit b95fcd0

Please sign in to comment.