From 81e80bfaed9b04790ba4d71c2e23f18df6d815e0 Mon Sep 17 00:00:00 2001 From: wangxueliang Date: Wed, 10 Apr 2019 09:20:22 +0800 Subject: [PATCH] feat: popconfirm --- components/popconfirm/index.jsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/components/popconfirm/index.jsx b/components/popconfirm/index.jsx index a31f11abe..d11e026f7 100644 --- a/components/popconfirm/index.jsx +++ b/components/popconfirm/index.jsx @@ -9,6 +9,7 @@ import Icon from '../icon'; import Button from '../button'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; import defaultLocale from '../locale-provider/default'; +import { ConfigConsumerProps } from '../config-provider'; const tooltipProps = abstractTooltipProps(); const btnProps = buttonTypes(); @@ -16,7 +17,7 @@ const Popconfirm = { name: 'APopconfirm', props: { ...tooltipProps, - prefixCls: PropTypes.string.def('ant-popover'), + prefixCls: PropTypes.string, transitionName: PropTypes.string.def('zoom-big'), content: PropTypes.any, title: PropTypes.any, @@ -38,6 +39,9 @@ const Popconfirm = { this.sVisible = val; }, }, + inject: { + configProvider: { default: () => ({}) }, + }, data() { const props = getOptionProps(this); const state = { sVisible: false }; @@ -72,8 +76,8 @@ const Popconfirm = { getPopupDomNode() { return this.$refs.tooltip.getPopupDomNode(); }, - renderOverlay(popconfirmLocale) { - const { prefixCls, okType, okButtonProps, cancelButtonProps } = this; + renderOverlay(prefixCls, popconfirmLocale) { + const { okType, okButtonProps, cancelButtonProps } = this; const icon = getComponentFromProp(this, 'icon') || ( ); @@ -120,10 +124,15 @@ const Popconfirm = { }, render() { const props = getOptionProps(this); + const { prefixCls: customizePrefixCls } = props; + const getPrefixCls = this.configProvider.getPrefixCls || ConfigConsumerProps.getPrefixCls; + const prefixCls = getPrefixCls('popover', customizePrefixCls); + const otherProps = omit(props, ['title', 'content', 'cancelText', 'okText']); const tooltipProps = { props: { ...otherProps, + prefixCls, visible: this.sVisible, }, ref: 'tooltip', @@ -135,7 +144,7 @@ const Popconfirm = { this.renderOverlay(prefixCls, popconfirmLocale) }} /> ); return (