Skip to content

Commit 6d1a385

Browse files
committed
feat: modal.confirm content ant title support function #824
1 parent f5d1fa6 commit 6d1a385

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

components/modal/ConfirmDialog.jsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ export default {
8181
<div class={`${contentPrefixCls}-body-wrapper`}>
8282
<div class={`${contentPrefixCls}-body`}>
8383
<Icon type={iconType} />
84-
<span class={`${contentPrefixCls}-title`}>{props.title}</span>
85-
<div class={`${contentPrefixCls}-content`}>{props.content}</div>
84+
<span class={`${contentPrefixCls}-title`}>
85+
{typeof props.title === 'function' ? props.title(h) : props.title}
86+
</span>
87+
<div class={`${contentPrefixCls}-content`}>
88+
{typeof props.content === 'function' ? props.content(h) : props.content}
89+
</div>
8690
</div>
8791
<div class={`${contentPrefixCls}-btns`}>
8892
{cancelButton}

components/modal/demo/confirm.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default {
2929
showConfirm() {
3030
this.$confirm({
3131
title: 'Do you Want to delete these items?',
32-
content: 'Some descriptions',
32+
content: h => <div style="color:red;">Some descriptions</div>,
3333
onOk() {
3434
console.log('OK');
3535
},

components/modal/index.en-US.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ The properties of the object are follows:
5555
| centered | Centered Modal | Boolean | `false` |
5656
| closable | Whether a close (x) button is visible on top right of the modal dialog or not | boolean | `false` |
5757
| class | class of container | string | - |
58-
| content | Content | string\|vNode | - |
58+
| content | Content | string\|vNode \|function(h) | - |
5959
| iconType | Icon `type` of the Icon component | string | `question-circle` |
6060
| keyboard | Whether support press esc to close | Boolean | true |
6161
| maskClosable | Whether to close the modal dialog when the mask (area outside the modal) is clicked | Boolean | `false` |
6262
| okText | Text of the OK button | string | `OK` |
6363
| okType | Button `type` of the OK button | string | `primary` |
6464
| okButtonProps | The ok button props | [ButtonProps](/components/button) | - |
6565
| cancelButtonProps | The cancel button props | [ButtonProps](/components/button) | - |
66-
| title | Title | string\|vNode | - |
66+
| title | Title | string\|vNode \|function(h) | - |
6767
| width | Width of the modal dialog | string\|number | 416 |
6868
| zIndex | The `z-index` of the Modal | Number | 1000 |
6969
| onCancel | Specify a function that will be called when the user clicks the Cancel button. The parameter of this function is a function whose execution should include closing the dialog. You can also just return a promise and when the promise is resolved, the modal dialog will also be closed | function | - |

components/modal/index.zh-CN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@
5454
| centered | 垂直居中展示 Modal | Boolean | `false` |
5555
| closable | 是否显示右上角的关闭按钮 | boolean | `false` |
5656
| class | 容器类名 | string | - |
57-
| content | 内容 | string\|vNode ||
57+
| content | 内容 | string \|vNode \|function(h) ||
5858
| iconType | 图标 Icon 类型 | string | question-circle |
5959
| maskClosable | 点击蒙层是否允许关闭 | Boolean | `false` |
6060
| keyboard | 是否支持键盘esc关闭 | boolean | true |
6161
| okText | 确认按钮文字 | string | 确定 |
6262
| okType | 确认按钮类型 | string | primary |
6363
| okButtonProps | ok 按钮 props | [ButtonProps](/components/button) | - |
6464
| cancelButtonProps | cancel 按钮 props | [ButtonProps](/components/button) | - |
65-
| title | 标题 | string\|vNode ||
65+
| title | 标题 | string\|vNode \|function(h) ||
6666
| width | 宽度 | string\|number | 416 |
6767
| zIndex | 设置 Modal 的 `z-index` | Number | 1000 |
6868
| onCancel | 取消回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function ||

types/modal.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export interface ModalOptions {
3737

3838
/**
3939
* Modal content
40-
* @type string | VNode
40+
* @type string | VNode | (h) => VNode
4141
*/
42-
content?: string | VNode;
42+
content?: any;
4343

4444
/**
4545
* Icon type of the Icon component
@@ -90,9 +90,9 @@ export interface ModalOptions {
9090

9191
/**
9292
* Title
93-
* @type string | VNode
93+
* @type string | VNode | (h) => VNode
9494
*/
95-
title?: string | VNode;
95+
title?: any;
9696

9797
/**
9898
* Width of the modal dialog

0 commit comments

Comments
 (0)