Skip to content

Commit

Permalink
feat(dialog): add dialogClassName API
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Feb 23, 2024
1 parent 191359b commit e2b7980
Show file tree
Hide file tree
Showing 15 changed files with 359 additions and 242 deletions.
Binary file modified db/TDesign.db
Binary file not shown.
14 changes: 6 additions & 8 deletions packages/products/tdesign-react/src/dialog/defaultProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdDialogCardProps, TdDialogProps } from './type';

export const dialogCardDefaultProps: TdDialogCardProps = {
closeBtn: true,
footer: true,
header: true,
theme: 'default',
};
import { TdDialogProps } from './type';

export const dialogDefaultProps: TdDialogProps = {
closeBtn: true,
closeOnEscKeydown: undefined,
closeOnOverlayClick: undefined,
confirmLoading: undefined,
destroyOnClose: false,
draggable: false,
footer: true,
header: true,
mode: 'modal',
placement: 'top',
preventScrollThrough: true,
showInAttachedElement: false,
showOverlay: true,
theme: 'default',
};
33 changes: 18 additions & 15 deletions packages/products/tdesign-react/src/dialog/dialog.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@ name | type | default | description | required
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,Typescript:`React.CSSProperties` | N
body | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
cancelBtn | TNode | - | Typescript:`string \| ButtonProps \| TNode \| null`[Button API Documents](./button?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/dialog/type.ts) | N
closeBtn | TNode | true | Typescript:`string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
confirmBtn | TNode | - | Typescript:`string \| ButtonProps \| TNode \| null`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
footer | TNode | true | Typescript:`boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
header | TNode | true | Typescript:`string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
theme | String | default | options:default/info/warning/danger/success | N
onCancel | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/> | N
onCloseBtnClick | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/> | N
onConfirm | Function | | Typescript:`(context: { e: MouseEvent \| KeyboardEvent }) => void`<br/> | N
`Pick<DialogProps, 'body' \| 'cancelBtn' \| 'closeBtn' \| 'confirmBtn' \| 'footer' \| 'header' \| 'theme' \| 'onCancel' \| 'onCloseBtnClick' \| 'onConfirm'>` | TNode | - | extends `Pick<DialogProps, 'body' \| 'cancelBtn' \| 'closeBtn' \| 'confirmBtn' \| 'footer' \| 'header' \| 'theme' \| 'onCancel' \| 'onCloseBtnClick' \| 'onConfirm'>`。Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N

### Dialog Props

Expand All @@ -25,24 +16,35 @@ name | type | default | description | required
className | String | - | 类名 | N
style | Object | - | 样式,Typescript:`React.CSSProperties` | N
attach | String / Function | - | Typescript:`AttachNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
body | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
cancelBtn | TNode | - | Typescript:`string \| ButtonProps \| TNode \| null`[Button API Documents](./button?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/dialog/type.ts) | N
children | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
closeOnEscKeydown | Boolean | true | \- | N
closeBtn | TNode | true | Typescript:`string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
closeOnEscKeydown | Boolean | true | trigger dialog close event on `ESC` keydown | N
closeOnOverlayClick | Boolean | true | \- | N
confirmBtn | TNode | - | Typescript:`string \| ButtonProps \| TNode \| null`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
confirmLoading | Boolean | undefined | confirm button loading status | N
confirmOnEnter | Boolean | - | confirm on enter | N
destroyOnClose | Boolean | false | \- | N
dialogClassName | String | - | \- | N
draggable | Boolean | false | \- | N
mode | String | modal | options:modal/modeless/full-screen | N
placement | String | top | options:top/center | N
footer | TNode | true | Typescript:`boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
header | TNode | true | Typescript:`string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
mode | String | modal | options: modal/modeless/full-screen | N
placement | String | top | options: top/center | N
preventScrollThrough | Boolean | true | \- | N
showInAttachedElement | Boolean | false | \- | N
showOverlay | Boolean | true | \- | N
theme | String | default | options: default/info/warning/danger/success | N
top | String / Number | - | \- | N
visible | Boolean | - | \- | N
width | String / Number | - | \- | N
zIndex | Number | - | \- | N
`DialogCardProps` | \- | - | \- | N
onCancel | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/> | N
onClose | Function | | Typescript:`(context: DialogCloseContext) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/dialog/type.ts)。<br/>`type DialogEventSource = 'esc' \| 'close-btn' \| 'cancel' \| 'overlay'`<br/><br/>`interface DialogCloseContext { trigger: DialogEventSource; e: MouseEvent \| KeyboardEvent }`<br/> | N
onCloseBtnClick | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/> | N
onClosed | Function | | Typescript:`() => void`<br/> | N
onConfirm | Function | | Typescript:`(context: { e: MouseEvent \| KeyboardEvent }) => void`<br/> | N
onEscKeydown | Function | | Typescript:`(context: { e: KeyboardEvent }) => void`<br/> | N
onOpened | Function | | Typescript:`() => void`<br/> | N
onOverlayClick | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/> | N
Expand All @@ -54,14 +56,15 @@ name | type | default | description | required
attach | String / Function | 'body' | Typescript:`AttachNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
className | String | - | \- | N
style | Object | - | Typescript:`Styles`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
`Omit<DialogProps, 'attach'>` | \- | - | \- | N
`Omit<DialogProps, 'attach'>` | \- | - | extends `Omit<DialogProps, 'attach'>` | N

### DialogInstance

name | params | return | description
-- | -- | -- | --
destroy | \- | \- | required
hide | \- | \- | required
setConfirmLoading | `(loading: boolean)` | \- | required。set confirm button loading status
show | \- | \- | required
update | `(props: DialogOptions)` | \- | required

Expand Down
27 changes: 15 additions & 12 deletions packages/products/tdesign-react/src/dialog/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
body | TNode | - | 对话框内容。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
cancelBtn | TNode | - | 取消按钮,可自定义。值为 null 则不显示取消按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。使用 TNode 自定义按钮时,需自行控制取消事件。TS 类型:`string \| ButtonProps \| TNode \| null`[Button API Documents](./button?tab=api)[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/dialog/type.ts) | N
closeBtn | TNode | true | 关闭按钮,可以自定义。值为 true 显示默认关闭按钮,值为 false 不显示关闭按钮。值类型为 string 则直接显示值,如:“关闭”。值类型为 TNode,则表示呈现自定义按钮示例。TS 类型:`string \| boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
confirmBtn | TNode | - | 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。使用 TNode 自定义按钮时,需自行控制确认事件。TS 类型:`string \| ButtonProps \| TNode \| null`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
footer | TNode | true | 底部操作栏,默认会有“确认”和“取消”两个按钮。值为 true 显示默认操作按钮,值为 false 不显示任何内容,值类型为 Function 表示自定义底部内容。TS 类型:`boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
header | TNode | true | 头部内容。值为 true 显示空白头部,值为 false 不显示任何内容,值类型为 string 则直接显示值,值类型为 Function 表示自定义头部内容。TS 类型:`string \| boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
theme | String | default | 对话框风格。可选项:default/info/warning/danger/success | N
onCancel | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>如果“取消”按钮存在,则点击“取消”按钮时触发,同时触发关闭事件 | N
onCloseBtnClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>点击右上角关闭按钮时触发 | N
onConfirm | Function | | TS 类型:`(context: { e: MouseEvent \| KeyboardEvent }) => void`<br/>如果“确认”按钮存在,则点击“确认”按钮时触发,或者键盘按下回车键时触发 | N
`Pick<DialogProps, 'body' \| 'cancelBtn' \| 'closeBtn' \| 'confirmBtn' \| 'footer' \| 'header' \| 'theme' \| 'onCancel' \| 'onCloseBtnClick' \| 'onConfirm'>` | TNode | - | 继承 `Pick<DialogProps, 'body' \| 'cancelBtn' \| 'closeBtn' \| 'confirmBtn' \| 'footer' \| 'header' \| 'theme' \| 'onCancel' \| 'onCloseBtnClick' \| 'onConfirm'>` 中的全部属性。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N

