Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
京东前端
nutui-react
提交
28a11074
N
nutui-react
项目概览
京东前端
/
nutui-react
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nutui-react
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
28a11074
编写于
7月 26, 2022
作者:
Y
yangjinjun3
提交者:
GitHub
7月 26, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 弹框增加onClickSelf事件 (#172)
上级
b4fc286c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
39 addition
and
15 deletion
+39
-15
src/packages/dialog/Content.tsx
src/packages/dialog/Content.tsx
+20
-4
src/packages/dialog/DialogWrap.tsx
src/packages/dialog/DialogWrap.tsx
+1
-0
src/packages/dialog/config.ts
src/packages/dialog/config.ts
+9
-5
src/packages/dialog/dialog.tsx
src/packages/dialog/dialog.tsx
+8
-6
src/packages/dialog/doc.md
src/packages/dialog/doc.md
+1
-0
未找到文件。
src/packages/dialog/Content.tsx
浏览文件 @
28a11074
...
...
@@ -5,14 +5,23 @@ interface ContentProps {
visible
?:
boolean
title
?:
ReactNode
footer
?:
ReactNode
textAlign
?:
any
textAlign
?:
string
footerDirection
?:
string
onClickSelf
?:
()
=>
void
}
export
const
Content
:
FunctionComponent
<
Partial
<
ContentProps
>
&
HTMLAttributes
<
HTMLDivElement
>
>
=
(
props
)
=>
{
const
{
visible
,
title
,
footer
,
textAlign
,
footerDirection
,
children
}
=
props
const
{
visible
,
title
,
footer
,
textAlign
,
footerDirection
,
onClickSelf
,
children
,
}
=
props
let
headerNode
:
ReactNode
if
(
title
)
{
...
...
@@ -32,14 +41,21 @@ export const Content: FunctionComponent<
)
}
const
handleClick
=
()
=>
{
onClickSelf
&&
onClickSelf
()
}
return
(
<
div
className
=
"nut-dialog__outer"
>
<
div
className
=
"nut-dialog__outer"
onClick
=
{
handleClick
}
>
<
div
className
=
"nut-dialog"
style
=
{
{
display
:
visible
?
'
flex
'
:
'
none
'
}
}
>
{
headerNode
}
<
div
className
=
"nut-dialog__content"
style
=
{
{
textAlign
}
}
>
<
div
className
=
"nut-dialog__content"
style
=
{
{
textAlign
}
as
React
.
CSSProperties
}
>
<
div
>
{
children
}
</
div
>
</
div
>
{
footerNode
}
...
...
src/packages/dialog/DialogWrap.tsx
浏览文件 @
28a11074
...
...
@@ -11,6 +11,7 @@ interface DialogWrapProps {
closeOnClickOverlay
?:
boolean
onCancel
?:
()
=>
void
onClosed
?:
()
=>
void
onClickSelf
?:
()
=>
void
}
export
const
DialogWrap
:
FunctionComponent
<
...
...
src/packages/dialog/config.ts
浏览文件 @
28a11074
...
...
@@ -26,16 +26,20 @@ export interface DialogProps {
noFooter
?:
boolean
closeOnClickOverlay
?:
boolean
cancelAutoClose
?:
boolean
textAlign
?:
any
textAlign
?:
string
footerDirection
?:
string
lockScroll
?:
boolean
onClosed
?:
()
=>
void
onOk
?:
(
e
?:
MouseEvent
)
=>
Promise
<
any
>
|
void
onOk
?:
(
e
?:
MouseEvent
)
=>
Promise
<
()
=>
void
>
|
void
onCancel
?:
()
=>
void
onConfirm
?:
(
e
?:
MouseEvent
)
=>
Promise
<
any
>
|
void
onClickSelf
?:
()
=>
void
onConfirm
?:
(
e
?:
MouseEvent
)
=>
Promise
<
()
=>
void
>
|
void
}
export
type
DialogReturnProps
=
{
update
:
Function
;
close
:
Function
}
export
type
DialogReturnProps
=
{
update
:
(
newConfig
:
ConfirmProps
)
=>
void
close
:
()
=>
void
}
export
interface
ConfirmProps
extends
DialogProps
{
content
?:
ReactNode
...
...
@@ -52,4 +56,4 @@ export interface DialogComponent
destroyAll
:
()
=>
void
}
export
const
destroyList
:
Array
<
Function
>
=
[]
export
const
destroyList
:
Array
<
()
=>
void
>
=
[]
src/packages/dialog/dialog.tsx
浏览文件 @
28a11074
...
...
@@ -51,10 +51,11 @@ const BaseDialog: ForwardRefRenderFunction<
...
restProps
}
=
props
const
renderFooter
=
()
=>
{
if
(
footer
===
null
)
return
const
renderFooter
=
function
()
{
if
(
footer
===
null
)
return
''
const
handleCancel
=
()
=>
{
const
handleCancel
=
function
(
e
:
MouseEvent
)
{
e
.
stopPropagation
()
if
(
!
cancelAutoClose
)
return
onClosed
?.()
...
...
@@ -64,7 +65,8 @@ const BaseDialog: ForwardRefRenderFunction<
}
}
const
handleOk
=
(
e
?:
any
)
=>
{
const
handleOk
=
function
(
e
:
MouseEvent
)
{
e
.
stopPropagation
()
onClosed
?.()
onOk
?.(
e
)
if
(
lockScroll
&&
visible
)
{
...
...
@@ -80,7 +82,7 @@ const BaseDialog: ForwardRefRenderFunction<
plain
type
=
"primary"
className
=
"nut-dialog__footer-cancel"
onClick
=
{
(
)
=>
handleCancel
(
)
}
onClick
=
{
(
e
)
=>
handleCancel
(
e
)
}
>
{
cancelText
||
locale
.
cancel
}
</
Button
>
...
...
@@ -93,7 +95,7 @@ const BaseDialog: ForwardRefRenderFunction<
disabled
:
okBtnDisabled
,
})
}
disabled
=
{
okBtnDisabled
}
onClick
=
{
(
)
=>
handleOk
(
)
}
onClick
=
{
(
e
)
=>
handleOk
(
e
)
}
>
{
okText
||
locale
.
confirm
}
</
Button
>
...
...
src/packages/dialog/doc.md
浏览文件 @
28a11074
...
...
@@ -106,3 +106,4 @@ return <>
| onOk | 确定按钮回调 | (e?: MouseEvent) => Promise | void |
| onCancel | 取消按钮回调 | () => void |
| onClosed | 关闭回调,任何情况关闭弹窗都会触发 | () => void |
| onClickSelf | 点击自身回调 | () => void |
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录