dtable-ui-component 0.1.75-beta3 → 0.1.75-beta4
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 +27 -38
- package/lib/ButtonFormatter/index.js +47 -59
- package/lib/CTimeFormatter/index.js +39 -53
- package/lib/CheckboxFormatter/index.js +35 -48
- package/lib/CollaboratorFormatter/index.js +42 -64
- package/lib/CollaboratorItem/index.js +44 -61
- package/lib/CreatorFormatter/index.js +42 -62
- package/lib/DateFormatter/index.js +40 -55
- package/lib/DurationFormatter/index.js +29 -42
- package/lib/EmailFormatter/index.js +27 -38
- package/lib/FileFormatter/index.js +50 -65
- package/lib/FileItemFormatter/index.js +32 -44
- package/lib/FileUploader/index.js +34 -44
- package/lib/FormulaFormatter/index.js +81 -102
- package/lib/GeolocationFormatter/index.js +35 -50
- package/lib/ImageFormatter/images-lazy-load.js +73 -81
- package/lib/ImageFormatter/index.js +90 -109
- package/lib/ImagePreviewerLightbox/index.js +27 -60
- package/lib/LastModifierFormatter/index.js +42 -62
- package/lib/LinkFormatter/index.js +59 -80
- package/lib/Loading/index.js +4 -13
- package/lib/LongTextFormatter/html-long-text-formatter.js +49 -60
- package/lib/LongTextFormatter/index.js +9 -28
- package/lib/LongTextFormatter/simple-long-text-formatter.js +52 -58
- package/lib/MTimeFormatter/index.js +39 -53
- package/lib/ModalPortal/index.js +30 -37
- package/lib/MultipleSelectFormatter/index.js +39 -55
- package/lib/NumberFormatter/index.js +35 -50
- package/lib/RateFormatter/index.js +37 -52
- package/lib/SelectItem/index.js +31 -46
- package/lib/SingleSelectFormatter/index.js +38 -54
- package/lib/TextFormatter/index.js +31 -44
- package/lib/UrlFormatter/index.js +27 -38
- package/lib/app.js +75 -80
- package/lib/cellFormatterFactory/index.js +17 -20
- package/lib/components/cell-editor/checkbox-editor.js +59 -66
- package/lib/components/cell-editor/collaborator-editor.js +113 -126
- package/lib/components/cell-editor/date-editor.js +99 -119
- package/lib/components/cell-editor/index.js +9 -40
- package/lib/components/cell-editor/link-editor.js +122 -140
- package/lib/components/cell-editor/multiple-select-editor.js +114 -127
- package/lib/components/cell-editor/number-editor.js +78 -86
- package/lib/components/cell-editor/single-select-editor.js +106 -120
- package/lib/components/cell-editor/text-editor.js +65 -72
- package/lib/components/cell-editor-dialog/pc-file-editor-dialog.js +31 -51
- package/lib/components/cell-editor-dialog/pc-files-addition/index.js +0 -1
- package/lib/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -1
- package/lib/components/cell-editor-dialog/pc-files-preview/index.js +0 -1
- package/lib/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -1
- package/lib/components/cell-editor-popover/mb-collaborator-editor-popover.js +105 -111
- package/lib/components/cell-editor-popover/mb-date-editor-popover.js +140 -157
- package/lib/components/cell-editor-popover/mb-link-editor-popover.js +103 -109
- package/lib/components/cell-editor-popover/mb-select-editor-popover.js +142 -155
- package/lib/components/cell-editor-popover/pc-collaborator-editor-popover.js +74 -89
- package/lib/components/cell-editor-popover/pc-date-editor-popover.js +88 -102
- package/lib/components/cell-editor-popover/pc-link-editor-popover.js +77 -91
- package/lib/components/cell-editor-popover/pc-select-editor-popover.js +91 -105
- package/lib/components/common/collaborator-item.js +43 -59
- package/lib/components/common/edit-editor-button.js +28 -39
- package/lib/components/common/link-editor-option.js +63 -71
- package/lib/components/common/mobile/mb-editor-header.js +39 -52
- package/lib/components/common/select-editor-option.js +58 -74
- package/lib/constants/cell-types.js +25 -54
- package/lib/constants/index.js +5 -28
- package/lib/formatterConfig/index.js +28 -59
- package/lib/index.js +31 -139
- package/lib/lang/index.js +11 -27
- package/lib/locals/de.js +1 -6
- package/lib/locals/en.js +1 -6
- package/lib/locals/fr.js +1 -6
- package/lib/locals/zh-CN.js +1 -6
- package/lib/toaster/alert.js +92 -106
- package/lib/toaster/index.js +3 -12
- package/lib/toaster/toast.js +103 -147
- package/lib/toaster/toastManager.js +78 -97
- package/lib/toaster/toaster.js +36 -52
- package/lib/utils/cell-value-validator.js +5 -9
- package/lib/utils/column-utils.js +5 -13
- package/lib/utils/editor-utils.js +3 -13
- package/lib/utils/markdown2html.js +1 -7
- package/lib/utils/normalize-long-text-value.js +1 -6
- package/lib/utils/number-precision.js +13 -31
- package/lib/utils/utils.js +8 -33
- package/lib/utils/value-format-utils.js +58 -108
- package/package.json +5 -5
- package/es/AutoNumberFormatter/index.css +0 -1
- package/es/AutoNumberFormatter/index.js +0 -36
- package/es/ButtonFormatter/index.css +0 -13
- package/es/ButtonFormatter/index.js +0 -56
- package/es/CTimeFormatter/index.css +0 -1
- package/es/CTimeFormatter/index.js +0 -58
- package/es/CheckboxFormatter/index.css +0 -1
- package/es/CheckboxFormatter/index.js +0 -45
- package/es/CollaboratorFormatter/index.css +0 -1
- package/es/CollaboratorFormatter/index.js +0 -91
- package/es/CollaboratorItem/index.css +0 -49
- package/es/CollaboratorItem/index.js +0 -64
- package/es/CreatorFormatter/index.css +0 -1
- package/es/CreatorFormatter/index.js +0 -87
- package/es/DateFormatter/index.css +0 -1
- package/es/DateFormatter/index.js +0 -60
- package/es/DurationFormatter/index.css +0 -1
- package/es/DurationFormatter/index.js +0 -38
- package/es/EmailFormatter/index.css +0 -5
- package/es/EmailFormatter/index.js +0 -36
- package/es/FileFormatter/index.css +0 -29
- package/es/FileFormatter/index.js +0 -64
- package/es/FileItemFormatter/index.js +0 -50
- package/es/FileUploader/index.js +0 -53
- package/es/FormulaFormatter/index.css +0 -19
- package/es/FormulaFormatter/index.js +0 -164
- package/es/GeolocationFormatter/index.css +0 -1
- package/es/GeolocationFormatter/index.js +0 -53
- package/es/ImageFormatter/images-lazy-load.js +0 -150
- package/es/ImageFormatter/index.css +0 -34
- package/es/ImageFormatter/index.js +0 -154
- package/es/ImagePreviewerLightbox/index.css +0 -87
- package/es/ImagePreviewerLightbox/index.js +0 -119
- package/es/LastModifierFormatter/index.css +0 -1
- package/es/LastModifierFormatter/index.js +0 -87
- package/es/LinkFormatter/index.css +0 -27
- package/es/LinkFormatter/index.js +0 -144
- package/es/Loading/index.css +0 -54
- package/es/Loading/index.js +0 -7
- package/es/LongTextFormatter/html-long-text-formatter.js +0 -96
- package/es/LongTextFormatter/index.css +0 -63
- package/es/LongTextFormatter/index.js +0 -29
- package/es/LongTextFormatter/simple-long-text-formatter.js +0 -104
- package/es/MTimeFormatter/index.css +0 -1
- package/es/MTimeFormatter/index.js +0 -58
- package/es/ModalPortal/index.js +0 -44
- package/es/MultipleSelectFormatter/index.css +0 -1
- package/es/MultipleSelectFormatter/index.js +0 -70
- package/es/NumberFormatter/index.css +0 -1
- package/es/NumberFormatter/index.js +0 -47
- package/es/RateFormatter/index.css +0 -1
- package/es/RateFormatter/index.js +0 -80
- package/es/SelectItem/index.js +0 -58
- package/es/SingleSelectFormatter/index.css +0 -1
- package/es/SingleSelectFormatter/index.js +0 -70
- package/es/TextFormatter/index.css +0 -1
- package/es/TextFormatter/index.js +0 -56
- package/es/UrlFormatter/index.css +0 -5
- package/es/UrlFormatter/index.js +0 -36
- package/es/app.css +0 -20
- package/es/app.js +0 -91
- package/es/assets/images/avatar/default_avatar.png +0 -0
- package/es/assets/images/file/192/excel.png +0 -0
- package/es/assets/images/file/192/file.png +0 -0
- package/es/assets/images/file/192/music.png +0 -0
- package/es/assets/images/file/192/pdf.png +0 -0
- package/es/assets/images/file/192/pic.png +0 -0
- package/es/assets/images/file/192/ppt.png +0 -0
- package/es/assets/images/file/192/txt.png +0 -0
- package/es/assets/images/file/192/video.png +0 -0
- package/es/assets/images/file/192/word.png +0 -0
- package/es/assets/images/file/24/excel.png +0 -0
- package/es/assets/images/file/24/file.png +0 -0
- package/es/assets/images/file/24/music.png +0 -0
- package/es/assets/images/file/24/pdf.png +0 -0
- package/es/assets/images/file/24/pic.png +0 -0
- package/es/assets/images/file/24/ppt.png +0 -0
- package/es/assets/images/file/24/txt.png +0 -0
- package/es/assets/images/file/24/video.png +0 -0
- package/es/assets/images/file/24/word.png +0 -0
- package/es/assets/images/folder/folder-192.png +0 -0
- package/es/assets/images/folder/folder-24.png +0 -0
- package/es/cellFormatterFactory/index.js +0 -25
- package/es/components/cell-editor/checkbox-editor.js +0 -104
- package/es/components/cell-editor/collaborator-editor.js +0 -236
- package/es/components/cell-editor/date-editor.js +0 -151
- package/es/components/cell-editor/index.js +0 -9
- package/es/components/cell-editor/link-editor.js +0 -303
- package/es/components/cell-editor/multiple-select-editor.js +0 -237
- package/es/components/cell-editor/number-editor.js +0 -154
- package/es/components/cell-editor/single-select-editor.js +0 -202
- package/es/components/cell-editor/text-editor.js +0 -122
- package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
- package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
- package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +0 -177
- package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
- package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
- package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
- package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
- package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
- package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
- package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
- package/es/components/common/collaborator-item.js +0 -63
- package/es/components/common/edit-editor-button.js +0 -56
- package/es/components/common/link-editor-option.js +0 -113
- package/es/components/common/mobile/mb-editor-header.js +0 -48
- package/es/components/common/select-editor-option.js +0 -106
- package/es/constants/cell-types.js +0 -25
- package/es/constants/index.js +0 -49
- package/es/css/cell-editor.css +0 -614
- package/es/css/cell-formatter.css +0 -4
- package/es/css/custom-rc-calendar.css +0 -118
- package/es/formatterConfig/index.js +0 -31
- package/es/index.js +0 -31
- package/es/lang/index.js +0 -50
- package/es/locals/de.js +0 -2
- package/es/locals/en.js +0 -17
- package/es/locals/fr.js +0 -2
- package/es/locals/zh-CN.js +0 -17
- package/es/toaster/alert.js +0 -150
- package/es/toaster/index.js +0 -3
- package/es/toaster/toast.js +0 -179
- package/es/toaster/toastManager.js +0 -170
- package/es/toaster/toaster.js +0 -76
- package/es/utils/cell-value-validator.js +0 -31
- package/es/utils/column-utils.js +0 -7
- package/es/utils/editor-utils.js +0 -71
- package/es/utils/markdown2html.js +0 -62
- package/es/utils/normalize-long-text-value.js +0 -69
- package/es/utils/number-precision.js +0 -164
- package/es/utils/unified/index.js +0 -470
- package/es/utils/utils.js +0 -116
- package/es/utils/value-format-utils.js +0 -497
- package/es/utils/vfile/core.js +0 -172
- package/es/utils/vfile/index.js +0 -48
package/lib/toaster/toast.js
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
11
|
-
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
|
-
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
|
|
16
|
-
var _glamor = require("glamor");
|
|
17
|
-
|
|
18
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
|
-
|
|
20
|
-
var _Transition = _interopRequireDefault(require("react-transition-group/Transition"));
|
|
21
|
-
|
|
22
|
-
var _alert = _interopRequireDefault(require("./alert"));
|
|
23
|
-
|
|
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
|
+
import React from 'react';
|
|
6
|
+
import { css } from 'glamor';
|
|
7
|
+
import Transition from 'react-transition-group/Transition';
|
|
8
|
+
import Alert from './alert';
|
|
24
9
|
var animationEasing = {
|
|
25
10
|
deceleration: 'cubic-bezier(0.0, 0.0, 0.2, 1)',
|
|
26
11
|
acceleration: 'cubic-bezier(0.4, 0.0, 1, 1)',
|
|
27
12
|
spring: 'cubic-bezier(0.175, 0.885, 0.320, 1.175)'
|
|
28
13
|
};
|
|
29
14
|
var ANIMATION_DURATION = 240;
|
|
30
|
-
|
|
31
|
-
var openAnimation = _glamor.css.keyframes('openAnimation', {
|
|
15
|
+
var openAnimation = css.keyframes('openAnimation', {
|
|
32
16
|
from: {
|
|
33
17
|
opacity: 0,
|
|
34
18
|
transform: 'translateY(-120%)'
|
|
@@ -37,8 +21,7 @@ var openAnimation = _glamor.css.keyframes('openAnimation', {
|
|
|
37
21
|
transform: 'translateY(0)'
|
|
38
22
|
}
|
|
39
23
|
});
|
|
40
|
-
|
|
41
|
-
var closeAnimation = _glamor.css.keyframes('closeAnimation', {
|
|
24
|
+
var closeAnimation = css.keyframes('closeAnimation', {
|
|
42
25
|
from: {
|
|
43
26
|
transform: 'scale(1)',
|
|
44
27
|
opacity: 1
|
|
@@ -48,63 +31,72 @@ var closeAnimation = _glamor.css.keyframes('closeAnimation', {
|
|
|
48
31
|
opacity: 0
|
|
49
32
|
}
|
|
50
33
|
});
|
|
51
|
-
|
|
52
|
-
var animationStyles = (0, _glamor.css)({
|
|
34
|
+
var animationStyles = css({
|
|
53
35
|
display: 'flex',
|
|
54
36
|
flexDirection: 'column',
|
|
55
37
|
alignItems: 'center',
|
|
56
38
|
height: 0,
|
|
57
|
-
transition: "all "
|
|
39
|
+
transition: "all ".concat(ANIMATION_DURATION, "ms ").concat(animationEasing.deceleration),
|
|
58
40
|
'&[data-state="entering"], &[data-state="entered"]': {
|
|
59
|
-
animation: openAnimation
|
|
41
|
+
animation: "".concat(openAnimation, " ").concat(ANIMATION_DURATION, "ms ").concat(animationEasing.spring, " both")
|
|
60
42
|
},
|
|
61
43
|
'&[data-state="exiting"]': {
|
|
62
|
-
animation: closeAnimation
|
|
44
|
+
animation: "".concat(closeAnimation, " 120ms ").concat(animationEasing.acceleration, " both")
|
|
63
45
|
}
|
|
64
46
|
});
|
|
65
47
|
|
|
66
48
|
var Toast = /*#__PURE__*/function (_React$PureComponent) {
|
|
67
|
-
(
|
|
49
|
+
_inherits(Toast, _React$PureComponent);
|
|
50
|
+
|
|
51
|
+
var _super = _createSuper(Toast);
|
|
68
52
|
|
|
69
53
|
function Toast() {
|
|
70
54
|
var _this;
|
|
71
55
|
|
|
56
|
+
_classCallCheck(this, Toast);
|
|
57
|
+
|
|
72
58
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
73
59
|
args[_key] = arguments[_key];
|
|
74
60
|
}
|
|
75
61
|
|
|
76
|
-
_this =
|
|
77
|
-
|
|
62
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
63
|
+
_this.state = {
|
|
78
64
|
isShown: true,
|
|
79
65
|
height: 0
|
|
80
|
-
}
|
|
81
|
-
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
_this.close = function () {
|
|
82
69
|
_this.clearCloseTimer();
|
|
83
70
|
|
|
84
71
|
_this.setState({
|
|
85
72
|
isShown: false
|
|
86
73
|
});
|
|
87
|
-
}
|
|
88
|
-
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
_this.startCloseTimer = function () {
|
|
89
77
|
if (_this.props.duration) {
|
|
90
78
|
_this.closeTimer = setTimeout(function () {
|
|
91
79
|
_this.close();
|
|
92
80
|
}, _this.props.duration * 1000);
|
|
93
81
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
_this.clearCloseTimer = function () {
|
|
96
85
|
if (_this.closeTimer) {
|
|
97
86
|
clearTimeout(_this.closeTimer);
|
|
98
87
|
_this.closeTimer = null;
|
|
99
88
|
}
|
|
100
|
-
}
|
|
101
|
-
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
_this.handleMouseEnter = function () {
|
|
102
92
|
_this.clearCloseTimer();
|
|
103
|
-
}
|
|
104
|
-
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
_this.handleMouseLeave = function () {
|
|
105
96
|
_this.startCloseTimer();
|
|
106
|
-
}
|
|
107
|
-
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
_this.onRef = function (ref) {
|
|
108
100
|
if (ref === null) return;
|
|
109
101
|
|
|
110
102
|
var _ref$getBoundingClien = ref.getBoundingClientRect(),
|
|
@@ -113,111 +105,75 @@ var Toast = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
113
105
|
_this.setState({
|
|
114
106
|
height: height
|
|
115
107
|
});
|
|
116
|
-
}
|
|
108
|
+
};
|
|
109
|
+
|
|
117
110
|
return _this;
|
|
118
111
|
}
|
|
119
112
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
_createClass(Toast, [{
|
|
114
|
+
key: "componentDidUpdate",
|
|
115
|
+
value: function componentDidUpdate(prevProps) {
|
|
116
|
+
if (prevProps.isShown !== this.props.isShown) {
|
|
117
|
+
// eslint-disable-next-line react/no-did-update-set-state
|
|
118
|
+
this.setState({
|
|
119
|
+
isShown: this.props.isShown
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "componentDidMount",
|
|
125
|
+
value: function componentDidMount() {
|
|
126
|
+
this.startCloseTimer();
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "componentWillUnmount",
|
|
130
|
+
value: function componentWillUnmount() {
|
|
131
|
+
this.clearCloseTimer();
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
134
|
+
key: "render",
|
|
135
|
+
value: function render() {
|
|
136
|
+
var _this2 = this;
|
|
137
|
+
|
|
138
|
+
return /*#__PURE__*/React.createElement(Transition, {
|
|
139
|
+
appear: true,
|
|
140
|
+
unmountOnExit: true,
|
|
141
|
+
timeout: ANIMATION_DURATION,
|
|
142
|
+
in: this.state.isShown,
|
|
143
|
+
onExited: this.props.onRemove
|
|
144
|
+
}, function (state) {
|
|
145
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
"data-state": state,
|
|
147
|
+
className: animationStyles,
|
|
148
|
+
onMouseEnter: _this2.handleMouseEnter,
|
|
149
|
+
onMouseLeave: _this2.handleMouseLeave,
|
|
150
|
+
style: {
|
|
151
|
+
height: _this2.state.height,
|
|
152
|
+
zIndex: _this2.props.zIndex,
|
|
153
|
+
marginBottom: _this2.state.isShown ? 0 : -_this2.state.height
|
|
154
|
+
}
|
|
155
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
156
|
+
ref: _this2.onRef,
|
|
157
|
+
style: {
|
|
158
|
+
padding: 8
|
|
159
|
+
}
|
|
160
|
+
}, /*#__PURE__*/React.createElement(Alert, {
|
|
161
|
+
intent: _this2.props.intent,
|
|
162
|
+
title: _this2.props.title,
|
|
163
|
+
children: _this2.props.children || '',
|
|
164
|
+
isRemoveable: _this2.props.hasCloseButton,
|
|
165
|
+
onRemove: function onRemove() {
|
|
166
|
+
return _this2.close();
|
|
167
|
+
}
|
|
168
|
+
})));
|
|
127
169
|
});
|
|
128
170
|
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
132
|
-
this.startCloseTimer();
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
136
|
-
this.clearCloseTimer();
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
_proto.render = function render() {
|
|
140
|
-
var _this2 = this;
|
|
141
|
-
|
|
142
|
-
return /*#__PURE__*/_react.default.createElement(_Transition.default, {
|
|
143
|
-
appear: true,
|
|
144
|
-
unmountOnExit: true,
|
|
145
|
-
timeout: ANIMATION_DURATION,
|
|
146
|
-
in: this.state.isShown,
|
|
147
|
-
onExited: this.props.onRemove
|
|
148
|
-
}, function (state) {
|
|
149
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
150
|
-
"data-state": state,
|
|
151
|
-
className: animationStyles,
|
|
152
|
-
onMouseEnter: _this2.handleMouseEnter,
|
|
153
|
-
onMouseLeave: _this2.handleMouseLeave,
|
|
154
|
-
style: {
|
|
155
|
-
height: _this2.state.height,
|
|
156
|
-
zIndex: _this2.props.zIndex,
|
|
157
|
-
marginBottom: _this2.state.isShown ? 0 : -_this2.state.height
|
|
158
|
-
}
|
|
159
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
160
|
-
ref: _this2.onRef,
|
|
161
|
-
style: {
|
|
162
|
-
padding: 8
|
|
163
|
-
}
|
|
164
|
-
}, /*#__PURE__*/_react.default.createElement(_alert.default, {
|
|
165
|
-
intent: _this2.props.intent,
|
|
166
|
-
title: _this2.props.title,
|
|
167
|
-
children: _this2.props.children || '',
|
|
168
|
-
isRemoveable: _this2.props.hasCloseButton,
|
|
169
|
-
onRemove: function onRemove() {
|
|
170
|
-
return _this2.close();
|
|
171
|
-
}
|
|
172
|
-
})));
|
|
173
|
-
});
|
|
174
|
-
};
|
|
171
|
+
}]);
|
|
175
172
|
|
|
176
173
|
return Toast;
|
|
177
|
-
}(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
(0, _defineProperty2.default)(Toast, "propTypes", {
|
|
181
|
-
/**
|
|
182
|
-
* The z-index of the toast.
|
|
183
|
-
*/
|
|
184
|
-
zIndex: _propTypes.default.number,
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Duration of the toast.
|
|
188
|
-
*/
|
|
189
|
-
duration: _propTypes.default.number,
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Function called when the toast is all the way closed.
|
|
193
|
-
*/
|
|
194
|
-
onRemove: _propTypes.default.func,
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* The type of the alert.
|
|
198
|
-
*/
|
|
199
|
-
intent: _propTypes.default.oneOf(['none', 'success', 'warning', 'danger']).isRequired,
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* The title of the alert.
|
|
203
|
-
*/
|
|
204
|
-
title: _propTypes.default.node,
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Description of the alert.
|
|
208
|
-
*/
|
|
209
|
-
children: _propTypes.default.node,
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* When true, show a close icon button inside of the toast.
|
|
213
|
-
*/
|
|
214
|
-
hasCloseButton: _propTypes.default.bool,
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* When false, will close the Toast and call onRemove when finished.
|
|
218
|
-
*/
|
|
219
|
-
isShown: _propTypes.default.bool
|
|
220
|
-
});
|
|
221
|
-
(0, _defineProperty2.default)(Toast, "defaultProps", {
|
|
174
|
+
}(React.PureComponent);
|
|
175
|
+
|
|
176
|
+
Toast.defaultProps = {
|
|
222
177
|
intent: 'none'
|
|
223
|
-
}
|
|
178
|
+
};
|
|
179
|
+
export { Toast as default };
|
|
@@ -1,41 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
-
|
|
12
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
13
|
-
|
|
14
|
-
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
15
|
-
|
|
16
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
|
|
18
|
-
var _react = _interopRequireDefault(require("react"));
|
|
19
|
-
|
|
20
|
-
var _glamor = require("glamor");
|
|
21
|
-
|
|
22
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
23
|
-
|
|
24
|
-
var _toast = _interopRequireDefault(require("./toast"));
|
|
25
|
-
|
|
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";
|
|
26
9
|
var _excluded = ["id", "description"];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
33
|
-
|
|
34
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
35
|
-
|
|
36
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
37
|
-
|
|
38
|
-
var wrapperClass = (0, _glamor.css)({
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { css } from 'glamor';
|
|
12
|
+
import Toast from './toast';
|
|
13
|
+
var wrapperClass = css({
|
|
39
14
|
maxWidth: 560,
|
|
40
15
|
margin: '0 auto',
|
|
41
16
|
top: 0,
|
|
@@ -50,30 +25,46 @@ var hasCustomId = function hasCustomId(settings) {
|
|
|
50
25
|
};
|
|
51
26
|
|
|
52
27
|
var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
|
|
53
|
-
(
|
|
28
|
+
_inherits(ToastManager, _React$PureComponent);
|
|
29
|
+
|
|
30
|
+
var _super = _createSuper(ToastManager);
|
|
54
31
|
|
|
55
32
|
function ToastManager(props, context) {
|
|
56
33
|
var _this;
|
|
57
34
|
|
|
58
|
-
|
|
59
|
-
|
|
35
|
+
_classCallCheck(this, ToastManager);
|
|
36
|
+
|
|
37
|
+
_this = _super.call(this, props, context);
|
|
38
|
+
|
|
39
|
+
_this.getToasts = function () {
|
|
60
40
|
return _this.state.toasts;
|
|
61
|
-
}
|
|
62
|
-
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
_this.closeAll = function () {
|
|
63
44
|
_this.getToasts().forEach(function (toast) {
|
|
64
45
|
return toast.close();
|
|
65
46
|
});
|
|
66
|
-
}
|
|
67
|
-
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
_this.notify = function (title, settings) {
|
|
68
50
|
// If there's a custom toast ID passed, close existing toasts with the same custom ID
|
|
69
51
|
if (hasCustomId(settings)) {
|
|
70
|
-
|
|
71
|
-
|
|
52
|
+
var _iterator = _createForOfIteratorHelper(_this.state.toasts),
|
|
53
|
+
_step;
|
|
72
54
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
try {
|
|
56
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
57
|
+
var toast = _step.value;
|
|
58
|
+
|
|
59
|
+
// Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
|
|
60
|
+
if (String(toast.id).startsWith(settings.id)) {
|
|
61
|
+
_this.closeToast(toast.id);
|
|
62
|
+
}
|
|
76
63
|
}
|
|
64
|
+
} catch (err) {
|
|
65
|
+
_iterator.e(err);
|
|
66
|
+
} finally {
|
|
67
|
+
_iterator.f();
|
|
77
68
|
}
|
|
78
69
|
}
|
|
79
70
|
|
|
@@ -81,15 +72,16 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
81
72
|
|
|
82
73
|
_this.setState(function (previousState) {
|
|
83
74
|
return {
|
|
84
|
-
toasts: [instance].concat(previousState.toasts)
|
|
75
|
+
toasts: [instance].concat(_toConsumableArray(previousState.toasts))
|
|
85
76
|
};
|
|
86
77
|
});
|
|
87
78
|
|
|
88
79
|
return instance;
|
|
89
|
-
}
|
|
90
|
-
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
_this.createToastInstance = function (title, settings) {
|
|
91
83
|
var uniqueId = ++ToastManager.idCounter;
|
|
92
|
-
var id = hasCustomId(settings) ? settings.id
|
|
84
|
+
var id = hasCustomId(settings) ? "".concat(settings.id, "-").concat(uniqueId) : uniqueId;
|
|
93
85
|
var hasCloseButton = settings.hasCloseButton || true;
|
|
94
86
|
var duration = settings.duration || 2;
|
|
95
87
|
|
|
@@ -112,8 +104,9 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
112
104
|
},
|
|
113
105
|
intent: settings.intent
|
|
114
106
|
};
|
|
115
|
-
}
|
|
116
|
-
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
_this.closeToast = function (id) {
|
|
117
110
|
_this.setState(function (previousState) {
|
|
118
111
|
return {
|
|
119
112
|
toasts: previousState.toasts.map(function (toast) {
|
|
@@ -127,8 +120,9 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
127
120
|
})
|
|
128
121
|
};
|
|
129
122
|
});
|
|
130
|
-
}
|
|
131
|
-
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
_this.removeToast = function (id) {
|
|
132
126
|
_this.setState(function (previousState) {
|
|
133
127
|
return {
|
|
134
128
|
toasts: previousState.toasts.filter(function (toast) {
|
|
@@ -136,7 +130,8 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
136
130
|
})
|
|
137
131
|
};
|
|
138
132
|
});
|
|
139
|
-
}
|
|
133
|
+
};
|
|
134
|
+
|
|
140
135
|
props.bindNotify(_this.notify);
|
|
141
136
|
props.bindGetToasts(_this.getToasts);
|
|
142
137
|
props.bindCloseAll(_this.closeAll);
|
|
@@ -146,44 +141,30 @@ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
146
141
|
return _this;
|
|
147
142
|
}
|
|
148
143
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
144
|
+
_createClass(ToastManager, [{
|
|
145
|
+
key: "render",
|
|
146
|
+
value: function render() {
|
|
147
|
+
var _this2 = this;
|
|
148
|
+
|
|
149
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
150
|
+
className: wrapperClass
|
|
151
|
+
}, this.state.toasts.map(function (_ref) {
|
|
152
|
+
var id = _ref.id,
|
|
153
|
+
description = _ref.description,
|
|
154
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
155
|
+
|
|
156
|
+
return /*#__PURE__*/React.createElement(Toast, Object.assign({
|
|
157
|
+
key: id,
|
|
158
|
+
onRemove: function onRemove() {
|
|
159
|
+
return _this2.removeToast(id);
|
|
160
|
+
}
|
|
161
|
+
}, props), description);
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
}]);
|
|
168
165
|
|
|
169
166
|
return ToastManager;
|
|
170
|
-
}(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Function called with the `this.notify` function.
|
|
176
|
-
*/
|
|
177
|
-
bindNotify: _propTypes.default.func.isRequired,
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Function called with the `this.getToasts` function.
|
|
181
|
-
*/
|
|
182
|
-
bindGetToasts: _propTypes.default.func.isRequired,
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Function called with the `this.closeAll` function.
|
|
186
|
-
*/
|
|
187
|
-
bindCloseAll: _propTypes.default.func.isRequired
|
|
188
|
-
});
|
|
189
|
-
(0, _defineProperty2.default)(ToastManager, "idCounter", 0);
|
|
167
|
+
}(React.PureComponent);
|
|
168
|
+
|
|
169
|
+
ToastManager.idCounter = 0;
|
|
170
|
+
export { ToastManager as default };
|