@autobest-ui/components 2.3.0 → 2.4.0
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/esm/accordion/Item.js +6 -23
- package/esm/accordion/index.js +8 -36
- package/esm/affix/PortalAffix.js +7 -11
- package/esm/affix/index.js +30 -70
- package/esm/carousel/index.js +45 -141
- package/esm/checkbox/index.js +12 -37
- package/esm/collapse/index.js +11 -49
- package/esm/confirm/index.d.ts +8 -0
- package/esm/confirm/index.js +23 -31
- package/esm/date-picker/DateEnum.js +0 -3
- package/esm/date-picker/calendar/Day.js +62 -78
- package/esm/date-picker/calendar/MonthYear.js +20 -53
- package/esm/date-picker/calendar/grid/index.js +7 -12
- package/esm/date-picker/calendar/index.js +4 -31
- package/esm/date-picker/index.js +11 -51
- package/esm/date-picker/utils.js +6 -11
- package/esm/drawer/Child.js +10 -20
- package/esm/drawer/index.js +22 -71
- package/esm/ellipsis/index.js +9 -17
- package/esm/guide/index.js +25 -63
- package/esm/index.d.ts +1 -1
- package/esm/input-number/ControlArrow.js +0 -2
- package/esm/input-number/constants.js +2 -2
- package/esm/input-number/index.js +26 -106
- package/esm/lazy-image/index.js +10 -55
- package/esm/link-list/index.js +11 -35
- package/esm/loading/index.js +15 -42
- package/esm/loading-container/index.js +3 -6
- package/esm/loading-icon/index.js +0 -2
- package/esm/mask/index.js +6 -9
- package/esm/message/index.d.ts +17 -6
- package/esm/message/index.js +68 -96
- package/esm/message/renderMessage.d.ts +17 -0
- package/esm/message/renderMessage.js +137 -0
- package/esm/message/style/index.css +1 -1
- package/esm/modal/Title.js +5 -12
- package/esm/modal/getPopupLocation.js +5 -7
- package/esm/modal/index.js +44 -125
- package/esm/move/index.js +32 -132
- package/esm/move/range.js +6 -12
- package/esm/move/utils.js +3 -10
- package/esm/popover/index.js +9 -28
- package/esm/portal/index.js +1 -22
- package/esm/script/index.js +19 -59
- package/esm/select/index.js +28 -106
- package/esm/show-more/index.js +40 -103
- package/esm/skeleton/Item.js +1 -3
- package/esm/skeleton/index.js +5 -11
- package/esm/style.css +1 -1
- package/esm/table/body/BodyRow.js +11 -28
- package/esm/table/body/CheckIcon.js +10 -18
- package/esm/table/body/index.js +8 -12
- package/esm/table/header/CheckIcon.js +3 -11
- package/esm/table/header/HeaderCell.js +12 -33
- package/esm/table/header/HeaderRow.js +6 -17
- package/esm/table/index.js +30 -100
- package/esm/tabs/index.js +35 -118
- package/esm/tooltip/index.js +0 -4
- package/esm/trigger/align.js +6 -6
- package/esm/trigger/bottomAlign.js +33 -45
- package/esm/trigger/constants.js +0 -1
- package/esm/trigger/getPopupLocation.js +48 -68
- package/esm/trigger/index.js +52 -187
- package/esm/trigger/leftAlign.js +33 -47
- package/esm/trigger/ref.js +2 -7
- package/esm/trigger/rightAlign.js +33 -45
- package/esm/trigger/topAlign.js +33 -45
- package/esm/trigger/utils.js +28 -45
- package/lib/accordion/Item.js +6 -27
- package/lib/accordion/index.js +8 -41
- package/lib/affix/PortalAffix.js +7 -17
- package/lib/affix/index.js +30 -75
- package/lib/carousel/index.js +45 -146
- package/lib/checkbox/index.js +12 -41
- package/lib/collapse/index.js +11 -53
- package/lib/confirm/index.d.ts +8 -0
- package/lib/confirm/index.js +23 -38
- package/lib/date-picker/DateEnum.js +0 -3
- package/lib/date-picker/calendar/Day.js +62 -87
- package/lib/date-picker/calendar/MonthYear.js +20 -62
- package/lib/date-picker/calendar/grid/index.js +7 -16
- package/lib/date-picker/calendar/index.js +4 -37
- package/lib/date-picker/index.js +9 -58
- package/lib/date-picker/utils.js +6 -26
- package/lib/drawer/Child.js +10 -25
- package/lib/drawer/index.js +22 -78
- package/lib/ellipsis/index.js +9 -23
- package/lib/guide/index.js +25 -71
- package/lib/index.d.ts +1 -1
- package/lib/index.js +0 -29
- package/lib/input-number/ControlArrow.js +0 -4
- package/lib/input-number/constants.js +2 -2
- package/lib/input-number/index.js +26 -114
- package/lib/lazy-image/index.js +10 -58
- package/lib/link-list/index.js +11 -40
- package/lib/loading/index.js +13 -48
- package/lib/loading-bar/index.js +0 -5
- package/lib/loading-container/index.js +3 -11
- package/lib/loading-icon/index.js +0 -7
- package/lib/mask/index.js +6 -17
- package/lib/message/index.d.ts +17 -6
- package/lib/message/index.js +67 -104
- package/lib/message/renderMessage.d.ts +17 -0
- package/lib/message/renderMessage.js +144 -0
- package/lib/message/style/index.css +1 -1
- package/lib/modal/Affix.js +0 -4
- package/lib/modal/Title.js +5 -15
- package/lib/modal/getPopupLocation.js +5 -9
- package/lib/modal/index.js +44 -135
- package/lib/move/index.js +32 -144
- package/lib/move/range.js +6 -14
- package/lib/move/utils.js +3 -12
- package/lib/popover/index.js +9 -33
- package/lib/portal/index.js +1 -25
- package/lib/script/index.js +19 -61
- package/lib/select/index.js +28 -113
- package/lib/show-more/index.js +40 -110
- package/lib/skeleton/Item.js +1 -8
- package/lib/skeleton/index.js +5 -16
- package/lib/style.css +1 -1
- package/lib/table/body/BodyRow.js +11 -33
- package/lib/table/body/CheckIcon.js +10 -22
- package/lib/table/body/index.js +8 -17
- package/lib/table/header/CheckIcon.js +3 -15
- package/lib/table/header/HeaderCell.js +12 -37
- package/lib/table/header/HeaderRow.js +6 -22
- package/lib/table/index.js +30 -107
- package/lib/tabs/index.js +35 -122
- package/lib/tooltip/index.js +0 -9
- package/lib/trigger/align.js +0 -4
- package/lib/trigger/bottomAlign.js +33 -48
- package/lib/trigger/constants.js +0 -2
- package/lib/trigger/getPopupLocation.js +48 -74
- package/lib/trigger/index.js +52 -198
- package/lib/trigger/leftAlign.js +33 -50
- package/lib/trigger/ref.js +2 -12
- package/lib/trigger/rightAlign.js +33 -48
- package/lib/trigger/topAlign.js +33 -48
- package/lib/trigger/utils.js +28 -53
- package/package.json +7 -3
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var __extends = this && this.__extends || function () {
|
|
2
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
3
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
4
|
+
__proto__: []
|
|
5
|
+
} instanceof Array && function (d, b) {
|
|
6
|
+
d.__proto__ = b;
|
|
7
|
+
} || function (d, b) {
|
|
8
|
+
for (var p in b) {
|
|
9
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
return _extendStatics(d, b);
|
|
13
|
+
};
|
|
14
|
+
return function (d, b) {
|
|
15
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
16
|
+
_extendStatics(d, b);
|
|
17
|
+
function __() {
|
|
18
|
+
this.constructor = d;
|
|
19
|
+
}
|
|
20
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
21
|
+
};
|
|
22
|
+
}();
|
|
23
|
+
import ReactDOM from 'react-dom';
|
|
24
|
+
import { CSSTransition, TransitionGroup } from 'react-transition-group';
|
|
25
|
+
import classNames from 'classnames';
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { getElementSize, isEmptyArray } from '@autobest-ui/utils';
|
|
28
|
+
var container = null;
|
|
29
|
+
/**
|
|
30
|
+
* Transition的组件,绑定其事件,处理收缩问题
|
|
31
|
+
*/
|
|
32
|
+
var TransitionContent = /** @class */function (_super) {
|
|
33
|
+
__extends(TransitionContent, _super);
|
|
34
|
+
function TransitionContent() {
|
|
35
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
36
|
+
_this.removeContainer = function () {
|
|
37
|
+
if (container) {
|
|
38
|
+
document.body.removeChild(container);
|
|
39
|
+
container = null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
_this.onEnter = function (element) {
|
|
43
|
+
if (!element) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
var height = getElementSize(element).height;
|
|
47
|
+
_this.elementContentHeight = height;
|
|
48
|
+
element.style.height = '0';
|
|
49
|
+
};
|
|
50
|
+
_this.onEntering = function (element) {
|
|
51
|
+
if (element) {
|
|
52
|
+
element.style.height = "".concat(_this.elementContentHeight, "px");
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
_this.onEntered = function (element) {
|
|
56
|
+
if (element) {
|
|
57
|
+
element.style.height = '';
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
_this.onExit = function (element) {
|
|
61
|
+
if (!element) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
var height = getElementSize(element).height;
|
|
65
|
+
element.style.height = "".concat(height, "px");
|
|
66
|
+
};
|
|
67
|
+
_this.onExiting = function (element) {
|
|
68
|
+
if (element) {
|
|
69
|
+
element.style.height = '0';
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
_this.onExited = function (item) {
|
|
73
|
+
if (isEmptyArray(_this.props.options)) {
|
|
74
|
+
_this.removeContainer();
|
|
75
|
+
}
|
|
76
|
+
if (item.onDestroy) {
|
|
77
|
+
item.onDestroy();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return _this;
|
|
81
|
+
}
|
|
82
|
+
TransitionContent.prototype.componentWillUnmount = function () {
|
|
83
|
+
this.removeContainer();
|
|
84
|
+
};
|
|
85
|
+
TransitionContent.prototype.render = function () {
|
|
86
|
+
var _this = this;
|
|
87
|
+
var _a = this.props,
|
|
88
|
+
options = _a.options,
|
|
89
|
+
prefixCls = _a.prefixCls;
|
|
90
|
+
return /*#__PURE__*/React.createElement(TransitionGroup, {
|
|
91
|
+
component: null
|
|
92
|
+
}, options.map(function (item) {
|
|
93
|
+
var content = item.content,
|
|
94
|
+
onClose = item.onClose,
|
|
95
|
+
contentClassName = item.contentClassName;
|
|
96
|
+
return /*#__PURE__*/React.createElement(CSSTransition, {
|
|
97
|
+
key: item.id,
|
|
98
|
+
timeout: 300,
|
|
99
|
+
classNames: "".concat(prefixCls, "-fade"),
|
|
100
|
+
onEnter: _this.onEnter,
|
|
101
|
+
onEntering: _this.onEntering,
|
|
102
|
+
onEntered: _this.onEntered,
|
|
103
|
+
onExit: _this.onExit,
|
|
104
|
+
onExiting: _this.onExiting,
|
|
105
|
+
onExited: function onExited() {
|
|
106
|
+
return _this.onExited(item);
|
|
107
|
+
},
|
|
108
|
+
appear: true
|
|
109
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
className: "".concat(prefixCls, "-notice")
|
|
111
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: classNames("".concat(prefixCls, "-content"), contentClassName)
|
|
113
|
+
}, content, /*#__PURE__*/React.createElement("div", {
|
|
114
|
+
className: "".concat(prefixCls, "-close"),
|
|
115
|
+
onClick: function onClick() {
|
|
116
|
+
return onClose(item.id);
|
|
117
|
+
}
|
|
118
|
+
}, "\xD7"))));
|
|
119
|
+
}));
|
|
120
|
+
};
|
|
121
|
+
return TransitionContent;
|
|
122
|
+
}(React.Component);
|
|
123
|
+
export default function renderMessage(props) {
|
|
124
|
+
var prefixCls = props.prefixCls,
|
|
125
|
+
options = props.options,
|
|
126
|
+
className = props.className;
|
|
127
|
+
// 创建容器
|
|
128
|
+
if (!container) {
|
|
129
|
+
container = document.createElement('div');
|
|
130
|
+
container.setAttribute('class', classNames(className, "".concat(prefixCls, "-container")));
|
|
131
|
+
document.body.appendChild(container);
|
|
132
|
+
}
|
|
133
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(TransitionContent, {
|
|
134
|
+
options: options,
|
|
135
|
+
prefixCls: prefixCls
|
|
136
|
+
}), container);
|
|
137
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-message-container{position:fixed
|
|
1
|
+
.ab-message-container{position:fixed}.ab-message-notice{overflow:hidden;transition:.3s ease-out}.ab-message-content{display:flex;align-items:center;justify-content:space-between;max-width:calc(100vw - .3rem);margin:.05rem .15rem;padding:.08rem;border-radius:.02rem;background-color:#333;color:#fff;box-shadow:0 .01rem .05rem #333}.ab-message-close{display:flex;align-items:center;justify-content:center;cursor:pointer;width:.2rem;height:.2rem;font-size:.2rem;margin-left:.08rem;color:#b0b0b0}.ab-message-close:hover{color:#fff}.ab-message-fade-appear,.ab-message-fade-enter{opacity:0}.ab-message-fade-appear-active,.ab-message-fade-enter-active,.ab-message-fade-enter-done,.ab-message-fade-exit{opacity:1}.ab-message-fade-exit-active{opacity:0}.ab-message-fade-exit-done{display:none}@media only screen and (max-width:767px){.ab-message-content{width:calc(100vw - .3rem);margin:.08rem .15rem}}
|
package/esm/modal/Title.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
2
|
function Times(_a) {
|
|
4
3
|
var prefixCls = _a.prefixCls,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
onClose = _a.onClose,
|
|
5
|
+
closable = _a.closable;
|
|
8
6
|
if (closable) {
|
|
9
7
|
return /*#__PURE__*/React.createElement("span", {
|
|
10
8
|
className: "".concat(prefixCls, "-times"),
|
|
@@ -23,16 +21,13 @@ function Times(_a) {
|
|
|
23
21
|
d: "M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"
|
|
24
22
|
})));
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
return null;
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
function Title(_a) {
|
|
31
27
|
var title = _a.title,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
closable = _a.closable,
|
|
29
|
+
prefixCls = _a.prefixCls,
|
|
30
|
+
onClose = _a.onClose;
|
|
36
31
|
if (title) {
|
|
37
32
|
return /*#__PURE__*/React.createElement("div", {
|
|
38
33
|
className: "".concat(prefixCls, "-title")
|
|
@@ -42,12 +37,10 @@ function Title(_a) {
|
|
|
42
37
|
onClose: onClose
|
|
43
38
|
}));
|
|
44
39
|
}
|
|
45
|
-
|
|
46
40
|
return /*#__PURE__*/React.createElement(Times, {
|
|
47
41
|
prefixCls: prefixCls,
|
|
48
42
|
closable: closable,
|
|
49
43
|
onClose: onClose
|
|
50
44
|
});
|
|
51
45
|
}
|
|
52
|
-
|
|
53
46
|
export default /*#__PURE__*/React.memo(Title);
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { getAvailSize, getElementSize } from '@autobest-ui/utils';
|
|
2
2
|
export default function getPopupLocation(_a) {
|
|
3
3
|
var placement = _a.placement,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
element = _a.element,
|
|
5
|
+
targetTop = _a.targetTop,
|
|
6
|
+
popupLimitSpacing = _a.popupLimitSpacing;
|
|
7
7
|
var clientSize = getAvailSize(true);
|
|
8
8
|
var popupSize = getElementSize(element);
|
|
9
9
|
var doubleLimit = popupLimitSpacing * 2;
|
|
10
10
|
var height = popupSize.height > clientSize.height - doubleLimit ? "".concat(clientSize.height - doubleLimit, "px") : '';
|
|
11
|
-
|
|
12
11
|
if (placement === 'top') {
|
|
13
12
|
return {
|
|
14
13
|
top: targetTop,
|
|
15
14
|
height: height
|
|
16
15
|
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
}
|
|
17
|
+
// 默认center
|
|
20
18
|
return {
|
|
21
19
|
height: height
|
|
22
20
|
};
|
package/esm/modal/index.js
CHANGED
|
@@ -9,23 +9,17 @@ var __extends = this && this.__extends || function () {
|
|
|
9
9
|
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
|
|
13
12
|
return _extendStatics(d, b);
|
|
14
13
|
};
|
|
15
|
-
|
|
16
14
|
return function (d, b) {
|
|
17
15
|
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
18
|
-
|
|
19
16
|
_extendStatics(d, b);
|
|
20
|
-
|
|
21
17
|
function __() {
|
|
22
18
|
this.constructor = d;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
26
21
|
};
|
|
27
22
|
}();
|
|
28
|
-
|
|
29
23
|
import React from 'react';
|
|
30
24
|
import { CSSTransition } from 'react-transition-group';
|
|
31
25
|
import classNames from 'classnames';
|
|
@@ -35,7 +29,6 @@ import Mask from '../mask';
|
|
|
35
29
|
import Title from './Title';
|
|
36
30
|
import Affix from './Affix';
|
|
37
31
|
import getPopupLocation from './getPopupLocation';
|
|
38
|
-
|
|
39
32
|
function getId() {
|
|
40
33
|
try {
|
|
41
34
|
return new Date().getTime();
|
|
@@ -43,15 +36,10 @@ function getId() {
|
|
|
43
36
|
return Math.random();
|
|
44
37
|
}
|
|
45
38
|
}
|
|
46
|
-
|
|
47
|
-
var Modal =
|
|
48
|
-
/** @class */
|
|
49
|
-
function (_super) {
|
|
39
|
+
var Modal = /** @class */function (_super) {
|
|
50
40
|
__extends(Modal, _super);
|
|
51
|
-
|
|
52
41
|
function Modal(props) {
|
|
53
42
|
var _this = _super.call(this, props) || this;
|
|
54
|
-
|
|
55
43
|
_this.openId = getId();
|
|
56
44
|
_this.prefixCls = 'ab-modal';
|
|
57
45
|
_this.scrollBarSize = 0;
|
|
@@ -61,114 +49,88 @@ function (_super) {
|
|
|
61
49
|
* 全局事件回调
|
|
62
50
|
* @param event
|
|
63
51
|
*/
|
|
64
|
-
|
|
65
52
|
_this.onDocumentClick = function (event) {
|
|
66
53
|
if (!_this.props.visible) {
|
|
67
54
|
return;
|
|
68
55
|
}
|
|
69
|
-
|
|
70
56
|
var target = event.target;
|
|
71
|
-
|
|
72
57
|
var popupEl = _this.getPopupDomNode();
|
|
73
|
-
|
|
74
58
|
var maskEl = _this.getMaskDomNode();
|
|
75
|
-
|
|
76
59
|
if (!target || !popupEl || !maskEl) {
|
|
77
60
|
return;
|
|
78
61
|
}
|
|
79
|
-
|
|
80
62
|
var notCloseElement;
|
|
81
|
-
|
|
82
63
|
if (_this.props.getNotCloseElement) {
|
|
83
64
|
notCloseElement = _this.props.getNotCloseElement();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
65
|
+
}
|
|
66
|
+
// 排除操作当前元素
|
|
87
67
|
if (!contains(popupEl, target) && (maskEl === target || target === popupEl.parentNode) || notCloseElement && !contains(notCloseElement, target)) {
|
|
88
68
|
_this.onClose(target, true);
|
|
89
69
|
}
|
|
90
70
|
};
|
|
91
|
-
|
|
92
71
|
_this.clearPopupTimer = function (popupEl) {
|
|
93
72
|
clearTimeout(_this.popupTimer);
|
|
94
|
-
|
|
95
73
|
var element = popupEl || _this.getPopupDomNode();
|
|
96
|
-
|
|
97
74
|
if (element) {
|
|
98
75
|
element.style.visibility = '';
|
|
99
76
|
}
|
|
100
77
|
};
|
|
101
|
-
|
|
102
78
|
_this.onClose = function (event, isOutsideClick) {
|
|
103
79
|
if (isOutsideClick === void 0) {
|
|
104
80
|
isOutsideClick = false;
|
|
105
81
|
}
|
|
106
|
-
|
|
107
82
|
var _a = _this.props,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
83
|
+
closable = _a.closable,
|
|
84
|
+
maskClosable = _a.maskClosable,
|
|
85
|
+
onClose = _a.onClose,
|
|
86
|
+
name = _a.name;
|
|
113
87
|
if ((isOutsideClick && maskClosable || !isOutsideClick && closable) && onClose) {
|
|
114
88
|
onClose(event, name);
|
|
115
89
|
}
|
|
116
90
|
};
|
|
117
|
-
|
|
118
91
|
_this.onEnter = function (popupEl) {
|
|
119
92
|
var element = popupEl || _this.getPopupDomNode();
|
|
120
|
-
|
|
121
93
|
if (!element) {
|
|
122
94
|
return;
|
|
123
95
|
}
|
|
124
|
-
|
|
125
96
|
if (element && element.parentNode) {
|
|
126
97
|
var parentNode = element.parentNode;
|
|
127
98
|
parentNode.style.display = 'block';
|
|
128
99
|
}
|
|
129
|
-
|
|
130
100
|
_this.clearPopupTimer(element);
|
|
131
|
-
|
|
132
101
|
var _a = _this.props,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
102
|
+
placement = _a.placement,
|
|
103
|
+
hiddenScroll = _a.hiddenScroll,
|
|
104
|
+
targetTop = _a.top,
|
|
105
|
+
popupLimitSpacing = _a.popupLimitSpacing;
|
|
138
106
|
if (hiddenScroll) {
|
|
139
107
|
Modal.cacheOpenedIds.push(_this.openId);
|
|
140
108
|
var currentDocument = window.document.body;
|
|
141
109
|
currentDocument.style.overflow = 'hidden';
|
|
142
|
-
|
|
143
110
|
if (hasVerticalScrollbar(_this.scrollBarSize)) {
|
|
144
111
|
currentDocument.style.paddingRight = "".concat(_this.scrollBarSize, "px");
|
|
145
|
-
|
|
146
112
|
if (element && element.parentNode) {
|
|
147
113
|
var parentNode = element.parentNode;
|
|
148
114
|
parentNode.style.paddingRight = "".concat(_this.scrollBarSize, "px");
|
|
149
115
|
}
|
|
150
116
|
}
|
|
151
117
|
}
|
|
152
|
-
|
|
153
118
|
var _b = getPopupLocation({
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
119
|
+
placement: placement,
|
|
120
|
+
element: element,
|
|
121
|
+
targetTop: targetTop,
|
|
122
|
+
popupLimitSpacing: popupLimitSpacing
|
|
123
|
+
}),
|
|
124
|
+
top = _b.top,
|
|
125
|
+
height = _b.height;
|
|
162
126
|
if (top) {
|
|
163
127
|
element.style.top = top;
|
|
164
128
|
}
|
|
165
|
-
|
|
166
129
|
if (height) {
|
|
167
130
|
element.style.height = height;
|
|
168
131
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
132
|
+
var isFixedTitle = _this.props.isFixedTitle;
|
|
133
|
+
// 固定title
|
|
172
134
|
if (isFixedTitle) {
|
|
173
135
|
// 需要延迟执行
|
|
174
136
|
_this.affixTimer = setTimeout(function () {
|
|
@@ -178,7 +140,6 @@ function (_super) {
|
|
|
178
140
|
var firstChildHeight = getStyleValue(firstChild, 'height');
|
|
179
141
|
lastChild.style.overflow = 'auto';
|
|
180
142
|
var popupHeight = height || _this.props.height;
|
|
181
|
-
|
|
182
143
|
if (!popupHeight || popupHeight === 'auto') {
|
|
183
144
|
lastChild.style.maxHeight = "calc(100vh - .3rem - ".concat(placement === 'top' && top ? top : '0px', " - ").concat(firstChildHeight, "px)");
|
|
184
145
|
} else {
|
|
@@ -187,55 +148,47 @@ function (_super) {
|
|
|
187
148
|
});
|
|
188
149
|
}
|
|
189
150
|
};
|
|
190
|
-
|
|
191
151
|
_this.onEntered = function () {
|
|
192
152
|
var _a = _this.props,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
153
|
+
onOpened = _a.onOpened,
|
|
154
|
+
name = _a.name;
|
|
196
155
|
if (onOpened) {
|
|
197
156
|
onOpened(name);
|
|
198
157
|
}
|
|
199
158
|
};
|
|
200
|
-
|
|
201
159
|
_this.onExited = function (element) {
|
|
202
160
|
clearTimeout(_this.affixTimer);
|
|
203
161
|
var _a = _this.props,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
162
|
+
hiddenScroll = _a.hiddenScroll,
|
|
163
|
+
onDestroy = _a.onDestroy,
|
|
164
|
+
name = _a.name;
|
|
207
165
|
var currentDocument = window.document.body;
|
|
208
|
-
|
|
209
166
|
if (hiddenScroll && currentDocument) {
|
|
210
167
|
// 删除指定id
|
|
211
168
|
Modal.cacheOpenedIds = Modal.cacheOpenedIds.filter(function (id) {
|
|
212
169
|
return id !== _this.openId;
|
|
213
|
-
});
|
|
214
|
-
|
|
170
|
+
});
|
|
171
|
+
// 如果都隐藏了,才清除body样式
|
|
215
172
|
if (Modal.cacheOpenedIds.length === 0) {
|
|
216
173
|
currentDocument.style.overflow = '';
|
|
217
174
|
currentDocument.style.paddingRight = '';
|
|
218
175
|
}
|
|
219
176
|
}
|
|
220
|
-
|
|
221
177
|
if (element && element.parentNode) {
|
|
222
178
|
var parentNode = element.parentNode;
|
|
223
179
|
parentNode.style.display = 'none';
|
|
224
180
|
parentNode.style.paddingRight = '';
|
|
225
181
|
}
|
|
226
|
-
|
|
227
182
|
if (onDestroy) {
|
|
228
183
|
onDestroy(name);
|
|
229
184
|
}
|
|
230
185
|
};
|
|
231
|
-
|
|
232
186
|
_this.state = {
|
|
233
187
|
isUserOperated: false,
|
|
234
188
|
cacheVisible: props.visible
|
|
235
189
|
};
|
|
236
190
|
return _this;
|
|
237
191
|
}
|
|
238
|
-
|
|
239
192
|
Modal.getDerivedStateFromProps = function (nextProps, preState) {
|
|
240
193
|
// isInsertNode为true时,只判断isUserOperated为false的情况
|
|
241
194
|
if (nextProps.isInsertNode && !preState.isUserOperated && preState.cacheVisible !== nextProps.visible) {
|
|
@@ -244,129 +197,101 @@ function (_super) {
|
|
|
244
197
|
isUserOperated: true
|
|
245
198
|
};
|
|
246
199
|
}
|
|
247
|
-
|
|
248
200
|
return null;
|
|
249
201
|
};
|
|
250
|
-
|
|
251
202
|
Modal.prototype.componentDidMount = function () {
|
|
252
203
|
this.scrollBarSize = getScrollBarSize();
|
|
253
204
|
this.componentDidUpdate();
|
|
254
205
|
};
|
|
255
|
-
|
|
256
206
|
Modal.prototype.getSnapshotBeforeUpdate = function () {
|
|
257
207
|
var popupEl = this.getPopupDomNode();
|
|
258
|
-
|
|
259
208
|
if (this.props.visible && popupEl) {
|
|
260
209
|
var displayValue = getStyle(popupEl, 'display');
|
|
261
|
-
|
|
262
210
|
if (displayValue === 'none') {
|
|
263
211
|
return null;
|
|
264
212
|
}
|
|
265
|
-
|
|
266
213
|
return getElementSize(popupEl);
|
|
267
214
|
}
|
|
268
|
-
|
|
269
215
|
return null;
|
|
270
216
|
};
|
|
271
|
-
|
|
272
217
|
Modal.prototype.componentDidUpdate = function (_prevProps, _prevState, prevPopupSize) {
|
|
273
218
|
var _this = this;
|
|
274
|
-
|
|
275
219
|
if (!this.props.visible) {
|
|
276
220
|
this.clearOutsideHandler();
|
|
277
221
|
return;
|
|
278
222
|
}
|
|
279
|
-
|
|
280
223
|
var currentDocument;
|
|
281
224
|
var touch = isTouchScreen();
|
|
282
|
-
|
|
283
225
|
if (!this.clickOutsideHandler && !touch) {
|
|
284
226
|
currentDocument = window.document;
|
|
285
227
|
this.clickOutsideHandler = addEventListener(currentDocument, 'mousedown', this.onDocumentClick);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
228
|
+
}
|
|
229
|
+
// always hide on mobile
|
|
289
230
|
if (!this.touchOutsideHandler && touch) {
|
|
290
231
|
currentDocument = currentDocument || window.document;
|
|
291
232
|
this.touchOutsideHandler = addEventListener(currentDocument, 'touchstart', this.onDocumentClick);
|
|
292
233
|
}
|
|
293
|
-
|
|
294
234
|
if (!prevPopupSize) {
|
|
295
235
|
return;
|
|
296
236
|
}
|
|
297
|
-
|
|
298
237
|
var popupEl = this.getPopupDomNode();
|
|
299
|
-
|
|
300
238
|
if (popupEl && prevPopupSize) {
|
|
301
239
|
var _a = getElementSize(popupEl),
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
240
|
+
width = _a.width,
|
|
241
|
+
height = _a.height;
|
|
305
242
|
if (prevPopupSize.width !== width || prevPopupSize.height !== height) {
|
|
306
243
|
this.clearPopupTimer(popupEl);
|
|
307
244
|
popupEl.style.visibility = 'hidden';
|
|
308
245
|
this.popupTimer = setTimeout(function () {
|
|
309
246
|
_this.onEnter(popupEl);
|
|
310
|
-
|
|
311
247
|
popupEl.style.visibility = '';
|
|
312
248
|
});
|
|
313
249
|
}
|
|
314
250
|
}
|
|
315
251
|
};
|
|
316
|
-
|
|
317
252
|
Modal.prototype.componentWillUnmount = function () {
|
|
318
253
|
// remove绑定事件
|
|
319
254
|
this.clearOutsideHandler();
|
|
320
255
|
this.onExited();
|
|
321
256
|
clearTimeout(this.affixTimer);
|
|
322
257
|
};
|
|
323
|
-
|
|
324
258
|
Modal.prototype.clearOutsideHandler = function () {
|
|
325
259
|
this.clearPopupTimer();
|
|
326
|
-
|
|
327
260
|
if (this.clickOutsideHandler) {
|
|
328
261
|
this.clickOutsideHandler.remove();
|
|
329
262
|
this.clickOutsideHandler = null;
|
|
330
263
|
}
|
|
331
|
-
|
|
332
264
|
if (this.touchOutsideHandler) {
|
|
333
265
|
this.touchOutsideHandler.remove();
|
|
334
266
|
this.touchOutsideHandler = null;
|
|
335
267
|
}
|
|
336
268
|
};
|
|
337
|
-
|
|
338
269
|
Modal.prototype.getPopupDomNode = function () {
|
|
339
270
|
if (this.popupRef && this.popupRef.current) {
|
|
340
271
|
return this.popupRef.current;
|
|
341
272
|
}
|
|
342
|
-
|
|
343
273
|
return null;
|
|
344
274
|
};
|
|
345
|
-
|
|
346
275
|
Modal.prototype.getMaskDomNode = function () {
|
|
347
276
|
if (this.maskRef && this.maskRef.current) {
|
|
348
277
|
return this.maskRef.current;
|
|
349
278
|
}
|
|
350
|
-
|
|
351
279
|
return null;
|
|
352
280
|
};
|
|
353
|
-
|
|
354
281
|
Modal.prototype.renderPopup = function () {
|
|
355
282
|
var _a;
|
|
356
|
-
|
|
357
283
|
var _this = this;
|
|
358
|
-
|
|
359
284
|
var cls = this.prefixCls;
|
|
360
285
|
var _b = this.props,
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
286
|
+
visible = _b.visible,
|
|
287
|
+
children = _b.children,
|
|
288
|
+
width = _b.width,
|
|
289
|
+
height = _b.height,
|
|
290
|
+
className = _b.className,
|
|
291
|
+
closable = _b.closable,
|
|
292
|
+
title = _b.title,
|
|
293
|
+
placement = _b.placement,
|
|
294
|
+
top = _b.top;
|
|
370
295
|
var maxHeight = "calc(100vh - .3rem - ".concat(placement === 'top' && top ? top : '0px', ")");
|
|
371
296
|
return /*#__PURE__*/React.createElement("div", {
|
|
372
297
|
className: classNames(cls, className, (_a = {}, _a["".concat(cls, "-center")] = placement === 'center', _a["".concat(this.prefixCls, "-hidden")] = !visible && !this.state.isUserOperated, _a))
|
|
@@ -395,12 +320,10 @@ function (_super) {
|
|
|
395
320
|
}), children);
|
|
396
321
|
}));
|
|
397
322
|
};
|
|
398
|
-
|
|
399
323
|
Modal.prototype.render = function () {
|
|
400
324
|
var _a;
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
325
|
+
var visible = this.props.visible;
|
|
326
|
+
// 插入元素,不使用传送门, 和当前元素同级
|
|
404
327
|
if (this.props.isInsertNode) {
|
|
405
328
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Mask, {
|
|
406
329
|
visible: visible,
|
|
@@ -409,7 +332,6 @@ function (_super) {
|
|
|
409
332
|
ref: this.maskRef
|
|
410
333
|
}), this.renderPopup());
|
|
411
334
|
}
|
|
412
|
-
|
|
413
335
|
if (visible || this.popupRef.current) {
|
|
414
336
|
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Mask, {
|
|
415
337
|
visible: visible,
|
|
@@ -417,13 +339,11 @@ function (_super) {
|
|
|
417
339
|
ref: this.maskRef
|
|
418
340
|
}), this.renderPopup()));
|
|
419
341
|
}
|
|
420
|
-
|
|
421
342
|
return null;
|
|
422
343
|
};
|
|
423
|
-
|
|
424
344
|
Modal.Affix = Affix;
|
|
425
|
-
Modal.cacheOpenedIds = [];
|
|
426
|
-
|
|
345
|
+
Modal.cacheOpenedIds = [];
|
|
346
|
+
// 默认值
|
|
427
347
|
Modal.defaultProps = {
|
|
428
348
|
placement: 'center',
|
|
429
349
|
width: '6.5rem',
|
|
@@ -436,5 +356,4 @@ function (_super) {
|
|
|
436
356
|
};
|
|
437
357
|
return Modal;
|
|
438
358
|
}(React.Component);
|
|
439
|
-
|
|
440
359
|
export default Modal;
|