1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import _extends from 'babel-runtime/helpers/extends';
import omit from 'omit.js';
import Tooltip from '../tooltip';
import abstractTooltipProps from '../tooltip/abstractTooltipProps';
import PropTypes from '../_util/vue-types';
import { getOptionProps, hasProp, getComponentFromProp, mergeProps } from '../_util/props-util';
import BaseMixin from '../_util/BaseMixin';
import buttonTypes from '../button/buttonTypes';
import Icon from '../icon';
import Button from '../button';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import defaultLocale from '../locale-provider/default';
var tooltipProps = abstractTooltipProps();
var btnProps = buttonTypes();
var Popconfirm = {
name: 'APopconfirm',
props: _extends({}, tooltipProps, {
prefixCls: PropTypes.string.def('ant-popover'),
transitionName: PropTypes.string.def('zoom-big'),
content: PropTypes.any,
title: PropTypes.any,
trigger: tooltipProps.trigger.def('click'),
okType: btnProps.type.def('primary'),
okText: PropTypes.any,
cancelText: PropTypes.any,
icon: PropTypes.any,
okButtonProps: PropTypes.object,
cancelButtonProps: PropTypes.object
}),
mixins: [BaseMixin],
model: {
prop: 'visible',
event: 'visibleChange'
},
watch: {
visible: function visible(val) {
this.sVisible = val;
}
},
data: function data() {
var props = getOptionProps(this);
var state = { sVisible: false };
if ('visible' in props) {
state.sVisible = props.visible;
} else if ('defaultVisible' in props) {
state.sVisible = props.defaultVisible;
}
return state;
},
methods: {
onConfirm: function onConfirm(e) {
this.setVisible(false, e);
this.$emit('confirm', e);
},
onCancel: function onCancel(e) {
this.setVisible(false, e);
this.$emit('cancel', e);
},
onVisibleChange: function onVisibleChange(sVisible) {
this.setVisible(sVisible);
},
setVisible: function setVisible(sVisible, e) {
if (!hasProp(this, 'visible')) {
this.setState({ sVisible: sVisible });
}
this.$emit('visibleChange', sVisible, e);
},
getPopupDomNode: function getPopupDomNode() {
return this.$refs.tooltip.getPopupDomNode();
},
renderOverlay: function renderOverlay(popconfirmLocale) {
var h = this.$createElement;
var prefixCls = this.prefixCls,
okType = this.okType,
okButtonProps = this.okButtonProps,
cancelButtonProps = this.cancelButtonProps;
var icon = getComponentFromProp(this, 'icon') || h(Icon, {
attrs: { type: 'exclamation-circle', theme: 'filled' }
});
var cancelBtnProps = mergeProps({
props: {
size: 'small'
},
on: {
click: this.onCancel
}
}, cancelButtonProps);
var okBtnProps = mergeProps({
props: {
type: okType,
size: 'small'
},
on: {
click: this.onConfirm
}
}, okButtonProps);
return h(
'div',
{ 'class': prefixCls + '-inner-content' },
[h(
'div',
{ 'class': prefixCls + '-message' },
[icon, h(
'div',
{ 'class': prefixCls + '-message-title' },
[getComponentFromProp(this, 'title')]
)]
), h(
'div',
{ 'class': prefixCls + '-buttons' },
[h(
Button,
cancelBtnProps,
[getComponentFromProp(this, 'cancelText') || popconfirmLocale.cancelText]
), h(
Button,
okBtnProps,
[getComponentFromProp(this, 'okText') || popconfirmLocale.okText]
)]
)]
);
}
},
render: function render() {
var h = arguments[0];
var props = getOptionProps(this);
var otherProps = omit(props, ['title', 'content', 'cancelText', 'okText']);
var tooltipProps = {
props: _extends({}, otherProps, {
visible: this.sVisible
}),
ref: 'tooltip',
on: {
visibleChange: this.onVisibleChange
}
};
var overlay = h(LocaleReceiver, {
attrs: {
componentName: 'Popconfirm',
defaultLocale: defaultLocale.Popconfirm
},
scopedSlots: { 'default': this.renderOverlay }
});
return h(
Tooltip,
tooltipProps,
[h(
'template',
{ slot: 'title' },
[overlay]
), this.$slots['default']]
);
}
};
/* istanbul ignore next */
Popconfirm.install = function (Vue) {
Vue.component(Popconfirm.name, Popconfirm);
};
export default Popconfirm;