@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
package/esm/accordion/Item.js
CHANGED
|
@@ -9,65 +9,48 @@ 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 Collapse from '../collapse';
|
|
31
|
-
|
|
32
|
-
var AccordionItem =
|
|
33
|
-
/** @class */
|
|
34
|
-
function (_super) {
|
|
25
|
+
var AccordionItem = /** @class */function (_super) {
|
|
35
26
|
__extends(AccordionItem, _super);
|
|
36
|
-
|
|
37
27
|
function AccordionItem() {
|
|
38
28
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
39
|
-
|
|
40
29
|
_this.getTitle = function () {
|
|
41
30
|
var _a = _this.props,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
title = _a.title,
|
|
32
|
+
onTitleClick = _a.onTitleClick;
|
|
45
33
|
if (!title) {
|
|
46
34
|
return null;
|
|
47
35
|
}
|
|
48
|
-
|
|
49
36
|
var child = React.Children.only(title);
|
|
50
37
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
51
38
|
onClick: onTitleClick
|
|
52
39
|
});
|
|
53
40
|
};
|
|
54
|
-
|
|
55
41
|
return _this;
|
|
56
42
|
}
|
|
57
|
-
|
|
58
43
|
AccordionItem.prototype.render = function () {
|
|
59
44
|
var _a = this.props,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
appear = _a.appear,
|
|
46
|
+
children = _a.children,
|
|
47
|
+
visible = _a.visible;
|
|
63
48
|
return /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement(Collapse, {
|
|
64
49
|
title: this.getTitle(),
|
|
65
50
|
visible: visible,
|
|
66
51
|
appear: appear
|
|
67
52
|
}, children));
|
|
68
53
|
};
|
|
69
|
-
|
|
70
54
|
return AccordionItem;
|
|
71
55
|
}(React.Component);
|
|
72
|
-
|
|
73
56
|
export default AccordionItem;
|
package/esm/accordion/index.js
CHANGED
|
@@ -9,73 +9,53 @@ 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
|
var __assign = this && this.__assign || function () {
|
|
30
24
|
__assign = Object.assign || function (t) {
|
|
31
25
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
32
26
|
s = arguments[i];
|
|
33
|
-
|
|
34
27
|
for (var p in s) {
|
|
35
28
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
36
29
|
}
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
return t;
|
|
40
32
|
};
|
|
41
|
-
|
|
42
33
|
return __assign.apply(this, arguments);
|
|
43
34
|
};
|
|
44
|
-
|
|
45
35
|
import React from 'react';
|
|
46
36
|
import classNames from 'classnames';
|
|
47
37
|
import { isEmptyArray } from '@autobest-ui/utils';
|
|
48
38
|
import AccordionItem from './Item';
|
|
49
|
-
|
|
50
|
-
var Accordion =
|
|
51
|
-
/** @class */
|
|
52
|
-
function (_super) {
|
|
39
|
+
var Accordion = /** @class */function (_super) {
|
|
53
40
|
__extends(Accordion, _super);
|
|
54
|
-
|
|
55
41
|
function Accordion(props) {
|
|
56
42
|
var _this = _super.call(this, props) || this;
|
|
57
|
-
|
|
58
43
|
_this.prefixCls = 'ab-accordion';
|
|
59
44
|
/** *
|
|
60
45
|
* 展开下拉链接列表
|
|
61
46
|
* @param name
|
|
62
47
|
*/
|
|
63
|
-
|
|
64
48
|
_this.onVisibleChange = function (name) {
|
|
65
49
|
var _a, _b;
|
|
66
|
-
|
|
67
50
|
var _c = _this.props,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
interactive = _c.interactive,
|
|
52
|
+
beforeVisibleChange = _c.beforeVisibleChange,
|
|
53
|
+
onVisibleChange = _c.onVisibleChange;
|
|
72
54
|
if (beforeVisibleChange) {
|
|
73
55
|
beforeVisibleChange(name);
|
|
74
56
|
}
|
|
75
|
-
|
|
76
57
|
var visibleNames = _this.state.visibleNames;
|
|
77
58
|
var isCurVisible = visibleNames[name];
|
|
78
|
-
|
|
79
59
|
if (interactive) {
|
|
80
60
|
// 能同时展开多项,只对当前项做展开/闭合操作
|
|
81
61
|
_this.setState({
|
|
@@ -87,34 +67,28 @@ function (_super) {
|
|
|
87
67
|
visibleNames: (_b = {}, _b[name] = !isCurVisible, _b)
|
|
88
68
|
});
|
|
89
69
|
}
|
|
90
|
-
|
|
91
70
|
if (onVisibleChange) {
|
|
92
71
|
onVisibleChange(name, !isCurVisible);
|
|
93
72
|
}
|
|
94
73
|
};
|
|
95
|
-
|
|
96
74
|
var visibleNames = {};
|
|
97
75
|
var defaultVisibleNames = props.defaultVisibleNames;
|
|
98
|
-
|
|
99
76
|
if (!isEmptyArray(defaultVisibleNames)) {
|
|
100
77
|
defaultVisibleNames.forEach(function (name) {
|
|
101
78
|
visibleNames[name] = true;
|
|
102
79
|
});
|
|
103
80
|
}
|
|
104
|
-
|
|
105
81
|
_this.state = {
|
|
106
82
|
visibleNames: visibleNames
|
|
107
83
|
};
|
|
108
84
|
return _this;
|
|
109
85
|
}
|
|
110
|
-
|
|
111
86
|
Accordion.prototype.render = function () {
|
|
112
87
|
var _this = this;
|
|
113
|
-
|
|
114
88
|
var cls = this.prefixCls;
|
|
115
89
|
var _a = this.props,
|
|
116
|
-
|
|
117
|
-
|
|
90
|
+
className = _a.className,
|
|
91
|
+
children = _a.children;
|
|
118
92
|
var visibleNames = this.state.visibleNames;
|
|
119
93
|
return /*#__PURE__*/React.createElement("ul", {
|
|
120
94
|
className: classNames(cls, className)
|
|
@@ -128,9 +102,8 @@ function (_super) {
|
|
|
128
102
|
visible: !!visibleNames[name]
|
|
129
103
|
});
|
|
130
104
|
}));
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
|
|
105
|
+
};
|
|
106
|
+
// 限制用户传入的参数,所以用BaseAccordionItemProps
|
|
134
107
|
Accordion.Item = AccordionItem;
|
|
135
108
|
Accordion.defaultProps = {
|
|
136
109
|
className: '',
|
|
@@ -139,5 +112,4 @@ function (_super) {
|
|
|
139
112
|
};
|
|
140
113
|
return Accordion;
|
|
141
114
|
}(React.Component);
|
|
142
|
-
|
|
143
115
|
export default Accordion;
|
package/esm/affix/PortalAffix.js
CHANGED
|
@@ -2,22 +2,20 @@ import React from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { CSSTransition } from 'react-transition-group';
|
|
4
4
|
import Portal from '../portal';
|
|
5
|
-
|
|
6
5
|
function PortalAffix(_a, ref) {
|
|
7
6
|
var cls = _a.prefixCls,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
visible = _a.visible,
|
|
8
|
+
children = _a.children,
|
|
9
|
+
top = _a.top,
|
|
10
|
+
left = _a.left,
|
|
11
|
+
width = _a.width,
|
|
12
|
+
className = _a.className,
|
|
13
|
+
fadeEffect = _a.fadeEffect;
|
|
15
14
|
var style = {
|
|
16
15
|
top: top,
|
|
17
16
|
left: left,
|
|
18
17
|
width: width
|
|
19
18
|
};
|
|
20
|
-
|
|
21
19
|
if (fadeEffect) {
|
|
22
20
|
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(CSSTransition, {
|
|
23
21
|
"in": visible,
|
|
@@ -30,7 +28,6 @@ function PortalAffix(_a, ref) {
|
|
|
30
28
|
className: classNames(className, "".concat(cls, "-custom"))
|
|
31
29
|
}, children)));
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
style.display = visible ? '' : 'none';
|
|
35
32
|
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
|
|
36
33
|
style: style,
|
|
@@ -38,5 +35,4 @@ function PortalAffix(_a, ref) {
|
|
|
38
35
|
className: classNames(className, "".concat(cls, "-custom"))
|
|
39
36
|
}, children));
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
export default /*#__PURE__*/React.forwardRef(PortalAffix);
|
package/esm/affix/index.js
CHANGED
|
@@ -9,96 +9,73 @@ 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
|
var __assign = this && this.__assign || function () {
|
|
30
24
|
__assign = Object.assign || function (t) {
|
|
31
25
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
32
26
|
s = arguments[i];
|
|
33
|
-
|
|
34
27
|
for (var p in s) {
|
|
35
28
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
36
29
|
}
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
return t;
|
|
40
32
|
};
|
|
41
|
-
|
|
42
33
|
return __assign.apply(this, arguments);
|
|
43
34
|
};
|
|
44
|
-
|
|
45
35
|
import React from 'react';
|
|
46
36
|
import classNames from 'classnames';
|
|
47
37
|
import { throttleWithRAF, addEventListener, getOffsetAndSize, getScrollOffset, getOffset } from '@autobest-ui/utils';
|
|
48
38
|
import PortalAffix from './PortalAffix';
|
|
49
|
-
|
|
50
|
-
var Affix =
|
|
51
|
-
/** @class */
|
|
52
|
-
function (_super) {
|
|
39
|
+
var Affix = /** @class */function (_super) {
|
|
53
40
|
__extends(Affix, _super);
|
|
54
|
-
|
|
55
41
|
function Affix(props) {
|
|
56
42
|
var _this = _super.call(this, props) || this;
|
|
57
|
-
|
|
58
43
|
_this.prefixCls = 'ab-affix';
|
|
59
44
|
_this.resizeHandler = null;
|
|
60
45
|
_this.wrapRef = /*#__PURE__*/React.createRef();
|
|
61
46
|
_this.customRef = /*#__PURE__*/React.createRef();
|
|
62
|
-
|
|
63
47
|
_this.onHandlerScroll = function (isResize) {
|
|
64
48
|
var _a = _this.props,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
49
|
+
offsetTop = _a.offsetTop,
|
|
50
|
+
onChange = _a.onChange,
|
|
51
|
+
onScroll = _a.onScroll,
|
|
52
|
+
renderAffix = _a.renderAffix,
|
|
53
|
+
allWidth = _a.allWidth,
|
|
54
|
+
fadeEffect = _a.fadeEffect,
|
|
55
|
+
getFixedStatus = _a.getFixedStatus,
|
|
56
|
+
ignoreHorizontalFixed = _a.ignoreHorizontalFixed;
|
|
73
57
|
var element = _this.wrapRef.current;
|
|
74
|
-
|
|
75
58
|
if (!element) {
|
|
76
59
|
return;
|
|
77
60
|
}
|
|
78
|
-
|
|
79
61
|
var _b = getScrollOffset(),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
62
|
+
scrollTop = _b.top,
|
|
63
|
+
scrollLeft = _b.left;
|
|
64
|
+
var parentElement = element.parentNode;
|
|
65
|
+
// 元素信息
|
|
85
66
|
var positionElement = _this.isFixed && !renderAffix ? parentElement : element;
|
|
86
67
|
var positionInfo = getOffsetAndSize(positionElement);
|
|
87
|
-
|
|
88
68
|
if (ignoreHorizontalFixed) {
|
|
89
69
|
var ignoreScrollLeft = getOffset(positionElement, true).left;
|
|
90
70
|
positionInfo.left = ignoreScrollLeft;
|
|
91
71
|
}
|
|
92
|
-
|
|
93
72
|
var currentFixed = getFixedStatus({
|
|
94
73
|
positionInfo: positionInfo,
|
|
95
74
|
scrollTop: scrollTop,
|
|
96
75
|
offsetTop: offsetTop
|
|
97
76
|
});
|
|
98
|
-
|
|
99
77
|
if (_this.isFixed && !currentFixed) {
|
|
100
78
|
_this.isFixed = false;
|
|
101
|
-
|
|
102
79
|
if (renderAffix || fadeEffect) {
|
|
103
80
|
_this.setState({
|
|
104
81
|
visible: false
|
|
@@ -111,13 +88,11 @@ function (_super) {
|
|
|
111
88
|
parentElement.style.width = '';
|
|
112
89
|
parentElement.style.height = '';
|
|
113
90
|
}
|
|
114
|
-
|
|
115
91
|
onChange(false);
|
|
116
92
|
} else if ((!_this.isFixed || isResize) && currentFixed) {
|
|
117
93
|
_this.isFixed = true;
|
|
118
94
|
var documentWidth = document.body.offsetWidth;
|
|
119
95
|
var allWidthLeft = ignoreHorizontalFixed ? "-".concat(scrollLeft, "px") : '0px';
|
|
120
|
-
|
|
121
96
|
if (renderAffix || fadeEffect) {
|
|
122
97
|
_this.setState({
|
|
123
98
|
visible: true,
|
|
@@ -133,14 +108,11 @@ function (_super) {
|
|
|
133
108
|
parentElement.style.width = "".concat(positionInfo.width, "px");
|
|
134
109
|
parentElement.style.height = "".concat(positionInfo.height, "px");
|
|
135
110
|
}
|
|
136
|
-
|
|
137
111
|
onChange(true);
|
|
138
112
|
} else if (_this.isFixed && currentFixed && ignoreHorizontalFixed) {
|
|
139
113
|
var allWidthLeft = "-".concat(scrollLeft, "px");
|
|
140
|
-
|
|
141
114
|
if (renderAffix || fadeEffect) {
|
|
142
115
|
var left = allWidth ? allWidthLeft : "".concat(positionInfo.left, "px");
|
|
143
|
-
|
|
144
116
|
if (left !== _this.state.left) {
|
|
145
117
|
_this.setState({
|
|
146
118
|
left: left
|
|
@@ -150,7 +122,6 @@ function (_super) {
|
|
|
150
122
|
element.style.left = allWidth ? allWidthLeft : "".concat(positionInfo.left, "px");
|
|
151
123
|
}
|
|
152
124
|
}
|
|
153
|
-
|
|
154
125
|
if (onScroll) {
|
|
155
126
|
onScroll(__assign(__assign({}, positionInfo), {
|
|
156
127
|
scrollTop: scrollTop,
|
|
@@ -158,7 +129,6 @@ function (_super) {
|
|
|
158
129
|
}));
|
|
159
130
|
}
|
|
160
131
|
};
|
|
161
|
-
|
|
162
132
|
_this.state = {
|
|
163
133
|
visible: false,
|
|
164
134
|
left: '',
|
|
@@ -167,47 +137,41 @@ function (_super) {
|
|
|
167
137
|
};
|
|
168
138
|
return _this;
|
|
169
139
|
}
|
|
170
|
-
|
|
171
140
|
Affix.prototype.componentDidMount = function () {
|
|
172
141
|
var _this = this;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
142
|
+
this.onHandlerScroll();
|
|
143
|
+
// 滚动监听
|
|
176
144
|
this.scrollHandler = addEventListener(window, 'scroll', throttleWithRAF(function () {
|
|
177
145
|
return _this.onHandlerScroll();
|
|
178
|
-
}));
|
|
179
|
-
|
|
146
|
+
}));
|
|
147
|
+
// resize 监听
|
|
180
148
|
if (!this.resizeHandler) {
|
|
181
149
|
this.resizeHandler = addEventListener(window, 'resize', throttleWithRAF(function () {
|
|
182
150
|
return _this.onHandlerScroll(true);
|
|
183
151
|
}));
|
|
184
152
|
}
|
|
185
153
|
};
|
|
186
|
-
|
|
187
154
|
Affix.prototype.componentWillUnmount = function () {
|
|
188
155
|
if (this.scrollHandler) {
|
|
189
156
|
this.scrollHandler.remove();
|
|
190
157
|
this.scrollHandler = null;
|
|
191
158
|
}
|
|
192
|
-
|
|
193
159
|
if (this.resizeHandler) {
|
|
194
160
|
this.resizeHandler.remove();
|
|
195
161
|
this.resizeHandler = null;
|
|
196
162
|
}
|
|
197
163
|
};
|
|
198
|
-
|
|
199
164
|
Affix.prototype.renderContent = function () {
|
|
200
165
|
var _a = this.props,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
166
|
+
fadeEffect = _a.fadeEffect,
|
|
167
|
+
renderAffix = _a.renderAffix,
|
|
168
|
+
className = _a.className,
|
|
169
|
+
children = _a.children;
|
|
205
170
|
var _b = this.state,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
171
|
+
visible = _b.visible,
|
|
172
|
+
left = _b.left,
|
|
173
|
+
top = _b.top,
|
|
174
|
+
width = _b.width;
|
|
211
175
|
if ((fadeEffect || renderAffix) && (visible || this.customRef.current)) {
|
|
212
176
|
return /*#__PURE__*/React.createElement(PortalAffix, {
|
|
213
177
|
top: top,
|
|
@@ -220,21 +184,18 @@ function (_super) {
|
|
|
220
184
|
ref: this.customRef
|
|
221
185
|
}, renderAffix ? renderAffix() : children);
|
|
222
186
|
}
|
|
223
|
-
|
|
224
187
|
return null;
|
|
225
188
|
};
|
|
226
|
-
|
|
227
189
|
Affix.prototype.render = function () {
|
|
228
190
|
var _a = this.props,
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
191
|
+
className = _a.className,
|
|
192
|
+
children = _a.children;
|
|
193
|
+
// 这里需要两层div 包裹,最外层的是在固定时,防止页面抖动
|
|
232
194
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
233
195
|
ref: this.wrapRef,
|
|
234
196
|
className: classNames(this.prefixCls, className)
|
|
235
197
|
}, children), this.renderContent());
|
|
236
198
|
};
|
|
237
|
-
|
|
238
199
|
Affix.defaultProps = {
|
|
239
200
|
offsetTop: 0,
|
|
240
201
|
allWidth: false,
|
|
@@ -242,12 +203,11 @@ function (_super) {
|
|
|
242
203
|
onChange: function onChange() {},
|
|
243
204
|
getFixedStatus: function getFixedStatus(_a) {
|
|
244
205
|
var positionInfo = _a.positionInfo,
|
|
245
|
-
|
|
246
|
-
|
|
206
|
+
scrollTop = _a.scrollTop,
|
|
207
|
+
offsetTop = _a.offsetTop;
|
|
247
208
|
return scrollTop > positionInfo.top - offsetTop;
|
|
248
209
|
}
|
|
249
210
|
};
|
|
250
211
|
return Affix;
|
|
251
212
|
}(React.Component);
|
|
252
|
-
|
|
253
213
|
export default Affix;
|