Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: dialog #945

Merged
merged 26 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
545731c
refactor: dialog
xiaoyatong Apr 24, 2023
9cd5c91
refactor: dialog
xiaoyatong Apr 24, 2023
fb71a41
feat: 文档
xiaoyatong Apr 24, 2023
6a08882
fix: 文档
xiaoyatong Apr 26, 2023
89098cc
feat: 增加demo,支持函数式调用下 关闭对话框。
xiaoyatong Apr 26, 2023
a0108d9
fix: overlay 组件 显示声明 onclick,修订lockScroll 使用等。
xiaoyatong Apr 27, 2023
241d242
Merge branch 'jdf2e:next' into next
xiaoyatong Apr 27, 2023
5f107ad
fix: popup组件集成overlay 属性,修改taro的分类目录。
xiaoyatong Apr 27, 2023
26400c5
Merge branch 'jdf2e:next' into next
xiaoyatong Apr 27, 2023
092dc4d
fix: 修改popup demo
xiaoyatong Apr 27, 2023
e1451ba
Merge branch 'jdf2e:next' into next
xiaoyatong Apr 28, 2023
1feaabb
Merge branch 'next' into next-dialog
xiaoyatong Apr 28, 2023
7c21279
fix: 删 onclick,继承overlay
xiaoyatong Apr 28, 2023
d3f493d
fix: 适配taro
xiaoyatong Apr 28, 2023
84e66be
fix: 调整demo和文档。
xiaoyatong Apr 28, 2023
4f20de1
fix: 使用dialog 的标签时,会默认把页面锁住。已修改,只有弹出时才可以锁。
xiaoyatong Apr 28, 2023
a8d859c
feat: 增加关闭或取消前的方法调用。
xiaoyatong Apr 28, 2023
782ed2e
docs: 文档修改。
xiaoyatong Apr 28, 2023
bfe36e8
fix: 增加 默认值为true,文件命名为 小写。
xiaoyatong Apr 28, 2023
46d458a
feat: change case
xiaoyatong Apr 28, 2023
bc4931e
Delete Confirm.tsx
xiaoyatong Apr 28, 2023
7178bd7
Delete Content.taro.tsx
xiaoyatong Apr 28, 2023
de892a7
Delete Content.tsx
xiaoyatong Apr 28, 2023
14f81b3
Delete DialogWrap.taro.tsx
xiaoyatong Apr 28, 2023
4a8a2da
Delete DialogWrap.tsx
xiaoyatong Apr 28, 2023
c7fce58
docs: 修改文档
xiaoyatong Apr 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions migrate-from-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@
- distance 重命名为 threshold
- 移除 isAnimation,通过 duration 设置 0 实现无动画效果
#### Dialog
- 修改 okText 为 confirmText,规范命名。
- 修改 mask 为 overlay,组件库中统一使用 Overlay 组件作为遮罩层,并使用 overlay 作为是否展示遮罩层的属性值。
- 修改 closeOnClickOverlay 为 closeOnOverlayClick,组件库统一到该属性。
- 修改 noOkBtn 为 hideConfirmButton,初始值不变,依然表示是否隐藏确认按钮,主要是为了语义化更强。
- 修改 noCancelBtn 为 hideCancelButton,初始值不变,依然表示是否隐藏取消按钮,主要是为了语义化更强。
- 修改 okBtnDisabled 为 disableConfirmButton,初始值不变,依然表示是否禁用确认按钮,主要是为了语义化更强。
- 删除 noFooter,使用 footer 统一处理,当 footer 为空时,及可替代该值。目前 noFooter 也需要手动声明是否为 noFooter;修改后需手动指出 footer={null}
- 删除 textAlign,改用样式变量 --nutui-dialog-content-text-align 或 SCSS 变量 $dialog-content-text-align 控制,默认值为 center。
- 删除 `cancelAutoClose`,改为 `beforeCancel` 和 `beforeClose` 来实现,在点击关闭或取消时,可先触发这两个方法,以确定是否要关闭弹框,如返回true,则关闭;否则不关闭。
- 修改 onOk 为 onConfirm,规范命名。
- 修改 onClosed 为 onClose,规范命名,关闭时触发。
- 修改 onClickSelf 为 onClick,语义不变,仍表示点击弹框自身时触发事件。
- 增加 overlayStyle 和 overlayClassName,用来配置 Overlay 组件样式。
- 增加 onClickOverlay,支持点击overlay时,触发事件。