### Dialog Props

Expand All @@ -25,24 +16,35 @@ onConfirm | Function | | TS 类型:`(context: { e: MouseEvent \| KeyboardEven
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
attach | String / Function | - | 对话框挂载的节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body。TS 类型:`AttachNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
body | TNode | - | 对话框内容。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
cancelBtn | TNode | - | 取消按钮,可自定义。值为 null 则不显示取消按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。使用 TNode 自定义按钮时,需自行控制取消事件。TS 类型:`string \| ButtonProps \| TNode \| null`[Button API Documents](./button?tab=api)[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/dialog/type.ts) | N
children | TNode | - | 对话框内容,同 body。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
closeBtn | TNode | true | 关闭按钮,可以自定义。值为 true 显示默认关闭按钮,值为 false 不显示关闭按钮。值类型为 string 则直接显示值,如:“关闭”。值类型为 TNode,则表示呈现自定义按钮示例。TS 类型:`string \| boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
closeOnEscKeydown | Boolean | true | 按下 ESC 时是否触发对话框关闭事件 | N
closeOnOverlayClick | Boolean | true | 点击蒙层时是否触发关闭事件 | N
confirmBtn | TNode | - | 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。使用 TNode 自定义按钮时,需自行控制确认事件。TS 类型:`string \| ButtonProps \| TNode \| null`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
confirmLoading | Boolean | undefined | 确认按钮加载状态 | N
confirmOnEnter | Boolean | - | 是否在按下回车键时,触发确认事件 | N
destroyOnClose | Boolean | false | 是否在关闭弹框的时候销毁子元素 | N
dialogClassName | String | - | 弹框元素类名,示例:'t-class-dialog-first t-class-dialog-second' | N
draggable | Boolean | false | 对话框是否可以拖拽(仅在非模态对话框时有效) | N
footer | TNode | true | 底部操作栏,默认会有“确认”和“取消”两个按钮。值为 true 显示默认操作按钮,值为 false 不显示任何内容,值类型为 Function 表示自定义底部内容。TS 类型:`boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
header | TNode | true | 头部内容。值为 true 显示空白头部,值为 false 不显示任何内容,值类型为 string 则直接显示值,值类型为 Function 表示自定义头部内容。TS 类型:`string \| boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
mode | String | modal | 对话框类型,有 3 种:模态对话框、非模态对话框、全屏对话框。弹出「模态对话框」时,只能操作对话框里面的内容,不能操作其他内容。弹出「非模态对话框」时,则可以操作页面内所有内容。「普通对话框」是指没有脱离文档流的对话框,可以在这个基础上开发更多的插件。可选项:modal/modeless/full-screen | N
placement | String | top | 对话框位置,内置两种:垂直水平居中显示 和 靠近顶部(top:20%)显示。默认情况,为避免贴顶或贴底,顶部和底部距离最小为 `48px`,可通过调整 `top` 覆盖默认大小。可选项:top/center | N
preventScrollThrough | Boolean | true | 防止滚动穿透 | N
showInAttachedElement | Boolean | false | 仅在挂载元素中显示抽屉,默认在浏览器可视区域显示。父元素需要有定位属性,如:position: relative | N
showOverlay | Boolean | true | 是否显示遮罩层 | N
theme | String | default | 对话框风格。可选项:default/info/warning/danger/success | N
top | String / Number | - | 用于弹框具体窗口顶部的距离,优先级大于 placement | N
visible | Boolean | - | 控制对话框是否显示 | N
width | String / Number | - | 对话框宽度,示例:320, '500px', '80%' | N
zIndex | Number | - | 对话框层级,Web 侧样式默认为 2500,移动端和小程序样式默认为 1500 | N
`DialogCardProps` | \- | - | 继承 `DialogCardProps` 中的全部 API | N
onCancel | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>如果“取消”按钮存在,则点击“取消”按钮时触发,同时触发关闭事件 | N
onClose | Function | | TS 类型:`(context: DialogCloseContext) => void`<br/>关闭事件,点击取消按钮、点击关闭按钮、点击蒙层、按下 ESC 等场景下触发。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/dialog/type.ts)。<br/>`type DialogEventSource = 'esc' \| 'close-btn' \| 'cancel' \| 'overlay'`<br/><br/>`interface DialogCloseContext { trigger: DialogEventSource; e: MouseEvent \| KeyboardEvent }`<br/> | N
onCloseBtnClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>点击右上角关闭按钮时触发 | N
onClosed | Function | | TS 类型:`() => void`<br/>对话框消失动画效果结束后触发 | N
onConfirm | Function | | TS 类型:`(context: { e: MouseEvent \| KeyboardEvent }) => void`<br/>如果“确认”按钮存在,则点击“确认”按钮时触发,或者键盘按下回车键时触发 | N
onEscKeydown | Function | | TS 类型:`(context: { e: KeyboardEvent }) => void`<br/>按下 ESC 时触发事件 | N
onOpened | Function | | TS 类型:`() => void`<br/>对话框弹出动画效果结束后触发 | N
onOverlayClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>如果蒙层存在,点击蒙层时触发 | N
Expand All @@ -54,14 +56,15 @@ onOverlayClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void
attach | String / Function | 'body' | 对话框挂载的节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body。TS 类型:`AttachNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
className | String | - | 弹框类名,示例:'t-class-dialog-first t-class-dialog-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-react/blob/develop/src/common.ts) | N
`Omit<DialogProps, 'attach'>` | \- | - | 继承 `Omit<DialogProps, 'attach'>` 中的全部 API | N
`Omit<DialogProps, 'attach'>` | \- | - | 继承 `Omit<DialogProps, 'attach'>` 中的全部属性 | N

### DialogInstance

名称 | 参数 | 返回值 | 描述
-- | -- | -- | --
destroy | \- | \- | 必需。销毁弹框
hide | \- | \- | 必需。隐藏弹框
setConfirmLoading | `(loading: boolean)` | \- | 必需。设置确认按钮加载状态
show | \- | \- | 必需。显示弹框
update | `(props: DialogOptions)` | \- | 必需。更新弹框内容

Expand Down
Loading

0 comments on commit e2b7980

Please sign in to comment.