dtable-ui-component 4.3.7 → 4.3.8
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/lib/AutoNumberFormatter/index.js +11 -24
- package/lib/ButtonFormatter/index.js +29 -45
- package/lib/CTimeFormatter/index.js +17 -32
- package/lib/CheckboxEditor/index.js +42 -49
- package/lib/CheckboxFormatter/index.js +17 -30
- package/lib/CollaboratorEditor/index.js +118 -135
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +90 -99
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +61 -69
- package/lib/CollaboratorFormatter/index.js +26 -42
- package/lib/CollaboratorItem/index.js +31 -44
- package/lib/CreatorFormatter/index.js +24 -40
- package/lib/DTableCustomizeCollaboratorSelect/index.js +80 -99
- package/lib/DTableCustomizeCollaboratorSelect/utils.js +12 -13
- package/lib/DTableCustomizeSelect/index.js +92 -103
- package/lib/DTablePopover/index.js +52 -71
- package/lib/DTablePopover/utils.js +1 -1
- package/lib/DTableRadio/index.js +9 -7
- package/lib/DTableSearchInput/index.js +89 -99
- package/lib/DTableSearchInput/utils.js +2 -2
- package/lib/DTableSelect/dtable-select-label.js +5 -3
- package/lib/DTableSelect/index.js +50 -64
- package/lib/DTableSelect/utils.js +36 -41
- package/lib/DTableSwitch/index.js +7 -5
- package/lib/DateEditor/index.js +88 -94
- package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
- package/lib/DateEditor/pc-date-editor-popover.js +70 -77
- package/lib/DateFormatter/index.js +15 -28
- package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
- package/lib/DigitalSignFormatter/index.js +55 -65
- package/lib/DigitalSignFormatter/utils.js +9 -8
- package/lib/DurationFormatter/index.js +14 -27
- package/lib/EditEditorButton/index.js +10 -22
- package/lib/EmailFormatter/index.js +11 -24
- package/lib/FieldDisplaySetting/field-item.js +18 -20
- package/lib/FieldDisplaySetting/index.js +41 -43
- package/lib/FileEditor/index.js +18 -29
- package/lib/FileFormatter/index.js +29 -43
- package/lib/FileItemFormatter/index.js +17 -32
- package/lib/FileItemFormatter/utils.js +5 -5
- package/lib/FileUploader/index.js +20 -33
- package/lib/FormulaFormatter/cell-value-validator.js +23 -8
- package/lib/FormulaFormatter/index.js +77 -83
- package/lib/FormulaFormatter/utils.js +27 -21
- package/lib/GeolocationFormatter/index.js +19 -32
- package/lib/HtmlLongTextFormatter/index.js +43 -52
- package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
- package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
- package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
- package/lib/ImageFormatter/images-lazy-load.js +71 -79
- package/lib/ImageFormatter/index.js +86 -97
- package/lib/ImageFormatter/utils.js +1 -1
- package/lib/ImagePreviewerLightbox/index.js +20 -18
- package/lib/ImagePreviewerLightbox/utils.js +3 -3
- package/lib/LastModifierFormatter/index.js +24 -40
- package/lib/LinkEditor/index.js +163 -167
- package/lib/LinkEditor/link-editor-option.js +41 -56
- package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
- package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
- package/lib/LinkFormatter/index.js +75 -77
- package/lib/LongTextFormatter/index.js +5 -3
- package/lib/MBEditorHeader/index.js +25 -38
- package/lib/MTimeFormatter/index.js +17 -32
- package/lib/ModalPortal/index.js +15 -32
- package/lib/MultipleSelectEditor/index.js +118 -136
- package/lib/MultipleSelectFormatter/index.js +24 -40
- package/lib/NotificationPopover/index.js +68 -95
- package/lib/NumberEditor/index.js +75 -82
- package/lib/NumberFormatter/index.js +15 -28
- package/lib/RateFormatter/index.js +29 -45
- package/lib/RoleStatusEditor/index.js +20 -22
- package/lib/RowExpandEmailFormatter/index.js +24 -37
- package/lib/RowExpandFileFormatter/index.js +28 -42
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
- package/lib/RowExpandFormatter/index.js +92 -96
- package/lib/RowExpandFormulaFormatter/index.js +85 -91
- package/lib/RowExpandImageFormatter/index.js +65 -82
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
- package/lib/RowExpandImageFormatter/utils.js +1 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
- package/lib/RowExpandLinkFormatter/index.js +131 -137
- package/lib/RowExpandLinkFormatter/utils.js +23 -17
- package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
- package/lib/RowExpandRateFormatter/index.js +27 -42
- package/lib/RowExpandUrlFormatter/index.js +27 -40
- package/lib/SelectItem/index.js +17 -33
- package/lib/SelectOptionGroup/index.js +141 -159
- package/lib/SelectOptionGroup/option.js +24 -40
- package/lib/SimpleLongTextFormatter/index.js +55 -67
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
- package/lib/SingleSelectEditor/index.js +108 -119
- package/lib/SingleSelectFormatter/index.js +21 -37
- package/lib/TextEditor/index.js +45 -51
- package/lib/TextFormatter/index.js +17 -32
- package/lib/UrlFormatter/index.js +11 -24
- package/lib/cellFormatterFactory/index.js +8 -17
- package/lib/common/ClickOutside.js +22 -43
- package/lib/common/delete-tip.js +40 -65
- package/lib/common/modal-portal.js +15 -33
- package/lib/constants/index.js +5 -5
- package/lib/data/dtable-value.js +4 -4
- package/lib/formatterConfig/base-formatter-config.js +24 -3
- package/lib/formatterConfig/index.js +5 -4
- package/lib/lang/index.js +6 -6
- package/lib/locals/de.js +1 -1
- package/lib/locals/en.js +1 -1
- package/lib/locals/fr.js +1 -1
- package/lib/locals/zh-CN.js +1 -1
- package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
- package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
- package/lib/select-editor/select-editor-option.js +41 -56
- package/lib/toaster/alert.js +73 -88
- package/lib/toaster/index.js +1 -1
- package/lib/toaster/toast.js +75 -102
- package/lib/toaster/toastManager.js +55 -91
- package/lib/toaster/toaster.js +58 -57
- package/lib/utils/editor-utils.js +17 -19
- package/lib/utils/utils.js +14 -14
- package/package.json +4 -4
package/lib/toaster/alert.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
2
|
import { css } from 'glamor';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _this;
|
|
12
|
-
_classCallCheck(this, Alert);
|
|
13
|
-
_this = _super.call(this, props);
|
|
14
|
-
_this.containerStyle = css({
|
|
3
|
+
class Alert extends React.PureComponent {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.containerStyle = css({
|
|
15
7
|
borderRadius: '3px',
|
|
16
8
|
backgroundColor: '#fff',
|
|
17
9
|
padding: '10px 16px',
|
|
@@ -21,30 +13,30 @@ var Alert = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
21
13
|
justifyContent: 'space-between',
|
|
22
14
|
flexDirection: 'row'
|
|
23
15
|
});
|
|
24
|
-
|
|
16
|
+
this.containerBorderSuccess = css({
|
|
25
17
|
borderLeft: '3px solid rgb(71, 184, 129)'
|
|
26
18
|
});
|
|
27
|
-
|
|
19
|
+
this.containerBorderWarn = css({
|
|
28
20
|
borderLeft: '3px solid rgb(217, 130, 43)'
|
|
29
21
|
});
|
|
30
|
-
|
|
22
|
+
this.containerBorderDanger = css({
|
|
31
23
|
borderLeft: '3px solid rgb(236, 76, 71)'
|
|
32
24
|
});
|
|
33
|
-
|
|
25
|
+
this.containerBorderNotify = css({
|
|
34
26
|
borderLeft: '3px solid rgb(16, 112, 202)'
|
|
35
27
|
});
|
|
36
|
-
|
|
28
|
+
this.toastTextTitle = css({
|
|
37
29
|
fontWeight: '600',
|
|
38
30
|
fontSize: '14px',
|
|
39
31
|
color: '#435a6f',
|
|
40
32
|
margin: '0'
|
|
41
33
|
});
|
|
42
|
-
|
|
34
|
+
this.toastTextChild = css({
|
|
43
35
|
fontSize: '14px',
|
|
44
36
|
color: '#999',
|
|
45
37
|
margin: '0'
|
|
46
38
|
});
|
|
47
|
-
|
|
39
|
+
this.toastClose = css({
|
|
48
40
|
marginLeft: '15px',
|
|
49
41
|
height: '24px',
|
|
50
42
|
width: '24px',
|
|
@@ -59,80 +51,73 @@ var Alert = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
59
51
|
opacity: 1
|
|
60
52
|
}
|
|
61
53
|
});
|
|
62
|
-
|
|
54
|
+
this.toastIcon = css({
|
|
63
55
|
marginRight: '10px',
|
|
64
56
|
width: '14px',
|
|
65
57
|
height: '20px',
|
|
66
58
|
lineHeight: '20px'
|
|
67
59
|
});
|
|
68
|
-
return _this;
|
|
69
60
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
iconClass: 'dtable-font dtable-icon-check-circle'
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}, {
|
|
117
|
-
key: "render",
|
|
118
|
-
value: function render() {
|
|
119
|
-
var toastStyle = this.getContainerStyle(this.props.intent);
|
|
120
|
-
return /*#__PURE__*/React.createElement("div", css(toastStyle.borderStyle, this.containerStyle), /*#__PURE__*/React.createElement("div", {
|
|
121
|
-
className: this.toastIcon
|
|
122
|
-
}, /*#__PURE__*/React.createElement("i", Object.assign({
|
|
123
|
-
className: toastStyle.iconClass
|
|
124
|
-
}, toastStyle.iconColor))), /*#__PURE__*/React.createElement("div", {
|
|
125
|
-
className: this.toastTextContainer
|
|
126
|
-
}, /*#__PURE__*/React.createElement("p", {
|
|
127
|
-
className: this.toastTextTitle
|
|
128
|
-
}, this.props.title), this.props.children ? /*#__PURE__*/React.createElement("p", {
|
|
129
|
-
className: this.toastTextChild
|
|
130
|
-
}, this.props.children) : null), this.props.isRemoveable && /*#__PURE__*/React.createElement("div", {
|
|
131
|
-
onClick: this.props.onRemove,
|
|
132
|
-
className: this.toastClose
|
|
133
|
-
}, /*#__PURE__*/React.createElement("span", null, "\xD7")));
|
|
61
|
+
getContainerStyle(intent) {
|
|
62
|
+
switch (intent) {
|
|
63
|
+
case 'success':
|
|
64
|
+
return {
|
|
65
|
+
borderStyle: this.containerBorderSuccess,
|
|
66
|
+
iconColor: css({
|
|
67
|
+
color: 'rgb(71, 184, 129)'
|
|
68
|
+
}),
|
|
69
|
+
iconClass: 'dtable-font dtable-icon-check-circle'
|
|
70
|
+
};
|
|
71
|
+
case 'warning':
|
|
72
|
+
return {
|
|
73
|
+
borderStyle: this.containerBorderWarn,
|
|
74
|
+
iconColor: css({
|
|
75
|
+
color: 'rgb(217, 130, 43)'
|
|
76
|
+
}),
|
|
77
|
+
iconClass: 'dtable-font dtable-icon-exclamation-triangle'
|
|
78
|
+
};
|
|
79
|
+
case 'none':
|
|
80
|
+
return {
|
|
81
|
+
borderStyle: this.containerBorderNotify,
|
|
82
|
+
iconColor: css({
|
|
83
|
+
color: 'rgb(16, 112, 202)'
|
|
84
|
+
}),
|
|
85
|
+
iconClass: 'dtable-font dtable-icon-exclamation-circle'
|
|
86
|
+
};
|
|
87
|
+
case 'danger':
|
|
88
|
+
return {
|
|
89
|
+
borderStyle: this.containerBorderDanger,
|
|
90
|
+
iconColor: css({
|
|
91
|
+
color: 'rgb(236, 76, 71)'
|
|
92
|
+
}),
|
|
93
|
+
iconClass: 'dtable-font dtable-icon-exclamation-circle'
|
|
94
|
+
};
|
|
95
|
+
default:
|
|
96
|
+
return {
|
|
97
|
+
borderStyle: this.containerBorderSuccess,
|
|
98
|
+
iconColor: css({
|
|
99
|
+
color: 'rgb(71, 184, 129)'
|
|
100
|
+
}),
|
|
101
|
+
iconClass: 'dtable-font dtable-icon-check-circle'
|
|
102
|
+
};
|
|
134
103
|
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
104
|
+
}
|
|
105
|
+
render() {
|
|
106
|
+
const toastStyle = this.getContainerStyle(this.props.intent);
|
|
107
|
+
return /*#__PURE__*/React.createElement("div", css(toastStyle.borderStyle, this.containerStyle), /*#__PURE__*/React.createElement("div", {
|
|
108
|
+
className: this.toastIcon
|
|
109
|
+
}, /*#__PURE__*/React.createElement("i", Object.assign({
|
|
110
|
+
className: toastStyle.iconClass
|
|
111
|
+
}, toastStyle.iconColor))), /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: this.toastTextContainer
|
|
113
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
114
|
+
className: this.toastTextTitle
|
|
115
|
+
}, this.props.title), this.props.children ? /*#__PURE__*/React.createElement("p", {
|
|
116
|
+
className: this.toastTextChild
|
|
117
|
+
}, this.props.children) : null), this.props.isRemoveable && /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
onClick: this.props.onRemove,
|
|
119
|
+
className: this.toastClose
|
|
120
|
+
}, /*#__PURE__*/React.createElement("span", null, "\xD7")));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
138
123
|
export default Alert;
|
package/lib/toaster/index.js
CHANGED
package/lib/toaster/toast.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
2
|
import { css } from 'glamor';
|
|
7
3
|
import Transition from 'react-transition-group/Transition';
|
|
8
4
|
import Alert from './alert';
|
|
9
|
-
|
|
5
|
+
const animationEasing = {
|
|
10
6
|
deceleration: 'cubic-bezier(0.0, 0.0, 0.2, 1)',
|
|
11
7
|
acceleration: 'cubic-bezier(0.4, 0.0, 1, 1)',
|
|
12
8
|
spring: 'cubic-bezier(0.175, 0.885, 0.320, 1.175)'
|
|
13
9
|
};
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const ANIMATION_DURATION = 240;
|
|
11
|
+
const openAnimation = css.keyframes('openAnimation', {
|
|
16
12
|
from: {
|
|
17
13
|
opacity: 0,
|
|
18
14
|
transform: 'translateY(-120%)'
|
|
@@ -21,7 +17,7 @@ var openAnimation = css.keyframes('openAnimation', {
|
|
|
21
17
|
transform: 'translateY(0)'
|
|
22
18
|
}
|
|
23
19
|
});
|
|
24
|
-
|
|
20
|
+
const closeAnimation = css.keyframes('closeAnimation', {
|
|
25
21
|
from: {
|
|
26
22
|
transform: 'scale(1)',
|
|
27
23
|
opacity: 1
|
|
@@ -31,7 +27,7 @@ var closeAnimation = css.keyframes('closeAnimation', {
|
|
|
31
27
|
opacity: 0
|
|
32
28
|
}
|
|
33
29
|
});
|
|
34
|
-
|
|
30
|
+
const animationStyles = css({
|
|
35
31
|
display: 'flex',
|
|
36
32
|
flexDirection: 'column',
|
|
37
33
|
alignItems: 'center',
|
|
@@ -44,120 +40,97 @@ var animationStyles = css({
|
|
|
44
40
|
animation: "".concat(closeAnimation, " 120ms ").concat(animationEasing.acceleration, " both")
|
|
45
41
|
}
|
|
46
42
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var _this;
|
|
52
|
-
_classCallCheck(this, Toast);
|
|
53
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
54
|
-
args[_key] = arguments[_key];
|
|
55
|
-
}
|
|
56
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
57
|
-
_this.state = {
|
|
43
|
+
export default class Toast extends React.PureComponent {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(...arguments);
|
|
46
|
+
this.state = {
|
|
58
47
|
isShown: true,
|
|
59
48
|
height: 0
|
|
60
49
|
};
|
|
61
|
-
|
|
50
|
+
this.close = event => {
|
|
62
51
|
if (event) {
|
|
63
52
|
event.nativeEvent.stopImmediatePropagation();
|
|
64
53
|
event.stopPropagation();
|
|
65
54
|
}
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
this.clearCloseTimer();
|
|
56
|
+
this.setState({
|
|
68
57
|
isShown: false
|
|
69
58
|
});
|
|
70
59
|
};
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
60
|
+
this.startCloseTimer = () => {
|
|
61
|
+
if (this.props.duration) {
|
|
62
|
+
this.closeTimer = setTimeout(() => {
|
|
63
|
+
this.close();
|
|
64
|
+
}, this.props.duration * 1000);
|
|
76
65
|
}
|
|
77
66
|
};
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
clearTimeout(
|
|
81
|
-
|
|
67
|
+
this.clearCloseTimer = () => {
|
|
68
|
+
if (this.closeTimer) {
|
|
69
|
+
clearTimeout(this.closeTimer);
|
|
70
|
+
this.closeTimer = null;
|
|
82
71
|
}
|
|
83
72
|
};
|
|
84
|
-
|
|
85
|
-
|
|
73
|
+
this.handleMouseEnter = () => {
|
|
74
|
+
this.clearCloseTimer();
|
|
86
75
|
};
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
this.handleMouseLeave = () => {
|
|
77
|
+
this.startCloseTimer();
|
|
89
78
|
};
|
|
90
|
-
|
|
79
|
+
this.onRef = ref => {
|
|
91
80
|
if (ref === null) return;
|
|
92
|
-
|
|
93
|
-
height
|
|
94
|
-
|
|
95
|
-
|
|
81
|
+
const {
|
|
82
|
+
height
|
|
83
|
+
} = ref.getBoundingClientRect();
|
|
84
|
+
this.setState({
|
|
85
|
+
height
|
|
96
86
|
});
|
|
97
87
|
};
|
|
98
|
-
return _this;
|
|
99
88
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.setState({
|
|
106
|
-
isShown: this.props.isShown
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}, {
|
|
111
|
-
key: "componentDidMount",
|
|
112
|
-
value: function componentDidMount() {
|
|
113
|
-
this.startCloseTimer();
|
|
114
|
-
}
|
|
115
|
-
}, {
|
|
116
|
-
key: "componentWillUnmount",
|
|
117
|
-
value: function componentWillUnmount() {
|
|
118
|
-
this.clearCloseTimer();
|
|
119
|
-
}
|
|
120
|
-
}, {
|
|
121
|
-
key: "render",
|
|
122
|
-
value: function render() {
|
|
123
|
-
var _this2 = this;
|
|
124
|
-
return /*#__PURE__*/React.createElement(Transition, {
|
|
125
|
-
appear: true,
|
|
126
|
-
unmountOnExit: true,
|
|
127
|
-
timeout: ANIMATION_DURATION,
|
|
128
|
-
in: this.state.isShown,
|
|
129
|
-
onExited: this.props.onRemove
|
|
130
|
-
}, function (state) {
|
|
131
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
132
|
-
"data-state": state,
|
|
133
|
-
className: animationStyles,
|
|
134
|
-
onMouseEnter: _this2.handleMouseEnter,
|
|
135
|
-
onMouseLeave: _this2.handleMouseLeave,
|
|
136
|
-
style: {
|
|
137
|
-
height: _this2.state.height,
|
|
138
|
-
zIndex: _this2.props.zIndex,
|
|
139
|
-
marginBottom: _this2.state.isShown ? 0 : -_this2.state.height
|
|
140
|
-
}
|
|
141
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
142
|
-
ref: _this2.onRef,
|
|
143
|
-
style: {
|
|
144
|
-
padding: 8
|
|
145
|
-
}
|
|
146
|
-
}, /*#__PURE__*/React.createElement(Alert, {
|
|
147
|
-
intent: _this2.props.intent,
|
|
148
|
-
title: _this2.props.title,
|
|
149
|
-
children: _this2.props.children || '',
|
|
150
|
-
isRemoveable: _this2.props.hasCloseButton,
|
|
151
|
-
onRemove: function onRemove(event) {
|
|
152
|
-
return _this2.close(event);
|
|
153
|
-
}
|
|
154
|
-
})));
|
|
89
|
+
componentDidUpdate(prevProps) {
|
|
90
|
+
if (prevProps.isShown !== this.props.isShown) {
|
|
91
|
+
// eslint-disable-next-line react/no-did-update-set-state
|
|
92
|
+
this.setState({
|
|
93
|
+
isShown: this.props.isShown
|
|
155
94
|
});
|
|
156
95
|
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
96
|
+
}
|
|
97
|
+
componentDidMount() {
|
|
98
|
+
this.startCloseTimer();
|
|
99
|
+
}
|
|
100
|
+
componentWillUnmount() {
|
|
101
|
+
this.clearCloseTimer();
|
|
102
|
+
}
|
|
103
|
+
render() {
|
|
104
|
+
return /*#__PURE__*/React.createElement(Transition, {
|
|
105
|
+
appear: true,
|
|
106
|
+
unmountOnExit: true,
|
|
107
|
+
timeout: ANIMATION_DURATION,
|
|
108
|
+
in: this.state.isShown,
|
|
109
|
+
onExited: this.props.onRemove
|
|
110
|
+
}, state => /*#__PURE__*/React.createElement("div", {
|
|
111
|
+
"data-state": state,
|
|
112
|
+
className: animationStyles,
|
|
113
|
+
onMouseEnter: this.handleMouseEnter,
|
|
114
|
+
onMouseLeave: this.handleMouseLeave,
|
|
115
|
+
style: {
|
|
116
|
+
height: this.state.height,
|
|
117
|
+
zIndex: this.props.zIndex,
|
|
118
|
+
marginBottom: this.state.isShown ? 0 : -this.state.height
|
|
119
|
+
}
|
|
120
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
121
|
+
ref: this.onRef,
|
|
122
|
+
style: {
|
|
123
|
+
padding: 8
|
|
124
|
+
}
|
|
125
|
+
}, /*#__PURE__*/React.createElement(Alert, {
|
|
126
|
+
intent: this.props.intent,
|
|
127
|
+
title: this.props.title,
|
|
128
|
+
children: this.props.children || '',
|
|
129
|
+
isRemoveable: this.props.hasCloseButton,
|
|
130
|
+
onRemove: event => this.close(event)
|
|
131
|
+
}))));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
160
134
|
Toast.defaultProps = {
|
|
161
135
|
intent: 'none'
|
|
162
|
-
};
|
|
163
|
-
export { Toast as default };
|
|
136
|
+
};
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
5
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
6
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
9
|
-
var _excluded = ["id", "description"];
|
|
10
1
|
import React from 'react';
|
|
11
2
|
import { css } from 'glamor';
|
|
12
3
|
import Toast from './toast';
|
|
13
|
-
|
|
4
|
+
const wrapperClass = css({
|
|
14
5
|
maxWidth: 560,
|
|
15
6
|
margin: '0 auto',
|
|
16
7
|
top: 0,
|
|
@@ -19,56 +10,39 @@ var wrapperClass = css({
|
|
|
19
10
|
position: 'fixed',
|
|
20
11
|
zIndex: 999999
|
|
21
12
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function ToastManager(props, context) {
|
|
29
|
-
var _this;
|
|
30
|
-
_classCallCheck(this, ToastManager);
|
|
31
|
-
_this = _super.call(this, props, context);
|
|
32
|
-
_this.getToasts = function () {
|
|
33
|
-
return _this.state.toasts;
|
|
13
|
+
const hasCustomId = settings => Object.hasOwnProperty.call(settings, 'id');
|
|
14
|
+
export default class ToastManager extends React.PureComponent {
|
|
15
|
+
constructor(props, context) {
|
|
16
|
+
super(props, context);
|
|
17
|
+
this.getToasts = () => {
|
|
18
|
+
return this.state.toasts;
|
|
34
19
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return toast.close();
|
|
38
|
-
});
|
|
20
|
+
this.closeAll = () => {
|
|
21
|
+
this.getToasts().forEach(toast => toast.close());
|
|
39
22
|
};
|
|
40
|
-
|
|
23
|
+
this.notify = (title, settings) => {
|
|
41
24
|
// If there's a custom toast ID passed, close existing toasts with the same custom ID
|
|
42
25
|
if (hasCustomId(settings)) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var toast = _step.value;
|
|
48
|
-
// Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
|
|
49
|
-
if (String(toast.id).startsWith(settings.id)) {
|
|
50
|
-
_this.closeToast(toast.id);
|
|
51
|
-
}
|
|
26
|
+
for (const toast of this.state.toasts) {
|
|
27
|
+
// Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
|
|
28
|
+
if (String(toast.id).startsWith(settings.id)) {
|
|
29
|
+
this.closeToast(toast.id);
|
|
52
30
|
}
|
|
53
|
-
} catch (err) {
|
|
54
|
-
_iterator.e(err);
|
|
55
|
-
} finally {
|
|
56
|
-
_iterator.f();
|
|
57
31
|
}
|
|
58
32
|
}
|
|
59
|
-
|
|
60
|
-
|
|
33
|
+
const instance = this.createToastInstance(title, settings);
|
|
34
|
+
this.setState(previousState => {
|
|
61
35
|
return {
|
|
62
|
-
toasts: [instance
|
|
36
|
+
toasts: [instance, ...previousState.toasts]
|
|
63
37
|
};
|
|
64
38
|
});
|
|
65
39
|
return instance;
|
|
66
40
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
41
|
+
this.createToastInstance = (title, settings) => {
|
|
42
|
+
const uniqueId = ++ToastManager.idCounter;
|
|
43
|
+
const id = hasCustomId(settings) ? "".concat(settings.id, "-").concat(uniqueId) : uniqueId;
|
|
44
|
+
let hasCloseButton = settings.hasCloseButton || true;
|
|
45
|
+
let duration = settings.duration || 2;
|
|
72
46
|
if (settings.hasCloseButton !== undefined) {
|
|
73
47
|
hasCloseButton = settings.hasCloseButton;
|
|
74
48
|
}
|
|
@@ -76,14 +50,12 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
76
50
|
duration = settings.duration;
|
|
77
51
|
}
|
|
78
52
|
return {
|
|
79
|
-
id
|
|
80
|
-
title
|
|
53
|
+
id,
|
|
54
|
+
title,
|
|
81
55
|
description: settings.description,
|
|
82
56
|
hasCloseButton: hasCloseButton,
|
|
83
57
|
duration: duration,
|
|
84
|
-
close:
|
|
85
|
-
return _this.closeToast(id);
|
|
86
|
-
},
|
|
58
|
+
close: () => this.closeToast(id),
|
|
87
59
|
intent: settings.intent
|
|
88
60
|
};
|
|
89
61
|
};
|
|
@@ -91,57 +63,49 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
91
63
|
* This will set isShown on the Toast which will close the toast.
|
|
92
64
|
* It won't remove the toast until onExited triggers onRemove.
|
|
93
65
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
66
|
+
this.closeToast = id => {
|
|
67
|
+
this.setState(previousState => {
|
|
96
68
|
return {
|
|
97
|
-
toasts: previousState.toasts.map(
|
|
69
|
+
toasts: previousState.toasts.map(toast => {
|
|
98
70
|
if (toast.id === id) {
|
|
99
|
-
return
|
|
71
|
+
return {
|
|
72
|
+
...toast,
|
|
100
73
|
isShown: false
|
|
101
|
-
}
|
|
74
|
+
};
|
|
102
75
|
}
|
|
103
76
|
return toast;
|
|
104
77
|
})
|
|
105
78
|
};
|
|
106
79
|
});
|
|
107
80
|
};
|
|
108
|
-
|
|
109
|
-
|
|
81
|
+
this.removeToast = id => {
|
|
82
|
+
this.setState(previousState => {
|
|
110
83
|
return {
|
|
111
|
-
toasts: previousState.toasts.filter(
|
|
112
|
-
return toast.id !== id;
|
|
113
|
-
})
|
|
84
|
+
toasts: previousState.toasts.filter(toast => toast.id !== id)
|
|
114
85
|
};
|
|
115
86
|
});
|
|
116
87
|
};
|
|
117
|
-
props.bindNotify(
|
|
118
|
-
props.bindGetToasts(
|
|
119
|
-
props.bindCloseAll(
|
|
120
|
-
|
|
88
|
+
props.bindNotify(this.notify);
|
|
89
|
+
props.bindGetToasts(this.getToasts);
|
|
90
|
+
props.bindCloseAll(this.closeAll);
|
|
91
|
+
this.state = {
|
|
121
92
|
toasts: []
|
|
122
93
|
};
|
|
123
|
-
return _this;
|
|
124
94
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
}]);
|
|
144
|
-
return ToastManager;
|
|
145
|
-
}(React.PureComponent);
|
|
146
|
-
ToastManager.idCounter = 0;
|
|
147
|
-
export { ToastManager as default };
|
|
95
|
+
render() {
|
|
96
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
97
|
+
className: wrapperClass
|
|
98
|
+
}, this.state.toasts.map(_ref => {
|
|
99
|
+
let {
|
|
100
|
+
id,
|
|
101
|
+
description,
|
|
102
|
+
...props
|
|
103
|
+
} = _ref;
|
|
104
|
+
return /*#__PURE__*/React.createElement(Toast, Object.assign({
|
|
105
|
+
key: id,
|
|
106
|
+
onRemove: () => this.removeToast(id)
|
|
107
|
+
}, props), description);
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
ToastManager.idCounter = 0;
|