dtable-ui-component 4.3.7 → 4.3.9-alpha1
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.css +1 -1
- 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.css +1 -1
- 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 +41 -135
- package/lib/toaster/index.css +116 -0
- package/lib/toaster/index.js +1 -1
- package/lib/toaster/toast.js +71 -136
- package/lib/toaster/toastManager.js +54 -100
- package/lib/toaster/toaster.js +59 -57
- package/lib/utils/editor-utils.js +17 -19
- package/lib/utils/utils.js +14 -14
- package/package.json +5 -6
package/lib/toaster/alert.js
CHANGED
|
@@ -1,138 +1,44 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
boxSizing: 'border-box',
|
|
20
|
-
boxShadow: 'rgba(67, 90, 111, 0.3) 0px 0px 1px, rgba(67, 90, 111, 0.47) 0px 8px 10px -4px',
|
|
21
|
-
justifyContent: 'space-between',
|
|
22
|
-
flexDirection: 'row'
|
|
23
|
-
});
|
|
24
|
-
_this.containerBorderSuccess = css({
|
|
25
|
-
borderLeft: '3px solid rgb(71, 184, 129)'
|
|
26
|
-
});
|
|
27
|
-
_this.containerBorderWarn = css({
|
|
28
|
-
borderLeft: '3px solid rgb(217, 130, 43)'
|
|
29
|
-
});
|
|
30
|
-
_this.containerBorderDanger = css({
|
|
31
|
-
borderLeft: '3px solid rgb(236, 76, 71)'
|
|
32
|
-
});
|
|
33
|
-
_this.containerBorderNotify = css({
|
|
34
|
-
borderLeft: '3px solid rgb(16, 112, 202)'
|
|
35
|
-
});
|
|
36
|
-
_this.toastTextTitle = css({
|
|
37
|
-
fontWeight: '600',
|
|
38
|
-
fontSize: '14px',
|
|
39
|
-
color: '#435a6f',
|
|
40
|
-
margin: '0'
|
|
41
|
-
});
|
|
42
|
-
_this.toastTextChild = css({
|
|
43
|
-
fontSize: '14px',
|
|
44
|
-
color: '#999',
|
|
45
|
-
margin: '0'
|
|
46
|
-
});
|
|
47
|
-
_this.toastClose = css({
|
|
48
|
-
marginLeft: '15px',
|
|
49
|
-
height: '24px',
|
|
50
|
-
width: '24px',
|
|
51
|
-
lineHeight: '22px',
|
|
52
|
-
fontWeight: '700',
|
|
53
|
-
textAlign: 'center',
|
|
54
|
-
fontSize: '20px',
|
|
55
|
-
color: '#000',
|
|
56
|
-
cursor: 'pointer',
|
|
57
|
-
opacity: '0.5',
|
|
58
|
-
':hover': {
|
|
59
|
-
opacity: 1
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
_this.toastIcon = css({
|
|
63
|
-
marginRight: '10px',
|
|
64
|
-
width: '14px',
|
|
65
|
-
height: '20px',
|
|
66
|
-
lineHeight: '20px'
|
|
67
|
-
});
|
|
68
|
-
return _this;
|
|
69
|
-
}
|
|
70
|
-
_createClass(Alert, [{
|
|
71
|
-
key: "getContainerStyle",
|
|
72
|
-
value: function getContainerStyle(intent) {
|
|
73
|
-
switch (intent) {
|
|
74
|
-
case 'success':
|
|
75
|
-
return {
|
|
76
|
-
borderStyle: this.containerBorderSuccess,
|
|
77
|
-
iconColor: css({
|
|
78
|
-
color: 'rgb(71, 184, 129)'
|
|
79
|
-
}),
|
|
80
|
-
iconClass: 'dtable-font dtable-icon-check-circle'
|
|
81
|
-
};
|
|
82
|
-
case 'warning':
|
|
83
|
-
return {
|
|
84
|
-
borderStyle: this.containerBorderWarn,
|
|
85
|
-
iconColor: css({
|
|
86
|
-
color: 'rgb(217, 130, 43)'
|
|
87
|
-
}),
|
|
88
|
-
iconClass: 'dtable-font dtable-icon-exclamation-triangle'
|
|
89
|
-
};
|
|
90
|
-
case 'none':
|
|
91
|
-
return {
|
|
92
|
-
borderStyle: this.containerBorderNotify,
|
|
93
|
-
iconColor: css({
|
|
94
|
-
color: 'rgb(16, 112, 202)'
|
|
95
|
-
}),
|
|
96
|
-
iconClass: 'dtable-font dtable-icon-exclamation-circle'
|
|
97
|
-
};
|
|
98
|
-
case 'danger':
|
|
99
|
-
return {
|
|
100
|
-
borderStyle: this.containerBorderDanger,
|
|
101
|
-
iconColor: css({
|
|
102
|
-
color: 'rgb(236, 76, 71)'
|
|
103
|
-
}),
|
|
104
|
-
iconClass: 'dtable-font dtable-icon-exclamation-circle'
|
|
105
|
-
};
|
|
106
|
-
default:
|
|
107
|
-
return {
|
|
108
|
-
borderStyle: this.containerBorderSuccess,
|
|
109
|
-
iconColor: css({
|
|
110
|
-
color: 'rgb(71, 184, 129)'
|
|
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")));
|
|
2
|
+
class Alert extends React.PureComponent {
|
|
3
|
+
getIconClass(intent) {
|
|
4
|
+
switch (intent) {
|
|
5
|
+
case 'success':
|
|
6
|
+
return 'dtable-font dtable-icon-check-circle';
|
|
7
|
+
case 'warning':
|
|
8
|
+
return 'dtable-font dtable-icon-exclamation-triangle';
|
|
9
|
+
case 'none':
|
|
10
|
+
return 'dtable-font dtable-icon-exclamation-circle';
|
|
11
|
+
case 'danger':
|
|
12
|
+
return 'dtable-font dtable-icon-exclamation-circle';
|
|
13
|
+
default:
|
|
14
|
+
return 'dtable-font dtable-icon-check-circle';
|
|
134
15
|
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
const {
|
|
19
|
+
intent,
|
|
20
|
+
title,
|
|
21
|
+
children,
|
|
22
|
+
isRemovable,
|
|
23
|
+
onRemove
|
|
24
|
+
} = this.props;
|
|
25
|
+
const iconClass = this.getIconClass(intent);
|
|
26
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
className: "dtable-toast-alert-container ".concat(intent || 'success')
|
|
28
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: "toast-alert-icon"
|
|
30
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
31
|
+
className: iconClass
|
|
32
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: "toast-text-container"
|
|
34
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
35
|
+
className: "toast-text-title"
|
|
36
|
+
}, title), children ? /*#__PURE__*/React.createElement("p", {
|
|
37
|
+
className: "toast-text-child"
|
|
38
|
+
}, children) : null), isRemovable && /*#__PURE__*/React.createElement("div", {
|
|
39
|
+
onClick: onRemove,
|
|
40
|
+
className: "toast-close"
|
|
41
|
+
}, /*#__PURE__*/React.createElement("span", null, "\xD7")));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
138
44
|
export default Alert;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
.dtable-toast-manager {
|
|
2
|
+
position: fixed;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
max-width: 560;
|
|
5
|
+
top: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
right: 0;
|
|
8
|
+
z-index: 999999;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.dtable-toast-container {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
align-items: center;
|
|
15
|
+
height: 0;
|
|
16
|
+
transition: all 240ms cubic-bezier(0.0, 0.0, 0.2, 1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@keyframes openAnimation {
|
|
20
|
+
from {
|
|
21
|
+
opacity: 0;
|
|
22
|
+
transform: translateY(-120%);
|
|
23
|
+
}
|
|
24
|
+
to {
|
|
25
|
+
transform: translateY(0);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@keyframes closeAnimation {
|
|
30
|
+
from {
|
|
31
|
+
transform: scale(1);
|
|
32
|
+
opacity: 1;
|
|
33
|
+
}
|
|
34
|
+
to {
|
|
35
|
+
transform: scale(0.9);
|
|
36
|
+
opacity: 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.dtable-toast-container.entering,
|
|
41
|
+
.dtable-toast-container.entered {
|
|
42
|
+
animation: openAnimation 240ms cubic-bezier(0.175, 0.885, 0.320, 1.175) both;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.dtable-toast-container.exiting {
|
|
46
|
+
animation: closeAnimation 120ms cubic-bezier(0.4, 0.0, 1, 1) both;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.dtable-toast-alert-container {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: row;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: space-between;
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
border-radius: 3px;
|
|
56
|
+
box-shadow: rgba(67, 90, 111, 0.3) 0px 0px 1px, rgba(67, 90, 111, 0.47) 0px 8px 10px -4px;
|
|
57
|
+
padding: 10px 16px;
|
|
58
|
+
background-color: #fff;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.dtable-toast-alert-container.success {
|
|
62
|
+
border-left: 3px solid rgb(71, 184, 129);
|
|
63
|
+
color: rgb(71, 184, 129);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.dtable-toast-alert-container.warning {
|
|
67
|
+
border-left: 3px solid rgb(217, 130, 43);
|
|
68
|
+
color: rgb(217, 130, 43);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.dtable-toast-alert-container.none {
|
|
72
|
+
border-left: 3px solid rgb(16, 112, 202);
|
|
73
|
+
color: rgb(16, 112, 202);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.dtable-toast-alert-container.danger {
|
|
77
|
+
border-left: 3px solid rgb(236, 76, 71);
|
|
78
|
+
color: rgb(236, 76, 71);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.dtable-toast-alert-container .toast-alert-icon {
|
|
82
|
+
margin-right: 10px;
|
|
83
|
+
width: 14px;
|
|
84
|
+
height: 20px;
|
|
85
|
+
line-height: 20px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.dtable-toast-alert-container .toast-text-title {
|
|
89
|
+
margin: 0;
|
|
90
|
+
font-weight: 600;
|
|
91
|
+
font-size: 14px;
|
|
92
|
+
color: #435a6f;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.dtable-toast-alert-container .toast-text-child {
|
|
96
|
+
font-size: 14px;
|
|
97
|
+
color: #999;
|
|
98
|
+
margin: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.dtable-toast-alert-container .toast-close {
|
|
102
|
+
text-align: center;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
height: 24px;
|
|
105
|
+
width: 24px;
|
|
106
|
+
margin-left: 15px;
|
|
107
|
+
line-height: 22px;
|
|
108
|
+
font-weight: 700;
|
|
109
|
+
font-size: 20px;
|
|
110
|
+
color: #000;
|
|
111
|
+
opacity: 0.5;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.dtable-toast-alert-container .toast-close:hover {
|
|
115
|
+
opacity: 1;
|
|
116
|
+
}
|
package/lib/toaster/index.js
CHANGED
package/lib/toaster/toast.js
CHANGED
|
@@ -1,163 +1,98 @@
|
|
|
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
|
-
import { css } from 'glamor';
|
|
7
2
|
import Transition from 'react-transition-group/Transition';
|
|
8
3
|
import Alert from './alert';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var ANIMATION_DURATION = 240;
|
|
15
|
-
var openAnimation = css.keyframes('openAnimation', {
|
|
16
|
-
from: {
|
|
17
|
-
opacity: 0,
|
|
18
|
-
transform: 'translateY(-120%)'
|
|
19
|
-
},
|
|
20
|
-
to: {
|
|
21
|
-
transform: 'translateY(0)'
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
var closeAnimation = css.keyframes('closeAnimation', {
|
|
25
|
-
from: {
|
|
26
|
-
transform: 'scale(1)',
|
|
27
|
-
opacity: 1
|
|
28
|
-
},
|
|
29
|
-
to: {
|
|
30
|
-
transform: 'scale(0.9)',
|
|
31
|
-
opacity: 0
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
var animationStyles = css({
|
|
35
|
-
display: 'flex',
|
|
36
|
-
flexDirection: 'column',
|
|
37
|
-
alignItems: 'center',
|
|
38
|
-
height: 0,
|
|
39
|
-
transition: "all ".concat(ANIMATION_DURATION, "ms ").concat(animationEasing.deceleration),
|
|
40
|
-
'&[data-state="entering"], &[data-state="entered"]': {
|
|
41
|
-
animation: "".concat(openAnimation, " ").concat(ANIMATION_DURATION, "ms ").concat(animationEasing.spring, " both")
|
|
42
|
-
},
|
|
43
|
-
'&[data-state="exiting"]': {
|
|
44
|
-
animation: "".concat(closeAnimation, " 120ms ").concat(animationEasing.acceleration, " both")
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
var Toast = /*#__PURE__*/function (_React$PureComponent) {
|
|
48
|
-
_inherits(Toast, _React$PureComponent);
|
|
49
|
-
var _super = _createSuper(Toast);
|
|
50
|
-
function Toast() {
|
|
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 = {
|
|
4
|
+
const ANIMATION_DURATION = 240;
|
|
5
|
+
export default class Toast extends React.PureComponent {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.state = {
|
|
58
9
|
isShown: true,
|
|
59
10
|
height: 0
|
|
60
11
|
};
|
|
61
|
-
|
|
12
|
+
this.close = event => {
|
|
62
13
|
if (event) {
|
|
63
14
|
event.nativeEvent.stopImmediatePropagation();
|
|
64
15
|
event.stopPropagation();
|
|
65
16
|
}
|
|
66
|
-
|
|
67
|
-
|
|
17
|
+
this.clearCloseTimer();
|
|
18
|
+
this.setState({
|
|
68
19
|
isShown: false
|
|
69
20
|
});
|
|
70
21
|
};
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
22
|
+
this.startCloseTimer = () => {
|
|
23
|
+
if (this.props.duration) {
|
|
24
|
+
this.closeTimer = setTimeout(() => {
|
|
25
|
+
this.close();
|
|
26
|
+
}, this.props.duration * 1000);
|
|
76
27
|
}
|
|
77
28
|
};
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
clearTimeout(
|
|
81
|
-
|
|
29
|
+
this.clearCloseTimer = () => {
|
|
30
|
+
if (this.closeTimer) {
|
|
31
|
+
clearTimeout(this.closeTimer);
|
|
32
|
+
this.closeTimer = null;
|
|
82
33
|
}
|
|
83
34
|
};
|
|
84
|
-
|
|
85
|
-
|
|
35
|
+
this.handleMouseEnter = () => {
|
|
36
|
+
this.clearCloseTimer();
|
|
86
37
|
};
|
|
87
|
-
|
|
88
|
-
|
|
38
|
+
this.handleMouseLeave = () => {
|
|
39
|
+
this.startCloseTimer();
|
|
89
40
|
};
|
|
90
|
-
|
|
41
|
+
this.onRef = ref => {
|
|
91
42
|
if (ref === null) return;
|
|
92
|
-
|
|
93
|
-
height
|
|
94
|
-
|
|
95
|
-
|
|
43
|
+
const {
|
|
44
|
+
height
|
|
45
|
+
} = ref.getBoundingClientRect();
|
|
46
|
+
this.setState({
|
|
47
|
+
height
|
|
96
48
|
});
|
|
97
49
|
};
|
|
98
|
-
return _this;
|
|
99
50
|
}
|
|
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
|
-
})));
|
|
51
|
+
componentDidUpdate(prevProps) {
|
|
52
|
+
if (prevProps.isShown !== this.props.isShown) {
|
|
53
|
+
// eslint-disable-next-line react/no-did-update-set-state
|
|
54
|
+
this.setState({
|
|
55
|
+
isShown: this.props.isShown
|
|
155
56
|
});
|
|
156
57
|
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
58
|
+
}
|
|
59
|
+
componentDidMount() {
|
|
60
|
+
this.startCloseTimer();
|
|
61
|
+
}
|
|
62
|
+
componentWillUnmount() {
|
|
63
|
+
this.clearCloseTimer();
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
return /*#__PURE__*/React.createElement(Transition, {
|
|
67
|
+
appear: true,
|
|
68
|
+
unmountOnExit: true,
|
|
69
|
+
timeout: ANIMATION_DURATION,
|
|
70
|
+
in: this.state.isShown,
|
|
71
|
+
onExited: this.props.onRemove
|
|
72
|
+
}, state => /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
"data-state": state,
|
|
74
|
+
className: "dtable-toast-container ".concat(state),
|
|
75
|
+
onMouseEnter: this.handleMouseEnter,
|
|
76
|
+
onMouseLeave: this.handleMouseLeave,
|
|
77
|
+
style: {
|
|
78
|
+
height: this.state.height,
|
|
79
|
+
zIndex: this.props.zIndex,
|
|
80
|
+
marginBottom: this.state.isShown ? 0 : -this.state.height
|
|
81
|
+
}
|
|
82
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
83
|
+
ref: this.onRef,
|
|
84
|
+
style: {
|
|
85
|
+
padding: 8
|
|
86
|
+
}
|
|
87
|
+
}, /*#__PURE__*/React.createElement(Alert, {
|
|
88
|
+
intent: this.props.intent,
|
|
89
|
+
title: this.props.title,
|
|
90
|
+
children: this.props.children || '',
|
|
91
|
+
isRemovable: this.props.hasCloseButton,
|
|
92
|
+
onRemove: event => this.close(event)
|
|
93
|
+
}))));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
160
96
|
Toast.defaultProps = {
|
|
161
97
|
intent: 'none'
|
|
162
|
-
};
|
|
163
|
-
export { Toast as default };
|
|
98
|
+
};
|