dtable-statistic 4.3.12 → 4.3.14
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/es/components/index.js +1 -8
- package/es/stat-list/index.js +3 -2
- package/package.json +3 -4
- package/es/components/toast/alert.js +0 -124
- package/es/components/toast/index.js +0 -10
- package/es/components/toast/toast.js +0 -145
- package/es/components/toast/toastManager.js +0 -123
- package/es/components/toast/toaster.js +0 -74
package/es/components/index.js
CHANGED
|
@@ -46,17 +46,10 @@ Object.defineProperty(exports, "SeaTableRadio", {
|
|
|
46
46
|
return _seatableRadio.default;
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
-
Object.defineProperty(exports, "toaster", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function () {
|
|
52
|
-
return _toast.default;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
49
|
var _commonAddTool = _interopRequireDefault(require("./common-add-tool"));
|
|
56
50
|
var _dtablePopover = _interopRequireDefault(require("./dtable-popover"));
|
|
57
51
|
var _dtableSearchInput = _interopRequireDefault(require("./dtable-search-input"));
|
|
58
52
|
var _loading = _interopRequireDefault(require("./loading"));
|
|
59
53
|
var _modalPortal = _interopRequireDefault(require("./modal-portal"));
|
|
60
54
|
var _newTableDialog = _interopRequireDefault(require("./dialog/new-table-dialog"));
|
|
61
|
-
var _seatableRadio = _interopRequireDefault(require("./seatable-radio"));
|
|
62
|
-
var _toast = _interopRequireDefault(require("./toast"));
|
|
55
|
+
var _seatableRadio = _interopRequireDefault(require("./seatable-radio"));
|
package/es/stat-list/index.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.default = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _reactGridLayout = _interopRequireWildcard(require("react-grid-layout"));
|
|
11
11
|
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
12
|
+
var _toaster = _interopRequireDefault(require("dtable-ui-component/lib/toaster"));
|
|
12
13
|
var _chartPreview = _interopRequireDefault(require("./chart-preview"));
|
|
13
14
|
var _components = require("../components");
|
|
14
15
|
var _enlargedChartDialog = _interopRequireDefault(require("../components/dialog/enlarged-chart-dialog"));
|
|
@@ -60,7 +61,7 @@ class StatList extends _react.Component {
|
|
|
60
61
|
this.exportChart2Table = (tableName, chart) => {
|
|
61
62
|
if (chart.type !== _constants.STAT_TYPE.PIVOT_TABLE) {
|
|
62
63
|
this.statisticalResult4Export = null;
|
|
63
|
-
|
|
64
|
+
_toaster.default.danger(_reactIntlUniversal.default.get('Failed_export_statistic_to_Table'));
|
|
64
65
|
this.closeNewTableDialog();
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
@@ -101,7 +102,7 @@ class StatList extends _react.Component {
|
|
|
101
102
|
} = this.props;
|
|
102
103
|
if (chartUpdate2Table.type !== _constants.STAT_TYPE.PIVOT_TABLE) {
|
|
103
104
|
this.statisticalResult4Update = null;
|
|
104
|
-
|
|
105
|
+
_toaster.default.danger(_reactIntlUniversal.default.get('Failed_export_statistic_to_Table'));
|
|
105
106
|
this.closeSelectTableDialog();
|
|
106
107
|
return;
|
|
107
108
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-statistic",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.14",
|
|
4
4
|
"description": "statistics",
|
|
5
5
|
"main": "dist/dtable-statistic.js",
|
|
6
6
|
"author": "seafile",
|
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
"@antv/g2": "4.1.46",
|
|
11
11
|
"@antv/util": "3.3.2",
|
|
12
12
|
"@seafile/seafile-calendar": "0.0.24",
|
|
13
|
-
"comlink": "^4.
|
|
13
|
+
"comlink": "^4.4.1",
|
|
14
14
|
"dayjs": "1.10.7",
|
|
15
|
-
"glamor": "^2.20.40",
|
|
16
15
|
"html2canvas": "^1.4.1",
|
|
17
16
|
"rc-slider": "^9.7.4",
|
|
18
17
|
"react": "17.0.2",
|
|
@@ -57,7 +56,7 @@
|
|
|
57
56
|
"css-minimizer-webpack-plugin": "^3.2.0",
|
|
58
57
|
"dotenv": "^10.0.0",
|
|
59
58
|
"dotenv-expand": "^5.1.0",
|
|
60
|
-
"dtable-ui-component": "4.3.
|
|
59
|
+
"dtable-ui-component": "4.3.10",
|
|
61
60
|
"dtable-utils": "4.3.5",
|
|
62
61
|
"dtable-web-api": "4.3.5",
|
|
63
62
|
"dtable-store": "4.3.6",
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _glamor = require("glamor");
|
|
10
|
-
class Alert extends _react.default.PureComponent {
|
|
11
|
-
constructor(props) {
|
|
12
|
-
super(props);
|
|
13
|
-
this.containerStyle = (0, _glamor.css)({
|
|
14
|
-
borderRadius: '3px',
|
|
15
|
-
backgroundColor: '#fff',
|
|
16
|
-
padding: '10px 16px',
|
|
17
|
-
display: 'flex',
|
|
18
|
-
boxSizing: 'border-box',
|
|
19
|
-
boxShadow: 'rgba(67, 90, 111, 0.3) 0px 0px 1px, rgba(67, 90, 111, 0.47) 0px 8px 10px -4px',
|
|
20
|
-
justifyContent: 'space-between',
|
|
21
|
-
flexDirection: 'row'
|
|
22
|
-
});
|
|
23
|
-
this.containerBorderSuccess = (0, _glamor.css)({
|
|
24
|
-
borderLeft: '3px solid rgb(71, 184, 129)'
|
|
25
|
-
});
|
|
26
|
-
this.containerBorderWarn = (0, _glamor.css)({
|
|
27
|
-
borderLeft: '3px solid rgb(217, 130, 43)'
|
|
28
|
-
});
|
|
29
|
-
this.containerBorderDanger = (0, _glamor.css)({
|
|
30
|
-
borderLeft: '3px solid rgb(236, 76, 71)'
|
|
31
|
-
});
|
|
32
|
-
this.containerBorderNotify = (0, _glamor.css)({
|
|
33
|
-
borderLeft: '3px solid rgb(16, 112, 202)'
|
|
34
|
-
});
|
|
35
|
-
this.toastTextTitle = (0, _glamor.css)({
|
|
36
|
-
fontWeight: '600',
|
|
37
|
-
fontSize: '14px',
|
|
38
|
-
color: '#435a6f',
|
|
39
|
-
margin: '0'
|
|
40
|
-
});
|
|
41
|
-
this.toastTextChild = (0, _glamor.css)({
|
|
42
|
-
fontSize: '14px',
|
|
43
|
-
color: '#999',
|
|
44
|
-
margin: '0'
|
|
45
|
-
});
|
|
46
|
-
this.toastClose = (0, _glamor.css)({
|
|
47
|
-
marginLeft: '15px',
|
|
48
|
-
height: '24px',
|
|
49
|
-
width: '24px',
|
|
50
|
-
lineHeight: '22px',
|
|
51
|
-
fontWeight: '700',
|
|
52
|
-
textAlign: 'center',
|
|
53
|
-
fontSize: '20px',
|
|
54
|
-
color: '#000',
|
|
55
|
-
cursor: 'pointer',
|
|
56
|
-
opacity: '0.5',
|
|
57
|
-
':hover': {
|
|
58
|
-
opacity: 1
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
this.toastIcon = (0, _glamor.css)({
|
|
62
|
-
marginRight: '10px',
|
|
63
|
-
width: '14px',
|
|
64
|
-
height: '20px',
|
|
65
|
-
lineHeight: '20px'
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
getContainerStyle(intent) {
|
|
69
|
-
switch (intent) {
|
|
70
|
-
case 'success':
|
|
71
|
-
return {
|
|
72
|
-
borderStyle: this.containerBorderSuccess,
|
|
73
|
-
iconColor: (0, _glamor.css)({
|
|
74
|
-
color: 'rgb(71, 184, 129)'
|
|
75
|
-
}),
|
|
76
|
-
iconClass: 'dtable-font dtable-icon-check-circle'
|
|
77
|
-
};
|
|
78
|
-
case 'warning':
|
|
79
|
-
return {
|
|
80
|
-
borderStyle: this.containerBorderWarn,
|
|
81
|
-
iconColor: (0, _glamor.css)({
|
|
82
|
-
color: 'rgb(217, 130, 43)'
|
|
83
|
-
}),
|
|
84
|
-
iconClass: 'dtable-font dtable-icon-exclamation-triangle'
|
|
85
|
-
};
|
|
86
|
-
case 'none':
|
|
87
|
-
return {
|
|
88
|
-
borderStyle: this.containerBorderNotify,
|
|
89
|
-
iconColor: (0, _glamor.css)({
|
|
90
|
-
color: 'rgb(16, 112, 202)'
|
|
91
|
-
}),
|
|
92
|
-
iconClass: 'dtable-font dtable-icon-description'
|
|
93
|
-
};
|
|
94
|
-
case 'danger':
|
|
95
|
-
return {
|
|
96
|
-
borderStyle: this.containerBorderDanger,
|
|
97
|
-
iconColor: (0, _glamor.css)({
|
|
98
|
-
color: 'rgb(236, 76, 71)'
|
|
99
|
-
}),
|
|
100
|
-
iconClass: 'dtable-font dtable-icon-exclamation-circle'
|
|
101
|
-
};
|
|
102
|
-
default:
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
render() {
|
|
107
|
-
const toastStyle = this.getContainerStyle(this.props.intent);
|
|
108
|
-
return /*#__PURE__*/_react.default.createElement("div", (0, _glamor.css)(toastStyle.borderStyle, this.containerStyle), /*#__PURE__*/_react.default.createElement("div", {
|
|
109
|
-
className: this.toastIcon
|
|
110
|
-
}, /*#__PURE__*/_react.default.createElement("i", Object.assign({
|
|
111
|
-
className: toastStyle.iconClass
|
|
112
|
-
}, toastStyle.iconColor))), /*#__PURE__*/_react.default.createElement("div", {
|
|
113
|
-
className: this.toastTextContainer
|
|
114
|
-
}, /*#__PURE__*/_react.default.createElement("p", {
|
|
115
|
-
className: this.toastTextTitle
|
|
116
|
-
}, this.props.title), this.props.children ? /*#__PURE__*/_react.default.createElement("p", {
|
|
117
|
-
className: this.toastTextChild
|
|
118
|
-
}, this.props.children) : null), this.props.isRemoveable && /*#__PURE__*/_react.default.createElement("div", {
|
|
119
|
-
onClick: this.props.onRemove,
|
|
120
|
-
className: this.toastClose
|
|
121
|
-
}, /*#__PURE__*/_react.default.createElement("span", null, "\xD7")));
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
var _default = exports.default = Alert;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _toaster = _interopRequireDefault(require("./toaster"));
|
|
9
|
-
const toaster = new _toaster.default();
|
|
10
|
-
var _default = exports.default = toaster;
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _glamor = require("glamor");
|
|
10
|
-
var _Transition = _interopRequireDefault(require("react-transition-group/Transition"));
|
|
11
|
-
var _alert = _interopRequireDefault(require("./alert"));
|
|
12
|
-
const animationEasing = {
|
|
13
|
-
deceleration: 'cubic-bezier(0.0, 0.0, 0.2, 1)',
|
|
14
|
-
acceleration: 'cubic-bezier(0.4, 0.0, 1, 1)',
|
|
15
|
-
spring: 'cubic-bezier(0.175, 0.885, 0.320, 1.175)'
|
|
16
|
-
};
|
|
17
|
-
const ANIMATION_DURATION = 240;
|
|
18
|
-
const openAnimation = _glamor.css.keyframes('openAnimation', {
|
|
19
|
-
from: {
|
|
20
|
-
opacity: 0,
|
|
21
|
-
transform: 'translateY(-120%)'
|
|
22
|
-
},
|
|
23
|
-
to: {
|
|
24
|
-
transform: 'translateY(0)'
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
const closeAnimation = _glamor.css.keyframes('closeAnimation', {
|
|
28
|
-
from: {
|
|
29
|
-
transform: 'scale(1)',
|
|
30
|
-
opacity: 1
|
|
31
|
-
},
|
|
32
|
-
to: {
|
|
33
|
-
transform: 'scale(0.9)',
|
|
34
|
-
opacity: 0
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const animationStyles = (0, _glamor.css)({
|
|
38
|
-
display: 'flex',
|
|
39
|
-
flexDirection: 'column',
|
|
40
|
-
alignItems: 'center',
|
|
41
|
-
height: 0,
|
|
42
|
-
transition: "all ".concat(ANIMATION_DURATION, "ms ").concat(animationEasing.deceleration),
|
|
43
|
-
'&[data-state="entering"], &[data-state="entered"]': {
|
|
44
|
-
animation: "".concat(openAnimation, " ").concat(ANIMATION_DURATION, "ms ").concat(animationEasing.spring, " both")
|
|
45
|
-
},
|
|
46
|
-
'&[data-state="exiting"]': {
|
|
47
|
-
animation: "".concat(closeAnimation, " 120ms ").concat(animationEasing.acceleration, " both")
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
class Toast extends _react.default.PureComponent {
|
|
51
|
-
constructor() {
|
|
52
|
-
super(...arguments);
|
|
53
|
-
this.state = {
|
|
54
|
-
isShown: true,
|
|
55
|
-
height: 0
|
|
56
|
-
};
|
|
57
|
-
this.close = event => {
|
|
58
|
-
if (event) {
|
|
59
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
60
|
-
event.stopPropagation();
|
|
61
|
-
}
|
|
62
|
-
this.clearCloseTimer();
|
|
63
|
-
this.setState({
|
|
64
|
-
isShown: false
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
this.startCloseTimer = () => {
|
|
68
|
-
if (this.props.duration) {
|
|
69
|
-
this.closeTimer = setTimeout(() => {
|
|
70
|
-
this.close();
|
|
71
|
-
}, this.props.duration * 1000);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
this.clearCloseTimer = () => {
|
|
75
|
-
if (this.closeTimer) {
|
|
76
|
-
clearTimeout(this.closeTimer);
|
|
77
|
-
this.closeTimer = null;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
this.handleMouseEnter = () => {
|
|
81
|
-
this.clearCloseTimer();
|
|
82
|
-
};
|
|
83
|
-
this.handleMouseLeave = () => {
|
|
84
|
-
this.startCloseTimer();
|
|
85
|
-
};
|
|
86
|
-
this.onRef = ref => {
|
|
87
|
-
if (ref === null) return;
|
|
88
|
-
const {
|
|
89
|
-
height
|
|
90
|
-
} = ref.getBoundingClientRect();
|
|
91
|
-
this.setState({
|
|
92
|
-
height
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
componentDidUpdate(prevProps) {
|
|
97
|
-
if (prevProps.isShown !== this.props.isShown) {
|
|
98
|
-
// eslint-disable-next-line react/no-did-update-set-state
|
|
99
|
-
this.setState({
|
|
100
|
-
isShown: this.props.isShown
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
componentDidMount() {
|
|
105
|
-
this.startCloseTimer();
|
|
106
|
-
}
|
|
107
|
-
componentWillUnmount() {
|
|
108
|
-
this.clearCloseTimer();
|
|
109
|
-
}
|
|
110
|
-
render() {
|
|
111
|
-
return /*#__PURE__*/_react.default.createElement(_Transition.default, {
|
|
112
|
-
appear: true,
|
|
113
|
-
unmountOnExit: true,
|
|
114
|
-
timeout: ANIMATION_DURATION,
|
|
115
|
-
in: this.state.isShown,
|
|
116
|
-
onExited: this.props.onRemove
|
|
117
|
-
}, state => /*#__PURE__*/_react.default.createElement("div", {
|
|
118
|
-
"data-state": state,
|
|
119
|
-
className: animationStyles,
|
|
120
|
-
onMouseEnter: this.handleMouseEnter,
|
|
121
|
-
onMouseLeave: this.handleMouseLeave,
|
|
122
|
-
style: {
|
|
123
|
-
height: this.state.height,
|
|
124
|
-
zIndex: this.props.zIndex,
|
|
125
|
-
marginBottom: this.state.isShown ? 0 : -this.state.height
|
|
126
|
-
}
|
|
127
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
128
|
-
ref: this.onRef,
|
|
129
|
-
style: {
|
|
130
|
-
padding: 8
|
|
131
|
-
}
|
|
132
|
-
}, /*#__PURE__*/_react.default.createElement(_alert.default, {
|
|
133
|
-
intent: this.props.intent,
|
|
134
|
-
title: this.props.title,
|
|
135
|
-
"aria-label": this.props.title,
|
|
136
|
-
children: this.props.children || '',
|
|
137
|
-
isRemoveable: this.props.hasCloseButton,
|
|
138
|
-
onRemove: event => this.close(event)
|
|
139
|
-
}))));
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
exports.default = Toast;
|
|
143
|
-
Toast.defaultProps = {
|
|
144
|
-
intent: 'none'
|
|
145
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _glamor = require("glamor");
|
|
10
|
-
var _toast = _interopRequireDefault(require("./toast"));
|
|
11
|
-
var _zIndexes = require("../../constants/zIndexes");
|
|
12
|
-
const wrapperClass = (0, _glamor.css)({
|
|
13
|
-
maxWidth: 560,
|
|
14
|
-
margin: '0 auto',
|
|
15
|
-
top: 0,
|
|
16
|
-
left: 0,
|
|
17
|
-
right: 0,
|
|
18
|
-
position: 'fixed',
|
|
19
|
-
zIndex: _zIndexes.TOAST_MANAGER
|
|
20
|
-
});
|
|
21
|
-
const hasCustomId = settings => Object.hasOwnProperty.call(settings, 'id');
|
|
22
|
-
class ToastManager extends _react.default.PureComponent {
|
|
23
|
-
constructor(props, context) {
|
|
24
|
-
super(props, context);
|
|
25
|
-
this.getToasts = () => {
|
|
26
|
-
return this.state.toasts;
|
|
27
|
-
};
|
|
28
|
-
this.closeAll = () => {
|
|
29
|
-
this.getToasts().forEach(toast => toast.close());
|
|
30
|
-
};
|
|
31
|
-
this.notify = (title, settings) => {
|
|
32
|
-
// If there's a custom toast ID passed, close existing toasts with the same custom ID
|
|
33
|
-
if (hasCustomId(settings)) {
|
|
34
|
-
// eslint-disable-next-line
|
|
35
|
-
for (const toast of this.state.toasts) {
|
|
36
|
-
// Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
|
|
37
|
-
if (String(toast.id).startsWith(settings.id)) {
|
|
38
|
-
this.closeToast(toast.id);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const instance = this.createToastInstance(title, settings);
|
|
43
|
-
this.onClose = settings.onClose;
|
|
44
|
-
this.setState(previousState => {
|
|
45
|
-
return {
|
|
46
|
-
toasts: [instance, ...previousState.toasts]
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
return instance;
|
|
50
|
-
};
|
|
51
|
-
this.createToastInstance = (title, settings) => {
|
|
52
|
-
const uniqueId = ++ToastManager.idCounter;
|
|
53
|
-
const id = hasCustomId(settings) ? "".concat(settings.id, "-").concat(uniqueId) : uniqueId;
|
|
54
|
-
let hasCloseButton = settings.hasCloseButton || true;
|
|
55
|
-
let duration = settings.duration || 2;
|
|
56
|
-
if (settings.hasCloseButton !== undefined) {
|
|
57
|
-
hasCloseButton = settings.hasCloseButton;
|
|
58
|
-
}
|
|
59
|
-
if (settings.duration !== undefined) {
|
|
60
|
-
duration = settings.duration;
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
id,
|
|
64
|
-
title,
|
|
65
|
-
description: settings.description,
|
|
66
|
-
hasCloseButton: hasCloseButton,
|
|
67
|
-
duration: duration,
|
|
68
|
-
close: () => this.closeToast(id),
|
|
69
|
-
intent: settings.intent
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* This will set isShown on the Toast which will close the toast.
|
|
74
|
-
* It won't remove the toast until onExited triggers onRemove.
|
|
75
|
-
*/
|
|
76
|
-
this.closeToast = id => {
|
|
77
|
-
this.setState(previousState => {
|
|
78
|
-
return {
|
|
79
|
-
toasts: previousState.toasts.map(toast => {
|
|
80
|
-
if (toast.id === id) {
|
|
81
|
-
return {
|
|
82
|
-
...toast,
|
|
83
|
-
isShown: false
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return toast;
|
|
87
|
-
})
|
|
88
|
-
};
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
this.removeToast = id => {
|
|
92
|
-
this.onClose && this.onClose();
|
|
93
|
-
this.setState(previousState => {
|
|
94
|
-
return {
|
|
95
|
-
toasts: previousState.toasts.filter(toast => toast.id !== id)
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
props.bindNotify(this.notify);
|
|
100
|
-
props.bindGetToasts(this.getToasts);
|
|
101
|
-
props.bindCloseAll(this.closeAll);
|
|
102
|
-
this.state = {
|
|
103
|
-
toasts: []
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
render() {
|
|
107
|
-
return /*#__PURE__*/_react.default.createElement("span", {
|
|
108
|
-
className: wrapperClass
|
|
109
|
-
}, this.state.toasts.map(_ref => {
|
|
110
|
-
let {
|
|
111
|
-
id,
|
|
112
|
-
description,
|
|
113
|
-
...props
|
|
114
|
-
} = _ref;
|
|
115
|
-
return /*#__PURE__*/_react.default.createElement(_toast.default, Object.assign({
|
|
116
|
-
key: id,
|
|
117
|
-
onRemove: () => this.removeToast(id)
|
|
118
|
-
}, props), description);
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.default = ToastManager;
|
|
123
|
-
ToastManager.idCounter = 0;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
10
|
-
var _toastManager = _interopRequireDefault(require("./toastManager"));
|
|
11
|
-
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The Toaster manages the interactionsb between
|
|
15
|
-
* the ToasterManger and the toast API.
|
|
16
|
-
*/
|
|
17
|
-
class Toaster {
|
|
18
|
-
constructor() {
|
|
19
|
-
var _this = this;
|
|
20
|
-
this._bindNotify = handler => {
|
|
21
|
-
this.notifyHandler = handler;
|
|
22
|
-
};
|
|
23
|
-
this._bindGetToasts = handler => {
|
|
24
|
-
this.getToastsHandler = handler;
|
|
25
|
-
};
|
|
26
|
-
this._bindCloseAll = handler => {
|
|
27
|
-
this.closeAllHandler = handler;
|
|
28
|
-
};
|
|
29
|
-
this.getToasts = () => {
|
|
30
|
-
return this.getToastsHandler();
|
|
31
|
-
};
|
|
32
|
-
this.closeAll = () => {
|
|
33
|
-
return this.closeAllHandler();
|
|
34
|
-
};
|
|
35
|
-
this.notify = function (title) {
|
|
36
|
-
let settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
37
|
-
return _this.notifyHandler(title, {
|
|
38
|
-
...settings,
|
|
39
|
-
intent: 'none'
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
this.success = function (title) {
|
|
43
|
-
let settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
44
|
-
return _this.notifyHandler(title, {
|
|
45
|
-
...settings,
|
|
46
|
-
intent: 'success'
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
this.warning = function (title) {
|
|
50
|
-
let settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
51
|
-
return _this.notifyHandler(title, {
|
|
52
|
-
...settings,
|
|
53
|
-
intent: 'warning'
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
this.danger = function (title) {
|
|
57
|
-
let settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
58
|
-
return _this.notifyHandler(title, {
|
|
59
|
-
...settings,
|
|
60
|
-
intent: 'danger'
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
if (!isBrowser) return;
|
|
64
|
-
const container = document.createElement('div');
|
|
65
|
-
container.setAttribute('data-evergreen-toaster-container', '');
|
|
66
|
-
document.body.appendChild(container);
|
|
67
|
-
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(_toastManager.default, {
|
|
68
|
-
bindNotify: this._bindNotify,
|
|
69
|
-
bindGetToasts: this._bindGetToasts,
|
|
70
|
-
bindCloseAll: this._bindCloseAll
|
|
71
|
-
}), container);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.default = Toaster;
|