antd3-esm 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/Checkbox.js +164 -0
- package/dist/CommonMixin.js +816 -0
- package/dist/Divider.js +646 -0
- package/dist/Notification.js +279 -0
- package/dist/Pagination.js +1106 -0
- package/dist/PortalWrapper.js +347 -0
- package/dist/RowContext.js +5 -0
- package/dist/Sider.js +533 -0
- package/dist/TextArea.js +432 -0
- package/dist/_arrayMap.js +68 -0
- package/dist/_assignValue.js +95 -0
- package/dist/_copyArray.js +31 -0
- package/dist/_hasPath.js +53 -0
- package/dist/_overArg.js +437 -0
- package/dist/_stringToArray.js +136 -0
- package/dist/antd/es/affix.js +12 -0
- package/dist/antd/es/alert.js +5 -0
- package/dist/antd/es/anchor.js +466 -0
- package/dist/antd/es/auto-complete.js +5 -0
- package/dist/antd/es/avatar.js +5 -0
- package/dist/antd/es/back-top.js +5 -0
- package/dist/antd/es/badge.js +5 -0
- package/dist/antd/es/breadcrumb.js +18 -0
- package/dist/antd/es/button.js +12 -0
- package/dist/antd/es/calendar.js +953 -0
- package/dist/antd/es/card.js +5 -0
- package/dist/antd/es/carousel.js +5 -0
- package/dist/antd/es/cascader.js +1275 -0
- package/dist/antd/es/checkbox.js +11 -0
- package/dist/antd/es/col.js +4 -0
- package/dist/antd/es/collapse.js +688 -0
- package/dist/antd/es/comment.js +5 -0
- package/dist/antd/es/config-provider.js +2 -0
- package/dist/antd/es/date-picker.js +4322 -0
- package/dist/antd/es/descriptions.js +342 -0
- package/dist/antd/es/divider.js +53 -0
- package/dist/antd/es/drawer.js +1115 -0
- package/dist/antd/es/dropdown.js +14 -0
- package/dist/antd/es/empty.js +6 -0
- package/dist/antd/es/form.js +5008 -0
- package/dist/antd/es/grid.js +13 -0
- package/dist/antd/es/icon.js +6 -0
- package/dist/antd/es/input-number.js +5 -0
- package/dist/antd/es/input.js +16 -0
- package/dist/antd/es/layout.js +14 -0
- package/dist/antd/es/list.js +5 -0
- package/dist/antd/es/locale/ar_EG.js +102 -0
- package/dist/antd/es/locale/bg_BG.js +98 -0
- package/dist/antd/es/locale/ca_ES.js +96 -0
- package/dist/antd/es/locale/cs_CZ.js +96 -0
- package/dist/antd/es/locale/da_DK.js +98 -0
- package/dist/antd/es/locale/de_DE.js +98 -0
- package/dist/antd/es/locale/default.js +2 -0
- package/dist/antd/es/locale/el_GR.js +98 -0
- package/dist/antd/es/locale/en_GB.js +98 -0
- package/dist/antd/es/locale/en_US.js +2 -0
- package/dist/antd/es/locale/es_ES.js +114 -0
- package/dist/antd/es/locale/et_EE.js +98 -0
- package/dist/antd/es/locale/fa_IR.js +98 -0
- package/dist/antd/es/locale/fi_FI.js +99 -0
- package/dist/antd/es/locale/fr_BE.js +102 -0
- package/dist/antd/es/locale/fr_FR.js +102 -0
- package/dist/antd/es/locale/ga_IE.js +99 -0
- package/dist/antd/es/locale/he_IL.js +99 -0
- package/dist/antd/es/locale/hi_IN.js +107 -0
- package/dist/antd/es/locale/hr_HR.js +113 -0
- package/dist/antd/es/locale/hu_HU.js +99 -0
- package/dist/antd/es/locale/hy_AM.js +109 -0
- package/dist/antd/es/locale/id_ID.js +101 -0
- package/dist/antd/es/locale/is_IS.js +98 -0
- package/dist/antd/es/locale/it_IT.js +111 -0
- package/dist/antd/es/locale/ja_JP.js +96 -0
- package/dist/antd/es/locale/kn_IN.js +107 -0
- package/dist/antd/es/locale/ko_KR.js +98 -0
- package/dist/antd/es/locale/ku_IQ.js +98 -0
- package/dist/antd/es/locale/lv_LV.js +98 -0
- package/dist/antd/es/locale/mk_MK.js +113 -0
- package/dist/antd/es/locale/mn_MN.js +99 -0
- package/dist/antd/es/locale/ms_MY.js +118 -0
- package/dist/antd/es/locale/nb_NO.js +97 -0
- package/dist/antd/es/locale/ne_NP.js +44 -0
- package/dist/antd/es/locale/nl_BE.js +98 -0
- package/dist/antd/es/locale/nl_NL.js +117 -0
- package/dist/antd/es/locale/pl_PL.js +98 -0
- package/dist/antd/es/locale/pt_BR.js +104 -0
- package/dist/antd/es/locale/pt_PT.js +127 -0
- package/dist/antd/es/locale/ro_RO.js +118 -0
- package/dist/antd/es/locale/ru_RU.js +110 -0
- package/dist/antd/es/locale/sk_SK.js +118 -0
- package/dist/antd/es/locale/sl_SI.js +96 -0
- package/dist/antd/es/locale/sr_RS.js +97 -0
- package/dist/antd/es/locale/sv_SE.js +101 -0
- package/dist/antd/es/locale/ta_IN.js +119 -0
- package/dist/antd/es/locale/th_TH.js +117 -0
- package/dist/antd/es/locale/tr_TR.js +112 -0
- package/dist/antd/es/locale/uk_UA.js +97 -0
- package/dist/antd/es/locale/vi_VN.js +99 -0
- package/dist/antd/es/locale/zh_CN.js +104 -0
- package/dist/antd/es/locale/zh_TW.js +100 -0
- package/dist/antd/es/locale-provider.js +6 -0
- package/dist/antd/es/mention.js +23215 -0
- package/dist/antd/es/mentions.js +961 -0
- package/dist/antd/es/menu.js +5 -0
- package/dist/antd/es/message.js +161 -0
- package/dist/antd/es/modal.js +885 -0
- package/dist/antd/es/notification.js +216 -0
- package/dist/antd/es/page-header.js +350 -0
- package/dist/antd/es/pagination.js +15 -0
- package/dist/antd/es/popconfirm.js +215 -0
- package/dist/antd/es/popover.js +5 -0
- package/dist/antd/es/progress.js +10 -0
- package/dist/antd/es/radio.js +10 -0
- package/dist/antd/es/rate.js +5 -0
- package/dist/antd/es/result.js +828 -0
- package/dist/antd/es/row.js +9 -0
- package/dist/antd/es/select.js +5 -0
- package/dist/antd/es/skeleton.js +370 -0
- package/dist/antd/es/slider.js +5 -0
- package/dist/antd/es/spin.js +11 -0
- package/dist/antd/es/statistic.js +650 -0
- package/dist/antd/es/steps.js +5 -0
- package/dist/antd/es/style.js +5 -0
- package/dist/antd/es/switch.js +5 -0
- package/dist/antd/es/table.js +7057 -0
- package/dist/antd/es/tabs.js +5 -0
- package/dist/antd/es/tag.js +12 -0
- package/dist/antd/es/time-picker.js +10 -0
- package/dist/antd/es/timeline.js +206 -0
- package/dist/antd/es/tooltip.js +9 -0
- package/dist/antd/es/transfer.js +2508 -0
- package/dist/antd/es/tree-select.js +5 -0
- package/dist/antd/es/tree.js +10 -0
- package/dist/antd/es/typography.js +1246 -0
- package/dist/antd/es/upload.js +3418 -0
- package/dist/antd/es/version.js +7 -0
- package/dist/col.js +142 -0
- package/dist/config-provider.js +6949 -0
- package/dist/dropdown.js +442 -0
- package/dist/get.js +1043 -0
- package/dist/icon.js +6138 -0
- package/dist/identity.js +230 -0
- package/dist/index.js +462 -0
- package/dist/index10.js +478 -0
- package/dist/index11.js +232 -0
- package/dist/index12.js +2766 -0
- package/dist/index13.js +422 -0
- package/dist/index14.js +283 -0
- package/dist/index15.js +1755 -0
- package/dist/index2.js +374 -0
- package/dist/index3.js +407 -0
- package/dist/index4.js +522 -0
- package/dist/index5.js +601 -0
- package/dist/index6.js +601 -0
- package/dist/index7.js +364 -0
- package/dist/index8.js +436 -0
- package/dist/index9.js +130 -0
- package/dist/input.js +475 -0
- package/dist/isLength.js +402 -0
- package/dist/keys.js +292 -0
- package/dist/menu.js +8138 -0
- package/dist/progress.js +852 -0
- package/dist/raf.js +34 -0
- package/dist/responsiveObserve.js +444 -0
- package/dist/row.js +173 -0
- package/dist/scrollTo.js +66 -0
- package/dist/toInteger.js +123 -0
- package/dist/toString.js +84 -0
- package/dist/transButton.js +121 -0
- package/dist/tree.js +3017 -0
- package/dist/warning.js +55 -0
- package/dist/wave.js +230 -0
- package/dist/zh_CN.js +17 -0
- package/package.json +160 -0
|
@@ -0,0 +1,885 @@
|
|
|
1
|
+
import { n, c as classNames, C as ConfigConsumer, p as propTypesExports, L as LocaleReceiver, u as getConfirmLocale } from '../../config-provider.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { _ as _inherits$2, a as _classCallCheck$2, b as _possibleConstructorReturn$2, e as _extends$4, I as Icon } from '../../icon.js';
|
|
4
|
+
import * as ReactDOM from 'react-dom';
|
|
5
|
+
import { K as KeyCode, A as Animate, h as contains, a as addEventListenerWrap } from '../../menu.js';
|
|
6
|
+
import { P as Portal } from '../../PortalWrapper.js';
|
|
7
|
+
import { B as Button } from '../../index7.js';
|
|
8
|
+
import '../../input.js';
|
|
9
|
+
import '../../wave.js';
|
|
10
|
+
import '../../raf.js';
|
|
11
|
+
|
|
12
|
+
var css = "/* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */\n/* stylelint-disable no-duplicate-selectors */\n/* stylelint-disable */\n/* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */\n.ant-modal {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n color: rgba(0, 0, 0, 0.65);\n font-size: 14px;\n font-variant: tabular-nums;\n line-height: 1.5;\n list-style: none;\n font-feature-settings: 'tnum';\n position: relative;\n top: 100px;\n width: auto;\n margin: 0 auto;\n padding-bottom: 24px;\n pointer-events: none;\n}\n.ant-modal-wrap {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 1000;\n overflow: auto;\n outline: 0;\n -webkit-overflow-scrolling: touch;\n}\n.ant-modal-title {\n margin: 0;\n color: rgba(0, 0, 0, 0.85);\n font-weight: 500;\n font-size: 16px;\n line-height: 22px;\n word-wrap: break-word;\n}\n.ant-modal-content {\n position: relative;\n background-color: #fff;\n background-clip: padding-box;\n border: 0;\n border-radius: 4px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n pointer-events: auto;\n}\n.ant-modal-close {\n position: absolute;\n top: 0;\n right: 0;\n z-index: 10;\n padding: 0;\n color: rgba(0, 0, 0, 0.45);\n font-weight: 700;\n line-height: 1;\n text-decoration: none;\n background: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n transition: color 0.3s;\n}\n.ant-modal-close-x {\n display: block;\n width: 56px;\n height: 56px;\n font-size: 16px;\n font-style: normal;\n line-height: 56px;\n text-align: center;\n text-transform: none;\n text-rendering: auto;\n}\n.ant-modal-close:focus,\n.ant-modal-close:hover {\n color: rgba(0, 0, 0, 0.75);\n text-decoration: none;\n}\n.ant-modal-header {\n padding: 16px 24px;\n color: rgba(0, 0, 0, 0.65);\n background: #fff;\n border-bottom: 1px solid #e8e8e8;\n border-radius: 4px 4px 0 0;\n}\n.ant-modal-body {\n padding: 24px;\n font-size: 14px;\n line-height: 1.5;\n word-wrap: break-word;\n}\n.ant-modal-footer {\n padding: 10px 16px;\n text-align: right;\n background: transparent;\n border-top: 1px solid #e8e8e8;\n border-radius: 0 0 4px 4px;\n}\n.ant-modal-footer button + button {\n margin-bottom: 0;\n margin-left: 8px;\n}\n.ant-modal.zoom-enter,\n.ant-modal.zoom-appear {\n transform: none;\n opacity: 0;\n animation-duration: 0.3s;\n user-select: none;\n}\n.ant-modal-mask {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 1000;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.45);\n filter: alpha(opacity=50);\n}\n.ant-modal-mask-hidden {\n display: none;\n}\n.ant-modal-open {\n overflow: hidden;\n}\n.ant-modal-centered {\n text-align: center;\n}\n.ant-modal-centered::before {\n display: inline-block;\n width: 0;\n height: 100%;\n vertical-align: middle;\n content: '';\n}\n.ant-modal-centered .ant-modal {\n top: 0;\n display: inline-block;\n text-align: left;\n vertical-align: middle;\n}\n@media (max-width: 767px) {\n .ant-modal {\n max-width: calc(100vw - 16px);\n margin: 8px auto;\n }\n .ant-modal-centered .ant-modal {\n flex: 1;\n }\n}\n.ant-modal-confirm .ant-modal-header {\n display: none;\n}\n.ant-modal-confirm .ant-modal-close {\n display: none;\n}\n.ant-modal-confirm .ant-modal-body {\n padding: 32px 32px 24px;\n}\n.ant-modal-confirm-body-wrapper {\n zoom: 1;\n}\n.ant-modal-confirm-body-wrapper::before,\n.ant-modal-confirm-body-wrapper::after {\n display: table;\n content: '';\n}\n.ant-modal-confirm-body-wrapper::after {\n clear: both;\n}\n.ant-modal-confirm-body .ant-modal-confirm-title {\n display: block;\n overflow: hidden;\n color: rgba(0, 0, 0, 0.85);\n font-weight: 500;\n font-size: 16px;\n line-height: 1.4;\n}\n.ant-modal-confirm-body .ant-modal-confirm-content {\n margin-top: 8px;\n color: rgba(0, 0, 0, 0.65);\n font-size: 14px;\n}\n.ant-modal-confirm-body > .anticon {\n float: left;\n margin-right: 16px;\n font-size: 22px;\n}\n.ant-modal-confirm-body > .anticon + .ant-modal-confirm-title + .ant-modal-confirm-content {\n margin-left: 38px;\n}\n.ant-modal-confirm .ant-modal-confirm-btns {\n float: right;\n margin-top: 24px;\n}\n.ant-modal-confirm .ant-modal-confirm-btns button + button {\n margin-bottom: 0;\n margin-left: 8px;\n}\n.ant-modal-confirm-error .ant-modal-confirm-body > .anticon {\n color: #f5222d;\n}\n.ant-modal-confirm-warning .ant-modal-confirm-body > .anticon,\n.ant-modal-confirm-confirm .ant-modal-confirm-body > .anticon {\n color: #faad14;\n}\n.ant-modal-confirm-info .ant-modal-confirm-body > .anticon {\n color: #1890ff;\n}\n.ant-modal-confirm-success .ant-modal-confirm-body > .anticon {\n color: #52c41a;\n}\n/*# sourceMappingURL=index.css.map */";
|
|
13
|
+
n(css,{"prepend":true});
|
|
14
|
+
|
|
15
|
+
var __rest$1 = undefined && undefined.__rest || function (s, e) {
|
|
16
|
+
var t = {};
|
|
17
|
+
for (var p in s) {
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
19
|
+
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
20
|
+
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
|
|
21
|
+
}return t;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
var LazyRenderBox = function (_React$Component) {
|
|
25
|
+
_inherits$2(LazyRenderBox, _React$Component);
|
|
26
|
+
|
|
27
|
+
function LazyRenderBox() {
|
|
28
|
+
_classCallCheck$2(this, LazyRenderBox);
|
|
29
|
+
|
|
30
|
+
return _possibleConstructorReturn$2(this, _React$Component.apply(this, arguments));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
LazyRenderBox.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
34
|
+
if (nextProps.forceRender) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return !!nextProps.hiddenClassName || !!nextProps.visible;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
LazyRenderBox.prototype.render = function render() {
|
|
41
|
+
var _a = this.props,
|
|
42
|
+
className = _a.className,
|
|
43
|
+
hiddenClassName = _a.hiddenClassName,
|
|
44
|
+
visible = _a.visible,
|
|
45
|
+
restProps = __rest$1(_a, ["className", "hiddenClassName", "visible", "forceRender"]);
|
|
46
|
+
var useClassName = className;
|
|
47
|
+
if (!!hiddenClassName && !visible) {
|
|
48
|
+
useClassName += " " + hiddenClassName;
|
|
49
|
+
}
|
|
50
|
+
return React.createElement("div", _extends$4({}, restProps, { className: useClassName }));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return LazyRenderBox;
|
|
54
|
+
}(React.Component);
|
|
55
|
+
|
|
56
|
+
var uuid = 0;
|
|
57
|
+
/* eslint react/no-is-mounted:0 */
|
|
58
|
+
function getScroll(w, top) {
|
|
59
|
+
var ret = w['page' + (top ? 'Y' : 'X') + 'Offset'];
|
|
60
|
+
var method = 'scroll' + (top ? 'Top' : 'Left');
|
|
61
|
+
if (typeof ret !== 'number') {
|
|
62
|
+
var d = w.document;
|
|
63
|
+
ret = d.documentElement[method];
|
|
64
|
+
if (typeof ret !== 'number') {
|
|
65
|
+
ret = d.body[method];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return ret;
|
|
69
|
+
}
|
|
70
|
+
function setTransformOrigin(node, value) {
|
|
71
|
+
var style = node.style;
|
|
72
|
+
['Webkit', 'Moz', 'Ms', 'ms'].forEach(function (prefix) {
|
|
73
|
+
style[prefix + 'TransformOrigin'] = value;
|
|
74
|
+
});
|
|
75
|
+
style['transformOrigin'] = value;
|
|
76
|
+
}
|
|
77
|
+
function offset(el) {
|
|
78
|
+
var rect = el.getBoundingClientRect();
|
|
79
|
+
var pos = {
|
|
80
|
+
left: rect.left,
|
|
81
|
+
top: rect.top
|
|
82
|
+
};
|
|
83
|
+
var doc = el.ownerDocument;
|
|
84
|
+
var w = doc.defaultView || doc.parentWindow;
|
|
85
|
+
pos.left += getScroll(w);
|
|
86
|
+
pos.top += getScroll(w, true);
|
|
87
|
+
return pos;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var Dialog$1 = function (_React$Component) {
|
|
91
|
+
_inherits$2(Dialog, _React$Component);
|
|
92
|
+
|
|
93
|
+
function Dialog(props) {
|
|
94
|
+
_classCallCheck$2(this, Dialog);
|
|
95
|
+
|
|
96
|
+
var _this = _possibleConstructorReturn$2(this, _React$Component.call(this, props));
|
|
97
|
+
|
|
98
|
+
_this.inTransition = false;
|
|
99
|
+
_this.onAnimateLeave = function () {
|
|
100
|
+
var afterClose = _this.props.afterClose;
|
|
101
|
+
// need demo?
|
|
102
|
+
// https://github.com/react-component/dialog/pull/28
|
|
103
|
+
|
|
104
|
+
if (_this.wrap) {
|
|
105
|
+
_this.wrap.style.display = 'none';
|
|
106
|
+
}
|
|
107
|
+
_this.inTransition = false;
|
|
108
|
+
_this.switchScrollingEffect();
|
|
109
|
+
if (afterClose) {
|
|
110
|
+
afterClose();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
_this.onDialogMouseDown = function () {
|
|
114
|
+
_this.dialogMouseDown = true;
|
|
115
|
+
};
|
|
116
|
+
_this.onMaskMouseUp = function () {
|
|
117
|
+
if (_this.dialogMouseDown) {
|
|
118
|
+
_this.timeoutId = setTimeout(function () {
|
|
119
|
+
_this.dialogMouseDown = false;
|
|
120
|
+
}, 0);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
_this.onMaskClick = function (e) {
|
|
124
|
+
// android trigger click on open (fastclick??)
|
|
125
|
+
if (Date.now() - _this.openTime < 300) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (e.target === e.currentTarget && !_this.dialogMouseDown) {
|
|
129
|
+
_this.close(e);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
_this.onKeyDown = function (e) {
|
|
133
|
+
var props = _this.props;
|
|
134
|
+
if (props.keyboard && e.keyCode === KeyCode.ESC) {
|
|
135
|
+
e.stopPropagation();
|
|
136
|
+
_this.close(e);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
// keep focus inside dialog
|
|
140
|
+
if (props.visible) {
|
|
141
|
+
if (e.keyCode === KeyCode.TAB) {
|
|
142
|
+
var activeElement = document.activeElement;
|
|
143
|
+
var sentinelStart = _this.sentinelStart;
|
|
144
|
+
if (e.shiftKey) {
|
|
145
|
+
if (activeElement === sentinelStart) {
|
|
146
|
+
_this.sentinelEnd.focus();
|
|
147
|
+
}
|
|
148
|
+
} else if (activeElement === _this.sentinelEnd) {
|
|
149
|
+
sentinelStart.focus();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
_this.getDialogElement = function () {
|
|
155
|
+
var props = _this.props;
|
|
156
|
+
var closable = props.closable;
|
|
157
|
+
var prefixCls = props.prefixCls;
|
|
158
|
+
var dest = {};
|
|
159
|
+
if (props.width !== undefined) {
|
|
160
|
+
dest.width = props.width;
|
|
161
|
+
}
|
|
162
|
+
if (props.height !== undefined) {
|
|
163
|
+
dest.height = props.height;
|
|
164
|
+
}
|
|
165
|
+
var footer = void 0;
|
|
166
|
+
if (props.footer) {
|
|
167
|
+
footer = React.createElement("div", { className: prefixCls + '-footer', ref: _this.saveRef('footer') }, props.footer);
|
|
168
|
+
}
|
|
169
|
+
var header = void 0;
|
|
170
|
+
if (props.title) {
|
|
171
|
+
header = React.createElement("div", { className: prefixCls + '-header', ref: _this.saveRef('header') }, React.createElement("div", { className: prefixCls + '-title', id: _this.titleId }, props.title));
|
|
172
|
+
}
|
|
173
|
+
var closer = void 0;
|
|
174
|
+
if (closable) {
|
|
175
|
+
closer = React.createElement("button", { type: "button", onClick: _this.close, "aria-label": "Close", className: prefixCls + '-close' }, props.closeIcon || React.createElement("span", { className: prefixCls + '-close-x' }));
|
|
176
|
+
}
|
|
177
|
+
var style = _extends$4({}, props.style, dest);
|
|
178
|
+
var sentinelStyle = { width: 0, height: 0, overflow: 'hidden', outline: 'none' };
|
|
179
|
+
var transitionName = _this.getTransitionName();
|
|
180
|
+
var dialogElement = React.createElement(LazyRenderBox, { key: "dialog-element", role: "document", ref: _this.saveRef('dialog'), style: style, className: prefixCls + ' ' + (props.className || ''), visible: props.visible, forceRender: props.forceRender, onMouseDown: _this.onDialogMouseDown }, React.createElement("div", { tabIndex: 0, ref: _this.saveRef('sentinelStart'), style: sentinelStyle, "aria-hidden": "true" }), React.createElement("div", { className: prefixCls + '-content' }, closer, header, React.createElement("div", _extends$4({ className: prefixCls + '-body', style: props.bodyStyle, ref: _this.saveRef('body') }, props.bodyProps), props.children), footer), React.createElement("div", { tabIndex: 0, ref: _this.saveRef('sentinelEnd'), style: sentinelStyle, "aria-hidden": "true" }));
|
|
181
|
+
return React.createElement(Animate, { key: "dialog", showProp: "visible", onLeave: _this.onAnimateLeave, transitionName: transitionName, component: "", transitionAppear: true }, props.visible || !props.destroyOnClose ? dialogElement : null);
|
|
182
|
+
};
|
|
183
|
+
_this.getZIndexStyle = function () {
|
|
184
|
+
var style = {};
|
|
185
|
+
var props = _this.props;
|
|
186
|
+
if (props.zIndex !== undefined) {
|
|
187
|
+
style.zIndex = props.zIndex;
|
|
188
|
+
}
|
|
189
|
+
return style;
|
|
190
|
+
};
|
|
191
|
+
_this.getWrapStyle = function () {
|
|
192
|
+
return _extends$4({}, _this.getZIndexStyle(), _this.props.wrapStyle);
|
|
193
|
+
};
|
|
194
|
+
_this.getMaskStyle = function () {
|
|
195
|
+
return _extends$4({}, _this.getZIndexStyle(), _this.props.maskStyle);
|
|
196
|
+
};
|
|
197
|
+
_this.getMaskElement = function () {
|
|
198
|
+
var props = _this.props;
|
|
199
|
+
var maskElement = void 0;
|
|
200
|
+
if (props.mask) {
|
|
201
|
+
var maskTransition = _this.getMaskTransitionName();
|
|
202
|
+
maskElement = React.createElement(LazyRenderBox, _extends$4({ style: _this.getMaskStyle(), key: "mask", className: props.prefixCls + '-mask', hiddenClassName: props.prefixCls + '-mask-hidden', visible: props.visible }, props.maskProps));
|
|
203
|
+
if (maskTransition) {
|
|
204
|
+
maskElement = React.createElement(Animate, { key: "mask", showProp: "visible", transitionAppear: true, component: "", transitionName: maskTransition }, maskElement);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return maskElement;
|
|
208
|
+
};
|
|
209
|
+
_this.getMaskTransitionName = function () {
|
|
210
|
+
var props = _this.props;
|
|
211
|
+
var transitionName = props.maskTransitionName;
|
|
212
|
+
var animation = props.maskAnimation;
|
|
213
|
+
if (!transitionName && animation) {
|
|
214
|
+
transitionName = props.prefixCls + '-' + animation;
|
|
215
|
+
}
|
|
216
|
+
return transitionName;
|
|
217
|
+
};
|
|
218
|
+
_this.getTransitionName = function () {
|
|
219
|
+
var props = _this.props;
|
|
220
|
+
var transitionName = props.transitionName;
|
|
221
|
+
var animation = props.animation;
|
|
222
|
+
if (!transitionName && animation) {
|
|
223
|
+
transitionName = props.prefixCls + '-' + animation;
|
|
224
|
+
}
|
|
225
|
+
return transitionName;
|
|
226
|
+
};
|
|
227
|
+
_this.close = function (e) {
|
|
228
|
+
var onClose = _this.props.onClose;
|
|
229
|
+
|
|
230
|
+
if (onClose) {
|
|
231
|
+
onClose(e);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
_this.saveRef = function (name) {
|
|
235
|
+
return function (node) {
|
|
236
|
+
_this[name] = node;
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
_this.titleId = 'rcDialogTitle' + uuid++;
|
|
240
|
+
_this.switchScrollingEffect = props.switchScrollingEffect || function () {};
|
|
241
|
+
return _this;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
Dialog.prototype.componentDidMount = function componentDidMount() {
|
|
245
|
+
this.componentDidUpdate({});
|
|
246
|
+
// if forceRender is true, set element style display to be none;
|
|
247
|
+
if ((this.props.forceRender || this.props.getContainer === false && !this.props.visible) && this.wrap) {
|
|
248
|
+
this.wrap.style.display = 'none';
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
Dialog.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
253
|
+
var _props = this.props,
|
|
254
|
+
visible = _props.visible,
|
|
255
|
+
mask = _props.mask,
|
|
256
|
+
focusTriggerAfterClose = _props.focusTriggerAfterClose;
|
|
257
|
+
|
|
258
|
+
var mousePosition = this.props.mousePosition;
|
|
259
|
+
if (visible) {
|
|
260
|
+
// first show
|
|
261
|
+
if (!prevProps.visible) {
|
|
262
|
+
this.openTime = Date.now();
|
|
263
|
+
this.switchScrollingEffect();
|
|
264
|
+
this.tryFocus();
|
|
265
|
+
var dialogNode = ReactDOM.findDOMNode(this.dialog);
|
|
266
|
+
if (mousePosition) {
|
|
267
|
+
var elOffset = offset(dialogNode);
|
|
268
|
+
setTransformOrigin(dialogNode, mousePosition.x - elOffset.left + 'px ' + (mousePosition.y - elOffset.top) + 'px');
|
|
269
|
+
} else {
|
|
270
|
+
setTransformOrigin(dialogNode, '');
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
} else if (prevProps.visible) {
|
|
274
|
+
this.inTransition = true;
|
|
275
|
+
if (mask && this.lastOutSideFocusNode && focusTriggerAfterClose) {
|
|
276
|
+
try {
|
|
277
|
+
this.lastOutSideFocusNode.focus();
|
|
278
|
+
} catch (e) {
|
|
279
|
+
this.lastOutSideFocusNode = null;
|
|
280
|
+
}
|
|
281
|
+
this.lastOutSideFocusNode = null;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
Dialog.prototype.componentWillUnmount = function componentWillUnmount() {
|
|
287
|
+
var _props2 = this.props,
|
|
288
|
+
visible = _props2.visible,
|
|
289
|
+
getOpenCount = _props2.getOpenCount;
|
|
290
|
+
|
|
291
|
+
if ((visible || this.inTransition) && !getOpenCount()) {
|
|
292
|
+
this.switchScrollingEffect();
|
|
293
|
+
}
|
|
294
|
+
clearTimeout(this.timeoutId);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
Dialog.prototype.tryFocus = function tryFocus() {
|
|
298
|
+
if (!contains(this.wrap, document.activeElement)) {
|
|
299
|
+
this.lastOutSideFocusNode = document.activeElement;
|
|
300
|
+
this.sentinelStart.focus();
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
Dialog.prototype.render = function render() {
|
|
305
|
+
var props = this.props;
|
|
306
|
+
var prefixCls = props.prefixCls,
|
|
307
|
+
maskClosable = props.maskClosable;
|
|
308
|
+
|
|
309
|
+
var style = this.getWrapStyle();
|
|
310
|
+
// clear hide display
|
|
311
|
+
// and only set display after async anim, not here for hide
|
|
312
|
+
if (props.visible) {
|
|
313
|
+
style.display = null;
|
|
314
|
+
}
|
|
315
|
+
return React.createElement("div", { className: prefixCls + '-root' }, this.getMaskElement(), React.createElement("div", _extends$4({ tabIndex: -1, onKeyDown: this.onKeyDown, className: prefixCls + '-wrap ' + (props.wrapClassName || ''), ref: this.saveRef('wrap'), onClick: maskClosable ? this.onMaskClick : null, onMouseUp: maskClosable ? this.onMaskMouseUp : null, role: "dialog", "aria-labelledby": props.title ? this.titleId : null, style: style }, props.wrapProps), this.getDialogElement()));
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
return Dialog;
|
|
319
|
+
}(React.Component);
|
|
320
|
+
|
|
321
|
+
Dialog$1.defaultProps = {
|
|
322
|
+
className: '',
|
|
323
|
+
mask: true,
|
|
324
|
+
visible: false,
|
|
325
|
+
keyboard: true,
|
|
326
|
+
closable: true,
|
|
327
|
+
maskClosable: true,
|
|
328
|
+
destroyOnClose: false,
|
|
329
|
+
prefixCls: 'rc-dialog',
|
|
330
|
+
focusTriggerAfterClose: true
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
// fix issue #10656
|
|
334
|
+
/*
|
|
335
|
+
* getContainer remarks
|
|
336
|
+
* Custom container should not be return, because in the Portal component, it will remove the
|
|
337
|
+
* return container element here, if the custom container is the only child of it's component,
|
|
338
|
+
* like issue #10656, It will has a conflict with removeChild method in react-dom.
|
|
339
|
+
* So here should add a child (div element) to custom container.
|
|
340
|
+
* */
|
|
341
|
+
var Dialog = (function (props) {
|
|
342
|
+
var visible = props.visible,
|
|
343
|
+
getContainer = props.getContainer,
|
|
344
|
+
forceRender = props.forceRender;
|
|
345
|
+
// 渲染在当前 dom 里;
|
|
346
|
+
|
|
347
|
+
if (getContainer === false) {
|
|
348
|
+
return React.createElement(Dialog$1, _extends$4({}, props, { getOpenCount: function getOpenCount() {
|
|
349
|
+
return 2;
|
|
350
|
+
} }));
|
|
351
|
+
}
|
|
352
|
+
return React.createElement(Portal, { visible: visible, forceRender: forceRender, getContainer: getContainer }, function (childProps) {
|
|
353
|
+
return React.createElement(Dialog$1, _extends$4({}, props, childProps));
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
|
|
358
|
+
|
|
359
|
+
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
360
|
+
|
|
361
|
+
function _extends$3() { _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
|
|
362
|
+
|
|
363
|
+
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
364
|
+
|
|
365
|
+
function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
366
|
+
|
|
367
|
+
function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); return Constructor; }
|
|
368
|
+
|
|
369
|
+
function _inherits$1(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$1(subClass, superClass); }
|
|
370
|
+
|
|
371
|
+
function _setPrototypeOf$1(o, p) { _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$1(o, p); }
|
|
372
|
+
|
|
373
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf$1(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$1(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$1(this, result); }; }
|
|
374
|
+
|
|
375
|
+
function _possibleConstructorReturn$1(self, call) { if (call && (_typeof$1(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$1(self); }
|
|
376
|
+
|
|
377
|
+
function _assertThisInitialized$1(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
378
|
+
|
|
379
|
+
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
380
|
+
|
|
381
|
+
function _getPrototypeOf$1(o) { _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$1(o); }
|
|
382
|
+
|
|
383
|
+
var __rest = undefined && undefined.__rest || function (s, e) {
|
|
384
|
+
var t = {};
|
|
385
|
+
|
|
386
|
+
for (var p in s) {
|
|
387
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
391
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
392
|
+
}
|
|
393
|
+
return t;
|
|
394
|
+
};
|
|
395
|
+
var mousePosition;
|
|
396
|
+
var destroyFns = []; // ref: https://github.com/ant-design/ant-design/issues/15795
|
|
397
|
+
|
|
398
|
+
var getClickPosition = function getClickPosition(e) {
|
|
399
|
+
mousePosition = {
|
|
400
|
+
x: e.pageX,
|
|
401
|
+
y: e.pageY
|
|
402
|
+
}; // 100ms 内发生过点击事件,则从点击位置动画展示
|
|
403
|
+
// 否则直接 zoom 展示
|
|
404
|
+
// 这样可以兼容非点击方式展开
|
|
405
|
+
|
|
406
|
+
setTimeout(function () {
|
|
407
|
+
return mousePosition = null;
|
|
408
|
+
}, 100);
|
|
409
|
+
}; // 只有点击事件支持从鼠标位置动画展开
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
if (typeof window !== 'undefined' && window.document && window.document.documentElement) {
|
|
413
|
+
addEventListenerWrap(document.documentElement, 'click', getClickPosition);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
var Modal = /*#__PURE__*/function (_React$Component) {
|
|
417
|
+
_inherits$1(Modal, _React$Component);
|
|
418
|
+
|
|
419
|
+
var _super = _createSuper$1(Modal);
|
|
420
|
+
|
|
421
|
+
function Modal() {
|
|
422
|
+
var _this;
|
|
423
|
+
|
|
424
|
+
_classCallCheck$1(this, Modal);
|
|
425
|
+
|
|
426
|
+
_this = _super.apply(this, arguments);
|
|
427
|
+
|
|
428
|
+
_this.handleCancel = function (e) {
|
|
429
|
+
var onCancel = _this.props.onCancel;
|
|
430
|
+
|
|
431
|
+
if (onCancel) {
|
|
432
|
+
onCancel(e);
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
_this.handleOk = function (e) {
|
|
437
|
+
var onOk = _this.props.onOk;
|
|
438
|
+
|
|
439
|
+
if (onOk) {
|
|
440
|
+
onOk(e);
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
_this.renderFooter = function (locale) {
|
|
445
|
+
var _this$props = _this.props,
|
|
446
|
+
okText = _this$props.okText,
|
|
447
|
+
okType = _this$props.okType,
|
|
448
|
+
cancelText = _this$props.cancelText,
|
|
449
|
+
confirmLoading = _this$props.confirmLoading;
|
|
450
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, _extends$3({
|
|
451
|
+
onClick: _this.handleCancel
|
|
452
|
+
}, _this.props.cancelButtonProps), cancelText || locale.cancelText), /*#__PURE__*/React.createElement(Button, _extends$3({
|
|
453
|
+
type: okType,
|
|
454
|
+
loading: confirmLoading,
|
|
455
|
+
onClick: _this.handleOk
|
|
456
|
+
}, _this.props.okButtonProps), okText || locale.okText));
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
_this.renderModal = function (_ref) {
|
|
460
|
+
var getContextPopupContainer = _ref.getPopupContainer,
|
|
461
|
+
getPrefixCls = _ref.getPrefixCls;
|
|
462
|
+
|
|
463
|
+
var _a = _this.props,
|
|
464
|
+
customizePrefixCls = _a.prefixCls,
|
|
465
|
+
footer = _a.footer,
|
|
466
|
+
visible = _a.visible,
|
|
467
|
+
wrapClassName = _a.wrapClassName,
|
|
468
|
+
centered = _a.centered,
|
|
469
|
+
getContainer = _a.getContainer,
|
|
470
|
+
closeIcon = _a.closeIcon,
|
|
471
|
+
restProps = __rest(_a, ["prefixCls", "footer", "visible", "wrapClassName", "centered", "getContainer", "closeIcon"]);
|
|
472
|
+
|
|
473
|
+
var prefixCls = getPrefixCls('modal', customizePrefixCls);
|
|
474
|
+
var defaultFooter = /*#__PURE__*/React.createElement(LocaleReceiver, {
|
|
475
|
+
componentName: "Modal",
|
|
476
|
+
defaultLocale: getConfirmLocale()
|
|
477
|
+
}, _this.renderFooter);
|
|
478
|
+
var closeIconToRender = /*#__PURE__*/React.createElement("span", {
|
|
479
|
+
className: "".concat(prefixCls, "-close-x")
|
|
480
|
+
}, closeIcon || /*#__PURE__*/React.createElement(Icon, {
|
|
481
|
+
className: "".concat(prefixCls, "-close-icon"),
|
|
482
|
+
type: "close"
|
|
483
|
+
}));
|
|
484
|
+
return /*#__PURE__*/React.createElement(Dialog, _extends$3({}, restProps, {
|
|
485
|
+
getContainer: getContainer === undefined ? getContextPopupContainer : getContainer,
|
|
486
|
+
prefixCls: prefixCls,
|
|
487
|
+
wrapClassName: classNames(_defineProperty$1({}, "".concat(prefixCls, "-centered"), !!centered), wrapClassName),
|
|
488
|
+
footer: footer === undefined ? defaultFooter : footer,
|
|
489
|
+
visible: visible,
|
|
490
|
+
mousePosition: mousePosition,
|
|
491
|
+
onClose: _this.handleCancel,
|
|
492
|
+
closeIcon: closeIconToRender
|
|
493
|
+
}));
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
return _this;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
_createClass$1(Modal, [{
|
|
500
|
+
key: "render",
|
|
501
|
+
value: function render() {
|
|
502
|
+
return /*#__PURE__*/React.createElement(ConfigConsumer, null, this.renderModal);
|
|
503
|
+
}
|
|
504
|
+
}]);
|
|
505
|
+
|
|
506
|
+
return Modal;
|
|
507
|
+
}(React.Component);
|
|
508
|
+
Modal.defaultProps = {
|
|
509
|
+
width: 520,
|
|
510
|
+
transitionName: 'zoom',
|
|
511
|
+
maskTransitionName: 'fade',
|
|
512
|
+
confirmLoading: false,
|
|
513
|
+
visible: false,
|
|
514
|
+
okType: 'primary'
|
|
515
|
+
};
|
|
516
|
+
Modal.propTypes = {
|
|
517
|
+
prefixCls: propTypesExports.string,
|
|
518
|
+
onOk: propTypesExports.func,
|
|
519
|
+
onCancel: propTypesExports.func,
|
|
520
|
+
okText: propTypesExports.node,
|
|
521
|
+
cancelText: propTypesExports.node,
|
|
522
|
+
centered: propTypesExports.bool,
|
|
523
|
+
width: propTypesExports.oneOfType([propTypesExports.number, propTypesExports.string]),
|
|
524
|
+
confirmLoading: propTypesExports.bool,
|
|
525
|
+
visible: propTypesExports.bool,
|
|
526
|
+
footer: propTypesExports.node,
|
|
527
|
+
title: propTypesExports.node,
|
|
528
|
+
closable: propTypesExports.bool,
|
|
529
|
+
closeIcon: propTypesExports.node
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
533
|
+
|
|
534
|
+
function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
|
|
535
|
+
|
|
536
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
537
|
+
|
|
538
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
539
|
+
|
|
540
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
|
|
541
|
+
|
|
542
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
543
|
+
|
|
544
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
545
|
+
|
|
546
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
547
|
+
|
|
548
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
549
|
+
|
|
550
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
551
|
+
|
|
552
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
553
|
+
|
|
554
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
555
|
+
|
|
556
|
+
var ActionButton = /*#__PURE__*/function (_React$Component) {
|
|
557
|
+
_inherits(ActionButton, _React$Component);
|
|
558
|
+
|
|
559
|
+
var _super = _createSuper(ActionButton);
|
|
560
|
+
|
|
561
|
+
function ActionButton(props) {
|
|
562
|
+
var _this;
|
|
563
|
+
|
|
564
|
+
_classCallCheck(this, ActionButton);
|
|
565
|
+
|
|
566
|
+
_this = _super.call(this, props);
|
|
567
|
+
|
|
568
|
+
_this.onClick = function () {
|
|
569
|
+
var _this$props = _this.props,
|
|
570
|
+
actionFn = _this$props.actionFn,
|
|
571
|
+
closeModal = _this$props.closeModal;
|
|
572
|
+
|
|
573
|
+
if (actionFn) {
|
|
574
|
+
var ret;
|
|
575
|
+
|
|
576
|
+
if (actionFn.length) {
|
|
577
|
+
ret = actionFn(closeModal);
|
|
578
|
+
} else {
|
|
579
|
+
ret = actionFn();
|
|
580
|
+
|
|
581
|
+
if (!ret) {
|
|
582
|
+
closeModal();
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
if (ret && ret.then) {
|
|
587
|
+
_this.setState({
|
|
588
|
+
loading: true
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
ret.then(function () {
|
|
592
|
+
// It's unnecessary to set loading=false, for the Modal will be unmounted after close.
|
|
593
|
+
// this.setState({ loading: false });
|
|
594
|
+
closeModal.apply(void 0, arguments);
|
|
595
|
+
}, function (e) {
|
|
596
|
+
// Emit error when catch promise reject
|
|
597
|
+
// eslint-disable-next-line no-console
|
|
598
|
+
console.error(e); // See: https://github.com/ant-design/ant-design/issues/6183
|
|
599
|
+
|
|
600
|
+
_this.setState({
|
|
601
|
+
loading: false
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
} else {
|
|
606
|
+
closeModal();
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
_this.state = {
|
|
611
|
+
loading: false
|
|
612
|
+
};
|
|
613
|
+
return _this;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
_createClass(ActionButton, [{
|
|
617
|
+
key: "componentDidMount",
|
|
618
|
+
value: function componentDidMount() {
|
|
619
|
+
if (this.props.autoFocus) {
|
|
620
|
+
var $this = ReactDOM.findDOMNode(this);
|
|
621
|
+
this.timeoutId = setTimeout(function () {
|
|
622
|
+
return $this.focus();
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}, {
|
|
627
|
+
key: "componentWillUnmount",
|
|
628
|
+
value: function componentWillUnmount() {
|
|
629
|
+
clearTimeout(this.timeoutId);
|
|
630
|
+
}
|
|
631
|
+
}, {
|
|
632
|
+
key: "render",
|
|
633
|
+
value: function render() {
|
|
634
|
+
var _this$props2 = this.props,
|
|
635
|
+
type = _this$props2.type,
|
|
636
|
+
children = _this$props2.children,
|
|
637
|
+
buttonProps = _this$props2.buttonProps;
|
|
638
|
+
var loading = this.state.loading;
|
|
639
|
+
return /*#__PURE__*/React.createElement(Button, _extends$2({
|
|
640
|
+
type: type,
|
|
641
|
+
onClick: this.onClick,
|
|
642
|
+
loading: loading
|
|
643
|
+
}, buttonProps), children);
|
|
644
|
+
}
|
|
645
|
+
}]);
|
|
646
|
+
|
|
647
|
+
return ActionButton;
|
|
648
|
+
}(React.Component);
|
|
649
|
+
|
|
650
|
+
function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
651
|
+
|
|
652
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
653
|
+
var IS_REACT_16 = !!ReactDOM.createPortal;
|
|
654
|
+
|
|
655
|
+
var ConfirmDialog = function ConfirmDialog(props) {
|
|
656
|
+
var onCancel = props.onCancel,
|
|
657
|
+
onOk = props.onOk,
|
|
658
|
+
close = props.close,
|
|
659
|
+
zIndex = props.zIndex,
|
|
660
|
+
afterClose = props.afterClose,
|
|
661
|
+
visible = props.visible,
|
|
662
|
+
keyboard = props.keyboard,
|
|
663
|
+
centered = props.centered,
|
|
664
|
+
getContainer = props.getContainer,
|
|
665
|
+
maskStyle = props.maskStyle,
|
|
666
|
+
okButtonProps = props.okButtonProps,
|
|
667
|
+
cancelButtonProps = props.cancelButtonProps,
|
|
668
|
+
_props$iconType = props.iconType,
|
|
669
|
+
iconType = _props$iconType === void 0 ? 'question-circle' : _props$iconType;
|
|
670
|
+
|
|
671
|
+
var icon = props.icon === undefined ? iconType : props.icon;
|
|
672
|
+
var okType = props.okType || 'primary';
|
|
673
|
+
var prefixCls = props.prefixCls || 'ant-modal';
|
|
674
|
+
var contentPrefixCls = "".concat(prefixCls, "-confirm"); // 默认为 true,保持向下兼容
|
|
675
|
+
|
|
676
|
+
var okCancel = 'okCancel' in props ? props.okCancel : true;
|
|
677
|
+
var width = props.width || 416;
|
|
678
|
+
var style = props.style || {};
|
|
679
|
+
var mask = props.mask === undefined ? true : props.mask; // 默认为 false,保持旧版默认行为
|
|
680
|
+
|
|
681
|
+
var maskClosable = props.maskClosable === undefined ? false : props.maskClosable;
|
|
682
|
+
var runtimeLocale = getConfirmLocale();
|
|
683
|
+
var okText = props.okText || (okCancel ? runtimeLocale.okText : runtimeLocale.justOkText);
|
|
684
|
+
var cancelText = props.cancelText || runtimeLocale.cancelText;
|
|
685
|
+
var autoFocusButton = props.autoFocusButton === null ? false : props.autoFocusButton || 'ok';
|
|
686
|
+
var transitionName = props.transitionName || 'zoom';
|
|
687
|
+
var maskTransitionName = props.maskTransitionName || 'fade';
|
|
688
|
+
var classString = classNames(contentPrefixCls, "".concat(contentPrefixCls, "-").concat(props.type), props.className);
|
|
689
|
+
var cancelButton = okCancel && /*#__PURE__*/React.createElement(ActionButton, {
|
|
690
|
+
actionFn: onCancel,
|
|
691
|
+
closeModal: close,
|
|
692
|
+
autoFocus: autoFocusButton === 'cancel',
|
|
693
|
+
buttonProps: cancelButtonProps
|
|
694
|
+
}, cancelText);
|
|
695
|
+
var iconNode = typeof icon === 'string' ? /*#__PURE__*/React.createElement(Icon, {
|
|
696
|
+
type: icon
|
|
697
|
+
}) : icon;
|
|
698
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
699
|
+
prefixCls: prefixCls,
|
|
700
|
+
className: classString,
|
|
701
|
+
wrapClassName: classNames(_defineProperty({}, "".concat(contentPrefixCls, "-centered"), !!props.centered)),
|
|
702
|
+
onCancel: function onCancel() {
|
|
703
|
+
return close({
|
|
704
|
+
triggerCancel: true
|
|
705
|
+
});
|
|
706
|
+
},
|
|
707
|
+
visible: visible,
|
|
708
|
+
title: "",
|
|
709
|
+
transitionName: transitionName,
|
|
710
|
+
footer: "",
|
|
711
|
+
maskTransitionName: maskTransitionName,
|
|
712
|
+
mask: mask,
|
|
713
|
+
maskClosable: maskClosable,
|
|
714
|
+
maskStyle: maskStyle,
|
|
715
|
+
style: style,
|
|
716
|
+
width: width,
|
|
717
|
+
zIndex: zIndex,
|
|
718
|
+
afterClose: afterClose,
|
|
719
|
+
keyboard: keyboard,
|
|
720
|
+
centered: centered,
|
|
721
|
+
getContainer: getContainer
|
|
722
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
723
|
+
className: "".concat(contentPrefixCls, "-body-wrapper")
|
|
724
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
725
|
+
className: "".concat(contentPrefixCls, "-body")
|
|
726
|
+
}, iconNode, props.title === undefined ? null : /*#__PURE__*/React.createElement("span", {
|
|
727
|
+
className: "".concat(contentPrefixCls, "-title")
|
|
728
|
+
}, props.title), /*#__PURE__*/React.createElement("div", {
|
|
729
|
+
className: "".concat(contentPrefixCls, "-content")
|
|
730
|
+
}, props.content)), /*#__PURE__*/React.createElement("div", {
|
|
731
|
+
className: "".concat(contentPrefixCls, "-btns")
|
|
732
|
+
}, cancelButton, /*#__PURE__*/React.createElement(ActionButton, {
|
|
733
|
+
type: okType,
|
|
734
|
+
actionFn: onOk,
|
|
735
|
+
closeModal: close,
|
|
736
|
+
autoFocus: autoFocusButton === 'ok',
|
|
737
|
+
buttonProps: okButtonProps
|
|
738
|
+
}, okText))));
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
function confirm(config) {
|
|
742
|
+
var div = document.createElement('div');
|
|
743
|
+
document.body.appendChild(div); // eslint-disable-next-line no-use-before-define
|
|
744
|
+
|
|
745
|
+
var currentConfig = _extends$1(_extends$1({}, config), {
|
|
746
|
+
close: close,
|
|
747
|
+
visible: true
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
function destroy() {
|
|
751
|
+
var unmountResult = ReactDOM.unmountComponentAtNode(div);
|
|
752
|
+
|
|
753
|
+
if (unmountResult && div.parentNode) {
|
|
754
|
+
div.parentNode.removeChild(div);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
758
|
+
args[_key] = arguments[_key];
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
var triggerCancel = args.some(function (param) {
|
|
762
|
+
return param && param.triggerCancel;
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
if (config.onCancel && triggerCancel) {
|
|
766
|
+
config.onCancel.apply(config, args);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
for (var i = 0; i < destroyFns.length; i++) {
|
|
770
|
+
var fn = destroyFns[i]; // eslint-disable-next-line no-use-before-define
|
|
771
|
+
|
|
772
|
+
if (fn === close) {
|
|
773
|
+
destroyFns.splice(i, 1);
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
function render(props) {
|
|
780
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(ConfirmDialog, props), div);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
function close() {
|
|
784
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
785
|
+
args[_key2] = arguments[_key2];
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
currentConfig = _extends$1(_extends$1({}, currentConfig), {
|
|
789
|
+
visible: false,
|
|
790
|
+
afterClose: destroy.bind.apply(destroy, [this].concat(args))
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
if (IS_REACT_16) {
|
|
794
|
+
render(currentConfig);
|
|
795
|
+
} else {
|
|
796
|
+
destroy.apply(void 0, args);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
function update(newConfig) {
|
|
801
|
+
currentConfig = _extends$1(_extends$1({}, currentConfig), newConfig);
|
|
802
|
+
render(currentConfig);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
render(currentConfig);
|
|
806
|
+
destroyFns.push(close);
|
|
807
|
+
return {
|
|
808
|
+
destroy: close,
|
|
809
|
+
update: update
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
814
|
+
|
|
815
|
+
function modalWarn(props) {
|
|
816
|
+
var config = _extends({
|
|
817
|
+
type: 'warning',
|
|
818
|
+
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
819
|
+
type: "exclamation-circle"
|
|
820
|
+
}),
|
|
821
|
+
okCancel: false
|
|
822
|
+
}, props);
|
|
823
|
+
|
|
824
|
+
return confirm(config);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
Modal.info = function infoFn(props) {
|
|
828
|
+
var config = _extends({
|
|
829
|
+
type: 'info',
|
|
830
|
+
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
831
|
+
type: "info-circle"
|
|
832
|
+
}),
|
|
833
|
+
okCancel: false
|
|
834
|
+
}, props);
|
|
835
|
+
|
|
836
|
+
return confirm(config);
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
Modal.success = function successFn(props) {
|
|
840
|
+
var config = _extends({
|
|
841
|
+
type: 'success',
|
|
842
|
+
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
843
|
+
type: "check-circle"
|
|
844
|
+
}),
|
|
845
|
+
okCancel: false
|
|
846
|
+
}, props);
|
|
847
|
+
|
|
848
|
+
return confirm(config);
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
Modal.error = function errorFn(props) {
|
|
852
|
+
var config = _extends({
|
|
853
|
+
type: 'error',
|
|
854
|
+
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
855
|
+
type: "close-circle"
|
|
856
|
+
}),
|
|
857
|
+
okCancel: false
|
|
858
|
+
}, props);
|
|
859
|
+
|
|
860
|
+
return confirm(config);
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
Modal.warning = modalWarn;
|
|
864
|
+
Modal.warn = modalWarn;
|
|
865
|
+
|
|
866
|
+
Modal.confirm = function confirmFn(props) {
|
|
867
|
+
var config = _extends({
|
|
868
|
+
type: 'confirm',
|
|
869
|
+
okCancel: true
|
|
870
|
+
}, props);
|
|
871
|
+
|
|
872
|
+
return confirm(config);
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
Modal.destroyAll = function destroyAllFn() {
|
|
876
|
+
while (destroyFns.length) {
|
|
877
|
+
var close = destroyFns.pop();
|
|
878
|
+
|
|
879
|
+
if (close) {
|
|
880
|
+
close();
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
export { Modal as default };
|