#### Drag
#### Infiniteloading
#### Notify
Expand Down
67 changes: 0 additions & 67 deletions src/packages/dialog/Content.tsx

This file was deleted.

74 changes: 0 additions & 74 deletions src/packages/dialog/DialogWrap.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions src/packages/dialog/DialogWrapper.taro.tsx

This file was deleted.

44 changes: 0 additions & 44 deletions src/packages/dialog/DialogWrapper.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions src/packages/dialog/Mask.tsx

This file was deleted.

16 changes: 7 additions & 9 deletions src/packages/dialog/__test__/dialog.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import '@testing-library/jest-dom'
import { Dialog } from '../dialog'

test('show dialog base info display ', async () => {
const onClosed = jest.fn()
const onClose = jest.fn()
const { container } = render(
<Dialog title="title" data-testid="test" visible onClosed={onClosed}>
content
<Dialog title="title" data-testid="test" visible onClose={onClose}>
<div>content</div>
</Dialog>
)

Expand All @@ -30,9 +30,9 @@ test('show dialog base info display ', async () => {
expect(contentEle.innerHTML).toEqual('<div>content</div>')
expect(footerEle.children.length).toBe(2)

expect(wrapEle).toHaveAttribute('style', 'display: block;')
expect(wrapEle).toBeNull()
fireEvent.click(footerCancelEle)
expect(onClosed).toBeCalled()
expect(onClose).toBeCalled()
})

test('show dialog custom footer-direction ', async () => {
Expand All @@ -50,7 +50,7 @@ test('show dialog custom footer-direction ', async () => {

test('hide dialog footer', async () => {
const { container } = render(
<Dialog title="title" noFooter visible>
<Dialog title="title" footer={null} visible>
content
</Dialog>
)
Expand All @@ -60,17 +60,15 @@ test('hide dialog footer', async () => {

test('hide dialog title', async () => {
const { container } = render(<Dialog visible>content</Dialog>)

expect(container.querySelectorAll('.nut-dialog__header').length).toBe(0)
})

test('tips dialog', async () => {
const { container } = render(
<Dialog visible noCancelBtn>
<Dialog visible hideCancelButton>
content
</Dialog>
)

expect(container.querySelectorAll('.nut-dialog__footer-cancel').length).toBe(
0
)
Expand Down
31 changes: 11 additions & 20 deletions src/packages/dialog/config.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
import {
CSSProperties,
ReactNode,
ForwardRefExoticComponent,
PropsWithChildren,
} from 'react'
import { ReactNode, ForwardRefExoticComponent, PropsWithChildren } from 'react'

export type DialogConfigType = {
prefixCls?: string
simple?: boolean
}

export interface BasicDialogProps {
className?: string
style?: CSSProperties
visible?: boolean
title?: ReactNode
content?: ReactNode
footer?: ReactNode
confirmText?: ReactNode
cancelText?: ReactNode
mask?: boolean
noOkBtn?: boolean
noCancelBtn?: boolean
okBtnDisabled?: boolean
noFooter?: boolean
closeOnClickOverlay?: boolean
cancelAutoClose?: boolean
textAlign?: string
overlay?: boolean
hideConfirmButton?: boolean
hideCancelButton?: boolean
disableConfirmButton?: boolean
closeOnOverlayClick?: boolean
footerDirection?: string
lockScroll?: boolean
onClosed?: () => void
onOk?: (e?: MouseEvent) => Promise<() => void> | void
onCancel?: () => void
onClickSelf?: () => void
beforeClose?: () => boolean
beforeCancel?: () => boolean
onClose?: () => void
onConfirm?: (e?: MouseEvent) => Promise<() => void> | void
onCancel?: () => void
onClick?: () => void
}

export type DialogReturnProps = {
Expand Down
Loading