Skip to content

Commit 6a96f3b

Browse files
feat(Dialog): add lazy props (#603)
* feat(Dialog): add `lazy` props * feat: 添加 react 支持 lazy * chore: 生成配置文件 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 52e362f commit 6a96f3b

File tree

14 files changed

+407
-4
lines changed

14 files changed

+407
-4
lines changed

db/TDesign.db

0 Bytes
Binary file not shown.

packages/products/tdesign-react/packages/components/dialog/defaultProps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const dialogDefaultProps: TdDialogProps = {
1414
footer: true,
1515
forceRender: false,
1616
header: true,
17+
lazy: false,
1718
mode: 'modal',
1819
placement: 'top',
1920
preventScrollThrough: true,

packages/products/tdesign-react/packages/components/dialog/dialog.en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ draggable | Boolean | false | \- | N
3434
footer | TNode | true | Typescript:`boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
3535
forceRender | Boolean | false | to force render Dialog | N
3636
header | TNode | true | Typescript:`string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
37+
lazy | Boolean | false | Enable Dialog lazy loading, the contents of the dialog box are not rendered when enable | N
3738
mode | String | modal | options: modal/modeless/normal/full-screen | N
3839
placement | String | top | options: top/center | N
3940
preventScrollThrough | Boolean | true | \- | N

packages/products/tdesign-react/packages/components/dialog/dialog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ draggable | Boolean | false | 对话框是否可以拖拽(仅在非模态对
3434
footer | TNode | true | 底部操作栏,默认会有“确认”和“取消”两个按钮。值为 true 显示默认操作按钮,值为 false 不显示任何内容,值类型为 Function 表示自定义底部内容。TS 类型:`boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
3535
forceRender | Boolean | false | 是否强制渲染Dialog | N
3636
header | TNode | true | 头部内容。值为 true 显示空白头部,值为 false 不显示任何内容,值类型为 string 则直接显示值,值类型为 Function 表示自定义头部内容。TS 类型:`string \| boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
37+
lazy | Boolean | false | 是否启用对话框懒加载,启用时对话框内的内容不渲染 | N
3738
mode | String | modal | 对话框类型,有 4 种:模态对话框、非模态对话框、普通对话框、全屏对话框。弹出「模态对话框」时,只能操作对话框里面的内容,不能操作其他内容。弹出「非模态对话框」时,则可以操作页面内所有内容。「普通对话框」是指没有脱离文档流的对话框,可以在这个基础上开发更多的插件。可选项:modal/modeless/normal/full-screen | N
3839
placement | String | top | 对话框位置,内置两种:垂直水平居中显示 和 靠近顶部(top:20%)显示。默认情况,为避免贴顶或贴底,顶部和底部距离最小为 `48px`,可通过调整 `top` 覆盖默认大小。可选项:top/center | N
3940
preventScrollThrough | Boolean | true | 防止滚动穿透 | N

packages/products/tdesign-react/packages/components/dialog/type.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ export interface TdDialogProps {
8484
* @default true
8585
*/
8686
header?: TNode;
87+
/**
88+
* 是否启用对话框懒加载,启用时对话框内的内容不渲染
89+
* @default false
90+
*/
91+
lazy?: boolean;
8792
/**
8893
* 对话框类型,有 4 种:模态对话框、非模态对话框、普通对话框、全屏对话框。弹出「模态对话框」时,只能操作对话框里面的内容,不能操作其他内容。弹出「非模态对话框」时,则可以操作页面内所有内容。「普通对话框」是指没有脱离文档流的对话框,可以在这个基础上开发更多的插件
8994
* @default modal

packages/products/tdesign-vue-next/packages/components/dialog/dialog.en-US.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,26 @@
66

77
name | type | default | description | required
88
-- | -- | -- | -- | --
9+
body | String / Slot / Function | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
10+
cancelBtn | String / Object / Slot / Function | - | Typescript:`string \| ButtonProps \| TNode \| null`[Button API Documents](./button?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/dialog/type.ts) | N
11+
closeBtn | String / Boolean / Slot / Function | true | Typescript:`string \| ButtonProps \| TNode \| null`[Button API Documents](./button?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/dialog/type.ts) | N
12+
confirmBtn | String / Object / Slot / Function | true | Typescript:`string \| ButtonProps \| TNode \| null`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
13+
confirmLoading | Boolean | - | confirm button loading status。Typescript:`string \| ButtonProps \| TNode \| null`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
14+
footer | Boolean / Slot / Function | true | Typescript:`boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
15+
header | String / Boolean / Slot / Function | true | Typescript:`string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
16+
theme | String | default | options: default/info/warning/danger/success | N
917
`Pick<DialogProps, 'body' \| 'cancelBtn' \| 'closeBtn' \| 'confirmBtn' \| 'footer' \| 'header' \| 'theme' \| 'onCancel' \| 'onCloseBtnClick' \| 'onConfirm' \| 'confirmLoading'>` | String / Slot / Function | - | extends `Pick<DialogProps, 'body' \| 'cancelBtn' \| 'closeBtn' \| 'confirmBtn' \| 'footer' \| 'header' \| 'theme' \| 'onCancel' \| 'onCloseBtnClick' \| 'onConfirm' \| 'confirmLoading'>`。Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
18+
onCancel | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/>options: default/info/warning/danger/success | N
19+
onCloseBtnClick | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/>options: default/info/warning/danger/success | N
20+
onConfirm | Function | | Typescript:`(context: { e: MouseEvent \| KeyboardEvent }) => void`<br/>options: default/info/warning/danger/success | N
21+
22+
### DialogCard Events
23+
24+
name | params | description
25+
-- | -- | --
26+
cancel | `(context: { e: MouseEvent })` | options: default/info/warning/danger/success
27+
close-btn-click | `(context: { e: MouseEvent })` | options: default/info/warning/danger/success
28+
confirm | `(context: { e: MouseEvent \| KeyboardEvent })` | options: default/info/warning/danger/success
1029

1130

1231
### Dialog Props
@@ -29,6 +48,7 @@ dialogStyle | Object | - | Styles that apply to the dialog box itself。Typescri
2948
draggable | Boolean | false | \- | N
3049
footer | Boolean / Slot / Function | true | Typescript:`boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
3150
header | String / Boolean / Slot / Function | true | Typescript:`string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
51+
lazy | Boolean | false | Enable Dialog lazy loading, the contents of the dialog box are not rendered when enable | N
3252
mode | String | modal | options: modal/modeless/normal/full-screen | N
3353
placement | String | top | options: top/center | N
3454
preventScrollThrough | Boolean | true | \- | N

packages/products/tdesign-vue-next/packages/components/dialog/dialog.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,26 @@
66

77
名称 | 类型 | 默认值 | 描述 | 必传
88
-- | -- | -- | -- | --
9+
body | String / Slot / Function | - | 对话框内容。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
10+
cancelBtn | String / Object / Slot / Function | - | 取消按钮,可自定义。值为 null 则不显示取消按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。使用 TNode 自定义按钮时,需自行控制取消事件。TS 类型:`string \| ButtonProps \| TNode \| null`[Button API Documents](./button?tab=api)[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/dialog/type.ts) | N
11+
closeBtn | String / Boolean / Slot / Function | true | 关闭按钮,可以自定义。值为 true 显示默认关闭按钮,值为 false 不显示关闭按钮。值类型为 string 则直接显示值,如:“关闭”。值类型为 TNode,则表示呈现自定义按钮示例。TS 类型:`string \| ButtonProps \| TNode \| null`[Button API Documents](./button?tab=api)[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/dialog/type.ts) | N
12+
confirmBtn | String / Object / Slot / Function | true | 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。使用 TNode 自定义按钮时,需自行控制确认事件。TS 类型:`string \| ButtonProps \| TNode \| null`[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
13+
confirmLoading | Boolean | - | 确认按钮加载状态。TS 类型:`string \| ButtonProps \| TNode \| null`[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
14+
footer | Boolean / Slot / Function | true | 底部操作栏,默认会有“确认”和“取消”两个按钮。值为 true 显示默认操作按钮,值为 false 不显示任何内容,值类型为 Function 表示自定义底部内容。TS 类型:`boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
15+
header | String / Boolean / Slot / Function | true | 头部内容。值为 true 显示空白头部,值为 false 不显示任何内容,值类型为 string 则直接显示值,值类型为 Function 表示自定义头部内容。TS 类型:`string \| boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
16+
theme | String | default | 对话框风格。可选项:default/info/warning/danger/success | N
917
`Pick<DialogProps, 'body' \| 'cancelBtn' \| 'closeBtn' \| 'confirmBtn' \| 'footer' \| 'header' \| 'theme' \| 'onCancel' \| 'onCloseBtnClick' \| 'onConfirm' \| 'confirmLoading'>` | String / Slot / Function | - | 继承 `Pick<DialogProps, 'body' \| 'cancelBtn' \| 'closeBtn' \| 'confirmBtn' \| 'footer' \| 'header' \| 'theme' \| 'onCancel' \| 'onCloseBtnClick' \| 'onConfirm' \| 'confirmLoading'>` 中的全部属性。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
18+
onCancel | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>如果“取消”按钮存在,则点击“取消”按钮时触发,同时触发关闭事件。可选项:default/info/warning/danger/success | N
19+
onCloseBtnClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>点击右上角关闭按钮时触发。可选项:default/info/warning/danger/success | N
20+
onConfirm | Function | | TS 类型:`(context: { e: MouseEvent \| KeyboardEvent }) => void`<br/>如果“确认”按钮存在,则点击“确认”按钮时触发,或者键盘按下回车键时触发。可选项:default/info/warning/danger/success | N
21+
22+
### DialogCard Events
23+
24+
名称 | 参数 | 描述
25+
-- | -- | --
26+
cancel | `(context: { e: MouseEvent })` | 如果“取消”按钮存在,则点击“取消”按钮时触发,同时触发关闭事件。可选项:default/info/warning/danger/success
27+
close-btn-click | `(context: { e: MouseEvent })` | 点击右上角关闭按钮时触发。可选项:default/info/warning/danger/success
28+
confirm | `(context: { e: MouseEvent \| KeyboardEvent })` | 如果“确认”按钮存在,则点击“确认”按钮时触发,或者键盘按下回车键时触发。可选项:default/info/warning/danger/success
1029

1130

1231
### Dialog Props
@@ -29,6 +48,7 @@ dialogStyle | Object | - | 作用于对话框本身的样式。TS 类型:`Styl
2948
draggable | Boolean | false | 对话框是否可以拖拽(仅在非模态对话框时有效) | N
3049
footer | Boolean / Slot / Function | true | 底部操作栏,默认会有“确认”和“取消”两个按钮。值为 true 显示默认操作按钮,值为 false 不显示任何内容,值类型为 Function 表示自定义底部内容。TS 类型:`boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
3150
header | String / Boolean / Slot / Function | true | 头部内容。值为 true 显示空白头部,值为 false 不显示任何内容,值类型为 string 则直接显示值,值类型为 Function 表示自定义头部内容。TS 类型:`string \| boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N
51+
lazy | Boolean | false | 是否启用对话框懒加载,启用时对话框内的内容不渲染 | N
3252
mode | String | modal | 对话框类型,有 4 种:模态对话框、非模态对话框、普通对话框、全屏对话框。弹出「模态对话框」时,只能操作对话框里面的内容,不能操作其他内容。弹出「非模态对话框」时,则可以操作页面内所有内容。「普通对话框」是指没有脱离文档流的对话框,可以在这个基础上开发更多的插件。可选项:modal/modeless/normal/full-screen | N
3353
placement | String | top | 对话框位置,内置两种:垂直水平居中显示 和 靠近顶部(top:20%)显示。默认情况,为避免贴顶或贴底,顶部和底部距离最小为 `48px`,可通过调整 `top` 覆盖默认大小。可选项:top/center | N
3454
preventScrollThrough | Boolean | true | 防止滚动穿透 | N

packages/products/tdesign-vue-next/packages/components/dialog/props.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export default {
7373
type: [String, Boolean, Function] as PropType<TdDialogProps['header']>,
7474
default: true as TdDialogProps['header'],
7575
},
76+
/** 是否启用对话框懒加载,启用时对话框内的内容不渲染 */
77+
lazy: Boolean,
7678
/** 对话框类型,有 4 种:模态对话框、非模态对话框、普通对话框、全屏对话框。弹出「模态对话框」时,只能操作对话框里面的内容,不能操作其他内容。弹出「非模态对话框」时,则可以操作页面内所有内容。「普通对话框」是指没有脱离文档流的对话框,可以在这个基础上开发更多的插件 */
7779
mode: {
7880
type: String as PropType<TdDialogProps['mode']>,

0 commit comments

Comments
 (0)