@autobest-ui/components 2.2.1 → 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/accordion/style/index.css +1 -0
- package/esm/affix/PortalAffix.js +7 -11
- package/esm/affix/index.js +30 -70
- package/esm/affix/style/index.css +1 -1
- package/esm/base.css +1 -1
- package/esm/carousel/index.js +45 -141
- package/esm/checkbox/index.js +12 -37
- package/esm/checkbox/style/index.css +1 -1
- package/esm/collapse/index.js +11 -49
- package/esm/confirm/index.d.ts +8 -0
- package/esm/confirm/index.js +23 -31
- package/esm/confirm/style/index.css +1 -1
- 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/style/index.css +1 -1
- package/esm/date-picker/utils.js +6 -11
- package/esm/drawer/Child.js +10 -20
- package/esm/drawer/index.js +22 -71
- package/esm/drawer/style/index.css +1 -1
- package/esm/ellipsis/index.js +9 -17
- package/esm/ellipsis/style/index.css +1 -1
- package/esm/guide/index.js +25 -63
- package/esm/guide/style/index.css +1 -1
- 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/input-number/style/index.css +1 -1
- package/esm/lazy-image/index.js +10 -55
- package/esm/lazy-image/style/index.css +1 -1
- package/esm/link-list/index.js +11 -35
- package/esm/link-list/style/index.css +1 -1
- package/esm/loading/index.js +15 -42
- package/esm/loading/style/index.css +1 -1
- package/esm/loading-bar/style/index.css +1 -1
- package/esm/loading-container/index.js +3 -6
- package/esm/loading-container/style/index.css +1 -1
- package/esm/loading-icon/index.js +0 -2
- package/esm/loading-icon/style/index.css +1 -1
- package/esm/mask/index.js +6 -9
- package/esm/mask/style/index.css +1 -1
- 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/modal/style/index.css +1 -1
- 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/popover/style/index.css +1 -1
- package/esm/portal/index.js +1 -22
- package/esm/script/index.js +19 -59
- package/esm/select/index.js +28 -106
- package/esm/select/style/index.css +1 -1
- package/esm/show-more/index.js +40 -103
- package/esm/skeleton/Item.js +1 -3
- package/esm/skeleton/index.js +5 -11
- package/esm/skeleton/style/index.css +1 -1
- package/esm/style.css +1 -33
- 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/table/style/index.css +1 -1
- package/esm/tabs/index.js +35 -118
- package/esm/tabs/style/index.css +1 -1
- package/esm/tooltip/index.js +0 -4
- package/esm/tooltip/style/index.css +1 -1
- 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/accordion/style/index.css +1 -0
- package/lib/affix/PortalAffix.js +7 -17
- package/lib/affix/index.js +30 -75
- package/lib/affix/style/index.css +1 -1
- package/lib/base.css +1 -1
- package/lib/carousel/index.js +45 -146
- package/lib/checkbox/index.js +12 -41
- package/lib/checkbox/style/index.css +1 -1
- package/lib/collapse/index.js +11 -53
- package/lib/confirm/index.d.ts +8 -0
- package/lib/confirm/index.js +23 -38
- package/lib/confirm/style/index.css +1 -1
- 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/style/index.css +1 -1
- package/lib/date-picker/utils.js +6 -26
- package/lib/drawer/Child.js +10 -25
- package/lib/drawer/index.js +22 -78
- package/lib/drawer/style/index.css +1 -1
- package/lib/ellipsis/index.js +9 -23
- package/lib/ellipsis/style/index.css +1 -1
- package/lib/guide/index.js +25 -71
- package/lib/guide/style/index.css +1 -1
- 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/input-number/style/index.css +1 -1
- package/lib/lazy-image/index.js +10 -58
- package/lib/lazy-image/style/index.css +1 -1
- package/lib/link-list/index.js +11 -40
- package/lib/link-list/style/index.css +1 -1
- package/lib/loading/index.js +13 -48
- package/lib/loading/style/index.css +1 -1
- package/lib/loading-bar/index.js +0 -5
- package/lib/loading-bar/style/index.css +1 -1
- package/lib/loading-container/index.js +3 -11
- package/lib/loading-container/style/index.css +1 -1
- package/lib/loading-icon/index.js +0 -7
- package/lib/loading-icon/style/index.css +1 -1
- package/lib/mask/index.js +6 -17
- package/lib/mask/style/index.css +1 -1
- 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/modal/style/index.css +1 -1
- 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/popover/style/index.css +1 -1
- package/lib/portal/index.js +1 -25
- package/lib/script/index.js +19 -61
- package/lib/select/index.js +28 -113
- package/lib/select/style/index.css +1 -1
- package/lib/show-more/index.js +40 -110
- package/lib/skeleton/Item.js +1 -8
- package/lib/skeleton/index.js +5 -16
- package/lib/skeleton/style/index.css +1 -1
- package/lib/style.css +1 -33
- 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/table/style/index.css +1 -1
- package/lib/tabs/index.js +35 -122
- package/lib/tabs/style/index.css +1 -1
- package/lib/tooltip/index.js +0 -9
- package/lib/tooltip/style/index.css +1 -1
- 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 +9 -3
- package/esm/accordion/style/index.d.ts +0 -1
- package/esm/accordion/style/index.js +0 -5
- package/esm/affix/style/index.d.ts +0 -1
- package/esm/affix/style/index.js +0 -5
- package/esm/affix/style/index.scss +0 -35
- package/esm/base.scss +0 -42
- package/esm/carousel/style/index.d.ts +0 -1
- package/esm/carousel/style/index.js +0 -5
- package/esm/carousel/style/index.scss +0 -37
- package/esm/checkbox/style/index.d.ts +0 -1
- package/esm/checkbox/style/index.js +0 -5
- package/esm/checkbox/style/index.scss +0 -118
- package/esm/collapse/style/index.d.ts +0 -1
- package/esm/collapse/style/index.js +0 -5
- package/esm/collapse/style/index.scss +0 -43
- package/esm/confirm/style/index.d.ts +0 -1
- package/esm/confirm/style/index.js +0 -7
- package/esm/confirm/style/index.scss +0 -44
- package/esm/date-picker/calendar/grid/index.scss +0 -90
- package/esm/date-picker/calendar/index.scss +0 -58
- package/esm/date-picker/style/index.d.ts +0 -1
- package/esm/date-picker/style/index.js +0 -11
- package/esm/date-picker/style/index.scss +0 -24
- package/esm/drawer/style/index.d.ts +0 -1
- package/esm/drawer/style/index.js +0 -7
- package/esm/drawer/style/index.scss +0 -44
- package/esm/ellipsis/style/index.d.ts +0 -1
- package/esm/ellipsis/style/index.js +0 -5
- package/esm/ellipsis/style/index.scss +0 -35
- package/esm/guide/style/index.d.ts +0 -1
- package/esm/guide/style/index.js +0 -7
- package/esm/guide/style/index.scss +0 -18
- package/esm/input-number/style/index.d.ts +0 -1
- package/esm/input-number/style/index.js +0 -5
- package/esm/input-number/style/index.scss +0 -70
- package/esm/lazy-image/style/index.d.ts +0 -1
- package/esm/lazy-image/style/index.js +0 -5
- package/esm/lazy-image/style/index.scss +0 -25
- package/esm/link-list/style/index.d.ts +0 -1
- package/esm/link-list/style/index.js +0 -7
- package/esm/link-list/style/index.scss +0 -125
- package/esm/loading/style/index.d.ts +0 -1
- package/esm/loading/style/index.js +0 -7
- package/esm/loading/style/index.scss +0 -21
- package/esm/loading-bar/style/index.d.ts +0 -1
- package/esm/loading-bar/style/index.js +0 -5
- package/esm/loading-bar/style/index.scss +0 -62
- package/esm/loading-container/style/index.d.ts +0 -1
- package/esm/loading-container/style/index.js +0 -7
- package/esm/loading-container/style/index.scss +0 -28
- package/esm/loading-icon/style/index.d.ts +0 -1
- package/esm/loading-icon/style/index.js +0 -5
- package/esm/loading-icon/style/index.scss +0 -24
- package/esm/mask/style/index.d.ts +0 -1
- package/esm/mask/style/index.js +0 -5
- package/esm/mask/style/index.scss +0 -35
- package/esm/message/style/index.d.ts +0 -1
- package/esm/message/style/index.js +0 -5
- package/esm/message/style/index.scss +0 -71
- package/esm/modal/style/index.d.ts +0 -1
- package/esm/modal/style/index.js +0 -7
- package/esm/modal/style/index.scss +0 -112
- package/esm/move/style/index.d.ts +0 -1
- package/esm/move/style/index.js +0 -5
- package/esm/move/style/index.scss +0 -7
- package/esm/popover/style/index.d.ts +0 -1
- package/esm/popover/style/index.js +0 -7
- package/esm/popover/style/index.scss +0 -60
- package/esm/portal/style/index.d.ts +0 -1
- package/esm/portal/style/index.js +0 -5
- package/esm/portal/style/index.scss +0 -0
- package/esm/script/style/index.d.ts +0 -1
- package/esm/script/style/index.js +0 -1
- package/esm/script/style/index.scss +0 -0
- package/esm/select/style/index.d.ts +0 -1
- package/esm/select/style/index.js +0 -7
- package/esm/select/style/index.scss +0 -126
- package/esm/show-more/style/index.d.ts +0 -1
- package/esm/show-more/style/index.js +0 -5
- package/esm/show-more/style/index.scss +0 -23
- package/esm/skeleton/style/index.d.ts +0 -1
- package/esm/skeleton/style/index.js +0 -5
- package/esm/skeleton/style/index.scss +0 -27
- package/esm/table/style/index.d.ts +0 -1
- package/esm/table/style/index.js +0 -9
- package/esm/table/style/index.scss +0 -45
- package/esm/tabs/style/index.d.ts +0 -1
- package/esm/tabs/style/index.js +0 -5
- package/esm/tabs/style/index.scss +0 -62
- package/esm/tooltip/style/index.d.ts +0 -1
- package/esm/tooltip/style/index.js +0 -7
- package/esm/tooltip/style/index.scss +0 -62
- package/esm/trigger/style/index.d.ts +0 -1
- package/esm/trigger/style/index.js +0 -5
- package/esm/trigger/style/index.scss +0 -79
- package/lib/accordion/style/index.d.ts +0 -1
- package/lib/accordion/style/index.js +0 -7
- package/lib/affix/style/index.d.ts +0 -1
- package/lib/affix/style/index.js +0 -7
- package/lib/affix/style/index.scss +0 -35
- package/lib/base.scss +0 -42
- package/lib/carousel/style/index.d.ts +0 -1
- package/lib/carousel/style/index.js +0 -7
- package/lib/carousel/style/index.scss +0 -37
- package/lib/checkbox/style/index.d.ts +0 -1
- package/lib/checkbox/style/index.js +0 -7
- package/lib/checkbox/style/index.scss +0 -118
- package/lib/collapse/style/index.d.ts +0 -1
- package/lib/collapse/style/index.js +0 -7
- package/lib/collapse/style/index.scss +0 -43
- package/lib/confirm/style/index.d.ts +0 -1
- package/lib/confirm/style/index.js +0 -9
- package/lib/confirm/style/index.scss +0 -44
- package/lib/date-picker/calendar/grid/index.scss +0 -90
- package/lib/date-picker/calendar/index.scss +0 -58
- package/lib/date-picker/style/index.d.ts +0 -1
- package/lib/date-picker/style/index.js +0 -13
- package/lib/date-picker/style/index.scss +0 -24
- package/lib/drawer/style/index.d.ts +0 -1
- package/lib/drawer/style/index.js +0 -9
- package/lib/drawer/style/index.scss +0 -44
- package/lib/ellipsis/style/index.d.ts +0 -1
- package/lib/ellipsis/style/index.js +0 -7
- package/lib/ellipsis/style/index.scss +0 -35
- package/lib/guide/style/index.d.ts +0 -1
- package/lib/guide/style/index.js +0 -9
- package/lib/guide/style/index.scss +0 -18
- package/lib/input-number/style/index.d.ts +0 -1
- package/lib/input-number/style/index.js +0 -7
- package/lib/input-number/style/index.scss +0 -70
- package/lib/lazy-image/style/index.d.ts +0 -1
- package/lib/lazy-image/style/index.js +0 -7
- package/lib/lazy-image/style/index.scss +0 -25
- package/lib/link-list/style/index.d.ts +0 -1
- package/lib/link-list/style/index.js +0 -9
- package/lib/link-list/style/index.scss +0 -125
- package/lib/loading/style/index.d.ts +0 -1
- package/lib/loading/style/index.js +0 -9
- package/lib/loading/style/index.scss +0 -21
- package/lib/loading-bar/style/index.d.ts +0 -1
- package/lib/loading-bar/style/index.js +0 -7
- package/lib/loading-bar/style/index.scss +0 -62
- package/lib/loading-container/style/index.d.ts +0 -1
- package/lib/loading-container/style/index.js +0 -9
- package/lib/loading-container/style/index.scss +0 -28
- package/lib/loading-icon/style/index.d.ts +0 -1
- package/lib/loading-icon/style/index.js +0 -7
- package/lib/loading-icon/style/index.scss +0 -24
- package/lib/mask/style/index.d.ts +0 -1
- package/lib/mask/style/index.js +0 -7
- package/lib/mask/style/index.scss +0 -35
- package/lib/message/style/index.d.ts +0 -1
- package/lib/message/style/index.js +0 -7
- package/lib/message/style/index.scss +0 -71
- package/lib/modal/style/index.d.ts +0 -1
- package/lib/modal/style/index.js +0 -9
- package/lib/modal/style/index.scss +0 -112
- package/lib/move/style/index.d.ts +0 -1
- package/lib/move/style/index.js +0 -7
- package/lib/move/style/index.scss +0 -7
- package/lib/popover/style/index.d.ts +0 -1
- package/lib/popover/style/index.js +0 -9
- package/lib/popover/style/index.scss +0 -60
- package/lib/portal/style/index.d.ts +0 -1
- package/lib/portal/style/index.js +0 -7
- package/lib/portal/style/index.scss +0 -0
- package/lib/script/style/index.d.ts +0 -1
- package/lib/script/style/index.js +0 -1
- package/lib/script/style/index.scss +0 -0
- package/lib/select/style/index.d.ts +0 -1
- package/lib/select/style/index.js +0 -9
- package/lib/select/style/index.scss +0 -126
- package/lib/show-more/style/index.d.ts +0 -1
- package/lib/show-more/style/index.js +0 -7
- package/lib/show-more/style/index.scss +0 -23
- package/lib/skeleton/style/index.d.ts +0 -1
- package/lib/skeleton/style/index.js +0 -7
- package/lib/skeleton/style/index.scss +0 -27
- package/lib/table/style/index.d.ts +0 -1
- package/lib/table/style/index.js +0 -11
- package/lib/table/style/index.scss +0 -45
- package/lib/tabs/style/index.d.ts +0 -1
- package/lib/tabs/style/index.js +0 -7
- package/lib/tabs/style/index.scss +0 -62
- package/lib/tooltip/style/index.d.ts +0 -1
- package/lib/tooltip/style/index.js +0 -9
- package/lib/tooltip/style/index.scss +0 -62
- package/lib/trigger/style/index.d.ts +0 -1
- package/lib/trigger/style/index.js +0 -7
- package/lib/trigger/style/index.scss +0 -79
package/esm/link-list/index.js
CHANGED
|
@@ -9,53 +9,38 @@ 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 classNames from 'classnames';
|
|
31
25
|
import { isEmptyObject } from '@autobest-ui/utils';
|
|
32
26
|
import Popover from '../popover';
|
|
33
|
-
|
|
34
|
-
var LinkList =
|
|
35
|
-
/** @class */
|
|
36
|
-
function (_super) {
|
|
27
|
+
var LinkList = /** @class */function (_super) {
|
|
37
28
|
__extends(LinkList, _super);
|
|
38
|
-
|
|
39
29
|
function LinkList(props) {
|
|
40
30
|
var _this = _super.call(this, props) || this;
|
|
41
|
-
|
|
42
31
|
_this.prefixCls = 'ab-link-list';
|
|
43
|
-
|
|
44
32
|
_this.onVisibleChange = function () {
|
|
45
33
|
_this.setState({
|
|
46
34
|
visible: !_this.state.visible
|
|
47
35
|
});
|
|
48
36
|
};
|
|
49
|
-
|
|
50
37
|
_this.state = {
|
|
51
38
|
visible: props.defaultVisible
|
|
52
39
|
};
|
|
53
40
|
return _this;
|
|
54
41
|
}
|
|
55
|
-
|
|
56
42
|
LinkList.prototype.renderItemContent = function (item) {
|
|
57
43
|
var _a;
|
|
58
|
-
|
|
59
44
|
var hrefTarget = this.props.hrefTarget;
|
|
60
45
|
var cls = this.prefixCls;
|
|
61
46
|
return item.url ? /*#__PURE__*/React.createElement("a", {
|
|
@@ -68,13 +53,11 @@ function (_super) {
|
|
|
68
53
|
className: classNames((_a = {}, _a["".concat(cls, "-hidden")] = item.isHidden, _a))
|
|
69
54
|
}, "".concat(item.name, " "));
|
|
70
55
|
};
|
|
71
|
-
|
|
72
56
|
LinkList.prototype.renderItem = function (item) {
|
|
73
57
|
// 判断hiddenPopover和是否有具体的popover参数
|
|
74
58
|
if (this.props.hiddenPopover || isEmptyObject(item.subInfo)) {
|
|
75
59
|
return this.renderItemContent(item);
|
|
76
60
|
}
|
|
77
|
-
|
|
78
61
|
var subInfo = item.subInfo;
|
|
79
62
|
var cls = this.prefixCls;
|
|
80
63
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
@@ -95,37 +78,32 @@ function (_super) {
|
|
|
95
78
|
mouseEnterDelay: 0.1
|
|
96
79
|
}, this.renderItemContent(item));
|
|
97
80
|
};
|
|
98
|
-
|
|
99
81
|
LinkList.prototype.renderContent = function () {
|
|
100
82
|
var _this = this;
|
|
101
|
-
|
|
102
83
|
var _a = this.props,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
84
|
+
hiddenPopover = _a.hiddenPopover,
|
|
85
|
+
options = _a.options;
|
|
86
|
+
// 隐藏popover和忽略分列
|
|
106
87
|
if (hiddenPopover) {
|
|
107
88
|
return options.map(function (item) {
|
|
108
89
|
return _this.renderItemContent(item);
|
|
109
90
|
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
91
|
+
}
|
|
92
|
+
// 忽略分列
|
|
113
93
|
return options.map(function (item) {
|
|
114
94
|
return _this.renderItem(item);
|
|
115
95
|
});
|
|
116
96
|
};
|
|
117
|
-
|
|
118
97
|
LinkList.prototype.render = function () {
|
|
119
98
|
var _a, _b;
|
|
120
|
-
|
|
121
99
|
var cls = this.prefixCls;
|
|
122
100
|
var visible = this.state.visible;
|
|
123
101
|
var _c = this.props,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
102
|
+
className = _c.className,
|
|
103
|
+
title = _c.title,
|
|
104
|
+
extraTopElement = _c.extraTopElement,
|
|
105
|
+
extraBottomElement = _c.extraBottomElement,
|
|
106
|
+
columnCount = _c.columnCount;
|
|
129
107
|
return /*#__PURE__*/React.createElement("div", {
|
|
130
108
|
className: classNames(cls, className)
|
|
131
109
|
}, title ? /*#__PURE__*/React.createElement("div", {
|
|
@@ -139,7 +117,6 @@ function (_super) {
|
|
|
139
117
|
className: classNames("".concat(cls, "-content"), "".concat(cls, "-col").concat(columnCount))
|
|
140
118
|
}, this.renderContent()), extraBottomElement));
|
|
141
119
|
};
|
|
142
|
-
|
|
143
120
|
LinkList.defaultProps = {
|
|
144
121
|
className: '',
|
|
145
122
|
hrefTarget: '_self',
|
|
@@ -150,5 +127,4 @@ function (_super) {
|
|
|
150
127
|
};
|
|
151
128
|
return LinkList;
|
|
152
129
|
}(React.Component);
|
|
153
|
-
|
|
154
130
|
export default LinkList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-link-list-title{font-size:.16rem;margin:0
|
|
1
|
+
.ab-trigger-wrap{position:absolute;top:0;left:0;z-index:101}.ab-trigger-wrap.ab-trigger-hidden{display:none}.ab-trigger-mask{position:fixed;top:0;left:0;bottom:0;right:0;z-index:101;background-color:transparent;display:none}.ab-trigger-mask.ab-trigger-mask-show{display:block}.ab-trigger-fade-appear,.ab-trigger-fade-enter,.ab-trigger-fade-hr-appear,.ab-trigger-fade-hr-enter{opacity:0}.ab-trigger-fade-appear,.ab-trigger-fade-enter{transform:scale(.7)}.ab-trigger-fade-hr-appear,.ab-trigger-fade-hr-enter{opacity:0;transform:scaleY(.7)}.ab-trigger-fade-appear-active,.ab-trigger-fade-enter-active,.ab-trigger-fade-hr-appear-active,.ab-trigger-fade-hr-enter-active{opacity:1;transition:opacity .2s,transform .2s}.ab-trigger-fade-appear-active,.ab-trigger-fade-enter-active{transform:scale(1)}.ab-trigger-fade-hr-appear-active,.ab-trigger-fade-hr-enter-active{transform:scaleY(1)}.ab-trigger-fade-exit,.ab-trigger-fade-hr-exit{opacity:1}.ab-trigger-fade-exit-active,.ab-trigger-fade-hr-exit-active{opacity:0;transition:opacity .2s,transform .2s}.ab-trigger-fade-exit-active{transform:scale(.7)}.ab-trigger-fade-hr-exit-active{transform:scaleY(.7)}.ab-trigger-fade-exit-done,.ab-trigger-fade-hr-exit-done{display:none}.ab-popover-wrap{background-color:#fff;background-clip:padding-box;box-shadow:0 2px 8px rgba(0,0,0,.15);padding:.08rem .11rem .05rem;min-width:210px;border-radius:4px}.ab-popover-inner{position:relative;width:100%;overflow:hidden;font-size:.12rem}.ab-popover-inner-expand{padding-right:.1rem}.ab-popover-arrow{position:absolute;display:block;width:8px;height:8px;border-style:solid;background-color:#fff;border-color:transparent #fff #fff transparent;border-width:4px;box-shadow:3px 3px 7px rgba(0,0,0,.07)}.ab-popover-close{position:absolute;right:.02rem;top:.05rem;cursor:pointer;padding:0 .05rem;color:#bfbfbf;font-size:.2rem;line-height:1;z-index:2}.ab-popover-close:hover{color:#4a4a4a}@media only screen and (max-width:767px){.ab-popover-wrap{width:calc(100% - .3rem)}}.ab-link-list-title{font-size:.16rem;margin:0;padding:0 0 .12rem;display:flex;justify-content:space-between;align-items:center}.ab-link-list-icon{display:none}.ab-link-list-content{flex-wrap:wrap;width:auto;margin-right:-.15rem}.ab-link-list-content.ab-link-list-col2>a,.ab-link-list-content.ab-link-list-col2>span{min-width:calc(100% / 2 - .15rem);max-width:calc(100% / 2 - .15rem)}.ab-link-list-content.ab-link-list-col4>a,.ab-link-list-content.ab-link-list-col4>span{min-width:calc(100% / 4 - .15rem);max-width:calc(100% / 4 - .15rem)}.ab-link-list-content.ab-link-list-col5>a,.ab-link-list-content.ab-link-list-col5>span{min-width:calc(100% / 5 - .15rem);max-width:calc(100% / 5 - .15rem)}.ab-link-list-content.ab-link-list-col6>a,.ab-link-list-content.ab-link-list-col6>span{min-width:calc(100% / 6 - .15rem);max-width:calc(100% / 6 - .15rem)}.ab-link-list-content.ab-link-list-col8>a,.ab-link-list-content.ab-link-list-col8>span{min-width:calc(100% / 8 - .15rem);max-width:calc(100% / 8 - .15rem)}.ab-link-list-content>a,.ab-link-list-content>span{cursor:pointer;border:.5px solid #d0d0d0;margin-bottom:8px;display:inline-block;justify-content:space-between;align-items:center;width:100%;position:relative;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:.085rem .15rem .085rem .12rem;color:#333;margin-right:.15rem}.ab-link-list-content>a::after,.ab-link-list-content>span::after{content:">";position:absolute;right:.1rem;top:50%;transform:translateY(-50%);color:grey;font-size:.12rem}.ab-link-list-content>a:hover,.ab-link-list-content>span:hover{text-decoration:underline;color:#f97601}.ab-link-list-content>.ab-link-list-hidden{display:none}.ab-link-list-wrap-popover.ab-popover-wrap{max-width:3.5rem;min-width:3rem}.ab-link-list-sub-title{display:block;padding-bottom:.06rem;font-size:.12rem}.ab-link-list-sub-link{text-decoration:underline;color:#333;font-size:.12rem;padding:0 .05rem .05rem 0;display:inline-block}@media only screen and (max-width:767px){.ab-link-list-divider{border-bottom:1px solid #d0d0d0}.ab-link-list-body{height:0;width:0;overflow:hidden}.ab-link-list-body.ab-link-list-active{height:auto;width:auto}.ab-link-list-content.ab-link-list-col2>a,.ab-link-list-content.ab-link-list-col2>span,.ab-link-list-content.ab-link-list-col4>a,.ab-link-list-content.ab-link-list-col4>span,.ab-link-list-content.ab-link-list-col5>a,.ab-link-list-content.ab-link-list-col5>span,.ab-link-list-content.ab-link-list-col6>a,.ab-link-list-content.ab-link-list-col6>span,.ab-link-list-content.ab-link-list-col8>a,.ab-link-list-content.ab-link-list-col8>span{min-width:calc(50% - .15rem);max-width:calc(50% - .15rem)}.ab-link-list-icon{font-weight:700;font-size:.22rem;cursor:pointer;width:.2rem;height:.2rem;display:flex;align-items:center;justify-content:center}}
|
package/esm/loading/index.js
CHANGED
|
@@ -2,63 +2,51 @@ var __assign = this && this.__assign || function () {
|
|
|
2
2
|
__assign = Object.assign || function (t) {
|
|
3
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
4
|
s = arguments[i];
|
|
5
|
-
|
|
6
5
|
for (var p in s) {
|
|
7
6
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
return t;
|
|
12
10
|
};
|
|
13
|
-
|
|
14
11
|
return __assign.apply(this, arguments);
|
|
15
12
|
};
|
|
16
|
-
|
|
17
13
|
import React from 'react';
|
|
18
14
|
import classNames from 'classnames';
|
|
19
15
|
import ReactDOM from 'react-dom';
|
|
20
16
|
import { canUseDOM } from '@autobest-ui/utils';
|
|
21
|
-
import LoadingIcon from '../loading-icon';
|
|
22
|
-
|
|
17
|
+
import LoadingIcon from '../loading-icon';
|
|
18
|
+
// 缓存创建的loading元素
|
|
23
19
|
var loadingElement = null;
|
|
24
20
|
var loadingTimer = null;
|
|
25
21
|
var closeTimer = null;
|
|
26
22
|
var prevCustomIcon = null;
|
|
27
23
|
var cls = 'ab-loading';
|
|
28
|
-
|
|
29
24
|
function getLoadingContainer(customIcon, className) {
|
|
30
25
|
return /*#__PURE__*/React.createElement("div", {
|
|
31
26
|
className: classNames("".concat(cls, "-wrap"), className)
|
|
32
27
|
}, customIcon || /*#__PURE__*/React.createElement(LoadingIcon, {
|
|
33
28
|
className: "".concat(cls, "-content")
|
|
34
29
|
}));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
}
|
|
31
|
+
// openIds 容器
|
|
32
|
+
var openIds = [];
|
|
33
|
+
// closeIds 容器
|
|
40
34
|
var closeIds = [];
|
|
41
|
-
|
|
42
35
|
function createLoading(customIcon, className) {
|
|
43
36
|
loadingElement = document.createElement('div');
|
|
44
37
|
document.body.appendChild(loadingElement);
|
|
45
38
|
ReactDOM.render(getLoadingContainer(customIcon, className), loadingElement);
|
|
46
39
|
}
|
|
47
|
-
|
|
48
|
-
var Loading =
|
|
49
|
-
/** @class */
|
|
50
|
-
function () {
|
|
40
|
+
var Loading = /** @class */function () {
|
|
51
41
|
function Loading() {}
|
|
52
|
-
|
|
53
42
|
Loading.open = function (config) {
|
|
54
43
|
if (!canUseDOM) {
|
|
55
44
|
return null;
|
|
56
45
|
}
|
|
57
|
-
|
|
58
46
|
config = __assign({
|
|
59
47
|
expire: 0
|
|
60
|
-
}, config);
|
|
61
|
-
|
|
48
|
+
}, config);
|
|
49
|
+
// 防止重复创建或自定义loading icon,重新创建
|
|
62
50
|
if (!loadingElement) {
|
|
63
51
|
createLoading(config.customIcon, config.className);
|
|
64
52
|
} else if (config.customIcon || config.customIcon !== prevCustomIcon) {
|
|
@@ -68,75 +56,60 @@ function () {
|
|
|
68
56
|
loadingElement = null;
|
|
69
57
|
} catch (e) {}
|
|
70
58
|
}
|
|
71
|
-
|
|
72
59
|
createLoading(config.customIcon, config.className);
|
|
73
60
|
} else {
|
|
74
61
|
loadingElement.style.display = 'block';
|
|
75
62
|
}
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
prevCustomIcon = config.customIcon;
|
|
64
|
+
// 如果配置中有expire且大于0
|
|
78
65
|
// 将会在到达时间后自动关闭,不用手动再关闭(不需要再close())
|
|
79
|
-
|
|
80
66
|
if (config.expire > 0) {
|
|
81
67
|
loadingTimer = setTimeout(function () {
|
|
82
68
|
Loading.close();
|
|
83
69
|
}, config.expire);
|
|
84
70
|
}
|
|
85
|
-
|
|
86
71
|
var id = new Date().getTime();
|
|
87
72
|
openIds.push(id);
|
|
88
73
|
return id;
|
|
89
74
|
};
|
|
90
|
-
|
|
91
75
|
Loading.close = function (closeId) {
|
|
92
76
|
if (!canUseDOM) {
|
|
93
77
|
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
78
|
+
}
|
|
79
|
+
// 防止重复关闭
|
|
97
80
|
if (loadingTimer) {
|
|
98
81
|
clearTimeout(loadingTimer);
|
|
99
82
|
}
|
|
100
|
-
|
|
101
83
|
if (closeTimer) {
|
|
102
84
|
clearTimeout(closeTimer);
|
|
103
85
|
}
|
|
104
|
-
|
|
105
86
|
if (!closeId) {
|
|
106
87
|
openIds = [];
|
|
107
88
|
closeIds = [];
|
|
108
|
-
|
|
109
89
|
if (loadingElement) {
|
|
110
90
|
loadingElement.style.display = 'none';
|
|
111
91
|
}
|
|
112
|
-
|
|
113
92
|
return;
|
|
114
93
|
}
|
|
115
|
-
|
|
116
|
-
|
|
94
|
+
closeIds.push(closeId);
|
|
95
|
+
// 代码执行时,由于一些接口loading很短暂,而另一个接口还没有开始调用,
|
|
117
96
|
// 只有closeId是不能真正解决一些特殊loading抖动情况,
|
|
118
97
|
// 根据js的任务队列,我们加入setTimeout,只有主线程结束后才执行销毁
|
|
119
|
-
|
|
120
98
|
closeTimer = setTimeout(function () {
|
|
121
99
|
closeIds.forEach(function (id) {
|
|
122
100
|
var index = openIds.indexOf(id);
|
|
123
|
-
|
|
124
101
|
if (index >= 0) {
|
|
125
102
|
openIds.splice(index, 1);
|
|
126
103
|
}
|
|
127
104
|
});
|
|
128
|
-
|
|
129
105
|
if (!openIds.length) {
|
|
130
106
|
closeIds = [];
|
|
131
|
-
|
|
132
107
|
if (loadingElement) {
|
|
133
108
|
loadingElement.style.display = 'none';
|
|
134
109
|
}
|
|
135
110
|
}
|
|
136
111
|
});
|
|
137
112
|
};
|
|
138
|
-
|
|
139
113
|
return Loading;
|
|
140
114
|
}();
|
|
141
|
-
|
|
142
115
|
export default Loading;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-loading-wrap{position:fixed;top:0;left:0;z-index:9999;background-color:rgba(255,255,255,.7);height:100%;width:100%}.ab-loading-wrap .ab-loading-content{position:absolute;left:50%;top:50%;display:block;width:.31rem;height:.31rem;transform:
|
|
1
|
+
.ab-svg-loading{display:inline-block}.ab-svg-loading-icon{display:block;width:.31rem;height:.31rem;animation:1s linear infinite reverse loading}@keyframes loading{0%{transform:rotate(0)}50%{transform:rotate(180deg)}100%{transform:rotate(360deg)}}.ab-loading-wrap{position:fixed;top:0;left:0;z-index:9999;background-color:rgba(255,255,255,.7);height:100%;width:100%}.ab-loading-wrap .ab-loading-content{position:absolute;left:50%;top:50%;display:block;width:.31rem;height:.31rem;transform:translate(-50%,-50%)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-loading-bar{position:fixed;top:0;left:0;margin-bottom:-3px;height:3px;width:100%;z-index:999}@keyframes movingBar{0%{left:50%;right:50%}99.9%{left:0;right:0}100%{left:50%;right:50%}}@keyframes changeBar{0
|
|
1
|
+
.ab-loading-bar{position:fixed;top:0;left:0;margin-bottom:-3px;height:3px;width:100%;z-index:999}@keyframes movingBar{0%{left:50%;right:50%}99.9%{left:0;right:0}100%{left:50%;right:50%}}@keyframes changeBar{0%,33.3%{background-color:#0aa770}33.33%{background-color:red}66.6%,66.66%{background-color:#f987d6}99.9%{background-color:#00bcd4}}.ab-loading-bar-bar{position:absolute;height:0;width:100%;text-indent:-9999px;background-color:#0aa770;animation:2.25s infinite changeBar}.ab-loading-bar-bar::before{content:"";height:3px;position:absolute;left:50%;right:50%;background-color:inherit;animation:.75s infinite movingBar}
|
|
@@ -2,14 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import LoadingIcon from '../loading-icon';
|
|
4
4
|
var cls = 'ab-loading-container';
|
|
5
|
-
|
|
6
5
|
function LoadingContainer(props) {
|
|
7
6
|
var _a;
|
|
8
|
-
|
|
9
7
|
var _b = props.loading,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
loading = _b === void 0 ? false : _b,
|
|
9
|
+
className = props.className,
|
|
10
|
+
children = props.children;
|
|
13
11
|
return /*#__PURE__*/React.createElement("div", {
|
|
14
12
|
className: classNames(className, cls, (_a = {}, _a["".concat(cls, "-active")] = loading, _a))
|
|
15
13
|
}, children, loading && /*#__PURE__*/React.createElement("div", {
|
|
@@ -18,5 +16,4 @@ function LoadingContainer(props) {
|
|
|
18
16
|
className: "".concat(cls, "-icon")
|
|
19
17
|
})));
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
export default LoadingContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-loading-container{position:relative}.ab-loading-container-active{user-select:none;pointer-events:none}.ab-loading-container-icon-box{position:absolute;background-color:rgba(255,255,255,.7);top:0;left:0;z-index:4;display:block;width:100%;height:100%}.ab-loading-container-icon{position:absolute;top:50%;left:50%;transform:
|
|
1
|
+
.ab-svg-loading{display:inline-block}.ab-svg-loading-icon{display:block;width:.31rem;height:.31rem;animation:1s linear infinite reverse loading}@keyframes loading{0%{transform:rotate(0)}50%{transform:rotate(180deg)}100%{transform:rotate(360deg)}}.ab-loading-container{position:relative}.ab-loading-container-active{user-select:none;pointer-events:none}.ab-loading-container-icon-box{position:absolute;background-color:rgba(255,255,255,.7);top:0;left:0;z-index:4;display:block;width:100%;height:100%}.ab-loading-container-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
var cls = 'ab-svg-loading';
|
|
4
|
-
|
|
5
4
|
var LoadingIcon = function LoadingIcon(props) {
|
|
6
5
|
var className = props.className;
|
|
7
6
|
return /*#__PURE__*/React.createElement("span", {
|
|
@@ -54,5 +53,4 @@ var LoadingIcon = function LoadingIcon(props) {
|
|
|
54
53
|
fill: "#fff"
|
|
55
54
|
})));
|
|
56
55
|
};
|
|
57
|
-
|
|
58
56
|
export default /*#__PURE__*/React.memo(LoadingIcon);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-svg-loading{display:inline-block}.ab-svg-loading-icon{display:block;width:.31rem;height:.31rem;animation:
|
|
1
|
+
.ab-svg-loading{display:inline-block}.ab-svg-loading-icon{display:block;width:.31rem;height:.31rem;animation:1s linear infinite reverse loading}@keyframes loading{0%{transform:rotate(0)}50%{transform:rotate(180deg)}100%{transform:rotate(360deg)}}
|
package/esm/mask/index.js
CHANGED
|
@@ -3,18 +3,16 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { CSSTransition } from 'react-transition-group';
|
|
4
4
|
import { isTouchScreen } from '@autobest-ui/utils';
|
|
5
5
|
var prefixCls = 'ab-mask';
|
|
6
|
-
|
|
7
6
|
function Mask(_a, ref) {
|
|
8
7
|
var className = _a.className,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
_b = _a.timeout,
|
|
9
|
+
timeout = _b === void 0 ? 300 : _b,
|
|
10
|
+
_c = _a.onClose,
|
|
11
|
+
onClose = _c === void 0 ? function () {} : _c,
|
|
12
|
+
visible = _a.visible;
|
|
13
|
+
// mousedown和touchstart会一起触发,这里判断后,只执行一次
|
|
15
14
|
var onChangeVisible = React.useCallback(function (event) {
|
|
16
15
|
var touch = isTouchScreen();
|
|
17
|
-
|
|
18
16
|
if (event.type === 'touchstart' && touch || event.type === 'mousedown' && !touch) {
|
|
19
17
|
onClose(event);
|
|
20
18
|
}
|
|
@@ -31,5 +29,4 @@ function Mask(_a, ref) {
|
|
|
31
29
|
ref: ref
|
|
32
30
|
}));
|
|
33
31
|
}
|
|
34
|
-
|
|
35
32
|
export default /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(Mask));
|
package/esm/mask/style/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-mask{position:fixed;top:0;left:0;z-index:101;width:100%;height:100%;background-color:rgba(0,0,0,.45);transition:opacity .4s cubic-bezier(.7,.3,.1,1)}.ab-mask-fade-appear,.ab-mask-fade-enter{opacity:0}.ab-mask-fade-appear-active,.ab-mask-fade-enter-active,.ab-mask-fade-enter-done
|
|
1
|
+
.ab-mask{position:fixed;top:0;left:0;z-index:101;width:100%;height:100%;background-color:rgba(0,0,0,.45);transition:opacity .4s cubic-bezier(.7,.3,.1,1)}.ab-mask-fade-appear,.ab-mask-fade-enter{opacity:0}.ab-mask-fade-appear-active,.ab-mask-fade-enter-active,.ab-mask-fade-enter-done,.ab-mask-fade-exit{opacity:1}.ab-mask-fade-exit-active{opacity:0}.ab-mask-fade-exit-done{display:none}
|
package/esm/message/index.d.ts
CHANGED
|
@@ -5,20 +5,31 @@ export interface MessageProps {
|
|
|
5
5
|
*/
|
|
6
6
|
content: React.ReactNode;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* 支持多种样式
|
|
9
9
|
*/
|
|
10
|
-
className?: string;
|
|
11
10
|
contentClassName?: string;
|
|
12
11
|
/**
|
|
13
12
|
* 提示文字显示的时间,达到时间后自动关闭
|
|
14
13
|
*/
|
|
15
14
|
expires?: number;
|
|
15
|
+
/**
|
|
16
|
+
* 销毁后的回调
|
|
17
|
+
*/
|
|
18
|
+
onDestroy?: () => void;
|
|
19
|
+
}
|
|
20
|
+
export interface MessageConfig {
|
|
21
|
+
className?: string;
|
|
22
|
+
expires?: number;
|
|
16
23
|
/**
|
|
17
24
|
* 最多同时显示的提示文字条数
|
|
18
25
|
*/
|
|
19
26
|
maxCount?: number;
|
|
20
|
-
width?: string;
|
|
21
|
-
height?: string;
|
|
22
|
-
onDestroy?: (id: number) => void;
|
|
23
27
|
}
|
|
24
|
-
|
|
28
|
+
declare function Message(props: MessageProps): {
|
|
29
|
+
onCloseAll: () => void;
|
|
30
|
+
onClose: () => void;
|
|
31
|
+
};
|
|
32
|
+
declare namespace Message {
|
|
33
|
+
var setConfig: (config: MessageConfig) => void;
|
|
34
|
+
}
|
|
35
|
+
export default Message;
|
package/esm/message/index.js
CHANGED
|
@@ -2,125 +2,97 @@ var __assign = this && this.__assign || function () {
|
|
|
2
2
|
__assign = Object.assign || function (t) {
|
|
3
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
4
|
s = arguments[i];
|
|
5
|
-
|
|
6
5
|
for (var p in s) {
|
|
7
6
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
return t;
|
|
12
10
|
};
|
|
13
|
-
|
|
14
11
|
return __assign.apply(this, arguments);
|
|
15
12
|
};
|
|
16
|
-
|
|
17
|
-
import
|
|
18
|
-
import { CSSTransition, TransitionGroup } from 'react-transition-group';
|
|
19
|
-
import classNames from 'classnames';
|
|
20
|
-
import ReactDOM from 'react-dom';
|
|
21
|
-
import { canUseDOM } from '@autobest-ui/utils';
|
|
22
|
-
var defaultConfig = {
|
|
23
|
-
expires: 3000,
|
|
24
|
-
maxCount: 3,
|
|
25
|
-
width: '6rem',
|
|
26
|
-
height: 'auto',
|
|
27
|
-
onDestroy: function onDestroy() {}
|
|
28
|
-
};
|
|
13
|
+
import { canUseDOM, isEmptyArray } from '@autobest-ui/utils';
|
|
14
|
+
import renderMessage from './renderMessage';
|
|
29
15
|
var prefixCls = 'ab-message';
|
|
30
|
-
var
|
|
31
|
-
var items = [];
|
|
16
|
+
var options = [];
|
|
32
17
|
var id = 0;
|
|
33
|
-
|
|
18
|
+
// 全局配置的默认值
|
|
19
|
+
var currentConfig = {
|
|
20
|
+
expires: 3000,
|
|
21
|
+
maxCount: 3
|
|
22
|
+
};
|
|
23
|
+
export default function Message(props) {
|
|
34
24
|
if (!canUseDOM) {
|
|
35
25
|
throw new Error('Message use client!');
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
var cachedId = id++;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
document.body.appendChild(container);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (items.length >= currentConfig.maxCount) {
|
|
49
|
-
close(items[0].id);
|
|
28
|
+
function render() {
|
|
29
|
+
renderMessage({
|
|
30
|
+
prefixCls: prefixCls,
|
|
31
|
+
className: currentConfig.className,
|
|
32
|
+
options: options
|
|
33
|
+
});
|
|
50
34
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
35
|
+
/**
|
|
36
|
+
* 关闭指定的一条message
|
|
37
|
+
* @param currentId
|
|
38
|
+
*/
|
|
39
|
+
function _onClose(currentId) {
|
|
40
|
+
if (isEmptyArray(options)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
var index = options.findIndex(function (item) {
|
|
54
44
|
return item.id === currentId;
|
|
55
45
|
});
|
|
56
|
-
|
|
57
46
|
if (index >= 0) {
|
|
58
|
-
clearTimeout(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
clearTimeout(options[index].timer);
|
|
48
|
+
options.splice(index, 1);
|
|
49
|
+
// 关闭需要再渲染一次
|
|
50
|
+
render();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 关闭所有message
|
|
55
|
+
*/
|
|
56
|
+
function onCloseAll() {
|
|
57
|
+
if (isEmptyArray(options)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
options.forEach(function (child) {
|
|
61
|
+
clearTimeout(child.timer);
|
|
62
|
+
});
|
|
63
|
+
options = [];
|
|
63
64
|
render();
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
function render() {
|
|
72
|
-
var cls = prefixCls;
|
|
73
|
-
ReactDOM.render( /*#__PURE__*/React.createElement(TransitionGroup, {
|
|
74
|
-
component: null
|
|
75
|
-
}, items.map(function (item) {
|
|
76
|
-
var _a = item.currentConfig,
|
|
77
|
-
content = _a.content,
|
|
78
|
-
width = _a.width,
|
|
79
|
-
height = _a.height,
|
|
80
|
-
contentClassName = _a.contentClassName;
|
|
81
|
-
var style = {
|
|
82
|
-
width: width,
|
|
83
|
-
height: height
|
|
84
|
-
};
|
|
85
|
-
return /*#__PURE__*/React.createElement(CSSTransition, {
|
|
86
|
-
key: item.id,
|
|
87
|
-
timeout: 300,
|
|
88
|
-
classNames: "".concat(cls, "-fade"),
|
|
89
|
-
onExited: function onExited() {
|
|
90
|
-
_onExited(item.id);
|
|
91
|
-
},
|
|
92
|
-
appear: true
|
|
93
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
94
|
-
className: classNames("".concat(cls, "-content"), contentClassName),
|
|
95
|
-
style: style
|
|
96
|
-
}, content, /*#__PURE__*/React.createElement("div", {
|
|
97
|
-
className: "".concat(cls, "-close"),
|
|
98
|
-
onClick: function onClick() {
|
|
99
|
-
close(item.id);
|
|
100
|
-
}
|
|
101
|
-
}, "\xD7")));
|
|
102
|
-
})), container);
|
|
66
|
+
/**
|
|
67
|
+
* 超出条数,将删除最旧的那条message
|
|
68
|
+
*/
|
|
69
|
+
if (options.length >= currentConfig.maxCount) {
|
|
70
|
+
_onClose(options[0].id);
|
|
103
71
|
}
|
|
104
|
-
|
|
72
|
+
// 每条message对象
|
|
105
73
|
var item = {
|
|
106
|
-
|
|
74
|
+
content: props.content,
|
|
75
|
+
contentClassName: props.contentClassName,
|
|
107
76
|
id: cachedId,
|
|
77
|
+
onDestroy: props.onDestroy,
|
|
78
|
+
onClose: _onClose,
|
|
108
79
|
timer: null
|
|
109
80
|
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
81
|
+
// push
|
|
82
|
+
options.push(item);
|
|
83
|
+
// 开始渲染
|
|
84
|
+
render();
|
|
85
|
+
// render后设置自动关闭功能,把定时器绑定到列表
|
|
113
86
|
item.timer = setTimeout(function () {
|
|
114
|
-
|
|
115
|
-
}, currentConfig.expires);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
87
|
+
_onClose(cachedId);
|
|
88
|
+
}, props.expires || currentConfig.expires);
|
|
89
|
+
return {
|
|
90
|
+
onCloseAll: onCloseAll,
|
|
91
|
+
onClose: function onClose() {
|
|
92
|
+
return _onClose(cachedId);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
Message.setConfig = function (config) {
|
|
97
|
+
currentConfig = __assign(__assign({}, currentConfig), config);
|
|
98
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface MessageItem {
|
|
3
|
+
content: React.ReactNode;
|
|
4
|
+
contentClassName?: string;
|
|
5
|
+
id: number;
|
|
6
|
+
onClose?: (id: number) => void;
|
|
7
|
+
onDestroy?: () => void;
|
|
8
|
+
}
|
|
9
|
+
interface TransitionContentProps {
|
|
10
|
+
prefixCls: string;
|
|
11
|
+
options: MessageItem[];
|
|
12
|
+
}
|
|
13
|
+
export interface RenderMessageProps extends TransitionContentProps {
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export default function renderMessage(props: RenderMessageProps): void;
|
|
17
|
+
export {};
|