Skip to content

Commit

Permalink
feat: feat: popupconfirm components add trigger API
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-ovo committed Jul 13, 2023
1 parent e9a2047 commit b1fb46a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/popconfirm/Popconfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const Popconfirm = forwardRef((props: PopconfirmProps, ref: React.RefObject<Popu
ref={ref}
{...props}
visible={visible}
trigger="click"
onVisibleChange={(visible) => setVisible(visible)}
overlayClassName={classNames(`${classPrefix}-popconfirm`)}
content={
Expand Down
1 change: 1 addition & 0 deletions src/popconfirm/__tests__/popconfirm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('Popconfirm 组件测试', () => {
const { getByText, queryByTestId, queryByText } = render(
<Popconfirm
placement="top"
trigger="click"
content={<div data-testid={testId}>{text}</div>}
onCancel={onCancelMock}
onConfirm={onConfirmMock}
Expand Down
25 changes: 24 additions & 1 deletion src/popconfirm/_usage/props.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,29 @@
}
]
},
{
"name": "trigger",
"type": "enum",
"defaultValue": "hover",
"options": [
{
"label": "hover",
"value": "hover"
},
{
"label": "click",
"value": "click"
},
{
"label": "focus",
"value": "focus"
},
{
"label": "context-menu",
"value": "context-menu"
}
]
},
{
"name": "showArrow",
"type": "Boolean",
Expand Down Expand Up @@ -91,4 +114,4 @@
"defaultValue": false,
"options": []
}
]
]
1 change: 1 addition & 0 deletions src/popconfirm/popconfirm.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ placement | String | top | options:top/left/right/bottom/top-left/top-right/bo
popupProps | Object | - | Typescript:`PopupProps`[Popup API Documents](./popup?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/popconfirm/type.ts) | N
showArrow | Boolean | true | \- | N
theme | String | default | options:default/warning/danger | N
trigger | String | hover | options:hover/click/focus/mousedown/context-menu | N
triggerElement | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
visible | Boolean | - | \- | N
defaultVisible | Boolean | - | uncontrolled property | N
Expand Down
1 change: 1 addition & 0 deletions src/popconfirm/popconfirm.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ placement | String | top | 浮层出现位置。可选项:top/left/right/botto
popupProps | Object | - | 透传 Popup 组件属性。TS 类型:`PopupProps`[Popup API Documents](./popup?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/popconfirm/type.ts) | N
showArrow | Boolean | true | 是否显示浮层箭头 | N
theme | String | default | 文字提示风格。可选项:default/warning/danger | N
trigger | String | hover | 触发浮层出现的方式。可选项:hover/click/focus/mousedown/context-menu | N
triggerElement | TNode | - | 触发元素。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
visible | Boolean | - | 是否显示气泡确认框 | N
defaultVisible | Boolean | - | 是否显示气泡确认框。非受控属性 | N
Expand Down
5 changes: 5 additions & 0 deletions src/popconfirm/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export interface TdPopconfirmProps {
* @default default
*/
theme?: 'default' | 'warning' | 'danger';
/**
* 触发浮层出现的方式
* @default hover
*/
trigger?: 'hover' | 'click' | 'focus' | 'mousedown' | 'context-menu';
/**
* 触发元素
*/
Expand Down

0 comments on commit b1fb46a

Please sign in to comment.