@cloudflare/component-notifications 4.1.7 → 5.0.0
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/CHANGELOG.md +895 -2925
- package/es/Notification.js +93 -83
- package/es/NotificationGlobalContainer.js +24 -18
- package/es/NotificationList.js +10 -7
- package/lib/Notification.js +14 -8
- package/lib/index.js +4 -4
- package/package.json +8 -8
package/es/Notification.js
CHANGED
|
@@ -5,7 +5,7 @@ import raf from 'raf';
|
|
|
5
5
|
import { createComponent } from '@cloudflare/style-container';
|
|
6
6
|
import { Icon } from '@cloudflare/component-icon';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
var getBorderColor = (type, theme) => {
|
|
9
9
|
switch (type) {
|
|
10
10
|
case 'success':
|
|
11
11
|
return theme.colors.green[5];
|
|
@@ -22,7 +22,7 @@ const getBorderColor = (type, theme) => {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
var getBackgroundColor = (type, theme) => {
|
|
26
26
|
switch (type) {
|
|
27
27
|
case 'success':
|
|
28
28
|
return theme.colors.green[isDarkMode() ? 3 : 6];
|
|
@@ -39,99 +39,109 @@ const getBackgroundColor = (type, theme) => {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
width: '2.5em',
|
|
61
|
-
cursor: 'pointer',
|
|
62
|
-
'&:hover': {
|
|
63
|
-
backgroundColor: getBorderColor(type, theme)
|
|
64
|
-
},
|
|
65
|
-
'&::before': {
|
|
42
|
+
var NotificationMessage = createComponent(_ref => {
|
|
43
|
+
var {
|
|
44
|
+
theme
|
|
45
|
+
} = _ref;
|
|
46
|
+
return {
|
|
47
|
+
position: 'relative',
|
|
48
|
+
zIndex: 2,
|
|
49
|
+
color: theme.colors.white,
|
|
50
|
+
display: 'flex',
|
|
51
|
+
alignItems: 'center'
|
|
52
|
+
};
|
|
53
|
+
}, 'span');
|
|
54
|
+
var NotificationClose = createComponent(_ref2 => {
|
|
55
|
+
var {
|
|
56
|
+
theme,
|
|
57
|
+
type
|
|
58
|
+
} = _ref2;
|
|
59
|
+
return {
|
|
66
60
|
position: 'absolute',
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}) => ({
|
|
76
|
-
position: 'relative',
|
|
77
|
-
padding: theme.space[2],
|
|
78
|
-
verticalAlign: 'middle',
|
|
79
|
-
'-webkit-text-stroke': '0',
|
|
80
|
-
'-webkit-font-smoothing': 'antialiased',
|
|
81
|
-
cursor: 'pointer',
|
|
82
|
-
transformOrigin: 'bottom left',
|
|
83
|
-
borderTopColor: getBorderColor(type, theme),
|
|
84
|
-
borderBottomColor: getBorderColor(type, theme),
|
|
85
|
-
borderLeftColor: getBorderColor(type, theme),
|
|
86
|
-
borderRightColor: getBorderColor(type, theme),
|
|
87
|
-
borderTopWidth: 1,
|
|
88
|
-
borderRightWidth: 1,
|
|
89
|
-
borderBottomWidth: 0,
|
|
90
|
-
borderLeftWidth: 1,
|
|
91
|
-
borderStyle: 'solid',
|
|
92
|
-
backgroundColor: getBackgroundColor(type, theme),
|
|
93
|
-
animationName: {
|
|
94
|
-
'0%': {
|
|
95
|
-
transform: 'scaleY(0)'
|
|
61
|
+
zIndex: 3,
|
|
62
|
+
top: 0,
|
|
63
|
+
right: 0,
|
|
64
|
+
bottom: 0,
|
|
65
|
+
width: '2.5em',
|
|
66
|
+
cursor: 'pointer',
|
|
67
|
+
'&:hover': {
|
|
68
|
+
backgroundColor: getBorderColor(type, theme)
|
|
96
69
|
},
|
|
97
|
-
'
|
|
98
|
-
|
|
70
|
+
'&::before': {
|
|
71
|
+
position: 'absolute',
|
|
72
|
+
top: '50%',
|
|
73
|
+
left: '50%',
|
|
74
|
+
transform: 'translate(-50%, -50%)'
|
|
99
75
|
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
76
|
+
};
|
|
77
|
+
}, 'span');
|
|
78
|
+
var NotificationContainer = createComponent(_ref3 => {
|
|
79
|
+
var {
|
|
80
|
+
theme,
|
|
81
|
+
type
|
|
82
|
+
} = _ref3;
|
|
83
|
+
return {
|
|
84
|
+
position: 'relative',
|
|
85
|
+
padding: theme.space[2],
|
|
86
|
+
verticalAlign: 'middle',
|
|
87
|
+
'-webkit-text-stroke': '0',
|
|
88
|
+
'-webkit-font-smoothing': 'antialiased',
|
|
89
|
+
cursor: 'pointer',
|
|
90
|
+
transformOrigin: 'bottom left',
|
|
91
|
+
borderTopColor: getBorderColor(type, theme),
|
|
92
|
+
borderBottomColor: getBorderColor(type, theme),
|
|
93
|
+
borderLeftColor: getBorderColor(type, theme),
|
|
94
|
+
borderRightColor: getBorderColor(type, theme),
|
|
95
|
+
borderTopWidth: 1,
|
|
96
|
+
borderRightWidth: 1,
|
|
97
|
+
borderBottomWidth: 0,
|
|
98
|
+
borderLeftWidth: 1,
|
|
99
|
+
borderStyle: 'solid',
|
|
100
|
+
backgroundColor: getBackgroundColor(type, theme),
|
|
101
|
+
animationName: {
|
|
102
|
+
'0%': {
|
|
103
|
+
transform: 'scaleY(0)'
|
|
104
|
+
},
|
|
105
|
+
'100%': {
|
|
106
|
+
transform: 'scaleY(1)'
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
animationDuration: '200ms',
|
|
110
|
+
animationTimingFunction: 'ease-in-out',
|
|
111
|
+
'&::before': {
|
|
112
|
+
position: 'absolute',
|
|
113
|
+
top: '50%',
|
|
114
|
+
left: '0.75rem',
|
|
115
|
+
transform: 'translate(0, -50%)',
|
|
116
|
+
lineHeight: '1',
|
|
117
|
+
verticalAlign: 'middle'
|
|
118
|
+
},
|
|
119
|
+
'&:first-child': {
|
|
120
|
+
borderTopWidth: 1
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}, 'div');
|
|
124
|
+
var IconWrapper = createComponent(() => ({
|
|
116
125
|
paddingRight: 6,
|
|
117
126
|
display: 'flex'
|
|
118
127
|
}));
|
|
119
|
-
|
|
128
|
+
var NotificationWrapper = createComponent(() => ({
|
|
120
129
|
display: 'flex'
|
|
121
130
|
}));
|
|
122
|
-
|
|
131
|
+
var CloseWrapper = createComponent(() => ({
|
|
123
132
|
position: 'absolute',
|
|
124
133
|
top: '50%',
|
|
125
134
|
left: '50%',
|
|
126
135
|
transform: 'translate(-50%,-50%)'
|
|
127
136
|
}));
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
var NotificationItem = createComponent(() => ({}), _ref4 => {
|
|
138
|
+
var {
|
|
139
|
+
children,
|
|
140
|
+
closable,
|
|
141
|
+
handleClickClose,
|
|
142
|
+
type
|
|
143
|
+
} = _ref4;
|
|
144
|
+
var iconType;
|
|
135
145
|
|
|
136
146
|
switch (type) {
|
|
137
147
|
case 'success':
|
|
@@ -209,7 +219,7 @@ class Notification extends React.Component {
|
|
|
209
219
|
}
|
|
210
220
|
|
|
211
221
|
this.stopTimeout();
|
|
212
|
-
|
|
222
|
+
var timeoutId = setTimeout(() => this.props.onClose(), this.props.delay);
|
|
213
223
|
this.setState({
|
|
214
224
|
timeoutId
|
|
215
225
|
});
|
|
@@ -2,25 +2,31 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { createComponent } from '@cloudflare/style-container';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
var styles = _ref => {
|
|
6
|
+
var {
|
|
7
|
+
theme
|
|
8
|
+
} = _ref;
|
|
9
|
+
return {
|
|
10
|
+
position: 'fixed',
|
|
11
|
+
bottom: 0,
|
|
12
|
+
left: 0,
|
|
13
|
+
right: 0,
|
|
14
|
+
maxHeight: '25%',
|
|
15
|
+
overflow: 'auto',
|
|
16
|
+
zIndex: 1600,
|
|
17
|
+
fontSize: theme.fontSizes[3]
|
|
18
|
+
};
|
|
19
|
+
};
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
var NotificationGlobalContainer = _ref2 => {
|
|
22
|
+
var {
|
|
23
|
+
className,
|
|
24
|
+
children
|
|
25
|
+
} = _ref2;
|
|
26
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
className: className
|
|
28
|
+
}, children);
|
|
29
|
+
};
|
|
24
30
|
|
|
25
31
|
NotificationGlobalContainer.propTypes = {
|
|
26
32
|
children: PropTypes.node,
|
package/es/NotificationList.js
CHANGED
|
@@ -2,17 +2,20 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { createComponent } from '@cloudflare/style-container';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
var styles = () => ({
|
|
6
6
|
marginTop: 0,
|
|
7
7
|
marginBottom: 0
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
var NotificationList = _ref => {
|
|
11
|
+
var {
|
|
12
|
+
className,
|
|
13
|
+
children
|
|
14
|
+
} = _ref;
|
|
15
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
className: className
|
|
17
|
+
}, children);
|
|
18
|
+
};
|
|
16
19
|
|
|
17
20
|
NotificationList.propTypes = {
|
|
18
21
|
children: PropTypes.node,
|
package/lib/Notification.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -25,17 +25,21 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
25
25
|
|
|
26
26
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
27
27
|
|
|
28
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
28
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
29
29
|
|
|
30
|
-
function
|
|
30
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
33
|
+
|
|
34
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
35
|
|
|
34
|
-
function
|
|
36
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
35
37
|
|
|
36
|
-
function
|
|
38
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
39
|
|
|
38
|
-
function
|
|
40
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
|
+
|
|
42
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
43
|
|
|
40
44
|
var getBorderColor = function getBorderColor(type, theme) {
|
|
41
45
|
switch (type) {
|
|
@@ -223,12 +227,14 @@ NotificationItem.propTypes = {
|
|
|
223
227
|
var Notification = /*#__PURE__*/function (_React$Component) {
|
|
224
228
|
_inherits(Notification, _React$Component);
|
|
225
229
|
|
|
230
|
+
var _super = _createSuper(Notification);
|
|
231
|
+
|
|
226
232
|
function Notification(props) {
|
|
227
233
|
var _this;
|
|
228
234
|
|
|
229
235
|
_classCallCheck(this, Notification);
|
|
230
236
|
|
|
231
|
-
_this =
|
|
237
|
+
_this = _super.call(this, props);
|
|
232
238
|
_this.state = {
|
|
233
239
|
persist: _this.props.persist,
|
|
234
240
|
timeoutId: null
|
package/lib/index.js
CHANGED
|
@@ -9,16 +9,16 @@ Object.defineProperty(exports, "Notification", {
|
|
|
9
9
|
return _Notification.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "NotificationGlobalContainer", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function get() {
|
|
15
|
-
return
|
|
15
|
+
return _NotificationGlobalContainer.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "NotificationList", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function get() {
|
|
21
|
-
return
|
|
21
|
+
return _NotificationList.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
|
package/package.json
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/component-notifications",
|
|
3
3
|
"description": "Cloudflare Notifications Component",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"author": "James Kyle <jkyle@cloudflare.com>",
|
|
8
8
|
"license": "BSD-3-Clause",
|
|
9
9
|
"publishConfig": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"access": "public",
|
|
11
|
+
"main": "lib/index.js",
|
|
12
|
+
"module": "es/index.js"
|
|
12
13
|
},
|
|
13
14
|
"dependencies": {
|
|
14
|
-
"@cloudflare/component-icon": "^
|
|
15
|
+
"@cloudflare/component-icon": "^8.0.0",
|
|
15
16
|
"prop-types": "^15.6.0",
|
|
16
17
|
"raf": "^3.3.2"
|
|
17
18
|
},
|
|
18
19
|
"peerDependencies": {
|
|
19
20
|
"@cloudflare/style-const": "^5.3.9",
|
|
20
|
-
"@cloudflare/style-container": "^7.
|
|
21
|
+
"@cloudflare/style-container": "^7.9.0",
|
|
21
22
|
"react": "^15.0.0-0 || ^16.0.0-0 || ^17.0.0-0"
|
|
22
23
|
},
|
|
23
24
|
"stratus": {
|
|
@@ -30,6 +31,5 @@
|
|
|
30
31
|
"test": "stratus test",
|
|
31
32
|
"test-coverage": "stratus test --coverage --muteErrorsFixWeNeedToSolveThis",
|
|
32
33
|
"test-watch": "stratus test --watch"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
34
|
+
}
|
|
35
|
+
}
|