@zendeskgarden/react-notifications 8.57.1 → 8.58.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/dist/index.cjs.js +232 -442
- package/dist/index.esm.js +232 -442
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -14,256 +14,76 @@ import { TransitionGroup, CSSTransition } from 'react-transition-group';
|
|
|
14
14
|
import { uid } from 'react-uid';
|
|
15
15
|
import { hideVisually } from 'polished';
|
|
16
16
|
|
|
17
|
-
function ownKeys(object, enumerableOnly) {
|
|
18
|
-
var keys = Object.keys(object);
|
|
19
|
-
|
|
20
|
-
if (Object.getOwnPropertySymbols) {
|
|
21
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
22
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
23
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
24
|
-
})), keys.push.apply(keys, symbols);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return keys;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function _objectSpread2(target) {
|
|
31
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
32
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
33
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
34
|
-
_defineProperty(target, key, source[key]);
|
|
35
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
36
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return target;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function _defineProperty(obj, key, value) {
|
|
44
|
-
if (key in obj) {
|
|
45
|
-
Object.defineProperty(obj, key, {
|
|
46
|
-
value: value,
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true,
|
|
49
|
-
writable: true
|
|
50
|
-
});
|
|
51
|
-
} else {
|
|
52
|
-
obj[key] = value;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return obj;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
17
|
function _extends$5() {
|
|
59
18
|
_extends$5 = Object.assign ? Object.assign.bind() : function (target) {
|
|
60
19
|
for (var i = 1; i < arguments.length; i++) {
|
|
61
20
|
var source = arguments[i];
|
|
62
|
-
|
|
63
21
|
for (var key in source) {
|
|
64
22
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
65
23
|
target[key] = source[key];
|
|
66
24
|
}
|
|
67
25
|
}
|
|
68
26
|
}
|
|
69
|
-
|
|
70
27
|
return target;
|
|
71
28
|
};
|
|
72
29
|
return _extends$5.apply(this, arguments);
|
|
73
30
|
}
|
|
74
31
|
|
|
75
|
-
|
|
76
|
-
if (source == null) return {};
|
|
77
|
-
var target = {};
|
|
78
|
-
var sourceKeys = Object.keys(source);
|
|
79
|
-
var key, i;
|
|
80
|
-
|
|
81
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
82
|
-
key = sourceKeys[i];
|
|
83
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
84
|
-
target[key] = source[key];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return target;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function _objectWithoutProperties(source, excluded) {
|
|
91
|
-
if (source == null) return {};
|
|
92
|
-
|
|
93
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
94
|
-
|
|
95
|
-
var key, i;
|
|
96
|
-
|
|
97
|
-
if (Object.getOwnPropertySymbols) {
|
|
98
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
99
|
-
|
|
100
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
101
|
-
key = sourceSymbolKeys[i];
|
|
102
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
103
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
104
|
-
target[key] = source[key];
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return target;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function _slicedToArray(arr, i) {
|
|
112
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function _toConsumableArray(arr) {
|
|
116
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function _arrayWithoutHoles(arr) {
|
|
120
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function _arrayWithHoles(arr) {
|
|
124
|
-
if (Array.isArray(arr)) return arr;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function _iterableToArray(iter) {
|
|
128
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function _iterableToArrayLimit(arr, i) {
|
|
132
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
133
|
-
|
|
134
|
-
if (_i == null) return;
|
|
135
|
-
var _arr = [];
|
|
136
|
-
var _n = true;
|
|
137
|
-
var _d = false;
|
|
138
|
-
|
|
139
|
-
var _s, _e;
|
|
140
|
-
|
|
141
|
-
try {
|
|
142
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
143
|
-
_arr.push(_s.value);
|
|
144
|
-
|
|
145
|
-
if (i && _arr.length === i) break;
|
|
146
|
-
}
|
|
147
|
-
} catch (err) {
|
|
148
|
-
_d = true;
|
|
149
|
-
_e = err;
|
|
150
|
-
} finally {
|
|
151
|
-
try {
|
|
152
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
153
|
-
} finally {
|
|
154
|
-
if (_d) throw _e;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return _arr;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
162
|
-
if (!o) return;
|
|
163
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
164
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
165
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
166
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
167
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function _arrayLikeToArray(arr, len) {
|
|
171
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
172
|
-
|
|
173
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
174
|
-
|
|
175
|
-
return arr2;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function _nonIterableSpread() {
|
|
179
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function _nonIterableRest() {
|
|
183
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
184
|
-
}
|
|
32
|
+
const TYPE = ['success', 'warning', 'error', 'info'];
|
|
185
33
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
var COMPONENT_ID$5 = 'notifications.close';
|
|
189
|
-
var StyledClose = styled.button.attrs({
|
|
34
|
+
const COMPONENT_ID$5 = 'notifications.close';
|
|
35
|
+
const StyledClose = styled.button.attrs({
|
|
190
36
|
'data-garden-id': COMPONENT_ID$5,
|
|
191
|
-
'data-garden-version': '8.
|
|
37
|
+
'data-garden-version': '8.58.0'
|
|
192
38
|
}).withConfig({
|
|
193
39
|
displayName: "StyledClose",
|
|
194
40
|
componentId: "sc-1mr9nx1-0"
|
|
195
|
-
})(["display:block;position:absolute;top:", "px;", ":", ";transition:background-color 0.1s ease-in-out,color 0.25s ease-in-out;border:none;border-radius:50%;background-color:transparent;cursor:pointer;padding:0;width:", "px;height:", "px;overflow:hidden;color:", ";font-size:0;user-select:none;&:hover{color:", ";}&:focus{outline:none;}&[data-garden-focus-visible]{background-color:", ";color:", ";&::-moz-focus-inner{border:0;}}", ";"],
|
|
196
|
-
return props.theme.space.base;
|
|
197
|
-
}, function (props) {
|
|
198
|
-
return props.theme.rtl ? 'left' : 'right';
|
|
199
|
-
}, function (props) {
|
|
200
|
-
return "".concat(props.theme.space.base, "px");
|
|
201
|
-
}, function (props) {
|
|
202
|
-
return props.theme.space.base * 7;
|
|
203
|
-
}, function (props) {
|
|
204
|
-
return props.theme.space.base * 7;
|
|
205
|
-
}, function (props) {
|
|
206
|
-
return props.hue ? getColor(props.hue, props.hue === 'warningHue' ? 700 : 600, props.theme) : getColor('neutralHue', 600, props.theme);
|
|
207
|
-
}, function (props) {
|
|
208
|
-
return props.hue ? getColor(props.hue, 800, props.theme) : getColor('neutralHue', 800, props.theme);
|
|
209
|
-
}, function (props) {
|
|
210
|
-
return props.hue ? getColor(props.hue, props.hue === 'warningHue' ? 700 : 600, props.theme, 0.15) : getColor('neutralHue', 600, props.theme, 0.15);
|
|
211
|
-
}, function (props) {
|
|
212
|
-
return props.hue ? getColor(props.hue, 800, props.theme) : getColor('neutralHue', 800, props.theme);
|
|
213
|
-
}, function (props) {
|
|
214
|
-
return retrieveComponentStyles(COMPONENT_ID$5, props);
|
|
215
|
-
});
|
|
41
|
+
})(["display:block;position:absolute;top:", "px;", ":", ";transition:background-color 0.1s ease-in-out,color 0.25s ease-in-out;border:none;border-radius:50%;background-color:transparent;cursor:pointer;padding:0;width:", "px;height:", "px;overflow:hidden;color:", ";font-size:0;user-select:none;&:hover{color:", ";}&:focus{outline:none;}&[data-garden-focus-visible]{background-color:", ";color:", ";&::-moz-focus-inner{border:0;}}", ";"], props => props.theme.space.base, props => props.theme.rtl ? 'left' : 'right', props => `${props.theme.space.base}px`, props => props.theme.space.base * 7, props => props.theme.space.base * 7, props => props.hue ? getColor(props.hue, props.hue === 'warningHue' ? 700 : 600, props.theme) : getColor('neutralHue', 600, props.theme), props => props.hue ? getColor(props.hue, 800, props.theme) : getColor('neutralHue', 800, props.theme), props => props.hue ? getColor(props.hue, props.hue === 'warningHue' ? 700 : 600, props.theme, 0.15) : getColor('neutralHue', 600, props.theme, 0.15), props => props.hue ? getColor(props.hue, 800, props.theme) : getColor('neutralHue', 800, props.theme), props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
216
42
|
StyledClose.defaultProps = {
|
|
217
43
|
theme: DEFAULT_THEME
|
|
218
44
|
};
|
|
219
45
|
|
|
220
|
-
|
|
221
|
-
|
|
46
|
+
const COMPONENT_ID$4 = 'notifications.paragraph';
|
|
47
|
+
const StyledParagraph = styled.p.attrs({
|
|
222
48
|
'data-garden-id': COMPONENT_ID$4,
|
|
223
|
-
'data-garden-version': '8.
|
|
49
|
+
'data-garden-version': '8.58.0'
|
|
224
50
|
}).withConfig({
|
|
225
51
|
displayName: "StyledParagraph",
|
|
226
52
|
componentId: "sc-12tmd6p-0"
|
|
227
|
-
})(["margin:", "px 0 0;", ";"],
|
|
228
|
-
return props.theme.space.base * 2;
|
|
229
|
-
}, function (props) {
|
|
230
|
-
return retrieveComponentStyles(COMPONENT_ID$4, props);
|
|
231
|
-
});
|
|
53
|
+
})(["margin:", "px 0 0;", ";"], props => props.theme.space.base * 2, props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
232
54
|
StyledParagraph.defaultProps = {
|
|
233
55
|
theme: DEFAULT_THEME
|
|
234
56
|
};
|
|
235
57
|
|
|
236
|
-
|
|
237
|
-
|
|
58
|
+
const COMPONENT_ID$3 = 'notifications.title';
|
|
59
|
+
const StyledTitle = styled.div.attrs({
|
|
238
60
|
'data-garden-id': COMPONENT_ID$3,
|
|
239
|
-
'data-garden-version': '8.
|
|
61
|
+
'data-garden-version': '8.58.0'
|
|
240
62
|
}).withConfig({
|
|
241
63
|
displayName: "StyledTitle",
|
|
242
64
|
componentId: "sc-xx4jsv-0"
|
|
243
|
-
})(["margin:0;color:", ";font-weight:", ";", ";"],
|
|
244
|
-
return props.theme.colors.foreground;
|
|
245
|
-
}, function (props) {
|
|
246
|
-
return props.isRegular ? props.theme.fontWeights.regular : props.theme.fontWeights.semibold;
|
|
247
|
-
}, function (props) {
|
|
248
|
-
return retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
249
|
-
});
|
|
65
|
+
})(["margin:0;color:", ";font-weight:", ";", ";"], props => props.theme.colors.foreground, props => props.isRegular ? props.theme.fontWeights.regular : props.theme.fontWeights.semibold, props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
250
66
|
StyledTitle.defaultProps = {
|
|
251
67
|
theme: DEFAULT_THEME
|
|
252
68
|
};
|
|
253
69
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
70
|
+
const boxShadow = props => {
|
|
71
|
+
const {
|
|
72
|
+
theme
|
|
73
|
+
} = props;
|
|
74
|
+
const {
|
|
75
|
+
space,
|
|
76
|
+
shadows
|
|
77
|
+
} = theme;
|
|
78
|
+
const offsetY = `${space.base * 5}px`;
|
|
79
|
+
const blurRadius = `${space.base * 7}px`;
|
|
80
|
+
const color = getColor('chromeHue', 600, theme, 0.15);
|
|
261
81
|
return shadows.lg(offsetY, blurRadius, color);
|
|
262
82
|
};
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
83
|
+
const colorStyles$2 = props => {
|
|
84
|
+
let backgroundColor;
|
|
85
|
+
let borderColor;
|
|
86
|
+
let foregroundColor;
|
|
267
87
|
if (props.hue) {
|
|
268
88
|
backgroundColor = getColor(props.hue, 100, props.theme);
|
|
269
89
|
borderColor = getColor(props.hue, 300, props.theme);
|
|
@@ -275,62 +95,52 @@ var colorStyles$2 = function colorStyles(props) {
|
|
|
275
95
|
}
|
|
276
96
|
return css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, foregroundColor);
|
|
277
97
|
};
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
98
|
+
const padding = props => {
|
|
99
|
+
const {
|
|
100
|
+
space
|
|
101
|
+
} = props.theme;
|
|
102
|
+
const paddingVertical = `${space.base * 5}px`;
|
|
103
|
+
const paddingHorizontal = `${space.base * 10}px`;
|
|
104
|
+
return `${paddingVertical} ${paddingHorizontal}`;
|
|
283
105
|
};
|
|
284
|
-
|
|
106
|
+
const StyledBase = styled.div.withConfig({
|
|
285
107
|
displayName: "StyledBase",
|
|
286
108
|
componentId: "sc-14syaqw-0"
|
|
287
|
-
})(["position:relative;border:", ";border-radius:", ";box-shadow:", ";padding:", ";line-height:", ";font-size:", ";direction:", ";", ";"],
|
|
288
|
-
return props.theme.borders.sm;
|
|
289
|
-
}, function (props) {
|
|
290
|
-
return props.theme.borderRadii.md;
|
|
291
|
-
}, function (props) {
|
|
292
|
-
return props.isFloating && boxShadow;
|
|
293
|
-
}, padding, function (props) {
|
|
294
|
-
return getLineHeight(props.theme.space.base * 5, props.theme.fontSizes.md);
|
|
295
|
-
}, function (props) {
|
|
296
|
-
return props.theme.fontSizes.md;
|
|
297
|
-
}, function (props) {
|
|
298
|
-
return props.theme.rtl && 'rtl';
|
|
299
|
-
}, colorStyles$2);
|
|
109
|
+
})(["position:relative;border:", ";border-radius:", ";box-shadow:", ";padding:", ";line-height:", ";font-size:", ";direction:", ";", ";"], props => props.theme.borders.sm, props => props.theme.borderRadii.md, props => props.isFloating && boxShadow, padding, props => getLineHeight(props.theme.space.base * 5, props.theme.fontSizes.md), props => props.theme.fontSizes.md, props => props.theme.rtl && 'rtl', colorStyles$2);
|
|
300
110
|
StyledBase.defaultProps = {
|
|
301
111
|
theme: DEFAULT_THEME
|
|
302
112
|
};
|
|
303
113
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
'data-garden-version': '8.57.1',
|
|
312
|
-
role: props.role === undefined ? 'alert' : props.role
|
|
313
|
-
};
|
|
314
|
-
}).withConfig({
|
|
114
|
+
const COMPONENT_ID$2 = 'notifications.alert';
|
|
115
|
+
const colorStyles$1 = props => css(["", "{color:", ";}"], StyledTitle, props.hue && getColor(props.hue, 800, props.theme));
|
|
116
|
+
const StyledAlert = styled(StyledBase).attrs(props => ({
|
|
117
|
+
'data-garden-id': COMPONENT_ID$2,
|
|
118
|
+
'data-garden-version': '8.58.0',
|
|
119
|
+
role: props.role === undefined ? 'alert' : props.role
|
|
120
|
+
})).withConfig({
|
|
315
121
|
displayName: "StyledAlert",
|
|
316
122
|
componentId: "sc-fyn8jp-0"
|
|
317
|
-
})(["", " ", ";"], colorStyles$1,
|
|
318
|
-
return retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
319
|
-
});
|
|
123
|
+
})(["", " ", ";"], colorStyles$1, props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
320
124
|
StyledAlert.defaultProps = {
|
|
321
125
|
theme: DEFAULT_THEME
|
|
322
126
|
};
|
|
323
127
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
128
|
+
const COMPONENT_ID$1 = 'notifications.notification';
|
|
129
|
+
const colorStyles = props => {
|
|
130
|
+
const {
|
|
131
|
+
type,
|
|
132
|
+
theme
|
|
133
|
+
} = props;
|
|
134
|
+
const {
|
|
135
|
+
colors
|
|
136
|
+
} = theme;
|
|
137
|
+
const {
|
|
138
|
+
successHue,
|
|
139
|
+
dangerHue,
|
|
140
|
+
warningHue,
|
|
141
|
+
foreground
|
|
142
|
+
} = colors;
|
|
143
|
+
let color;
|
|
334
144
|
switch (type) {
|
|
335
145
|
case 'success':
|
|
336
146
|
color = getColor(successHue, 600, theme);
|
|
@@ -350,18 +160,14 @@ var colorStyles = function colorStyles(props) {
|
|
|
350
160
|
}
|
|
351
161
|
return css(["", "{color:", ";}"], StyledTitle, color);
|
|
352
162
|
};
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
};
|
|
359
|
-
}).withConfig({
|
|
163
|
+
const StyledNotification = styled(StyledBase).attrs(props => ({
|
|
164
|
+
'data-garden-id': COMPONENT_ID$1,
|
|
165
|
+
'data-garden-version': '8.58.0',
|
|
166
|
+
role: props.role === undefined ? 'status' : props.role
|
|
167
|
+
})).withConfig({
|
|
360
168
|
displayName: "StyledNotification",
|
|
361
169
|
componentId: "sc-uf6jh-0"
|
|
362
|
-
})(["", " ", ";"], colorStyles,
|
|
363
|
-
return retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
364
|
-
});
|
|
170
|
+
})(["", " ", ";"], colorStyles, props => retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
365
171
|
StyledNotification.propTypes = {
|
|
366
172
|
type: PropTypes.oneOf(TYPE)
|
|
367
173
|
};
|
|
@@ -369,41 +175,28 @@ StyledNotification.defaultProps = {
|
|
|
369
175
|
theme: DEFAULT_THEME
|
|
370
176
|
};
|
|
371
177
|
|
|
372
|
-
|
|
373
|
-
|
|
178
|
+
const COMPONENT_ID = 'notifications.well';
|
|
179
|
+
const StyledWell = styled(StyledBase).attrs({
|
|
374
180
|
'data-garden-id': COMPONENT_ID,
|
|
375
|
-
'data-garden-version': '8.
|
|
181
|
+
'data-garden-version': '8.58.0'
|
|
376
182
|
}).withConfig({
|
|
377
183
|
displayName: "StyledWell",
|
|
378
184
|
componentId: "sc-a5831c-0"
|
|
379
|
-
})(["background-color:", ";color:", " ", ";"],
|
|
380
|
-
return props.isRecessed && getColor('neutralHue', 100, props.theme);
|
|
381
|
-
}, function (props) {
|
|
382
|
-
return getColor('neutralHue', 600, props.theme);
|
|
383
|
-
}, function (props) {
|
|
384
|
-
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
385
|
-
});
|
|
185
|
+
})(["background-color:", ";color:", " ", ";"], props => props.isRecessed && getColor('neutralHue', 100, props.theme), props => getColor('neutralHue', 600, props.theme), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
386
186
|
StyledWell.defaultProps = {
|
|
387
187
|
theme: DEFAULT_THEME
|
|
388
188
|
};
|
|
389
189
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
190
|
+
const StyledIcon = styled(_ref => {
|
|
191
|
+
let {
|
|
192
|
+
children,
|
|
193
|
+
...props
|
|
194
|
+
} = _ref;
|
|
394
195
|
return React__default.cloneElement(Children.only(children), props);
|
|
395
196
|
}).withConfig({
|
|
396
197
|
displayName: "StyledIcon",
|
|
397
198
|
componentId: "sc-msklws-0"
|
|
398
|
-
})(["position:absolute;right:", ";left:", ";margin-top:", "px;color:", ";"],
|
|
399
|
-
return props.theme.rtl && "".concat(props.theme.space.base * 4, "px");
|
|
400
|
-
}, function (props) {
|
|
401
|
-
return !props.theme.rtl && "".concat(props.theme.space.base * 4, "px");
|
|
402
|
-
}, function (props) {
|
|
403
|
-
return props.theme.space.base / 2;
|
|
404
|
-
}, function (props) {
|
|
405
|
-
return props.hue && getColor(props.hue, props.hue === 'warningHue' ? 700 : 600, props.theme);
|
|
406
|
-
});
|
|
199
|
+
})(["position:absolute;right:", ";left:", ";margin-top:", "px;color:", ";"], props => props.theme.rtl && `${props.theme.space.base * 4}px`, props => !props.theme.rtl && `${props.theme.space.base * 4}px`, props => props.theme.space.base / 2, props => props.hue && getColor(props.hue, props.hue === 'warningHue' ? 700 : 600, props.theme));
|
|
407
200
|
StyledIcon.defaultProps = {
|
|
408
201
|
theme: DEFAULT_THEME
|
|
409
202
|
};
|
|
@@ -419,7 +212,8 @@ var SvgAlertErrorStroke = function SvgAlertErrorStroke(props) {
|
|
|
419
212
|
height: 16,
|
|
420
213
|
focusable: "false",
|
|
421
214
|
viewBox: "0 0 16 16",
|
|
422
|
-
"aria-hidden": "true"
|
|
215
|
+
"aria-hidden": "true",
|
|
216
|
+
role: "img"
|
|
423
217
|
}, props), _g$2 || (_g$2 = /*#__PURE__*/React.createElement("g", {
|
|
424
218
|
fill: "none",
|
|
425
219
|
stroke: "currentColor"
|
|
@@ -449,7 +243,8 @@ var SvgCheckCircleStroke = function SvgCheckCircleStroke(props) {
|
|
|
449
243
|
height: 16,
|
|
450
244
|
focusable: "false",
|
|
451
245
|
viewBox: "0 0 16 16",
|
|
452
|
-
"aria-hidden": "true"
|
|
246
|
+
"aria-hidden": "true",
|
|
247
|
+
role: "img"
|
|
453
248
|
}, props), _g$1 || (_g$1 = /*#__PURE__*/React.createElement("g", {
|
|
454
249
|
fill: "none",
|
|
455
250
|
stroke: "currentColor"
|
|
@@ -475,7 +270,8 @@ var SvgAlertWarningStroke = function SvgAlertWarningStroke(props) {
|
|
|
475
270
|
height: 16,
|
|
476
271
|
focusable: "false",
|
|
477
272
|
viewBox: "0 0 16 16",
|
|
478
|
-
"aria-hidden": "true"
|
|
273
|
+
"aria-hidden": "true",
|
|
274
|
+
role: "img"
|
|
479
275
|
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
480
276
|
fill: "none",
|
|
481
277
|
stroke: "currentColor",
|
|
@@ -500,7 +296,8 @@ var SvgInfoStroke = function SvgInfoStroke(props) {
|
|
|
500
296
|
height: 16,
|
|
501
297
|
focusable: "false",
|
|
502
298
|
viewBox: "0 0 16 16",
|
|
503
|
-
"aria-hidden": "true"
|
|
299
|
+
"aria-hidden": "true",
|
|
300
|
+
role: "img"
|
|
504
301
|
}, props), _g || (_g = /*#__PURE__*/React.createElement("g", {
|
|
505
302
|
stroke: "currentColor"
|
|
506
303
|
}, /*#__PURE__*/React.createElement("circle", {
|
|
@@ -519,27 +316,27 @@ var SvgInfoStroke = function SvgInfoStroke(props) {
|
|
|
519
316
|
})));
|
|
520
317
|
};
|
|
521
318
|
|
|
522
|
-
|
|
319
|
+
const validationIcons = {
|
|
523
320
|
success: SvgCheckCircleStroke,
|
|
524
321
|
error: SvgAlertErrorStroke,
|
|
525
322
|
warning: SvgAlertWarningStroke,
|
|
526
323
|
info: SvgInfoStroke
|
|
527
324
|
};
|
|
528
|
-
|
|
325
|
+
const validationHues = {
|
|
529
326
|
success: 'successHue',
|
|
530
327
|
error: 'dangerHue',
|
|
531
328
|
warning: 'warningHue',
|
|
532
329
|
info: 'neutralHue'
|
|
533
330
|
};
|
|
534
331
|
|
|
535
|
-
|
|
536
|
-
|
|
332
|
+
const NotificationsContext = createContext(undefined);
|
|
333
|
+
const useNotificationsContext = () => {
|
|
537
334
|
return useContext(NotificationsContext);
|
|
538
335
|
};
|
|
539
336
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
337
|
+
const Alert = React__default.forwardRef((props, ref) => {
|
|
338
|
+
const hue = validationHues[props.type];
|
|
339
|
+
const Icon = validationIcons[props.type];
|
|
543
340
|
return React__default.createElement(NotificationsContext.Provider, {
|
|
544
341
|
value: hue
|
|
545
342
|
}, React__default.createElement(StyledAlert, _extends$5({
|
|
@@ -554,9 +351,9 @@ Alert.propTypes = {
|
|
|
554
351
|
type: PropTypes.oneOf(TYPE).isRequired
|
|
555
352
|
};
|
|
556
353
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
354
|
+
const Notification = React__default.forwardRef((props, ref) => {
|
|
355
|
+
const Icon = props.type ? validationIcons[props.type] : SvgInfoStroke;
|
|
356
|
+
const hue = props.type && validationHues[props.type];
|
|
560
357
|
return React__default.createElement(StyledNotification, _extends$5({
|
|
561
358
|
ref: ref,
|
|
562
359
|
type: props.type,
|
|
@@ -570,11 +367,9 @@ Notification.propTypes = {
|
|
|
570
367
|
type: PropTypes.oneOf(TYPE)
|
|
571
368
|
};
|
|
572
369
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
}, props));
|
|
577
|
-
});
|
|
370
|
+
const Well = React__default.forwardRef((props, ref) => React__default.createElement(StyledWell, _extends$5({
|
|
371
|
+
ref: ref
|
|
372
|
+
}, props)));
|
|
578
373
|
Well.displayName = 'Well';
|
|
579
374
|
Well.propTypes = {
|
|
580
375
|
isRecessed: PropTypes.bool,
|
|
@@ -592,7 +387,8 @@ var SvgXStroke = function SvgXStroke(props) {
|
|
|
592
387
|
height: 12,
|
|
593
388
|
focusable: "false",
|
|
594
389
|
viewBox: "0 0 12 12",
|
|
595
|
-
"aria-hidden": "true"
|
|
390
|
+
"aria-hidden": "true",
|
|
391
|
+
role: "img"
|
|
596
392
|
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
597
393
|
stroke: "currentColor",
|
|
598
394
|
strokeLinecap: "round",
|
|
@@ -600,8 +396,8 @@ var SvgXStroke = function SvgXStroke(props) {
|
|
|
600
396
|
})));
|
|
601
397
|
};
|
|
602
398
|
|
|
603
|
-
|
|
604
|
-
|
|
399
|
+
const Close = React__default.forwardRef((props, ref) => {
|
|
400
|
+
const hue = useNotificationsContext();
|
|
605
401
|
return React__default.createElement(StyledClose, _extends$5({
|
|
606
402
|
ref: ref,
|
|
607
403
|
hue: hue
|
|
@@ -609,93 +405,99 @@ var Close = React__default.forwardRef(function (props, ref) {
|
|
|
609
405
|
});
|
|
610
406
|
Close.displayName = 'Close';
|
|
611
407
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
}, props));
|
|
616
|
-
});
|
|
408
|
+
const Paragraph = React__default.forwardRef((props, ref) => React__default.createElement(StyledParagraph, _extends$5({
|
|
409
|
+
ref: ref
|
|
410
|
+
}, props)));
|
|
617
411
|
Paragraph.displayName = 'Paragraph';
|
|
618
412
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}, props));
|
|
623
|
-
});
|
|
413
|
+
const Title = React__default.forwardRef((props, ref) => React__default.createElement(StyledTitle, _extends$5({
|
|
414
|
+
ref: ref
|
|
415
|
+
}, props)));
|
|
624
416
|
Title.displayName = 'Title';
|
|
625
417
|
|
|
626
|
-
|
|
627
|
-
var getInitialState = function getInitialState() {
|
|
418
|
+
const getInitialState = () => {
|
|
628
419
|
return {
|
|
629
420
|
toasts: []
|
|
630
421
|
};
|
|
631
422
|
};
|
|
632
|
-
|
|
423
|
+
const toasterReducer = (state, action) => {
|
|
633
424
|
switch (action.type) {
|
|
634
425
|
case 'ADD_TOAST':
|
|
635
426
|
{
|
|
636
|
-
return
|
|
637
|
-
|
|
638
|
-
|
|
427
|
+
return {
|
|
428
|
+
...state,
|
|
429
|
+
toasts: [...state.toasts, action.payload]
|
|
430
|
+
};
|
|
639
431
|
}
|
|
640
432
|
case 'REMOVE_TOAST':
|
|
641
433
|
{
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
434
|
+
const filteredToasts = state.toasts.filter(toast => toast.id !== action.payload);
|
|
435
|
+
return {
|
|
436
|
+
...state,
|
|
646
437
|
toasts: filteredToasts
|
|
647
|
-
}
|
|
438
|
+
};
|
|
648
439
|
}
|
|
649
440
|
case 'UPDATE_TOAST':
|
|
650
441
|
{
|
|
651
|
-
|
|
442
|
+
const updatedToasts = state.toasts.map(toast => {
|
|
652
443
|
if (toast.id !== action.payload.id) {
|
|
653
444
|
return toast;
|
|
654
445
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
446
|
+
const updatedToast = toast;
|
|
447
|
+
const {
|
|
448
|
+
content,
|
|
449
|
+
...newOptions
|
|
450
|
+
} = action.payload.options;
|
|
659
451
|
if (content) {
|
|
660
452
|
updatedToast.content = content;
|
|
661
453
|
}
|
|
662
|
-
updatedToast.options =
|
|
454
|
+
updatedToast.options = {
|
|
455
|
+
...updatedToast.options,
|
|
456
|
+
...newOptions
|
|
457
|
+
};
|
|
663
458
|
return updatedToast;
|
|
664
459
|
});
|
|
665
|
-
return
|
|
460
|
+
return {
|
|
461
|
+
...state,
|
|
666
462
|
toasts: updatedToasts
|
|
667
|
-
}
|
|
463
|
+
};
|
|
668
464
|
}
|
|
669
465
|
case 'REMOVE_ALL_TOASTS':
|
|
670
466
|
{
|
|
671
|
-
return
|
|
467
|
+
return {
|
|
468
|
+
...state,
|
|
672
469
|
toasts: []
|
|
673
|
-
}
|
|
470
|
+
};
|
|
674
471
|
}
|
|
675
472
|
default:
|
|
676
473
|
throw new Error('Invalid toaster reducer action');
|
|
677
474
|
}
|
|
678
475
|
};
|
|
679
476
|
|
|
680
|
-
|
|
477
|
+
const ToastContext = createContext(undefined);
|
|
681
478
|
|
|
682
|
-
|
|
479
|
+
const DEFAULT_TOAST_OPTIONS = {
|
|
683
480
|
autoDismiss: 5000,
|
|
684
481
|
placement: 'top-end'
|
|
685
482
|
};
|
|
686
|
-
|
|
687
|
-
|
|
483
|
+
const useToast = () => {
|
|
484
|
+
const context = useContext(ToastContext);
|
|
688
485
|
if (context === undefined) {
|
|
689
486
|
throw new Error('useToast() must be used within a "ToastProvider"');
|
|
690
487
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
488
|
+
const {
|
|
489
|
+
dispatch,
|
|
490
|
+
state
|
|
491
|
+
} = context;
|
|
492
|
+
const addToast = useCallback(function (content) {
|
|
493
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
494
|
+
const mergedOptions = {
|
|
495
|
+
...DEFAULT_TOAST_OPTIONS,
|
|
496
|
+
...options
|
|
497
|
+
};
|
|
498
|
+
const newToast = {
|
|
697
499
|
id: mergedOptions.id || uid(content),
|
|
698
|
-
content
|
|
500
|
+
content,
|
|
699
501
|
options: mergedOptions
|
|
700
502
|
};
|
|
701
503
|
dispatch({
|
|
@@ -704,56 +506,60 @@ var useToast = function useToast() {
|
|
|
704
506
|
});
|
|
705
507
|
return newToast.id;
|
|
706
508
|
}, [dispatch]);
|
|
707
|
-
|
|
509
|
+
const removeToast = useCallback(id => {
|
|
708
510
|
dispatch({
|
|
709
511
|
type: 'REMOVE_TOAST',
|
|
710
512
|
payload: id
|
|
711
513
|
});
|
|
712
514
|
}, [dispatch]);
|
|
713
|
-
|
|
515
|
+
const updateToast = useCallback((id, options) => {
|
|
714
516
|
dispatch({
|
|
715
517
|
type: 'UPDATE_TOAST',
|
|
716
518
|
payload: {
|
|
717
|
-
id
|
|
718
|
-
options
|
|
519
|
+
id,
|
|
520
|
+
options
|
|
719
521
|
}
|
|
720
522
|
});
|
|
721
523
|
}, [dispatch]);
|
|
722
|
-
|
|
524
|
+
const removeAllToasts = useCallback(() => {
|
|
723
525
|
dispatch({
|
|
724
526
|
type: 'REMOVE_ALL_TOASTS'
|
|
725
527
|
});
|
|
726
528
|
}, [dispatch]);
|
|
727
529
|
return {
|
|
728
|
-
addToast
|
|
729
|
-
removeToast
|
|
730
|
-
updateToast
|
|
731
|
-
removeAllToasts
|
|
530
|
+
addToast,
|
|
531
|
+
removeToast,
|
|
532
|
+
updateToast,
|
|
533
|
+
removeAllToasts,
|
|
732
534
|
toasts: state.toasts
|
|
733
535
|
};
|
|
734
536
|
};
|
|
735
537
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
538
|
+
const Toast = _ref => {
|
|
539
|
+
let {
|
|
540
|
+
toast,
|
|
541
|
+
pauseTimers
|
|
542
|
+
} = _ref;
|
|
543
|
+
const {
|
|
544
|
+
removeToast
|
|
545
|
+
} = useToast();
|
|
546
|
+
const {
|
|
547
|
+
id
|
|
548
|
+
} = toast;
|
|
549
|
+
const {
|
|
550
|
+
autoDismiss
|
|
551
|
+
} = toast.options;
|
|
552
|
+
const [remainingTime, setRemainingTime] = useState(NaN);
|
|
553
|
+
const startTimeRef = useRef(Date.now());
|
|
554
|
+
const previousRemainingTimeRef = useRef(remainingTime);
|
|
555
|
+
useEffect(() => {
|
|
750
556
|
if (typeof autoDismiss === 'number') {
|
|
751
557
|
setRemainingTime(autoDismiss);
|
|
752
558
|
} else {
|
|
753
559
|
setRemainingTime(NaN);
|
|
754
560
|
}
|
|
755
561
|
}, [autoDismiss]);
|
|
756
|
-
useEffect(
|
|
562
|
+
useEffect(() => {
|
|
757
563
|
if (pauseTimers && !isNaN(remainingTime)) {
|
|
758
564
|
previousRemainingTimeRef.current = remainingTime - (Date.now() - startTimeRef.current);
|
|
759
565
|
setRemainingTime(NaN);
|
|
@@ -761,38 +567,32 @@ var Toast = function Toast(_ref) {
|
|
|
761
567
|
setRemainingTime(previousRemainingTimeRef.current);
|
|
762
568
|
}
|
|
763
569
|
}, [pauseTimers, remainingTime]);
|
|
764
|
-
useEffect(
|
|
765
|
-
|
|
570
|
+
useEffect(() => {
|
|
571
|
+
let timeout;
|
|
766
572
|
if (!isNaN(remainingTime)) {
|
|
767
573
|
startTimeRef.current = Date.now();
|
|
768
|
-
timeout = setTimeout(
|
|
574
|
+
timeout = setTimeout(() => {
|
|
769
575
|
removeToast(id);
|
|
770
576
|
}, remainingTime);
|
|
771
577
|
}
|
|
772
|
-
return
|
|
578
|
+
return () => {
|
|
773
579
|
clearTimeout(timeout);
|
|
774
580
|
};
|
|
775
581
|
}, [id, pauseTimers, remainingTime, removeToast]);
|
|
776
|
-
|
|
582
|
+
const close = useCallback(() => {
|
|
777
583
|
removeToast(toast.id);
|
|
778
584
|
}, [removeToast, toast.id]);
|
|
779
585
|
return toast.content({
|
|
780
|
-
close
|
|
586
|
+
close
|
|
781
587
|
});
|
|
782
588
|
};
|
|
783
589
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
590
|
+
const TRANSITION_CLASS = 'garden-toast-transition';
|
|
591
|
+
const DEFAULT_DURATION = '400ms';
|
|
592
|
+
const StyledFadeInTransition = styled.div.withConfig({
|
|
787
593
|
displayName: "styled__StyledFadeInTransition",
|
|
788
594
|
componentId: "sc-nq0usb-0"
|
|
789
|
-
})(["transition:opacity ", " ease-in 300ms;opacity:", ";margin-bottom:", "px;", " &.", "-enter{transform:translateY( ", " );opacity:0;max-height:0;}&.", "-enter-active{transform:translateY(0);transition:opacity ", " ease-in,transform ", " cubic-bezier(0.15,0.85,0.35,1.2),max-height ", ";opacity:1;max-height:500px;}&.", "-exit{opacity:1;max-height:500px;}&.", "-exit-active{transition:opacity 550ms ease-out,max-height ", " linear 150ms;opacity:0;max-height:0;}"], DEFAULT_DURATION,
|
|
790
|
-
return p.isHidden ? '0 !important' : 1;
|
|
791
|
-
}, function (p) {
|
|
792
|
-
return p.theme.space.base * 2;
|
|
793
|
-
}, function (p) {
|
|
794
|
-
return p.isHidden && hideVisually();
|
|
795
|
-
}, TRANSITION_CLASS, function (props) {
|
|
595
|
+
})(["transition:opacity ", " ease-in 300ms;opacity:", ";margin-bottom:", "px;", " &.", "-enter{transform:translateY( ", " );opacity:0;max-height:0;}&.", "-enter-active{transform:translateY(0);transition:opacity ", " ease-in,transform ", " cubic-bezier(0.15,0.85,0.35,1.2),max-height ", ";opacity:1;max-height:500px;}&.", "-exit{opacity:1;max-height:500px;}&.", "-exit-active{transition:opacity 550ms ease-out,max-height ", " linear 150ms;opacity:0;max-height:0;}"], DEFAULT_DURATION, p => p.isHidden ? '0 !important' : 1, p => p.theme.space.base * 2, p => p.isHidden && hideVisually(), TRANSITION_CLASS, props => {
|
|
796
596
|
if (props.placement === 'bottom-start' || props.placement === 'bottom' || props.placement === 'bottom-end') {
|
|
797
597
|
return '100px';
|
|
798
598
|
}
|
|
@@ -801,15 +601,15 @@ var StyledFadeInTransition = styled.div.withConfig({
|
|
|
801
601
|
StyledFadeInTransition.defaultProps = {
|
|
802
602
|
theme: DEFAULT_THEME
|
|
803
603
|
};
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
604
|
+
const placementStyles = props => {
|
|
605
|
+
const verticalDistance = `${props.theme.space.base * 16}px`;
|
|
606
|
+
const horizontalDistance = `${props.theme.space.base * 3}px`;
|
|
607
|
+
const topLeftStyles = css(["top:", ";left:", ";"], verticalDistance, horizontalDistance);
|
|
608
|
+
const topStyles = css(["top:", ";left:50%;transform:translate(-50%,0);"], verticalDistance);
|
|
609
|
+
const topRightStyles = css(["top:", ";right:", ";"], verticalDistance, horizontalDistance);
|
|
610
|
+
const bottomLeftStyles = css(["bottom:", ";left:", ";"], verticalDistance, horizontalDistance);
|
|
611
|
+
const bottomStyles = css(["bottom:", ";left:50%;transform:translate(-50%,0);"], verticalDistance);
|
|
612
|
+
const bottomRightStyles = css(["right:", ";bottom:", ";"], horizontalDistance, verticalDistance);
|
|
813
613
|
switch (props.$placement) {
|
|
814
614
|
case 'top-start':
|
|
815
615
|
if (props.theme.rtl) {
|
|
@@ -839,53 +639,49 @@ var placementStyles = function placementStyles(props) {
|
|
|
839
639
|
return '';
|
|
840
640
|
}
|
|
841
641
|
};
|
|
842
|
-
|
|
642
|
+
const StyledTransitionGroup = styled(TransitionGroup).withConfig({
|
|
843
643
|
displayName: "styled__StyledTransitionGroup",
|
|
844
644
|
componentId: "sc-nq0usb-1"
|
|
845
|
-
})(["position:fixed;z-index:", ";", ";"],
|
|
846
|
-
return props.$zIndex;
|
|
847
|
-
}, placementStyles);
|
|
645
|
+
})(["position:fixed;z-index:", ";", ";"], props => props.$zIndex, placementStyles);
|
|
848
646
|
StyledTransitionGroup.defaultProps = {
|
|
849
647
|
theme: DEFAULT_THEME
|
|
850
648
|
};
|
|
851
649
|
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
var environment = useDocument(theme);
|
|
865
|
-
var handleVisibilityChange = useCallback(function (e) {
|
|
650
|
+
const ToastSlot = _ref => {
|
|
651
|
+
let {
|
|
652
|
+
toasts,
|
|
653
|
+
placement,
|
|
654
|
+
zIndex,
|
|
655
|
+
limit,
|
|
656
|
+
...props
|
|
657
|
+
} = _ref;
|
|
658
|
+
const [pauseTimers, setPauseTimers] = useState(false);
|
|
659
|
+
const theme = useContext(ThemeContext);
|
|
660
|
+
const environment = useDocument(theme);
|
|
661
|
+
const handleVisibilityChange = useCallback(e => {
|
|
866
662
|
if (e.target.visibilityState === 'visible') {
|
|
867
663
|
setPauseTimers(false);
|
|
868
664
|
} else {
|
|
869
665
|
setPauseTimers(true);
|
|
870
666
|
}
|
|
871
667
|
}, []);
|
|
872
|
-
useEffect(
|
|
668
|
+
useEffect(() => {
|
|
873
669
|
if (environment) {
|
|
874
670
|
environment.addEventListener('visibilitychange', handleVisibilityChange);
|
|
875
671
|
}
|
|
876
|
-
return
|
|
672
|
+
return () => {
|
|
877
673
|
if (environment) {
|
|
878
674
|
environment.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
879
675
|
}
|
|
880
676
|
};
|
|
881
677
|
}, [environment, handleVisibilityChange]);
|
|
882
|
-
|
|
678
|
+
const handleMouseEnter = useCallback(() => {
|
|
883
679
|
setPauseTimers(true);
|
|
884
680
|
}, []);
|
|
885
|
-
|
|
681
|
+
const handleMouseLeave = useCallback(() => {
|
|
886
682
|
setPauseTimers(false);
|
|
887
683
|
}, []);
|
|
888
|
-
|
|
684
|
+
const isHidden = useCallback(index => {
|
|
889
685
|
if (placement === 'bottom' || placement === 'bottom-start' || placement === 'bottom-end') {
|
|
890
686
|
return index < toasts.length - limit;
|
|
891
687
|
}
|
|
@@ -897,8 +693,8 @@ var ToastSlot = function ToastSlot(_ref) {
|
|
|
897
693
|
$zIndex: zIndex,
|
|
898
694
|
onMouseEnter: handleMouseEnter,
|
|
899
695
|
onMouseLeave: handleMouseLeave
|
|
900
|
-
}, props), toasts.map(
|
|
901
|
-
|
|
696
|
+
}, props), toasts.map((toast, index) => {
|
|
697
|
+
const transitionRef = React__default.createRef();
|
|
902
698
|
return React__default.createElement(CSSTransition, {
|
|
903
699
|
key: toast.id,
|
|
904
700
|
timeout: {
|
|
@@ -919,26 +715,20 @@ var ToastSlot = function ToastSlot(_ref) {
|
|
|
919
715
|
}));
|
|
920
716
|
};
|
|
921
717
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
};
|
|
937
|
-
}, [state, dispatch]);
|
|
938
|
-
var toastsByPlacement = useCallback(function (placement) {
|
|
939
|
-
var matchingToasts = state.toasts.filter(function (toast) {
|
|
940
|
-
return toast.options.placement === placement;
|
|
941
|
-
});
|
|
718
|
+
const ToastProvider = _ref => {
|
|
719
|
+
let {
|
|
720
|
+
limit,
|
|
721
|
+
zIndex,
|
|
722
|
+
placementProps = {},
|
|
723
|
+
children
|
|
724
|
+
} = _ref;
|
|
725
|
+
const [state, dispatch] = useReducer(toasterReducer, getInitialState());
|
|
726
|
+
const contextValue = useMemo(() => ({
|
|
727
|
+
state,
|
|
728
|
+
dispatch
|
|
729
|
+
}), [state, dispatch]);
|
|
730
|
+
const toastsByPlacement = useCallback(placement => {
|
|
731
|
+
let matchingToasts = state.toasts.filter(toast => toast.options.placement === placement);
|
|
942
732
|
if (placement === 'bottom' || placement === 'bottom-start' || placement === 'bottom-end') {
|
|
943
733
|
matchingToasts = matchingToasts.reverse();
|
|
944
734
|
}
|