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
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
var _icon = require('../icon');
var _icon2 = _interopRequireDefault(_icon);
var _Modal = require('./Modal');
var _Modal2 = _interopRequireDefault(_Modal);
var _ActionButton = require('./ActionButton');
var _ActionButton2 = _interopRequireDefault(_ActionButton);
var _locale = require('./locale');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
exports['default'] = {
functional: true,
render: function render(h, context) {
var props = context.props;
var onCancel = props.onCancel,
onOk = props.onOk,
close = props.close,
zIndex = props.zIndex,
afterClose = props.afterClose,
visible = props.visible,
keyboard = props.keyboard,
centered = props.centered,
getContainer = props.getContainer,
maskStyle = props.maskStyle,
okButtonProps = props.okButtonProps,
cancelButtonProps = props.cancelButtonProps;
var iconType = props.iconType || 'question-circle';
var okType = props.okType || 'primary';
var prefixCls = props.prefixCls || 'ant-modal';
var contentPrefixCls = prefixCls + '-confirm';
// 默认为 true,保持向下兼容
var okCancel = 'okCancel' in props ? props.okCancel : true;
var width = props.width || 416;
var style = props.style || {};
// 默认为 false,保持旧版默认行为
var maskClosable = props.maskClosable === undefined ? false : props.maskClosable;
var runtimeLocale = (0, _locale.getConfirmLocale)();
var okText = props.okText || (okCancel ? runtimeLocale.okText : runtimeLocale.justOkText);
var cancelText = props.cancelText || runtimeLocale.cancelText;
var autoFocusButton = props.autoFocusButton === null ? false : props.autoFocusButton || 'ok';
var classString = (0, _classnames2['default'])(contentPrefixCls, contentPrefixCls + '-' + props.type, prefixCls + '-' + props.type, props['class']);
var cancelButton = okCancel && h(
_ActionButton2['default'],
{
attrs: {
actionFn: onCancel,
closeModal: close,
autoFocus: autoFocusButton === 'cancel',
buttonProps: cancelButtonProps
}
},
[cancelText]
);
return h(
_Modal2['default'],
{
attrs: {
prefixCls: prefixCls,
wrapClassName: (0, _classnames2['default'])((0, _defineProperty3['default'])({}, contentPrefixCls + '-centered', !!centered)),
visible: visible,
title: '',
transitionName: 'zoom',
footer: '',
maskTransitionName: 'fade',
maskClosable: maskClosable,
maskStyle: maskStyle,
width: width,
zIndex: zIndex,
afterClose: afterClose,
keyboard: keyboard,
centered: centered,
getContainer: getContainer
},
'class': classString, on: {
'cancel': function cancel(e) {
return close({ triggerCancel: true }, e);
}
},
style: style },
[h(
'div',
{ 'class': contentPrefixCls + '-body-wrapper' },
[h(
'div',
{ 'class': contentPrefixCls + '-body' },
[h(_icon2['default'], {
attrs: { type: iconType }
}), h(
'span',
{ 'class': contentPrefixCls + '-title' },
[props.title]
), h(
'div',
{ 'class': contentPrefixCls + '-content' },
[props.content]
)]
), h(
'div',
{ 'class': contentPrefixCls + '-btns' },
[cancelButton, h(
_ActionButton2['default'],
{
attrs: {
type: okType,
actionFn: onOk,
closeModal: close,
autoFocus: autoFocusButton === 'ok',
buttonProps: okButtonProps
}
},
[okText]
)]
)]
)]
);
}
};