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