@zendeskgarden/react-avatars 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 +148 -281
- package/dist/index.esm.js +148 -281
- package/dist/typings/elements/StatusIndicator.d.ts +3 -0
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -16,114 +16,17 @@ function _extends$4() {
|
|
|
16
16
|
_extends$4 = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
17
|
for (var i = 1; i < arguments.length; i++) {
|
|
18
18
|
var source = arguments[i];
|
|
19
|
-
|
|
20
19
|
for (var key in source) {
|
|
21
20
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
21
|
target[key] = source[key];
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
return target;
|
|
28
26
|
};
|
|
29
27
|
return _extends$4.apply(this, arguments);
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
33
|
-
if (source == null) return {};
|
|
34
|
-
var target = {};
|
|
35
|
-
var sourceKeys = Object.keys(source);
|
|
36
|
-
var key, i;
|
|
37
|
-
|
|
38
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
39
|
-
key = sourceKeys[i];
|
|
40
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
41
|
-
target[key] = source[key];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return target;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function _objectWithoutProperties(source, excluded) {
|
|
48
|
-
if (source == null) return {};
|
|
49
|
-
|
|
50
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
51
|
-
|
|
52
|
-
var key, i;
|
|
53
|
-
|
|
54
|
-
if (Object.getOwnPropertySymbols) {
|
|
55
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
56
|
-
|
|
57
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
58
|
-
key = sourceSymbolKeys[i];
|
|
59
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
60
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
61
|
-
target[key] = source[key];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return target;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function _slicedToArray(arr, i) {
|
|
69
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function _arrayWithHoles(arr) {
|
|
73
|
-
if (Array.isArray(arr)) return arr;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function _iterableToArrayLimit(arr, i) {
|
|
77
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
78
|
-
|
|
79
|
-
if (_i == null) return;
|
|
80
|
-
var _arr = [];
|
|
81
|
-
var _n = true;
|
|
82
|
-
var _d = false;
|
|
83
|
-
|
|
84
|
-
var _s, _e;
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
88
|
-
_arr.push(_s.value);
|
|
89
|
-
|
|
90
|
-
if (i && _arr.length === i) break;
|
|
91
|
-
}
|
|
92
|
-
} catch (err) {
|
|
93
|
-
_d = true;
|
|
94
|
-
_e = err;
|
|
95
|
-
} finally {
|
|
96
|
-
try {
|
|
97
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
98
|
-
} finally {
|
|
99
|
-
if (_d) throw _e;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return _arr;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
107
|
-
if (!o) return;
|
|
108
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
109
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
110
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
111
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
112
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function _arrayLikeToArray(arr, len) {
|
|
116
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
117
|
-
|
|
118
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
119
|
-
|
|
120
|
-
return arr2;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function _nonIterableRest() {
|
|
124
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
125
|
-
}
|
|
126
|
-
|
|
127
30
|
var _g$1;
|
|
128
31
|
|
|
129
32
|
function _extends$3() { _extends$3 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
|
|
@@ -135,7 +38,8 @@ var SvgClockStroke$1 = function SvgClockStroke(props) {
|
|
|
135
38
|
height: 12,
|
|
136
39
|
focusable: "false",
|
|
137
40
|
viewBox: "0 0 12 12",
|
|
138
|
-
"aria-hidden": "true"
|
|
41
|
+
"aria-hidden": "true",
|
|
42
|
+
role: "img"
|
|
139
43
|
}, props), _g$1 || (_g$1 = /*#__PURE__*/React.createElement("g", {
|
|
140
44
|
fill: "none",
|
|
141
45
|
stroke: "currentColor"
|
|
@@ -161,7 +65,8 @@ var SvgClockStroke = function SvgClockStroke(props) {
|
|
|
161
65
|
height: 16,
|
|
162
66
|
focusable: "false",
|
|
163
67
|
viewBox: "0 0 16 16",
|
|
164
|
-
"aria-hidden": "true"
|
|
68
|
+
"aria-hidden": "true",
|
|
69
|
+
role: "img"
|
|
165
70
|
}, props), _g || (_g = /*#__PURE__*/React.createElement("g", {
|
|
166
71
|
fill: "none",
|
|
167
72
|
stroke: "currentColor"
|
|
@@ -187,7 +92,8 @@ var SvgArrowLeftSmStroke$1 = function SvgArrowLeftSmStroke(props) {
|
|
|
187
92
|
height: 12,
|
|
188
93
|
focusable: "false",
|
|
189
94
|
viewBox: "0 0 12 12",
|
|
190
|
-
"aria-hidden": "true"
|
|
95
|
+
"aria-hidden": "true",
|
|
96
|
+
role: "img"
|
|
191
97
|
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
192
98
|
fill: "currentColor",
|
|
193
99
|
d: "M2.146 6.854a.5.5 0 0 1 0-.708l2-2a.5.5 0 1 1 .708.708L3.707 6H9.5a.5.5 0 0 1 0 1H3.707l1.147 1.146a.5.5 0 1 1-.708.708l-2-2Z"
|
|
@@ -205,37 +111,31 @@ var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
|
|
|
205
111
|
height: 16,
|
|
206
112
|
focusable: "false",
|
|
207
113
|
viewBox: "0 0 16 16",
|
|
208
|
-
"aria-hidden": "true"
|
|
114
|
+
"aria-hidden": "true",
|
|
115
|
+
role: "img"
|
|
209
116
|
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
210
117
|
fill: "currentColor",
|
|
211
118
|
d: "M3.146 8.854a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L4.707 8H12.5a.5.5 0 0 1 0 1H4.707l2.147 2.146a.5.5 0 1 1-.708.707l-3-3Z"
|
|
212
119
|
})));
|
|
213
120
|
};
|
|
214
121
|
|
|
215
|
-
|
|
216
|
-
|
|
122
|
+
const SIZE = ['extraextrasmall', 'extrasmall', 'small', 'medium', 'large'];
|
|
123
|
+
const STATUS = ['available', 'away', 'transfers', 'offline'];
|
|
217
124
|
|
|
218
|
-
|
|
219
|
-
|
|
125
|
+
const COMPONENT_ID$6 = 'avatars.text';
|
|
126
|
+
const StyledText = styled.span.attrs({
|
|
220
127
|
'data-garden-id': COMPONENT_ID$6,
|
|
221
|
-
'data-garden-version': '8.
|
|
128
|
+
'data-garden-version': '8.58.0'
|
|
222
129
|
}).withConfig({
|
|
223
130
|
displayName: "StyledText",
|
|
224
131
|
componentId: "sc-1a6hivh-0"
|
|
225
|
-
})(["overflow:hidden;text-align:center;white-space:nowrap;", ";"],
|
|
226
|
-
return retrieveComponentStyles(COMPONENT_ID$6, props);
|
|
227
|
-
});
|
|
132
|
+
})(["overflow:hidden;text-align:center;white-space:nowrap;", ";"], props => retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
228
133
|
StyledText.defaultProps = {
|
|
229
134
|
theme: DEFAULT_THEME
|
|
230
135
|
};
|
|
231
136
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
xs$1 = _SIZE$1[1],
|
|
235
|
-
s$1 = _SIZE$1[2],
|
|
236
|
-
m$1 = _SIZE$1[3],
|
|
237
|
-
l$1 = _SIZE$1[4];
|
|
238
|
-
var TRANSITION_DURATION = 0.25;
|
|
137
|
+
const [xxs$1, xs$1, s$1, m$1, l$1] = SIZE;
|
|
138
|
+
const TRANSITION_DURATION = 0.25;
|
|
239
139
|
function getStatusColor(type, theme) {
|
|
240
140
|
switch (type) {
|
|
241
141
|
case 'active':
|
|
@@ -253,20 +153,20 @@ function getStatusColor(type, theme) {
|
|
|
253
153
|
}
|
|
254
154
|
}
|
|
255
155
|
function getStatusBorderOffset(props) {
|
|
256
|
-
return props.size === xxs$1 ? math(
|
|
156
|
+
return props.size === xxs$1 ? math(`${props.theme.shadowWidths.sm} - 1`) : props.theme.shadowWidths.sm;
|
|
257
157
|
}
|
|
258
158
|
function getStatusSize(props, offset) {
|
|
259
|
-
|
|
159
|
+
const isActive = props.type === 'active';
|
|
260
160
|
switch (props.size) {
|
|
261
161
|
case xxs$1:
|
|
262
|
-
return math(
|
|
162
|
+
return math(`${props.theme.space.base}px - ${offset}`);
|
|
263
163
|
case xs$1:
|
|
264
|
-
return math(
|
|
164
|
+
return math(`${props.theme.space.base * 2}px - (${offset} * 2)`);
|
|
265
165
|
case s$1:
|
|
266
|
-
return math(
|
|
166
|
+
return math(`${props.theme.space.base * 3}px ${isActive ? '' : `- (${offset} * 2)`}`);
|
|
267
167
|
case m$1:
|
|
268
168
|
case l$1:
|
|
269
|
-
return math(
|
|
169
|
+
return math(`${props.theme.space.base * 4}px ${isActive ? '' : `- (${offset} * 2)`}`);
|
|
270
170
|
default:
|
|
271
171
|
return '0';
|
|
272
172
|
}
|
|
@@ -275,253 +175,224 @@ function includes(array, element) {
|
|
|
275
175
|
return array.includes(element);
|
|
276
176
|
}
|
|
277
177
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
178
|
+
const COMPONENT_ID$5 = 'avatars.status-indicator.base';
|
|
179
|
+
const iconFadeIn = keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
|
|
180
|
+
const sizeStyles$3 = props => {
|
|
181
|
+
const offset = getStatusBorderOffset(props);
|
|
182
|
+
const size = getStatusSize(props, offset);
|
|
283
183
|
return css(["border:", " ", ";border-radius:", ";width:", ";min-width:", ";height:", ";line-height:", ";& > svg{position:absolute;top:-", ";left:-", ";transform-origin:50% 50%;animation:", " ", "s;max-height:unset;&[data-icon-status='transfers']{transform:scale(", ",1);}&[data-icon-status='away'] circle{display:none;}}"], offset, props.theme.borderStyles.solid, size, size, size, size, size, offset, offset, iconFadeIn, TRANSITION_DURATION, props.theme.rtl ? -1 : 1);
|
|
284
184
|
};
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
185
|
+
const colorStyles$2 = props => {
|
|
186
|
+
let backgroundColor = getStatusColor(props.type, props.theme);
|
|
187
|
+
let borderColor = backgroundColor;
|
|
288
188
|
if (props.type === 'offline') {
|
|
289
189
|
borderColor = getStatusColor(props.type, props.theme);
|
|
290
190
|
backgroundColor = props.theme.palette.white;
|
|
291
191
|
}
|
|
292
192
|
return css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, props.theme.palette.white);
|
|
293
193
|
};
|
|
294
|
-
|
|
194
|
+
const StyledStatusIndicatorBase = styled.div.attrs({
|
|
295
195
|
'data-garden-id': COMPONENT_ID$5,
|
|
296
|
-
'data-garden-version': '8.
|
|
196
|
+
'data-garden-version': '8.58.0'
|
|
297
197
|
}).withConfig({
|
|
298
198
|
displayName: "StyledStatusIndicatorBase",
|
|
299
199
|
componentId: "sc-1rininy-0"
|
|
300
|
-
})(["transition:inherit;", " ", " ", ";"], sizeStyles$3, colorStyles$2,
|
|
301
|
-
return retrieveComponentStyles(COMPONENT_ID$5, props);
|
|
302
|
-
});
|
|
200
|
+
})(["transition:inherit;", " ", " ", ";"], sizeStyles$3, colorStyles$2, props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
303
201
|
StyledStatusIndicatorBase.defaultProps = {
|
|
304
202
|
theme: DEFAULT_THEME,
|
|
305
203
|
size: 'small'
|
|
306
204
|
};
|
|
307
205
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
l = _SIZE[4];
|
|
315
|
-
var sizeStyles$2 = function sizeStyles(props) {
|
|
316
|
-
var isVisible = !includes([xxs, xs], props.size);
|
|
317
|
-
var borderWidth = getStatusBorderOffset(props);
|
|
318
|
-
var padding = '0';
|
|
206
|
+
const COMPONENT_ID$4 = 'avatars.status_indicator';
|
|
207
|
+
const [xxs, xs, s, m, l] = SIZE;
|
|
208
|
+
const sizeStyles$2 = props => {
|
|
209
|
+
const isVisible = !includes([xxs, xs], props.size);
|
|
210
|
+
const borderWidth = getStatusBorderOffset(props);
|
|
211
|
+
let padding = '0';
|
|
319
212
|
if (props.size === s) {
|
|
320
|
-
padding = math(
|
|
213
|
+
padding = math(`${props.theme.space.base + 1}px - (${borderWidth} * 2)`);
|
|
321
214
|
} else if (includes([m, l], props.size)) {
|
|
322
|
-
padding = math(
|
|
215
|
+
padding = math(`${props.theme.space.base + 3}px - (${borderWidth} * 2)`);
|
|
323
216
|
}
|
|
324
217
|
return css(["max-width:calc(2em + (", " * 3));box-sizing:content-box;overflow:hidden;text-align:center;text-overflow:ellipsis;white-space:nowrap;font-size:", ";font-weight:", ";& > span{display:", ";padding:0 ", ";max-width:2em;overflow:inherit;text-align:inherit;text-overflow:inherit;white-space:inherit;}& > svg{", "}"], borderWidth, props.theme.fontSizes.xs, props.theme.fontWeights.semibold, isVisible ? 'inline-block' : 'none', padding, !isVisible && 'display: none;');
|
|
325
218
|
};
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
219
|
+
const colorStyles$1 = props => {
|
|
220
|
+
const {
|
|
221
|
+
theme,
|
|
222
|
+
type,
|
|
223
|
+
size,
|
|
224
|
+
borderColor,
|
|
225
|
+
surfaceColor
|
|
226
|
+
} = props;
|
|
227
|
+
let boxShadow = theme.shadows.sm(surfaceColor || (type ? theme.colors.background : theme.palette.white));
|
|
335
228
|
if (size === xxs) {
|
|
336
229
|
boxShadow = boxShadow.replace(theme.shadowWidths.sm, '1px');
|
|
337
230
|
}
|
|
338
|
-
return css(["border-color:", ";box-shadow:", ";
|
|
231
|
+
return css(["border-color:", ";box-shadow:", ";"], borderColor, boxShadow);
|
|
339
232
|
};
|
|
340
|
-
|
|
233
|
+
const StyledStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
|
|
341
234
|
'data-garden-id': COMPONENT_ID$4,
|
|
342
|
-
'data-garden-version': '8.
|
|
235
|
+
'data-garden-version': '8.58.0'
|
|
343
236
|
}).withConfig({
|
|
344
237
|
displayName: "StyledStatusIndicator",
|
|
345
238
|
componentId: "sc-16t9if3-0"
|
|
346
|
-
})(["", " ", " ", ";"], sizeStyles$2, colorStyles$1,
|
|
347
|
-
return retrieveComponentStyles(COMPONENT_ID$4, props);
|
|
348
|
-
});
|
|
239
|
+
})(["", " ", " ", ";"], sizeStyles$2, colorStyles$1, props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
349
240
|
StyledStatusIndicator.defaultProps = {
|
|
350
241
|
size: 'medium',
|
|
351
242
|
theme: DEFAULT_THEME
|
|
352
243
|
};
|
|
353
244
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
xs = _SIZE[1],
|
|
359
|
-
s = _SIZE[2],
|
|
360
|
-
m = _SIZE[3],
|
|
361
|
-
l = _SIZE[4];
|
|
362
|
-
var position = "".concat(props.theme.space.base * -1, "px");
|
|
245
|
+
const COMPONENT_ID$3 = 'avatars.avatar';
|
|
246
|
+
const badgeStyles = props => {
|
|
247
|
+
const [xxs, xs, s, m, l] = SIZE;
|
|
248
|
+
let position = `${props.theme.space.base * -1}px`;
|
|
363
249
|
switch (props.size) {
|
|
364
250
|
case s:
|
|
365
251
|
case m:
|
|
366
|
-
position = math(
|
|
252
|
+
position = math(`${position} + 2`);
|
|
367
253
|
break;
|
|
368
254
|
case xxs:
|
|
369
255
|
case xs:
|
|
370
256
|
case l:
|
|
371
|
-
position = math(
|
|
257
|
+
position = math(`${position} + 3`);
|
|
372
258
|
break;
|
|
373
259
|
}
|
|
374
|
-
|
|
260
|
+
const animation = keyframes(["0%{transform:scale(.1);}"]);
|
|
375
261
|
return css(["position:absolute;", ":", ";bottom:", ";transition:all ", "s ease-in-out;", ""], props.theme.rtl ? 'left' : 'right', position, position, TRANSITION_DURATION, props.status === 'active' && css(["animation:", " ", "s ease-in-out;"], animation, TRANSITION_DURATION * 1.5));
|
|
376
262
|
};
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
263
|
+
const colorStyles = props => {
|
|
264
|
+
const statusColor = getStatusColor(props.status, props.theme);
|
|
265
|
+
const backgroundColor = props.backgroundColor || 'transparent';
|
|
266
|
+
const foregroundColor = props.foregroundColor || props.theme.palette.white;
|
|
267
|
+
const surfaceColor = props.status ? props.surfaceColor || props.theme.colors.background : 'transparent';
|
|
382
268
|
return css(["box-shadow:", ";background-color:", ";color:", ";& > svg,& ", "{color:", ";}"], props.theme.shadows.sm(statusColor), backgroundColor, surfaceColor, StyledText, foregroundColor);
|
|
383
269
|
};
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
270
|
+
const sizeStyles$1 = props => {
|
|
271
|
+
let boxShadow;
|
|
272
|
+
let borderRadius;
|
|
273
|
+
let size;
|
|
274
|
+
let fontSize;
|
|
275
|
+
let svgSize;
|
|
390
276
|
if (props.size === 'extraextrasmall') {
|
|
391
|
-
boxShadow =
|
|
392
|
-
borderRadius = props.isSystem ? math(
|
|
393
|
-
size =
|
|
277
|
+
boxShadow = `0 0 0 ${math(`${props.theme.shadowWidths.sm} - 1`)}`;
|
|
278
|
+
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
279
|
+
size = `${props.theme.space.base * 4}px`;
|
|
394
280
|
fontSize = 0;
|
|
395
|
-
svgSize =
|
|
281
|
+
svgSize = `${props.theme.space.base * 3}px`;
|
|
396
282
|
} else if (props.size === 'extrasmall') {
|
|
397
|
-
boxShadow =
|
|
398
|
-
borderRadius = props.isSystem ? math(
|
|
399
|
-
size =
|
|
283
|
+
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
284
|
+
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
285
|
+
size = `${props.theme.space.base * 6}px`;
|
|
400
286
|
fontSize = props.theme.fontSizes.sm;
|
|
401
|
-
svgSize =
|
|
287
|
+
svgSize = `${props.theme.space.base * 3}px`;
|
|
402
288
|
} else if (props.size === 'small') {
|
|
403
|
-
boxShadow =
|
|
404
|
-
borderRadius = props.isSystem ? math(
|
|
405
|
-
size =
|
|
289
|
+
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
290
|
+
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
291
|
+
size = `${props.theme.space.base * 8}px`;
|
|
406
292
|
fontSize = props.theme.fontSizes.md;
|
|
407
|
-
svgSize =
|
|
293
|
+
svgSize = `${props.theme.space.base * 3}px`;
|
|
408
294
|
} else if (props.size === 'large') {
|
|
409
|
-
boxShadow =
|
|
410
|
-
borderRadius = props.isSystem ? math(
|
|
411
|
-
size =
|
|
295
|
+
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
296
|
+
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} + 1`) : '50%';
|
|
297
|
+
size = `${props.theme.space.base * 12}px`;
|
|
412
298
|
fontSize = props.theme.fontSizes.xl;
|
|
413
|
-
svgSize =
|
|
299
|
+
svgSize = `${props.theme.space.base * 6}px`;
|
|
414
300
|
} else {
|
|
415
|
-
boxShadow =
|
|
301
|
+
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
416
302
|
borderRadius = props.isSystem ? props.theme.borderRadii.md : '50%';
|
|
417
|
-
size =
|
|
303
|
+
size = `${props.theme.space.base * 10}px`;
|
|
418
304
|
fontSize = props.theme.fontSizes.lg;
|
|
419
|
-
svgSize =
|
|
305
|
+
svgSize = `${props.theme.space.base * 4}px`;
|
|
420
306
|
}
|
|
421
307
|
return css(["border-radius:", ";width:", " !important;height:", " !important;::before{box-shadow:", ";}& > svg{font-size:", ";}& ", "{line-height:", ";font-size:", ";}"], borderRadius, size, size, boxShadow, svgSize, StyledText, size, fontSize);
|
|
422
308
|
};
|
|
423
|
-
|
|
309
|
+
const StyledAvatar = styled.figure.attrs({
|
|
424
310
|
'data-garden-id': COMPONENT_ID$3,
|
|
425
|
-
'data-garden-version': '8.
|
|
311
|
+
'data-garden-version': '8.58.0'
|
|
426
312
|
}).withConfig({
|
|
427
313
|
displayName: "StyledAvatar",
|
|
428
314
|
componentId: "sc-608m04-0"
|
|
429
|
-
})(["display:inline-flex;position:relative;align-items:center;justify-content:center;transition:box-shadow ", "s ease-in-out,color 0.1s ease-in-out;margin:0;vertical-align:middle;box-sizing:border-box;", ";", ";&::before{position:absolute;top:0;left:0;transition:box-shadow ", "s ease-in-out;content:'';}&::before,&& > img{border-radius:inherit;width:100%;height:100%;}&& > img{box-sizing:inherit;vertical-align:bottom;object-fit:cover;}&& > svg{width:1em;height:1em;}& > ", "{", ";}", ";"], TRANSITION_DURATION,
|
|
430
|
-
return sizeStyles$1(props);
|
|
431
|
-
}, function (props) {
|
|
432
|
-
return colorStyles(props);
|
|
433
|
-
}, TRANSITION_DURATION, StyledStatusIndicator, badgeStyles, function (props) {
|
|
434
|
-
return retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
435
|
-
});
|
|
315
|
+
})(["display:inline-flex;position:relative;align-items:center;justify-content:center;transition:box-shadow ", "s ease-in-out,color 0.1s ease-in-out;margin:0;vertical-align:middle;box-sizing:border-box;", ";", ";&::before{position:absolute;top:0;left:0;transition:box-shadow ", "s ease-in-out;content:'';}&::before,&& > img{border-radius:inherit;width:100%;height:100%;}&& > img{box-sizing:inherit;vertical-align:bottom;object-fit:cover;}&& > svg{width:1em;height:1em;}& > ", "{", ";}", ";"], TRANSITION_DURATION, props => sizeStyles$1(props), props => colorStyles(props), TRANSITION_DURATION, StyledStatusIndicator, badgeStyles, props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
436
316
|
StyledAvatar.defaultProps = {
|
|
437
317
|
size: 'medium',
|
|
438
318
|
theme: DEFAULT_THEME
|
|
439
319
|
};
|
|
440
320
|
|
|
441
|
-
|
|
442
|
-
|
|
321
|
+
const COMPONENT_ID$2 = 'avatars.status-indicator.status';
|
|
322
|
+
const StyledStandaloneStatus = styled.figure.attrs({
|
|
443
323
|
'data-garden-id': COMPONENT_ID$2,
|
|
444
|
-
'data-garden-version': '8.
|
|
324
|
+
'data-garden-version': '8.58.0'
|
|
445
325
|
}).withConfig({
|
|
446
326
|
displayName: "StyledStandaloneStatus",
|
|
447
327
|
componentId: "sc-1ow4nfj-0"
|
|
448
|
-
})(["display:inline-flex;flex-flow:row nowrap;transition:all ", "s ease-in-out;margin:0;box-sizing:content-box;", ";"], TRANSITION_DURATION,
|
|
449
|
-
return retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
450
|
-
});
|
|
328
|
+
})(["display:inline-flex;flex-flow:row nowrap;transition:all ", "s ease-in-out;margin:0;box-sizing:content-box;", ";"], TRANSITION_DURATION, props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
451
329
|
StyledStandaloneStatus.defaultProps = {
|
|
452
330
|
theme: DEFAULT_THEME
|
|
453
331
|
};
|
|
454
332
|
|
|
455
|
-
|
|
333
|
+
const COMPONENT_ID$1 = 'avatars.status-indicator.caption';
|
|
456
334
|
function sizeStyles(props) {
|
|
457
|
-
|
|
335
|
+
const marginRule = `margin-${props.theme.rtl ? 'right' : 'left'}: ${props.theme.space.base * 2}px;`;
|
|
458
336
|
return css(["", " line-height:", ";font-size:", ";"], marginRule, getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md), props.theme.fontSizes.md);
|
|
459
337
|
}
|
|
460
|
-
|
|
338
|
+
const StyledStandaloneStatusCaption = styled.figcaption.attrs({
|
|
461
339
|
'data-garden-id': COMPONENT_ID$1,
|
|
462
|
-
'data-garden-version': '8.
|
|
340
|
+
'data-garden-version': '8.58.0'
|
|
463
341
|
}).withConfig({
|
|
464
342
|
displayName: "StyledStandaloneStatusCaption",
|
|
465
343
|
componentId: "sc-aalyk1-0"
|
|
466
|
-
})(["", " ", ";"], sizeStyles,
|
|
467
|
-
return retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
468
|
-
});
|
|
344
|
+
})(["", " ", ";"], sizeStyles, props => retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
469
345
|
StyledStandaloneStatusCaption.defaultProps = {
|
|
470
346
|
theme: DEFAULT_THEME
|
|
471
347
|
};
|
|
472
348
|
|
|
473
|
-
|
|
474
|
-
|
|
349
|
+
const COMPONENT_ID = 'avatars.status-indicator.indicator';
|
|
350
|
+
const StyledStandaloneStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
|
|
475
351
|
'data-garden-id': COMPONENT_ID,
|
|
476
|
-
'data-garden-version': '8.
|
|
352
|
+
'data-garden-version': '8.58.0'
|
|
477
353
|
}).withConfig({
|
|
478
354
|
displayName: "StyledStandaloneStatusIndicator",
|
|
479
355
|
componentId: "sc-1xt1heq-0"
|
|
480
|
-
})(["position:relative;margin-top:", ";", ";"],
|
|
481
|
-
return "calc((".concat(props.theme.lineHeights.md, " - ").concat(getStatusSize(props, '0'), ") / 2)");
|
|
482
|
-
}, function (props) {
|
|
483
|
-
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
484
|
-
});
|
|
356
|
+
})(["position:relative;margin-top:", ";", ";"], props => `calc((${props.theme.lineHeights.md} - ${getStatusSize(props, '0')}) / 2)`, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
485
357
|
StyledStandaloneStatusIndicator.defaultProps = {
|
|
486
358
|
type: 'offline',
|
|
487
359
|
theme: DEFAULT_THEME
|
|
488
360
|
};
|
|
489
361
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
}, props));
|
|
494
|
-
});
|
|
362
|
+
const TextComponent = forwardRef((props, ref) => React__default.createElement(StyledText, _extends$4({
|
|
363
|
+
ref: ref
|
|
364
|
+
}, props)));
|
|
495
365
|
TextComponent.displayName = 'Avatar.Text';
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
366
|
+
const Text = TextComponent;
|
|
367
|
+
|
|
368
|
+
const AvatarComponent = forwardRef((_ref, ref) => {
|
|
369
|
+
let {
|
|
370
|
+
isSystem,
|
|
371
|
+
size,
|
|
372
|
+
status,
|
|
373
|
+
children,
|
|
374
|
+
badge,
|
|
375
|
+
surfaceColor,
|
|
376
|
+
backgroundColor,
|
|
377
|
+
foregroundColor,
|
|
378
|
+
...props
|
|
379
|
+
} = _ref;
|
|
380
|
+
const computedStatus = badge === undefined ? status : 'active';
|
|
381
|
+
let ClockIcon = SvgClockStroke$1;
|
|
382
|
+
let ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
512
383
|
if (['large', 'medium'].includes(size)) {
|
|
513
384
|
ClockIcon = SvgClockStroke;
|
|
514
385
|
ArrowLeftIcon = SvgArrowLeftSmStroke;
|
|
515
386
|
}
|
|
516
|
-
|
|
517
|
-
|
|
387
|
+
const defaultStatusLabel = useMemo(() => {
|
|
388
|
+
let statusMessage = computedStatus;
|
|
518
389
|
if (computedStatus === 'active') {
|
|
519
|
-
|
|
520
|
-
statusMessage =
|
|
390
|
+
const count = typeof badge === 'string' ? parseInt(badge, 10) : badge;
|
|
391
|
+
statusMessage = `active. ${count > 0 ? `${count} notification${count > 1 ? 's' : ''}` : 'no notifications'}`;
|
|
521
392
|
}
|
|
522
393
|
return ['status'].concat(statusMessage || []).join(': ');
|
|
523
394
|
}, [computedStatus, badge]);
|
|
524
|
-
|
|
395
|
+
const statusLabel = useText(AvatarComponent, props, 'statusLabel', defaultStatusLabel);
|
|
525
396
|
return React__default.createElement(StyledAvatar, _extends$4({
|
|
526
397
|
ref: ref,
|
|
527
398
|
isSystem: isSystem,
|
|
@@ -535,8 +406,6 @@ var AvatarComponent = forwardRef(function (_ref, ref) {
|
|
|
535
406
|
}, props), Children.only(children), computedStatus && React__default.createElement(StyledStatusIndicator, {
|
|
536
407
|
size: size,
|
|
537
408
|
type: computedStatus,
|
|
538
|
-
backgroundColor: backgroundColor,
|
|
539
|
-
foregroundColor: foregroundColor,
|
|
540
409
|
surfaceColor: surfaceColor,
|
|
541
410
|
"aria-label": statusLabel,
|
|
542
411
|
role: "img"
|
|
@@ -562,26 +431,25 @@ AvatarComponent.propTypes = {
|
|
|
562
431
|
AvatarComponent.defaultProps = {
|
|
563
432
|
size: 'medium'
|
|
564
433
|
};
|
|
565
|
-
|
|
434
|
+
const Avatar = AvatarComponent;
|
|
566
435
|
Avatar.Text = Text;
|
|
567
436
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
437
|
+
const StatusIndicator = forwardRef((_ref, ref) => {
|
|
438
|
+
let {
|
|
439
|
+
children,
|
|
440
|
+
type,
|
|
441
|
+
isCompact,
|
|
442
|
+
'aria-label': label,
|
|
443
|
+
...props
|
|
444
|
+
} = _ref;
|
|
445
|
+
let ClockIcon = SvgClockStroke;
|
|
446
|
+
let ArrowLeftIcon = SvgArrowLeftSmStroke;
|
|
577
447
|
if (isCompact) {
|
|
578
448
|
ClockIcon = SvgClockStroke$1;
|
|
579
449
|
ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
580
450
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}, [type]);
|
|
584
|
-
var ariaLabel = useText(StatusIndicatorComponent, {
|
|
451
|
+
const defaultLabel = useMemo(() => ['status'].concat(type || []).join(': '), [type]);
|
|
452
|
+
const ariaLabel = useText(StatusIndicator, {
|
|
585
453
|
'aria-label': label
|
|
586
454
|
}, 'aria-label', defaultLabel);
|
|
587
455
|
return React__default.createElement(StyledStandaloneStatus, _extends$4({
|
|
@@ -600,14 +468,13 @@ var StatusIndicatorComponent = forwardRef(function (_ref, ref) {
|
|
|
600
468
|
"aria-hidden": "true"
|
|
601
469
|
}) : null), children && React__default.createElement(StyledStandaloneStatusCaption, null, children));
|
|
602
470
|
});
|
|
603
|
-
|
|
604
|
-
|
|
471
|
+
StatusIndicator.displayName = 'StatusIndicator';
|
|
472
|
+
StatusIndicator.propTypes = {
|
|
605
473
|
type: PropTypes.oneOf(STATUS),
|
|
606
474
|
isCompact: PropTypes.bool
|
|
607
475
|
};
|
|
608
|
-
|
|
476
|
+
StatusIndicator.defaultProps = {
|
|
609
477
|
type: 'offline'
|
|
610
478
|
};
|
|
611
|
-
var StatusIndicator = StatusIndicatorComponent;
|
|
612
479
|
|
|
613
480
|
export { Avatar, StatusIndicator };
|