diff --git a/src/index.ts b/src/index.ts index 613a09772..e76350807 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,6 +27,7 @@ export { default as KeyEventListener } from './keyEventListener'; export { default as MarkdownRender } from './markdownRender'; export { default as Modal } from './modal/modal'; export { default as NotFound } from './notFound'; +export { default as Popconfirm } from './popConfirm'; export { default as ProgressBar } from './progressBar'; export { default as ProgressLine } from './progressLine'; export { default as Resize } from './resize'; diff --git a/src/popConfirm/__tests__/__snapshots__/index.test.tsx.snap b/src/popConfirm/__tests__/__snapshots__/index.test.tsx.snap new file mode 100644 index 000000000..d5982c531 --- /dev/null +++ b/src/popConfirm/__tests__/__snapshots__/index.test.tsx.snap @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Popconfirm should render Popconfirm success render 1`] = ` +
+
+
+
+## API
+
+| 属性 | 说明 | 类型 | 默认值 |
+| -------- | ------------ | ---------------------------------- | --------- |
+| showIcon | 是否显示图标 | boolean | true |
+| type | 图标类型 | 'primary' \| 'warning' \| 'danger' | 'primary' |
+
+其余属性均继承自 `Popconfirm` 组件,参考 [Popconfirm API](https://4x.ant.design/components/popconfirm-cn/#API)
diff --git a/src/popConfirm/index.scss b/src/popConfirm/index.scss
new file mode 100644
index 000000000..c1af14e89
--- /dev/null
+++ b/src/popConfirm/index.scss
@@ -0,0 +1,13 @@
+.dtc-popconfirm {
+ .ant-popover-message {
+ display: flex;
+ align-items: start;
+ &-title {
+ padding-left: 0;
+ }
+ }
+ .dtstack-icon {
+ margin-right: 8px;
+ font-size: 20px;
+ }
+}
diff --git a/src/popConfirm/index.tsx b/src/popConfirm/index.tsx
new file mode 100644
index 000000000..9371bb94f
--- /dev/null
+++ b/src/popConfirm/index.tsx
@@ -0,0 +1,45 @@
+import React from 'react';
+import { CloseFilled, InformationFilled, WarningFilled } from '@dtinsight/react-icons';
+import { Popconfirm as AntdPopconfirm, PopconfirmProps as AntdPopconfirmProps } from 'antd';
+import classNames from 'classnames';
+
+import './index.scss';
+
+export interface PopconfirmProps extends AntdPopconfirmProps {
+ showIcon?: boolean;
+ type?: 'primary' | 'warning' | 'danger';
+}
+
+const Popconfirm = ({
+ showIcon = true,
+ type = 'primary',
+ icon,
+ okButtonProps,
+ ...rest
+}: PopconfirmProps) => {
+ const generateIcon = () => {
+ if (!showIcon) return <>>;
+ if (icon) return icon;
+ switch (type) {
+ case 'primary':
+ return