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

feat(Popover): 新增 Confirm 用法 #751

Merged
merged 44 commits into from Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a196114
feat(Table): Table 新增树形数据结构展示功能 #539
cuilanxin Mar 16, 2022
ba4173c
Merge branch 'master' of github.com:uiwjs/uiw
cuilanxin Mar 17, 2022
a9b9b5f
feat(Table): Table 新增支持 align 属性 className属性 #682
cuilanxin Mar 17, 2022
03bb855
Merge branch 'master' of github.com:uiwjs/uiw
cuilanxin Mar 17, 2022
ccf7d16
Merge branch 'master' of github.com:uiwjs/uiw
cuilanxin Mar 18, 2022
8a06082
feat(Table): Table 添加 scroll 属性,解决表格冗余 div #687
cuilanxin Mar 18, 2022
a11db86
feat(Table): Table 添加 scroll 属性,解决表格冗余 div #687
cuilanxin Mar 18, 2022
f064884
Merge branch 'uiwjs:master' into master
cuilanxin Mar 20, 2022
e0dded3
Merge branch 'uiwjs:master' into master
cuilanxin Mar 21, 2022
2bb39f9
feat(Table): Table 新增固定列属性
cuilanxin Mar 21, 2022
a86201e
feat(Table): Table 新增固定列属性
cuilanxin Mar 21, 2022
e825768
Merge branch 'master' of github.com:uiwjs/uiw
cuilanxin Mar 21, 2022
35816f7
doc(Table): Update README.md
cuilanxin Mar 21, 2022
86699f6
Merge branch 'master' of github.com:uiwjs/uiw
cuilanxin Mar 22, 2022
68f8262
update(Table): Table 支持树形数据显示和可展开同时出现
cuilanxin Mar 22, 2022
90b101f
Merge branch 'uiwjs:master' into master
cuilanxin Mar 22, 2022
a9d6ba7
Merge branch 'uiwjs:master' into master
cuilanxin Mar 23, 2022
fab96bd
fix(Table): 修复Table indentSize 传递0失效问题
cuilanxin Mar 23, 2022
fe440e6
Merge branch 'uiwjs:master' into master
cuilanxin Mar 23, 2022
343aef7
Merge branch 'uiwjs:master' into master
cuilanxin Mar 25, 2022
5a5bbdd
fix(Table): 修复 table fixed 不能对表头分组使用
cuilanxin Mar 25, 2022
2bab0b6
Merge branch 'uiwjs:master' into master
cuilanxin Mar 25, 2022
85bcab1
Merge branch 'uiwjs:master' into master
cuilanxin Mar 28, 2022
b5a2a04
Merge branch 'uiwjs:master' into master
cuilanxin Mar 28, 2022
980e4ec
Merge branch 'uiwjs:master' into master
cuilanxin Mar 30, 2022
2c9f85f
fix(Table): 修复table fix 在表头分组中fixed固定位置错误问题
cuilanxin Mar 30, 2022
f7d8831
fix(Table): 修复table fix 在表头分组中fixed固定位置错误问题
cuilanxin Mar 30, 2022
64da40d
fix(Table): 修复table fix 在表头分组中fixed固定位置错误问题
cuilanxin Mar 30, 2022
4ce3935
Merge branch 'uiwjs:master' into master
cuilanxin Apr 1, 2022
c6dd9b2
doc(Table): 增加Table可编辑,可编辑行例子
cuilanxin Apr 1, 2022
74d7bec
Merge branch 'uiwjs:master' into master
cuilanxin Apr 2, 2022
eb632e9
doc(Table): 更新table组件文档 可编辑行例子的错误
cuilanxin Apr 2, 2022
0cbe904
Merge branch 'uiwjs:master' into master
cuilanxin Apr 2, 2022
ac9facd
Merge branch 'uiwjs:master' into master
cuilanxin Apr 6, 2022
74f1b0c
Merge branch 'uiwjs:master' into master
cuilanxin Apr 6, 2022
e5dccf7
feat(Modal) fix(Overlay): 新增Modal.show()快速使用弹框功能,修复Overlay首次打开没有动画问题
cuilanxin Apr 6, 2022
a980dd8
feat(Modal) fix(Overlay): 新增Modal.show()快速使用弹框功能,修复Overlay首次打开没有动画问题
cuilanxin Apr 6, 2022
365dd47
feat(Modal) fix(Overlay): 新增Modal.show()快速使用弹框功能,修复Overlay首次打开没有动画问题
cuilanxin Apr 6, 2022
175344c
feat(Modal) fix(Overlay): 新增Modal.show()快速使用弹框功能,修复Overlay首次打开没有动画问题
cuilanxin Apr 6, 2022
05a9cd0
feat(Modal) fix(Overlay): 新增Modal.show()快速使用弹框功能,修复Overlay首次打开没有动画问题
cuilanxin Apr 6, 2022
4368c4c
Merge branch 'uiwjs:master' into master
cuilanxin Apr 6, 2022
fbd4e17
Merge branch 'uiwjs:master' into master
cuilanxin Apr 7, 2022
7cbd9b4
Merge branch 'uiwjs:master' into master
cuilanxin Apr 8, 2022
d6e3006
feat(Popover): 新增 Confirm 用法
cuilanxin Apr 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions packages/react-popover/README.md
Expand Up @@ -334,6 +334,26 @@ class Demo extends React.Component {
ReactDOM.render(<Demo />, _mount_);
```

### Confirm 用法

<!--rehype:bgWhite=true&codeSandbox=true&codePen=true-->
```jsx
import React from 'react';
import ReactDOM from 'react-dom';
import { Popover, Row } from 'uiw';

class Demo extends React.Component {
render() {
return (
<Row style={{ alignItems: 'center' }}>
<Popover.Confirm title="Are you sure delete this?">delete</Popover.Confirm>
</Row>
)
}
}
ReactDOM.render(<Demo />, _mount_);
```

## Props

| 参数 | 说明 | 类型 | 默认值 |
Expand All @@ -348,4 +368,18 @@ ReactDOM.render(<Demo />, _mount_);
| autoAdjustOverflow | 弹出层被遮挡时自动调整位置,继承 `<OverlayTrigger />` 组件属性 | Boolean | `false` |
| onVisibleChange | 显示隐藏的回调,继承 `<OverlayTrigger />` 组件属性 | Function(isVisible:bool) | - |

## Confirm Props

| 参数 | 说明 | 类型 | 默认值 |
|--------- |-------- |--------- |-------- |
| trigger| 悬停/点击弹出窗口,继承 `<OverlayTrigger />` 组件属性 | Enum{`hover`, `click`, `focus`} | `hover` |
| placement | 气泡框位置,可现实箭头在不同的方位 | Enum{`top`, `topLeft`, `topRight`,<br /> `left`, `leftTop`, `leftBottom`,<br /> `right`, `rightTop`, `rightBottom`,<br /> `bottom`, `bottomLeft`, `bottomRight`} | `top` |
| visibleArrow | 是否显示箭头 | Boolean | `true` |
| children | 子元素 | React.ReactNode | - |
| onConfirm | 确定方法 | ()=>void | |
| confirmText | 确定按钮文本 | string | Yes |
| title | 标题信息 | React.ReactNode | - |
| cancelText | 取消按钮文本 | string | No |


更多属性请参考 [OverlayTrigger](#/components/overlay-trigger)。
4 changes: 3 additions & 1 deletion packages/react-popover/package.json
Expand Up @@ -44,6 +44,8 @@
"react-dom": ">=16.9.0"
},
"dependencies": {
"@uiw/react-overlay-trigger": "^4.19.0"
"@uiw/react-overlay-trigger": "^4.19.0",
"@uiw/react-icon": "^4.19.0",
"@uiw/react-button": "^4.19.0"
}
}
67 changes: 67 additions & 0 deletions packages/react-popover/src/Confirm.tsx
@@ -0,0 +1,67 @@
import React, { useState } from 'react';
import Popover, { PopoverProps } from './';
import './style/index.less';
import Button from '@uiw/react-button';
import Icon from '@uiw/react-icon';

interface Confirm {
trigger?: PopoverProps['trigger'];
placement?: PopoverProps['placement'];
children?: React.ReactNode;
visibleArrow?: PopoverProps['visibleArrow'];
onConfirm?: () => void;
confirmText?: string;
title?: React.ReactNode;
cancelText?: string;
}

export default function Confirm(props: Confirm) {
const {
trigger = 'click',
placement = 'top',
confirmText = 'Yes',
title,
cancelText = 'No',
visibleArrow,
children,
onConfirm,
} = props;
const [isOpen, setIsOpen] = useState(false);
return (
<Popover
isOpen={isOpen}
visibleArrow={visibleArrow}
content={
<div style={{ padding: '12px 16px', position: 'relative' }}>
<Icon
type="information"
style={{ position: 'absolute', top: 13.5, fontSize: 14, transform: 'rotate(180deg)', color: '#faad14' }}
/>
<div style={{ paddingLeft: 20 }}>
<div style={{ fontSize: 14 }}>{title}</div>
<div style={{ position: 'relative', bottom: 0, marginTop: 12, display: 'flex', justifyContent: 'end' }}>
<Button size="small" onClick={() => setIsOpen(false)}>
{cancelText}
</Button>
<Button
size="small"
type="primary"
style={{ marginLeft: 10 }}
onClick={() => {
onConfirm?.();
setIsOpen(false);
}}
>
{confirmText}
</Button>
</div>
</div>
</div>
}
trigger={trigger}
placement={placement}
>
<div onClick={() => setIsOpen(true)}>{children}</div>
</Popover>
);
}
2 changes: 2 additions & 0 deletions packages/react-popover/src/index.tsx
@@ -1,5 +1,6 @@
import React from 'react';
import OverlayTrigger, { OverlayTriggerProps } from '@uiw/react-overlay-trigger';
import Confirm from './Confirm';
import './style/index.less';

export interface PopoverProps extends OverlayTriggerProps {
Expand All @@ -8,6 +9,7 @@ export interface PopoverProps extends OverlayTriggerProps {
}

export default class Popover extends React.Component<PopoverProps> {
static Confirm = Confirm;
public static defaultProps: PopoverProps = {
prefixCls: 'w-popover',
placement: 'top',
Expand Down