dtable-ui-component 4.3.9-alpha1 → 4.3.9
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/toaster/alert.js +107 -28
- package/lib/toaster/toast.js +40 -2
- package/lib/toaster/toastManager.js +12 -2
- package/lib/toaster/toaster.js +0 -1
- package/package.json +3 -2
- package/lib/toaster/index.css +0 -116
package/lib/toaster/alert.js
CHANGED
|
@@ -1,43 +1,122 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { css } from 'glamor';
|
|
2
3
|
class Alert extends React.PureComponent {
|
|
3
|
-
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.containerStyle = css({
|
|
7
|
+
borderRadius: '3px',
|
|
8
|
+
backgroundColor: '#fff',
|
|
9
|
+
padding: '10px 16px',
|
|
10
|
+
display: 'flex',
|
|
11
|
+
boxSizing: 'border-box',
|
|
12
|
+
boxShadow: 'rgba(67, 90, 111, 0.3) 0px 0px 1px, rgba(67, 90, 111, 0.47) 0px 8px 10px -4px',
|
|
13
|
+
justifyContent: 'space-between',
|
|
14
|
+
flexDirection: 'row'
|
|
15
|
+
});
|
|
16
|
+
this.containerBorderSuccess = css({
|
|
17
|
+
borderLeft: '3px solid rgb(71, 184, 129)'
|
|
18
|
+
});
|
|
19
|
+
this.containerBorderWarn = css({
|
|
20
|
+
borderLeft: '3px solid rgb(217, 130, 43)'
|
|
21
|
+
});
|
|
22
|
+
this.containerBorderDanger = css({
|
|
23
|
+
borderLeft: '3px solid rgb(236, 76, 71)'
|
|
24
|
+
});
|
|
25
|
+
this.containerBorderNotify = css({
|
|
26
|
+
borderLeft: '3px solid rgb(16, 112, 202)'
|
|
27
|
+
});
|
|
28
|
+
this.toastTextTitle = css({
|
|
29
|
+
fontWeight: '600',
|
|
30
|
+
fontSize: '14px',
|
|
31
|
+
color: '#435a6f',
|
|
32
|
+
margin: '0'
|
|
33
|
+
});
|
|
34
|
+
this.toastTextChild = css({
|
|
35
|
+
fontSize: '14px',
|
|
36
|
+
color: '#999',
|
|
37
|
+
margin: '0'
|
|
38
|
+
});
|
|
39
|
+
this.toastClose = css({
|
|
40
|
+
marginLeft: '15px',
|
|
41
|
+
height: '24px',
|
|
42
|
+
width: '24px',
|
|
43
|
+
lineHeight: '22px',
|
|
44
|
+
fontWeight: '700',
|
|
45
|
+
textAlign: 'center',
|
|
46
|
+
fontSize: '20px',
|
|
47
|
+
color: '#000',
|
|
48
|
+
cursor: 'pointer',
|
|
49
|
+
opacity: '0.5',
|
|
50
|
+
':hover': {
|
|
51
|
+
opacity: 1
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
this.toastIcon = css({
|
|
55
|
+
marginRight: '10px',
|
|
56
|
+
width: '14px',
|
|
57
|
+
height: '20px',
|
|
58
|
+
lineHeight: '20px'
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
getContainerStyle(intent) {
|
|
4
62
|
switch (intent) {
|
|
5
63
|
case 'success':
|
|
6
|
-
return
|
|
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
|
+
};
|
|
7
71
|
case 'warning':
|
|
8
|
-
return
|
|
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
|
+
};
|
|
9
79
|
case 'none':
|
|
10
|
-
return
|
|
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
|
+
};
|
|
11
87
|
case 'danger':
|
|
12
|
-
return
|
|
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
|
+
};
|
|
13
95
|
default:
|
|
14
|
-
return
|
|
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
|
+
};
|
|
15
103
|
}
|
|
16
104
|
}
|
|
17
105
|
render() {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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"
|
|
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
|
|
34
113
|
}, /*#__PURE__*/React.createElement("p", {
|
|
35
|
-
className:
|
|
36
|
-
}, title), children ? /*#__PURE__*/React.createElement("p", {
|
|
37
|
-
className:
|
|
38
|
-
}, children) : null),
|
|
39
|
-
onClick: onRemove,
|
|
40
|
-
className:
|
|
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
|
|
41
120
|
}, /*#__PURE__*/React.createElement("span", null, "\xD7")));
|
|
42
121
|
}
|
|
43
122
|
}
|
package/lib/toaster/toast.js
CHANGED
|
@@ -1,7 +1,45 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { css } from 'glamor';
|
|
2
3
|
import Transition from 'react-transition-group/Transition';
|
|
3
4
|
import Alert from './alert';
|
|
5
|
+
const animationEasing = {
|
|
6
|
+
deceleration: 'cubic-bezier(0.0, 0.0, 0.2, 1)',
|
|
7
|
+
acceleration: 'cubic-bezier(0.4, 0.0, 1, 1)',
|
|
8
|
+
spring: 'cubic-bezier(0.175, 0.885, 0.320, 1.175)'
|
|
9
|
+
};
|
|
4
10
|
const ANIMATION_DURATION = 240;
|
|
11
|
+
const openAnimation = css.keyframes('openAnimation', {
|
|
12
|
+
from: {
|
|
13
|
+
opacity: 0,
|
|
14
|
+
transform: 'translateY(-120%)'
|
|
15
|
+
},
|
|
16
|
+
to: {
|
|
17
|
+
transform: 'translateY(0)'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const closeAnimation = css.keyframes('closeAnimation', {
|
|
21
|
+
from: {
|
|
22
|
+
transform: 'scale(1)',
|
|
23
|
+
opacity: 1
|
|
24
|
+
},
|
|
25
|
+
to: {
|
|
26
|
+
transform: 'scale(0.9)',
|
|
27
|
+
opacity: 0
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const animationStyles = css({
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'column',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
height: 0,
|
|
35
|
+
transition: "all ".concat(ANIMATION_DURATION, "ms ").concat(animationEasing.deceleration),
|
|
36
|
+
'&[data-state="entering"], &[data-state="entered"]': {
|
|
37
|
+
animation: "".concat(openAnimation, " ").concat(ANIMATION_DURATION, "ms ").concat(animationEasing.spring, " both")
|
|
38
|
+
},
|
|
39
|
+
'&[data-state="exiting"]': {
|
|
40
|
+
animation: "".concat(closeAnimation, " 120ms ").concat(animationEasing.acceleration, " both")
|
|
41
|
+
}
|
|
42
|
+
});
|
|
5
43
|
export default class Toast extends React.PureComponent {
|
|
6
44
|
constructor() {
|
|
7
45
|
super(...arguments);
|
|
@@ -71,7 +109,7 @@ export default class Toast extends React.PureComponent {
|
|
|
71
109
|
onExited: this.props.onRemove
|
|
72
110
|
}, state => /*#__PURE__*/React.createElement("div", {
|
|
73
111
|
"data-state": state,
|
|
74
|
-
className:
|
|
112
|
+
className: animationStyles,
|
|
75
113
|
onMouseEnter: this.handleMouseEnter,
|
|
76
114
|
onMouseLeave: this.handleMouseLeave,
|
|
77
115
|
style: {
|
|
@@ -88,7 +126,7 @@ export default class Toast extends React.PureComponent {
|
|
|
88
126
|
intent: this.props.intent,
|
|
89
127
|
title: this.props.title,
|
|
90
128
|
children: this.props.children || '',
|
|
91
|
-
|
|
129
|
+
isRemoveable: this.props.hasCloseButton,
|
|
92
130
|
onRemove: event => this.close(event)
|
|
93
131
|
}))));
|
|
94
132
|
}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { css } from 'glamor';
|
|
2
3
|
import Toast from './toast';
|
|
4
|
+
const wrapperClass = css({
|
|
5
|
+
maxWidth: 560,
|
|
6
|
+
margin: '0 auto',
|
|
7
|
+
top: 0,
|
|
8
|
+
left: 0,
|
|
9
|
+
right: 0,
|
|
10
|
+
position: 'fixed',
|
|
11
|
+
zIndex: 999999
|
|
12
|
+
});
|
|
3
13
|
const hasCustomId = settings => Object.hasOwnProperty.call(settings, 'id');
|
|
4
14
|
export default class ToastManager extends React.PureComponent {
|
|
5
15
|
constructor(props, context) {
|
|
@@ -83,8 +93,8 @@ export default class ToastManager extends React.PureComponent {
|
|
|
83
93
|
};
|
|
84
94
|
}
|
|
85
95
|
render() {
|
|
86
|
-
return /*#__PURE__*/React.createElement("
|
|
87
|
-
className:
|
|
96
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
97
|
+
className: wrapperClass
|
|
88
98
|
}, this.state.toasts.map(_ref => {
|
|
89
99
|
let {
|
|
90
100
|
id,
|
package/lib/toaster/toaster.js
CHANGED
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-ui-component",
|
|
3
|
-
"version": "4.3.9
|
|
3
|
+
"version": "4.3.9",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@seafile/react-image-lightbox": "2.0.5",
|
|
7
7
|
"@seafile/seafile-calendar": "0.0.24",
|
|
8
|
-
"@seafile/seafile-editor": "0.3.
|
|
8
|
+
"@seafile/seafile-editor": "0.3.145",
|
|
9
9
|
"antd-mobile": "2.3.1",
|
|
10
10
|
"bail": "1.0.5",
|
|
11
11
|
"classnames": "^2.3.2",
|
|
12
12
|
"dayjs": "1.10.7",
|
|
13
13
|
"deepmerge": "^2.1.0",
|
|
14
14
|
"dtable-utils": "~4.3.5",
|
|
15
|
+
"glamor": "^2.20.40",
|
|
15
16
|
"hast-util-sanitize": "^1.1.2",
|
|
16
17
|
"hast-util-to-html": "3.1.0",
|
|
17
18
|
"is-hotkey": "0.2.0",
|
package/lib/toaster/index.css
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
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
|
-
}
|